diff --git a/debian/changelog b/debian/changelog index 7e74939..49a5958 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +kylin-update-notify (1.3.2.1-ok16) nile; urgency=medium + + *BUG号:205057 【wlcom】【控制面板】【更新】开启控制面板-更新-有更新应用时通知按钮,系统更新弹窗没有显示在右下角 + *需求号:无 + *其他改动说明:无 + *影响域: 无 + + -- luoxueyi <luoxueyi@kylinos.cn> Fri, 15 Dec 2023 16:33:56 +0800 + kylin-update-notify (1.3.2.1-ok15) nile; urgency=medium * Add providers. diff --git a/debian/control b/debian/control index ccb0ba5..d9750fa 100644 --- a/debian/control +++ b/debian/control @@ -13,12 +13,13 @@ Build-Depends: debhelper-compat(=12), libgsettings-qt-dev, libqt5dbus5, nvme-cli, - libqapt-dev, + libqapt-dev, libkf5windowsystem-data, libkf5windowsystem-dev, libkf5windowsystem5, libkf5windowsystem-doc, libukui-log4qt-dev, + libkysdk-waylandhelper-dev Standards-Version: 4.1.3 Package: kylin-update-notify @@ -26,7 +27,8 @@ Architecture: any Section: universe/admin Priority: optional Depends: ${shlibs:Depends}, - kylin-system-updater ( >= 2.0.5.1 ) + kylin-system-updater ( >= 2.0.5.1 ), + libkysdk-waylandhelper Conflicts: kylin-background-upgrade,kylin-update-tray,kylin-update-notify-immutable Breaks: kylin-background-upgrade,kylin-update-tray Description: kylin update notify @@ -36,7 +38,8 @@ Architecture: any Section: universe/admin Priority: optional Depends: ${shlibs:Depends}, - kylin-system-updater-immutable + kylin-system-updater-immutable, + libkysdk-waylandhelper Conflicts: kylin-background-upgrade,kylin-update-tray,kylin-update-notify Provides:kylin-update-notify Replaces:kylin-update-notify diff --git a/debian/patches/0002-fix.patch b/debian/patches/0002-fix.patch new file mode 100644 index 0000000..dff9650 --- /dev/null +++ b/debian/patches/0002-fix.patch @@ -0,0 +1,7444 @@ +From: luoxueyi <luoxueyi@kylinos.cn> +Date: Fri, 15 Dec 2023 17:18:50 +0800 +Subject: fix + +--- + kylin-update-notify-immutable/README.md | 36 + + kylin-update-notify-immutable/checkUpdate.py | 20 + + kylin-update-notify-immutable/checkUpdate.pyc | Bin 0 -> 897 bytes + kylin-update-notify-immutable/data/Resources.qrc | 8 + + .../data/background_upgrade_icon.png | Bin 0 -> 5225 bytes + kylin-update-notify-immutable/data/close.png | Bin 0 -> 957 bytes + .../data/kylin-background-upgrade-manul.service | 10 + + .../data/kylin-background-upgrade-manul.timer | 12 + + .../data/kylin-background-upgrade-template.conf | 9 + + .../data/kylin-background-upgrade.desktop | 10 + + .../data/kylin-update.timer.conf | 6 + + ...kui.log4qt.kylin-background-upgrade.gschema.xml | 39 ++ + kylin-update-notify-immutable/data/update.png | Bin 0 -> 8074 bytes + kylin-update-notify-immutable/debian/changelog | 300 +++++++++ + kylin-update-notify-immutable/debian/control | 31 + + kylin-update-notify-immutable/debian/install | 2 + + kylin-update-notify-immutable/debian/postinst | 5 + + kylin-update-notify-immutable/debian/postrm | 7 + + kylin-update-notify-immutable/debian/rules | 8 + + kylin-update-notify-immutable/debian/source/format | 1 + + .../debian/source/options | 1 + + kylin-update-notify-immutable/env.pri | 4 + + .../kylin-update-notify-immutable.pro | 42 ++ + .../kylin-update-notify.desktop | 6 + + kylin-update-notify-immutable/src/core.cpp | 22 + + kylin-update-notify-immutable/src/core.h | 23 + + kylin-update-notify-immutable/src/main.cpp | 206 ++++++ + kylin-update-notify-immutable/src/traydbus.cpp | 450 +++++++++++++ + kylin-update-notify-immutable/src/traydbus.h | 160 +++++ + kylin-update-notify-immutable/src/trayicon.cpp | 35 + + kylin-update-notify-immutable/src/trayicon.h | 33 + + kylin-update-notify-immutable/src/updatehandle.cpp | 750 +++++++++++++++++++++ + kylin-update-notify-immutable/src/updatehandle.h | 105 +++ + kylin-update-notify-immutable/src/updatewidget.cpp | 664 ++++++++++++++++++ + kylin-update-notify-immutable/src/updatewidget.h | 131 ++++ + kylin-update-notify-immutable/src/updatewidget.ui | 21 + + .../translations/UapLBi.json | 1 + + .../translations/kylin-background-upgrade_bo_CN.qm | Bin 0 -> 2003 bytes + .../translations/kylin-background-upgrade_bo_CN.ts | 112 +++ + .../translations/kylin-background-upgrade_zh_CN.qm | Bin 0 -> 1305 bytes + .../translations/kylin-background-upgrade_zh_CN.ts | 151 +++++ + .../widgets/Button/button.pri | 6 + + .../widgets/Button/fixbutton.cpp | 36 + + .../widgets/Button/fixbutton.h | 21 + + kylin-update-notify-immutable/widgets/widgets.pri | 4 + + kylin-update-notify.pro | 4 + + kylin-update-notify/checkUpdate.py | 20 + + kylin-update-notify/checkUpdate.pyc | Bin 0 -> 897 bytes + kylin-update-notify/data/Resources.qrc | 8 + + .../data/background_upgrade_icon.png | Bin 0 -> 5225 bytes + kylin-update-notify/data/close.png | Bin 0 -> 957 bytes + .../data/kylin-background-upgrade-manul.service | 10 + + .../data/kylin-background-upgrade-manul.timer | 12 + + .../data/kylin-background-upgrade-silent.service | 10 + + .../data/kylin-background-upgrade-silent.timer | 12 + + .../data/kylin-background-upgrade-template.conf | 9 + + .../data/kylin-background-upgrade.desktop | 10 + + kylin-update-notify/data/kylin-update.timer.conf | 6 + + ...kui.log4qt.kylin-background-upgrade.gschema.xml | 39 ++ + kylin-update-notify/data/update.png | Bin 0 -> 8074 bytes + kylin-update-notify/env.pri | 4 + + kylin-update-notify/kylin-update-notify.desktop | 6 + + kylin-update-notify/kylin-update-notify.pro | 42 ++ + kylin-update-notify/src/core.cpp | 22 + + kylin-update-notify/src/core.h | 23 + + kylin-update-notify/src/main.cpp | 206 ++++++ + kylin-update-notify/src/traydbus.cpp | 450 +++++++++++++ + kylin-update-notify/src/traydbus.h | 160 +++++ + kylin-update-notify/src/trayicon.cpp | 35 + + kylin-update-notify/src/trayicon.h | 33 + + kylin-update-notify/src/updatehandle.cpp | 750 +++++++++++++++++++++ + kylin-update-notify/src/updatehandle.h | 105 +++ + kylin-update-notify/src/updatewidget.cpp | 664 ++++++++++++++++++ + kylin-update-notify/src/updatewidget.h | 131 ++++ + kylin-update-notify/src/updatewidget.ui | 21 + + kylin-update-notify/translations/UapLBi.json | 1 + + .../translations/kylin-background-upgrade_bo_CN.qm | Bin 0 -> 2003 bytes + .../translations/kylin-background-upgrade_bo_CN.ts | 112 +++ + .../translations/kylin-background-upgrade_zh_CN.qm | Bin 0 -> 1305 bytes + .../translations/kylin-background-upgrade_zh_CN.ts | 151 +++++ + kylin-update-notify/widgets/Button/button.pri | 6 + + kylin-update-notify/widgets/Button/fixbutton.cpp | 36 + + kylin-update-notify/widgets/Button/fixbutton.h | 21 + + kylin-update-notify/widgets/widgets.pri | 4 + + 84 files changed, 6611 insertions(+) + create mode 100644 kylin-update-notify-immutable/README.md + create mode 100755 kylin-update-notify-immutable/checkUpdate.py + create mode 100644 kylin-update-notify-immutable/checkUpdate.pyc + create mode 100644 kylin-update-notify-immutable/data/Resources.qrc + create mode 100644 kylin-update-notify-immutable/data/background_upgrade_icon.png + create mode 100644 kylin-update-notify-immutable/data/close.png + create mode 100644 kylin-update-notify-immutable/data/kylin-background-upgrade-manul.service + create mode 100644 kylin-update-notify-immutable/data/kylin-background-upgrade-manul.timer + create mode 100644 kylin-update-notify-immutable/data/kylin-background-upgrade-template.conf + create mode 100644 kylin-update-notify-immutable/data/kylin-background-upgrade.desktop + create mode 100644 kylin-update-notify-immutable/data/kylin-update.timer.conf + create mode 100644 kylin-update-notify-immutable/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml + create mode 100644 kylin-update-notify-immutable/data/update.png + create mode 100644 kylin-update-notify-immutable/debian/changelog + create mode 100644 kylin-update-notify-immutable/debian/control + create mode 100644 kylin-update-notify-immutable/debian/install + create mode 100755 kylin-update-notify-immutable/debian/postinst + create mode 100644 kylin-update-notify-immutable/debian/postrm + create mode 100755 kylin-update-notify-immutable/debian/rules + create mode 100644 kylin-update-notify-immutable/debian/source/format + create mode 100644 kylin-update-notify-immutable/debian/source/options + create mode 100644 kylin-update-notify-immutable/env.pri + create mode 100644 kylin-update-notify-immutable/kylin-update-notify-immutable.pro + create mode 100644 kylin-update-notify-immutable/kylin-update-notify.desktop + create mode 100644 kylin-update-notify-immutable/src/core.cpp + create mode 100644 kylin-update-notify-immutable/src/core.h + create mode 100644 kylin-update-notify-immutable/src/main.cpp + create mode 100644 kylin-update-notify-immutable/src/traydbus.cpp + create mode 100644 kylin-update-notify-immutable/src/traydbus.h + create mode 100644 kylin-update-notify-immutable/src/trayicon.cpp + create mode 100644 kylin-update-notify-immutable/src/trayicon.h + create mode 100644 kylin-update-notify-immutable/src/updatehandle.cpp + create mode 100644 kylin-update-notify-immutable/src/updatehandle.h + create mode 100644 kylin-update-notify-immutable/src/updatewidget.cpp + create mode 100644 kylin-update-notify-immutable/src/updatewidget.h + create mode 100644 kylin-update-notify-immutable/src/updatewidget.ui + create mode 100644 kylin-update-notify-immutable/translations/UapLBi.json + create mode 100644 kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.qm + create mode 100644 kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.ts + create mode 100644 kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.qm + create mode 100644 kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.ts + create mode 100644 kylin-update-notify-immutable/widgets/Button/button.pri + create mode 100644 kylin-update-notify-immutable/widgets/Button/fixbutton.cpp + create mode 100644 kylin-update-notify-immutable/widgets/Button/fixbutton.h + create mode 100644 kylin-update-notify-immutable/widgets/widgets.pri + create mode 100644 kylin-update-notify.pro + create mode 100755 kylin-update-notify/checkUpdate.py + create mode 100644 kylin-update-notify/checkUpdate.pyc + create mode 100644 kylin-update-notify/data/Resources.qrc + create mode 100644 kylin-update-notify/data/background_upgrade_icon.png + create mode 100644 kylin-update-notify/data/close.png + create mode 100644 kylin-update-notify/data/kylin-background-upgrade-manul.service + create mode 100644 kylin-update-notify/data/kylin-background-upgrade-manul.timer + create mode 100644 kylin-update-notify/data/kylin-background-upgrade-silent.service + create mode 100644 kylin-update-notify/data/kylin-background-upgrade-silent.timer + create mode 100644 kylin-update-notify/data/kylin-background-upgrade-template.conf + create mode 100644 kylin-update-notify/data/kylin-background-upgrade.desktop + create mode 100644 kylin-update-notify/data/kylin-update.timer.conf + create mode 100644 kylin-update-notify/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml + create mode 100644 kylin-update-notify/data/update.png + create mode 100644 kylin-update-notify/env.pri + create mode 100644 kylin-update-notify/kylin-update-notify.desktop + create mode 100644 kylin-update-notify/kylin-update-notify.pro + create mode 100644 kylin-update-notify/src/core.cpp + create mode 100644 kylin-update-notify/src/core.h + create mode 100644 kylin-update-notify/src/main.cpp + create mode 100644 kylin-update-notify/src/traydbus.cpp + create mode 100644 kylin-update-notify/src/traydbus.h + create mode 100644 kylin-update-notify/src/trayicon.cpp + create mode 100644 kylin-update-notify/src/trayicon.h + create mode 100644 kylin-update-notify/src/updatehandle.cpp + create mode 100644 kylin-update-notify/src/updatehandle.h + create mode 100644 kylin-update-notify/src/updatewidget.cpp + create mode 100644 kylin-update-notify/src/updatewidget.h + create mode 100644 kylin-update-notify/src/updatewidget.ui + create mode 100644 kylin-update-notify/translations/UapLBi.json + create mode 100644 kylin-update-notify/translations/kylin-background-upgrade_bo_CN.qm + create mode 100644 kylin-update-notify/translations/kylin-background-upgrade_bo_CN.ts + create mode 100644 kylin-update-notify/translations/kylin-background-upgrade_zh_CN.qm + create mode 100644 kylin-update-notify/translations/kylin-background-upgrade_zh_CN.ts + create mode 100644 kylin-update-notify/widgets/Button/button.pri + create mode 100644 kylin-update-notify/widgets/Button/fixbutton.cpp + create mode 100644 kylin-update-notify/widgets/Button/fixbutton.h + create mode 100644 kylin-update-notify/widgets/widgets.pri + +diff --git a/kylin-update-notify-immutable/README.md b/kylin-update-notify-immutable/README.md +new file mode 100644 +index 0000000..2620f7b +--- /dev/null ++++ b/kylin-update-notify-immutable/README.md +@@ -0,0 +1,36 @@ ++# kylin-background-upgrade ++ ++## 主要功能: ++ ++> 由后台定时器定时调起,访问源服务器检测是否有强制更新与可选更新 ++> ++> 检测到强制更新内容在后台升级,托盘不显示 ++> ++> 如果控制面板的自动检测更新关闭,则后台托盘程序不提醒用户更新 ++> ++> 检测到可选更新弹出交互界面 ++> ++> 点击同意更新按钮,调到控制面板更新页面,托盘程序退出 ++> ++> 点击暂不更新按钮,退出托盘程序 ++ ++## 注意事项: ++ ++> 如果托盘应该出现的情况下没出现,请查看是否收纳。在控制面板>个性化>显示在托盘上的图标中,把更新管理器托盘程序改成显示。 ++> ++> 如果托盘打印信息为:“源管理器updateSource is failed,连接失败,程序退出”,请查看源管理器是否启动,如已启动,请执行: sudo pkill -f start_dbus sudo ++> ++> killall kylin-software-properties-service sudo kylin-software-properties-service 后,再启动托盘程序。 ++> ++> 静默升级时,会在命令行打印信息 ++> ++> 右下角提示,在不进行其他操作时,不退出 ++> ++ ++## 启动定时器: ++ ++> 定时器与托盘服务名称: kylin-background-upgrade-timer.timer kylin-background-upgrade.service ++> ++> 查看定时器是否工作: systemctl --user status kylin-background-upgrade-timer.timer ++ ++ +diff --git a/kylin-update-notify-immutable/checkUpdate.py b/kylin-update-notify-immutable/checkUpdate.py +new file mode 100755 +index 0000000..23ce81a +--- /dev/null ++++ b/kylin-update-notify-immutable/checkUpdate.py +@@ -0,0 +1,20 @@ ++#!/usr/bin/python3 ++import apt ++import subprocess ++ ++def calculate_upgradable_pkgs(): ++ cache = apt.Cache() ++ pkgs_to_upgrade = [] ++ ++ for pkg in cache: ++ if pkg.is_installed and pkg.is_upgradable : ++ pkgs_to_upgrade.append(pkg.name) ++ ++ if cache.get_changes(): ++ cache.clear() ++ ++ if len(pkgs_to_upgrade) != 0: ++ subprocess.Popen('dbus-send --system --type=signal / com.kylin.update.notification.DownloadFinish', shell=True) ++ ++if __name__ == "__main__": ++ calculate_upgradable_pkgs() +diff --git a/kylin-update-notify-immutable/checkUpdate.pyc b/kylin-update-notify-immutable/checkUpdate.pyc +new file mode 100644 +index 0000000..d168620 +--- /dev/null ++++ b/kylin-update-notify-immutable/checkUpdate.pyc +@@ -0,0 +1,2 @@ ++� ++'�bc�����������@���s9���d��d�l��Z��d����Z�d����Z�e�d�k�r5�e����GHn��d�S(���i����Nc����������C���se���t��j����}��g��}�x3�|��D]+�}�|�j�r�|�j�r�|�j�|�j���q�q�W|��j����ra�|��j����n��|�S(���N(���t���aptt���Cachet���is_installedt ���is_upgradablet���appendt���namet���get_changest���clear(���t���cachet���pkgs_to_upgradet���pkg(����(����sT���/home/lxy/kylin-background-upgrade/OpenKylin/kylin-background-upgrade/checkUpdate.pyt���calculate_upgradable_pkgs���s���� c�����������C���s ���d�GHd��S(���Ns���haihaihai luoxueyi(����(����(����(����sT���/home/lxy/kylin-background-upgrade/OpenKylin/kylin-background-upgrade/checkUpdate.pyt���test���s����t���__main__(���R����R���R���t���__name__(����(����(����sT���/home/lxy/kylin-background-upgrade/OpenKylin/kylin-background-upgrade/checkUpdate.pyt���<module>���s��� +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/data/Resources.qrc b/kylin-update-notify-immutable/data/Resources.qrc +new file mode 100644 +index 0000000..d68938f +--- /dev/null ++++ b/kylin-update-notify-immutable/data/Resources.qrc +@@ -0,0 +1,8 @@ ++<RCC> ++ <qresource prefix="/json"/> ++ <qresource prefix="/"> ++ <file>update.png</file> ++ <file>background_upgrade_icon.png</file> ++ <file>close.png</file> ++ </qresource> ++</RCC> +diff --git a/kylin-update-notify-immutable/data/background_upgrade_icon.png b/kylin-update-notify-immutable/data/background_upgrade_icon.png +new file mode 100644 +index 0000000..19fb6d0 +--- /dev/null ++++ b/kylin-update-notify-immutable/data/background_upgrade_icon.png +@@ -0,0 +1,23 @@ ++�PNG ++ ++��� IHDR���,���,����Z���sRGB�������gAMA�����a��� pHYs��t��t�fx���IDATXGMY�{U�տ��c�m����06�c��i`v &.��� ���x6�ll�R�����$uT�$ے%g��8{�k������U�w��UU�+$.1.��6<u�z\T�~�tQ�)�� ++b��%J瑘:�Ʌ��Z�����+���0�t �<W������x]�p��B�%�s��~��%�|���P8�}��P���j\�I���(�42�%�+��b��C�%����9�f�!��A(9 $ o(-�@ ���D,SB|r�מ���"ҌD�<"\�2<��IF����E�������ɠ^�H�� H�9���L���[F� "�B� D�)D��6K�E�$ ++Ǡ��F8�n� ��,bY�/-��&K�ɞ�>q�D� 2S&�ȯ4qc{��O�~�,�.�A�>��0ʛM̞G2?�G�0��L� �bl#�Fc�"@�h���� �$�44�7��\٩dg�"�0���R�¼�]D�d�d=w�N�N{�` �8-���`Q�13w�X���l�@����� ��ɢA8G�`��*�H<�0C�9a�4!�ct4�x&���E�|��%%�0%"�שu��:��2`��%�v�&�>̈r?=w��kВ�p�IxB)��0_0�a|"���<b-�u��~�L��4ҙ���p�L�L ++�D�2 ++C�5hA�3�Hc�8�li��YD�A�2���܊+��� v�!#*QL�(�%Q<��9&Y�����K�Kv�P�rc�bƁ�������=Op�NБ2�Z'�G���[�籽8r�0jHģ� Δ�G�С�h���0��GL$�ʠˀ)}�A���"&gW8E��N���I��8|�W��x��g��ю��Ztw������[H���!� ���p���}�vtvu�����5��߇�����c\��G�l��wI�3E�"�����9�x:O�SԒd���r ���'H�N���`C�G���ՕhiiAWg7:�ݽhnl�SO���C�{5|��A������AwOz���mk[:�����4�"��b�ۀH.�Tv�NBi�ɶ���ˀ)nI2aw��OMΒ�A�ԟ5�S�ɂ�)�18�O���ف��v�U@6�nF�� ��uhjhFue :�;�ۻ �6mFO�Vl�|�ׇ;��P��i�s(C��#x��p��>�Ĵ��L�`��C�?3��4/�ȨN�ڔ���Tdد�)4�������!�]܋��n�|g{��vw������ޞ���f��;����2i�|%AVh��d�~?�6����3�Q��P��z�R,�0���F�ɠ�f����Yڒ���ȧ���CG[':;z�2���[������U�����0(��n�voR����f���H�&�5&Y�4� ����T�Z��,��K�N� yz�i���!� o�31��a� xxp�m�B@md�K�jo'PS+vp�w>����^~�e���صsY�Ac}#�9]d3�,�ٷ�%���G��&�Aw �� Zhpzu�\���0�01�7+���_�?2!B����ѯ����¡}�۷�SS3��S�hnh�}�܋�?��t<�lf^^;j����D�1;�;p@��P���4)�4�>O?��81��َ>��=��:+!g�Oƽ�a"�E�HY�Q�,����`��)vѩ��樃�����XIvPWS��65���.�WSS�I'ȍO����mw��� ++5��:To؈f������� �a���T2�dZ9Kuu JR&Iֺ&4���8�$�"&}i��kCE����<�8����j~4v�l�������B[��Sډ�n���S_�Z�c�v�ā�n��D�m��W��l����p��a$������ �/��-Q�V��r1�t��W^�%�D�t μ4Z �YE�rȝ^��Cv����W��z��� ]b_�vS�b����F�eu%�@��$�Z�$���c�~��z}%�z�-$��n�S�I���Ҧ��D���>����OW�$I�Q�9;s�cnv]��Ɉ����Ƈ4H'�jG'Aa���[��6���UaS~�^���� ��@��7_~��GmU�*"x5D��n�LJ>c"��8��$Ѵj*�S�H��9.��1܈�Wؽ�!ZW5YmU��bR���C�P�+P2�V�������賓�8q�{���E5���m�D$I}/��r�V�����& Lʯ��n�uM���eV�{��,;���t0����uAs��w9����"H�-��46���}}���سW1*!��p����j�r��-T�V��W�ʴ$e������h��y�A�ndi߱�.Y��!e��T�$�Z�Ed�s���E�u�����d��à<�l �y� Nk-��m v=�ƓI%aL��o��M^�N�ZB�E���[5(����z���9�-*D��յ�Xl,Vx��Wb�^��D:F�_��P�u2�z�q8 ځ�ıo��V+v뫫��"�jW��,��1I��~��r�pU´�~���&�E�O=�8�顗��Q ++����N���Y�h�3��)����Ԑ��CE���ƼeK��t��I�n�������'�[Í��xr�2���u��p�I�����+�v�ea��_�!��];���t��hy=�|Ԭ�O���r����fs!�J\1Β��a�����ㆋ�.�1��>z�=jn5ܬ�� c°���G>���WB@K���=Ʌ֦F�τ�_ا�I��=r}�.C/9x��a��&�%�a��˥T).,�l%=��{�7�s�a� ���ز���&r*����ܮX���oX�l�>�a�?��*�: ++��w�Tb����(-JZ�����vpUU �����'��=>8I����d���� �t.��Q+Y�8��}W� +++�WaX@�]��_W� ++X�M2��'����*����o�����s�uK�lTE�9:��y��D�lb�հl�<��~��8h�S@��g�Łɭ��m�0K�2��( �������J5���2(aS2|߳�)�d��R�!� ���=��w���GU��tѺ��X��_����˾܊�� �ؚĺu���7��:9�ba�B X�Y���f��trFEd(�U�%��JC°�[��&�<�ؓ��y� ++x)ºh\�W�J'��� ��>�MgT��Z��<k�,��|Κ57��O�(�6��*�qvlFa ŅK\�D`��qJ��p|��'Xw�Ů�taH� [�6)�Je[)�E�bueݒE�,3�������;��ʳ#�rc�PO�UjY��^<;e:ju�!�$&���0Wʓ�W�\a%�6�4��,#�6)YH�05H�kP�d+�{�����r�Yѷ��k�Uq�$�����CK����e�&�[���ˮZ��y+�;��t��V���0dC~�[��l� 8�%��� ++,v?ld�e��d�SXz��xP�'�PN���?>P�&�������It��K/�0�������ϔ���J�J���=���Nz��la�����eĥpH/K艹�p� �ڹZ��O��KU; �X�,"��⭿Y�-�}�Q����p�а�~tP�ˍ�vgE� ++�&2��K�S�g�V�����.��ZGɮ����!��E2w�O]�2��Rv���F�.�MIB�,a��մK��+�/��h&�U����W���VS�$!�ՋT����� �#��� 8����;j��\ X���/L/ �%`�%�� ++t�:����+p��w�L��N8iq�F�G�����s��#Gp��7�I|�l�n��>����x\y�z�/!��P���@keyD9ܶi�|�r5$f�Y�n��v���i����f/�|+4��C%�+�e'瑟g���U�� �j%�����u;��ѯ��-k~M@a"� b�ڬ��_G��<�m%� �6���@d&D�����T���:ս �2 ++��'��6��a��$Ɍ��7?ZiE���w��J(Şs|�,,j�fڊ �Cd����U2���X�v-j��hR�N��DW�R�����x� � ��٪zT�|8�##dt��;��d��� ۰�xS�4���{Ѽ�U%`y�/0�r+�@(w)^��+�����Q8�c�P?l���_�U\QW��lVW�*��� ǎ~�Մ�̹N����77���(�Z�݈{���{�b�2s�A�LR�c2���p5Oߍd�"�����>c�><} �,Y�����\:�Xr�k='l#���%�'x��Ʒ_}�� 7�Y�_���_���\E��a<�����gR���(~����_� ++��{�����}%�l�LnVWѮy`����4=7>>�D�2�W�8Ov� ++*|�t��e��ryR>��jz�k����V'�,�e24� ���������ݗT>y���,���S��v31�w��W�x��w��7���{��f��:�-_#Y��XR ���O0r�/��dX+�[�+N��� �y�|ّ7���j����6�itQkc���ɓ�S�1j�筃</�A50 9.[���FFhY6�����w�#��')E��F�����(FK�%K��B[����J��Ǚ���qp��*�ɳ���(�d��^���m6'��Y��2<ٯ�r,Um�`d�m�F9F04t ++#,J#�������@�y��^�s�{�5��T8wa�5��R���|��W��$�D���e�U�ǂ��J�p@,��s0u�"3�� ++�ĩ�a�:9�~��t���any~d� ++�p9�-ꜙ���T�j��i�]B|f��X&��Kd�y5I��]��(\U*��Qiy������ڗ�{�7����7;��&�,-�ĵ�xa��$W�a.��8�+Y�c`p'OYV(��U7l^�T�篠�x��?�X�˧.2J�t>+�0�+ ++p(�u�'e!�����A�GE���Fa�!Dd�=5-�$!'9���z�"��Kl�W09�Ț?����Y�R/���1��u�s+H�:�4�C��x��,R��pT���EL�"]�,]����^6 �����IEND�B`� +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/data/close.png b/kylin-update-notify-immutable/data/close.png +new file mode 100644 +index 0000000..ff39832 +--- /dev/null ++++ b/kylin-update-notify-immutable/data/close.png +@@ -0,0 +1,6 @@ ++�PNG ++ ++��� IHDR��� ��� ���szz����IDATx��W�RRa�Q���$���N��t���e# FFx �j3�������,=Cы��L5�7��c�0�̷��{�}|��S�?��G �Wpza��x�(��h�yTT�"��:!34��W�{�6�Q����`�($��ېj� �5�wҋS%X���V�����%1�CTg�X}���q��@(7�Je��>wAH��G Tj��[0��\����$*+!��u�T:��6�����J젺�)M��9� o� �2]F}�Ԇ�"�N+�p��fEbnq�u����ܳȨ�����ZD�����21�"��R���ȸ����;��P!��������PZ�C�iƓ`Yu\"��ѡ��la�E�ZrP#&�Qd݊/ëx ++r� *G[��r<'���(���CY�id���j�Lh���J��B�`��LF_����Q�XN�0�K�Mct����2 �7���a6X�T��2���ذ;���q6�lA����V0�m�uf��Ph�P4���3�ԂjR���U��#IH� G���ա�{Tq&��=��'�d4�w��p�D���}�7(gx�v?,� ݳ��:�LN���gx��3dG�`5h�*\# ++,%!��P�[���.|8J�P�fuMZ��aO����@ oA%g���=K�B��@�ia��}=��CL�)���fU���$u�z8�e?�]3a�S-��Ft�%?�`mT��C�/$�`B�@�lƸ�e^+���!X SN���|%��P���sf ++.�R��;� �>M�}���K�L, ��J����y�إL�~X�У�}��Z�4���z����9:S��d5���6�Ԩq��u�0�G �5���+�i��:�����(������+9N�����8.$~��F���O����IEND�B`� +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/data/kylin-background-upgrade-manul.service b/kylin-update-notify-immutable/data/kylin-background-upgrade-manul.service +new file mode 100644 +index 0000000..1eab582 +--- /dev/null ++++ b/kylin-update-notify-immutable/data/kylin-background-upgrade-manul.service +@@ -0,0 +1,10 @@ ++[Unit] ++Description=Kylin Background Upgrade ++ ++ ++[Service] ++Type=forking ++TimeoutStartSec=infinity ++ExecStart=/usr/bin/kylin-background-upgrade --check-upgrade ++ ++ +diff --git a/kylin-update-notify-immutable/data/kylin-background-upgrade-manul.timer b/kylin-update-notify-immutable/data/kylin-background-upgrade-manul.timer +new file mode 100644 +index 0000000..9455699 +--- /dev/null ++++ b/kylin-update-notify-immutable/data/kylin-background-upgrade-manul.timer +@@ -0,0 +1,12 @@ ++[Unit] ++Description=系统升级定时检测 ++ ++[Timer] ++OnStartupSec=10min ++OnUnitInactiveSec=10min ++AccuracySec=5s ++Unit=kylin-background-upgrade-manul.service ++ ++[Install] ++WantedBy=default.target ++ +diff --git a/kylin-update-notify-immutable/data/kylin-background-upgrade-template.conf b/kylin-update-notify-immutable/data/kylin-background-upgrade-template.conf +new file mode 100644 +index 0000000..0ac8fb8 +--- /dev/null ++++ b/kylin-update-notify-immutable/data/kylin-background-upgrade-template.conf +@@ -0,0 +1,9 @@ ++[Settings] ++powersize=1 ++setpackagesize=999999999 ++ ++[Timer] ++checkUpgradeTime= ++checkUpgradeTimeSlot=9:30-11:30 ++RandomizedExecute=True ++ +diff --git a/kylin-update-notify-immutable/data/kylin-background-upgrade.desktop b/kylin-update-notify-immutable/data/kylin-background-upgrade.desktop +new file mode 100644 +index 0000000..2e53db2 +--- /dev/null ++++ b/kylin-update-notify-immutable/data/kylin-background-upgrade.desktop +@@ -0,0 +1,10 @@ ++[Desktop Entry] ++Name=kylin-background-upgrade ++Name[zh_CN]=更新管理器托盘程序 ++Exec=/usr/bin/kylin-background-upgrade --check-immediately ++Icon=kylin-update-manager ++Type=Application ++X-UKUI-AutoRestart=true ++OnlyShowIn=UKUI ++X-UKUI-Autostart-Phase=Application ++NoDisplay=true +diff --git a/kylin-update-notify-immutable/data/kylin-update.timer.conf b/kylin-update-notify-immutable/data/kylin-update.timer.conf +new file mode 100644 +index 0000000..09880ea +--- /dev/null ++++ b/kylin-update-notify-immutable/data/kylin-update.timer.conf +@@ -0,0 +1,6 @@ ++[Timer] ++CheckUpgradeTime= ++CheckCompleted=false ++CheckUpgradeTimeSlot=09:30:00-11:30:00 ++GeneratRandomTime=true ++RandomizedExecute=true +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml b/kylin-update-notify-immutable/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml +new file mode 100644 +index 0000000..cc35fcd +--- /dev/null ++++ b/kylin-update-notify-immutable/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml +@@ -0,0 +1,39 @@ ++<schemalist gettext-domain="ukui-log4qt-kylin-background-upgrade"> ++ <schema id="org.ukui.ukui-log4qt-kylin-background-upgrade" path="/org/ukui/ukui-log4qt-kylin-background-upgrade/"> ++ <key type="s" name="log4j-handleqtmessages"> ++ <default>"true"</default> ++ <summary>hook qt messages</summary> ++ <description>Control if hook qt messages</description> ++ </key> ++ <key type="s" name="log4j-rootlogger"> ++ <default>"DEBUG,console,daily"</default> ++ <summary>config rootLogger's level and appenders</summary> ++ <description>config rootLogger's level and appenders:"level,appender"</description> ++ </key> ++ <key type="s" name="log4j-appender-daily-datepattern"> ++ <default>".yyyy-MM-dd"</default> ++ <summary>daily log file pattern</summary> ++ <description>set daily log file pattern format:one day</description> ++ </key> ++ <key type="s" name="log4j-appender-daily-layout-conversionpattern"> ++ <default>"%d{yyyy-MM-dd HH:mm:ss,zzz}(%-4r)[%t]|%-5p| - %m%n"</default> ++ <summary>set log message's format</summary> ++ <description>set log message's format</description> ++ </key> ++ <key type="i" name="delaytime"> ++ <default>3600</default> ++ <summary>set check log files delay time</summary> ++ <description>set check log files delay time</description> ++ </key> ++ <key type="i" name="maxfilecount"> ++ <default>7</default> ++ <summary>set log files count</summary> ++ <description>set log files count,unit s</description> ++ </key> ++ <key type="i" name="maxfilesize"> ++ <default>512</default> ++ <summary>set log files total size</summary> ++ <description>set log files total size, unit M</description> ++ </key> ++ </schema> ++</schemalist> +diff --git a/kylin-update-notify-immutable/data/update.png b/kylin-update-notify-immutable/data/update.png +new file mode 100644 +index 0000000..fe222a3 +--- /dev/null ++++ b/kylin-update-notify-immutable/data/update.png +@@ -0,0 +1,36 @@ ++�PNG ++ ++��� IHDR���`���`����w8��� pHYs������~���<IDATx��] tU���z�B:!D��"��#��(0��ˠ�˸�ί�"#"����:���������8��"*��DV�M�aIؒ��鵖��Z��/U�՝��9���E��-w���W�ɲ�������������:��{Q�����TA m���b�U�h9WUUE��3�f�c�]�lt}.�g#��t�s͙���T���?71�:�b�`��;�H��%��Q233QUUu։q�@!��<s���3 F���F�/27���*?9o�h�Y�����yyyC=^O{��ٜ��t��V�ɲ,��E�"�.?sfM�.�_�.hD� �Cf%bڴi|AA�����YVV��ҥ�кukaȐ!�Y�RF�OF��;q��7n��S�N�}YY�9��fP ++I�!KP?̗�9(�x��8p�: AkjjKJ/����%1�VG��#GbÆ ��s�;M�t�Y���q{;����Xda���o������ @W#�w��.���Ov�8q⬜��a���|DQ�(ɐ$ ���?��p�^!�$�bUe���,|g�CS��hĈi��d��梼������&�־�ݼ#�jQ�'õ�����;���������z�A!]G��Ï�zԨ��Ҽ��QBL�rxc�����ԈGJ ++ ++�}�kF���z�p8�b�eWOߡ�d�<N\q}�yv��dАO73�5j���i�|�屘�p��D"\.�"�k�2z��7D�Ѭ�.���n�&�2�����/yy��{M�]�!~��:N�:��f��DIB�gD<�n�<ΔW�3ẑ���;��pzR鏨��b�C��^���F�T�|��~ؾ�����0�9B��9�xDABH�B�TWu�r��g�%U�y'+pp\f�(��3��M9j�|�^���ӣ]��U_��uѣ�(;���9�|AĞ=���DM���!��?eʔ���$���φ������|�-����6U<�sDQĩӧp~��sMs8��رšyV��4L���˯�g�/�='�W����T��g�e�e��d~��P]S��`PPP�lR�'�v�ӊ�K���o3&�q��I�D�� ++�W��������������oKD|Z�^w�7���Y�� 1K|% U�m`���jǣ��C�?�����P8y䯩�q�Q ��H�} ++�/r���<֜���/E�d|Z�)�����dz'd��)E|0���LQ܌!ᤓ5�4�(�'��]��c��� b|bŢG�$\_$c q<x�βNf�H����G����8y|Z���B ��4���r!;;e�F�`TǢ��P�l���F�N�矯�����`D1dJ��f�{BZ �l�R�Fuq8�0t��J��_���" �"پ�Bp�U <X?W��l��}��a@i(����_�P $$��ѭ��y�^��W���D�t�]���W~�g��xU��x��&�2�#�_��N��[Ɩ��?N�gm;_mڶEQ�l�Q�����c�_�<yrBd Sz_�t�CS��7�ˋ/�]�I�h45��|�x8����2��g_�iI���~�x�'����6�� ��4�Қ�(+�2���۶mK�;����Y�ϔ���٥6Ii�zn�`��M�� 9����]�ߏ��o��an<Kj�%��Ͻ�U���`-a�D�;�<��}��W����o��eeu!�m�z�jm]��l4�K3�S�/�^�@�X��kK�E!��������`DW�m۶�d�D�5+���� � ��@0�l�4� �l��<_g*��!��p�a��"o�ك���%U1�����ׁ��-�W֯��h�7���K�-++���� ++b�?.�C��N�Y����r#��y�p6 3�u�0���'*#- ��Uַ ++�������8u�$j���ϧxM;v���ޛ�"w$� moA����|rEE�!��$�������+r�����jm���j��S�J'��N5�F����x�~;�x!p��q �ژ��t:��wZ��S�!���N%p��������?��[o.�v�痩y�G2+��y=��U�+?�lC������\��G o�xecPV���}L��x��OaN�J���r�01���A ;�ٍ,�t9�~�|ԗ��J����4)��� K�h�q��9s������6j�����QCt?�x�5$�����-��FF�V����~rF��2��F�tNU�n�pr�y\�A�WG�XL@zVz��w�t��� ++��~2�lVs'��Ѹ?����O�;[���T ++ ���\��}!zL�=�!> ++�ʕ1�'�q-�UQ���,����2Jkx ��8U2XuGƌ�Ȉɘ�]Ƅ֩;d{���پ������#�n��d#�'sܸ�]�|��ŕ ��,~v1�U�<ʂ@K/�6]V⤽�j`���C2P�~f7�|��[Z���~R�g�|wLĦR�P�l���|�vq��y� �N�x|�Jbk2y�˩rmD|QF&t�Tq�}-]��\�t�d)���1�����6���A\PG��|�G�z���{n���# "�k�9�5�V3]Ӹ�ZR�;�������]R�Kb(L�j�Gw]����.Tƀ��y��& N����ί[���+���q;��^�.��ݔDtW�t�����Ⴊ��%���ov:UQ�:��p����Á?�WJ��I[�ȍ�������^��qx����&�����������+D�ȵ�PvVZ4-�ۋ�F���I˧��~���F���0E��2�>�i���UF���Ņ1��W[��|��$�x7�O�J�3I@���D��D}Z����D��������3X8� ++d<���~��������_F�FC��HW ���#3��1)x��(f���*���:*��"� ++K����(�ެFö�P���"�ޢ�- ��٣ǵ�>��Y�C�C���������z ���y5#i7�CD�Z5����1�=���1���i�Oô�cX�_���k;��� 6�}N/���Uvvvo P]�O���G k�NW��ƚ�%G���b�j$dgɘ�WD�_�c+����:�VR��K���\��JszJh�IJ0ְ6�b�|ZK\����fj(�|�ي�DbB¹��}�� OV<���ed�8ܿ4lױ����Z`u5�� ++�� ++��X��"j�`D=�2��9����A�Ɯ%m|8v�Kx;���u�S*�7"�Ӡ�3���S�N��l hC���,��ܟ)c�2��%�m~mT3 ({�p����t��O3�e��s�V���#ؼ�BQ��y7�1m*��p���{;1�#��la��! ��L'T�d�,���m��})d8�3��w6�l��NQ���q@�F�N"�� r�8T���wQ� �wN�Ŷ zta�k���6\��Qy[n�W����� �m�忶�p{/�w1{��8JF}�Hq(�U��>�>����i�6.9�('q�!�j<ϧ��*��x�(��* fbM8)�b\>��T@Q�"Jh8��Ċ}�yy�9���=�����6� ++�jt}k[YE��|ugጌV�D�ss\a����4F�4PA<sͳj��re�-r�e���zd ++�~6�I�ZP�ѩ��,'�h��&�̠Fĥ�yL�]l��A^�Mp0l���SP�0����w���P�\F��"V��5ڝ8�C�`e���\�L��ы2>& ]����F�K�U�cW�q^GbRNF���2m���7n�T셕Q�_���'�{鴴dxd �n��%3�ە�x@�;'F��B�hTL��GiYN�\�K#�I��.��]v�Z�� ��A.�<\�s ��{c�Z�h���9\u��p���Ǭ�1n�*)���@�4PA�K��`l�77a�\�>Z]Q#z�^$u�`���=�щbQ%̍� 0E>� Т2f̘�٤���>� ++��E��c�~%�i��O�ِ kL`B�JQ�g��O@�KAF�t���A�� ?>`����������y��)�acMN��i��+�#{�B֠�H}|-}��Yu@b0� ����]�jc)��VԺ2ʩ��D��a��P�c��qC���%�|<�zq�Q]�(�Mm��zȈ�u�0KG��?Yˣ�eGjO,�5�<� ��æ��}�hK�Y ����z�n$5��� 0S�C"0�d�F�P�0�G�q����n>�ҹKK������p�Ө�شCV���/��/V��k:��ֹQ��(C��u]G�h4J���wx A6�U�1ts�v�����B^�f�@���ᕱ�o��B-ݖ1F����弱�$���8p�"*#��!�2a�:�I�}�T^~�Į���$��Y��UN�à�ܟ8T�@UT�}\@�u�����}_�.�U�8�;&�K�9l8沘/�}�c���z����Q�N|Yt.ȴ�J�i;ԞP���/�Qt��1�V����n�>��hɋ�>6���gI��l:P�o�5�r�7|;�%\�ҁŇj����RK���Pr�w����ϝ�$����ճ!����%�/��� ++��]}��fByvS�m�f�X��}�#��&f}ښg/��|uҁ+��0�3���9d{ա�a`�A_�Q��R�aa c�������`�j��i��߹!_�8E���A��E���@S�.y�㮝�G��p0HZ����`Ÿ�<�ī?�0���q��a��h6aq1��U#�Ԃ:���D ���q/>>��`��� ++�����Q�Գ���-�s��Y�8T� �>���������1K��� ++M ++�8����a��@ܻ��)�8��wɝ�I+����1�]����L��MK��ji�4�ӳ��(3�%=u�F=u&��(ۗ��\�-�����F��P)81�.��1}j:�;��~55�.�G1�f':��ٍ������MԪ{je��x����ӻ�ċ� ++b�P�:�۷}�h���Qu�%�Z"��9l��ū�x���½w���/��d@8�P�_��\X�ׁ%{����N�i%V��^������n`��E3x�"��o�ٝ>7pULj��b7b��:�s�O�?w90m����M6�Kc��AVςy���8�\��[�N<�M�J|'�BP�pY�����lg�����8�4�*��Oäk%�9�Ҏ|n۹�Ռ��\�A��qϒ,��R7�z�e�����d�ﴌ�7po/R�"��(=��<�q�~rq=Ȫ��1� �?)]Qqo�%��TT���2��-����ڃ5�e�5S���ӗ��r3 ȵV��F�Q�T�H=GMi��|�h�C�H��ڄIi�I 8%Z h��' � ����|��;�z��Σ��,�{�͏�-����b�K�z�IP�7��� ��5��33�<����z�� �Nf|QC���ks�Ю����%���ߺy�;# �Z��P�\�R��쎝:�^����D���p��эM?��?�#�����$�)��O8"��V9�z��v(��u�vm7uQm��Ro}A���J@3G���hׅC�^<���A��j��9�������\L+���6�#@�2�e��q����\Bߋ�xfx�6��5f�ț���}��ŴZ ++�]���R�� m�w�9(�4bTsh��1��t���ei�`��sdH-�u ++����^(4X|�����ƫ���������P�Cuy���|��'$xD �� ��_ďc�+8t��kF�M!��:�!�)Qg���G�iv K'�W����w�؞� ���M2q�\gZ���� ���N����^��E���E�'vsaW�K=Z�(#|H��K$�����Z[ܝ&O��_��|�F���"dvH��|�WSC����,�br� l ++"{Շ �0�J���frC�WB��Wb�|�B8.���������mip���5��fx��:@�/D�Q�E43�;���9A�l��F��ǚ5�~gJ�h�fjxYjN����*o��nu[S)㖱A�ϒ��^���BO�ٰ�T{B�����1��~�� ++�~���֭�Wۍ_�ڝŐ�$�g�IYOfpmU��I��i�w���˕��p��|�s `��rEu P��=�Q ��)��Щ�`?pk������ƚD���gfL����V���� 2E���P�bL���+�����q;-e�~ ++-��������7_ڷwO9Ť���(� @KA�zs��-�7�i�螨�,�l� @�TCŘ���#%��~d�B��r6Z��ܹ������V/ܯ@��� �H�HI���B���Ь�,�8S~�1+8I���EmDY��C2p@�K�g��G�z��VPY�D�?�C�L�WT}�����p��4F�N��T�A�=>S{C����3O��ʫ���q�������s�8u���Y<@�2bq��J�t�m��;����J*9,����6C(�xf�]�W��g�����b��N}����g�����o��0SAR 0v�V�q7m\tG�D"�p*�[�B*��y"��A5C������ ++<rE�|�{�����Q|�d9.̌ԥd4�Z�O����N��$�"�<5�ɂ5_��dTm�LUcJ�h/�10�J�D,�dɾ��~�A*���:�G��bj�zai � ++�7�a��jdy��"�-�}5��Q��:O5�+�AU]uȋ����ϊ������HZ!����H��2�ό�� {�tu���P�g>��𱿹m�Հf����+��ذ=�� '��(��xy��:�ۤYS���ך���L�3�2����C���bᓏ�>c��ϵH���xY�xP�#ao�QϑhFΘ����nj��M� ++�mtc��4��r)��?���%�!�����;�27�� ++��Kch�m�S :�g�,�9}� ++ԟP*(���v�Ɣ��)J�i�F��ڵ���퉧�{0U"4b��`��̞�����Ѹ�FS=���g]O[�ò� �'���������Ь_���Ͼ�ҽ��-Z7!N�:�+*�=��C[��������T��g�U=:�~���=�槫$� +����7�ɿ�Я��+����۶~�����Aq��S�&~R�G2��|\ � <�]���\����^��8����f9���Y��@�b����`��4d(����I]�z��{chiЉ�_{�۵�}�ɿ\߷߀!�2����臇��V�R9A����=��1�(1ϓ�����%�s?��ȵ�_��m'Oy亞���dJ(,ܽ���_�q��cT��b6�l�=1��+��8��L��S����?����! ++������_�i��z R���I�%5�H��0'�n�6x ����˺��ɗ_9t���e#��_�n���c��#G����Ex�b�EA~c_�ۨ��}��F�/C���=�Q�p��!]/�E��m��wLybPVz�h���wnX�m�g˗2�n�ft�Q~�Q���Y{��p�n�.�S�Z�m�]]��pan��99�ͳ|��DR�����**�%����>����TB1F嵢�n�w:�@g7S�v̠��% �<C��FR\TsRj��Gt�Z_�Ν"�D�M���(��0C Z���o�>7��T ^e�3y$��.�w1��rR�"�@@� ��`���w��`�O����&j�6�.����'����(�ؿ���`�K�����@�K��p= g����P�h'c?x���X$ ��m�g�:�\�g�����Y�Uu�R�J��Gb~S'MM�����:B�f���6�t��Ȍ$�\- \f��O��4�5�@?���Q.,���À�4Y�`D��76�J�:t�<&FD����_�`�kF�&�7����4�dV}�Z����IEND�B`� +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/debian/changelog b/kylin-update-notify-immutable/debian/changelog +new file mode 100644 +index 0000000..d51510b +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/changelog +@@ -0,0 +1,300 @@ ++kylin-update-notify (1.3.2.1-ok8) yangtze; urgency=medium ++ ++ *BUG号:无 ++ *需求号:无 ++ *其他改动说明:适配新版本updater ++ *影响域: 无 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Fri, 01 Dec 2023 14:16:50 +0800 ++ ++kylin-update-notify (1.3.2.1-ok7) yangtze; urgency=medium ++ ++ * remove depend kylin-software-properties . ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Mon, 12 Jun 2023 14:08:00 +0800 ++ ++kylin-update-notify (1.3.2.1-ok6) yangtze; urgency=medium ++ ++ * Fix the upload error. ++ ++ -- handsome_feng <jianfengli@ubuntukylin.com> Fri, 09 Jun 2023 15:55:18 +0800 ++ ++kylin-update-notify (1.3.2.1-ok5) yangtze; urgency=medium ++ ++ *BUG号:#issues/I784B9 【arm】【树莓派】【系统更新】控制面板“有更新应用时通知”是关闭的,会自动弹出“检测到有系统更新”弹窗 ++ #issues/I7847A 【arm】【树莓派】【系统更新】点击“检测到有系统更新”弹窗的“立即更新”按钮,无法跳转到控制面板系统更新页面 ++ #issues/I76LO5 【wayland】【控制面板】【更新】更新提示弹窗未显示在屏幕右下角 ++ #issues/I768RV 【控制面板】【更新】推迟提醒计时器时间错乱,在未到推迟时间又重新出现弹窗 ++ #issues/I74KO7 【控制面板】【更新】开启"有更新应用时通知",在通知弹窗中点击"立即更新"无法跳转到控制面板-更新界面 ++ ++ *需求号:无 ++ *其他改动说明:无 ++ *影响域: 无 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Fri, 09 Jun 2023 10:13:18 +0800 ++ ++kylin-update-notify (1.3.2.1-ok4) yangtze; urgency=medium ++ ++ *BUG号:135671 【wayland】【更新升级】设置推迟时间不生效,到推迟的时间后没有再次出现自动更新弹窗 ++ *需求号:无 ++ *其他改动说明:无 ++ *影响域: 无 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Tue, 18 Apr 2023 09:46:45 +0800 ++ ++kylin-update-notify (1.3.2.1-ok3) yangtze; urgency=medium ++ ++ * patch from zhangdongwei ++ ++ -- Xie Wei <xiewei@kylinos.cn> Thu, 21 Jul 2022 19:41:21 +0800 ++ ++kylin-update-notify (1.3.2.1-ok2) yangtze; urgency=medium ++ ++ * add BR: python2.7-dev ++ ++ -- Xie Wei <xiewei@kylinos.cn> Thu, 21 Jul 2022 18:26:14 +0800 ++ ++kylin-update-notify (1.3.2.1-ok1) yangtze; urgency=medium ++ ++ * build for openKylin ++ * 修改为quilt格式 ++ ++ -- Xie Wei <xiewei@kylinos.cn> Thu, 21 Jul 2022 18:08:51 +0800 ++ ++kylin-update-notify (1.3.2.1) yangtze; urgency=medium ++ ++ *BUG号:无 ++ *需求号:无 ++ *其他改动说明:无 ++ *影响域: 系统更新-静默升级 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Thu, 21 Jul 2022 17:57:12 +0800 ++ ++kylin-background-upgrade (1.3.2.1) v101; urgency=medium ++ ++ *BUG号:121781 【在线更新】中文环境下,静默更新完成后,右上角及侧边栏通知未汉化 ++ 122046 【更新升级】配置静默推送,但是仓库源不存在推送的包,后台日志有报错,功能未见异常 ++ 122183 【在线更新】上午8-12点外仍会弹出更新通知 ++ 122425 【在线更新】设置每隔1min38s弹出通知,在弹出的通知弹窗中点击推迟,1min38s后再次弹出更新通知 ++ *需求号:无 ++ *其他改动说明:无 ++ *影响域: 系统更新-静默升级 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Thu, 07 Jul 2022 18:34:30 +0800 ++ ++kylin-background-upgrade (1.3.2.0) v101; urgency=medium ++ ++ *BUG号:无 ++ *需求号:# 12723 【更新升级】静默升级接口重构 ++ # 13511 【更新升级】系统可选更新通知机制优化 ++ *其他改动说明:更新kylin-system-updater后端接口 ++ *影响域: 系统更新-静默升级 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Mon, 06 Jun 2022 16:24:14 +0800 ++ ++kylin-background-upgrade (1.3.1+0527kord0) v101; urgency=medium ++ ++ *BUG号:无 ++ *需求号:无 ++ *其他改动说明:更新kylin-system-updater后端接口 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Fri, 20 May 2022 15:58:48 +0800 ++ ++kylin-background-upgrade (1.3.1+0520) v101; urgency=medium ++ ++ *BUG号:无 ++ *需求号:无 ++ *其他改动说明:更新kylin-system-updater后端接口 ++ ++ -- luoxueyi <luoxueyi@kylinos.cn> Fri, 20 May 2022 15:58:48 +0800 ++ ++kylin-background-upgrade (1.3.1+0125.2) v101; urgency=medium ++ ++ *BUG号:104479 ++ *需求号:无 ++ *其他改动说明:无 ++ ++ -- wanghailiang <wanghailiang@kylinos.cn> Tue, 25 Jan 2022 10:11:46 +0800 ++ ++kylin-background-upgrade (1.3.1+0111.1) v101; urgency=medium ++ ++ *BUG 号: 102451 ++ *需求号:无 ++ *其他改动说明:无 ++ ++ -- liyanda <liyanda@kylinos.cn> Tue, 11 Jan 2022 18:05:55 +0800 ++ ++kylin-background-upgrade (1.2.1+0830.4hw1) v101.hw; urgency=medium ++ ++ *BUG 号:无 ++ *需求号:无 ++ *其他改动说明:测试设置固定值的窗口出现位置 ++ ++ -- liyanda <liyanda@kylinos.cn> Thu, 29 Apr 2021 19:24:32 +0800 ++ ++kylin-background-upgrade (1.2.1+0331.1) v101; urgency=medium ++ ++ * 更新界面拉起控制面板异常问题 ++ ++ -- liyanda <liyanda@kylinos.cn> Wed, 31 Mar 2021 19:26:45 +0800 ++ ++kylin-background-upgrade (1.2.1+0324.1) v101; urgency=medium ++ ++ * 适配高分屏 ++ ++ -- liyanda <liyanda@kylinos.cn> Wed, 24 Mar 2021 18:53:48 +0800 ++ ++kylin-background-upgrade (1.2.1+0320.5) v101; urgency=medium ++ ++ * 优化弹窗布局 ++ ++ -- liyanda <liyanda@kylinos.cn> Sat, 20 Mar 2021 16:23:38 +0800 ++ ++kylin-background-upgrade (1.2.1+0316.3) v101; urgency=medium ++ ++ * 更改定时器生成机制 ++ ++ -- liyanda <liyanda@kylinos.cn> Mon, 15 Mar 2021 12:37:14 +0800 ++ ++kylin-background-upgrade (1.2.1+0312.2) v101; urgency=medium ++ ++ * 增加推迟提醒功能 ++ ++ -- liyanda <liyanda@kylinos.cn> Fri, 12 Mar 2021 15:07:45 +0800 ++ ++kylin-background-upgrade (1.2.1+0303.1) v101; urgency=medium ++ ++ * 更新文件锁内容 ++ ++ -- liyanda <liyanda@kylinos.cn> Wed, 03 Mar 2021 13:49:46 +0800 ++ ++kylin-background-upgrade (1.2.1+0204.2) v101; urgency=medium ++ ++ * 更改托盘图标提示方式 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Thu, 04 Feb 2021 11:32:41 +0800 ++ ++kylin-background-upgrade (1.2.1+0201.1) v101; urgency=medium ++ ++ * Change file lock path ++ * 更改文件锁路径 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Mon, 01 Feb 2021 15:46:09 +0800 ++ ++kylin-background-upgrade (1.2.1+0129.1) v101; urgency=medium ++ ++ * Modify the problem of abnormal installation ++ * 修改安装异常的问题 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Fri, 29 Jan 2021 13:48:21 +0800 ++ ++kylin-background-upgrade (1.2.1+0126.1) v101; urgency=medium ++ ++ * 更改后台更新错误处理机制 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Tue, 26 Jan 2021 16:42:59 +0800 ++ ++kylin-background-upgrade (1.2.1+0122.1) v101; urgency=medium ++ ++ * 更改托盘选择页面的ui ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Fri, 22 Jan 2021 15:13:40 +0800 ++ ++kylin-background-upgrade (1.2.1+0120.4) v101; urgency=medium ++ ++ * 更改消息通知逻辑 ++ * 更改环境变量 ++ * 更改托盘图标右键内容 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Wed, 20 Jan 2021 11:40:40 +0800 ++ ++kylin-background-upgrade (1.2.1+0119.3) v101; urgency=medium ++ ++ * Modify message notification icon ++ * 修改消息通知图标 ++ ++ * Standardize message notification content ++ * 规范消息通知内容 ++ ++ * Increase the focus on source management ++ * 增加对源管理器重连机制 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Tue, 19 Jan 2021 11:05:27 +0800 ++ ++kylin-background-upgrade (1.2.1+0118.1) v101; urgency=medium ++ ++ * 增加对更新管理器的启动的判断 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Mon, 18 Jan 2021 17:41:38 +0800 ++ ++kylin-background-upgrade (1.2.1+0115.3) v101; urgency=medium ++ ++ * 增加中英文翻译 ++ * 更改单例方式 ++ * 更改连接dbus的方式 ++ * 修改server参数,调整定时器调用方式 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Fri, 15 Jan 2021 11:13:31 +0800 ++ ++kylin-background-upgrade (1.2.1+0112.1) v101; urgency=medium ++ ++ * 修改读取更新管理器数据库地址 ++ * 修改获取源管理器返回值类型 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Tue, 12 Jan 2021 17:27:38 +0800 ++ ++kylin-background-upgrade (1.2.1+0111.1) v101; urgency=medium ++ ++ * 增加电量与包大小的判断 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Mon, 11 Jan 2021 13:38:20 +0800 ++ ++kylin-background-upgrade (1.2.1+0109.4) v101; urgency=medium ++ ++ * 修改了电量错误处理 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Sat, 09 Jan 2021 13:26:51 +0800 ++ ++kylin-background-upgrade (1.2.1+0108.1) v101; urgency=medium ++ ++ * 重新命名托盘 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Fri, 08 Jan 2021 12:15:37 +0800 ++ ++kylin-background-upgrade (1.2.1+0106.3) v101; urgency=medium ++ ++ * 增加文件锁的错误处理 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Wed, 06 Jan 2021 14:29:43 +0800 ++ ++kylin-background-upgrade (1.2.1+0104.8) v101; urgency=medium ++ ++ * 增加文件锁 ++ * 增加消息通知功能 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Mon, 04 Jan 2021 10:18:57 +0800 ++ ++kylin-background-upgrade (1.1.1+1231.2) v101; urgency=medium ++ ++ * 新增托盘静默更新气泡提示 ++ * 重构dbus连接代码 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Thu, 31 Dec 2020 14:43:43 +0800 ++ ++kylin-background-upgrade (1.1.1+1230.5) v101; urgency=medium ++ ++ * 更改获取包列表的方式 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Wed, 30 Dec 2020 20:53:18 +0800 ++ ++kylin-background-upgrade (1.1.1+1229.6) v101; urgency=medium ++ ++ * 更改任务栏显示的问题 ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Tue, 29 Dec 2020 17:00:00 +0800 ++ ++kylin-background-upgrade (1.1.1+1229.1) v101; urgency=medium ++ ++ * firstlog ++ ++ -- liyanda1234 <liyanda@kylinos.cn> Wed, 23 Dec 2020 15:18:22 +0800 +diff --git a/kylin-update-notify-immutable/debian/control b/kylin-update-notify-immutable/debian/control +new file mode 100644 +index 0000000..dd7c4ea +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/control +@@ -0,0 +1,31 @@ ++Source: kylin-update-notify ++Maintainer: kylin <kylin@kylinos.cn> ++Section: universe/admin ++Priority: optional ++Build-Depends: debhelper-compat(=12), ++ qtbase5-dev, ++ libxml2-dev, ++ libxml2, ++ libqt5svg5-dev, ++ libglib2.0-dev, ++ qttools5-dev-tools, ++ qtchooser, ++ libgsettings-qt-dev, ++ libqt5dbus5, ++ nvme-cli, ++ libqapt-dev, ++ libkf5windowsystem-data, ++ libkf5windowsystem-dev, ++ libkf5windowsystem5, ++ libkf5windowsystem-doc, ++ libukui-log4qt-dev, ++Standards-Version: 4.1.3 ++ ++Package: kylin-update-notify ++Architecture: any ++Section: universe/admin ++Priority: optional ++Depends: ${shlibs:Depends}, ++ kylin-system-updater ( >= 2.0.5.1 ) ++Breaks: kylin-update-tray ++Description: kylin background upgrade +diff --git a/kylin-update-notify-immutable/debian/install b/kylin-update-notify-immutable/debian/install +new file mode 100644 +index 0000000..2d1cc74 +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/install +@@ -0,0 +1,2 @@ ++kylin-update-notify.desktop /etc/xdg/autostart/ ++checkUpdate.py /usr/share/kylin-update-notify +diff --git a/kylin-update-notify-immutable/debian/postinst b/kylin-update-notify-immutable/debian/postinst +new file mode 100755 +index 0000000..18fefff +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/postinst +@@ -0,0 +1,5 @@ ++#!/bin/bash ++ ++systemctl --user daemon-reload ++systemctl --global enable kylin-background-upgrade-silent.timer ++systemctl --global enable kylin-background-upgrade-manul.timer +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/debian/postrm b/kylin-update-notify-immutable/debian/postrm +new file mode 100644 +index 0000000..c9010ea +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/postrm +@@ -0,0 +1,7 @@ ++#!/bin/bash ++ ++#if [ ! -f "/etc/systemd/user/kylin-background-upgrade-timer.timer" ];then ++#echo "remove_timer" ++#else ++#rm /etc/systemd/user/kylin-background-upgrade-timer.timer ++#fi +diff --git a/kylin-update-notify-immutable/debian/rules b/kylin-update-notify-immutable/debian/rules +new file mode 100755 +index 0000000..9e47e96 +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/rules +@@ -0,0 +1,8 @@ ++#!/usr/bin/make -f ++ ++export DEB_BUILD_MAINT_OPTIONS = hardening=+all ++export QT_SELECT := qt5 ++ ++%: ++ dh $@ ++ +diff --git a/kylin-update-notify-immutable/debian/source/format b/kylin-update-notify-immutable/debian/source/format +new file mode 100644 +index 0000000..89ae9db +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/source/format +@@ -0,0 +1 @@ ++3.0 (native) +diff --git a/kylin-update-notify-immutable/debian/source/options b/kylin-update-notify-immutable/debian/source/options +new file mode 100644 +index 0000000..06e1ae9 +--- /dev/null ++++ b/kylin-update-notify-immutable/debian/source/options +@@ -0,0 +1 @@ ++include-binaries +diff --git a/kylin-update-notify-immutable/env.pri b/kylin-update-notify-immutable/env.pri +new file mode 100644 +index 0000000..673db9f +--- /dev/null ++++ b/kylin-update-notify-immutable/env.pri +@@ -0,0 +1,4 @@ ++PROJECT_ROOTDIR = $$PWD ++ ++INCLUDEPATH = ./widgets ++include(./widgets/widgets.pri) +diff --git a/kylin-update-notify-immutable/kylin-update-notify-immutable.pro b/kylin-update-notify-immutable/kylin-update-notify-immutable.pro +new file mode 100644 +index 0000000..450bff3 +--- /dev/null ++++ b/kylin-update-notify-immutable/kylin-update-notify-immutable.pro +@@ -0,0 +1,42 @@ ++QT += core gui dbus network KWindowSystem sql ++greaterThan(QT_MAJOR_VERSION, 4): QT += widgets ++ ++CONFIG += c++11 link_pkgconfig ++ ++# 项目名 ++TARGET = kylin-background-upgrade ++TEMPLATE = app ++ ++LIBS +=-lukui-log4qt ++ ++include(env.pri) ++INCLUDEPATH +=./widgets ++ ++SOURCES += \ ++ ./src/core.cpp \ ++ ./src/main.cpp \ ++ ./src/traydbus.cpp \ ++ ./src/trayicon.cpp \ ++ ./src/updatehandle.cpp \ ++ ./src/updatewidget.cpp ++ ++HEADERS += \ ++ ./src/core.h \ ++ ./src/traydbus.h \ ++ ./src/trayicon.h \ ++ ./src/updatehandle.h \ ++ ./src/updatewidget.h ++ ++TRANSLATIONS += translations/kylin-background-upgrade_zh_CN.ts \ ++ translations/kylin-background-upgrade_bo_CN.ts ++ ++PKGCONFIG += gsettings-qt kysdk-waylandhelper ++ ++FORMS += \ ++ ./src/updatewidget.ui ++ ++RESOURCES += \ ++ ./data/Resources.qrc ++ ++DISTFILES += \ ++ ./data/update.png +diff --git a/kylin-update-notify-immutable/kylin-update-notify.desktop b/kylin-update-notify-immutable/kylin-update-notify.desktop +new file mode 100644 +index 0000000..72d60c6 +--- /dev/null ++++ b/kylin-update-notify-immutable/kylin-update-notify.desktop +@@ -0,0 +1,6 @@ ++[Desktop Entry] ++Name=update-notify-force ++Exec=/usr/bin/kylin-update-notify --check-upgrade ++Type=Application ++NoDisplay=true ++Comment=update-notify-force +diff --git a/kylin-update-notify-immutable/src/core.cpp b/kylin-update-notify-immutable/src/core.cpp +new file mode 100644 +index 0000000..269318f +--- /dev/null ++++ b/kylin-update-notify-immutable/src/core.cpp +@@ -0,0 +1,22 @@ ++#include "core.h" ++ ++core::core(QString getnum, QWidget *parent) ++ : QMainWindow(parent) ++{ ++ updateHandle = new updatehandle(getnum,this); ++ connect(updateHandle,&updatehandle::execSignal,this,&core::execSlots); ++ this->setWindowFlags(Qt::SubWindow); ++ ++} ++ ++core::~core() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++} ++ ++void core::execSlots() ++{ ++ emit execSignal(); ++} ++ ++ +diff --git a/kylin-update-notify-immutable/src/core.h b/kylin-update-notify-immutable/src/core.h +new file mode 100644 +index 0000000..9647b0e +--- /dev/null ++++ b/kylin-update-notify-immutable/src/core.h +@@ -0,0 +1,23 @@ ++#ifndef CORE_H ++#define CORE_H ++ ++#include <QMainWindow> ++#include "updatehandle.h" ++ ++class core : public QMainWindow ++{ ++ Q_OBJECT ++ ++public: ++ core(QString getnum, QWidget *parent = nullptr); ++ ~core(); ++ updatehandle *updateHandle; ++ ++signals: ++ void execSignal(); ++ ++protected slots: ++ void execSlots(); ++ ++}; ++#endif // CORE_H +diff --git a/kylin-update-notify-immutable/src/main.cpp b/kylin-update-notify-immutable/src/main.cpp +new file mode 100644 +index 0000000..e3c717b +--- /dev/null ++++ b/kylin-update-notify-immutable/src/main.cpp +@@ -0,0 +1,206 @@ ++#include "core.h" ++#include <QApplication> ++#include <QDebug> ++#include <sys/stat.h> ++#include <unistd.h> ++#include <iostream> ++#include <ukui-log4qt.h> ++#include<qdebug.h> ++#include <QLockFile> ++ ++#define PROGRAM_NAME "kylin-background-upgrade" ++#define LOG_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade.log" ++#define LOG_SILENT_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade-silent.log" ++#define LOG_MANUL_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade-manul.log" ++ ++static FILE *fp = NULL; ++QString toDir; ++static bool _silentOrManul = true; ++ ++void msgHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) ++{ ++ static char logPath[255] = {0}; ++ int uid = -1; ++ static int pid = 0; ++ ++ Q_UNUSED(context); ++ ++ QDateTime currentTime = QDateTime::currentDateTime(); ++ QString timeStr = currentTime.toString("yy.MM.dd hh:mm:ss +zzz"); ++ pid = (int)getpid(); ++ uid = (int)getuid(); ++ // 获取用于控制命令行输出的环境变量 ++ char *ctrlEnv = getenv("BACKGROUND_UPGRADE_DEBUG"); ++ QString env; ++ ++ // 格式化输出字符串,添加消息发生时间、消息等级 ++ QString outMsg; ++ switch (type) { ++ case QtDebugMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtInfoMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtWarningMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtCriticalMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtFatalMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ } ++ ++ if (fp != NULL) { ++ // 日志文件存在,则输出到日志文件中 ++ fprintf(fp, "%s\n", outMsg.toUtf8().data()); ++ fflush(fp); ++ } ++ ++ if (ctrlEnv != NULL) { ++ // 环境变量为true或者1,则将信息输出到命令行 ++ env = QString(ctrlEnv).toLower(); ++ if ((env == "true") || (env == "1")) { ++ fprintf(stdout, "%s\n", outMsg.toStdString().c_str()); ++ fflush(stdout); ++ } ++ } ++ ++ // 遇到致命错误,需要终止程序(这里终止程序是可选的) ++ if (type == QtFatalMsg) ++ abort(); ++} ++ ++void log_env_init(QString arg){ ++ static int uid = -1; ++ static char logPath[98] = {0}; ++ bool _is_root = false; ++ toDir = QDir::homePath(); ++ toDir += "/.config/kylin-background-upgrade/"; ++ QDir dir(toDir); ++ if(!dir.exists()) { ++ dir.mkdir(toDir); ++ } ++ ++ // 初始执行时,设置log文件路径 ++ if (uid == -1) { ++ uid = getuid(); ++ } ++ if (uid == 0) { ++ // root user ++ sprintf(logPath, "/var/log/kylin-background-upgrade/kylin-background-upgrade.log"); ++ _is_root = true; ++ } else { ++ // normal user ++ // sprintf(logPath, "/run/user/%d/%s.log", uid, PROGRAM_NAME); ++ //QString 转 const char* ++ std::string str = QDir::homePath().toStdString(); ++ const char* ch = str.c_str(); ++ if (arg == "--check-upgrade" || arg == "--check-immediately") { ++ sprintf(logPath, "%s%s", ch, LOG_MANUL_NAME); ++ } else { ++ sprintf(logPath, "%s%s", ch, LOG_SILENT_NAME); ++ } ++ } ++ ++ if (access(logPath, F_OK|W_OK) == 0) { // log文件存在且可写 ++ if (fp == NULL) ++ fp = fopen(logPath, "a+"); ++ QFileInfo info(logPath); ++ if (info.size() > 1024*1024*20) { //20MB ++ fclose(fp); fp = NULL; ++ QFile fileclean(logPath); ++ fileclean.open(QIODevice::WriteOnly | QIODevice::Text | QFile::Truncate); ++ fileclean.close(); ++ if (fp == NULL) ++ fp = fopen(logPath, "a+"); ++ } ++ } else if (access(logPath, F_OK) != 0){ //文件不存在 ++ if (fp == NULL) { ++ if (_is_root) { //root用户日志文件 ++ QDir* dir = new QDir(); ++ if(!dir->exists("/var/log/kylin-background-upgrade/")){ ++ dir->mkpath("/var/log/kylin-background-upgrade/"); ++ } ++ fp = fopen(logPath, "a+"); ++ if (fp == NULL) ++ printf("Can't open logfile!\n"); ++ } else { ++ fp = fopen(logPath, "a+"); ++ if (fp == NULL) ++ printf("Can't open logfile!\n"); ++ } ++ } ++ } else { ++ // log文件不可写,则需要判断是否被打开过,被打开过就需要关闭 ++ if (fp != NULL) ++ fclose(fp); ++ fp = NULL; ++ } ++} ++ ++bool _is_openkylin() ++{ ++ QString OPENKYLIN_DISTTRIBUTOR = "Openkylin"; ++ QString command = "lsb_release -i -s"; ++ QProcess process; ++ process.start(command); ++ process.waitForFinished(); ++ ++ QString result = process.readAllStandardOutput(); ++ int ret = result.left(OPENKYLIN_DISTTRIBUTOR.length()).compare(OPENKYLIN_DISTTRIBUTOR.left(OPENKYLIN_DISTTRIBUTOR.length())); ++ return (0 == ret)?true:false; ++} ++ ++int main(int argc, char *argv[]) ++{ ++ QString arg=QString::fromLatin1(argv[1]); ++ log_env_init(arg); ++ qInstallMessageHandler(msgHandler); ++ char *dis_env=getenv("DISPLAY"); ++ QString display_env(dis_env); ++ if(display_env != NULL){ ++ qDebug()<<"The desktop graphics environment is normal, DISPLAY="<<dis_env; ++ } else { ++ qDebug()<<"The desktop graphics environment is abnormal, DISPLAY="<<dis_env<<", exit!"; ++ exit(0); ++ } ++ ++ QLockFile manul_lock(toDir+"manul.lock"); ++ QLockFile silent_lock(toDir+"silent.lock"); ++ qDebug()<<""; ++ qDebug()<<"---------------------------------------------------------------------------------------------------"; ++ if (arg == "--check-upgrade" || arg == "--check-immediately") { ++ qDebug()<<"Start check upgradable ..."; ++ if (arg == "--check-immediately") { ++ qDebug()<<"Perform a boot update check ..."; ++ } ++ if (!manul_lock.tryLock(0)) { ++ qDebug()<<"Another process is checking for updates, exit!"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"Start silent upgrade ..."; ++ if (!silent_lock.tryLock(0)) { ++ qDebug()<<"Another process is silently upgrading, exit!"; ++ exit(0); ++ } ++ if (_is_openkylin()) { ++ qDebug()<<"openkylin, exit!"; ++ exit(0); ++ } ++ } ++ ++#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) ++ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); ++ QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); ++#endif ++ ++ setenv("QT_QPA_PLATFORMTHEME","ukui",true); ++ qunsetenv("SESSION_MANAGER"); ++ QApplication a(argc, argv); ++ core m_core(arg); ++// QObject::connect(m_core,SIGNAL(execSignal()),&a,SLOT(quit())); ++ return a.exec(); ++} +diff --git a/kylin-update-notify-immutable/src/traydbus.cpp b/kylin-update-notify-immutable/src/traydbus.cpp +new file mode 100644 +index 0000000..7618f0d +--- /dev/null ++++ b/kylin-update-notify-immutable/src/traydbus.cpp +@@ -0,0 +1,450 @@ ++#include "traydbus.h" ++#include <iostream> ++#include <ostream> ++#include <QDateTime> ++ ++//托盘d-bus 服务 ++traydbusservice::traydbusservice() ++{ ++ ++} ++ ++QStringList traydbusservice::getCrucial() ++{ ++ QFile file("/var/lib/kylin-software-properties/template/crucial.list"); ++ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) ++ return crucial; ++ while (!file.atEnd()) { ++ QByteArray line = file.readLine(); ++ QString str = QString(line); ++ qDebug()<<str; ++ crucial = str.split(QRegExp("[ ]")); ++ qDebug()<<"d-bus crucial: "<<crucial; ++ } ++ return crucial; ++} ++QStringList traydbusservice::getImportant() ++{ ++ QFile file("/var/lib/kylin-software-properties/template/important.list"); ++ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) ++ return important; ++ while (!file.atEnd()) { ++ QByteArray line = file.readLine(); ++ QString str = QString(line); ++ qDebug()<<str; ++ important = str.split(QRegExp("[ ]")); ++ qDebug()<<"d-bus important: "<<important; ++ } ++ return important; ++} ++void traydbusservice::connectSuccessslots() ++{ ++ emit connectSuccessSignal(); ++} ++void traydbusservice::quitslots() ++{ ++ emit quitsignal(); ++} ++ ++ ++//连接源管理器的d-bus································ ++ ++source_dbus* source_dbus::sourceMutual = nullptr; ++using namespace std; ++/** ++ * @brief source_dbus::getInstance ++ * 单例 ++ * @return ++ */ ++source_dbus* source_dbus::getInstance() ++{ ++ static QMutex mutex; ++ if (nullptr == sourceMutual) { ++ QMutexLocker locker(&mutex); ++ sourceMutual = new source_dbus; ++ } ++ return sourceMutual; ++} ++ ++source_dbus::source_dbus(QObject *parent) ++ :QObject(parent) ++{ ++ connectTimer = new QTimer(this); ++ connect(connectTimer, SIGNAL(timeout()), this, SLOT(connectDbus())); ++} ++ ++source_dbus::~source_dbus() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++} ++ ++/** ++ * @brief source_dbus::initSource_Dbus ++ * 连接源管理器dbus ++ * @return ++ */ ++bool source_dbus::initSource_Dbus() ++{ ++ //创建QDBusInterface接口 ++ interface1 = new QDBusInterface("com.kylin.software.properties", "/com/kylin/software/properties", ++ "com.kylin.software.properties.interface", ++ QDBusConnection::systemBus()); ++ if (!interface1->isValid()) { ++ qDebug() << qPrintable(QDBusConnection::systemBus().lastError().message()); ++ exit(1); ++ } ++ ++ interface1->setTimeout(123456789); ++ //调用远程的value方法,源管理器update ++ qDebug()<<"Start updateSourceTemplate ..."; ++ QDBusReply<bool> reply1 = interface1->call(QDBus::Block, "updateSourceTemplate"); ++ if (reply1.isValid()) { ++ if (reply1.value()) { ++// QDBusReply<int> reply2 = interface1->call(QDBus::Block, "updateSourcePackages","kylin-background-upgrade"); ++// if (reply2.isValid()) { ++// qDebug()<<"updateSourcePackages return value:"<<reply2.value(); ++// if (reply2.value() == 100) { ++// qDebug()<<"源管理器 updateSource 连接成功"; ++// emit ready(); ++// } else { ++// qDebug()<<"源管理器updateSourcePackages failed,连接失败 "; ++// return false; ++// } ++// } else { ++// qDebug() << "源管理器updateSourcePackages failed "; ++// return false; ++// } ++ emit ready(); ++ } else { ++ qDebug()<<"updateSourceTemplate failed "; ++ return false; ++ } ++ } else { ++ qDebug() << "updateSourceTemplate method called failed "; ++ return false; ++ } ++ return true; ++} ++ ++/** ++ * @brief source_dbus::connectDbus ++ * 重连机制 ++ */ ++void source_dbus::connectDbus() ++{ ++ connectTimer->start(3000); ++ if (initSource_Dbus()) { ++ connectTimer->stop(); ++ } else { ++ num ++; ++ if (num >2) { ++ qDebug()<<"updateSourceTemplate failed, exit."; ++ exit(0); ++ } ++ qDebug()<<"updateSourceTemplate failed,Retries are in progress for the "<<num<<"th time."; ++ } ++} ++ ++//连接更新管理器的d-bus································ ++ ++update_dbus* update_dbus::updateMutual = nullptr; ++using namespace std; ++ ++update_dbus* update_dbus::getInstance() ++{ ++ static QMutex mutex; ++ if (nullptr == updateMutual) { ++ QMutexLocker locker(&mutex); ++ updateMutual = new update_dbus; ++ } ++ return updateMutual; ++} ++ ++ ++update_dbus::update_dbus(QObject *parent) ++ :QObject(parent) ++{ ++ initUpdate_Dbus(); ++ ++} ++ ++update_dbus::~update_dbus() ++{ ++ ++} ++ ++/** ++ * @brief update_dbus::initUpdate_Dbus ++ * 连接更新管理器dbus ++ */ ++void update_dbus::initUpdate_Dbus() ++{ ++ //创建QDBusInterface接口 ++ interface = new QDBusInterface("com.kylin.systemupgrade", "/com/kylin/systemupgrade", ++ "com.kylin.systemupgrade.interface", ++ QDBusConnection::systemBus()); ++ if (!interface->isValid()) { ++ qDebug() << qPrintable(QDBusConnection::systemBus().lastError().message()); ++ qDebug() << "Failed to connect /com/kylin/systemupgrade "; ++ exit(1); ++ } ++ interface_utils = new QDBusInterface("com.kylin.systemupgrade", "/com/kylin/systemupgrade/utils", ++ "com.kylin.systemupgrade.interface", ++ QDBusConnection::systemBus()); ++ if (!interface_utils->isValid()) { ++ qDebug() << qPrintable(QDBusConnection::systemBus().lastError().message()); ++ qDebug() << "Failed to connect /com/kylin/systemupgrade "; ++ exit(1); ++ } ++ ++ //监听D-bus信号,获取安装信息与进度 ++// connect(interface,SIGNAL(UpdateDloadAndInstStaChanged(QStringList, int, QString, QString)),this,SLOT(getsignal(QStringList, int, QString, QString))); ++// QDBusConnection::systemBus().connect(QString("com.kylin.systemupgrade"), QString("/com/kylin/systemupgrade"), ++// QString("com.kylin.systemupgrade.interface"), ++// QString("UpdateDloadAndInstStaChanged"), this, SLOT(getsignal(QStringList, int32_t, QString, QString))); ++ ++} ++ ++/** ++ * @brief update_dbus::getsignal ++ * 获取下载进度 ++ */ ++void update_dbus::getsignal(QStringList pkgs, int progess, QString status, QString current_details) ++{ ++ QString aptStatus = ""; ++// QString aptAppName; ++ int aptPercent = 0; ++ ++// QVariant dateQVariant; ++// aptStatus = arg; ++ ++// QVariantMap::Iterator it; ++// for (it = key.begin(); it != key.end(); ++it) { ++// if (it.key() == "apt_appname") { ++// dateQVariant = it.value(); ++// aptAppName = dateQVariant.toString(); ++// } ++// if (it.key() == "apt_percent") { ++// dateQVariant = it.value(); ++// aptPercent = dateQVariant.toFloat(); ++// } ++// } ++ ++// if (arg == "apt_start" && aptD_busStatus == true) { ++// aptD_busStatus =false; ++// } ++// if ((arg == "apt_start" || arg == "apt_finish") && (aptPercent == 0 || aptPercent == 100)) { ++// emit aptAppNames_Percentsignal(aptAppName,aptPercent,true); ++// } else if (arg == "apt_error" ) { ++// emit aptAppNames_Percentsignal(aptAppName,aptPercent,false); ++// } ++ if (aptPercent != progess) { ++ aptPercent = progess; ++ emit aptAppNames_Percentsignal(pkgs.at(0),aptPercent,status); ++ } ++ ++} ++ ++/** ++ * @brief update_dbus::checkForUpdates ++ * 检测强制推送列表 ++ */ ++QStringList update_dbus::checkForUpdates(QStringList arg) ++{ ++ QDBusReply<QStringList> reply = interface_utils->call("CheckInstalledOrUpgrade",arg); ++ if (reply.isValid()) ++ { ++ qDebug()<<"The upgradeable list:"<<reply.value(); ++ return reply.value(); ++ ++ } else { ++ qDebug() << "Get upgradeable list failed, exit"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief update_dbus::checkForUpdateDect ++ * 检测系统更新 ++ */ ++bool update_dbus::checkForUpdateDect() ++{ ++ qDebug()<<"Start to check system upgrade ..."; ++ connect(interface,SIGNAL(UpdateDetectFinished(bool, QStringList, QString, QString)),this,SLOT(UpdateDectSlot(bool, QStringList, QString, QString))); ++ QDBusReply<QVariantList> res = interface->asyncCall("UpdateDetect"); ++ qDebug() << "UpdateDetect (mode: MODE_UPDATE_DETECT) ..."; ++ return true; ++} ++ ++/** ++ * @brief update_dbus::installAndUpgrade ++ * 静默升级入口 ++ */ ++bool update_dbus::installAndUpgrade(QStringList pkgNames) ++{ ++ installpkgs = pkgNames; ++ ++ //调用D-bus接口,安装软件 ++ connect(interface,SIGNAL(UpdateDetectFinished(bool,QStringList,QString,QString)),this,SLOT(slotUpdateCache(bool,QStringList,QString,QString))); ++// QDBusPendingCall call = interface_utils->asyncCall("InstallPackages","kylin-background-upgrade", installpkgs); ++ QDBusPendingCall call = interface->asyncCall("UpdateCache"); ++ qDebug() << "UpdateCache (mode: MODE_UPDATE_CACHE) ..."; //MODE_UPDATE_CACHE ++ return true; ++} ++ ++void update_dbus::slotInstallFinish(bool status, QStringList pkgs,QString error,QString details) ++{ ++ emit UpdateInstallFinished(status,pkgs,error,details); ++} ++ ++void update_dbus::UpdateDectSlot(bool status, QStringList pkgs,QString error,QString details) ++{ ++ emit UpdateDectFinished(status,pkgs,error,details); ++} ++ ++void update_dbus::slotUpdateCache(bool status,QStringList pkgslist,QString errorstring,QString errorcode) ++{ ++ if (status) { ++ qDebug() << "MODE_UPDATE_CACHE finish ."; ++ connect(interface,SIGNAL(UpdateInstallFinished(bool,QStringList,QString,QString)),this,SLOT(slotInstallFinish(bool,QStringList,QString,QString))); ++ interface->asyncCall("InstallPackages", installpkgs); ++ } else { ++ qDebug() << "Call UpdateCache (mode: MODE_UPDATE_CACHE) failed, exit!"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief update_dbus::listenState ++ * 监听状态 ++ * @return ++ */ ++bool update_dbus::listenState() ++{ ++ QDBusReply<bool> r4eply = interface->call("get_important_status"); ++ return r4eply; ++} ++ ++ ++//连接电源的d-bus································ ++ ++power_dbus::power_dbus(QObject *parent) ++ :QObject(parent) ++{ ++ ++} ++ ++power_dbus::~power_dbus() ++{ ++ ++} ++ ++/** ++ * @brief power_dbus::initDbusaddrest ++ * 连接电源管理器的dbus,获取dbus路径 ++ * @return ++ */ ++bool power_dbus::initDbusaddrest() ++{ ++ ++ QStringList users; ++ QDBusInterface m_interface1( "org.freedesktop.UPower", ++ "/org/freedesktop/UPower", ++ "org.freedesktop.UPower", ++ QDBusConnection::systemBus() ); ++ if (!m_interface1.isValid()) { ++ qDebug() << "< org.freedesktop.UPower > initialization failed!"; ++ return false; ++ } ++ ++ QDBusReply<QList<QDBusObjectPath>> obj_reply = m_interface1.call("EnumerateDevices"); ++ ++ ++ if (obj_reply.isValid()) { ++ for (QDBusObjectPath op : obj_reply.value()) ++ users << op.path(); ++ if (users.size()==1 || users.isEmpty()) { ++ qDebug()<<"Failed to obtain the remaining battery capacity, The built-in power supply cannot be detected ..."; ++ return false; ++ } ++ powerpath=users.at(1); ++ return true; ++ } ++ return true; ++} ++ ++/** ++ * @brief power_dbus::getPower_Dbus ++ * 连接电源管理器的dbus ++ * @return ++ */ ++QString power_dbus::getPower_Dbus() ++{ ++ QDBusInterface m_interface( "org.freedesktop.UPower", ++ powerpath, ++ "org.freedesktop.DBus.Properties", ++ QDBusConnection::systemBus()); ++ ++ if (!m_interface.isValid()) { ++ qDebug() << "电源管理器dbus接口初始化失败"; ++ return "false"; ++ } ++ ++ QDBusReply<QVariant> obj_reply = m_interface.call("Get","org.freedesktop.UPower.Device","Percentage"); ++ QString Ele_surplus=obj_reply.value().toString(); ++ return Ele_surplus; ++} ++ ++//判断是否为活跃用户的dbus······························· ++ ++UserIdStatus::UserIdStatus(QObject *parent) ++ :QObject(parent) ++{ ++ initUserIdStatus(); ++} ++ ++UserIdStatus::~UserIdStatus() ++{ ++ ++} ++ ++ ++void UserIdStatus::initConnectionInfo() ++{ ++// qRegisterMetaType<MyClass>("MyClass"); ++// QDBusInterface m_interface1("org.freedesktop.login1", ++// "/org/freedesktop/login1", ++// "org.freedesktop.login1.Manager", ++// QDBusConnection::systemBus() ); ++// if (!m_interface1.isValid()) { ++// qDebug() << "dbus接口初始化失败"; ++// return; ++// } ++ ++// QDBusMessage res = m_interface1.call("ListUsers"); ++ ++// qDebug() << res.arguments().at(0).value<MyClass>().IDName; ++// qDebug()<<res; ++} ++ ++void UserIdStatus::initUserIdStatus() ++{ ++ static int uid = -1; ++ uid = getuid(); ++ QString uIDaddress = QString("/org/freedesktop/login1/user/_%1").arg(uid); ++ QDBusInterface m_interface1("org.freedesktop.login1", ++ uIDaddress, ++ "org.freedesktop.DBus.Properties", ++ QDBusConnection::systemBus()); ++ if (!m_interface1.isValid()) { ++ qDebug() << "dbus接口初始化失败"; ++ return; ++ } ++ ++ QDBusReply<QVariant> res = m_interface1.call("Get","org.freedesktop.login1.User","State"); ++ UIDStatus = res.value().toString(); ++} ++ ++ ++ ++ +diff --git a/kylin-update-notify-immutable/src/traydbus.h b/kylin-update-notify-immutable/src/traydbus.h +new file mode 100644 +index 0000000..795f869 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/traydbus.h +@@ -0,0 +1,160 @@ ++#ifndef TRAYDBUSSERVICE_H ++#define TRAYDBUSSERVICE_H ++ ++#include <QObject> ++#include <QDBusInterface> ++#include <QDBusReply> ++#include <QDBusMessage> ++#include <QDBusReply> ++#include <QDBusConnection> ++#include <QTimer> ++#include <QDebug> ++#include <QFile> ++#include <QMutexLocker> ++ ++ ++#include <sys/stat.h> ++#include <unistd.h> ++#include <iostream> ++ ++class traydbusservice : public QObject ++{ ++ Q_OBJECT ++ //定义Interface名称为com.scorpio.test.value ++ Q_CLASSINFO("D-Bus Interface", "com.scorpio.test.value") ++public: ++ traydbusservice(); ++ ++ QStringList crucial; ++ QStringList important; ++ ++public slots: ++ QStringList getCrucial(); ++ QStringList getImportant(); ++ ++ void connectSuccessslots(); ++ void quitslots(); ++ ++private: ++ ++Q_SIGNALS: // SIGNALS ++ QString ready(QString ret); ++ QString connectSuccessSignal(); ++ QString quitsignal(); ++ ++}; ++ ++//连接源管理器的d-bus································ ++ ++class source_dbus: public QObject ++{ ++ Q_OBJECT ++ ++public: ++ explicit source_dbus(QObject *parent = nullptr); ++ ~source_dbus(); ++ QString serialNumber; ++ QTimer *connectTimer; ++ int num=0; ++ static source_dbus *getInstance(); ++ QDBusInterface *interface1; //连接源更新管理器的D-bus ++ ++ bool initSource_Dbus(); ++ static source_dbus *sourceMutual; //UpdateDbus类静态对象 ++ ++public slots: ++ void connectDbus(); ++ ++Q_SIGNALS: ++ void ready(); ++}; ++ ++//连接更新管理器的d-bus································ ++ ++class update_dbus: public QObject ++{ ++ Q_OBJECT ++ ++public: ++ explicit update_dbus(QObject *parent = nullptr); ++ ~update_dbus(); ++ static update_dbus *getInstance(); ++ QDBusInterface *interface; //连接更新管理器的D-bus ++ QDBusInterface *interface_utils; //kylin-system-updater utils ++ void initUpdate_Dbus(); ++ static update_dbus *updateMutual; //UpdateDbus类静态对象 ++ QStringList checkForUpdates(QStringList arg); //检测是否有更新 ++ bool checkForUpdateDect(); //检测系统更新 ++ bool installAndUpgrade(QStringList pkgNames); //静默升级入口 ++ QTimer *timer; ++ ++ bool aptD_busStatus=true; //发送状态的标志位 ++ ++ bool listenState(); ++ QStringList installpkgs; ++Q_SIGNALS: ++ void ready(); ++ void aptAppNames_Percentsignal(QString arg,int32_t args,QString state); //发送正在下载安装的包名以及进度 ++ void dowloadStart(); ++ void UpdateInstallFinished(bool,QStringList,QString,QString); ++ void UpdateDectFinished(bool,QStringList,QString,QString); ++ ++protected slots: ++ void getsignal(QStringList, int, QString, QString); ++ void slotUpdateCache(bool,QStringList,QString,QString); ++ void slotInstallFinish(bool,QStringList,QString,QString); ++ void UpdateDectSlot(bool,QStringList,QString,QString); ++}; ++ ++//连接电源的d-bus································ ++ ++class power_dbus: public QObject ++{ ++ Q_OBJECT ++public: ++ power_dbus(QObject *parent = nullptr); ++ ~power_dbus(); ++ QDBusInterface *interface; //连接更新管理器的D-bus ++ bool initDbusaddrest(); ++ QString getPower_Dbus(); ++ QString powerpath; ++ ++ ++Q_SIGNALS: ++ void ready(); ++ ++protected slots: ++ ++}; ++ ++//判断是否为活跃用户的dbus······························· ++ ++ ++class MyClass ++{ ++public: ++ uint32_t uidnum; ++ QString IDName; ++ QDBusObjectPath address; ++}; ++Q_DECLARE_METATYPE(MyClass) ++ ++class UserIdStatus: public QObject ++{ ++ Q_OBJECT ++public: ++ UserIdStatus(QObject *parent = nullptr); ++ ~UserIdStatus(); ++ QString UIDStatus; ++ void initConnectionInfo(); ++ void initUserIdStatus(); ++ ++Q_SIGNALS: ++ void ready(); ++ ++protected slots: ++ ++}; ++ ++ ++#endif // TRAYDBUSSERVICE_H +diff --git a/kylin-update-notify-immutable/src/trayicon.cpp b/kylin-update-notify-immutable/src/trayicon.cpp +new file mode 100644 +index 0000000..612e126 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/trayicon.cpp +@@ -0,0 +1,35 @@ ++#include "trayicon.h" ++ ++trayicon::trayicon(QWidget *parent) : QSystemTrayIcon(parent) ++{ ++ initAction(); ++} ++ ++void trayicon::initAction() ++{ ++ this->setToolTip(tr("The system is updating silently")); ++ this->setIcon(QIcon(":/update.png")); ++ ++ m_trayMenu = new QMenu(); ++ m_topWidget = new QWidget(); ++ m_topWidget->setFixedSize(30,30); ++ m_topWidget->installEventFilter(this); ++ m_topWidgetAction = new QWidgetAction(this); ++ ++} ++ ++/** ++ * @brief trayicon::eventFilter ++ * 事件过滤器 ++ */ ++bool trayicon::eventFilter(QObject *obj, QEvent *event) ++{ ++// if (obj == m_topWidget && event->type() == QEvent::MouseButtonPress) ++// { ++// QPainter painter(m_topWidget); ++// painter.setPen(Qt::NoPen); ++// painter.setBrush(QColor(42,120,192)); ++// painter.drawRect(m_topWidget->rect()); ++// } ++ return QSystemTrayIcon::eventFilter(obj,event); ++} +diff --git a/kylin-update-notify-immutable/src/trayicon.h b/kylin-update-notify-immutable/src/trayicon.h +new file mode 100644 +index 0000000..6e49374 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/trayicon.h +@@ -0,0 +1,33 @@ ++#ifndef TRAYICON_H ++#define TRAYICON_H ++ ++#include <QWidget> ++#include <QSystemTrayIcon> ++#include <QAction> ++#include <QMenu> ++#include <QPainter> ++#include <QEvent> ++#include <QDebug> ++#include <QWidgetAction> ++ ++class trayicon : public QSystemTrayIcon ++{ ++ Q_OBJECT ++public: ++ explicit trayicon(QWidget *parent = nullptr); ++ void initAction(); ++ ++ QAction *action_show; ++ QMenu *m_trayMenu; ++ QWidget *m_topWidget; ++ QWidgetAction *m_topWidgetAction; ++ QMenu* trayIconMenu; ++ QAction* OpenSetUp; ++protected: ++ bool eventFilter(QObject *obj, QEvent *event); ++ ++signals: ++ ++}; ++ ++#endif // TRAYICON_H +diff --git a/kylin-update-notify-immutable/src/updatehandle.cpp b/kylin-update-notify-immutable/src/updatehandle.cpp +new file mode 100644 +index 0000000..8e04ed5 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/updatehandle.cpp +@@ -0,0 +1,750 @@ ++#include "updatehandle.h" ++#include <iostream> ++#include <QProcess> ++ ++updatehandle::updatehandle(QString getnum1,QWidget *parent) : QWidget(parent) ++{ ++ argnum = getnum1; ++ ++ initTranslator(); //加载翻译文件 ++ getpower(); //获取电量值 ++ readconf(); //读取配置文件设定值 ++ initDbus(); //初始化dbus ++ initUI(argnum); //初始化托盘程序 ++} ++ ++updatehandle::~updatehandle() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++} ++ ++/** ++ * @brief updatehandle::initTranslator ++ * 加载翻译文件 ++ */ ++void updatehandle::initTranslator() ++{ ++ QTranslator *translator = new QTranslator; ++ if (translator->load(QLocale(), QLatin1String("kylin-background-upgrade"), QLatin1String("_"), QLatin1String("/usr/share/kylin-background-upgrade"))) { ++ QApplication::installTranslator(translator); ++ } else { ++ qDebug() << "cannot load translator kylin-background-upgrade_" << QLocale::system().name() << ".qm!"; ++ } ++ ++} ++ ++/** ++ * @brief updatehandle::getpower ++ * 获取电量值 ++ */ ++void updatehandle::getpower() ++{ ++ //获取电量信息 ++ Power_dbus = new power_dbus(this); ++ powerState = Power_dbus->initDbusaddrest(); ++ if (powerState) { ++ powerNum = Power_dbus->getPower_Dbus(); ++ qDebug()<<"电脑电量值为:"<<powerNum; ++ } ++} ++ ++/** ++ * @brief updatehandle::initDbus ++ * 初始化dbus ++ */ ++void updatehandle::initDbus() ++{ ++ UserIdStatus *arg = new UserIdStatus(); //查看当前是否为用户操作的用户 ++ if(arg->UIDStatus == "online") { ++ qDebug()<<"非活跃窗口,禁止启动"; ++ exit(0); ++ } ++ m_updateMutual = update_dbus::getInstance(); //初始化更新管理器d-bus ++ m_sourceMutual = source_dbus::getInstance(); //初始化源管理器d-bus ++ ++} ++ ++ ++/** ++ * @brief updatehandle::initUI ++ * 初始化界面类 ++ */ ++void updatehandle::initUI(QString argnum) ++{ ++ timerDownload = new QTimer(this); ++ connect(timerDownload, SIGNAL(timeout()), this, SLOT(downloadTimeout())); ++ ++ if(argnum.contains("--check-immediately")){ ++ qDebug()<<"exec --check-immediately"; ++ } else if(argnum.contains("--check-upgrade")) { ++ qDebug()<<"exec --check-upgrade"; ++ } else { ++ qDebug()<<"exec slient."; ++ } ++ ++ trayIcon = new trayicon(this); ++ bool ignore_or_delay = ignoreOrDelay(argnum.contains("--check-immediately",Qt::CaseInsensitive)); ++ choice_window = new updatewidget(ignore_or_delay);//更新选择页面 ++ tip_window = new updateTip(); //静默升级提示 ++ ++ if (argnum == "") { ++ //监听连接源管理器d-bus ++ //监听托盘点击事件,3:单击,2:双击,1:右键 ++ connect(trayIcon,&trayicon::activated, this,&updatehandle::onActivated); ++ connect(m_sourceMutual,&source_dbus::ready,this,&updatehandle::getTemplateList); ++ m_sourceMutual->connectDbus(); ++ } else if (argnum.contains("--check-upgrade",Qt::CaseInsensitive)||ignore_or_delay) { ++ //连接关闭功能槽函数 ++ connect(choice_window,&updatewidget::disAgreeBtnSignals,this,&updatehandle::execslots); ++ UpdateDectCheck(ignore_or_delay); ++ } else { ++ qDebug()<<"No update,exit!"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief updatehandle::tray_Show ++ * 启动托盘选择页面 ++ */ ++void updatehandle::tray_Show() ++{ ++ if(checktime()){ ++ if (!m_updateMutual->listenState()) { ++ if (m_getsql()) { ++ qDebug()<<"m_getsql 的值为true"; ++ choice_window->update_lab->setText(tr("System update")); ++ if (argnum != "update") { ++ choice_window->updateWidgetShow(); ++ } ++ } else { ++ qDebug()<<"更新管理器关闭检测更新,托盘程序结束"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"更新管理器已运行,程序退出"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"配置文件设定时间未到,程序退出"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief updatehandle::checktime ++ * 进行当前时间与配置文件时间比对 ++ * @return ++ * true: 当前时间大于配置文件时间 ++ * false: 当前时间小于配置文件时间 ++ */ ++bool updatehandle::checktime() ++{ ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ CheckUpgradeTime = timersetting->value("CheckUpgradeTime").toString(); ++ QDateTime datetime = QDateTime::fromString(CheckUpgradeTime, "yyyy-MM-dd hh:mm:ss"); ++ //结束组 ++ timersetting->endGroup(); ++ QDateTime Nowtime = QDateTime::currentDateTime(); //获取系统现在的时间 ++ qint64 nSecs = Nowtime.secsTo(datetime); //对比 ++ qDebug()<<"Get timing time: "<<CheckUpgradeTime; ++ qDebug()<<"Current system time: "<<Nowtime; ++ qDebug()<<"nSecs"<<nSecs; ++ if(nSecs == 0){ ++ qDebug()<<"The timing configuration file is abnormal,ckeck upgrade ..."; ++ return true; ++ } ++ if(nSecs < 0){ ++ qDebug()<<"Check upgrade starts when the scheduled time is reached."; ++ return true; ++ } ++ return false; ++} ++ ++/** ++ * @brief updatehandle::m_getsql ++ * 获取更新管理器是否自动检测的数据 ++ * @return ++ * true:自动检测 ++ * false:关闭自动检测 ++ */ ++bool updatehandle::m_getsql() ++{ ++ db = QSqlDatabase::addDatabase("QSQLITE"); ++ db.setDatabaseName("/var/cache/kylin-system-updater/kylin-system-updater.db"); ++ if (!db.open()) { ++ qDebug()<<"open sql error"; ++ return false; ++ } ++ QSqlQuery query; ++ query.exec("SELECT * FROM display"); ++ while(query.next()){ ++ QString tmp=query.value(3).toString(); ++ if (tmp == "true") { ++ return true; ++ } else if (tmp == "false") { ++ return false; ++ } ++ } ++ qDebug()<<"从数据库未读到正确的标志信息"; ++ return false; ++} ++ ++/** ++ * @brief updatehandle::onActivated ++ * 接收点击时间的槽函数 ++ * @param reason ++ * reason:传入点击事件信息 ++ */ ++void updatehandle::onActivated(trayicon::ActivationReason reason) ++{ ++ if(tip_window->isHidden()){ ++ QPoint pt=cursor().pos(); ++ tip_window->move(pt.x(),pt.y()-45); ++ tip_window->show(); ++ } else { ++ tip_window->hide(); ++ } ++} ++ ++/** ++ * @brief updatehandle::getTemplateList ++ * 获取源管理器文件中的可选更新与强制更新列表 ++ */ ++void updatehandle::getTemplateList() ++{ ++ qDebug()<<"Parses the optional update list and the mandatory update list ..."; ++ QMap<QString,QStringList> updatedata; ++ QString str1; ++ QString str2; ++ QStringList m_crucial; ++ QFile file1("/var/lib/kylin-software-properties/template/crucial.list"); ++ if (!file1.open(QIODevice::ReadOnly | QIODevice::Text)){ ++ qDebug()<<"cat not open file crucial.list"; ++ exit(0); ++ } ++ while (!file1.atEnd()) { ++ QByteArray line = file1.readLine(); ++ str1 += QString(line); ++ } ++ str1.replace(QString("\n"), QString("")); ++ m_crucial = str1.split(QRegExp("[ ]")); ++ m_crucial.removeAll(QString("")); ++ qDebug()<<"The crucial lists: "<<m_crucial; ++ ++ QStringList m_important; ++ QFile file2("/var/lib/kylin-software-properties/template/important.list"); ++ if (!file2.open(QIODevice::ReadOnly | QIODevice::Text)) { ++ qDebug()<<"cat not open file important.list"; ++ exit(0); ++ } ++ while (!file2.atEnd()) { ++ QByteArray line = file2.readLine(); ++ str2 += QString(line); ++ } ++ str2.replace(QString("\n"), QString("")); ++ m_important = str2.split(QRegExp("[ ]")); ++ m_important.removeAll(QString("")); ++ qDebug()<<"The important lists: "<<m_important; ++ ++ updatedata.insert("crucial",m_crucial); ++ updatedata.insert("important",m_important); ++ ++ processData(updatedata); ++} ++ ++/** ++ * @brief updatehandle::processData ++ * 处理获取的更新数据 ++ * @param data ++ * 传入可选更新与强制更新列表 ++ */ ++void updatehandle::processData(QMap<QString,QStringList> data) ++{ ++ qDebug()<<"Monitor the installation progress and status signal ..."; ++ //ksu获取进度,状态 ++ connect(m_updateMutual,&update_dbus::UpdateInstallFinished,this,&updatehandle::InstallFinsih); ++ QStringList crucial; ++ QMap<QString,QStringList>::iterator it; ++ for (it = data.begin();it != data.end();it++) { ++ if (it.key() == "crucial") { ++ crucial = it.value(); ++ } else if (it.key() == "important") { ++ important = it.value(); ++ } ++ } ++ qDebug()<<"Checking silent upgrade list: "<<crucial; ++ QStringList checkCrucialAll; ++ ++ checkCrucialAll = m_updateMutual->checkForUpdates(crucial); ++ if (!checkCrucialAll.isEmpty()) { ++ handleCrucial(checkCrucialAll); ++ } else { ++ qDebug() << "Silent upgrade list is empty, exit!"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief updatehandle::handleCrucial ++ * 处理静默升级包 ++ * @param checkCrucialAll ++ * 传入包列表 ++ */ ++void updatehandle::handleCrucial(QStringList checkCrucialAll) ++{ ++ QStringList crucialPackageSize; ++ QStringList crucialPackage; ++ ++ if (checkCrucialAll.count()%2 != 0) { ++ qDebug()<<"The format of the silent upgrade list is incorrect, exit!"; ++ exit(0); ++ } ++ if (argnum != "update") { ++ //提取包名与大小信息 ++ for (int i=0;i<checkCrucialAll.count();i+=2) { ++ crucialPackage.append(checkCrucialAll.at(i)); ++ } ++ ++ for (int i=1;i<checkCrucialAll.count();i+=2) { ++ crucialPackageSize.append(checkCrucialAll.at(i)); ++ } ++ checkCrucial = crucialPackage; ++ qDebug()<<"Checking for inactivity in silent upgrading ..."; ++ timerDownload->start(20*60*1000); ++ if (powerState) { //判断是否获取到电量 ++ if (powerNum.toInt()<powerSize) { //判断电量是否达到警戒值 ++ qDebug()<<"超出设定电源警戒值,判断包大小是否符合继续下载条件"; ++ if (packageDownOrNot(crucialPackageSize)) { ++ notify_send(tr("The system is updating silently")); ++ trayIcon->setVisible(true); ++ qDebug()<<"The system is updating silently ..."; ++ m_updateMutual->installAndUpgrade(crucialPackage); ++ } else { ++ exit(0); ++ } ++ } else { ++ notify_send(tr("The system is updating silently")); ++ trayIcon->setVisible(true); ++ qDebug()<<"The system is updating silently ..."; ++ m_updateMutual->installAndUpgrade(crucialPackage); ++ } ++ } else { ++ notify_send(tr("The system is updating silently")); ++ trayIcon->setVisible(true); ++ qDebug()<<"The system is updating silently ..."; ++ m_updateMutual->installAndUpgrade(crucialPackage); ++ } ++ } ++} ++ ++/** ++ * @brief updatehandle::UpdateDectSlot ++ * 处理可选升级包 ++ */ ++void updatehandle::UpdateDectSlot(bool status,QStringList list,QString errorstring,QString errorcode) ++{ ++ if (!status) { ++ qDebug() << "Update Detect failed: " << QString("%1 %2").arg(errorstring).arg(errorcode); ++ exit(0); ++ } else { ++ if (list.length() == 0) { ++ qDebug() << "The software on this computer is up to date, exit!"; ++ exit(0); ++ } else { ++ choice_window->update_lab->setText(tr("System update")); ++ if (argnum != "update") { ++ choice_window->updateWidgetShow(); ++ } ++ } ++ } ++ //完成检测,刷新下次更新标志位 ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ timersetting->setValue("GeneratRandomTime",true); ++ timersetting->setValue("CheckCompleted",true); ++ timersetting->sync(); ++ timersetting->endGroup(); ++} ++ ++/** ++ * @brief updatehandle::UpdateDectCheck ++ * 处理可选升级包 ++ */ ++void updatehandle::UpdateDectCheck(bool _check_immediately) ++{ ++ //判断是否有系统更新 ++ if(checktime() || !RandomizedExecute || _check_immediately){ ++ if (m_getsql() || _check_immediately) { ++ qDebug()<<"Detection update has been opened ..."; ++ connect(m_updateMutual,&update_dbus::UpdateDectFinished,this,&updatehandle::UpdateDectSlot); ++ bool ret= m_updateMutual->checkForUpdateDect(); ++ } else { ++ qDebug()<<"Detection updates have been disabled, exit!"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"The scheduled time is not reached, exit."; ++ exit(0); ++ } ++} ++ ++ ++/** ++ * @brief updatehandle::ignoreOrDelays ++ * 处理可选升级包 ++ */ ++bool updatehandle::ignoreOrDelay(bool mode) ++{ ++ static char flagPath[64] = {0}; ++ sprintf(flagPath, "/var/cache/kylin-update-manager/ignoreOrDelay"); ++ bool ignore_or_delay = false; ++ QFile file(flagPath); ++ ++ //判断是否完成第一步更新 ++ if (access(flagPath, F_OK) == 0) { // flag文件存在且可写 ++ qDebug()<<flagPath<<"is found!"; ++ ++ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) ++ ignore_or_delay = false; ++ QByteArray line = file.readLine(); ++ if(QString(line).contains("2107",Qt::CaseInsensitive)) { ++ ignore_or_delay = true; ++ qDebug()<<"The first step of the upgrade has been completed, Detection of the second step of the upgrade! [2107]"; ++// //需要清空文件 ++// file.close(); ++// file.open(QIODevice::Truncate); ++// file.close(); ++// file.open(QIODevice::WriteOnly); ++ } else if (QString(line).contains("2203",Qt::CaseInsensitive)) { ++ ignore_or_delay = true; ++ qDebug()<<"The first step of the upgrade has been completed, Detection of the second step of the upgrade! [2203]"; ++ } ++ } else { ++ qDebug()<<flagPath<<"isn't found!"; ++ ignore_or_delay = false; ++ } ++ file.close(); ++ return ignore_or_delay&&mode; ++} ++ ++/** ++ * @brief updatehandle::packageDownOrNot ++ * 判断是否超出设定大小 ++ * @param arg ++ * 传入包列表 ++ * @return ++ * true:符合预定大小 ++ * false:超出设定大小 ++ */ ++bool updatehandle::packageDownOrNot(QStringList arg) ++{ ++ qDebug()<<"开始检测包大小是否超出设定大小"; ++ for (int i = 0 ;i<arg.count();i++) { ++ QString pagesize = arg.at(i); ++ if (pagesize.toFloat() > setPackageSize) { ++ qDebug()<<"包大小超出设定大小,程序退出"; ++ return false; ++ } ++ } ++ qDebug()<<"包大小符合预定大小"; ++ return true; ++} ++ ++/** ++ * @brief updatehandle::register_dbus ++ */ ++void updatehandle::register_dbus() ++{ ++ //建立到session bus的连接 ++ QDBusConnection connection = QDBusConnection::sessionBus(); ++ ++ //在session bus上注册名为com.scorpio.test的服务 ++ if (!connection.registerService("com.scorpio.test")) { ++ qDebug() << "error:" << connection.lastError().message(); ++ exit(-1); ++ } ++ object = new traydbusservice(); ++ ++ //注册名为/test/objects的对象,把类Object所有槽函数导出为object的method ++ connection.registerObject("/test/objectsd", object,QDBusConnection::ExportAllSlots| QDBusConnection :: ExportAllSignals); ++ ++ connect(object,&traydbusservice::quitsignal,[=](){ ++ emit execSignal(); ++ }); ++ ++ connect(object,&traydbusservice::connectSuccessSignal,[=](){ ++ dbusConnectStatus = true; ++ emit object->ready("success"); ++ }); ++ ++} ++ ++/** ++ * @brief updatehandle::d_busStatus ++ * 判断下载状态的槽函数 ++ * @param arg : Appname ++ * @param args : aptpercent ++ * @param state : state ++ */ ++void updatehandle::d_busStatus(QString arg,int32_t args,QString state) ++{ ++ if (!checkCrucial.isEmpty() && messstate2) { ++ messstate2=false; ++ trayIcon->setVisible(true); ++ } ++ ++// qDebug()<<"下载进度:"; ++// qDebug()<<"Appname:"<<arg; ++// qDebug()<<"aptpercent:"<<args; ++} ++ ++void updatehandle::InstallFinsih(bool state,QStringList pkgname,QString error,QString reason) ++{ ++ bool _check_status; ++ timerDownload->stop(); ++ //apt返回失败时判断是否安装成功 ++ if (!state) ++ _check_status = package_installation_status(checkCrucial); ++ ++ if(state || _check_status){ ++ qDebug() << "Silent upgrade is complete, exit."; ++ notify_send(tr("The system has completed an important update, It is recommended that you restart immediately.")); ++ }else{ ++ QString errorstate = tr("update error"); ++ QString errorName; ++ errorName = QString("%1 %2").arg(error).arg(errorstate); ++ qDebug() << "Silent update failed: "<<errorName; ++ notify_send(errorName); ++ } ++ trayIcon->setVisible(false); ++ tip_window->hide(); ++ exit(0); ++} ++ ++bool updatehandle::package_installation_status(QStringList pkgs) ++{ ++ QString pkgname; ++ QString cmd; ++ QProcess process; ++ bool status,status_single; ++ for (QStringList::iterator it = pkgs.begin(); it != pkgs.end(); ++it) { ++ pkgname = *it; ++ status_single = false; ++ cmd = QString("dpkg -l %1").arg(pkgname); ++ process.start(cmd); ++ process.waitForFinished(); ++ QByteArray result_ = process.readAllStandardOutput(); ++ if (QString::fromLocal8Bit(result_) != "") { ++ QStringList rets = QString::fromLocal8Bit(result_).split(QRegExp("[\n]"),QString::SkipEmptyParts); ++ for (QStringList::iterator it_ret = rets.begin(); it_ret != rets.end(); ++it_ret) { ++ QString ret; ++ ret = *it_ret; ++ if (ret.contains(pkgname) && ret.startsWith("ii")) { ++ status_single = true; ++ qDebug() << "pkg "<<pkgname<<",Installation succeeded."; ++ } ++ } ++ if (!status_single) { //install failed ++ status = false; ++ break; ++ } ++ } else { ++ status = false; ++ break; ++ } ++ if (status_single) ++ status = true; ++ } ++ return status; ++} ++ ++/** ++ * @brief updatehandle::execslots ++ * 关闭界面槽函数 ++ */ ++void updatehandle::execslots() ++{ ++ //设置推迟检测,更新标志位 ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ timersetting->setValue("CheckCompleted",false); ++ timersetting->setValue("GeneratRandomTime",false); ++ timersetting->sync(); ++ timersetting->endGroup(); ++ emit execSignal(); ++} ++ ++/** ++ * @brief updatehandle::notify_send ++ * 发送消息通知函数 ++ * @param arg ++ * 发送的正文 ++ */ ++void updatehandle::notify_send(QString arg) ++{ ++ QDBusInterface iface("org.freedesktop.Notifications", ++ "/org/freedesktop/Notifications", ++ "org.freedesktop.Notifications", ++ QDBusConnection::sessionBus()); ++ QList<QVariant> args; ++ args<<tr("kylin-background-upgrade") ++ <<((unsigned int) 0) ++ <<QString("kylin-update-manager") ++ <<tr("update") //显示的是什么类型的信息//系统升级 ++ <<arg //显示的具体信息 ++ <<QStringList() ++ <<QVariantMap() ++ <<(int)-1; ++ iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args); ++} ++ ++/** ++ * @brief updatehandle::downloadTimeout ++ * 下载时间超时函数 ++ */ ++void updatehandle::downloadTimeout() ++{ ++ qDebug() << "Download the timeout, exit!"; ++ exit(0); ++} ++ ++ ++/** ++ * @brief updatehandle::_secsTo ++ */ ++int updatehandle::_secsTo(QString time1, QString time2) ++{ ++ QStringList time1Slot,time2Slot; ++ // **:** ++ if (time1.contains(":")){ ++ time1Slot = time1.split(":"); ++ }else{return -1;} ++ if (time2.contains(":")){ ++ time2Slot = time2.split(":"); ++ }else{return -1;} ++ if (time1Slot.at(0) > time2Slot.at(0)) { ++ return 1; ++ } else if (time1Slot.at(0) == time2Slot.at(0)) { ++ if (time1Slot.at(1) > time2Slot.at(1)) { ++ return 1; ++ } else if (time1Slot.at(1) == time2Slot.at(1)) { ++ return 0; ++ } else if (time1Slot.at(1) < time2Slot.at(1)) { ++ return -1; ++ } ++ } else if (time1Slot.at(0) < time2Slot.at(0)) { ++ return -1; ++ } ++} ++ ++/** ++ * @brief updatehandle::readconf ++ * 读取配置文件 ++ */ ++void updatehandle::readconf() ++{ ++ QMap<QString, QVariant> Timer; ++ Timer.insert("CheckCompleted", bool(false)); ++ Timer.insert("CheckUpgradeTime", " "); ++ Timer.insert("CheckUpgradeTimeSlot", "14:30:00-16:30:00"); ++ Timer.insert("GeneratRandomTime", bool(true)); ++ Timer.insert("RandomizedExecute", bool(true)); ++ QMap<QString, QVariant> Settings; ++ Settings.insert("powersize", int(1)); ++ Settings.insert("setpackagesize", "999999999"); ++// qDebug()<<"Settings "<<QString::number(float(999999999),'f',2); ++ ++ confPath = QDir::homePath()+"/.config/kylin-background-upgrade/kylin-background-upgrade-conf.ini"; ++ QFileInfo fileInfo(confPath); ++ if (!fileInfo.exists()) { ++ qDebug()<<"The background-upgrade configuration file isn't exists."; ++ QMapIterator<QString, QVariant> ir_timer(Timer); ++ QMapIterator<QString, QVariant> ir_settings(Settings); ++ QSettings *code_conf = new QSettings(confPath,QSettings::IniFormat); ++ code_conf->beginGroup(QString::fromLocal8Bit("Timer")); ++ while(ir_timer.hasNext()){ ++ ir_timer.next(); ++ code_conf->setValue(ir_timer.key(), ir_timer.value()); ++ } ++ code_conf->sync(); ++ code_conf->endGroup(); ++ code_conf->beginGroup(QString::fromLocal8Bit("Settings")); ++ while(ir_settings.hasNext()){ ++ ir_settings.next(); ++ code_conf->setValue(ir_settings.key(), ir_settings.value()); ++ } ++ code_conf->sync(); ++ code_conf->endGroup(); ++ } ++ ++ timersetting = new QSettings(confPath,QSettings::IniFormat); ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ CheckUpgradeTime = timersetting->value("CheckUpgradeTime").toString(); ++ CheckUpgradeTimeSlot = timersetting->value("CheckUpgradeTimeSlot").toString(); ++ RandomizedExecute = timersetting->value("RandomizedExecute").toBool(); ++ GeneratRandomTime = timersetting->value("GeneratRandomTime").toBool(); ++ CheckCompleted = timersetting->value("CheckCompleted").toBool(); ++ qDebug()<<"[ CheckUpgradeTime: "<<CheckUpgradeTime<<", CheckUpgradeTimeSlot: "<<CheckUpgradeTimeSlot \ ++ <<", RandomizedExecute: "<<RandomizedExecute<<", GeneratRandomTime: "<<GeneratRandomTime<<", CheckUpgradeTime: "<<CheckUpgradeTime\ ++ <<", CheckCompleted: "<<CheckCompleted<<" ]"; ++ timersetting->endGroup(); ++ ++ timersetting->beginGroup(QString::fromLocal8Bit("Settings")); ++ powerSize = timersetting->value("powersize").toInt(); ++ setPackageSize = timersetting->value("setpackagesize").toFloat(); ++ timersetting->endGroup(); ++ ++ QStringList timeSlot = CheckUpgradeTimeSlot.split("-"); ++ qDebug()<<"timeSlot "<<timeSlot; ++ //需要刷新检测时间 ++ if (GeneratRandomTime) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString current_datetime = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QString current_date= time.toString("yyyy-MM-dd"); //设置显示格式 ++ QString current_time= time.toString("hh:mm:ss"); //设置显示格式 ++ QString nowtime; ++ QByteArray str2char2 = current_time.toLatin1(); // must ++ nowtime = str2char2.data(); ++ ++ qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); ++ int a = 0; ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ QString timing = current_date+' '+timeSlot.at(0); ++ QString start_timing = timeSlot.at(0); ++ QString end_timing = timeSlot.at(1); ++ QStringList start_timingSlot,end_timingSlot; ++ QString time0,time1,time2,time3; ++ if (start_timing.contains(":")){ ++ start_timingSlot = start_timing.split(":"); ++ time0 = start_timingSlot.at(0); ++ time1 = start_timingSlot.at(1); ++ } ++ if (end_timing.contains(":")){ ++ end_timingSlot = end_timing.split(":"); ++ time2 = end_timingSlot.at(0); ++ time3 = end_timingSlot.at(1); ++ } ++ int strayParameter = (time2.toInt()*60+time3.toInt())-(time0.toInt()*60+time1.toInt()); ++ a = 0; ++ if (strayParameter<0){ ++ qDebug() << "Time format error."; ++ }else if (strayParameter==0) { ++ qDebug() << "strayParameter: "<< strayParameter << ", a "<<a; ++ } else { ++ a = qrand()%(strayParameter); ++ qDebug() << "strayParameter: "<< strayParameter << ", a "<<a; ++ } ++ QDateTime bojb = QDateTime::fromString(timing,"yyyy-MM-dd hh:mm:ss").addSecs(a*60); ++ if (CheckCompleted) { ++ bojb = bojb.addDays(1); ++ timersetting->setValue("CheckCompleted",false); ++ } ++ QString timing_time = bojb.toString("yyyy-MM-dd hh:mm:ss").toLatin1().data(); ++ ++ timersetting->setValue("CheckUpgradeTime",timing_time); ++ timersetting->setValue("GeneratRandomTime",false); ++ qDebug()<< "CheckUpgradeTime "<<timing_time; ++ timersetting->sync(); ++ timersetting->endGroup(); ++ } ++} ++ +diff --git a/kylin-update-notify-immutable/src/updatehandle.h b/kylin-update-notify-immutable/src/updatehandle.h +new file mode 100644 +index 0000000..9eb4250 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/updatehandle.h +@@ -0,0 +1,105 @@ ++#ifndef TRAY_H ++#define TRAY_H ++ ++#include <QMap> ++#include <QDebug> ++#include <QWidget> ++#include <QProcess> ++#include <QSettings> ++#include <QSqlQuery> ++#include <QTextCodec> ++#include <QPushButton> ++#include <QTranslator> ++#include <QSqlDatabase> ++#include <QNetworkReply> ++#include <QSqlQueryModel> ++#include <QNetworkRequest> ++#include <QNetworkAccessManager> ++ ++#include <string.h> ++#include <unistd.h> ++#include <sys/file.h> ++#include <sys/stat.h> ++ ++#include "traydbus.h" ++#include "trayicon.h" ++#include "updatewidget.h" ++ ++ ++class updatehandle : public QWidget ++{ ++ Q_OBJECT ++public: ++ updatehandle(QString getnum1,QWidget *parent = nullptr); ++ ~updatehandle(); ++ trayicon *trayIcon; //托盘实例化 ++ QStringList important; //保存重要更新包名 ++ QString argnum; //得到命令行输入参数 ++ traydbusservice *object; //托盘dbus服务 ++ bool powerState; //保存电量是否可获取 ++ QString powerNum = "0"; //保存电量值 ++ QString confPath = ""; //保存配置文件位置 ++ ++ bool dbusConnectStatus=false; //d-bus连接状态 ++ bool messstate1=true; ++ bool messstate2=true; ++ int powerSize; //电源设定值 ++ float setPackageSize; //包大小设定值 ++ QString CheckUpgradeTime; //检查更新时间 ++ QString CheckUpgradeTimeSlot; //检查更新时间段 ++ bool CheckCompleted; //是否检查完成 ++ bool RandomizedExecute; //是否随机执行 ++ bool GeneratRandomTime; //是否刷新随机时间 ++ bool errorStatus=false; //是否完整下载安装的状态值 ++ ++ updatewidget *choice_window; //托盘选择框 ++ updateTip *tip_window; //托盘提示框框 ++ QStringList checkCrucial; //保存静默升级包以及大小信息 ++ ++ source_dbus *m_sourceMutual; //源管理器dbus ++ update_dbus *m_updateMutual; //更新管理器dbus ++ power_dbus *Power_dbus; ++ QTimer *timerDownload; //托盘下载时间错误延时处理 ++ QTimer *timerLock; //文件锁定时检测 ++ QSettings *mqsetting; //读取配置文件 ++ QSettings *timersetting; //读取timer配置文件 ++ ++ ++ void initUI(QString); //初始化界面 ++ void initDbus(); //初始化dbus ++ void initTranslator(); //初始化翻译加载 ++ void getTemplateList(); //获取源管理器文件中的可选更新与强制更新 ++ void processData(QMap<QString,QStringList> data); //处理获取的更新数据 ++ void handleCrucial(QStringList checkCrucialAll); //处理静默升级包 ++ void handleImportant(); //处理可选升级包 ++ void register_dbus(); //注册D-bus服务 ++ bool checktime(); //检查设定更新时间 ++ ++ //数据库相关 ++ QSqlDatabase db; ++ QSqlQueryModel model; ++ ++ bool m_getsql(); //获取更新管理器数据库信息 ++ void notify_send(QString arg); //向notification发送信息显示 ++ ++ bool packageDownOrNot(QStringList arg); ++ void readconf(); //读取配置文件 ++ int _secsTo(QString,QString); //时间差 ++ void getpower(); //获取电量值 ++ void UpdateDectCheck(bool); //调用后端UpdateDetect ++ bool ignoreOrDelay(bool mode); //是否开机检查检查弹窗 ++ bool package_installation_status(QStringList); ++signals: ++ void execSignal(); //关闭窗口信号 ++ ++protected slots: ++ void onActivated(trayicon::ActivationReason reason); //更新选择页面 ++ void tray_Show(); //启动托盘显示 ++ void execslots(); //关闭窗口槽函数 ++ void d_busStatus(QString,int32_t,QString); //判断下载状态的槽函数 ++ void InstallFinsih(bool,QStringList,QString,QString); //状态槽函数 ++ void downloadTimeout(); //延时检测下载状态 ++ void UpdateDectSlot(bool,QStringList,QString,QString); //updatedetect回调函数 ++}; ++ ++#endif // TRAY_H +diff --git a/kylin-update-notify-immutable/src/updatewidget.cpp b/kylin-update-notify-immutable/src/updatewidget.cpp +new file mode 100644 +index 0000000..054dd15 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/updatewidget.cpp +@@ -0,0 +1,664 @@ ++#include "updatewidget.h" ++#include "ui_updatewidget.h" ++#include <QPainterPath> ++#include <QToolTip> ++#include <QHoverEvent> ++#include "ukuistylehelper/ukuistylehelper.h" ++#include "windowmanager/windowmanager.h" ++ ++#define PANEL_DBUS_SERVICE "com.ukui.panel.desktop" ++#define PANEL_DBUS_PATH "/" ++#define PANEL_DBUS_INTERFACE "com.ukui.panel.desktop" ++#define UKUI_PANEL_SETTING "org.ukui.panel.settings" ++ ++#define DBUS_NAME "org.ukui.SettingsDaemon" ++#define DBUS_PATH "/org/ukui/SettingsDaemon/wayland" ++#define DBUS_INTERFACE "org.ukui.SettingsDaemon.wayland" ++ ++updatewidget::updatewidget(bool check_Tips, QWidget *parent) : ++ QWidget(parent), ++ ui(new Ui::Form) ++{ ++ ui->setupUi(this); ++ //设置出现在屏幕的位置以及大小 ++ listenPanelChange(); ++ QString xdg_session_type = qgetenv("XDG_SESSION_TYPE"); ++ if (xdg_session_type != "wayland"){ ++ initPanelDbusGsetting(); ++ GetsAvailableAreaScreen(); ++ qDebug()<<"not wayland"; ++ bIsWayland = false; ++ } else { ++ //注释掉的是原先的接口,已经废除。采用原本的获取方式 ++// initset_window_position(); ++// set_window_position(); ++ initPanelDbusGsetting(); ++ GetsAvailableAreaScreen(); ++ qDebug()<<"wayland"; ++ bIsWayland = true; ++ } ++ _check_Tips = check_Tips; ++ //设置任务栏无显示 ++ setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); ++ setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); ++ ++ update_lab = new QLabel(); ++ icon_lab = new QLabel(); ++ ++ tip_lab = new QLabel(); ++ tip_lab->setText(tr(" Updatable app detected on your system!")); ++ agreebtn = new FixButton(); ++ delaybtn = new FixButton(); ++ window_close = new QPushButton(this); ++ ++ window_close->setIcon(QIcon::fromTheme("window-close-symbolic")); ++ window_close->setProperty("isWindowButton", 0x2); ++ window_close->setProperty("useIconHighlightEffect", 0x8); ++ window_close->setFlat(true); ++ window_close->setToolTip(tr("Close")); ++ window_close->installEventFilter(this); ++ connect(window_close, &QPushButton::clicked, this, &updatewidget::onClick_close_btn); ++ ++ QPixmap icon(QIcon::fromTheme("ukui-control-center").pixmap(QSize(26,26))); ++ ++ m_pfirstlayout = new QVBoxLayout(); ++ m_labellayout = new QHBoxLayout(); ++ m_psecondlayout = new QHBoxLayout(); ++ m_pselectlayout = new QHBoxLayout(); ++ comboBox = new QComboBox(); ++ comboBox->clear(); ++ strList<<tr("30 minutes later")<<tr("1 hour later")<<tr("5 hours later")<<tr("1 day later")<<tr("3 days later"); ++ comboBox->addItems(strList); ++ comboBox->installEventFilter(this); ++ ++ labelwidget = new QWidget(); ++ selectWidget = new QWidget(); ++ statwidget = new QWidget(); ++ ++ agreebtn->setText(tr("Update"),1); ++ agreebtn->installEventFilter(this); ++ delaybtn->setText(tr("Delay"),1); ++ delaybtn->installEventFilter(this); ++ ++ connect(agreebtn,&QPushButton::clicked,this,&updatewidget::agreeBtnClicked); ++ connect(comboBox,SIGNAL(activated(int)),this,SLOT(comboBoxClicked(int))); ++ connect(delaybtn,&QPushButton::clicked,this,&updatewidget::delayBtnClicked); ++ ++ icon_lab->setPixmap(icon); ++ icon_lab->setScaledContents(true); ++ icon_lab->setMaximumSize(26,26); ++ update_lab->setMaximumHeight(26); ++ update_lab->setContentsMargins(0,0,0,3); ++ window_close->setFixedSize(24,24); ++ window_close->setContentsMargins(0,0,0,3); ++ m_labellayout->addWidget(icon_lab); ++ m_labellayout->addWidget(update_lab); ++ m_labellayout->addStretch(); ++ m_labellayout->addWidget(window_close); ++ m_labellayout->setContentsMargins(0,0,0,20); ++ labelwidget->setLayout(m_labellayout); ++ ++ m_pselectlayout->addWidget(tip_lab); ++ m_pselectlayout->setContentsMargins(0,0,0,25); ++ selectWidget->setLayout(m_pselectlayout); ++ ++ m_psecondlayout->addStretch(); ++ comboBox->setFixedHeight(35); ++ comboBox->setMinimumWidth(135); ++ comboBox->setMaximumWidth(155); ++ agreebtn->setFixedSize(100,35); ++ if (_check_Tips) ++ m_psecondlayout->addWidget(delaybtn); ++ else ++ m_psecondlayout->addWidget(comboBox); ++ m_psecondlayout->addWidget(agreebtn); ++ m_psecondlayout->setSpacing(15); //set space between comboBox and btn ++ m_psecondlayout->setContentsMargins(0,0,12,12); ++ statwidget->setLayout(m_psecondlayout); ++ ++ m_pfirstlayout->addWidget(labelwidget); ++ m_pfirstlayout->addWidget(selectWidget); ++ m_pfirstlayout->addWidget(statwidget); ++ ++ m_pfirstlayout->setSpacing(2); ++ this->setLayout(m_pfirstlayout); ++ this->setFixedSize(435,160); ++ ++// QGSettings *settings; ++// if(QGSettings::isSchemaInstalled("org.ukui.style")){ ++// settings = new QGSettings("org.ukui.style"); ++// connect(settings,&QGSettings::changed,this,&ActiveConnectionWidget::GSettingsChanges); ++// } ++ ++// const QByteArray transparency_id(TRANSPARENCY_SETTINGS); ++// if(QGSettings::isSchemaInstalled(transparency_id)) { ++// transparency = new QGSettings(transparency_id); ++// } ++// if(QGSettings::isSchemaInstalled(transparency_id)) { ++// getTransparency(); ++// connect(transparency,&QGSettings::changed,this,&ActiveConnectionWidget::GSettingsChanges); ++// } ++ ++ this->setProperty("useStyleWindowManager", false); ++ this->setProperty("useSystemStyleBlur", true); ++ this->setAttribute(Qt::WA_TranslucentBackground, true); ++ this->setWindowOpacity(0.9); ++ ++// labelwidget->setStyleSheet("background-color:green;"); ++// update_lab->setStyleSheet("background-color:blue;"); ++// selectWidget->setStyleSheet("background-color:red;"); ++// statwidget->setStyleSheet("background-color:orange;"); ++// comboBox->setStyleSheet("background-color:violet;"); ++// agreebtn->setStyleSheet("background-color:yellow;"); ++} ++ ++updatewidget::~updatewidget() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++ delete ui; ++} ++ ++void updatewidget::updateWidgetShow() ++{ ++ this->show(); ++ qDebug()<<"should show:"<<updateWidgetRect; ++ ++ if (bIsWayland) ++ kdk::WindowManager::setGeometry(this->windowHandle(), updateWidgetRect); ++ else ++ this->setGeometry(updateWidgetRect); ++} ++ ++void updatewidget::onClick_close_btn() ++{ ++ // emit disAgreeBtnSignals(); ++ qDebug()<<"User Cancel reminder, exit tray program!"; ++ // exit(0); ++ qApp->quit(); ++} ++ ++/** ++ * @brief updatewidget::eventFilter ++ * 事件过滤器 ++ */ ++bool updatewidget::eventFilter(QObject *obj, QEvent *event) ++{ ++ if (obj == this->window_close) { //指定window_close ++ if (event->type() == QEvent::HoverMove) { ++ QPushButton *close_btn = qobject_cast<QPushButton *>(obj); ++ if (close_btn) { ++ QToolTip::showText(QCursor::pos(), close_btn->toolTip()); ++ } ++ } ++ } else if (obj == this->agreebtn || obj == this->delaybtn) { ++ if (event->type() == QEvent::HoverMove) { ++ FixButton *btn = qobject_cast<FixButton *>(obj); ++ if (btn) { ++ QToolTip::showText(QCursor::pos(), btn->toolTip()); ++ } ++ } ++ } else if (obj == this->comboBox) { ++ if (event->type() == QEvent::HoverMove) { ++ QComboBox *comboBox = qobject_cast<QComboBox *>(obj); ++ if (comboBox) { ++ QToolTip::showText(QCursor::pos(), comboBox->toolTip()); ++ } ++ } ++ } ++ return QWidget::eventFilter(obj, event); ++} ++ ++/** ++ * @brief updatewidget::initPanelDbusGsetting ++ * 初始化与任务栏gsetting和dbus ++ */ ++void updatewidget::initPanelDbusGsetting() ++{ ++ /* 链接任务栏Dbus接口,获取任务栏高度和位置 */ ++ m_pServiceInterface = new QDBusInterface(PANEL_DBUS_SERVICE, PANEL_DBUS_PATH, PANEL_DBUS_INTERFACE, QDBusConnection::sessionBus()); ++ m_pServiceInterface->setTimeout(2147483647); ++ connect(m_pPanelSetting, &QGSettings::changed,[=](QString key){ ++ if ("panelposition" == key | "panelsize" == key) { ++ GetsAvailableAreaScreen(); ++ } ++ }); ++} ++ ++void updatewidget::listenPanelChange() ++{ ++ /* 链接任务栏dgsetting接口 */ ++ if(QGSettings::isSchemaInstalled(UKUI_PANEL_SETTING)) ++ m_pPanelSetting = new QGSettings(UKUI_PANEL_SETTING); ++} ++ ++/** ++ * @brief updatewidget::connectTaskBarDbus ++ * 链接任务栏dbus获取高度的接口 ++ * @return ++ */ ++int updatewidget::connectTaskBarDbus() ++{ ++ int panelHeight = 46; ++ if (m_pPanelSetting != nullptr) { ++ QStringList keys = m_pPanelSetting->keys(); ++ if (keys.contains("panelsize")) { ++ panelHeight = m_pPanelSetting->get("panelsize").toInt(); ++ } ++ } else { ++ QDBusMessage msg = m_pServiceInterface->call("GetPanelSize", QVariant("Hight")); ++ panelHeight = msg.arguments().at(0).toInt(); ++ return panelHeight; ++ } ++ return panelHeight; ++} ++ ++/** ++ * @brief updatewidget::getPanelSite ++ * 获取任务栏状态位置下上左右 ++ * @return ++ * 返回任务栏位置 ++ */ ++int updatewidget::getPanelSite() ++{ ++ int panelPosition = 0; ++ if (m_pPanelSetting != nullptr) { ++ QStringList keys = m_pPanelSetting->keys(); ++ if (keys.contains("panelposition")) { ++ panelPosition = m_pPanelSetting->get("panelposition").toInt(); ++ } ++ } else { ++ QDBusMessage msg = m_pServiceInterface->call("GetPanelPosition", QVariant("Site")); ++ panelPosition = msg.arguments().at(0).toInt(); ++ } ++ qDebug() << "Current Position of ukui panel: " << panelPosition; ++ return panelPosition; ++} ++ ++/** ++ * @brief updatewidget::GetsAvailableAreaScreen ++ * 获取屏幕的可用区域高度和宽度并设置位置 ++ */ ++void updatewidget::GetsAvailableAreaScreen() ++{ ++ //如果取不到任务栏的高度,还是优先获取桌面分辨率,可用区域 ++ if ((0 == connectTaskBarDbus()) && (0 == getPanelSite())) { ++ QScreen* pScreen = QGuiApplication::primaryScreen(); ++ QRect DeskSize = pScreen->availableGeometry(); ++ m_nScreenWidth = DeskSize.width(); //桌面分辨率的宽 ++ m_nScreenHeight = DeskSize.height(); //桌面分辨率的高 ++ } else { ++ //如果取到任务栏的高度,则取屏幕分辨率的高度 ++ int h = connectTaskBarDbus(); ++ QRect screenRect = QGuiApplication::primaryScreen()->geometry(); ++ m_nScreenWidth = screenRect.width(); ++ m_nScreenHeight = screenRect.height(); ++ m_pPeonySite = getPanelSite(); ++ switch (m_pPeonySite) ++ { ++ case updatewidget::PanelDown : ++ { ++ qDebug()<<"Taskbar coordinates: [ '"<<m_nScreenWidth-445<<"','"<< m_nScreenHeight-h-170<<"','"<<300<<"','"<<150 - 100<<"']"; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-h-170, 300, 150-100); ++ } ++ break; ++ case updatewidget::PanelUp: ++ { ++ qDebug()<<"任务栏在上方: 显示坐标为: "<<m_nScreenWidth - 445 << m_nScreenHeight - 170 << 300 << 150 - 100; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-170, 300, 150-100); ++ } ++ break; ++ case updatewidget::PanelLeft: ++ { ++ qDebug()<<"任务栏在左侧: 显示坐标为: "<<m_nScreenWidth - 445 << m_nScreenHeight - 170 << 300 << 150 - 100; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-170, 300, 150-100); ++ } ++ break; ++ case updatewidget::PanelRight: ++ { ++ qDebug()<<"任务栏在右侧: 显示坐标为: "<<m_nScreenWidth - 445 - h << m_nScreenHeight - 170 << 300 << 150 - 100; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-170, 300, 150-100); ++ } ++ break; ++ default: ++ break; ++ } ++ ++ } ++ qDebug() << "Current screen width: " << m_nScreenWidth <<"; height:"<< m_nScreenHeight; ++} ++ ++ ++int updatewidget::getTaskbarPos(QString str) ++{ ++ QDBusInterface interface( "com.ukui.panel.desktop", ++ "/", ++ "com.ukui.panel.desktop", ++ QDBusConnection::sessionBus() ); ++ ++ QDBusReply<int> reply = interface.call("GetPanelPosition", str); ++ return reply; ++} ++ ++int updatewidget::getTaskbarHeight(QString str) ++{ ++ QDBusInterface interface( "com.ukui.panel.desktop", ++ "/", ++ "com.ukui.panel.desktop", ++ QDBusConnection::sessionBus() ); ++ ++ QDBusReply<int> reply = interface.call("GetPanelSize", str); ++ return reply; ++} ++ ++ ++int updatewidget::getScreenGeometry(QString methodName) ++{ ++ int res = 0; ++ QDBusMessage message = QDBusMessage::createMethodCall(DBUS_NAME, ++ DBUS_PATH, ++ DBUS_INTERFACE, ++ methodName); ++ QDBusMessage response = QDBusConnection::sessionBus().call(message); ++ if (response.type() == QDBusMessage::ReplyMessage) { ++ if(response.arguments().isEmpty() == false) { ++ int value = response.arguments().takeFirst().toInt(); ++ res = value; ++ } ++ } else { ++ qDebug()<<methodName<<"called failed"; ++ } ++ return res; ++} ++ ++void updatewidget::initset_window_position() ++{ ++ connect(m_pPanelSetting, &QGSettings::changed,[=](QString key){ ++ if ("panelposition" == key | "panelsize" == key) { ++ set_window_position(); ++ } ++ } ++ ); ++} ++ ++void updatewidget::set_window_position() ++{ ++ QRect rect; ++ int availableWidth,totalWidth; ++ int availableHeight,totalHeight; ++ rect = this->geometry(); ++ int priX = getScreenGeometry("x"); ++ int priY = getScreenGeometry("y"); ++ int priWid = getScreenGeometry("width"); ++ int priHei = getScreenGeometry("height"); ++ QRect screenGeometry = qApp->primaryScreen()->geometry(); ++ ++ availableWidth = priX + priWid; ++ availableHeight = priY + priHei; ++ totalHeight = screenGeometry.height(); ++ totalWidth = screenGeometry.width(); ++ ++ int distance = 4; ++ int n = 0; ++ int m = 46; ++ ++ n = getTaskbarPos("position"); ++ m = getTaskbarHeight("height"); ++ if(n == 0){ ++ //任务栏在下侧 ++ this->setGeometry(priWid-435-distance,availableHeight-160-m-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在下侧"<<priWid-435-distance<<" "<<availableHeight-160-m-distance <<" "<<this->width()<<" "<<this->height(); ++ }else if(n == 1){ ++ //任务栏在上侧 ++ this->setGeometry(priWid-435-distance,availableHeight-160-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在上侧"<<priWid-435-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height(); ++ } else if (n == 2){ ++ //任务栏在左侧 ++ this->setGeometry(priWid-435-distance,availableHeight-160-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在左侧"<<priWid-435-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height(); ++ } else if (n == 3){ ++ //任务栏在右侧 ++ this->setGeometry(availableWidth-435-m-distance,availableHeight-160-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在右侧"<<availableWidth-435-m-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height(); ++ } ++} ++ ++/** ++ * @brief updatewidget::insideTime ++ * 获取时间 ++ * @return ++ */ ++char *updatewidget::insideTime() ++{ ++ qDebug()<<"current select: "<<this->comboBox->currentText(); ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QByteArray str2char2 = str.toLatin1(); // must ++ char *nowtime = str2char2.data(); ++ ++ if(comboBox->currentText() == strList.at(0)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(1800); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(1)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(3600); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(2)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(18000); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(3)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addDays(1); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(4)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addDays(3); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } ++ return nowtime; ++ ++} ++ ++bool updatewidget::_is_openkylin() ++{ ++ QString OPENKYLIN_DISTTRIBUTOR = "Openkylin"; ++ QString command = "lsb_release -i -s"; ++ QProcess process; ++ process.start(command); ++ process.waitForFinished(); ++ ++ QString result = process.readAllStandardOutput(); ++ int ret = result.left(OPENKYLIN_DISTTRIBUTOR.length()).compare(OPENKYLIN_DISTTRIBUTOR.left(OPENKYLIN_DISTTRIBUTOR.length())); ++ return (0 == ret)?true:false; ++} ++ ++/** ++ * @brief updatewidget::agreeBtnClicked ++ * 同意更新按钮槽函数 ++ */ ++void updatewidget::agreeBtnClicked() ++{ ++ emit agreeBtnSignals(); ++ bool _is_2107 = true; ++ QFile file("/etc/os-release"); ++ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { ++ QString line; ++ QTextStream in(&file); ++ line = in.readLine(); ++ while(!line.isNull()) { ++ line = in.readLine(); ++ if(line.contains("KYLIN_RELEASE_ID")) { ++ _is_2107 = false; ++ } ++ } ++ } ++ file.close(); ++ QProcess p(0); ++ if (_is_2107&&!_is_openkylin()) { ++ p.startDetached("ukui-control-center --upgrade"); ++ qDebug()<<"exec --upgrade"; ++ } else { ++ p.startDetached("ukui-control-center -m upgrade"); ++ qDebug()<<"exec -m upgrade"; ++ } ++ p.waitForStarted(); ++ qDebug()<<"Open the control panel and start updating immediately, exit tray program!"; ++ exit(0); ++} ++ ++/** ++ * @brief updatewidget::comboBoxClicked ++ * 推迟框槽函数 ++ */ ++void updatewidget::comboBoxClicked(int num) ++{ ++ //判断是否有kylin-background-upgrade目录,没有则创建 ++ QString toDir = QDir::homePath(); ++ toDir += "/.config/kylin-background-upgrade/"; ++ QDir dir(toDir); ++ if(! dir.exists()) { ++ dir.mkdir(toDir);//只创建一级子目录,即必须保证上级目录存在 ++ } ++ ++ toDir += "kylin-background-upgrade-conf.ini"; ++ QFileInfo fileInfo(toDir); ++ if (!fileInfo.exists()) { ++ qDebug()<<"The periodic configuration file fails to be opened, exit!"; ++ exit(0); ++ } else { ++ char *nowtime=insideTime(); ++ qDebug() << "current timing: "<<nowtime; ++ timersettings = new QSettings(toDir,QSettings::IniFormat); ++ timersettings->beginGroup(QString::fromLocal8Bit("Timer")); ++ timersettings->setValue("CheckUpgradeTime",nowtime); ++ timersettings->sync(); ++ timersettings->endGroup(); ++ } ++ emit disAgreeBtnSignals(); ++ qDebug()<<"Users do not update, exit tray program!"; ++ exit(0); ++} ++ ++/** ++ * @brief updatewidget::delayBtnClicked ++ * 延迟提醒,退出 ++ */ ++void updatewidget::delayBtnClicked() ++{ ++ qDebug() << "User deferred updates, exit!"; ++ exit(0); ++} ++ ++/** ++ * @brief updatewidget::paintEvent ++ * 样式绘画画家 ++ * @param e ++ */ ++void updatewidget::paintEvent(QPaintEvent *e) ++{ ++ QStyleOption opt; ++ opt.init(this); ++ QPainter p(this); ++ /* 获取当前剪贴板中字体的颜色,作为背景色; ++ * 白字体 --> 黑背景 ++ * 黑字体 --> 白字体 ++ */ ++ p.setBrush(opt.palette.color(QPalette::Base)); ++ p.setOpacity(1); ++ p.setPen(QPen(QColor(220,220,220))); ++ QPainterPath path; ++ opt.rect.adjust(0,0,0,0); ++ path.addRoundedRect(opt.rect,12,12); ++ p.setRenderHint(QPainter::Antialiasing); //反锯齿 ++ p.drawRoundedRect(opt.rect,12,12); ++ setProperty("blurRegion",QRegion(path.toFillPolygon().toPolygon())); ++ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); ++ ++ QFontMetrics fontMetrics(this->font()); ++ QString current_str = comboBox->currentText(); ++ int fontSize = fontMetrics.width(current_str); ++ int showTextSize = comboBox->width() - 32; ++ if (fontSize > showTextSize) { ++ QString elidedText = fontMetrics.elidedText(comboBox->currentText(), Qt::ElideRight, showTextSize); ++ comboBox->setItemText(comboBox->currentIndex(), elidedText); ++ comboBox->setToolTip(current_str); ++ } ++ QWidget::paintEvent(e); ++} ++ ++/** ++ * @brief updateTip::updateTip ++ * 提示框 ++ * @param parent ++ */ ++updateTip::updateTip(QWidget *parent) : ++ QWidget(parent) ++{ ++ //设置任务栏无显示 ++ setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); ++ setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::Popup); ++ ++ m_layout = new QVBoxLayout(); ++ tipLabel = new QLabel(); ++ tipLabel->setText(tr("The system is updating silently")); ++ m_layout->addWidget(tipLabel); ++ this->setLayout(m_layout); ++ this->setProperty("useSystemStyleBlur", true); ++ this->setAttribute(Qt::WA_TranslucentBackground, true); ++ this->setWindowOpacity(0.9); ++} ++ ++updateTip::~updateTip() ++{ ++ ++} ++ ++/** ++ * @brief updateTip::paintEvent ++ * 样式绘画画家 ++ * @param e ++ */ ++void updateTip::paintEvent(QPaintEvent *e) ++{ ++ QStyleOption opt; ++ opt.init(this); ++ QPainter p(this); ++ /* 获取当前剪贴板中字体的颜色,作为背景色; ++ * 白字体 --> 黑背景 ++ * 黑字体 --> 白字体 ++ */ ++ p.setBrush(opt.palette.color(QPalette::Base)); ++ p.setOpacity(1); ++ p.setPen(QPen(QColor(220,220,220))); ++ QPainterPath path; ++ opt.rect.adjust(0,0,0,0); ++ path.addRoundedRect(opt.rect,4,4); ++ p.setRenderHint(QPainter::Antialiasing); //反锯齿 ++ p.drawRoundedRect(opt.rect,4,4); ++ setProperty("blurRegion",QRegion(path.toFillPolygon().toPolygon())); ++ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); ++ QWidget::paintEvent(e); ++} ++ ++ +diff --git a/kylin-update-notify-immutable/src/updatewidget.h b/kylin-update-notify-immutable/src/updatewidget.h +new file mode 100644 +index 0000000..15f0c30 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/updatewidget.h +@@ -0,0 +1,131 @@ ++#ifndef TRAYWIDGET_H ++#define TRAYWIDGET_H ++ ++#include <QWidget> ++#include <QApplication> ++#include <QLabel> ++#include <QPushButton> ++#include <QHBoxLayout> ++#include <QDebug> ++#include <QPainter> ++#include <QProcess> ++#include <QComboBox> ++#include <QDir> ++#include <fcntl.h> ++#include <QDateTime> ++#include <QPoint> ++#include <QDBusInterface> ++#include <QGSettings> ++#include <QScreen> ++#include <QDBusReply> ++#include <QSettings> ++#include <sys/stat.h> ++#include <unistd.h> ++#include <QMouseEvent> ++#include "Button/fixbutton.h" ++ ++namespace Ui { ++class Form; ++} ++ ++class updatewidget : public QWidget ++{ ++ Q_OBJECT ++ ++public: ++ explicit updatewidget(bool check_Tips, QWidget *parent = nullptr); ++ ~updatewidget(); ++ ++ enum PanelStatePosition ++ { ++ PanelDown = 0, ++ PanelUp, ++ PanelLeft, ++ PanelRight ++ }; ++ ++ bool _check_Tips; ++ QLabel *update_lab; ++ QLabel *icon_lab; ++ QLabel *tip_lab; ++ QLabel *close_lab; ++ ++ FixButton *agreebtn; ++ FixButton *delaybtn; ++ QPushButton *window_close; ++ QWidget *labelwidget; ++ QWidget *statwidget; ++ QWidget *selectWidget; ++ QStringList strList; ++ QPixmap *icon; ++ ++ QVBoxLayout *m_pfirstlayout = nullptr; ++ QHBoxLayout *m_labellayout = nullptr; ++ QHBoxLayout *m_psecondlayout = nullptr; ++ QHBoxLayout *m_pselectlayout = nullptr; ++ ++ QDBusInterface* m_pServiceInterface; // 获取任务栏的高度 ++ QGSettings *m_pPanelSetting = nullptr; ++ QComboBox *comboBox; ++ ++ int m_nScreenWidth; // 屏幕分辨率的宽 ++ int m_nScreenHeight; // 屏幕分辨率的高 ++ int m_pPeonySite; // 任务栏位置 ++ QSettings *timersettings; //读取timer配置文件 ++ QRect updateWidgetRect; ++ bool bIsWayland = false; ++ ++ int connectTaskBarDbus(); ++ int getPanelSite(); ++ void GetsAvailableAreaScreen(); ++ char *insideTime(); ++ int getTaskbarPos(QString str); ++ int getTaskbarHeight(QString str); ++ int getScreenGeometry(QString methodName); ++ void set_window_position(); ++ void initset_window_position(); ++ void listenPanelChange(); ++ void initPanelDbusGsetting(); // 初始化与任务栏gsetting和dbus ++ bool eventFilter(QObject *, QEvent *); // 添加事件过滤器声明 ++ bool _is_openkylin(); ++ void updateWidgetShow(); ++ ++private: ++ Ui::Form *ui; ++ void paintEvent(QPaintEvent *e); ++ ++signals: ++ void agreeBtnSignals(); ++ void disAgreeBtnSignals(); ++ ++protected slots: ++ void agreeBtnClicked(); ++ void comboBoxClicked(int); ++ void delayBtnClicked(); ++ void onClick_close_btn(); ++}; ++ ++ ++ ++ ++ ++class updateTip : public QWidget ++{ ++ Q_OBJECT ++public: ++ explicit updateTip(QWidget *parent = nullptr); ++ ~updateTip(); ++ QLabel *tipLabel; ++ QVBoxLayout *m_layout = nullptr; ++ ++ ++private: ++ void paintEvent(QPaintEvent *e); ++ ++ ++signals: ++ ++protected slots: ++}; ++ ++#endif // TRAYWIDGET_H +diff --git a/kylin-update-notify-immutable/src/updatewidget.ui b/kylin-update-notify-immutable/src/updatewidget.ui +new file mode 100644 +index 0000000..d527737 +--- /dev/null ++++ b/kylin-update-notify-immutable/src/updatewidget.ui +@@ -0,0 +1,21 @@ ++<ui version="4.0"> ++ <author/> ++ <comment/> ++ <exportmacro/> ++ <class>Form</class> ++ <widget class="QWidget" name="Form"> ++ <property name="geometry"> ++ <rect> ++ <x>0</x> ++ <y>0</y> ++ <width>400</width> ++ <height>300</height> ++ </rect> ++ </property> ++ <property name="windowTitle"> ++ <string>Form</string> ++ </property> ++ </widget> ++ <pixmapfunction/> ++ <connections/> ++</ui> +diff --git a/kylin-update-notify-immutable/translations/UapLBi.json b/kylin-update-notify-immutable/translations/UapLBi.json +new file mode 100644 +index 0000000..c82f587 +--- /dev/null ++++ b/kylin-update-notify-immutable/translations/UapLBi.json +@@ -0,0 +1 @@ ++[{"excluded":[],"includePaths":["/usr/include/x86_64-linux-gnu/qt5/QGSettings","/usr/include/KF5/KWindowSystem","/usr/include/x86_64-linux-gnu/qt5","/usr/include/x86_64-linux-gnu/qt5/QtWidgets","/usr/include/x86_64-linux-gnu/qt5/QtGui","/usr/include/x86_64-linux-gnu/qt5/QtDBus","/usr/include/x86_64-linux-gnu/qt5/QtNetwork","/usr/include/x86_64-linux-gnu/qt5/QtSql","/usr/include/x86_64-linux-gnu/qt5/QtCore","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade"],"projectFile":"/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/kylin-background-upgrade.pro","sources":["/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/core.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/core.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/main.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/traydbus.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/traydbus.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/trayicon.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/trayicon.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatehandle.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatehandle.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatewidget.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatewidget.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatewidget.ui"]}] +diff --git a/kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.qm b/kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.qm +new file mode 100644 +index 0000000..535b5f5 +--- /dev/null ++++ b/kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.qm +@@ -0,0 +1 @@ ++<�d��!�`���B�����J6���v�J�����1����t"r������-�*y�����*y�����*y����b��$ƨ����D#���xd|��ƨ����(G^��u*�Q��>a�B������i��1���Rb��tQA|DfAb|BBzbbrX`B�tbV�zQf�D �������The system is updating silently���trayicon���Rb��tQA|DfAb|BBzbbrX`B�tbV�zQf�D �������The system is updating silently��� updateTip���*b��tQA|DfBfbf��tb������� System update���updatehandle����XcBBr`BBb�`rBfbf��tb^rBczBfB�tVQD VfX`FbcA�zQbD`U�cXbVf��b`V�zQ �������]The system has completed an important update, It is recommended that you restart immediately.���updatehandle���Rb��tQA|DfAb|BBzbbrX`B�tbV�zQf�D �������The system is updating silently���updatehandle���8b��Vf�zBfBfbf��tbV�brX �������kylin-background-upgrade���updatehandle���(b��tQA|DfbrXf�|b�������update���updatehandle���$brX`Ub`B�tVXzQ �������update error���updatehandle���D� � � � b��tQA|DfBfbf��tbb�XB�Df�������* Updatable app detected on your system!���updatewidget���&IrSBErBSb`B�Df �������1 day later���updatewidget���,FtZ|QBErBSb`B�Df �������1 hour later���updatewidget���&IrSBftXSb`B�Df �������3 days later���updatewidget���(U�rb`B�Dff�bX�3�0 �������30 minutes later���updatewidget���$FtZ|Q�5Sb`B�Df ������� 5 hours later���updatewidget���f�|b��BT�������Close���updatewidget���Sb`B�Df �������Delay���updatewidget��� cXfDBfbf��tb�������Update���updatewidget +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.ts b/kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.ts +new file mode 100644 +index 0000000..6bf37ed +--- /dev/null ++++ b/kylin-update-notify-immutable/translations/kylin-background-upgrade_bo_CN.ts +@@ -0,0 +1,112 @@ ++<?xml version="1.0" encoding="utf-8"?> ++<!DOCTYPE TS> ++<TS version="2.1" language="bo_CN"> ++<context> ++ <name>Form</name> ++ <message> ++ <location filename="../src/updatewidget.ui" line="16"/> ++ <source>Form</source> ++ <translation type="unfinished"></translation> ++ </message> ++</context> ++<context> ++ <name>trayicon</name> ++ <message> ++ <location filename="../src/trayicon.cpp" line="10"/> ++ <source>The system is updating silently</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་ཁ་རོག་གེར་རིམ་འགྱུར་བྱེད་སྒང་།</translation> ++ </message> ++</context> ++<context> ++ <name>updateTip</name> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="548"/> ++ <source>The system is updating silently</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་ཁ་རོག་གེར་རིམ་འགྱུར་བྱེད་སྒང་།</translation> ++ </message> ++</context> ++<context> ++ <name>updatehandle</name> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="116"/> ++ <location filename="../src/updatehandle.cpp" line="355"/> ++ <source>System update</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་གསར་སྒྱུར་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="319"/> ++ <location filename="../src/updatehandle.cpp" line="327"/> ++ <location filename="../src/updatehandle.cpp" line="333"/> ++ <source>The system is updating silently</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་ཁ་རོག་གེར་རིམ་འགྱུར་བྱེད་སྒང་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="511"/> ++ <source>The system has completed an important update, It is recommended that you restart immediately.</source> ++ <translation type="unfinished">མ་ལག་གི་འགག་རྩའི་གསར་སྒྱུར་ཞིག་ལེགས་གྲུབ་དང་།བསམ་འཆར་ལ་ཁྱེད་རང་འཕྲལ་མར་བསྐྱར་འབྱེད་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="513"/> ++ <source>update error</source> ++ <translation type="unfinished">རིམ་འཕར་འགྲུབ་མེད།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="589"/> ++ <source>kylin-background-upgrade</source> ++ <translation type="unfinished">རྒྱབ་སྟེགས་གསར་སྒྱུར་བྱ་རིམ།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="592"/> ++ <source>update</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་རིམ་སྤོར་</translation> ++ </message> ++</context> ++<context> ++ <name>updatewidget</name> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="42"/> ++ <source> Updatable app detected on your system!</source> ++ <translation type="unfinished"> རྒྱུད་ཁོངས་གསར་སྒྱུར་རྣམ་གྲངས་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="51"/> ++ <source>Close</source> ++ <translation type="unfinished">སྒོ་རྒྱག་པ་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>30 minutes later</source> ++ <translation type="unfinished">ཕྱིར་འགྱངས་སྐར་མ་30།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 hour later</source> ++ <translation type="unfinished">ཆུ་ཚོད་གཅིག་ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>5 hours later</source> ++ <translation type="unfinished">ཆུ་ཚོད་5ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 day later</source> ++ <translation type="unfinished">ཉིན་གཅིག་ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>3 days later</source> ++ <translation type="unfinished">ཉིན་གསུམ་ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="69"/> ++ <source>Update</source> ++ <translation type="unfinished">ལམ་སང་གསར་སྒྱུར་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="70"/> ++ <source>Delay</source> ++ <translation type="unfinished">ནར་འགྱངས།</translation> ++ </message> ++</context> ++</TS> +diff --git a/kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.qm b/kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.qm +new file mode 100644 +index 0000000..1025f13 +--- /dev/null ++++ b/kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.qm +@@ -0,0 +1 @@ ++<�d��!�`���B�����J6�����J����1���5t"r��w�����*y�����*y���L�*y��q�b���ƨ���HD#���>d|��ƨ���(G^����*�Q��ja�B��������i��w���|�~�kcW(�Y��f�e��������The system is updating silently���trayicon���|�~�kcW(�Y��f�e��������The system is updating silently��� updateTip���|�~�f�e�������� System update���updatehandle���$|�~�[�bN��yQs�.f�e��^���`�z�Ss��T/�������]The system has completed an important update, It is recommended that you restart immediately.���updatehandle���|�~�kcW(�Y��f�e��������The system is updating silently���updatehandle���TS�f�e�z^��������kylin-background-upgrade���updatehandle���|�~�SG~��������update���updatehandle���SG~�Y1�%�������update error���updatehandle���� � � � |�~�g f�e��yv��������* Updatable app detected on your system!���updatewidget���c���� �1� Y)�������1 day later���updatewidget���c���� �1� \e��������1 hour later���updatewidget���c���� �3� Y)�������3 days later���updatewidget���c���� �3�0� R���������30 minutes later���updatewidget���c���� �5� \e�������� 5 hours later���updatewidget���Qs���������Close���updatewidget���c����������Delay���updatewidget���z�Ssf�e��������Update���updatewidget +\ No newline at end of file +diff --git a/kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.ts b/kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.ts +new file mode 100644 +index 0000000..480f39a +--- /dev/null ++++ b/kylin-update-notify-immutable/translations/kylin-background-upgrade_zh_CN.ts +@@ -0,0 +1,151 @@ ++<?xml version="1.0" encoding="utf-8"?> ++<!DOCTYPE TS> ++<TS version="2.1" language="zh_CN"> ++<context> ++ <name>Form</name> ++ <message> ++ <location filename="../src/updatewidget.ui" line="16"/> ++ <source>Form</source> ++ <translation type="unfinished"></translation> ++ </message> ++</context> ++<context> ++ <name>QObject</name> ++ <message> ++ <source>The system is updating silently</source> ++ <translation type="vanished">系统正在静默更新</translation> ++ </message> ++</context> ++<context> ++ <name>trayicon</name> ++ <message> ++ <location filename="../src/trayicon.cpp" line="10"/> ++ <source>The system is updating silently</source> ++ <translation>系统正在静默更新</translation> ++ </message> ++</context> ++<context> ++ <name>updateTip</name> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="548"/> ++ <source>The system is updating silently</source> ++ <translation>系统正在静默更新</translation> ++ </message> ++</context> ++<context> ++ <name>updatehandle</name> ++ <message> ++ <source>The system has completed an important update. It is recommended that you restart immediately.</source> ++ <translation type="vanished">系统已经完成一项关键更新,建议您立即重启</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="319"/> ++ <location filename="../src/updatehandle.cpp" line="327"/> ++ <location filename="../src/updatehandle.cpp" line="333"/> ++ <source>The system is updating silently</source> ++ <translation>系统正在静默更新</translation> ++ </message> ++ <message> ++ <source>System update detected </source> ++ <translation type="vanished">检测到有系统更新</translation> ++ </message> ++ <message> ++ <source>System update detected</source> ++ <translation type="vanished">检测到有系统更新</translation> ++ </message> ++ <message> ++ <source>The system has completed a critical update, and some software packages failed to update. It is recommended that you restart immediately</source> ++ <translation type="obsolete">系统完成一项关键更新,部分软件包更新失败,建议您立即重启</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="116"/> ++ <location filename="../src/updatehandle.cpp" line="355"/> ++ <source>System update</source> ++ <translation>系统更新</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="511"/> ++ <source>The system has completed an important update, It is recommended that you restart immediately.</source> ++ <translation>系统完成一项关键更新,建议您立即重启</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="513"/> ++ <source>update error</source> ++ <translation>升级失败</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="589"/> ++ <source>kylin-background-upgrade</source> ++ <translation>后台更新程序</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="592"/> ++ <source>update</source> ++ <translation>系统升级</translation> ++ </message> ++</context> ++<context> ++ <name>updatewidget</name> ++ <message> ++ <source>Please remind me later</source> ++ <translation type="vanished">请在以下时间段之后提醒我</translation> ++ </message> ++ <message> ++ <source>at</source> ++ <translation type="vanished">在</translation> ++ </message> ++ <message> ++ <source>No more reminders</source> ++ <translation type="vanished">内不再提醒</translation> ++ </message> ++ <message> ++ <source>No reminders</source> ++ <translation type="vanished">内不再提醒</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="42"/> ++ <source> Updatable app detected on your system!</source> ++ <translation type="unfinished"> 系统有更新项目</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="51"/> ++ <source>Close</source> ++ <translation type="unfinished">关闭</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>30 minutes later</source> ++ <translation>推迟 30 分钟</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 hour later</source> ++ <translation type="unfinished">推迟 1 小时</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>3 days later</source> ++ <translation type="unfinished">推迟 3 天</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="70"/> ++ <source>Delay</source> ++ <translation type="unfinished">推迟</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>5 hours later</source> ++ <translation>推迟 5 小时</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 day later</source> ++ <translation>推迟 1 天</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="69"/> ++ <source>Update</source> ++ <translation>立即更新</translation> ++ </message> ++</context> ++</TS> +diff --git a/kylin-update-notify-immutable/widgets/Button/button.pri b/kylin-update-notify-immutable/widgets/Button/button.pri +new file mode 100644 +index 0000000..ded778b +--- /dev/null ++++ b/kylin-update-notify-immutable/widgets/Button/button.pri +@@ -0,0 +1,6 @@ ++SOURCES += \ ++ $$PWD/fixbutton.cpp \ ++ ++HEADERS += \ ++ $$PWD/fixbutton.h \ ++ +diff --git a/kylin-update-notify-immutable/widgets/Button/fixbutton.cpp b/kylin-update-notify-immutable/widgets/Button/fixbutton.cpp +new file mode 100644 +index 0000000..fed4aad +--- /dev/null ++++ b/kylin-update-notify-immutable/widgets/Button/fixbutton.cpp +@@ -0,0 +1,36 @@ ++#include "fixbutton.h" ++#include <QFontMetrics> ++#include <QDebug> ++ ++FixButton::FixButton(QWidget *parent): ++ QPushButton(parent) ++{ ++ ++} ++ ++FixButton::~FixButton() ++{ ++ ++} ++ ++void FixButton::paintEvent(QPaintEvent *event) ++{ ++ QFontMetrics fontMetrics(this->font()); ++ int fontSize = fontMetrics.width(mStr); ++ int showTextSize = this->width() - 32; ++ if (fontSize > showTextSize) { ++ this->setText(fontMetrics.elidedText(mStr, Qt::ElideRight, showTextSize), false); ++ this->setToolTip(mStr); ++ } else { ++ this->setText(mStr, false); ++ this->setToolTip(""); ++ } ++ QPushButton::paintEvent(event); ++} ++ ++void FixButton::setText(const QString & text, bool saveTextFlag) ++{ ++ if (saveTextFlag) ++ mStr = text; ++ QPushButton::setText(text); ++} +diff --git a/kylin-update-notify-immutable/widgets/Button/fixbutton.h b/kylin-update-notify-immutable/widgets/Button/fixbutton.h +new file mode 100644 +index 0000000..2f30dbe +--- /dev/null ++++ b/kylin-update-notify-immutable/widgets/Button/fixbutton.h +@@ -0,0 +1,21 @@ ++#ifndef _FIXBUTTON_H_ ++#define _FIXBUTTON_H_ ++#include <QPushButton> ++ ++class FixButton : public QPushButton ++{ ++ Q_OBJECT ++public: ++ FixButton(QWidget *parent = nullptr); ++ ~FixButton(); ++ void setText(const QString &text, bool saveTextFlag = true); ++private: ++ void paintEvent(QPaintEvent *event); ++ ++private: ++ QString mStr; ++}; ++ ++ ++ ++#endif +diff --git a/kylin-update-notify-immutable/widgets/widgets.pri b/kylin-update-notify-immutable/widgets/widgets.pri +new file mode 100644 +index 0000000..da4ea4f +--- /dev/null ++++ b/kylin-update-notify-immutable/widgets/widgets.pri +@@ -0,0 +1,4 @@ ++INCLUDEPATH += $$PWD ++ ++include(Button/button.pri) ++#include(ComboBox/comboBox.pri) +diff --git a/kylin-update-notify.pro b/kylin-update-notify.pro +new file mode 100644 +index 0000000..2206f0c +--- /dev/null ++++ b/kylin-update-notify.pro +@@ -0,0 +1,4 @@ ++TEMPLATE = subdirs ++SUBDIRS = \ ++ kylin-update-notify \ ++ kylin-update-notify-immutable +\ No newline at end of file +diff --git a/kylin-update-notify/checkUpdate.py b/kylin-update-notify/checkUpdate.py +new file mode 100755 +index 0000000..23ce81a +--- /dev/null ++++ b/kylin-update-notify/checkUpdate.py +@@ -0,0 +1,20 @@ ++#!/usr/bin/python3 ++import apt ++import subprocess ++ ++def calculate_upgradable_pkgs(): ++ cache = apt.Cache() ++ pkgs_to_upgrade = [] ++ ++ for pkg in cache: ++ if pkg.is_installed and pkg.is_upgradable : ++ pkgs_to_upgrade.append(pkg.name) ++ ++ if cache.get_changes(): ++ cache.clear() ++ ++ if len(pkgs_to_upgrade) != 0: ++ subprocess.Popen('dbus-send --system --type=signal / com.kylin.update.notification.DownloadFinish', shell=True) ++ ++if __name__ == "__main__": ++ calculate_upgradable_pkgs() +diff --git a/kylin-update-notify/checkUpdate.pyc b/kylin-update-notify/checkUpdate.pyc +new file mode 100644 +index 0000000..d168620 +--- /dev/null ++++ b/kylin-update-notify/checkUpdate.pyc +@@ -0,0 +1,2 @@ ++� ++'�bc�����������@���s9���d��d�l��Z��d����Z�d����Z�e�d�k�r5�e����GHn��d�S(���i����Nc����������C���se���t��j����}��g��}�x3�|��D]+�}�|�j�r�|�j�r�|�j�|�j���q�q�W|��j����ra�|��j����n��|�S(���N(���t���aptt���Cachet���is_installedt ���is_upgradablet���appendt���namet���get_changest���clear(���t���cachet���pkgs_to_upgradet���pkg(����(����sT���/home/lxy/kylin-background-upgrade/OpenKylin/kylin-background-upgrade/checkUpdate.pyt���calculate_upgradable_pkgs���s���� c�����������C���s ���d�GHd��S(���Ns���haihaihai luoxueyi(����(����(����(����sT���/home/lxy/kylin-background-upgrade/OpenKylin/kylin-background-upgrade/checkUpdate.pyt���test���s����t���__main__(���R����R���R���t���__name__(����(����(����sT���/home/lxy/kylin-background-upgrade/OpenKylin/kylin-background-upgrade/checkUpdate.pyt���<module>���s��� +\ No newline at end of file +diff --git a/kylin-update-notify/data/Resources.qrc b/kylin-update-notify/data/Resources.qrc +new file mode 100644 +index 0000000..d68938f +--- /dev/null ++++ b/kylin-update-notify/data/Resources.qrc +@@ -0,0 +1,8 @@ ++<RCC> ++ <qresource prefix="/json"/> ++ <qresource prefix="/"> ++ <file>update.png</file> ++ <file>background_upgrade_icon.png</file> ++ <file>close.png</file> ++ </qresource> ++</RCC> +diff --git a/kylin-update-notify/data/background_upgrade_icon.png b/kylin-update-notify/data/background_upgrade_icon.png +new file mode 100644 +index 0000000..19fb6d0 +--- /dev/null ++++ b/kylin-update-notify/data/background_upgrade_icon.png +@@ -0,0 +1,23 @@ ++�PNG ++ ++��� IHDR���,���,����Z���sRGB�������gAMA�����a��� pHYs��t��t�fx���IDATXGMY�{U�տ��c�m����06�c��i`v &.��� ���x6�ll�R�����$uT�$ے%g��8{�k������U�w��UU�+$.1.��6<u�z\T�~�tQ�)�� ++b��%J瑘:�Ʌ��Z�����+���0�t �<W������x]�p��B�%�s��~��%�|���P8�}��P���j\�I���(�42�%�+��b��C�%����9�f�!��A(9 $ o(-�@ ���D,SB|r�מ���"ҌD�<"\�2<��IF����E�������ɠ^�H�� H�9���L���[F� "�B� D�)D��6K�E�$ ++Ǡ��F8�n� ��,bY�/-��&K�ɞ�>q�D� 2S&�ȯ4qc{��O�~�,�.�A�>��0ʛM̞G2?�G�0��L� �bl#�Fc�"@�h���� �$�44�7��\٩dg�"�0���R�¼�]D�d�d=w�N�N{�` �8-���`Q�13w�X���l�@����� ��ɢA8G�`��*�H<�0C�9a�4!�ct4�x&���E�|��%%�0%"�שu��:��2`��%�v�&�>̈r?=w��kВ�p�IxB)��0_0�a|"���<b-�u��~�L��4ҙ���p�L�L ++�D�2 ++C�5hA�3�Hc�8�li��YD�A�2���܊+��� v�!#*QL�(�%Q<��9&Y�����K�Kv�P�rc�bƁ�������=Op�NБ2�Z'�G���[�籽8r�0jHģ� Δ�G�С�h���0��GL$�ʠˀ)}�A���"&gW8E��N���I��8|�W��x��g��ю��Ztw������[H���!� ���p���}�vtvu�����5��߇�����c\��G�l��wI�3E�"�����9�x:O�SԒd���r ���'H�N���`C�G���ՕhiiAWg7:�ݽhnl�SO���C�{5|��A������AwOz���mk[:�����4�"��b�ۀH.�Tv�NBi�ɶ���ˀ)nI2aw��OMΒ�A�ԟ5�S�ɂ�)�18�O���ف��v�U@6�nF�� ��uhjhFue :�;�ۻ �6mFO�Vl�|�ׇ;��P��i�s(C��#x��p��>�Ĵ��L�`��C�?3��4/�ȨN�ڔ���Tdد�)4�������!�]܋��n�|g{��vw������ޞ���f��;����2i�|%AVh��d�~?�6����3�Q��P��z�R,�0���F�ɠ�f����Yڒ���ȧ���CG[':;z�2���[������U�����0(��n�voR����f���H�&�5&Y�4� ����T�Z��,��K�N� yz�i���!� o�31��a� xxp�m�B@md�K�jo'PS+vp�w>����^~�e���صsY�Ac}#�9]d3�,�ٷ�%���G��&�Aw �� Zhpzu�\���0�01�7+���_�?2!B����ѯ����¡}�۷�SS3��S�hnh�}�܋�?��t<�lf^^;j����D�1;�;p@��P���4)�4�>O?��81��َ>��=��:+!g�Oƽ�a"�E�HY�Q�,����`��)vѩ��樃�����XIvPWS��65���.�WSS�I'ȍO����mw��� ++5��:To؈f������� �a���T2�dZ9Kuu JR&Iֺ&4���8�$�"&}i��kCE����<�8����j~4v�l�������B[��Sډ�n���S_�Z�c�v�ā�n��D�m��W��l����p��a$������ �/��-Q�V��r1�t��W^�%�D�t μ4Z �YE�rȝ^��Cv����W��z��� ]b_�vS�b����F�eu%�@��$�Z�$���c�~��z}%�z�-$��n�S�I���Ҧ��D���>����OW�$I�Q�9;s�cnv]��Ɉ����Ƈ4H'�jG'Aa���[��6���UaS~�^���� ��@��7_~��GmU�*"x5D��n�LJ>c"��8��$Ѵj*�S�H��9.��1܈�Wؽ�!ZW5YmU��bR���C�P�+P2�V�������賓�8q�{���E5���m�D$I}/��r�V�����& Lʯ��n�uM���eV�{��,;���t0����uAs��w9����"H�-��46���}}���سW1*!��p����j�r��-T�V��W�ʴ$e������h��y�A�ndi߱�.Y��!e��T�$�Z�Ed�s���E�u�����d��à<�l �y� Nk-��m v=�ƓI%aL��o��M^�N�ZB�E���[5(����z���9�-*D��յ�Xl,Vx��Wb�^��D:F�_��P�u2�z�q8 ځ�ıo��V+v뫫��"�jW��,��1I��~��r�pU´�~���&�E�O=�8�顗��Q ++����N���Y�h�3��)����Ԑ��CE���ƼeK��t��I�n�������'�[Í��xr�2���u��p�I�����+�v�ea��_�!��];���t��hy=�|Ԭ�O���r����fs!�J\1Β��a�����ㆋ�.�1��>z�=jn5ܬ�� c°���G>���WB@K���=Ʌ֦F�τ�_ا�I��=r}�.C/9x��a��&�%�a��˥T).,�l%=��{�7�s�a� ���ز���&r*����ܮX���oX�l�>�a�?��*�: ++��w�Tb����(-JZ�����vpUU �����'��=>8I����d���� �t.��Q+Y�8��}W� +++�WaX@�]��_W� ++X�M2��'����*����o�����s�uK�lTE�9:��y��D�lb�հl�<��~��8h�S@��g�Łɭ��m�0K�2��( �������J5���2(aS2|߳�)�d��R�!� ���=��w���GU��tѺ��X��_����˾܊�� �ؚĺu���7��:9�ba�B X�Y���f��trFEd(�U�%��JC°�[��&�<�ؓ��y� ++x)ºh\�W�J'��� ��>�MgT��Z��<k�,��|Κ57��O�(�6��*�qvlFa ŅK\�D`��qJ��p|��'Xw�Ů�taH� [�6)�Je[)�E�bueݒE�,3�������;��ʳ#�rc�PO�UjY��^<;e:ju�!�$&���0Wʓ�W�\a%�6�4��,#�6)YH�05H�kP�d+�{�����r�Yѷ��k�Uq�$�����CK����e�&�[���ˮZ��y+�;��t��V���0dC~�[��l� 8�%��� ++,v?ld�e��d�SXz��xP�'�PN���?>P�&�������It��K/�0�������ϔ���J�J���=���Nz��la�����eĥpH/K艹�p� �ڹZ��O��KU; �X�,"��⭿Y�-�}�Q����p�а�~tP�ˍ�vgE� ++�&2��K�S�g�V�����.��ZGɮ����!��E2w�O]�2��Rv���F�.�MIB�,a��մK��+�/��h&�U����W���VS�$!�ՋT����� �#��� 8����;j��\ X���/L/ �%`�%�� ++t�:����+p��w�L��N8iq�F�G�����s��#Gp��7�I|�l�n��>����x\y�z�/!��P���@keyD9ܶi�|�r5$f�Y�n��v���i����f/�|+4��C%�+�e'瑟g���U�� �j%�����u;��ѯ��-k~M@a"� b�ڬ��_G��<�m%� �6���@d&D�����T���:ս �2 ++��'��6��a��$Ɍ��7?ZiE���w��J(Şs|�,,j�fڊ �Cd����U2���X�v-j��hR�N��DW�R�����x� � ��٪zT�|8�##dt��;��d��� ۰�xS�4���{Ѽ�U%`y�/0�r+�@(w)^��+�����Q8�c�P?l���_�U\QW��lVW�*��� ǎ~�Մ�̹N����77���(�Z�݈{���{�b�2s�A�LR�c2���p5Oߍd�"�����>c�><} �,Y�����\:�Xr�k='l#���%�'x��Ʒ_}�� 7�Y�_���_���\E��a<�����gR���(~����_� ++��{�����}%�l�LnVWѮy`����4=7>>�D�2�W�8Ov� ++*|�t��e��ryR>��jz�k����V'�,�e24� ���������ݗT>y���,���S��v31�w��W�x��w��7���{��f��:�-_#Y��XR ���O0r�/��dX+�[�+N��� �y�|ّ7���j����6�itQkc���ɓ�S�1j�筃</�A50 9.[���FFhY6�����w�#��')E��F�����(FK�%K��B[����J��Ǚ���qp��*�ɳ���(�d��^���m6'��Y��2<ٯ�r,Um�`d�m�F9F04t ++#,J#�������@�y��^�s�{�5��T8wa�5��R���|��W��$�D���e�U�ǂ��J�p@,��s0u�"3�� ++�ĩ�a�:9�~��t���any~d� ++�p9�-ꜙ���T�j��i�]B|f��X&��Kd�y5I��]��(\U*��Qiy������ڗ�{�7����7;��&�,-�ĵ�xa��$W�a.��8�+Y�c`p'OYV(��U7l^�T�篠�x��?�X�˧.2J�t>+�0�+ ++p(�u�'e!�����A�GE���Fa�!Dd�=5-�$!'9���z�"��Kl�W09�Ț?����Y�R/���1��u�s+H�:�4�C��x��,R��pT���EL�"]�,]����^6 �����IEND�B`� +\ No newline at end of file +diff --git a/kylin-update-notify/data/close.png b/kylin-update-notify/data/close.png +new file mode 100644 +index 0000000..ff39832 +--- /dev/null ++++ b/kylin-update-notify/data/close.png +@@ -0,0 +1,6 @@ ++�PNG ++ ++��� IHDR��� ��� ���szz����IDATx��W�RRa�Q���$���N��t���e# FFx �j3�������,=Cы��L5�7��c�0�̷��{�}|��S�?��G �Wpza��x�(��h�yTT�"��:!34��W�{�6�Q����`�($��ېj� �5�wҋS%X���V�����%1�CTg�X}���q��@(7�Je��>wAH��G Tj��[0��\����$*+!��u�T:��6�����J젺�)M��9� o� �2]F}�Ԇ�"�N+�p��fEbnq�u����ܳȨ�����ZD�����21�"��R���ȸ����;��P!��������PZ�C�iƓ`Yu\"��ѡ��la�E�ZrP#&�Qd݊/ëx ++r� *G[��r<'���(���CY�id���j�Lh���J��B�`��LF_����Q�XN�0�K�Mct����2 �7���a6X�T��2���ذ;���q6�lA����V0�m�uf��Ph�P4���3�ԂjR���U��#IH� G���ա�{Tq&��=��'�d4�w��p�D���}�7(gx�v?,� ݳ��:�LN���gx��3dG�`5h�*\# ++,%!��P�[���.|8J�P�fuMZ��aO����@ oA%g���=K�B��@�ia��}=��CL�)���fU���$u�z8�e?�]3a�S-��Ft�%?�`mT��C�/$�`B�@�lƸ�e^+���!X SN���|%��P���sf ++.�R��;� �>M�}���K�L, ��J����y�إL�~X�У�}��Z�4���z����9:S��d5���6�Ԩq��u�0�G �5���+�i��:�����(������+9N�����8.$~��F���O����IEND�B`� +\ No newline at end of file +diff --git a/kylin-update-notify/data/kylin-background-upgrade-manul.service b/kylin-update-notify/data/kylin-background-upgrade-manul.service +new file mode 100644 +index 0000000..34f7c2a +--- /dev/null ++++ b/kylin-update-notify/data/kylin-background-upgrade-manul.service +@@ -0,0 +1,10 @@ ++[Unit] ++Description=系统升级后台检测程序 ++ ++ ++[Service] ++Type=forking ++TimeoutStartSec=infinity ++ExecStart=/usr/bin/kylin-background-upgrade --check-upgrade ++ ++ +diff --git a/kylin-update-notify/data/kylin-background-upgrade-manul.timer b/kylin-update-notify/data/kylin-background-upgrade-manul.timer +new file mode 100644 +index 0000000..4268f77 +--- /dev/null ++++ b/kylin-update-notify/data/kylin-background-upgrade-manul.timer +@@ -0,0 +1,12 @@ ++[Unit] ++Description=系统升级定时检测 ++ ++[Timer] ++OnStartupSec=5min 10s ++OnUnitInactiveSec=5min 10s ++AccuracySec=5s ++Unit=kylin-background-upgrade-manul.service ++ ++[Install] ++WantedBy=default.target ++ +diff --git a/kylin-update-notify/data/kylin-background-upgrade-silent.service b/kylin-update-notify/data/kylin-background-upgrade-silent.service +new file mode 100644 +index 0000000..d10f47f +--- /dev/null ++++ b/kylin-update-notify/data/kylin-background-upgrade-silent.service +@@ -0,0 +1,10 @@ ++[Unit] ++Description=自动更新托盘更新程序 ++ ++ ++[Service] ++Type=forking ++TimeoutStartSec=infinity ++ExecStart=/usr/bin/kylin-background-upgrade ++ ++ +diff --git a/kylin-update-notify/data/kylin-background-upgrade-silent.timer b/kylin-update-notify/data/kylin-background-upgrade-silent.timer +new file mode 100644 +index 0000000..89a2a70 +--- /dev/null ++++ b/kylin-update-notify/data/kylin-background-upgrade-silent.timer +@@ -0,0 +1,12 @@ ++[Unit] ++Description=静默更新定时检测 ++ ++[Timer] ++OnStartupSec=30min ++OnUnitInactiveSec=2h ++AccuracySec=20s ++Unit=kylin-background-upgrade-silent.service ++ ++[Install] ++WantedBy=default.target ++ +diff --git a/kylin-update-notify/data/kylin-background-upgrade-template.conf b/kylin-update-notify/data/kylin-background-upgrade-template.conf +new file mode 100644 +index 0000000..0ac8fb8 +--- /dev/null ++++ b/kylin-update-notify/data/kylin-background-upgrade-template.conf +@@ -0,0 +1,9 @@ ++[Settings] ++powersize=1 ++setpackagesize=999999999 ++ ++[Timer] ++checkUpgradeTime= ++checkUpgradeTimeSlot=9:30-11:30 ++RandomizedExecute=True ++ +diff --git a/kylin-update-notify/data/kylin-background-upgrade.desktop b/kylin-update-notify/data/kylin-background-upgrade.desktop +new file mode 100644 +index 0000000..2e53db2 +--- /dev/null ++++ b/kylin-update-notify/data/kylin-background-upgrade.desktop +@@ -0,0 +1,10 @@ ++[Desktop Entry] ++Name=kylin-background-upgrade ++Name[zh_CN]=更新管理器托盘程序 ++Exec=/usr/bin/kylin-background-upgrade --check-immediately ++Icon=kylin-update-manager ++Type=Application ++X-UKUI-AutoRestart=true ++OnlyShowIn=UKUI ++X-UKUI-Autostart-Phase=Application ++NoDisplay=true +diff --git a/kylin-update-notify/data/kylin-update.timer.conf b/kylin-update-notify/data/kylin-update.timer.conf +new file mode 100644 +index 0000000..09880ea +--- /dev/null ++++ b/kylin-update-notify/data/kylin-update.timer.conf +@@ -0,0 +1,6 @@ ++[Timer] ++CheckUpgradeTime= ++CheckCompleted=false ++CheckUpgradeTimeSlot=09:30:00-11:30:00 ++GeneratRandomTime=true ++RandomizedExecute=true +\ No newline at end of file +diff --git a/kylin-update-notify/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml b/kylin-update-notify/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml +new file mode 100644 +index 0000000..cc35fcd +--- /dev/null ++++ b/kylin-update-notify/data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml +@@ -0,0 +1,39 @@ ++<schemalist gettext-domain="ukui-log4qt-kylin-background-upgrade"> ++ <schema id="org.ukui.ukui-log4qt-kylin-background-upgrade" path="/org/ukui/ukui-log4qt-kylin-background-upgrade/"> ++ <key type="s" name="log4j-handleqtmessages"> ++ <default>"true"</default> ++ <summary>hook qt messages</summary> ++ <description>Control if hook qt messages</description> ++ </key> ++ <key type="s" name="log4j-rootlogger"> ++ <default>"DEBUG,console,daily"</default> ++ <summary>config rootLogger's level and appenders</summary> ++ <description>config rootLogger's level and appenders:"level,appender"</description> ++ </key> ++ <key type="s" name="log4j-appender-daily-datepattern"> ++ <default>".yyyy-MM-dd"</default> ++ <summary>daily log file pattern</summary> ++ <description>set daily log file pattern format:one day</description> ++ </key> ++ <key type="s" name="log4j-appender-daily-layout-conversionpattern"> ++ <default>"%d{yyyy-MM-dd HH:mm:ss,zzz}(%-4r)[%t]|%-5p| - %m%n"</default> ++ <summary>set log message's format</summary> ++ <description>set log message's format</description> ++ </key> ++ <key type="i" name="delaytime"> ++ <default>3600</default> ++ <summary>set check log files delay time</summary> ++ <description>set check log files delay time</description> ++ </key> ++ <key type="i" name="maxfilecount"> ++ <default>7</default> ++ <summary>set log files count</summary> ++ <description>set log files count,unit s</description> ++ </key> ++ <key type="i" name="maxfilesize"> ++ <default>512</default> ++ <summary>set log files total size</summary> ++ <description>set log files total size, unit M</description> ++ </key> ++ </schema> ++</schemalist> +diff --git a/kylin-update-notify/data/update.png b/kylin-update-notify/data/update.png +new file mode 100644 +index 0000000..fe222a3 +--- /dev/null ++++ b/kylin-update-notify/data/update.png +@@ -0,0 +1,36 @@ ++�PNG ++ ++��� IHDR���`���`����w8��� pHYs������~���<IDATx��] tU���z�B:!D��"��#��(0��ˠ�˸�ί�"#"����:���������8��"*��DV�M�aIؒ��鵖��Z��/U�՝��9���E��-w���W�ɲ�������������:��{Q�����TA m���b�U�h9WUUE��3�f�c�]�lt}.�g#��t�s͙���T���?71�:�b�`��;�H��%��Q233QUUu։q�@!��<s���3 F���F�/27���*?9o�h�Y�����yyyC=^O{��ٜ��t��V�ɲ,��E�"�.?sfM�.�_�.hD� �Cf%bڴi|AA�����YVV��ҥ�кukaȐ!�Y�RF�OF��;q��7n��S�N�}YY�9��fP ++I�!KP?̗�9(�x��8p�: AkjjKJ/����%1�VG��#GbÆ ��s�;M�t�Y���q{;����Xda���o������ @W#�w��.���Ov�8q⬜��a���|DQ�(ɐ$ ���?��p�^!�$�bUe���,|g�CS��hĈi��d��梼������&�־�ݼ#�jQ�'õ�����;���������z�A!]G��Ï�zԨ��Ҽ��QBL�rxc�����ԈGJ ++ ++�}�kF���z�p8�b�eWOߡ�d�<N\q}�yv��dАO73�5j���i�|�屘�p��D"\.�"�k�2z��7D�Ѭ�.���n�&�2�����/yy��{M�]�!~��:N�:��f��DIB�gD<�n�<ΔW�3ẑ���;��pzR鏨��b�C��^���F�T�|��~ؾ�����0�9B��9�xDABH�B�TWu�r��g�%U�y'+pp\f�(��3��M9j�|�^���ӣ]��U_��uѣ�(;���9�|AĞ=���DM���!��?eʔ���$���φ������|�-����6U<�sDQĩӧp~��sMs8��رšyV��4L���˯�g�/�='�W����T��g�e�e��d~��P]S��`PPP�lR�'�v�ӊ�K���o3&�q��I�D�� ++�W��������������oKD|Z�^w�7���Y�� 1K|% U�m`���jǣ��C�?�����P8y䯩�q�Q ��H�} ++�/r���<֜���/E�d|Z�)�����dz'd��)E|0���LQ܌!ᤓ5�4�(�'��]��c��� b|bŢG�$\_$c q<x�βNf�H����G����8y|Z���B ��4���r!;;e�F�`TǢ��P�l���F�N�矯�����`D1dJ��f�{BZ �l�R�Fuq8�0t��J��_���" �"پ�Bp�U <X?W��l��}��a@i(����_�P $$��ѭ��y�^��W���D�t�]���W~�g��xU��x��&�2�#�_��N��[Ɩ��?N�gm;_mڶEQ�l�Q�����c�_�<yrBd Sz_�t�CS��7�ˋ/�]�I�h45��|�x8����2��g_�iI���~�x�'����6�� ��4�Қ�(+�2���۶mK�;����Y�ϔ���٥6Ii�zn�`��M�� 9����]�ߏ��o��an<Kj�%��Ͻ�U���`-a�D�;�<��}��W����o��eeu!�m�z�jm]��l4�K3�S�/�^�@�X��kK�E!��������`DW�m۶�d�D�5+���� � ��@0�l�4� �l��<_g*��!��p�a��"o�ك���%U1�����ׁ��-�W֯��h�7���K�-++���� ++b�?.�C��N�Y����r#��y�p6 3�u�0���'*#- ��Uַ ++�������8u�$j���ϧxM;v���ޛ�"w$� moA����|rEE�!��$�������+r�����jm���j��S�J'��N5�F����x�~;�x!p��q �ژ��t:��wZ��S�!���N%p��������?��[o.�v�痩y�G2+��y=��U�+?�lC������\��G o�xecPV���}L��x��OaN�J���r�01���A ;�ٍ,�t9�~�|ԗ��J����4)��� K�h�q��9s������6j�����QCt?�x�5$�����-��FF�V����~rF��2��F�tNU�n�pr�y\�A�WG�XL@zVz��w�t��� ++��~2�lVs'��Ѹ?����O�;[���T ++ ���\��}!zL�=�!> ++�ʕ1�'�q-�UQ���,����2Jkx ��8U2XuGƌ�Ȉɘ�]Ƅ֩;d{���پ������#�n��d#�'sܸ�]�|��ŕ ��,~v1�U�<ʂ@K/�6]V⤽�j`���C2P�~f7�|��[Z���~R�g�|wLĦR�P�l���|�vq��y� �N�x|�Jbk2y�˩rmD|QF&t�Tq�}-]��\�t�d)���1�����6���A\PG��|�G�z���{n���# "�k�9�5�V3]Ӹ�ZR�;�������]R�Kb(L�j�Gw]����.Tƀ��y��& N����ί[���+���q;��^�.��ݔDtW�t�����Ⴊ��%���ov:UQ�:��p����Á?�WJ��I[�ȍ�������^��qx����&�����������+D�ȵ�PvVZ4-�ۋ�F���I˧��~���F���0E��2�>�i���UF���Ņ1��W[��|��$�x7�O�J�3I@���D��D}Z����D��������3X8� ++d<���~��������_F�FC��HW ���#3��1)x��(f���*���:*��"� ++K����(�ެFö�P���"�ޢ�- ��٣ǵ�>��Y�C�C���������z ���y5#i7�CD�Z5����1�=���1���i�Oô�cX�_���k;��� 6�}N/���Uvvvo P]�O���G k�NW��ƚ�%G���b�j$dgɘ�WD�_�c+����:�VR��K���\��JszJh�IJ0ְ6�b�|ZK\����fj(�|�ي�DbB¹��}�� OV<���ed�8ܿ4lױ����Z`u5�� ++�� ++��X��"j�`D=�2��9����A�Ɯ%m|8v�Kx;���u�S*�7"�Ӡ�3���S�N��l hC���,��ܟ)c�2��%�m~mT3 ({�p����t��O3�e��s�V���#ؼ�BQ��y7�1m*��p���{;1�#��la��! ��L'T�d�,���m��})d8�3��w6�l��NQ���q@�F�N"�� r�8T���wQ� �wN�Ŷ zta�k���6\��Qy[n�W����� �m�忶�p{/�w1{��8JF}�Hq(�U��>�>����i�6.9�('q�!�j<ϧ��*��x�(��* fbM8)�b\>��T@Q�"Jh8��Ċ}�yy�9���=�����6� ++�jt}k[YE��|ugጌV�D�ss\a����4F�4PA<sͳj��re�-r�e���zd ++�~6�I�ZP�ѩ��,'�h��&�̠Fĥ�yL�]l��A^�Mp0l���SP�0����w���P�\F��"V��5ڝ8�C�`e���\�L��ы2>& ]����F�K�U�cW�q^GbRNF���2m���7n�T셕Q�_���'�{鴴dxd �n��%3�ە�x@�;'F��B�hTL��GiYN�\�K#�I��.��]v�Z�� ��A.�<\�s ��{c�Z�h���9\u��p���Ǭ�1n�*)���@�4PA�K��`l�77a�\�>Z]Q#z�^$u�`���=�щbQ%̍� 0E>� Т2f̘�٤���>� ++��E��c�~%�i��O�ِ kL`B�JQ�g��O@�KAF�t���A�� ?>`����������y��)�acMN��i��+�#{�B֠�H}|-}��Yu@b0� ����]�jc)��VԺ2ʩ��D��a��P�c��qC���%�|<�zq�Q]�(�Mm��zȈ�u�0KG��?Yˣ�eGjO,�5�<� ��æ��}�hK�Y ����z�n$5��� 0S�C"0�d�F�P�0�G�q����n>�ҹKK������p�Ө�شCV���/��/V��k:��ֹQ��(C��u]G�h4J���wx A6�U�1ts�v�����B^�f�@���ᕱ�o��B-ݖ1F����弱�$���8p�"*#��!�2a�:�I�}�T^~�Į���$��Y��UN�à�ܟ8T�@UT�}\@�u�����}_�.�U�8�;&�K�9l8沘/�}�c���z����Q�N|Yt.ȴ�J�i;ԞP���/�Qt��1�V����n�>��hɋ�>6���gI��l:P�o�5�r�7|;�%\�ҁŇj����RK���Pr�w����ϝ�$����ճ!����%�/��� ++��]}��fByvS�m�f�X��}�#��&f}ښg/��|uҁ+��0�3���9d{ա�a`�A_�Q��R�aa c�������`�j��i��߹!_�8E���A��E���@S�.y�㮝�G��p0HZ����`Ÿ�<�ī?�0���q��a��h6aq1��U#�Ԃ:���D ���q/>>��`��� ++�����Q�Գ���-�s��Y�8T� �>���������1K��� ++M ++�8����a��@ܻ��)�8��wɝ�I+����1�]����L��MK��ji�4�ӳ��(3�%=u�F=u&��(ۗ��\�-�����F��P)81�.��1}j:�;��~55�.�G1�f':��ٍ������MԪ{je��x����ӻ�ċ� ++b�P�:�۷}�h���Qu�%�Z"��9l��ū�x���½w���/��d@8�P�_��\X�ׁ%{����N�i%V��^������n`��E3x�"��o�ٝ>7pULj��b7b��:�s�O�?w90m����M6�Kc��AVςy���8�\��[�N<�M�J|'�BP�pY�����lg�����8�4�*��Oäk%�9�Ҏ|n۹�Ռ��\�A��qϒ,��R7�z�e�����d�ﴌ�7po/R�"��(=��<�q�~rq=Ȫ��1� �?)]Qqo�%��TT���2��-����ڃ5�e�5S���ӗ��r3 ȵV��F�Q�T�H=GMi��|�h�C�H��ڄIi�I 8%Z h��' � ����|��;�z��Σ��,�{�͏�-����b�K�z�IP�7��� ��5��33�<����z�� �Nf|QC���ks�Ю����%���ߺy�;# �Z��P�\�R��쎝:�^����D���p��эM?��?�#�����$�)��O8"��V9�z��v(��u�vm7uQm��Ro}A���J@3G���hׅC�^<���A��j��9�������\L+���6�#@�2�e��q����\Bߋ�xfx�6��5f�ț���}��ŴZ ++�]���R�� m�w�9(�4bTsh��1��t���ei�`��sdH-�u ++����^(4X|�����ƫ���������P�Cuy���|��'$xD �� ��_ďc�+8t��kF�M!��:�!�)Qg���G�iv K'�W����w�؞� ���M2q�\gZ���� ���N����^��E���E�'vsaW�K=Z�(#|H��K$�����Z[ܝ&O��_��|�F���"dvH��|�WSC����,�br� l ++"{Շ �0�J���frC�WB��Wb�|�B8.���������mip���5��fx��:@�/D�Q�E43�;���9A�l��F��ǚ5�~gJ�h�fjxYjN����*o��nu[S)㖱A�ϒ��^���BO�ٰ�T{B�����1��~�� ++�~���֭�Wۍ_�ڝŐ�$�g�IYOfpmU��I��i�w���˕��p��|�s `��rEu P��=�Q ��)��Щ�`?pk������ƚD���gfL����V���� 2E���P�bL���+�����q;-e�~ ++-��������7_ڷwO9Ť���(� @KA�zs��-�7�i�螨�,�l� @�TCŘ���#%��~d�B��r6Z��ܹ������V/ܯ@��� �H�HI���B���Ь�,�8S~�1+8I���EmDY��C2p@�K�g��G�z��VPY�D�?�C�L�WT}�����p��4F�N��T�A�=>S{C����3O��ʫ���q�������s�8u���Y<@�2bq��J�t�m��;����J*9,����6C(�xf�]�W��g�����b��N}����g�����o��0SAR 0v�V�q7m\tG�D"�p*�[�B*��y"��A5C������ ++<rE�|�{�����Q|�d9.̌ԥd4�Z�O����N��$�"�<5�ɂ5_��dTm�LUcJ�h/�10�J�D,�dɾ��~�A*���:�G��bj�zai � ++�7�a��jdy��"�-�}5��Q��:O5�+�AU]uȋ����ϊ������HZ!����H��2�ό�� {�tu���P�g>��𱿹m�Հf����+��ذ=�� '��(��xy��:�ۤYS���ך���L�3�2����C���bᓏ�>c��ϵH���xY�xP�#ao�QϑhFΘ����nj��M� ++�mtc��4��r)��?���%�!�����;�27�� ++��Kch�m�S :�g�,�9}� ++ԟP*(���v�Ɣ��)J�i�F��ڵ���퉧�{0U"4b��`��̞�����Ѹ�FS=���g]O[�ò� �'���������Ь_���Ͼ�ҽ��-Z7!N�:�+*�=��C[��������T��g�U=:�~���=�槫$� +����7�ɿ�Я��+����۶~�����Aq��S�&~R�G2��|\ � <�]���\����^��8����f9���Y��@�b����`��4d(����I]�z��{chiЉ�_{�۵�}�ɿ\߷߀!�2����臇��V�R9A����=��1�(1ϓ�����%�s?��ȵ�_��m'Oy亞���dJ(,ܽ���_�q��cT��b6�l�=1��+��8��L��S����?����! ++������_�i��z R���I�%5�H��0'�n�6x ����˺��ɗ_9t���e#��_�n���c��#G����Ex�b�EA~c_�ۨ��}��F�/C���=�Q�p��!]/�E��m��wLybPVz�h���wnX�m�g˗2�n�ft�Q~�Q���Y{��p�n�.�S�Z�m�]]��pan��99�ͳ|��DR�����**�%����>����TB1F嵢�n�w:�@g7S�v̠��% �<C��FR\TsRj��Gt�Z_�Ν"�D�M���(��0C Z���o�>7��T ^e�3y$��.�w1��rR�"�@@� ��`���w��`�O����&j�6�.����'����(�ؿ���`�K�����@�K��p= g����P�h'c?x���X$ ��m�g�:�\�g�����Y�Uu�R�J��Gb~S'MM�����:B�f���6�t��Ȍ$�\- \f��O��4�5�@?���Q.,���À�4Y�`D��76�J�:t�<&FD����_�`�kF�&�7����4�dV}�Z����IEND�B`� +\ No newline at end of file +diff --git a/kylin-update-notify/env.pri b/kylin-update-notify/env.pri +new file mode 100644 +index 0000000..673db9f +--- /dev/null ++++ b/kylin-update-notify/env.pri +@@ -0,0 +1,4 @@ ++PROJECT_ROOTDIR = $$PWD ++ ++INCLUDEPATH = ./widgets ++include(./widgets/widgets.pri) +diff --git a/kylin-update-notify/kylin-update-notify.desktop b/kylin-update-notify/kylin-update-notify.desktop +new file mode 100644 +index 0000000..72d60c6 +--- /dev/null ++++ b/kylin-update-notify/kylin-update-notify.desktop +@@ -0,0 +1,6 @@ ++[Desktop Entry] ++Name=update-notify-force ++Exec=/usr/bin/kylin-update-notify --check-upgrade ++Type=Application ++NoDisplay=true ++Comment=update-notify-force +diff --git a/kylin-update-notify/kylin-update-notify.pro b/kylin-update-notify/kylin-update-notify.pro +new file mode 100644 +index 0000000..450bff3 +--- /dev/null ++++ b/kylin-update-notify/kylin-update-notify.pro +@@ -0,0 +1,42 @@ ++QT += core gui dbus network KWindowSystem sql ++greaterThan(QT_MAJOR_VERSION, 4): QT += widgets ++ ++CONFIG += c++11 link_pkgconfig ++ ++# 项目名 ++TARGET = kylin-background-upgrade ++TEMPLATE = app ++ ++LIBS +=-lukui-log4qt ++ ++include(env.pri) ++INCLUDEPATH +=./widgets ++ ++SOURCES += \ ++ ./src/core.cpp \ ++ ./src/main.cpp \ ++ ./src/traydbus.cpp \ ++ ./src/trayicon.cpp \ ++ ./src/updatehandle.cpp \ ++ ./src/updatewidget.cpp ++ ++HEADERS += \ ++ ./src/core.h \ ++ ./src/traydbus.h \ ++ ./src/trayicon.h \ ++ ./src/updatehandle.h \ ++ ./src/updatewidget.h ++ ++TRANSLATIONS += translations/kylin-background-upgrade_zh_CN.ts \ ++ translations/kylin-background-upgrade_bo_CN.ts ++ ++PKGCONFIG += gsettings-qt kysdk-waylandhelper ++ ++FORMS += \ ++ ./src/updatewidget.ui ++ ++RESOURCES += \ ++ ./data/Resources.qrc ++ ++DISTFILES += \ ++ ./data/update.png +diff --git a/kylin-update-notify/src/core.cpp b/kylin-update-notify/src/core.cpp +new file mode 100644 +index 0000000..269318f +--- /dev/null ++++ b/kylin-update-notify/src/core.cpp +@@ -0,0 +1,22 @@ ++#include "core.h" ++ ++core::core(QString getnum, QWidget *parent) ++ : QMainWindow(parent) ++{ ++ updateHandle = new updatehandle(getnum,this); ++ connect(updateHandle,&updatehandle::execSignal,this,&core::execSlots); ++ this->setWindowFlags(Qt::SubWindow); ++ ++} ++ ++core::~core() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++} ++ ++void core::execSlots() ++{ ++ emit execSignal(); ++} ++ ++ +diff --git a/kylin-update-notify/src/core.h b/kylin-update-notify/src/core.h +new file mode 100644 +index 0000000..9647b0e +--- /dev/null ++++ b/kylin-update-notify/src/core.h +@@ -0,0 +1,23 @@ ++#ifndef CORE_H ++#define CORE_H ++ ++#include <QMainWindow> ++#include "updatehandle.h" ++ ++class core : public QMainWindow ++{ ++ Q_OBJECT ++ ++public: ++ core(QString getnum, QWidget *parent = nullptr); ++ ~core(); ++ updatehandle *updateHandle; ++ ++signals: ++ void execSignal(); ++ ++protected slots: ++ void execSlots(); ++ ++}; ++#endif // CORE_H +diff --git a/kylin-update-notify/src/main.cpp b/kylin-update-notify/src/main.cpp +new file mode 100644 +index 0000000..e3c717b +--- /dev/null ++++ b/kylin-update-notify/src/main.cpp +@@ -0,0 +1,206 @@ ++#include "core.h" ++#include <QApplication> ++#include <QDebug> ++#include <sys/stat.h> ++#include <unistd.h> ++#include <iostream> ++#include <ukui-log4qt.h> ++#include<qdebug.h> ++#include <QLockFile> ++ ++#define PROGRAM_NAME "kylin-background-upgrade" ++#define LOG_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade.log" ++#define LOG_SILENT_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade-silent.log" ++#define LOG_MANUL_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade-manul.log" ++ ++static FILE *fp = NULL; ++QString toDir; ++static bool _silentOrManul = true; ++ ++void msgHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) ++{ ++ static char logPath[255] = {0}; ++ int uid = -1; ++ static int pid = 0; ++ ++ Q_UNUSED(context); ++ ++ QDateTime currentTime = QDateTime::currentDateTime(); ++ QString timeStr = currentTime.toString("yy.MM.dd hh:mm:ss +zzz"); ++ pid = (int)getpid(); ++ uid = (int)getuid(); ++ // 获取用于控制命令行输出的环境变量 ++ char *ctrlEnv = getenv("BACKGROUND_UPGRADE_DEBUG"); ++ QString env; ++ ++ // 格式化输出字符串,添加消息发生时间、消息等级 ++ QString outMsg; ++ switch (type) { ++ case QtDebugMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtInfoMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtWarningMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtCriticalMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ break; ++ case QtFatalMsg: ++ outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid); ++ } ++ ++ if (fp != NULL) { ++ // 日志文件存在,则输出到日志文件中 ++ fprintf(fp, "%s\n", outMsg.toUtf8().data()); ++ fflush(fp); ++ } ++ ++ if (ctrlEnv != NULL) { ++ // 环境变量为true或者1,则将信息输出到命令行 ++ env = QString(ctrlEnv).toLower(); ++ if ((env == "true") || (env == "1")) { ++ fprintf(stdout, "%s\n", outMsg.toStdString().c_str()); ++ fflush(stdout); ++ } ++ } ++ ++ // 遇到致命错误,需要终止程序(这里终止程序是可选的) ++ if (type == QtFatalMsg) ++ abort(); ++} ++ ++void log_env_init(QString arg){ ++ static int uid = -1; ++ static char logPath[98] = {0}; ++ bool _is_root = false; ++ toDir = QDir::homePath(); ++ toDir += "/.config/kylin-background-upgrade/"; ++ QDir dir(toDir); ++ if(!dir.exists()) { ++ dir.mkdir(toDir); ++ } ++ ++ // 初始执行时,设置log文件路径 ++ if (uid == -1) { ++ uid = getuid(); ++ } ++ if (uid == 0) { ++ // root user ++ sprintf(logPath, "/var/log/kylin-background-upgrade/kylin-background-upgrade.log"); ++ _is_root = true; ++ } else { ++ // normal user ++ // sprintf(logPath, "/run/user/%d/%s.log", uid, PROGRAM_NAME); ++ //QString 转 const char* ++ std::string str = QDir::homePath().toStdString(); ++ const char* ch = str.c_str(); ++ if (arg == "--check-upgrade" || arg == "--check-immediately") { ++ sprintf(logPath, "%s%s", ch, LOG_MANUL_NAME); ++ } else { ++ sprintf(logPath, "%s%s", ch, LOG_SILENT_NAME); ++ } ++ } ++ ++ if (access(logPath, F_OK|W_OK) == 0) { // log文件存在且可写 ++ if (fp == NULL) ++ fp = fopen(logPath, "a+"); ++ QFileInfo info(logPath); ++ if (info.size() > 1024*1024*20) { //20MB ++ fclose(fp); fp = NULL; ++ QFile fileclean(logPath); ++ fileclean.open(QIODevice::WriteOnly | QIODevice::Text | QFile::Truncate); ++ fileclean.close(); ++ if (fp == NULL) ++ fp = fopen(logPath, "a+"); ++ } ++ } else if (access(logPath, F_OK) != 0){ //文件不存在 ++ if (fp == NULL) { ++ if (_is_root) { //root用户日志文件 ++ QDir* dir = new QDir(); ++ if(!dir->exists("/var/log/kylin-background-upgrade/")){ ++ dir->mkpath("/var/log/kylin-background-upgrade/"); ++ } ++ fp = fopen(logPath, "a+"); ++ if (fp == NULL) ++ printf("Can't open logfile!\n"); ++ } else { ++ fp = fopen(logPath, "a+"); ++ if (fp == NULL) ++ printf("Can't open logfile!\n"); ++ } ++ } ++ } else { ++ // log文件不可写,则需要判断是否被打开过,被打开过就需要关闭 ++ if (fp != NULL) ++ fclose(fp); ++ fp = NULL; ++ } ++} ++ ++bool _is_openkylin() ++{ ++ QString OPENKYLIN_DISTTRIBUTOR = "Openkylin"; ++ QString command = "lsb_release -i -s"; ++ QProcess process; ++ process.start(command); ++ process.waitForFinished(); ++ ++ QString result = process.readAllStandardOutput(); ++ int ret = result.left(OPENKYLIN_DISTTRIBUTOR.length()).compare(OPENKYLIN_DISTTRIBUTOR.left(OPENKYLIN_DISTTRIBUTOR.length())); ++ return (0 == ret)?true:false; ++} ++ ++int main(int argc, char *argv[]) ++{ ++ QString arg=QString::fromLatin1(argv[1]); ++ log_env_init(arg); ++ qInstallMessageHandler(msgHandler); ++ char *dis_env=getenv("DISPLAY"); ++ QString display_env(dis_env); ++ if(display_env != NULL){ ++ qDebug()<<"The desktop graphics environment is normal, DISPLAY="<<dis_env; ++ } else { ++ qDebug()<<"The desktop graphics environment is abnormal, DISPLAY="<<dis_env<<", exit!"; ++ exit(0); ++ } ++ ++ QLockFile manul_lock(toDir+"manul.lock"); ++ QLockFile silent_lock(toDir+"silent.lock"); ++ qDebug()<<""; ++ qDebug()<<"---------------------------------------------------------------------------------------------------"; ++ if (arg == "--check-upgrade" || arg == "--check-immediately") { ++ qDebug()<<"Start check upgradable ..."; ++ if (arg == "--check-immediately") { ++ qDebug()<<"Perform a boot update check ..."; ++ } ++ if (!manul_lock.tryLock(0)) { ++ qDebug()<<"Another process is checking for updates, exit!"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"Start silent upgrade ..."; ++ if (!silent_lock.tryLock(0)) { ++ qDebug()<<"Another process is silently upgrading, exit!"; ++ exit(0); ++ } ++ if (_is_openkylin()) { ++ qDebug()<<"openkylin, exit!"; ++ exit(0); ++ } ++ } ++ ++#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) ++ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); ++ QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); ++#endif ++ ++ setenv("QT_QPA_PLATFORMTHEME","ukui",true); ++ qunsetenv("SESSION_MANAGER"); ++ QApplication a(argc, argv); ++ core m_core(arg); ++// QObject::connect(m_core,SIGNAL(execSignal()),&a,SLOT(quit())); ++ return a.exec(); ++} +diff --git a/kylin-update-notify/src/traydbus.cpp b/kylin-update-notify/src/traydbus.cpp +new file mode 100644 +index 0000000..7618f0d +--- /dev/null ++++ b/kylin-update-notify/src/traydbus.cpp +@@ -0,0 +1,450 @@ ++#include "traydbus.h" ++#include <iostream> ++#include <ostream> ++#include <QDateTime> ++ ++//托盘d-bus 服务 ++traydbusservice::traydbusservice() ++{ ++ ++} ++ ++QStringList traydbusservice::getCrucial() ++{ ++ QFile file("/var/lib/kylin-software-properties/template/crucial.list"); ++ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) ++ return crucial; ++ while (!file.atEnd()) { ++ QByteArray line = file.readLine(); ++ QString str = QString(line); ++ qDebug()<<str; ++ crucial = str.split(QRegExp("[ ]")); ++ qDebug()<<"d-bus crucial: "<<crucial; ++ } ++ return crucial; ++} ++QStringList traydbusservice::getImportant() ++{ ++ QFile file("/var/lib/kylin-software-properties/template/important.list"); ++ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) ++ return important; ++ while (!file.atEnd()) { ++ QByteArray line = file.readLine(); ++ QString str = QString(line); ++ qDebug()<<str; ++ important = str.split(QRegExp("[ ]")); ++ qDebug()<<"d-bus important: "<<important; ++ } ++ return important; ++} ++void traydbusservice::connectSuccessslots() ++{ ++ emit connectSuccessSignal(); ++} ++void traydbusservice::quitslots() ++{ ++ emit quitsignal(); ++} ++ ++ ++//连接源管理器的d-bus································ ++ ++source_dbus* source_dbus::sourceMutual = nullptr; ++using namespace std; ++/** ++ * @brief source_dbus::getInstance ++ * 单例 ++ * @return ++ */ ++source_dbus* source_dbus::getInstance() ++{ ++ static QMutex mutex; ++ if (nullptr == sourceMutual) { ++ QMutexLocker locker(&mutex); ++ sourceMutual = new source_dbus; ++ } ++ return sourceMutual; ++} ++ ++source_dbus::source_dbus(QObject *parent) ++ :QObject(parent) ++{ ++ connectTimer = new QTimer(this); ++ connect(connectTimer, SIGNAL(timeout()), this, SLOT(connectDbus())); ++} ++ ++source_dbus::~source_dbus() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++} ++ ++/** ++ * @brief source_dbus::initSource_Dbus ++ * 连接源管理器dbus ++ * @return ++ */ ++bool source_dbus::initSource_Dbus() ++{ ++ //创建QDBusInterface接口 ++ interface1 = new QDBusInterface("com.kylin.software.properties", "/com/kylin/software/properties", ++ "com.kylin.software.properties.interface", ++ QDBusConnection::systemBus()); ++ if (!interface1->isValid()) { ++ qDebug() << qPrintable(QDBusConnection::systemBus().lastError().message()); ++ exit(1); ++ } ++ ++ interface1->setTimeout(123456789); ++ //调用远程的value方法,源管理器update ++ qDebug()<<"Start updateSourceTemplate ..."; ++ QDBusReply<bool> reply1 = interface1->call(QDBus::Block, "updateSourceTemplate"); ++ if (reply1.isValid()) { ++ if (reply1.value()) { ++// QDBusReply<int> reply2 = interface1->call(QDBus::Block, "updateSourcePackages","kylin-background-upgrade"); ++// if (reply2.isValid()) { ++// qDebug()<<"updateSourcePackages return value:"<<reply2.value(); ++// if (reply2.value() == 100) { ++// qDebug()<<"源管理器 updateSource 连接成功"; ++// emit ready(); ++// } else { ++// qDebug()<<"源管理器updateSourcePackages failed,连接失败 "; ++// return false; ++// } ++// } else { ++// qDebug() << "源管理器updateSourcePackages failed "; ++// return false; ++// } ++ emit ready(); ++ } else { ++ qDebug()<<"updateSourceTemplate failed "; ++ return false; ++ } ++ } else { ++ qDebug() << "updateSourceTemplate method called failed "; ++ return false; ++ } ++ return true; ++} ++ ++/** ++ * @brief source_dbus::connectDbus ++ * 重连机制 ++ */ ++void source_dbus::connectDbus() ++{ ++ connectTimer->start(3000); ++ if (initSource_Dbus()) { ++ connectTimer->stop(); ++ } else { ++ num ++; ++ if (num >2) { ++ qDebug()<<"updateSourceTemplate failed, exit."; ++ exit(0); ++ } ++ qDebug()<<"updateSourceTemplate failed,Retries are in progress for the "<<num<<"th time."; ++ } ++} ++ ++//连接更新管理器的d-bus································ ++ ++update_dbus* update_dbus::updateMutual = nullptr; ++using namespace std; ++ ++update_dbus* update_dbus::getInstance() ++{ ++ static QMutex mutex; ++ if (nullptr == updateMutual) { ++ QMutexLocker locker(&mutex); ++ updateMutual = new update_dbus; ++ } ++ return updateMutual; ++} ++ ++ ++update_dbus::update_dbus(QObject *parent) ++ :QObject(parent) ++{ ++ initUpdate_Dbus(); ++ ++} ++ ++update_dbus::~update_dbus() ++{ ++ ++} ++ ++/** ++ * @brief update_dbus::initUpdate_Dbus ++ * 连接更新管理器dbus ++ */ ++void update_dbus::initUpdate_Dbus() ++{ ++ //创建QDBusInterface接口 ++ interface = new QDBusInterface("com.kylin.systemupgrade", "/com/kylin/systemupgrade", ++ "com.kylin.systemupgrade.interface", ++ QDBusConnection::systemBus()); ++ if (!interface->isValid()) { ++ qDebug() << qPrintable(QDBusConnection::systemBus().lastError().message()); ++ qDebug() << "Failed to connect /com/kylin/systemupgrade "; ++ exit(1); ++ } ++ interface_utils = new QDBusInterface("com.kylin.systemupgrade", "/com/kylin/systemupgrade/utils", ++ "com.kylin.systemupgrade.interface", ++ QDBusConnection::systemBus()); ++ if (!interface_utils->isValid()) { ++ qDebug() << qPrintable(QDBusConnection::systemBus().lastError().message()); ++ qDebug() << "Failed to connect /com/kylin/systemupgrade "; ++ exit(1); ++ } ++ ++ //监听D-bus信号,获取安装信息与进度 ++// connect(interface,SIGNAL(UpdateDloadAndInstStaChanged(QStringList, int, QString, QString)),this,SLOT(getsignal(QStringList, int, QString, QString))); ++// QDBusConnection::systemBus().connect(QString("com.kylin.systemupgrade"), QString("/com/kylin/systemupgrade"), ++// QString("com.kylin.systemupgrade.interface"), ++// QString("UpdateDloadAndInstStaChanged"), this, SLOT(getsignal(QStringList, int32_t, QString, QString))); ++ ++} ++ ++/** ++ * @brief update_dbus::getsignal ++ * 获取下载进度 ++ */ ++void update_dbus::getsignal(QStringList pkgs, int progess, QString status, QString current_details) ++{ ++ QString aptStatus = ""; ++// QString aptAppName; ++ int aptPercent = 0; ++ ++// QVariant dateQVariant; ++// aptStatus = arg; ++ ++// QVariantMap::Iterator it; ++// for (it = key.begin(); it != key.end(); ++it) { ++// if (it.key() == "apt_appname") { ++// dateQVariant = it.value(); ++// aptAppName = dateQVariant.toString(); ++// } ++// if (it.key() == "apt_percent") { ++// dateQVariant = it.value(); ++// aptPercent = dateQVariant.toFloat(); ++// } ++// } ++ ++// if (arg == "apt_start" && aptD_busStatus == true) { ++// aptD_busStatus =false; ++// } ++// if ((arg == "apt_start" || arg == "apt_finish") && (aptPercent == 0 || aptPercent == 100)) { ++// emit aptAppNames_Percentsignal(aptAppName,aptPercent,true); ++// } else if (arg == "apt_error" ) { ++// emit aptAppNames_Percentsignal(aptAppName,aptPercent,false); ++// } ++ if (aptPercent != progess) { ++ aptPercent = progess; ++ emit aptAppNames_Percentsignal(pkgs.at(0),aptPercent,status); ++ } ++ ++} ++ ++/** ++ * @brief update_dbus::checkForUpdates ++ * 检测强制推送列表 ++ */ ++QStringList update_dbus::checkForUpdates(QStringList arg) ++{ ++ QDBusReply<QStringList> reply = interface_utils->call("CheckInstalledOrUpgrade",arg); ++ if (reply.isValid()) ++ { ++ qDebug()<<"The upgradeable list:"<<reply.value(); ++ return reply.value(); ++ ++ } else { ++ qDebug() << "Get upgradeable list failed, exit"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief update_dbus::checkForUpdateDect ++ * 检测系统更新 ++ */ ++bool update_dbus::checkForUpdateDect() ++{ ++ qDebug()<<"Start to check system upgrade ..."; ++ connect(interface,SIGNAL(UpdateDetectFinished(bool, QStringList, QString, QString)),this,SLOT(UpdateDectSlot(bool, QStringList, QString, QString))); ++ QDBusReply<QVariantList> res = interface->asyncCall("UpdateDetect"); ++ qDebug() << "UpdateDetect (mode: MODE_UPDATE_DETECT) ..."; ++ return true; ++} ++ ++/** ++ * @brief update_dbus::installAndUpgrade ++ * 静默升级入口 ++ */ ++bool update_dbus::installAndUpgrade(QStringList pkgNames) ++{ ++ installpkgs = pkgNames; ++ ++ //调用D-bus接口,安装软件 ++ connect(interface,SIGNAL(UpdateDetectFinished(bool,QStringList,QString,QString)),this,SLOT(slotUpdateCache(bool,QStringList,QString,QString))); ++// QDBusPendingCall call = interface_utils->asyncCall("InstallPackages","kylin-background-upgrade", installpkgs); ++ QDBusPendingCall call = interface->asyncCall("UpdateCache"); ++ qDebug() << "UpdateCache (mode: MODE_UPDATE_CACHE) ..."; //MODE_UPDATE_CACHE ++ return true; ++} ++ ++void update_dbus::slotInstallFinish(bool status, QStringList pkgs,QString error,QString details) ++{ ++ emit UpdateInstallFinished(status,pkgs,error,details); ++} ++ ++void update_dbus::UpdateDectSlot(bool status, QStringList pkgs,QString error,QString details) ++{ ++ emit UpdateDectFinished(status,pkgs,error,details); ++} ++ ++void update_dbus::slotUpdateCache(bool status,QStringList pkgslist,QString errorstring,QString errorcode) ++{ ++ if (status) { ++ qDebug() << "MODE_UPDATE_CACHE finish ."; ++ connect(interface,SIGNAL(UpdateInstallFinished(bool,QStringList,QString,QString)),this,SLOT(slotInstallFinish(bool,QStringList,QString,QString))); ++ interface->asyncCall("InstallPackages", installpkgs); ++ } else { ++ qDebug() << "Call UpdateCache (mode: MODE_UPDATE_CACHE) failed, exit!"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief update_dbus::listenState ++ * 监听状态 ++ * @return ++ */ ++bool update_dbus::listenState() ++{ ++ QDBusReply<bool> r4eply = interface->call("get_important_status"); ++ return r4eply; ++} ++ ++ ++//连接电源的d-bus································ ++ ++power_dbus::power_dbus(QObject *parent) ++ :QObject(parent) ++{ ++ ++} ++ ++power_dbus::~power_dbus() ++{ ++ ++} ++ ++/** ++ * @brief power_dbus::initDbusaddrest ++ * 连接电源管理器的dbus,获取dbus路径 ++ * @return ++ */ ++bool power_dbus::initDbusaddrest() ++{ ++ ++ QStringList users; ++ QDBusInterface m_interface1( "org.freedesktop.UPower", ++ "/org/freedesktop/UPower", ++ "org.freedesktop.UPower", ++ QDBusConnection::systemBus() ); ++ if (!m_interface1.isValid()) { ++ qDebug() << "< org.freedesktop.UPower > initialization failed!"; ++ return false; ++ } ++ ++ QDBusReply<QList<QDBusObjectPath>> obj_reply = m_interface1.call("EnumerateDevices"); ++ ++ ++ if (obj_reply.isValid()) { ++ for (QDBusObjectPath op : obj_reply.value()) ++ users << op.path(); ++ if (users.size()==1 || users.isEmpty()) { ++ qDebug()<<"Failed to obtain the remaining battery capacity, The built-in power supply cannot be detected ..."; ++ return false; ++ } ++ powerpath=users.at(1); ++ return true; ++ } ++ return true; ++} ++ ++/** ++ * @brief power_dbus::getPower_Dbus ++ * 连接电源管理器的dbus ++ * @return ++ */ ++QString power_dbus::getPower_Dbus() ++{ ++ QDBusInterface m_interface( "org.freedesktop.UPower", ++ powerpath, ++ "org.freedesktop.DBus.Properties", ++ QDBusConnection::systemBus()); ++ ++ if (!m_interface.isValid()) { ++ qDebug() << "电源管理器dbus接口初始化失败"; ++ return "false"; ++ } ++ ++ QDBusReply<QVariant> obj_reply = m_interface.call("Get","org.freedesktop.UPower.Device","Percentage"); ++ QString Ele_surplus=obj_reply.value().toString(); ++ return Ele_surplus; ++} ++ ++//判断是否为活跃用户的dbus······························· ++ ++UserIdStatus::UserIdStatus(QObject *parent) ++ :QObject(parent) ++{ ++ initUserIdStatus(); ++} ++ ++UserIdStatus::~UserIdStatus() ++{ ++ ++} ++ ++ ++void UserIdStatus::initConnectionInfo() ++{ ++// qRegisterMetaType<MyClass>("MyClass"); ++// QDBusInterface m_interface1("org.freedesktop.login1", ++// "/org/freedesktop/login1", ++// "org.freedesktop.login1.Manager", ++// QDBusConnection::systemBus() ); ++// if (!m_interface1.isValid()) { ++// qDebug() << "dbus接口初始化失败"; ++// return; ++// } ++ ++// QDBusMessage res = m_interface1.call("ListUsers"); ++ ++// qDebug() << res.arguments().at(0).value<MyClass>().IDName; ++// qDebug()<<res; ++} ++ ++void UserIdStatus::initUserIdStatus() ++{ ++ static int uid = -1; ++ uid = getuid(); ++ QString uIDaddress = QString("/org/freedesktop/login1/user/_%1").arg(uid); ++ QDBusInterface m_interface1("org.freedesktop.login1", ++ uIDaddress, ++ "org.freedesktop.DBus.Properties", ++ QDBusConnection::systemBus()); ++ if (!m_interface1.isValid()) { ++ qDebug() << "dbus接口初始化失败"; ++ return; ++ } ++ ++ QDBusReply<QVariant> res = m_interface1.call("Get","org.freedesktop.login1.User","State"); ++ UIDStatus = res.value().toString(); ++} ++ ++ ++ ++ +diff --git a/kylin-update-notify/src/traydbus.h b/kylin-update-notify/src/traydbus.h +new file mode 100644 +index 0000000..795f869 +--- /dev/null ++++ b/kylin-update-notify/src/traydbus.h +@@ -0,0 +1,160 @@ ++#ifndef TRAYDBUSSERVICE_H ++#define TRAYDBUSSERVICE_H ++ ++#include <QObject> ++#include <QDBusInterface> ++#include <QDBusReply> ++#include <QDBusMessage> ++#include <QDBusReply> ++#include <QDBusConnection> ++#include <QTimer> ++#include <QDebug> ++#include <QFile> ++#include <QMutexLocker> ++ ++ ++#include <sys/stat.h> ++#include <unistd.h> ++#include <iostream> ++ ++class traydbusservice : public QObject ++{ ++ Q_OBJECT ++ //定义Interface名称为com.scorpio.test.value ++ Q_CLASSINFO("D-Bus Interface", "com.scorpio.test.value") ++public: ++ traydbusservice(); ++ ++ QStringList crucial; ++ QStringList important; ++ ++public slots: ++ QStringList getCrucial(); ++ QStringList getImportant(); ++ ++ void connectSuccessslots(); ++ void quitslots(); ++ ++private: ++ ++Q_SIGNALS: // SIGNALS ++ QString ready(QString ret); ++ QString connectSuccessSignal(); ++ QString quitsignal(); ++ ++}; ++ ++//连接源管理器的d-bus································ ++ ++class source_dbus: public QObject ++{ ++ Q_OBJECT ++ ++public: ++ explicit source_dbus(QObject *parent = nullptr); ++ ~source_dbus(); ++ QString serialNumber; ++ QTimer *connectTimer; ++ int num=0; ++ static source_dbus *getInstance(); ++ QDBusInterface *interface1; //连接源更新管理器的D-bus ++ ++ bool initSource_Dbus(); ++ static source_dbus *sourceMutual; //UpdateDbus类静态对象 ++ ++public slots: ++ void connectDbus(); ++ ++Q_SIGNALS: ++ void ready(); ++}; ++ ++//连接更新管理器的d-bus································ ++ ++class update_dbus: public QObject ++{ ++ Q_OBJECT ++ ++public: ++ explicit update_dbus(QObject *parent = nullptr); ++ ~update_dbus(); ++ static update_dbus *getInstance(); ++ QDBusInterface *interface; //连接更新管理器的D-bus ++ QDBusInterface *interface_utils; //kylin-system-updater utils ++ void initUpdate_Dbus(); ++ static update_dbus *updateMutual; //UpdateDbus类静态对象 ++ QStringList checkForUpdates(QStringList arg); //检测是否有更新 ++ bool checkForUpdateDect(); //检测系统更新 ++ bool installAndUpgrade(QStringList pkgNames); //静默升级入口 ++ QTimer *timer; ++ ++ bool aptD_busStatus=true; //发送状态的标志位 ++ ++ bool listenState(); ++ QStringList installpkgs; ++Q_SIGNALS: ++ void ready(); ++ void aptAppNames_Percentsignal(QString arg,int32_t args,QString state); //发送正在下载安装的包名以及进度 ++ void dowloadStart(); ++ void UpdateInstallFinished(bool,QStringList,QString,QString); ++ void UpdateDectFinished(bool,QStringList,QString,QString); ++ ++protected slots: ++ void getsignal(QStringList, int, QString, QString); ++ void slotUpdateCache(bool,QStringList,QString,QString); ++ void slotInstallFinish(bool,QStringList,QString,QString); ++ void UpdateDectSlot(bool,QStringList,QString,QString); ++}; ++ ++//连接电源的d-bus································ ++ ++class power_dbus: public QObject ++{ ++ Q_OBJECT ++public: ++ power_dbus(QObject *parent = nullptr); ++ ~power_dbus(); ++ QDBusInterface *interface; //连接更新管理器的D-bus ++ bool initDbusaddrest(); ++ QString getPower_Dbus(); ++ QString powerpath; ++ ++ ++Q_SIGNALS: ++ void ready(); ++ ++protected slots: ++ ++}; ++ ++//判断是否为活跃用户的dbus······························· ++ ++ ++class MyClass ++{ ++public: ++ uint32_t uidnum; ++ QString IDName; ++ QDBusObjectPath address; ++}; ++Q_DECLARE_METATYPE(MyClass) ++ ++class UserIdStatus: public QObject ++{ ++ Q_OBJECT ++public: ++ UserIdStatus(QObject *parent = nullptr); ++ ~UserIdStatus(); ++ QString UIDStatus; ++ void initConnectionInfo(); ++ void initUserIdStatus(); ++ ++Q_SIGNALS: ++ void ready(); ++ ++protected slots: ++ ++}; ++ ++ ++#endif // TRAYDBUSSERVICE_H +diff --git a/kylin-update-notify/src/trayicon.cpp b/kylin-update-notify/src/trayicon.cpp +new file mode 100644 +index 0000000..612e126 +--- /dev/null ++++ b/kylin-update-notify/src/trayicon.cpp +@@ -0,0 +1,35 @@ ++#include "trayicon.h" ++ ++trayicon::trayicon(QWidget *parent) : QSystemTrayIcon(parent) ++{ ++ initAction(); ++} ++ ++void trayicon::initAction() ++{ ++ this->setToolTip(tr("The system is updating silently")); ++ this->setIcon(QIcon(":/update.png")); ++ ++ m_trayMenu = new QMenu(); ++ m_topWidget = new QWidget(); ++ m_topWidget->setFixedSize(30,30); ++ m_topWidget->installEventFilter(this); ++ m_topWidgetAction = new QWidgetAction(this); ++ ++} ++ ++/** ++ * @brief trayicon::eventFilter ++ * 事件过滤器 ++ */ ++bool trayicon::eventFilter(QObject *obj, QEvent *event) ++{ ++// if (obj == m_topWidget && event->type() == QEvent::MouseButtonPress) ++// { ++// QPainter painter(m_topWidget); ++// painter.setPen(Qt::NoPen); ++// painter.setBrush(QColor(42,120,192)); ++// painter.drawRect(m_topWidget->rect()); ++// } ++ return QSystemTrayIcon::eventFilter(obj,event); ++} +diff --git a/kylin-update-notify/src/trayicon.h b/kylin-update-notify/src/trayicon.h +new file mode 100644 +index 0000000..6e49374 +--- /dev/null ++++ b/kylin-update-notify/src/trayicon.h +@@ -0,0 +1,33 @@ ++#ifndef TRAYICON_H ++#define TRAYICON_H ++ ++#include <QWidget> ++#include <QSystemTrayIcon> ++#include <QAction> ++#include <QMenu> ++#include <QPainter> ++#include <QEvent> ++#include <QDebug> ++#include <QWidgetAction> ++ ++class trayicon : public QSystemTrayIcon ++{ ++ Q_OBJECT ++public: ++ explicit trayicon(QWidget *parent = nullptr); ++ void initAction(); ++ ++ QAction *action_show; ++ QMenu *m_trayMenu; ++ QWidget *m_topWidget; ++ QWidgetAction *m_topWidgetAction; ++ QMenu* trayIconMenu; ++ QAction* OpenSetUp; ++protected: ++ bool eventFilter(QObject *obj, QEvent *event); ++ ++signals: ++ ++}; ++ ++#endif // TRAYICON_H +diff --git a/kylin-update-notify/src/updatehandle.cpp b/kylin-update-notify/src/updatehandle.cpp +new file mode 100644 +index 0000000..8e04ed5 +--- /dev/null ++++ b/kylin-update-notify/src/updatehandle.cpp +@@ -0,0 +1,750 @@ ++#include "updatehandle.h" ++#include <iostream> ++#include <QProcess> ++ ++updatehandle::updatehandle(QString getnum1,QWidget *parent) : QWidget(parent) ++{ ++ argnum = getnum1; ++ ++ initTranslator(); //加载翻译文件 ++ getpower(); //获取电量值 ++ readconf(); //读取配置文件设定值 ++ initDbus(); //初始化dbus ++ initUI(argnum); //初始化托盘程序 ++} ++ ++updatehandle::~updatehandle() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++} ++ ++/** ++ * @brief updatehandle::initTranslator ++ * 加载翻译文件 ++ */ ++void updatehandle::initTranslator() ++{ ++ QTranslator *translator = new QTranslator; ++ if (translator->load(QLocale(), QLatin1String("kylin-background-upgrade"), QLatin1String("_"), QLatin1String("/usr/share/kylin-background-upgrade"))) { ++ QApplication::installTranslator(translator); ++ } else { ++ qDebug() << "cannot load translator kylin-background-upgrade_" << QLocale::system().name() << ".qm!"; ++ } ++ ++} ++ ++/** ++ * @brief updatehandle::getpower ++ * 获取电量值 ++ */ ++void updatehandle::getpower() ++{ ++ //获取电量信息 ++ Power_dbus = new power_dbus(this); ++ powerState = Power_dbus->initDbusaddrest(); ++ if (powerState) { ++ powerNum = Power_dbus->getPower_Dbus(); ++ qDebug()<<"电脑电量值为:"<<powerNum; ++ } ++} ++ ++/** ++ * @brief updatehandle::initDbus ++ * 初始化dbus ++ */ ++void updatehandle::initDbus() ++{ ++ UserIdStatus *arg = new UserIdStatus(); //查看当前是否为用户操作的用户 ++ if(arg->UIDStatus == "online") { ++ qDebug()<<"非活跃窗口,禁止启动"; ++ exit(0); ++ } ++ m_updateMutual = update_dbus::getInstance(); //初始化更新管理器d-bus ++ m_sourceMutual = source_dbus::getInstance(); //初始化源管理器d-bus ++ ++} ++ ++ ++/** ++ * @brief updatehandle::initUI ++ * 初始化界面类 ++ */ ++void updatehandle::initUI(QString argnum) ++{ ++ timerDownload = new QTimer(this); ++ connect(timerDownload, SIGNAL(timeout()), this, SLOT(downloadTimeout())); ++ ++ if(argnum.contains("--check-immediately")){ ++ qDebug()<<"exec --check-immediately"; ++ } else if(argnum.contains("--check-upgrade")) { ++ qDebug()<<"exec --check-upgrade"; ++ } else { ++ qDebug()<<"exec slient."; ++ } ++ ++ trayIcon = new trayicon(this); ++ bool ignore_or_delay = ignoreOrDelay(argnum.contains("--check-immediately",Qt::CaseInsensitive)); ++ choice_window = new updatewidget(ignore_or_delay);//更新选择页面 ++ tip_window = new updateTip(); //静默升级提示 ++ ++ if (argnum == "") { ++ //监听连接源管理器d-bus ++ //监听托盘点击事件,3:单击,2:双击,1:右键 ++ connect(trayIcon,&trayicon::activated, this,&updatehandle::onActivated); ++ connect(m_sourceMutual,&source_dbus::ready,this,&updatehandle::getTemplateList); ++ m_sourceMutual->connectDbus(); ++ } else if (argnum.contains("--check-upgrade",Qt::CaseInsensitive)||ignore_or_delay) { ++ //连接关闭功能槽函数 ++ connect(choice_window,&updatewidget::disAgreeBtnSignals,this,&updatehandle::execslots); ++ UpdateDectCheck(ignore_or_delay); ++ } else { ++ qDebug()<<"No update,exit!"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief updatehandle::tray_Show ++ * 启动托盘选择页面 ++ */ ++void updatehandle::tray_Show() ++{ ++ if(checktime()){ ++ if (!m_updateMutual->listenState()) { ++ if (m_getsql()) { ++ qDebug()<<"m_getsql 的值为true"; ++ choice_window->update_lab->setText(tr("System update")); ++ if (argnum != "update") { ++ choice_window->updateWidgetShow(); ++ } ++ } else { ++ qDebug()<<"更新管理器关闭检测更新,托盘程序结束"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"更新管理器已运行,程序退出"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"配置文件设定时间未到,程序退出"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief updatehandle::checktime ++ * 进行当前时间与配置文件时间比对 ++ * @return ++ * true: 当前时间大于配置文件时间 ++ * false: 当前时间小于配置文件时间 ++ */ ++bool updatehandle::checktime() ++{ ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ CheckUpgradeTime = timersetting->value("CheckUpgradeTime").toString(); ++ QDateTime datetime = QDateTime::fromString(CheckUpgradeTime, "yyyy-MM-dd hh:mm:ss"); ++ //结束组 ++ timersetting->endGroup(); ++ QDateTime Nowtime = QDateTime::currentDateTime(); //获取系统现在的时间 ++ qint64 nSecs = Nowtime.secsTo(datetime); //对比 ++ qDebug()<<"Get timing time: "<<CheckUpgradeTime; ++ qDebug()<<"Current system time: "<<Nowtime; ++ qDebug()<<"nSecs"<<nSecs; ++ if(nSecs == 0){ ++ qDebug()<<"The timing configuration file is abnormal,ckeck upgrade ..."; ++ return true; ++ } ++ if(nSecs < 0){ ++ qDebug()<<"Check upgrade starts when the scheduled time is reached."; ++ return true; ++ } ++ return false; ++} ++ ++/** ++ * @brief updatehandle::m_getsql ++ * 获取更新管理器是否自动检测的数据 ++ * @return ++ * true:自动检测 ++ * false:关闭自动检测 ++ */ ++bool updatehandle::m_getsql() ++{ ++ db = QSqlDatabase::addDatabase("QSQLITE"); ++ db.setDatabaseName("/var/cache/kylin-system-updater/kylin-system-updater.db"); ++ if (!db.open()) { ++ qDebug()<<"open sql error"; ++ return false; ++ } ++ QSqlQuery query; ++ query.exec("SELECT * FROM display"); ++ while(query.next()){ ++ QString tmp=query.value(3).toString(); ++ if (tmp == "true") { ++ return true; ++ } else if (tmp == "false") { ++ return false; ++ } ++ } ++ qDebug()<<"从数据库未读到正确的标志信息"; ++ return false; ++} ++ ++/** ++ * @brief updatehandle::onActivated ++ * 接收点击时间的槽函数 ++ * @param reason ++ * reason:传入点击事件信息 ++ */ ++void updatehandle::onActivated(trayicon::ActivationReason reason) ++{ ++ if(tip_window->isHidden()){ ++ QPoint pt=cursor().pos(); ++ tip_window->move(pt.x(),pt.y()-45); ++ tip_window->show(); ++ } else { ++ tip_window->hide(); ++ } ++} ++ ++/** ++ * @brief updatehandle::getTemplateList ++ * 获取源管理器文件中的可选更新与强制更新列表 ++ */ ++void updatehandle::getTemplateList() ++{ ++ qDebug()<<"Parses the optional update list and the mandatory update list ..."; ++ QMap<QString,QStringList> updatedata; ++ QString str1; ++ QString str2; ++ QStringList m_crucial; ++ QFile file1("/var/lib/kylin-software-properties/template/crucial.list"); ++ if (!file1.open(QIODevice::ReadOnly | QIODevice::Text)){ ++ qDebug()<<"cat not open file crucial.list"; ++ exit(0); ++ } ++ while (!file1.atEnd()) { ++ QByteArray line = file1.readLine(); ++ str1 += QString(line); ++ } ++ str1.replace(QString("\n"), QString("")); ++ m_crucial = str1.split(QRegExp("[ ]")); ++ m_crucial.removeAll(QString("")); ++ qDebug()<<"The crucial lists: "<<m_crucial; ++ ++ QStringList m_important; ++ QFile file2("/var/lib/kylin-software-properties/template/important.list"); ++ if (!file2.open(QIODevice::ReadOnly | QIODevice::Text)) { ++ qDebug()<<"cat not open file important.list"; ++ exit(0); ++ } ++ while (!file2.atEnd()) { ++ QByteArray line = file2.readLine(); ++ str2 += QString(line); ++ } ++ str2.replace(QString("\n"), QString("")); ++ m_important = str2.split(QRegExp("[ ]")); ++ m_important.removeAll(QString("")); ++ qDebug()<<"The important lists: "<<m_important; ++ ++ updatedata.insert("crucial",m_crucial); ++ updatedata.insert("important",m_important); ++ ++ processData(updatedata); ++} ++ ++/** ++ * @brief updatehandle::processData ++ * 处理获取的更新数据 ++ * @param data ++ * 传入可选更新与强制更新列表 ++ */ ++void updatehandle::processData(QMap<QString,QStringList> data) ++{ ++ qDebug()<<"Monitor the installation progress and status signal ..."; ++ //ksu获取进度,状态 ++ connect(m_updateMutual,&update_dbus::UpdateInstallFinished,this,&updatehandle::InstallFinsih); ++ QStringList crucial; ++ QMap<QString,QStringList>::iterator it; ++ for (it = data.begin();it != data.end();it++) { ++ if (it.key() == "crucial") { ++ crucial = it.value(); ++ } else if (it.key() == "important") { ++ important = it.value(); ++ } ++ } ++ qDebug()<<"Checking silent upgrade list: "<<crucial; ++ QStringList checkCrucialAll; ++ ++ checkCrucialAll = m_updateMutual->checkForUpdates(crucial); ++ if (!checkCrucialAll.isEmpty()) { ++ handleCrucial(checkCrucialAll); ++ } else { ++ qDebug() << "Silent upgrade list is empty, exit!"; ++ exit(0); ++ } ++} ++ ++/** ++ * @brief updatehandle::handleCrucial ++ * 处理静默升级包 ++ * @param checkCrucialAll ++ * 传入包列表 ++ */ ++void updatehandle::handleCrucial(QStringList checkCrucialAll) ++{ ++ QStringList crucialPackageSize; ++ QStringList crucialPackage; ++ ++ if (checkCrucialAll.count()%2 != 0) { ++ qDebug()<<"The format of the silent upgrade list is incorrect, exit!"; ++ exit(0); ++ } ++ if (argnum != "update") { ++ //提取包名与大小信息 ++ for (int i=0;i<checkCrucialAll.count();i+=2) { ++ crucialPackage.append(checkCrucialAll.at(i)); ++ } ++ ++ for (int i=1;i<checkCrucialAll.count();i+=2) { ++ crucialPackageSize.append(checkCrucialAll.at(i)); ++ } ++ checkCrucial = crucialPackage; ++ qDebug()<<"Checking for inactivity in silent upgrading ..."; ++ timerDownload->start(20*60*1000); ++ if (powerState) { //判断是否获取到电量 ++ if (powerNum.toInt()<powerSize) { //判断电量是否达到警戒值 ++ qDebug()<<"超出设定电源警戒值,判断包大小是否符合继续下载条件"; ++ if (packageDownOrNot(crucialPackageSize)) { ++ notify_send(tr("The system is updating silently")); ++ trayIcon->setVisible(true); ++ qDebug()<<"The system is updating silently ..."; ++ m_updateMutual->installAndUpgrade(crucialPackage); ++ } else { ++ exit(0); ++ } ++ } else { ++ notify_send(tr("The system is updating silently")); ++ trayIcon->setVisible(true); ++ qDebug()<<"The system is updating silently ..."; ++ m_updateMutual->installAndUpgrade(crucialPackage); ++ } ++ } else { ++ notify_send(tr("The system is updating silently")); ++ trayIcon->setVisible(true); ++ qDebug()<<"The system is updating silently ..."; ++ m_updateMutual->installAndUpgrade(crucialPackage); ++ } ++ } ++} ++ ++/** ++ * @brief updatehandle::UpdateDectSlot ++ * 处理可选升级包 ++ */ ++void updatehandle::UpdateDectSlot(bool status,QStringList list,QString errorstring,QString errorcode) ++{ ++ if (!status) { ++ qDebug() << "Update Detect failed: " << QString("%1 %2").arg(errorstring).arg(errorcode); ++ exit(0); ++ } else { ++ if (list.length() == 0) { ++ qDebug() << "The software on this computer is up to date, exit!"; ++ exit(0); ++ } else { ++ choice_window->update_lab->setText(tr("System update")); ++ if (argnum != "update") { ++ choice_window->updateWidgetShow(); ++ } ++ } ++ } ++ //完成检测,刷新下次更新标志位 ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ timersetting->setValue("GeneratRandomTime",true); ++ timersetting->setValue("CheckCompleted",true); ++ timersetting->sync(); ++ timersetting->endGroup(); ++} ++ ++/** ++ * @brief updatehandle::UpdateDectCheck ++ * 处理可选升级包 ++ */ ++void updatehandle::UpdateDectCheck(bool _check_immediately) ++{ ++ //判断是否有系统更新 ++ if(checktime() || !RandomizedExecute || _check_immediately){ ++ if (m_getsql() || _check_immediately) { ++ qDebug()<<"Detection update has been opened ..."; ++ connect(m_updateMutual,&update_dbus::UpdateDectFinished,this,&updatehandle::UpdateDectSlot); ++ bool ret= m_updateMutual->checkForUpdateDect(); ++ } else { ++ qDebug()<<"Detection updates have been disabled, exit!"; ++ exit(0); ++ } ++ } else { ++ qDebug()<<"The scheduled time is not reached, exit."; ++ exit(0); ++ } ++} ++ ++ ++/** ++ * @brief updatehandle::ignoreOrDelays ++ * 处理可选升级包 ++ */ ++bool updatehandle::ignoreOrDelay(bool mode) ++{ ++ static char flagPath[64] = {0}; ++ sprintf(flagPath, "/var/cache/kylin-update-manager/ignoreOrDelay"); ++ bool ignore_or_delay = false; ++ QFile file(flagPath); ++ ++ //判断是否完成第一步更新 ++ if (access(flagPath, F_OK) == 0) { // flag文件存在且可写 ++ qDebug()<<flagPath<<"is found!"; ++ ++ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) ++ ignore_or_delay = false; ++ QByteArray line = file.readLine(); ++ if(QString(line).contains("2107",Qt::CaseInsensitive)) { ++ ignore_or_delay = true; ++ qDebug()<<"The first step of the upgrade has been completed, Detection of the second step of the upgrade! [2107]"; ++// //需要清空文件 ++// file.close(); ++// file.open(QIODevice::Truncate); ++// file.close(); ++// file.open(QIODevice::WriteOnly); ++ } else if (QString(line).contains("2203",Qt::CaseInsensitive)) { ++ ignore_or_delay = true; ++ qDebug()<<"The first step of the upgrade has been completed, Detection of the second step of the upgrade! [2203]"; ++ } ++ } else { ++ qDebug()<<flagPath<<"isn't found!"; ++ ignore_or_delay = false; ++ } ++ file.close(); ++ return ignore_or_delay&&mode; ++} ++ ++/** ++ * @brief updatehandle::packageDownOrNot ++ * 判断是否超出设定大小 ++ * @param arg ++ * 传入包列表 ++ * @return ++ * true:符合预定大小 ++ * false:超出设定大小 ++ */ ++bool updatehandle::packageDownOrNot(QStringList arg) ++{ ++ qDebug()<<"开始检测包大小是否超出设定大小"; ++ for (int i = 0 ;i<arg.count();i++) { ++ QString pagesize = arg.at(i); ++ if (pagesize.toFloat() > setPackageSize) { ++ qDebug()<<"包大小超出设定大小,程序退出"; ++ return false; ++ } ++ } ++ qDebug()<<"包大小符合预定大小"; ++ return true; ++} ++ ++/** ++ * @brief updatehandle::register_dbus ++ */ ++void updatehandle::register_dbus() ++{ ++ //建立到session bus的连接 ++ QDBusConnection connection = QDBusConnection::sessionBus(); ++ ++ //在session bus上注册名为com.scorpio.test的服务 ++ if (!connection.registerService("com.scorpio.test")) { ++ qDebug() << "error:" << connection.lastError().message(); ++ exit(-1); ++ } ++ object = new traydbusservice(); ++ ++ //注册名为/test/objects的对象,把类Object所有槽函数导出为object的method ++ connection.registerObject("/test/objectsd", object,QDBusConnection::ExportAllSlots| QDBusConnection :: ExportAllSignals); ++ ++ connect(object,&traydbusservice::quitsignal,[=](){ ++ emit execSignal(); ++ }); ++ ++ connect(object,&traydbusservice::connectSuccessSignal,[=](){ ++ dbusConnectStatus = true; ++ emit object->ready("success"); ++ }); ++ ++} ++ ++/** ++ * @brief updatehandle::d_busStatus ++ * 判断下载状态的槽函数 ++ * @param arg : Appname ++ * @param args : aptpercent ++ * @param state : state ++ */ ++void updatehandle::d_busStatus(QString arg,int32_t args,QString state) ++{ ++ if (!checkCrucial.isEmpty() && messstate2) { ++ messstate2=false; ++ trayIcon->setVisible(true); ++ } ++ ++// qDebug()<<"下载进度:"; ++// qDebug()<<"Appname:"<<arg; ++// qDebug()<<"aptpercent:"<<args; ++} ++ ++void updatehandle::InstallFinsih(bool state,QStringList pkgname,QString error,QString reason) ++{ ++ bool _check_status; ++ timerDownload->stop(); ++ //apt返回失败时判断是否安装成功 ++ if (!state) ++ _check_status = package_installation_status(checkCrucial); ++ ++ if(state || _check_status){ ++ qDebug() << "Silent upgrade is complete, exit."; ++ notify_send(tr("The system has completed an important update, It is recommended that you restart immediately.")); ++ }else{ ++ QString errorstate = tr("update error"); ++ QString errorName; ++ errorName = QString("%1 %2").arg(error).arg(errorstate); ++ qDebug() << "Silent update failed: "<<errorName; ++ notify_send(errorName); ++ } ++ trayIcon->setVisible(false); ++ tip_window->hide(); ++ exit(0); ++} ++ ++bool updatehandle::package_installation_status(QStringList pkgs) ++{ ++ QString pkgname; ++ QString cmd; ++ QProcess process; ++ bool status,status_single; ++ for (QStringList::iterator it = pkgs.begin(); it != pkgs.end(); ++it) { ++ pkgname = *it; ++ status_single = false; ++ cmd = QString("dpkg -l %1").arg(pkgname); ++ process.start(cmd); ++ process.waitForFinished(); ++ QByteArray result_ = process.readAllStandardOutput(); ++ if (QString::fromLocal8Bit(result_) != "") { ++ QStringList rets = QString::fromLocal8Bit(result_).split(QRegExp("[\n]"),QString::SkipEmptyParts); ++ for (QStringList::iterator it_ret = rets.begin(); it_ret != rets.end(); ++it_ret) { ++ QString ret; ++ ret = *it_ret; ++ if (ret.contains(pkgname) && ret.startsWith("ii")) { ++ status_single = true; ++ qDebug() << "pkg "<<pkgname<<",Installation succeeded."; ++ } ++ } ++ if (!status_single) { //install failed ++ status = false; ++ break; ++ } ++ } else { ++ status = false; ++ break; ++ } ++ if (status_single) ++ status = true; ++ } ++ return status; ++} ++ ++/** ++ * @brief updatehandle::execslots ++ * 关闭界面槽函数 ++ */ ++void updatehandle::execslots() ++{ ++ //设置推迟检测,更新标志位 ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ timersetting->setValue("CheckCompleted",false); ++ timersetting->setValue("GeneratRandomTime",false); ++ timersetting->sync(); ++ timersetting->endGroup(); ++ emit execSignal(); ++} ++ ++/** ++ * @brief updatehandle::notify_send ++ * 发送消息通知函数 ++ * @param arg ++ * 发送的正文 ++ */ ++void updatehandle::notify_send(QString arg) ++{ ++ QDBusInterface iface("org.freedesktop.Notifications", ++ "/org/freedesktop/Notifications", ++ "org.freedesktop.Notifications", ++ QDBusConnection::sessionBus()); ++ QList<QVariant> args; ++ args<<tr("kylin-background-upgrade") ++ <<((unsigned int) 0) ++ <<QString("kylin-update-manager") ++ <<tr("update") //显示的是什么类型的信息//系统升级 ++ <<arg //显示的具体信息 ++ <<QStringList() ++ <<QVariantMap() ++ <<(int)-1; ++ iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args); ++} ++ ++/** ++ * @brief updatehandle::downloadTimeout ++ * 下载时间超时函数 ++ */ ++void updatehandle::downloadTimeout() ++{ ++ qDebug() << "Download the timeout, exit!"; ++ exit(0); ++} ++ ++ ++/** ++ * @brief updatehandle::_secsTo ++ */ ++int updatehandle::_secsTo(QString time1, QString time2) ++{ ++ QStringList time1Slot,time2Slot; ++ // **:** ++ if (time1.contains(":")){ ++ time1Slot = time1.split(":"); ++ }else{return -1;} ++ if (time2.contains(":")){ ++ time2Slot = time2.split(":"); ++ }else{return -1;} ++ if (time1Slot.at(0) > time2Slot.at(0)) { ++ return 1; ++ } else if (time1Slot.at(0) == time2Slot.at(0)) { ++ if (time1Slot.at(1) > time2Slot.at(1)) { ++ return 1; ++ } else if (time1Slot.at(1) == time2Slot.at(1)) { ++ return 0; ++ } else if (time1Slot.at(1) < time2Slot.at(1)) { ++ return -1; ++ } ++ } else if (time1Slot.at(0) < time2Slot.at(0)) { ++ return -1; ++ } ++} ++ ++/** ++ * @brief updatehandle::readconf ++ * 读取配置文件 ++ */ ++void updatehandle::readconf() ++{ ++ QMap<QString, QVariant> Timer; ++ Timer.insert("CheckCompleted", bool(false)); ++ Timer.insert("CheckUpgradeTime", " "); ++ Timer.insert("CheckUpgradeTimeSlot", "14:30:00-16:30:00"); ++ Timer.insert("GeneratRandomTime", bool(true)); ++ Timer.insert("RandomizedExecute", bool(true)); ++ QMap<QString, QVariant> Settings; ++ Settings.insert("powersize", int(1)); ++ Settings.insert("setpackagesize", "999999999"); ++// qDebug()<<"Settings "<<QString::number(float(999999999),'f',2); ++ ++ confPath = QDir::homePath()+"/.config/kylin-background-upgrade/kylin-background-upgrade-conf.ini"; ++ QFileInfo fileInfo(confPath); ++ if (!fileInfo.exists()) { ++ qDebug()<<"The background-upgrade configuration file isn't exists."; ++ QMapIterator<QString, QVariant> ir_timer(Timer); ++ QMapIterator<QString, QVariant> ir_settings(Settings); ++ QSettings *code_conf = new QSettings(confPath,QSettings::IniFormat); ++ code_conf->beginGroup(QString::fromLocal8Bit("Timer")); ++ while(ir_timer.hasNext()){ ++ ir_timer.next(); ++ code_conf->setValue(ir_timer.key(), ir_timer.value()); ++ } ++ code_conf->sync(); ++ code_conf->endGroup(); ++ code_conf->beginGroup(QString::fromLocal8Bit("Settings")); ++ while(ir_settings.hasNext()){ ++ ir_settings.next(); ++ code_conf->setValue(ir_settings.key(), ir_settings.value()); ++ } ++ code_conf->sync(); ++ code_conf->endGroup(); ++ } ++ ++ timersetting = new QSettings(confPath,QSettings::IniFormat); ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ CheckUpgradeTime = timersetting->value("CheckUpgradeTime").toString(); ++ CheckUpgradeTimeSlot = timersetting->value("CheckUpgradeTimeSlot").toString(); ++ RandomizedExecute = timersetting->value("RandomizedExecute").toBool(); ++ GeneratRandomTime = timersetting->value("GeneratRandomTime").toBool(); ++ CheckCompleted = timersetting->value("CheckCompleted").toBool(); ++ qDebug()<<"[ CheckUpgradeTime: "<<CheckUpgradeTime<<", CheckUpgradeTimeSlot: "<<CheckUpgradeTimeSlot \ ++ <<", RandomizedExecute: "<<RandomizedExecute<<", GeneratRandomTime: "<<GeneratRandomTime<<", CheckUpgradeTime: "<<CheckUpgradeTime\ ++ <<", CheckCompleted: "<<CheckCompleted<<" ]"; ++ timersetting->endGroup(); ++ ++ timersetting->beginGroup(QString::fromLocal8Bit("Settings")); ++ powerSize = timersetting->value("powersize").toInt(); ++ setPackageSize = timersetting->value("setpackagesize").toFloat(); ++ timersetting->endGroup(); ++ ++ QStringList timeSlot = CheckUpgradeTimeSlot.split("-"); ++ qDebug()<<"timeSlot "<<timeSlot; ++ //需要刷新检测时间 ++ if (GeneratRandomTime) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString current_datetime = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QString current_date= time.toString("yyyy-MM-dd"); //设置显示格式 ++ QString current_time= time.toString("hh:mm:ss"); //设置显示格式 ++ QString nowtime; ++ QByteArray str2char2 = current_time.toLatin1(); // must ++ nowtime = str2char2.data(); ++ ++ qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); ++ int a = 0; ++ timersetting->beginGroup(QString::fromLocal8Bit("Timer")); ++ QString timing = current_date+' '+timeSlot.at(0); ++ QString start_timing = timeSlot.at(0); ++ QString end_timing = timeSlot.at(1); ++ QStringList start_timingSlot,end_timingSlot; ++ QString time0,time1,time2,time3; ++ if (start_timing.contains(":")){ ++ start_timingSlot = start_timing.split(":"); ++ time0 = start_timingSlot.at(0); ++ time1 = start_timingSlot.at(1); ++ } ++ if (end_timing.contains(":")){ ++ end_timingSlot = end_timing.split(":"); ++ time2 = end_timingSlot.at(0); ++ time3 = end_timingSlot.at(1); ++ } ++ int strayParameter = (time2.toInt()*60+time3.toInt())-(time0.toInt()*60+time1.toInt()); ++ a = 0; ++ if (strayParameter<0){ ++ qDebug() << "Time format error."; ++ }else if (strayParameter==0) { ++ qDebug() << "strayParameter: "<< strayParameter << ", a "<<a; ++ } else { ++ a = qrand()%(strayParameter); ++ qDebug() << "strayParameter: "<< strayParameter << ", a "<<a; ++ } ++ QDateTime bojb = QDateTime::fromString(timing,"yyyy-MM-dd hh:mm:ss").addSecs(a*60); ++ if (CheckCompleted) { ++ bojb = bojb.addDays(1); ++ timersetting->setValue("CheckCompleted",false); ++ } ++ QString timing_time = bojb.toString("yyyy-MM-dd hh:mm:ss").toLatin1().data(); ++ ++ timersetting->setValue("CheckUpgradeTime",timing_time); ++ timersetting->setValue("GeneratRandomTime",false); ++ qDebug()<< "CheckUpgradeTime "<<timing_time; ++ timersetting->sync(); ++ timersetting->endGroup(); ++ } ++} ++ +diff --git a/kylin-update-notify/src/updatehandle.h b/kylin-update-notify/src/updatehandle.h +new file mode 100644 +index 0000000..9eb4250 +--- /dev/null ++++ b/kylin-update-notify/src/updatehandle.h +@@ -0,0 +1,105 @@ ++#ifndef TRAY_H ++#define TRAY_H ++ ++#include <QMap> ++#include <QDebug> ++#include <QWidget> ++#include <QProcess> ++#include <QSettings> ++#include <QSqlQuery> ++#include <QTextCodec> ++#include <QPushButton> ++#include <QTranslator> ++#include <QSqlDatabase> ++#include <QNetworkReply> ++#include <QSqlQueryModel> ++#include <QNetworkRequest> ++#include <QNetworkAccessManager> ++ ++#include <string.h> ++#include <unistd.h> ++#include <sys/file.h> ++#include <sys/stat.h> ++ ++#include "traydbus.h" ++#include "trayicon.h" ++#include "updatewidget.h" ++ ++ ++class updatehandle : public QWidget ++{ ++ Q_OBJECT ++public: ++ updatehandle(QString getnum1,QWidget *parent = nullptr); ++ ~updatehandle(); ++ trayicon *trayIcon; //托盘实例化 ++ QStringList important; //保存重要更新包名 ++ QString argnum; //得到命令行输入参数 ++ traydbusservice *object; //托盘dbus服务 ++ bool powerState; //保存电量是否可获取 ++ QString powerNum = "0"; //保存电量值 ++ QString confPath = ""; //保存配置文件位置 ++ ++ bool dbusConnectStatus=false; //d-bus连接状态 ++ bool messstate1=true; ++ bool messstate2=true; ++ int powerSize; //电源设定值 ++ float setPackageSize; //包大小设定值 ++ QString CheckUpgradeTime; //检查更新时间 ++ QString CheckUpgradeTimeSlot; //检查更新时间段 ++ bool CheckCompleted; //是否检查完成 ++ bool RandomizedExecute; //是否随机执行 ++ bool GeneratRandomTime; //是否刷新随机时间 ++ bool errorStatus=false; //是否完整下载安装的状态值 ++ ++ updatewidget *choice_window; //托盘选择框 ++ updateTip *tip_window; //托盘提示框框 ++ QStringList checkCrucial; //保存静默升级包以及大小信息 ++ ++ source_dbus *m_sourceMutual; //源管理器dbus ++ update_dbus *m_updateMutual; //更新管理器dbus ++ power_dbus *Power_dbus; ++ QTimer *timerDownload; //托盘下载时间错误延时处理 ++ QTimer *timerLock; //文件锁定时检测 ++ QSettings *mqsetting; //读取配置文件 ++ QSettings *timersetting; //读取timer配置文件 ++ ++ ++ void initUI(QString); //初始化界面 ++ void initDbus(); //初始化dbus ++ void initTranslator(); //初始化翻译加载 ++ void getTemplateList(); //获取源管理器文件中的可选更新与强制更新 ++ void processData(QMap<QString,QStringList> data); //处理获取的更新数据 ++ void handleCrucial(QStringList checkCrucialAll); //处理静默升级包 ++ void handleImportant(); //处理可选升级包 ++ void register_dbus(); //注册D-bus服务 ++ bool checktime(); //检查设定更新时间 ++ ++ //数据库相关 ++ QSqlDatabase db; ++ QSqlQueryModel model; ++ ++ bool m_getsql(); //获取更新管理器数据库信息 ++ void notify_send(QString arg); //向notification发送信息显示 ++ ++ bool packageDownOrNot(QStringList arg); ++ void readconf(); //读取配置文件 ++ int _secsTo(QString,QString); //时间差 ++ void getpower(); //获取电量值 ++ void UpdateDectCheck(bool); //调用后端UpdateDetect ++ bool ignoreOrDelay(bool mode); //是否开机检查检查弹窗 ++ bool package_installation_status(QStringList); ++signals: ++ void execSignal(); //关闭窗口信号 ++ ++protected slots: ++ void onActivated(trayicon::ActivationReason reason); //更新选择页面 ++ void tray_Show(); //启动托盘显示 ++ void execslots(); //关闭窗口槽函数 ++ void d_busStatus(QString,int32_t,QString); //判断下载状态的槽函数 ++ void InstallFinsih(bool,QStringList,QString,QString); //状态槽函数 ++ void downloadTimeout(); //延时检测下载状态 ++ void UpdateDectSlot(bool,QStringList,QString,QString); //updatedetect回调函数 ++}; ++ ++#endif // TRAY_H +diff --git a/kylin-update-notify/src/updatewidget.cpp b/kylin-update-notify/src/updatewidget.cpp +new file mode 100644 +index 0000000..054dd15 +--- /dev/null ++++ b/kylin-update-notify/src/updatewidget.cpp +@@ -0,0 +1,664 @@ ++#include "updatewidget.h" ++#include "ui_updatewidget.h" ++#include <QPainterPath> ++#include <QToolTip> ++#include <QHoverEvent> ++#include "ukuistylehelper/ukuistylehelper.h" ++#include "windowmanager/windowmanager.h" ++ ++#define PANEL_DBUS_SERVICE "com.ukui.panel.desktop" ++#define PANEL_DBUS_PATH "/" ++#define PANEL_DBUS_INTERFACE "com.ukui.panel.desktop" ++#define UKUI_PANEL_SETTING "org.ukui.panel.settings" ++ ++#define DBUS_NAME "org.ukui.SettingsDaemon" ++#define DBUS_PATH "/org/ukui/SettingsDaemon/wayland" ++#define DBUS_INTERFACE "org.ukui.SettingsDaemon.wayland" ++ ++updatewidget::updatewidget(bool check_Tips, QWidget *parent) : ++ QWidget(parent), ++ ui(new Ui::Form) ++{ ++ ui->setupUi(this); ++ //设置出现在屏幕的位置以及大小 ++ listenPanelChange(); ++ QString xdg_session_type = qgetenv("XDG_SESSION_TYPE"); ++ if (xdg_session_type != "wayland"){ ++ initPanelDbusGsetting(); ++ GetsAvailableAreaScreen(); ++ qDebug()<<"not wayland"; ++ bIsWayland = false; ++ } else { ++ //注释掉的是原先的接口,已经废除。采用原本的获取方式 ++// initset_window_position(); ++// set_window_position(); ++ initPanelDbusGsetting(); ++ GetsAvailableAreaScreen(); ++ qDebug()<<"wayland"; ++ bIsWayland = true; ++ } ++ _check_Tips = check_Tips; ++ //设置任务栏无显示 ++ setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); ++ setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); ++ ++ update_lab = new QLabel(); ++ icon_lab = new QLabel(); ++ ++ tip_lab = new QLabel(); ++ tip_lab->setText(tr(" Updatable app detected on your system!")); ++ agreebtn = new FixButton(); ++ delaybtn = new FixButton(); ++ window_close = new QPushButton(this); ++ ++ window_close->setIcon(QIcon::fromTheme("window-close-symbolic")); ++ window_close->setProperty("isWindowButton", 0x2); ++ window_close->setProperty("useIconHighlightEffect", 0x8); ++ window_close->setFlat(true); ++ window_close->setToolTip(tr("Close")); ++ window_close->installEventFilter(this); ++ connect(window_close, &QPushButton::clicked, this, &updatewidget::onClick_close_btn); ++ ++ QPixmap icon(QIcon::fromTheme("ukui-control-center").pixmap(QSize(26,26))); ++ ++ m_pfirstlayout = new QVBoxLayout(); ++ m_labellayout = new QHBoxLayout(); ++ m_psecondlayout = new QHBoxLayout(); ++ m_pselectlayout = new QHBoxLayout(); ++ comboBox = new QComboBox(); ++ comboBox->clear(); ++ strList<<tr("30 minutes later")<<tr("1 hour later")<<tr("5 hours later")<<tr("1 day later")<<tr("3 days later"); ++ comboBox->addItems(strList); ++ comboBox->installEventFilter(this); ++ ++ labelwidget = new QWidget(); ++ selectWidget = new QWidget(); ++ statwidget = new QWidget(); ++ ++ agreebtn->setText(tr("Update"),1); ++ agreebtn->installEventFilter(this); ++ delaybtn->setText(tr("Delay"),1); ++ delaybtn->installEventFilter(this); ++ ++ connect(agreebtn,&QPushButton::clicked,this,&updatewidget::agreeBtnClicked); ++ connect(comboBox,SIGNAL(activated(int)),this,SLOT(comboBoxClicked(int))); ++ connect(delaybtn,&QPushButton::clicked,this,&updatewidget::delayBtnClicked); ++ ++ icon_lab->setPixmap(icon); ++ icon_lab->setScaledContents(true); ++ icon_lab->setMaximumSize(26,26); ++ update_lab->setMaximumHeight(26); ++ update_lab->setContentsMargins(0,0,0,3); ++ window_close->setFixedSize(24,24); ++ window_close->setContentsMargins(0,0,0,3); ++ m_labellayout->addWidget(icon_lab); ++ m_labellayout->addWidget(update_lab); ++ m_labellayout->addStretch(); ++ m_labellayout->addWidget(window_close); ++ m_labellayout->setContentsMargins(0,0,0,20); ++ labelwidget->setLayout(m_labellayout); ++ ++ m_pselectlayout->addWidget(tip_lab); ++ m_pselectlayout->setContentsMargins(0,0,0,25); ++ selectWidget->setLayout(m_pselectlayout); ++ ++ m_psecondlayout->addStretch(); ++ comboBox->setFixedHeight(35); ++ comboBox->setMinimumWidth(135); ++ comboBox->setMaximumWidth(155); ++ agreebtn->setFixedSize(100,35); ++ if (_check_Tips) ++ m_psecondlayout->addWidget(delaybtn); ++ else ++ m_psecondlayout->addWidget(comboBox); ++ m_psecondlayout->addWidget(agreebtn); ++ m_psecondlayout->setSpacing(15); //set space between comboBox and btn ++ m_psecondlayout->setContentsMargins(0,0,12,12); ++ statwidget->setLayout(m_psecondlayout); ++ ++ m_pfirstlayout->addWidget(labelwidget); ++ m_pfirstlayout->addWidget(selectWidget); ++ m_pfirstlayout->addWidget(statwidget); ++ ++ m_pfirstlayout->setSpacing(2); ++ this->setLayout(m_pfirstlayout); ++ this->setFixedSize(435,160); ++ ++// QGSettings *settings; ++// if(QGSettings::isSchemaInstalled("org.ukui.style")){ ++// settings = new QGSettings("org.ukui.style"); ++// connect(settings,&QGSettings::changed,this,&ActiveConnectionWidget::GSettingsChanges); ++// } ++ ++// const QByteArray transparency_id(TRANSPARENCY_SETTINGS); ++// if(QGSettings::isSchemaInstalled(transparency_id)) { ++// transparency = new QGSettings(transparency_id); ++// } ++// if(QGSettings::isSchemaInstalled(transparency_id)) { ++// getTransparency(); ++// connect(transparency,&QGSettings::changed,this,&ActiveConnectionWidget::GSettingsChanges); ++// } ++ ++ this->setProperty("useStyleWindowManager", false); ++ this->setProperty("useSystemStyleBlur", true); ++ this->setAttribute(Qt::WA_TranslucentBackground, true); ++ this->setWindowOpacity(0.9); ++ ++// labelwidget->setStyleSheet("background-color:green;"); ++// update_lab->setStyleSheet("background-color:blue;"); ++// selectWidget->setStyleSheet("background-color:red;"); ++// statwidget->setStyleSheet("background-color:orange;"); ++// comboBox->setStyleSheet("background-color:violet;"); ++// agreebtn->setStyleSheet("background-color:yellow;"); ++} ++ ++updatewidget::~updatewidget() ++{ ++ qDebug() << Q_FUNC_INFO << __LINE__; ++ delete ui; ++} ++ ++void updatewidget::updateWidgetShow() ++{ ++ this->show(); ++ qDebug()<<"should show:"<<updateWidgetRect; ++ ++ if (bIsWayland) ++ kdk::WindowManager::setGeometry(this->windowHandle(), updateWidgetRect); ++ else ++ this->setGeometry(updateWidgetRect); ++} ++ ++void updatewidget::onClick_close_btn() ++{ ++ // emit disAgreeBtnSignals(); ++ qDebug()<<"User Cancel reminder, exit tray program!"; ++ // exit(0); ++ qApp->quit(); ++} ++ ++/** ++ * @brief updatewidget::eventFilter ++ * 事件过滤器 ++ */ ++bool updatewidget::eventFilter(QObject *obj, QEvent *event) ++{ ++ if (obj == this->window_close) { //指定window_close ++ if (event->type() == QEvent::HoverMove) { ++ QPushButton *close_btn = qobject_cast<QPushButton *>(obj); ++ if (close_btn) { ++ QToolTip::showText(QCursor::pos(), close_btn->toolTip()); ++ } ++ } ++ } else if (obj == this->agreebtn || obj == this->delaybtn) { ++ if (event->type() == QEvent::HoverMove) { ++ FixButton *btn = qobject_cast<FixButton *>(obj); ++ if (btn) { ++ QToolTip::showText(QCursor::pos(), btn->toolTip()); ++ } ++ } ++ } else if (obj == this->comboBox) { ++ if (event->type() == QEvent::HoverMove) { ++ QComboBox *comboBox = qobject_cast<QComboBox *>(obj); ++ if (comboBox) { ++ QToolTip::showText(QCursor::pos(), comboBox->toolTip()); ++ } ++ } ++ } ++ return QWidget::eventFilter(obj, event); ++} ++ ++/** ++ * @brief updatewidget::initPanelDbusGsetting ++ * 初始化与任务栏gsetting和dbus ++ */ ++void updatewidget::initPanelDbusGsetting() ++{ ++ /* 链接任务栏Dbus接口,获取任务栏高度和位置 */ ++ m_pServiceInterface = new QDBusInterface(PANEL_DBUS_SERVICE, PANEL_DBUS_PATH, PANEL_DBUS_INTERFACE, QDBusConnection::sessionBus()); ++ m_pServiceInterface->setTimeout(2147483647); ++ connect(m_pPanelSetting, &QGSettings::changed,[=](QString key){ ++ if ("panelposition" == key | "panelsize" == key) { ++ GetsAvailableAreaScreen(); ++ } ++ }); ++} ++ ++void updatewidget::listenPanelChange() ++{ ++ /* 链接任务栏dgsetting接口 */ ++ if(QGSettings::isSchemaInstalled(UKUI_PANEL_SETTING)) ++ m_pPanelSetting = new QGSettings(UKUI_PANEL_SETTING); ++} ++ ++/** ++ * @brief updatewidget::connectTaskBarDbus ++ * 链接任务栏dbus获取高度的接口 ++ * @return ++ */ ++int updatewidget::connectTaskBarDbus() ++{ ++ int panelHeight = 46; ++ if (m_pPanelSetting != nullptr) { ++ QStringList keys = m_pPanelSetting->keys(); ++ if (keys.contains("panelsize")) { ++ panelHeight = m_pPanelSetting->get("panelsize").toInt(); ++ } ++ } else { ++ QDBusMessage msg = m_pServiceInterface->call("GetPanelSize", QVariant("Hight")); ++ panelHeight = msg.arguments().at(0).toInt(); ++ return panelHeight; ++ } ++ return panelHeight; ++} ++ ++/** ++ * @brief updatewidget::getPanelSite ++ * 获取任务栏状态位置下上左右 ++ * @return ++ * 返回任务栏位置 ++ */ ++int updatewidget::getPanelSite() ++{ ++ int panelPosition = 0; ++ if (m_pPanelSetting != nullptr) { ++ QStringList keys = m_pPanelSetting->keys(); ++ if (keys.contains("panelposition")) { ++ panelPosition = m_pPanelSetting->get("panelposition").toInt(); ++ } ++ } else { ++ QDBusMessage msg = m_pServiceInterface->call("GetPanelPosition", QVariant("Site")); ++ panelPosition = msg.arguments().at(0).toInt(); ++ } ++ qDebug() << "Current Position of ukui panel: " << panelPosition; ++ return panelPosition; ++} ++ ++/** ++ * @brief updatewidget::GetsAvailableAreaScreen ++ * 获取屏幕的可用区域高度和宽度并设置位置 ++ */ ++void updatewidget::GetsAvailableAreaScreen() ++{ ++ //如果取不到任务栏的高度,还是优先获取桌面分辨率,可用区域 ++ if ((0 == connectTaskBarDbus()) && (0 == getPanelSite())) { ++ QScreen* pScreen = QGuiApplication::primaryScreen(); ++ QRect DeskSize = pScreen->availableGeometry(); ++ m_nScreenWidth = DeskSize.width(); //桌面分辨率的宽 ++ m_nScreenHeight = DeskSize.height(); //桌面分辨率的高 ++ } else { ++ //如果取到任务栏的高度,则取屏幕分辨率的高度 ++ int h = connectTaskBarDbus(); ++ QRect screenRect = QGuiApplication::primaryScreen()->geometry(); ++ m_nScreenWidth = screenRect.width(); ++ m_nScreenHeight = screenRect.height(); ++ m_pPeonySite = getPanelSite(); ++ switch (m_pPeonySite) ++ { ++ case updatewidget::PanelDown : ++ { ++ qDebug()<<"Taskbar coordinates: [ '"<<m_nScreenWidth-445<<"','"<< m_nScreenHeight-h-170<<"','"<<300<<"','"<<150 - 100<<"']"; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-h-170, 300, 150-100); ++ } ++ break; ++ case updatewidget::PanelUp: ++ { ++ qDebug()<<"任务栏在上方: 显示坐标为: "<<m_nScreenWidth - 445 << m_nScreenHeight - 170 << 300 << 150 - 100; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-170, 300, 150-100); ++ } ++ break; ++ case updatewidget::PanelLeft: ++ { ++ qDebug()<<"任务栏在左侧: 显示坐标为: "<<m_nScreenWidth - 445 << m_nScreenHeight - 170 << 300 << 150 - 100; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-170, 300, 150-100); ++ } ++ break; ++ case updatewidget::PanelRight: ++ { ++ qDebug()<<"任务栏在右侧: 显示坐标为: "<<m_nScreenWidth - 445 - h << m_nScreenHeight - 170 << 300 << 150 - 100; ++ updateWidgetRect = QRect(m_nScreenWidth-445, m_nScreenHeight-170, 300, 150-100); ++ } ++ break; ++ default: ++ break; ++ } ++ ++ } ++ qDebug() << "Current screen width: " << m_nScreenWidth <<"; height:"<< m_nScreenHeight; ++} ++ ++ ++int updatewidget::getTaskbarPos(QString str) ++{ ++ QDBusInterface interface( "com.ukui.panel.desktop", ++ "/", ++ "com.ukui.panel.desktop", ++ QDBusConnection::sessionBus() ); ++ ++ QDBusReply<int> reply = interface.call("GetPanelPosition", str); ++ return reply; ++} ++ ++int updatewidget::getTaskbarHeight(QString str) ++{ ++ QDBusInterface interface( "com.ukui.panel.desktop", ++ "/", ++ "com.ukui.panel.desktop", ++ QDBusConnection::sessionBus() ); ++ ++ QDBusReply<int> reply = interface.call("GetPanelSize", str); ++ return reply; ++} ++ ++ ++int updatewidget::getScreenGeometry(QString methodName) ++{ ++ int res = 0; ++ QDBusMessage message = QDBusMessage::createMethodCall(DBUS_NAME, ++ DBUS_PATH, ++ DBUS_INTERFACE, ++ methodName); ++ QDBusMessage response = QDBusConnection::sessionBus().call(message); ++ if (response.type() == QDBusMessage::ReplyMessage) { ++ if(response.arguments().isEmpty() == false) { ++ int value = response.arguments().takeFirst().toInt(); ++ res = value; ++ } ++ } else { ++ qDebug()<<methodName<<"called failed"; ++ } ++ return res; ++} ++ ++void updatewidget::initset_window_position() ++{ ++ connect(m_pPanelSetting, &QGSettings::changed,[=](QString key){ ++ if ("panelposition" == key | "panelsize" == key) { ++ set_window_position(); ++ } ++ } ++ ); ++} ++ ++void updatewidget::set_window_position() ++{ ++ QRect rect; ++ int availableWidth,totalWidth; ++ int availableHeight,totalHeight; ++ rect = this->geometry(); ++ int priX = getScreenGeometry("x"); ++ int priY = getScreenGeometry("y"); ++ int priWid = getScreenGeometry("width"); ++ int priHei = getScreenGeometry("height"); ++ QRect screenGeometry = qApp->primaryScreen()->geometry(); ++ ++ availableWidth = priX + priWid; ++ availableHeight = priY + priHei; ++ totalHeight = screenGeometry.height(); ++ totalWidth = screenGeometry.width(); ++ ++ int distance = 4; ++ int n = 0; ++ int m = 46; ++ ++ n = getTaskbarPos("position"); ++ m = getTaskbarHeight("height"); ++ if(n == 0){ ++ //任务栏在下侧 ++ this->setGeometry(priWid-435-distance,availableHeight-160-m-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在下侧"<<priWid-435-distance<<" "<<availableHeight-160-m-distance <<" "<<this->width()<<" "<<this->height(); ++ }else if(n == 1){ ++ //任务栏在上侧 ++ this->setGeometry(priWid-435-distance,availableHeight-160-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在上侧"<<priWid-435-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height(); ++ } else if (n == 2){ ++ //任务栏在左侧 ++ this->setGeometry(priWid-435-distance,availableHeight-160-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在左侧"<<priWid-435-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height(); ++ } else if (n == 3){ ++ //任务栏在右侧 ++ this->setGeometry(availableWidth-435-m-distance,availableHeight-160-distance,this->width(),this->height()); ++ qDebug()<<"任务栏在右侧"<<availableWidth-435-m-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height(); ++ } ++} ++ ++/** ++ * @brief updatewidget::insideTime ++ * 获取时间 ++ * @return ++ */ ++char *updatewidget::insideTime() ++{ ++ qDebug()<<"current select: "<<this->comboBox->currentText(); ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QByteArray str2char2 = str.toLatin1(); // must ++ char *nowtime = str2char2.data(); ++ ++ if(comboBox->currentText() == strList.at(0)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(1800); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(1)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(3600); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(2)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(18000); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(3)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addDays(1); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } else if (comboBox->currentText() == strList.at(4)) { ++ QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间 ++ QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ++ QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addDays(3); ++ QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss"); ++ QByteArray str2char2 = str1.toLatin1(); // must ++ nowtime = str2char2.data(); ++ return nowtime; ++ } ++ return nowtime; ++ ++} ++ ++bool updatewidget::_is_openkylin() ++{ ++ QString OPENKYLIN_DISTTRIBUTOR = "Openkylin"; ++ QString command = "lsb_release -i -s"; ++ QProcess process; ++ process.start(command); ++ process.waitForFinished(); ++ ++ QString result = process.readAllStandardOutput(); ++ int ret = result.left(OPENKYLIN_DISTTRIBUTOR.length()).compare(OPENKYLIN_DISTTRIBUTOR.left(OPENKYLIN_DISTTRIBUTOR.length())); ++ return (0 == ret)?true:false; ++} ++ ++/** ++ * @brief updatewidget::agreeBtnClicked ++ * 同意更新按钮槽函数 ++ */ ++void updatewidget::agreeBtnClicked() ++{ ++ emit agreeBtnSignals(); ++ bool _is_2107 = true; ++ QFile file("/etc/os-release"); ++ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { ++ QString line; ++ QTextStream in(&file); ++ line = in.readLine(); ++ while(!line.isNull()) { ++ line = in.readLine(); ++ if(line.contains("KYLIN_RELEASE_ID")) { ++ _is_2107 = false; ++ } ++ } ++ } ++ file.close(); ++ QProcess p(0); ++ if (_is_2107&&!_is_openkylin()) { ++ p.startDetached("ukui-control-center --upgrade"); ++ qDebug()<<"exec --upgrade"; ++ } else { ++ p.startDetached("ukui-control-center -m upgrade"); ++ qDebug()<<"exec -m upgrade"; ++ } ++ p.waitForStarted(); ++ qDebug()<<"Open the control panel and start updating immediately, exit tray program!"; ++ exit(0); ++} ++ ++/** ++ * @brief updatewidget::comboBoxClicked ++ * 推迟框槽函数 ++ */ ++void updatewidget::comboBoxClicked(int num) ++{ ++ //判断是否有kylin-background-upgrade目录,没有则创建 ++ QString toDir = QDir::homePath(); ++ toDir += "/.config/kylin-background-upgrade/"; ++ QDir dir(toDir); ++ if(! dir.exists()) { ++ dir.mkdir(toDir);//只创建一级子目录,即必须保证上级目录存在 ++ } ++ ++ toDir += "kylin-background-upgrade-conf.ini"; ++ QFileInfo fileInfo(toDir); ++ if (!fileInfo.exists()) { ++ qDebug()<<"The periodic configuration file fails to be opened, exit!"; ++ exit(0); ++ } else { ++ char *nowtime=insideTime(); ++ qDebug() << "current timing: "<<nowtime; ++ timersettings = new QSettings(toDir,QSettings::IniFormat); ++ timersettings->beginGroup(QString::fromLocal8Bit("Timer")); ++ timersettings->setValue("CheckUpgradeTime",nowtime); ++ timersettings->sync(); ++ timersettings->endGroup(); ++ } ++ emit disAgreeBtnSignals(); ++ qDebug()<<"Users do not update, exit tray program!"; ++ exit(0); ++} ++ ++/** ++ * @brief updatewidget::delayBtnClicked ++ * 延迟提醒,退出 ++ */ ++void updatewidget::delayBtnClicked() ++{ ++ qDebug() << "User deferred updates, exit!"; ++ exit(0); ++} ++ ++/** ++ * @brief updatewidget::paintEvent ++ * 样式绘画画家 ++ * @param e ++ */ ++void updatewidget::paintEvent(QPaintEvent *e) ++{ ++ QStyleOption opt; ++ opt.init(this); ++ QPainter p(this); ++ /* 获取当前剪贴板中字体的颜色,作为背景色; ++ * 白字体 --> 黑背景 ++ * 黑字体 --> 白字体 ++ */ ++ p.setBrush(opt.palette.color(QPalette::Base)); ++ p.setOpacity(1); ++ p.setPen(QPen(QColor(220,220,220))); ++ QPainterPath path; ++ opt.rect.adjust(0,0,0,0); ++ path.addRoundedRect(opt.rect,12,12); ++ p.setRenderHint(QPainter::Antialiasing); //反锯齿 ++ p.drawRoundedRect(opt.rect,12,12); ++ setProperty("blurRegion",QRegion(path.toFillPolygon().toPolygon())); ++ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); ++ ++ QFontMetrics fontMetrics(this->font()); ++ QString current_str = comboBox->currentText(); ++ int fontSize = fontMetrics.width(current_str); ++ int showTextSize = comboBox->width() - 32; ++ if (fontSize > showTextSize) { ++ QString elidedText = fontMetrics.elidedText(comboBox->currentText(), Qt::ElideRight, showTextSize); ++ comboBox->setItemText(comboBox->currentIndex(), elidedText); ++ comboBox->setToolTip(current_str); ++ } ++ QWidget::paintEvent(e); ++} ++ ++/** ++ * @brief updateTip::updateTip ++ * 提示框 ++ * @param parent ++ */ ++updateTip::updateTip(QWidget *parent) : ++ QWidget(parent) ++{ ++ //设置任务栏无显示 ++ setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); ++ setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::Popup); ++ ++ m_layout = new QVBoxLayout(); ++ tipLabel = new QLabel(); ++ tipLabel->setText(tr("The system is updating silently")); ++ m_layout->addWidget(tipLabel); ++ this->setLayout(m_layout); ++ this->setProperty("useSystemStyleBlur", true); ++ this->setAttribute(Qt::WA_TranslucentBackground, true); ++ this->setWindowOpacity(0.9); ++} ++ ++updateTip::~updateTip() ++{ ++ ++} ++ ++/** ++ * @brief updateTip::paintEvent ++ * 样式绘画画家 ++ * @param e ++ */ ++void updateTip::paintEvent(QPaintEvent *e) ++{ ++ QStyleOption opt; ++ opt.init(this); ++ QPainter p(this); ++ /* 获取当前剪贴板中字体的颜色,作为背景色; ++ * 白字体 --> 黑背景 ++ * 黑字体 --> 白字体 ++ */ ++ p.setBrush(opt.palette.color(QPalette::Base)); ++ p.setOpacity(1); ++ p.setPen(QPen(QColor(220,220,220))); ++ QPainterPath path; ++ opt.rect.adjust(0,0,0,0); ++ path.addRoundedRect(opt.rect,4,4); ++ p.setRenderHint(QPainter::Antialiasing); //反锯齿 ++ p.drawRoundedRect(opt.rect,4,4); ++ setProperty("blurRegion",QRegion(path.toFillPolygon().toPolygon())); ++ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); ++ QWidget::paintEvent(e); ++} ++ ++ +diff --git a/kylin-update-notify/src/updatewidget.h b/kylin-update-notify/src/updatewidget.h +new file mode 100644 +index 0000000..15f0c30 +--- /dev/null ++++ b/kylin-update-notify/src/updatewidget.h +@@ -0,0 +1,131 @@ ++#ifndef TRAYWIDGET_H ++#define TRAYWIDGET_H ++ ++#include <QWidget> ++#include <QApplication> ++#include <QLabel> ++#include <QPushButton> ++#include <QHBoxLayout> ++#include <QDebug> ++#include <QPainter> ++#include <QProcess> ++#include <QComboBox> ++#include <QDir> ++#include <fcntl.h> ++#include <QDateTime> ++#include <QPoint> ++#include <QDBusInterface> ++#include <QGSettings> ++#include <QScreen> ++#include <QDBusReply> ++#include <QSettings> ++#include <sys/stat.h> ++#include <unistd.h> ++#include <QMouseEvent> ++#include "Button/fixbutton.h" ++ ++namespace Ui { ++class Form; ++} ++ ++class updatewidget : public QWidget ++{ ++ Q_OBJECT ++ ++public: ++ explicit updatewidget(bool check_Tips, QWidget *parent = nullptr); ++ ~updatewidget(); ++ ++ enum PanelStatePosition ++ { ++ PanelDown = 0, ++ PanelUp, ++ PanelLeft, ++ PanelRight ++ }; ++ ++ bool _check_Tips; ++ QLabel *update_lab; ++ QLabel *icon_lab; ++ QLabel *tip_lab; ++ QLabel *close_lab; ++ ++ FixButton *agreebtn; ++ FixButton *delaybtn; ++ QPushButton *window_close; ++ QWidget *labelwidget; ++ QWidget *statwidget; ++ QWidget *selectWidget; ++ QStringList strList; ++ QPixmap *icon; ++ ++ QVBoxLayout *m_pfirstlayout = nullptr; ++ QHBoxLayout *m_labellayout = nullptr; ++ QHBoxLayout *m_psecondlayout = nullptr; ++ QHBoxLayout *m_pselectlayout = nullptr; ++ ++ QDBusInterface* m_pServiceInterface; // 获取任务栏的高度 ++ QGSettings *m_pPanelSetting = nullptr; ++ QComboBox *comboBox; ++ ++ int m_nScreenWidth; // 屏幕分辨率的宽 ++ int m_nScreenHeight; // 屏幕分辨率的高 ++ int m_pPeonySite; // 任务栏位置 ++ QSettings *timersettings; //读取timer配置文件 ++ QRect updateWidgetRect; ++ bool bIsWayland = false; ++ ++ int connectTaskBarDbus(); ++ int getPanelSite(); ++ void GetsAvailableAreaScreen(); ++ char *insideTime(); ++ int getTaskbarPos(QString str); ++ int getTaskbarHeight(QString str); ++ int getScreenGeometry(QString methodName); ++ void set_window_position(); ++ void initset_window_position(); ++ void listenPanelChange(); ++ void initPanelDbusGsetting(); // 初始化与任务栏gsetting和dbus ++ bool eventFilter(QObject *, QEvent *); // 添加事件过滤器声明 ++ bool _is_openkylin(); ++ void updateWidgetShow(); ++ ++private: ++ Ui::Form *ui; ++ void paintEvent(QPaintEvent *e); ++ ++signals: ++ void agreeBtnSignals(); ++ void disAgreeBtnSignals(); ++ ++protected slots: ++ void agreeBtnClicked(); ++ void comboBoxClicked(int); ++ void delayBtnClicked(); ++ void onClick_close_btn(); ++}; ++ ++ ++ ++ ++ ++class updateTip : public QWidget ++{ ++ Q_OBJECT ++public: ++ explicit updateTip(QWidget *parent = nullptr); ++ ~updateTip(); ++ QLabel *tipLabel; ++ QVBoxLayout *m_layout = nullptr; ++ ++ ++private: ++ void paintEvent(QPaintEvent *e); ++ ++ ++signals: ++ ++protected slots: ++}; ++ ++#endif // TRAYWIDGET_H +diff --git a/kylin-update-notify/src/updatewidget.ui b/kylin-update-notify/src/updatewidget.ui +new file mode 100644 +index 0000000..d527737 +--- /dev/null ++++ b/kylin-update-notify/src/updatewidget.ui +@@ -0,0 +1,21 @@ ++<ui version="4.0"> ++ <author/> ++ <comment/> ++ <exportmacro/> ++ <class>Form</class> ++ <widget class="QWidget" name="Form"> ++ <property name="geometry"> ++ <rect> ++ <x>0</x> ++ <y>0</y> ++ <width>400</width> ++ <height>300</height> ++ </rect> ++ </property> ++ <property name="windowTitle"> ++ <string>Form</string> ++ </property> ++ </widget> ++ <pixmapfunction/> ++ <connections/> ++</ui> +diff --git a/kylin-update-notify/translations/UapLBi.json b/kylin-update-notify/translations/UapLBi.json +new file mode 100644 +index 0000000..c82f587 +--- /dev/null ++++ b/kylin-update-notify/translations/UapLBi.json +@@ -0,0 +1 @@ ++[{"excluded":[],"includePaths":["/usr/include/x86_64-linux-gnu/qt5/QGSettings","/usr/include/KF5/KWindowSystem","/usr/include/x86_64-linux-gnu/qt5","/usr/include/x86_64-linux-gnu/qt5/QtWidgets","/usr/include/x86_64-linux-gnu/qt5/QtGui","/usr/include/x86_64-linux-gnu/qt5/QtDBus","/usr/include/x86_64-linux-gnu/qt5/QtNetwork","/usr/include/x86_64-linux-gnu/qt5/QtSql","/usr/include/x86_64-linux-gnu/qt5/QtCore","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade"],"projectFile":"/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/kylin-background-upgrade.pro","sources":["/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/core.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/core.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/main.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/traydbus.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/traydbus.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/trayicon.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/trayicon.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatehandle.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatehandle.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatewidget.cpp","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatewidget.h","/home/li/ukui/kylin-background-upgrade/kylin-background-upgrade/updatewidget.ui"]}] +diff --git a/kylin-update-notify/translations/kylin-background-upgrade_bo_CN.qm b/kylin-update-notify/translations/kylin-background-upgrade_bo_CN.qm +new file mode 100644 +index 0000000..535b5f5 +--- /dev/null ++++ b/kylin-update-notify/translations/kylin-background-upgrade_bo_CN.qm +@@ -0,0 +1 @@ ++<�d��!�`���B�����J6���v�J�����1����t"r������-�*y�����*y�����*y����b��$ƨ����D#���xd|��ƨ����(G^��u*�Q��>a�B������i��1���Rb��tQA|DfAb|BBzbbrX`B�tbV�zQf�D �������The system is updating silently���trayicon���Rb��tQA|DfAb|BBzbbrX`B�tbV�zQf�D �������The system is updating silently��� updateTip���*b��tQA|DfBfbf��tb������� System update���updatehandle����XcBBr`BBb�`rBfbf��tb^rBczBfB�tVQD VfX`FbcA�zQbD`U�cXbVf��b`V�zQ �������]The system has completed an important update, It is recommended that you restart immediately.���updatehandle���Rb��tQA|DfAb|BBzbbrX`B�tbV�zQf�D �������The system is updating silently���updatehandle���8b��Vf�zBfBfbf��tbV�brX �������kylin-background-upgrade���updatehandle���(b��tQA|DfbrXf�|b�������update���updatehandle���$brX`Ub`B�tVXzQ �������update error���updatehandle���D� � � � b��tQA|DfBfbf��tbb�XB�Df�������* Updatable app detected on your system!���updatewidget���&IrSBErBSb`B�Df �������1 day later���updatewidget���,FtZ|QBErBSb`B�Df �������1 hour later���updatewidget���&IrSBftXSb`B�Df �������3 days later���updatewidget���(U�rb`B�Dff�bX�3�0 �������30 minutes later���updatewidget���$FtZ|Q�5Sb`B�Df ������� 5 hours later���updatewidget���f�|b��BT�������Close���updatewidget���Sb`B�Df �������Delay���updatewidget��� cXfDBfbf��tb�������Update���updatewidget +\ No newline at end of file +diff --git a/kylin-update-notify/translations/kylin-background-upgrade_bo_CN.ts b/kylin-update-notify/translations/kylin-background-upgrade_bo_CN.ts +new file mode 100644 +index 0000000..6bf37ed +--- /dev/null ++++ b/kylin-update-notify/translations/kylin-background-upgrade_bo_CN.ts +@@ -0,0 +1,112 @@ ++<?xml version="1.0" encoding="utf-8"?> ++<!DOCTYPE TS> ++<TS version="2.1" language="bo_CN"> ++<context> ++ <name>Form</name> ++ <message> ++ <location filename="../src/updatewidget.ui" line="16"/> ++ <source>Form</source> ++ <translation type="unfinished"></translation> ++ </message> ++</context> ++<context> ++ <name>trayicon</name> ++ <message> ++ <location filename="../src/trayicon.cpp" line="10"/> ++ <source>The system is updating silently</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་ཁ་རོག་གེར་རིམ་འགྱུར་བྱེད་སྒང་།</translation> ++ </message> ++</context> ++<context> ++ <name>updateTip</name> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="548"/> ++ <source>The system is updating silently</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་ཁ་རོག་གེར་རིམ་འགྱུར་བྱེད་སྒང་།</translation> ++ </message> ++</context> ++<context> ++ <name>updatehandle</name> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="116"/> ++ <location filename="../src/updatehandle.cpp" line="355"/> ++ <source>System update</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་གསར་སྒྱུར་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="319"/> ++ <location filename="../src/updatehandle.cpp" line="327"/> ++ <location filename="../src/updatehandle.cpp" line="333"/> ++ <source>The system is updating silently</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་ཁ་རོག་གེར་རིམ་འགྱུར་བྱེད་སྒང་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="511"/> ++ <source>The system has completed an important update, It is recommended that you restart immediately.</source> ++ <translation type="unfinished">མ་ལག་གི་འགག་རྩའི་གསར་སྒྱུར་ཞིག་ལེགས་གྲུབ་དང་།བསམ་འཆར་ལ་ཁྱེད་རང་འཕྲལ་མར་བསྐྱར་འབྱེད་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="513"/> ++ <source>update error</source> ++ <translation type="unfinished">རིམ་འཕར་འགྲུབ་མེད།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="589"/> ++ <source>kylin-background-upgrade</source> ++ <translation type="unfinished">རྒྱབ་སྟེགས་གསར་སྒྱུར་བྱ་རིམ།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="592"/> ++ <source>update</source> ++ <translation type="unfinished">རྒྱུད་ཁོངས་རིམ་སྤོར་</translation> ++ </message> ++</context> ++<context> ++ <name>updatewidget</name> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="42"/> ++ <source> Updatable app detected on your system!</source> ++ <translation type="unfinished"> རྒྱུད་ཁོངས་གསར་སྒྱུར་རྣམ་གྲངས་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="51"/> ++ <source>Close</source> ++ <translation type="unfinished">སྒོ་རྒྱག་པ་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>30 minutes later</source> ++ <translation type="unfinished">ཕྱིར་འགྱངས་སྐར་མ་30།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 hour later</source> ++ <translation type="unfinished">ཆུ་ཚོད་གཅིག་ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>5 hours later</source> ++ <translation type="unfinished">ཆུ་ཚོད་5ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 day later</source> ++ <translation type="unfinished">ཉིན་གཅིག་ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>3 days later</source> ++ <translation type="unfinished">ཉིན་གསུམ་ནར་འགྱངས་།</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="69"/> ++ <source>Update</source> ++ <translation type="unfinished">ལམ་སང་གསར་སྒྱུར་</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="70"/> ++ <source>Delay</source> ++ <translation type="unfinished">ནར་འགྱངས།</translation> ++ </message> ++</context> ++</TS> +diff --git a/kylin-update-notify/translations/kylin-background-upgrade_zh_CN.qm b/kylin-update-notify/translations/kylin-background-upgrade_zh_CN.qm +new file mode 100644 +index 0000000..1025f13 +--- /dev/null ++++ b/kylin-update-notify/translations/kylin-background-upgrade_zh_CN.qm +@@ -0,0 +1 @@ ++<�d��!�`���B�����J6�����J����1���5t"r��w�����*y�����*y���L�*y��q�b���ƨ���HD#���>d|��ƨ���(G^����*�Q��ja�B��������i��w���|�~�kcW(�Y��f�e��������The system is updating silently���trayicon���|�~�kcW(�Y��f�e��������The system is updating silently��� updateTip���|�~�f�e�������� System update���updatehandle���$|�~�[�bN��yQs�.f�e��^���`�z�Ss��T/�������]The system has completed an important update, It is recommended that you restart immediately.���updatehandle���|�~�kcW(�Y��f�e��������The system is updating silently���updatehandle���TS�f�e�z^��������kylin-background-upgrade���updatehandle���|�~�SG~��������update���updatehandle���SG~�Y1�%�������update error���updatehandle���� � � � |�~�g f�e��yv��������* Updatable app detected on your system!���updatewidget���c���� �1� Y)�������1 day later���updatewidget���c���� �1� \e��������1 hour later���updatewidget���c���� �3� Y)�������3 days later���updatewidget���c���� �3�0� R���������30 minutes later���updatewidget���c���� �5� \e�������� 5 hours later���updatewidget���Qs���������Close���updatewidget���c����������Delay���updatewidget���z�Ssf�e��������Update���updatewidget +\ No newline at end of file +diff --git a/kylin-update-notify/translations/kylin-background-upgrade_zh_CN.ts b/kylin-update-notify/translations/kylin-background-upgrade_zh_CN.ts +new file mode 100644 +index 0000000..480f39a +--- /dev/null ++++ b/kylin-update-notify/translations/kylin-background-upgrade_zh_CN.ts +@@ -0,0 +1,151 @@ ++<?xml version="1.0" encoding="utf-8"?> ++<!DOCTYPE TS> ++<TS version="2.1" language="zh_CN"> ++<context> ++ <name>Form</name> ++ <message> ++ <location filename="../src/updatewidget.ui" line="16"/> ++ <source>Form</source> ++ <translation type="unfinished"></translation> ++ </message> ++</context> ++<context> ++ <name>QObject</name> ++ <message> ++ <source>The system is updating silently</source> ++ <translation type="vanished">系统正在静默更新</translation> ++ </message> ++</context> ++<context> ++ <name>trayicon</name> ++ <message> ++ <location filename="../src/trayicon.cpp" line="10"/> ++ <source>The system is updating silently</source> ++ <translation>系统正在静默更新</translation> ++ </message> ++</context> ++<context> ++ <name>updateTip</name> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="548"/> ++ <source>The system is updating silently</source> ++ <translation>系统正在静默更新</translation> ++ </message> ++</context> ++<context> ++ <name>updatehandle</name> ++ <message> ++ <source>The system has completed an important update. It is recommended that you restart immediately.</source> ++ <translation type="vanished">系统已经完成一项关键更新,建议您立即重启</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="319"/> ++ <location filename="../src/updatehandle.cpp" line="327"/> ++ <location filename="../src/updatehandle.cpp" line="333"/> ++ <source>The system is updating silently</source> ++ <translation>系统正在静默更新</translation> ++ </message> ++ <message> ++ <source>System update detected </source> ++ <translation type="vanished">检测到有系统更新</translation> ++ </message> ++ <message> ++ <source>System update detected</source> ++ <translation type="vanished">检测到有系统更新</translation> ++ </message> ++ <message> ++ <source>The system has completed a critical update, and some software packages failed to update. It is recommended that you restart immediately</source> ++ <translation type="obsolete">系统完成一项关键更新,部分软件包更新失败,建议您立即重启</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="116"/> ++ <location filename="../src/updatehandle.cpp" line="355"/> ++ <source>System update</source> ++ <translation>系统更新</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="511"/> ++ <source>The system has completed an important update, It is recommended that you restart immediately.</source> ++ <translation>系统完成一项关键更新,建议您立即重启</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="513"/> ++ <source>update error</source> ++ <translation>升级失败</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="589"/> ++ <source>kylin-background-upgrade</source> ++ <translation>后台更新程序</translation> ++ </message> ++ <message> ++ <location filename="../src/updatehandle.cpp" line="592"/> ++ <source>update</source> ++ <translation>系统升级</translation> ++ </message> ++</context> ++<context> ++ <name>updatewidget</name> ++ <message> ++ <source>Please remind me later</source> ++ <translation type="vanished">请在以下时间段之后提醒我</translation> ++ </message> ++ <message> ++ <source>at</source> ++ <translation type="vanished">在</translation> ++ </message> ++ <message> ++ <source>No more reminders</source> ++ <translation type="vanished">内不再提醒</translation> ++ </message> ++ <message> ++ <source>No reminders</source> ++ <translation type="vanished">内不再提醒</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="42"/> ++ <source> Updatable app detected on your system!</source> ++ <translation type="unfinished"> 系统有更新项目</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="51"/> ++ <source>Close</source> ++ <translation type="unfinished">关闭</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>30 minutes later</source> ++ <translation>推迟 30 分钟</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 hour later</source> ++ <translation type="unfinished">推迟 1 小时</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>3 days later</source> ++ <translation type="unfinished">推迟 3 天</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="70"/> ++ <source>Delay</source> ++ <translation type="unfinished">推迟</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>5 hours later</source> ++ <translation>推迟 5 小时</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="62"/> ++ <source>1 day later</source> ++ <translation>推迟 1 天</translation> ++ </message> ++ <message> ++ <location filename="../src/updatewidget.cpp" line="69"/> ++ <source>Update</source> ++ <translation>立即更新</translation> ++ </message> ++</context> ++</TS> +diff --git a/kylin-update-notify/widgets/Button/button.pri b/kylin-update-notify/widgets/Button/button.pri +new file mode 100644 +index 0000000..ded778b +--- /dev/null ++++ b/kylin-update-notify/widgets/Button/button.pri +@@ -0,0 +1,6 @@ ++SOURCES += \ ++ $$PWD/fixbutton.cpp \ ++ ++HEADERS += \ ++ $$PWD/fixbutton.h \ ++ +diff --git a/kylin-update-notify/widgets/Button/fixbutton.cpp b/kylin-update-notify/widgets/Button/fixbutton.cpp +new file mode 100644 +index 0000000..fed4aad +--- /dev/null ++++ b/kylin-update-notify/widgets/Button/fixbutton.cpp +@@ -0,0 +1,36 @@ ++#include "fixbutton.h" ++#include <QFontMetrics> ++#include <QDebug> ++ ++FixButton::FixButton(QWidget *parent): ++ QPushButton(parent) ++{ ++ ++} ++ ++FixButton::~FixButton() ++{ ++ ++} ++ ++void FixButton::paintEvent(QPaintEvent *event) ++{ ++ QFontMetrics fontMetrics(this->font()); ++ int fontSize = fontMetrics.width(mStr); ++ int showTextSize = this->width() - 32; ++ if (fontSize > showTextSize) { ++ this->setText(fontMetrics.elidedText(mStr, Qt::ElideRight, showTextSize), false); ++ this->setToolTip(mStr); ++ } else { ++ this->setText(mStr, false); ++ this->setToolTip(""); ++ } ++ QPushButton::paintEvent(event); ++} ++ ++void FixButton::setText(const QString & text, bool saveTextFlag) ++{ ++ if (saveTextFlag) ++ mStr = text; ++ QPushButton::setText(text); ++} +diff --git a/kylin-update-notify/widgets/Button/fixbutton.h b/kylin-update-notify/widgets/Button/fixbutton.h +new file mode 100644 +index 0000000..2f30dbe +--- /dev/null ++++ b/kylin-update-notify/widgets/Button/fixbutton.h +@@ -0,0 +1,21 @@ ++#ifndef _FIXBUTTON_H_ ++#define _FIXBUTTON_H_ ++#include <QPushButton> ++ ++class FixButton : public QPushButton ++{ ++ Q_OBJECT ++public: ++ FixButton(QWidget *parent = nullptr); ++ ~FixButton(); ++ void setText(const QString &text, bool saveTextFlag = true); ++private: ++ void paintEvent(QPaintEvent *event); ++ ++private: ++ QString mStr; ++}; ++ ++ ++ ++#endif +diff --git a/kylin-update-notify/widgets/widgets.pri b/kylin-update-notify/widgets/widgets.pri +new file mode 100644 +index 0000000..da4ea4f +--- /dev/null ++++ b/kylin-update-notify/widgets/widgets.pri +@@ -0,0 +1,4 @@ ++INCLUDEPATH += $$PWD ++ ++include(Button/button.pri) ++#include(ComboBox/comboBox.pri) diff --git a/debian/patches/series b/debian/patches/series index 3ac5e52..281ab3e 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ 0001-1.3.2.1-ok13.1.patch +0002-fix.patch