ukui-notification/0000775000175000017500000000000015160526142013143 5ustar fengfengukui-notification/dbus/0000775000175000017500000000000015160523734014104 5ustar fengfengukui-notification/dbus/org.ukui.NotificationClient.xml0000664000175000017500000000150115160523734022152 0ustar fengfeng ukui-notification/dbus/org.ukui.NotificationServer.xml0000664000175000017500000000221415160523734022204 0ustar fengfeng ukui-notification/dbus/org.freedesktop.Notifications.xml0000664000175000017500000000331515160523734022541 0ustar fengfeng ukui-notification/dbus/org.ukui.NotificationSettings.xml0000664000175000017500000000125515160523734022542 0ustar fengfeng ukui-notification/LICENSE0000664000175000017500000010575515160523734014171 0ustar fengfeng GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ukui-notification/README.md0000664000175000017500000000501515160523746014432 0ustar fengfeng# ukui-notification ## 介绍 ukui-notificaton包含UKUI桌面环境的通知服务、通知开发接口和通知控制插件。 - ukui-notification-server: 通知服务 - libukui-notification: 通知开发接口 - notification-ukcc-plugin: 通知控制插件 ## 目录 - [通知服务](#通知服务) - [通知开发接口](#通知开发接口) - [通知控制插件](#通知控制插件) - [贡献指南](#贡献指南) ## 通知服务 ukui-notifiaction-server提供了遵循freedesktop[通知协议](https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html)的通知服务接口。 ### 支持的Capabilities | 能力 | 描述 | |------|------| | actions | 支持通知操作按钮 | | body | 支持富文本内容 | | body-hyperlinks | 支持内容中的超链接 | | persistence | 支持持久化通知 | | sound | 支持通知声音提示 | ### 扩展hints | Hint名称 | 描述 | |---------|------| | x-ukui-display | 标识通知弹窗应该显示在哪个DISPLAY上 | ### 扩展接口 | 接口名称 | 参数 | 返回值 | 描述 | |---------|------|--------|------| | org.ukui.NotificationServer.UpdateUnreadMessagesNumber | String desktop_entry, UInt32 number | void | 更新应用的未读消息数量 | | org.ukui.NotificationServer.RegisterNotificationControl | String desktop_entry | void | 注册应用的通知控制 | ## 通知开发接口 ### 使用cmake: ```cmake find_package(ukui-notification) target_link_libraries(yourapp ukui-notification) ``` ### 使用qmake: ```qmake CONFIG += link_pkgconfig PKGCONFIG += ukui-notification ``` ### 关键接口: | 头文件 | 功能描述 | 相关类 | |--------|----------|--------| | notification-client.h | 通知中心客户端注册、消息同步与action执行 | NotificationClient | | popup-notification.h | 单条通知的所有信息管理 | PopupNotification | | notification-global-settings.h | 全局通知设置 | NotificationGlobalSettings | | applications-settings.h | 应用通知行为设置 | ApplicationSettings | | single-application-settings.h | 单个应用的通知设置 | SingleApplicationSettings | ## 通知控制插件 控制面板通知插件,方便用户设置应用通知的权限 ## 贡献指南 ### 依赖 debhelper-compat (= 12), libkf5windowsystem-dev, libukui-search-dev(>=4.0.1.5-ok0), pkgconf, qtbase5-dev, qtchooser, qtdeclarative5-dev, qtscript5-dev, qttools5-dev, cmake, libkysdk-qtwidgets-dev, libukcc-dev, libgsettings-qt-dev, extra-cmake-modules, doxygen ### 编译: ``` mkdir build && cd build cmake .. make -j$(nproc) ```ukui-notification/man/0000775000175000017500000000000015160523746013725 5ustar fengfengukui-notification/man/ukui-notification-server.10000664000175000017500000000166015160523746020757 0ustar fengfeng.\" Hey, EMACS: -*- nroff -*- .TH ukui-notification-server 1 "2023" "ukui-notification" "UKUI Desktop Environment" .SH NAME ukui-notification-server \- UKUI desktop notification server .SH SYNOPSIS .B ukui-notification-server [\fIOPTIONS\fR] .SH DESCRIPTION .B ukui-notification-server is the notification server for the UKUI desktop environment. It implements the freedesktop.org notification specification. .PP This daemon runs in the background and handles notification requests from applications, displaying them to the user according to the system's notification settings. .SH OPTIONS This program does not typically accept command-line options as it is designed to run as a system service. .RE .SH AUTHOR launch ukui-notification was written by zhangpengfei . .br This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.ukui-notification/CMakeLists.txt0000664000175000017500000000161115160523746015711 0ustar fengfengcmake_minimum_required(VERSION 3.14) project(ukui-notification LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) if (BUILD_TEST) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") endif () set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Widgets LinguistTools DBus Network Gui Qml REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets LinguistTools DBus Network Gui Qml REQUIRED) find_package(ukui-quick COMPONENTS platform REQUIRED) set(REQUIRED_QT_VERSION 5.12.8) add_subdirectory(notification-server) add_subdirectory(libukui-notification) add_subdirectory(notification-ukcc-plugin) if(BUILD_TEST) add_subdirectory(test) endif() ukui-notification/NOTICE0000664000175000017500000000454315160523734014061 0ustar fengfengOPEN SOURCE SOFTWARE NOTICE Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders. Warranty Disclaimer THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. Copyright Notice and License Texts ------------------------------------------------------------------------ Software: qt-solutions Files: 3rd-parties/qtsingleapplication/* Copyright: 2013, Digia Plc and/or its subsidiary(-ies). License: BSD-3-clause The BSD License . Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------ ukui-notification/libukui-notification/0000775000175000017500000000000015160523746017302 5ustar fengfengukui-notification/libukui-notification/notification-client.cpp0000664000175000017500000002310115160523734023742 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "notification-client.h" #include "notification-client-private.h" #include #include #include "notificationclientadaptor.h" using namespace UkuiNotification; NotificationClientPrivate::NotificationClientPrivate(NotificationClient *q) : QObject(q), q(q) { } NotificationClientPrivate::~NotificationClientPrivate() { unregisterClient(); } bool NotificationClientPrivate::init() { if(m_registered) { return false; } m_registered = true; new NotificationClientAdaptor(this); QDBusConnection conn = QDBusConnection::sessionBus(); if(!conn.registerObject(clientServicePath(), clientServiceInterface(), this)) { qWarning() << "Failed to register NotificationClient DBus object!" << conn.lastError(); return false; } m_watcher = new QDBusServiceWatcher(QStringLiteral("org.freedesktop.Notifications"), conn, QDBusServiceWatcher::WatchForOwnerChange, this); connect(m_watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, &NotificationClientPrivate::serviceChange); return registerClient(); } bool NotificationClientPrivate::registerClient() { QDBusConnection conn = QDBusConnection::sessionBus(); if(!m_notificationsInterface) { m_notificationsInterface = new OrgFreedesktopNotificationsInterface(QStringLiteral("org.freedesktop.Notifications"), QStringLiteral("/org/freedesktop/Notifications"), conn); connect(m_notificationsInterface, &OrgFreedesktopNotificationsInterface::NotificationClosed, this, &NotificationClientPrivate::notificationClosed); } if(!m_serverInterface) { m_serverInterface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"), QStringLiteral("/org/freedesktop/Notifications"), QStringLiteral("org.ukui.NotificationServer"), conn, this); if(!m_serverInterface->isValid()) { qWarning() << "Failed to create notification server interface! " << conn.lastError(); return false; } } QDBusMessage reply = m_serverInterface->call(QStringLiteral("RegisterClient")); if (reply.type() == QDBusMessage::ErrorMessage || reply.type() == QDBusMessage::InvalidMessage) { qWarning() << "Failed to call RegisterClient!" << conn.lastError() << reply.type(); return false; } return true; } void NotificationClientPrivate::unregisterClient() { if(m_notificationsInterface) { disconnect(m_notificationsInterface, &OrgFreedesktopNotificationsInterface::NotificationClosed, this, &NotificationClientPrivate::notificationClosed); delete m_notificationsInterface; m_notificationsInterface = nullptr; } QDBusConnection conn = QDBusConnection::sessionBus(); if(m_serverInterface) { QDBusMessage reply = m_serverInterface->call(QStringLiteral("UnRegisterClient")); if (reply.type() == QDBusMessage::ErrorMessage || reply.type() == QDBusMessage::InvalidMessage) { qWarning() << "Failed to call UnRegisterClient!" << conn.lastError() << reply.type(); return; } } conn.unregisterObject(clientServicePath(), QDBusConnection::UnregisterTree); m_registered = false; } QString NotificationClientPrivate::clientServicePath() { return QStringLiteral("/NotificationClient"); } QString NotificationClientPrivate::clientServiceInterface() { return QStringLiteral("org.ukui.NotificationClient"); } void NotificationClientPrivate::Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout) { PopupNotification notification(replaces_id); notification.setSummary(summary); notification.setBody(body); notification.setApplicationName(app_name); notification.setApplicationIconName(app_icon); notification.setActions(actions); notification.setTimeout(timeout); notification.setHints(hints); Q_EMIT q->newNotification(notification); } void NotificationClientPrivate::notificationClosed(uint id, uint reason) { auto closeReason = NotificationCloseReason::CloseReason::Undefined; switch (reason) { case 1: closeReason = NotificationCloseReason::CloseReason::Expired; break; case 2: closeReason = NotificationCloseReason::CloseReason::DismissedByUser; break; case 3: closeReason = NotificationCloseReason::CloseReason::Revoked; break; } Q_EMIT q->notificationClosed(id, closeReason); } bool NotificationClientPrivate::closeNotification(uint id, NotificationCloseReason::CloseReason reason) { if(!m_serverInterface) { return false; } QDBusMessage reply = m_serverInterface->callWithArgumentList(QDBus::BlockWithGui, QStringLiteral("CloseNotification"), {id, static_cast(reason)}); if (reply.type() == QDBusMessage::ErrorMessage) { qWarning() << "Failed to call CloseNotification!" << QDBusConnection::sessionBus().lastError(); return false; } return true; } void NotificationClientPrivate::serviceChange(const QString &service, const QString &oldOwner, const QString &newOwner) { qDebug() << "Notification Service" << service << "status change, old owner:" << oldOwner << "new:" << newOwner; if(oldOwner.isEmpty() && m_registered) { registerClient(); } } bool NotificationClientPrivate::invokeAction(uint id, const QString &action_key) { if(!m_serverInterface) { return false; } qDebug() << "invokeAction" << id << action_key; QDBusMessage reply = m_serverInterface->callWithArgumentList(QDBus::NoBlock, QStringLiteral("InvokeAction"), {id, action_key}); if (reply.type() == QDBusMessage::ErrorMessage) { qWarning() << "Failed to call InvokedAction!" << QDBusConnection::sessionBus().lastError(); return false; } return true; } /*! \class UkuiNotification::NotificationClient \inmodule UkuiNotification \inheaderfile notification-client.h \brief UKUI 通知系统客户端 这个类封装了与通知服务交互的细节,并提供交互接口。 通过 \l {registerClient()} 向通知服务注册为客户端,即可接收通知服务发送的消息。 */ /*! \fn void UkuiNotification::NotificationClient::newNotification(const UkuiNotification::PopupNotification ¬ification) 此信号在通知服务收到新通知时发送. */ /*! \fn void UkuiNotification::NotificationClient::notificationClosed(uint id, UkuiNotification::NotificationCloseReason::CloseReason closeReason) 此信号在通知被关闭时发送. */ NotificationClient::NotificationClient(QObject *parent) : QObject(parent), d(new NotificationClientPrivate(this)) { qRegisterMetaType("PopupNotification"); qRegisterMetaType("const UkuiNotification::PopupNotification&"); qRegisterMetaType("ActionList"); qmlRegisterUncreatableType("org.ukui.notification.client", 1, 0, "NotificationCloseReason", ""); } NotificationClient::~NotificationClient() = default; /*! \brief 注册为通知服务客户端. 通过向 DBus总线注册为 DBus 服务,并调用通知服务的 DBus 接口注册为客户端。通知服务通过客户端的 DBus 接口,向客户端发送通知消息。 */ bool NotificationClient::registerClient() { return d->init(); } /*! \brief 调用此接口关闭通知. \a id: 通知ID, \a reason:通知关闭的原因 */ bool NotificationClient::closeNotification(uint id, NotificationCloseReason::CloseReason reason) { return d->closeNotification(id, reason); } /*! \brief 调用通知对应的 Action \a id: 通知ID, \a action_key:Action对应的 key, 由通知发送者定义。 */ bool NotificationClient::invokeAction(uint id, const QString &action_key) { return d->invokeAction(id, action_key); } /*! \brief 注销通知客户端 调用此接口注销客户端,注销之后不在接收通知消息 */ void NotificationClient::unregisterClient() { d->unregisterClient(); } ukui-notification/libukui-notification/doc/0000775000175000017500000000000015160523734020044 5ustar fengfengukui-notification/libukui-notification/doc/images/0000775000175000017500000000000015160523734021311 5ustar fengfengukui-notification/libukui-notification/doc/images/plugin_ui.png0000664000175000017500000020650715160523734024024 0ustar fengfengPNG  IHDRdIDATx^{U_}ˍJ/"$B i"(%ޤBB =ͦmzBP@:Ă "EEH>CəMYvf%י3g̙3iEf 5%B!g F}ݻ7o޼qτ8\qҕfB1F}'nݒS]B\+Bl}QkA#I:.c&[@cZq޽+'8&|pR1B7oY-! .f&1j-c8p17!XM>]p G/xkG&W~D4o`T1B9%đoB|,-TĬ6/Y2} 1lXc4SA^aq)ed-/wg޵` XT+̙p a0̆>S]񫴌ٙi0CZNn~^AX~zʋ2rf+V6? BYB&)2# 3gΜS l֬YӦM=x80 X;41cF!#=;_k| [C—>*PLi[LeB 9%S\\.gVh2b$&&W9`ؚ{US~9}ɓ'O4iE_dcيIFa}oR]W/D8f'EL4Ym6g}-/F@Q->Li:3d 3r"? reX;`e8'Άs@ƌ ŋ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Μ@7=~__gR|r8%%!1wrݲe̙3ײR  wڱc'Λ7JH#Y"ڽgVRҮET*<<|5Ǔ}-]N%Y%&FDEp1"""Oًܙt9wHÇS 7ny1z υ#O[R;#GQ򆆟^T@Lש}igɽ{y$W+W\!y sGiҤb'ZxqܹYYΤgdd-y63 L)$$\νSWs#GwUc\}ԩ7Ź7Aᧅ3"*P=S4/|{'^{ s//?ty-ᧅ3"*P=!C~ZxC1/'Wꁏ!| ~cZě{O g*EUz^DCG5Z|\VY,eZ|jd׸y⧅3"*P=|L2J"_j4VskC6xє~ O{!m-#G꫌Lb :OnʟZcKvh3qs^).|i5L TK)VEp<)|]_V"j)7ZA 裞꫍Lf^iV,n&1nWc}.O g*EUz˫g݃V1kc}*V%Bץl;kΖƎ^@ORnu^[~X0OZ6W*T+k헆@WRpb$KWW=n\z`{5mXdV >-mt?)f/=Q}LPi$Ym]O--r¸p|F\}067tL}7~Zx ?S/¯31RohROc8zIvJB_.?*iECeUW\7XZmnE,i%WObH!ijWT_U՗Solz[k DQW4 qsLYޗRB\IFi5=)9 l}m4AR\}z[ک-i: 10.UzV:cKe} WꨵusG޹˛*vP_}9j *[CA鏇Ozl UEn~"oqJzl&5XKTz_J劯+'}R{x *8x96ncJE~n]E^T@L+hWóm5TmKJڗ+*xkĂfcl﷘W9n9vن!dvP})+et?x^eᧅ3"*P=?nWwX{F-+/GE?Y}>_0Tr~dy%M.u1zʕ"S^?ZPdrqc|<}x\<-?-W?Vf6WF%S,A?,Uhn6O׊uφϧ?0JUTG,j춽q>t֗Df|P ?&w 71wRx_ }XG+m3<57#OA(mX$ksy({Śx[~Zx ?S/¯? `^IENDB`ukui-notification/libukui-notification/doc/ukui-notification.qdoc0000664000175000017500000001051115160523734024353 0ustar fengfeng/*! \module UkuiNotification \title Ukui Notification C++ Classes \brief 提供 Ukui Notification 开发接口的C++类实现. */ /*! \namespace UkuiNotification \inmodule UkuiNotification \keyword UkuiNotification Namespace \cmakepackage ukui-notification \brief The UkuiNotification namespace . */ /*! \page ukui-notification.html \title Ukui Notification ukui-notificaton包含UKUI桌面环境的通知服务、通知开发接口和通知控制插件。本文档重点介绍通知开发接口的使用。 \list \li ukui-notification-server: 通知服务 \li libukui-notification: 通知开发接口 \li notification-ukcc-plugin: 通知控制插件 \endlist \section1 通知服务 ukui-notifiaction-server提供了遵循freedesktop \l{https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html}{通知协议}的通知服务接口。 \section2 支持的Capabilities \table 80% \header \li Capability \li 描述 \row \li actions \li 支持通知操作按钮 \row \li body \li 支持富文本内容 \row \li body-hyperlinks \li 支持内容中的超链接 \row \li persistence \li 支持持久化通知 \row \li sound \li 支持通知声音提示 \endtable \section2 扩展hints \table \header \li Hint \li 描述 \row \li x-ukui-display \li 标识通知弹窗应该显示在哪个DISPLAY上 \endtable \section2 扩展接口 \table 80% \header \li 接口名称 \li 参数 \li 返回值 \li 描述 \row \li org.ukui.NotificationServer.UpdateUnreadMessagesNumber \li String desktop_entry, UInt32 number \li void \li 更新应用的未读消息数量 \row \li org.ukui.NotificationServer.RegisterNotificationControl \li String desktop_entry \li void \li 注册应用的通知控制 \endtable \section1 通知开发接口 通知提供了接口方便其他应用注册为通知客户端,接收通知服务发来的通知以及与通知服务进行其他交互。 \section2 使用 CMake: \code find_package(ukui-notification target_link_libraries(yourapp ukui-notification)) \endcode QMake: \code CONFIG += link_pkgconfig PKGCONFIG += ukui-notification \endcode \section2 关键接口 \table 80% \header \li Class/NameSpace \li 功能描述 \row \li UkuiNotification \li 通知系统的全局命名空间 \row \li UkuiNotification::NotificationClient \li 通知系统客户端接口 \row \li UkuiNotification::NotificationCloseReason \li 通知关闭原因的类,提供了枚举 CloseReason \row \li UkuiNotification::NotificationGlobalSettings \li 提供通知系统的全局配置管理功能 \row \li UkuiNotification::PopupNotification \li 表示一条通知,包含一条通知消息的全部 \row \li UkuiNotification::SettingsPropertiesInfo \li 封装通知设置属性的元数据信息 \row \li UkuiNotification::SingleApplicationSettings \li 表示单个应用的通知设置 \row \li UkuiNotification::ApplicationsSettings \li 提供应用程序通知设置的管理功能 \endtable \section1 通知控制插件 控制面板通知插件,方便用户设置应用通知的权限。 \image plugin_ui.png */ ukui-notification/libukui-notification/doc/notification-close-reason.qdoc0000664000175000017500000000076115160523734025776 0ustar fengfeng/*! \class UkuiNotification::NotificationCloseReason \inmodule UkuiNotification \inheaderfile notification-close-reason.h \brief 表示通知关闭原因的类,提供了枚举 CloseReason */ /*! \enum NotificationCloseReason::CloseReason 表示通知关闭原因的枚举 \value Expired 通知已过期 \value DismissedByUser 通知被用户关闭 \value Revoked 通知被发送者通过调用 CloseNotification 接口关闭 \value Undefined 未定义 */ukui-notification/libukui-notification/doc/settings-properties.qdoc0000664000175000017500000000376715160523734024763 0ustar fengfeng/*! \namespace UkuiNotification::SettingsProperty \inmodule UkuiNotification \brief 包含通知设置属性的枚举和类型定义. */ /*! \enum UkuiNotification::SettingsProperty::Property The Property enum contains all settings property types. \value Invalid = 0 无效值 \value ScheduleTurnOnDND 是否在计划时间范围内自动开启勿扰模式,bool类型,默认值false \value ScheduleTurnOnDNDTime 勿扰模式开启时间,QTime类型,默认值00:00 \value ScheduleTurnOffDNDTime 勿扰模式结束时间,QTime类型,默认值00:00 \value DNDWhileMultiScreen 是否多屏启动时是否启动勿扰模式,bool类型,默认值false \value DNDWhileFullScreen 是否全屏状态下是否启动勿扰模式,bool类型,默认值false \value NotifyAlarmWhileDND 是否勿扰模式下是否允许闹钟提示,bool类型,默认值false \value ReceiveNotificationsFromApps 是否获取来自应用程序的通知,bool类型,默认值true \value AllowNotify 是否接收当前应用通知,bool类型,默认值true \value AllowSound 是否打开通知提示声,bool类型,默认值true \value ShowContentOnLockScreen 是否锁屏界面是否显示通知内容信息,bool类型,默认值false \value ShowNotificationOnLockScreen 是否锁屏界面是否显示通知,bool类型,默认值false \value ConfigurationSource = 100 用于标记配置来源 */ /*! \typedef PropertyMap \relates UkuiNotification::SettingsProperty 同 QMap, 用于存储应用的通知设置属性和值 . */ /*! \variable UkuiNotification::GLOBAL_SETTINGS \brief 包含通知全局配置属性的列表. */ /*! \variable UkuiNotification::SINGLE_APPLICATION_SETTINGS \brief 包含单个应用的通知配置属性的列表. */ukui-notification/libukui-notification/doc/utils.qdoc0000664000175000017500000000250515160523734022056 0ustar fengfeng /*! \namespace UkuiNotification::Utils \inmodule UkuiNotification \brief 提供一些方便的接口. */ /*! \fn UkuiSearch::ApplicationInfo& UkuiNotification::Utils::applicationInfo() 获取全局 UkuiSearch::ApplicationInfo 实例. */ /*! \fn QString UkuiNotification::Utils::desktopEntryFromPid(uint pid, bool isFullPath = false) 根据进程号 \a pid 获取应用的 desktop 文件,\a isFullPath 是否获取全路径的标志位。 */ /*! \fn QString UkuiNotification::Utils::displayFromPid(uint pid) 根据进程号 \a pid 获取应用所在的 DISPLAY */ /*! \fn QString UkuiNotification::Utils::desktopEntryFromName(QString desktopFileName) 根据 \a desktopFileName 文件名(不带后缀)获取 desktop 全路径。 */ /*! \fn inline QString UkuiNotification::Utils::desktopEntry2Name(const QString& desktopFileName) Returns desktop 文件名(不含后缀),从 \a desktopFileName 文件全路径截取。 */ /*! \fn QString UkuiNotification::Utils::appNameForDesktopEntry(const QString& desktopFileName) 通过 desktop 全路径获取应用名称获取应用名称。 */ /*! \macro StringListDiff \relates UkuiNotification::Utils 返回 a 中存在 b 中不存在的元素, 求差集 \code StringListDiff(a, b) \endcode */ ukui-notification/libukui-notification/ukui-notification-config.cmake.in0000664000175000017500000000012315160523734025606 0ustar fengfeng@PACKAGE_INIT@ include("${CMAKE_CURRENT_LIST_DIR}/ukui-notification-targets.cmake")ukui-notification/libukui-notification/ukui-notification.pc.in0000664000175000017500000000046315160523734023674 0ustar fengfengprefix=/usr exec_prefix=${prefix} libdir=${prefix}/lib/@CMAKE_LIBRARY_ARCHITECTURE@ includedir=${prefix}/include/ukui-notification Name: ukui-notification Description: ukui-notification header files URL: https://www.ukui.org/ Version: @VERSION@ Cflags: -I${includedir} Libs: -L${libdir} -lukui-notificationukui-notification/libukui-notification/CMakeLists.txt0000664000175000017500000001440715160523746022050 0ustar fengfengset(VERSION_MAJOR 1) set(VERSION_MINOR 1) set(VERSION_MICRO 0) #changelog v1.0.0->v1.1.0:超时时间统一为单位为ms set(UKUI_NOTIFICATION_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}) include(FeatureSummary) find_package(ECM) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" TRUE) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMAddQch) find_package(PkgConfig REQUIRED) set(UKUI_NOTIFICATION_EXTERNAL_LIBS "") set(UKUI_NOTIFICATION_PC_PKGS ukui-search) foreach(PC_LIB IN ITEMS ${UKUI_NOTIFICATION_PC_PKGS}) pkg_check_modules(${PC_LIB} REQUIRED ${PC_LIB}) if(${${PC_LIB}_FOUND}) include_directories(${${PC_LIB}_INCLUDE_DIRS}) link_directories(${${PC_LIB}_LIBRARY_DIRS}) list(APPEND UKUI_NOTIFICATION_EXTERNAL_LIBS ${${PC_LIB}_LIBRARIES}) endif() endforeach() include_directories(notification-settings) set(ukui-notification_LIB_SRCS notification-client.cpp notification-client.h popup-notification.h popup-notification.cpp ukui-notification_global.h notification-client-private.h utils.h utils.cpp notification-close-reason.h security-control-config.h security-control-config.cpp notification-settings/settings-properties.h notification-settings/settings-properties-info.h notification-settings/settings-properties-info.cpp notification-settings/settings-manager-private.h notification-settings/settings-manager.h notification-settings/settings-manager.cpp notification-settings/notification-global-settings.cpp notification-settings/notification-global-settings.h notification-settings/single-application-settings.cpp notification-settings/single-application-settings.h notification-settings/applications-settings.cpp notification-settings/applications-settings.h) set(HEADERS notification-client.h popup-notification.h notification-close-reason.h notification-settings/settings-properties.h notification-settings/settings-properties-info.h notification-settings/notification-global-settings.h notification-settings/single-application-settings.h notification-settings/applications-settings.h ukui-notification_global.h utils.h) if(COMMAND qt_add_dbus_interface) qt_add_dbus_interface(ukui-notification_LIB_SRCS ../dbus/org.freedesktop.Notifications.xml notifications_interface) qt_add_dbus_adaptor(ukui-notification_LIB_SRCS ../dbus/org.ukui.NotificationClient.xml notification-client-private.h UkuiNotification::NotificationClientPrivate) else() qt5_add_dbus_interface(ukui-notification_LIB_SRCS ../dbus/org.freedesktop.Notifications.xml notifications_interface) qt5_add_dbus_adaptor(ukui-notification_LIB_SRCS ../dbus/org.ukui.NotificationClient.xml notification-client-private.h UkuiNotification::NotificationClientPrivate) endif() add_library(ukui-notification SHARED ${ukui-notification_LIB_SRCS}) target_link_libraries(ukui-notification PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::DBus Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Qml ${UKUI_NOTIFICATION_EXTERNAL_LIBS} ukui-quick::platform ) include(CMakePackageConfigHelpers) set(CMAKE_CONFIG_INSTALL_DIR "/usr/share/cmake/ukui-notification") set(HEADERS_INSTALL_DIR /usr/include/ukui-notification) set(PC_INSTALL_DIR "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") target_include_directories(ukui-notification PUBLIC $) if (BUILD_QCH) if (QT_VERSION_MAJOR EQUAL 6) set(QCH_INSTALL_DIR "/usr/share/doc/qt6/") else() set(QCH_INSTALL_DIR "/usr/share/qt5/doc/") endif() ecm_add_qch( ukui-notification-qch NAME ukui-notification BASE_NAME ukui-notification VERSION "${UKUI_NOTIFICATION_VERSION}" ORG_DOMAIN org.ukui SOURCES ${HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} TAGFILE_INSTALL_DESTINATION ${QCH_INSTALL_DIR} QCH_INSTALL_DESTINATION ${QCH_INSTALL_DIR} COMPONENT Devel ) ecm_install_qch_export( TARGETS ukui-notification-qch FILE ukui-notification-qch-targets.cmake DESTINATION "${CMAKE_CONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/ukui-notification-qch-targets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake" INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config-version.cmake VERSION ${UKUI_NOTIFICATION_VERSION} COMPATIBILITY SameMajorVersion ) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/ukui-notification.pc" INSTALL_DESTINATION ${PC_INSTALL_DIR}) set_target_properties(ukui-notification PROPERTIES VERSION ${UKUI_NOTIFICATION_VERSION} SOVERSION ${VERSION_MAJOR} OUTPUT_NAME ukui-notification ) install(TARGETS ukui-notification EXPORT ukui-notification PUBLIC_HEADER DESTINATION ${HEADERS_INSTALL_DIR} LIBRARY DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} ) install(EXPORT ukui-notification FILE ukui-notification-targets.cmake DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}) install(FILES ${HEADERS} DESTINATION ${HEADERS_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification.pc DESTINATION ${PC_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config-version.cmake DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}) if(BUILD_TEST) add_subdirectory(autotest) endif () ukui-notification/libukui-notification/security-control-config.h0000664000175000017500000000260415160523746024245 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: maomao */ #ifndef UKUI_NOTIFICATION_SECURITYCONTROLCONFIG_H #define UKUI_NOTIFICATION_SECURITYCONTROLCONFIG_H #include #include namespace UkuiNotification { class SecurityControlConfig : public QObject { Q_OBJECT public: static SecurityControlConfig& instance(); bool isNotificationEnable() const; public Q_SLOTS: void onControlConfigChanged(const QString &name); void onControlExited(); Q_SIGNALS: void configChanged(); void exitControl(); private: explicit SecurityControlConfig(QObject *parent = nullptr); void initData(); QJsonObject m_config; }; } #endif //UKUI_NOTIFICATION_SECURITYCONTROLCONFIG_H ukui-notification/libukui-notification/autotest/0000775000175000017500000000000015160523734021147 5ustar fengfengukui-notification/libukui-notification/autotest/settings-properties-info-test.h0000664000175000017500000000175415160523734027267 0ustar fengfeng/* * * Copyright (C) 2024, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom * */ #ifndef SETTINGS_PROPERTIES_INFO_TEST_H #define SETTINGS_PROPERTIES_INFO_TEST_H #include class SettingsPropertiesInfoTest : public QObject { Q_OBJECT private Q_SLOTS: void testName(); }; #endif //SETTINGS_PROPERTIES_INFO_TEST_H ukui-notification/libukui-notification/autotest/CMakeLists.txt0000664000175000017500000000117315160523734023711 0ustar fengfengset(CMAKE_AUTOMOC on) find_package(QT NAMES Qt6 Qt5 COMPONENTS Test REQUIRED) find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test) remove_definitions(-DQT_NO_CAST_FROM_ASCII) include_directories(../) add_executable(settingsPropertiesInfoTest settings-properties-info-test.cpp ../notification-settings/settings-properties-info.cpp) target_link_libraries(settingsPropertiesInfoTest PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test ukui-notification ) add_test(settingsPropertiesInfoTest ${CMAKE_BINARY_DIR}/autotests/settingsPropertiesInfoTest) ukui-notification/libukui-notification/autotest/settings-properties-info-test.cpp0000664000175000017500000000546115160523734027621 0ustar fengfeng/* * * Copyright (C) 2024, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom * */ #include "settings-properties-info-test.h" #include "settings-properties-info.h" #include void SettingsPropertiesInfoTest::testName() { UkuiNotification::SettingsPropertiesInfo info(UkuiNotification::SettingsProperty::Invalid); QCOMPARE(info.name(), "Invalid"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::ScheduleTurnOnDND); QCOMPARE(info.name(), "ScheduleTurnOnDND"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::ScheduleTurnOnDNDTime); QCOMPARE(info.name(), "ScheduleTurnOnDNDTime"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::ScheduleTurnOffDNDTime); QCOMPARE(info.name(), "ScheduleTurnOffDNDTime"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::DNDWhileMultiScreen); QCOMPARE(info.name(), "DNDWhileMultiScreen"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::DNDWhileFullScreen); QCOMPARE(info.name(), "DNDWhileFullScreen"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::NotifyAlarmWhileDND); QCOMPARE(info.name(), "NotifyAlarmWhileDND"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::ReceiveNotificationsFromApps); QCOMPARE(info.name(), "ReceiveNotificationsFromApps"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::AllowNotify); QCOMPARE(info.name(), "AllowNotify"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::AllowSound); QCOMPARE(info.name(), "AllowSound"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::ShowContentOnLockScreen); QCOMPARE(info.name(), "ShowContentOnLockScreen"); info = UkuiNotification::SettingsPropertiesInfo(UkuiNotification::SettingsProperty::ShowNotificationOnLockScreen); QCOMPARE(info.name(), "ShowNotificationOnLockScreen"); } QTEST_GUILESS_MAIN(SettingsPropertiesInfoTest) ukui-notification/libukui-notification/notification-client.h0000664000175000017500000000526315160523734023420 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_NOTIFICATION_CLIENT_H #define UKUI_NOTIFICATION_NOTIFICATION_CLIENT_H #include "ukui-notification_global.h" #include #include "popup-notification.h" #include "notification-close-reason.h" namespace UkuiNotification { class NotificationClientPrivate; /** * @short 通知中心客户端接口. * @author iaom */ class UKUINOTIFICATION_EXPORT NotificationClient : public QObject { Q_OBJECT public: explicit NotificationClient(QObject *parent = nullptr); ~NotificationClient(); /** * @brief 客户端注册,注册后可监听通知发送&关闭信号或调用通知动作执行以及主动关闭通知的接口。 * @return 是否成功操作 * @retval 成功:true;失败:false */ bool registerClient(); /** * @brief 注销当前客户端,注销后将不能再接收到新通知或通知关闭信号。 * @return 是否成功操作 * @retval 成功:true;失败:false */ void unregisterClient(); /** * @brief 关闭一条通知 * @param id:通知id * @param reason:通知关闭原因 * @return 是否成功操作 * @retval 成功:true;失败:false */ bool closeNotification(uint id, NotificationCloseReason::CloseReason reason); /** * @brief 执行动作 * @param id: 通知id * @param action_key: action的唯一标识 * @return 是否成功操作 * @retval 成功:true;失败:false */ bool invokeAction(uint id, const QString &action_key); Q_SIGNALS: /** * 通知服务收到新通知时发送. */ void newNotification(const UkuiNotification::PopupNotification ¬ification); /** * 通知被关闭时发送. */ void notificationClosed(uint id, UkuiNotification::NotificationCloseReason::CloseReason closeReason); private: NotificationClientPrivate *d = nullptr; }; } // UkuiNotification #endif //UKUI_NOTIFICATION_NOTIFICATION_CLIENT_H ukui-notification/libukui-notification/security-control-config.cpp0000664000175000017500000000447515160523746024610 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: maomao */ #include "security-control-config.h" #include #include using namespace UkuiNotification; using namespace UkuiQuick; static const QString CONFIG_NAME = "ukui-notification-v11"; static const QString NOTIFICATION_DISABLE_KEY = "disableAllNotifications"; SecurityControlConfig &SecurityControlConfig::instance() { static SecurityControlConfig instance; return instance; } SecurityControlConfig::SecurityControlConfig(QObject *parent) : QObject(parent) { initData(); connect(FunctionControl::instance(), &FunctionControl::functionControlChanged, this, &SecurityControlConfig::onControlConfigChanged); connect(FunctionControl::instance(), &FunctionControl::functionControlExit, this, &SecurityControlConfig::onControlExited); } void SecurityControlConfig::initData() { FunctionControl::instance()->addWatch(CONFIG_NAME); m_config = FunctionControl::instance()->functionControlObject(CONFIG_NAME).value(CONFIG_NAME).toObject(); qDebug() << "Init SecurityCtrl config data" << m_config; } void SecurityControlConfig::onControlExited() { m_config = {}; Q_EMIT exitControl(); } void SecurityControlConfig::onControlConfigChanged(const QString &name) { if (name == CONFIG_NAME) { m_config = FunctionControl::instance()->functionControlObject(CONFIG_NAME).value(CONFIG_NAME).toObject(); qDebug() << "Refresh SecurityCtrl config" << m_config; Q_EMIT configChanged(); } } bool SecurityControlConfig::isNotificationEnable() const { return m_config.isEmpty() || !m_config.value(NOTIFICATION_DISABLE_KEY).toBool(); }ukui-notification/libukui-notification/notification-client-private.h0000664000175000017500000000500115160523734025056 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_NOTIFICATION_CLIENT_PRIVATE_H #define UKUI_NOTIFICATION_NOTIFICATION_CLIENT_PRIVATE_H #include #include #include #include "notifications_interface.h" #include "notification-client.h" namespace UkuiNotification { class NotificationClientPrivate : public QObject { Q_OBJECT public: explicit NotificationClientPrivate(NotificationClient *q); ~NotificationClientPrivate() override; /** * 初始化客户端dbus服务并注册成为客户端 * @return */ bool init(); /** * 注销 */ void unregisterClient(); static QString clientServicePath(); static QString clientServiceInterface(); void Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout); bool closeNotification(uint id, NotificationCloseReason::CloseReason reason); bool invokeAction(uint id, const QString &action_key); private Q_SLOTS: void notificationClosed(uint id, uint reason); void serviceChange(const QString &service, const QString &oldOwner, const QString &newOwner); /** * 用于注册客户端,或在服务发生变化(重启)后重新注册客户端 * @return true 成功 false 失败 */ bool registerClient(); private: OrgFreedesktopNotificationsInterface* m_notificationsInterface = nullptr; QDBusInterface *m_serverInterface = nullptr; QDBusServiceWatcher *m_watcher = nullptr; bool m_registered = false; NotificationClient *q; }; } #endif //UKUI_NOTIFICATION_NOTIFICATION_CLIENT_PRIVATE_H ukui-notification/libukui-notification/notification-settings/0000775000175000017500000000000015160523746023626 5ustar fengfengukui-notification/libukui-notification/notification-settings/settings-manager.h0000664000175000017500000000471615160523746027257 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef SETTINGS_MANAGER_H #define SETTINGS_MANAGER_H #include #include "settings-properties.h" namespace UkuiNotification { class SettingsManagerPrivate; class SettingsManager : public QObject { Q_OBJECT public: static SettingsManager *self(); ~SettingsManager() = default; /** * 获取全局配置 */ QJsonObject getGlobalSettings(); /** * @brief getAllAppSettings * 获取当前用户全部应用通知相关配置信息。 */ QJsonObject getAllAppSettings(); /** * @brief getAppSettings * 获取当前用户某个应用通知相关配置信息。 * @param appDesktopName 传"default"获取配置默认值 */ QJsonObject getAppSettings(const QString &appDesktopName); /** * 获取应用通知设置默认值 * @return */ QJsonObject getAppDefaultSettings(); /** * 获取默认应用列表 * @return */ void getAppList(QStringList &defaultAppList, QStringList &otherAppList); bool setGlobalSettings(SettingsProperty::Property key, const QVariant &value); bool setAppSettings(const QString &appDesktopName, SettingsProperty::Property key, const QVariant &value); bool addAppSettings(const QString &appDesktopName, const QString &configurationSource = "Default"); bool deleteAppSettings(const QString &appDesktopName); bool hasAppSettings(const QString &appDesktopName); bool isInAllowList(const QString &appDesktopName); Q_SIGNALS: void settingsDataChanged(); void newAppInstalled(const QString &desktopEntry); void appUninstalled(const QString &desktopEntry); private: SettingsManager(QObject *parent = nullptr); SettingsManagerPrivate * d = nullptr; }; } #endif ukui-notification/libukui-notification/notification-settings/notification-global-settings.h0000664000175000017500000000774015160523734031566 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_NOTIFICATION_GLOBAL_SETTINGS_H #define UKUI_NOTIFICATION_NOTIFICATION_GLOBAL_SETTINGS_H #include #include #include "settings-properties.h" namespace UkuiNotification { class NotificationGlobalSettingsPrivate; /** * @short 通知的全局设置. * @author iaom */ class NotificationGlobalSettings : public QObject { Q_OBJECT Q_PROPERTY(bool scheduleTurnOnDND READ scheduleTurnOnDND WRITE setScheduleTurnOnDND NOTIFY scheduleTurnOnDNDChanged) Q_PROPERTY(QTime scheduleTurnOnDNDTime READ scheduleTurnOnDNDTime WRITE setScheduleTurnOnDNDTime NOTIFY scheduleTurnOnDNDTimeChanged) Q_PROPERTY(QTime scheduleTurnOffDNDTime READ scheduleTurnOffDNDTime WRITE setScheduleTurnOffDNDTime NOTIFY scheduleTurnOffDNDTimeChanged) Q_PROPERTY(bool DNDWhileMultiScreen READ DNDWhileMultiScreen WRITE setDNDWhileMultiScreen NOTIFY DNDWhileMultiScreenChanged) Q_PROPERTY(bool DNDWhileFullScreen READ DNDWhileFullScreen WRITE setDNDWhileFullScreen NOTIFY DNDWhileFullScreenChanged) Q_PROPERTY(bool notifyAlarmWhileDND READ notifyAlarmWhileDND WRITE setNotifyAlarmWhileDND NOTIFY notifyAlarmWhileDNDChanged) Q_PROPERTY(bool receiveNotificationsFromApps READ receiveNotificationsFromApps WRITE setReceiveNotificationsFromApps NOTIFY receiveNotificationsFromAppsChanged) Q_PROPERTY(bool DND READ isDND NOTIFY dndChanged) public: NotificationGlobalSettings(QObject *parent = nullptr); ~NotificationGlobalSettings(); /** * 自动开启勿扰模式 * @return true 自动开启 false 关闭 */ bool scheduleTurnOnDND(); void setScheduleTurnOnDND(bool enable); /** * 自动开启勿扰模式时间 * @return */ QTime scheduleTurnOnDNDTime(); void setScheduleTurnOnDNDTime(const QTime &time); /** * 自动关闭勿扰模式时间 * @return */ QTime scheduleTurnOffDNDTime(); void setScheduleTurnOffDNDTime(const QTime &time); /** * 多屏连接时自动开启勿扰模式 * @return */ bool DNDWhileMultiScreen(); void setDNDWhileMultiScreen(bool enable); /** * 全屏模式下自动开启勿扰模式 * @return */ bool DNDWhileFullScreen(); void setDNDWhileFullScreen(bool enable); /** * 勿扰模式下允许闹钟提示 * @return */ bool notifyAlarmWhileDND(); void setNotifyAlarmWhileDND(bool enable); /** * 获取来自应用的通知 * @return */ bool receiveNotificationsFromApps(); void setReceiveNotificationsFromApps(bool enable); /** * 当前是否处于勿扰模式 * @return */ bool isDND(); Q_SIGNALS: void scheduleTurnOnDNDChanged(bool); void scheduleTurnOnDNDTimeChanged(QTime); void scheduleTurnOffDNDTimeChanged(QTime); void DNDWhileMultiScreenChanged(bool); void DNDWhileFullScreenChanged(bool); void notifyAlarmWhileDNDChanged(bool); void receiveNotificationsFromAppsChanged(bool); void dndChanged(bool); private Q_SLOTS: void settingsDataChanged(); void screenModeChanged(int mode); void checkDNDMode(); void checkTimeForDND(); private: NotificationGlobalSettingsPrivate *d = nullptr; }; } // UkuiNotification #endif //UKUI_NOTIFICATION_NOTIFICATION_GLOBAL_SETTINGS_H ukui-notification/libukui-notification/notification-settings/single-application-settings.cpp0000664000175000017500000001707515160523746031764 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "single-application-settings.h" #include #include #include "settings-properties-info.h" #include "applications-settings.h" namespace UkuiNotification{ class SingleApplicationSettingsPrivate { friend class SingleApplicationSettings; public: SingleApplicationSettingsPrivate(); SingleApplicationSettingsPrivate(const SingleApplicationSettingsPrivate &other); ~SingleApplicationSettingsPrivate(); private: QJsonObject m_settings; QString m_desktopEntry; }; } using namespace UkuiNotification; SingleApplicationSettingsPrivate::SingleApplicationSettingsPrivate() { } SingleApplicationSettingsPrivate::SingleApplicationSettingsPrivate(const SingleApplicationSettingsPrivate &other) { m_settings = other.m_settings; m_desktopEntry = other.m_desktopEntry; } SingleApplicationSettingsPrivate::~SingleApplicationSettingsPrivate() { } /*! \class UkuiNotification::SingleApplicationSettings \inmodule UkuiNotification \inheaderfile notification-settings/single-application-settings.h \brief 表示单个应用的通知设置 */ /*! Constructor frome desktopEntry. */ SingleApplicationSettings::SingleApplicationSettings(const QString &desktopEntry, QObject *parent) : QObject(parent) , d(new SingleApplicationSettingsPrivate) { d->m_desktopEntry = desktopEntry; init(); } /*! Copy Constructor. */ SingleApplicationSettings::SingleApplicationSettings(const SingleApplicationSettings &other) : d(new SingleApplicationSettingsPrivate(*other.d)) { init(); } /*! Copy Assignment Operator. */ SingleApplicationSettings &SingleApplicationSettings::operator=(const SingleApplicationSettings &other) { *d = *other.d; init(); return *this; } /*! Move Assignment Operator. */ SingleApplicationSettings &SingleApplicationSettings::operator=(SingleApplicationSettings &&other) Q_DECL_NOEXCEPT { d = other.d; other.d = nullptr; init(); return *this; } /*! Destructor. */ SingleApplicationSettings::~SingleApplicationSettings() { if(d) { delete d; d = nullptr; } } void SingleApplicationSettings::init() { d->m_settings = ApplicationsSettings::self()->getAppSettings(d->m_desktopEntry); if(d->m_desktopEntry != QStringLiteral("default") && !d->m_desktopEntry.isEmpty()) { connect(ApplicationsSettings::self(), &ApplicationsSettings::applicationUninstalled, this, &SingleApplicationSettings::appUninstalled); connect(ApplicationsSettings::self(), &ApplicationsSettings::settingsUpdated, this, &SingleApplicationSettings::settingsDataChanged); } } /*! \property SingleApplicationSettings::allowNotify 此属性表示应用是否允许发送通知。 */ bool SingleApplicationSettings::allowNotify() const { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::AllowNotify).name()).toVariant().toBool(); } /*! \property SingleApplicationSettings::allowSound 此属性表示应用是否播放声音。 */ bool SingleApplicationSettings::allowSound() const { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::AllowSound).name()).toVariant().toBool(); } /*! \property SingleApplicationSettings::showContentOnLockScreen 此属性表示应用是否在锁屏界面显示通知内容。 */ bool SingleApplicationSettings::showContentOnLockScreen() const { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::ShowContentOnLockScreen).name()).toVariant().toBool(); } /*! \property SingleApplicationSettings::showNotificationOnLockScreen 此属性表示应用是否在锁屏界面显示通知。 */ bool SingleApplicationSettings::showNotificationOnLockScreen() const { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::ShowNotificationOnLockScreen).name()).toVariant().toBool(); } //SettingsProperty::Property UkuiNotification::SingleApplicationSettings::popupStyle() const //{ // return SettingsPropertiesInfo::fromName(d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::PopupStyle).name()).toString()).property(); //} void SingleApplicationSettings::settingsDataChanged(const QString& desktopEntry) { if (desktopEntry != d->m_desktopEntry) { return; } QJsonObject data = ApplicationsSettings::self()->getAppSettings(d->m_desktopEntry); if(data.isEmpty()) { return; } for(SettingsProperty::Property property : SINGLE_APPLICATION_SETTINGS) { QString name = SettingsPropertiesInfo(property).name(); QJsonValue value = data.value(name); if(d->m_settings.value(name) != value) { d->m_settings.insert(name, value); switch (property) { case SettingsProperty::AllowNotify: Q_EMIT allowNotifyChanged(value.toVariant().toBool()); break; case SettingsProperty::AllowSound: Q_EMIT allowSoundChanged(value.toVariant().toBool()); break; case SettingsProperty::ShowContentOnLockScreen: Q_EMIT showContentOnLockScreenChanged(value.toVariant().toBool()); break; case SettingsProperty::ShowNotificationOnLockScreen: Q_EMIT showNotificationOnLockScreenChanged(value.toVariant().toBool()); break; // case SettingsProperty::PopupStyle: // Q_EMIT popupStyleChanged(SettingsPropertiesInfo::fromName(value.toString()).property()); // break; default: break; } } } } void SingleApplicationSettings::appUninstalled(const QString &desktopEntry) { if(d->m_desktopEntry == desktopEntry) { Q_EMIT uninstalled(); } } void SingleApplicationSettings::setAllowNotify(bool enable) { qWarning() << d->m_desktopEntry << enable; ApplicationsSettings::self()->setAppSetting(d->m_desktopEntry, SettingsProperty::AllowNotify, enable); } void SingleApplicationSettings::setAllowSound(bool enable) { ApplicationsSettings::self()->setAppSetting(d->m_desktopEntry, SettingsProperty::AllowSound, enable); } void SingleApplicationSettings::setShowContentOnLockScreen(bool enable) { ApplicationsSettings::self()->setAppSetting(d->m_desktopEntry, SettingsProperty::ShowContentOnLockScreen, enable); } void SingleApplicationSettings::setShowNotificationOnLockScreen(bool enable) { ApplicationsSettings::self()->setAppSetting(d->m_desktopEntry, SettingsProperty::ShowNotificationOnLockScreen, enable); } //void SingleApplicationSettings::setPopupStyle(SettingsProperty::Property style) //{ // ApplicationsSettings::self()->setAppSetting(d->m_desktopEntry, SettingsProperty::PopupStyle, style); //} /*! 返回当前应用的 desktop entry. */ QString SingleApplicationSettings::desktopEntry() const { return d->m_desktopEntry; } ukui-notification/libukui-notification/notification-settings/settings-manager.cpp0000664000175000017500000003722015160523746027606 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "settings-manager.h" #include "settings-manager-private.h" #include #include #include #include #include #include #include #include #include #include #include "settings-properties-info.h" #include "utils.h" using namespace UkuiNotification; static const QString SETTINGS_FILE_PATH = QDir::homePath() + QStringLiteral("/.config/org.ukui/ukui-notification"); static const QString SETTINGS_FILE_PATH_NAME = SETTINGS_FILE_PATH + QStringLiteral("/ukui-notification-settings.json"); static const QString SETTINGS_ALLOW_LIST_NAME = QStringLiteral("/etc/ukui/ukui-notification/notification-allowlist.json"); static const QString DEFAULT_APP_LIST_PATH = QStringLiteral("/etc/ukui/ukui-notification/default-app/"); static std::once_flag flag; static SettingsManager *s_self; SettingsManagerPrivate::SettingsManagerPrivate(QObject* parent) : QObject(parent) , m_applicationInfo(Utils::applicationInfo()) , m_allowListData(loadAllowListData()) { for(SettingsProperty::Property property : SINGLE_APPLICATION_SETTINGS) { SettingsPropertiesInfo info(property); m_applicationDefaultSettings.insert(info.name(), info.defaultValue()); } } SettingsManagerPrivate::~SettingsManagerPrivate() { } void SettingsManagerPrivate::init() { m_watcher = new QFileSystemWatcher(this); connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &SettingsManagerPrivate::checkAndLoad); connect(&m_applicationInfo, &UkuiSearch::ApplicationInfo::appDBItems2BDelete, this, &SettingsManagerPrivate::desktopFileDelete); checkAndLoad(); } void SettingsManagerPrivate::checkAndLoad() { QLockFile lockFile(SETTINGS_FILE_PATH + QStringLiteral("ukui-notification-settings.json.lock")); lockFile.lock(); QFile settingsFile(SETTINGS_FILE_PATH_NAME); if (!settingsFile.exists()) { qDebug() << SETTINGS_FILE_PATH_NAME << " is not exist, start create settings file."; createSettingsFile(); lockFile.unlock(); return; } if (!settingsFile.open(QFile::ReadOnly)) { qWarning() << "SettingsManagerPrivate: configuration file " << settingsFile.fileName() << "open failed !"; m_watcher->addPath(SETTINGS_FILE_PATH_NAME); lockFile.unlock(); return; } // 读取json数据 QByteArray byteArray = settingsFile.readAll(); settingsFile.close(); QJsonParseError errRpt; QJsonDocument jsonDocument(QJsonDocument::fromJson(byteArray, &errRpt)); if (errRpt.error != QJsonParseError::NoError) { qWarning() << "SettingsManagerPrivate: Incorrect configuration files. JSON parse error"; createSettingsFile(); lockFile.unlock(); return; } // 读取配置文件 QJsonObject settingsData = jsonDocument.object(); QString version = settingsData.value("VERSION").toString(); updateSettingsFile(version, QStringLiteral(NOTIFICATION_SETTINGS_VERSION), settingsData); lockFile.unlock(); } void SettingsManagerPrivate::createSettingsFile() { initSettingsData(m_settingsData); save2SettingsFile(m_settingsData); Q_EMIT settingsUpdateFinished(); m_watcher->addPath(SETTINGS_FILE_PATH_NAME); } void SettingsManagerPrivate::updateSettingsFile(const QString& oldVersion, const QString& newVersion, QJsonObject& data) { if (oldVersion.toDouble() > newVersion.toDouble()) { qCritical() << "Notification configuration version has been updated to "<< oldVersion << ", current version is " << newVersion <<", please restart the application"; return; } bool needUpdateFileVersion = false; if (oldVersion == "2.0" && newVersion.toDouble() > 2.0) { needUpdateFileVersion = true; } //版本号不变, 或者版本号2.0升级到高版本,只获取配置,其他不做处理 if (oldVersion == newVersion || needUpdateFileVersion) { if(m_needCheckApplist) { checkApplicationList(data); m_needCheckApplist = false; } m_settingsData.swap(data); if (needUpdateFileVersion) { m_settingsData.insert("VERSION", newVersion); save2SettingsFile(m_settingsData); } Q_EMIT settingsUpdateFinished(); m_watcher->addPath(SETTINGS_FILE_PATH_NAME); return; } //版本号1.0升级到高版本,配置清空 if (oldVersion == "1.0" && newVersion.toDouble() > 1.0) { m_watcher->removePath(SETTINGS_FILE_PATH_NAME); QJsonObject newData; //初始化当前版本默认值 initSettingsData(newData); //写入数据 m_settingsData.swap(newData); save2SettingsFile(m_settingsData); m_watcher->addPath(SETTINGS_FILE_PATH_NAME); Q_EMIT settingsUpdateFinished(); qDebug() << "Notification settings version is different, need update! configFile:" << oldVersion << " new:" << newVersion; } } QStringList SettingsManagerPrivate::getAppInfo() { QStringList result; for (const QString& desktopPath : m_applicationInfo.getInfo(UkuiSearch::ApplicationProperties{}).keys()) { if (!result.contains(desktopPath)) { result << UkuiNotification::Utils::desktopEntry2Name(desktopPath); } } return result; } void SettingsManagerPrivate::initSettingsData(QJsonObject &data) { data.insert("VERSION", QString(NOTIFICATION_SETTINGS_VERSION)); //全局设置 QJsonObject globalSettings; for(SettingsProperty::Property property : GLOBAL_SETTINGS) { SettingsPropertiesInfo info(property); globalSettings.insert(info.name(), info.defaultValue()); } data.insert(QStringLiteral("Global"), globalSettings); } void SettingsManagerPrivate::desktopFileDelete(const QStringList &data) { if (data.isEmpty()) { return; } if (qApp->property("IS_UKUI_NOTIFICATION_SERVER").toBool()) { QJsonObject applicationsSettings = m_settingsData.value(QStringLiteral("Applications")).toObject(); for (const QString &app : data) { applicationsSettings.remove(UkuiNotification::Utils::desktopEntry2Name(app)); } m_settingsData.insert(QStringLiteral("Applications"), applicationsSettings); QLockFile lockFile(SETTINGS_FILE_PATH + QStringLiteral("ukui-notification-settings.json.lock")); lockFile.lock(); m_watcher->removePath(SETTINGS_FILE_PATH_NAME); save2SettingsFile(m_settingsData); m_watcher->addPath(SETTINGS_FILE_PATH_NAME); lockFile.unlock(); Q_EMIT settingsUpdateFinished(); } for(const QString &app : data) { Q_EMIT appUninstalled(UkuiNotification::Utils::desktopEntry2Name(app)); } } void SettingsManagerPrivate::save2SettingsFile(const QJsonObject &jsonDocData) { QDir dir; QString configFileDir(SETTINGS_FILE_PATH); if (!dir.exists(configFileDir)) { if (!dir.mkdir(configFileDir)) { qWarning() << "Unable to create notification settings config file."; return; } } QFile settingsFile(SETTINGS_FILE_PATH_NAME); settingsFile.open(QIODevice::WriteOnly | QIODevice::Truncate); if (settingsFile.write(QJsonDocument(jsonDocData).toJson()) == -1) { qWarning() << "SettingsManagerPrivate: Error saving configuration file."; } settingsFile.flush(); settingsFile.close(); } void SettingsManagerPrivate::checkApplicationList(QJsonObject &data) { QStringList appList = getAppInfo(); QStringList appNeedRemoved; QJsonObject applicationSettings = data.value(QStringLiteral("Applications")).toObject(); for(const QString &desktopFile : applicationSettings.keys()) { if(!appList.contains(desktopFile)) { appNeedRemoved.append(desktopFile); } } //移除应用列表里已经不存在的应用 for(const QString &desktopFile : appNeedRemoved) { applicationSettings.remove(desktopFile); } data.insert(QStringLiteral("Applications"), applicationSettings); save2SettingsFile(data); } QJsonObject SettingsManagerPrivate::loadAllowListData() { QFile file(SETTINGS_ALLOW_LIST_NAME); if (!file.exists()) { qWarning() << "SettingsManagerPrivate::loadAllowListData" << file.fileName() << "is not exists"; return QJsonObject(); } if (!file.open(QFile::ReadOnly)) { qWarning() << "SettingsManagerPrivate: configuration file " << file.fileName() << "open failed !"; return QJsonObject(); } // 读取json数据 QByteArray byteArray = file.readAll(); file.close(); QJsonParseError errRpt; QJsonDocument jsonDocument(QJsonDocument::fromJson(byteArray, &errRpt)); if (errRpt.error != QJsonParseError::NoError) { qWarning() << "SettingsManagerPrivate: Incorrect configuration files " << file.fileName() << "JSON parse error"; return QJsonObject(); } return jsonDocument.object(); } SettingsManager::SettingsManager(QObject *parent) : QObject(parent), d(new SettingsManagerPrivate(this)) { connect(d, &SettingsManagerPrivate::settingsUpdateFinished, this, &SettingsManager::settingsDataChanged); connect(d, &SettingsManagerPrivate::appUninstalled, this, &SettingsManager::appUninstalled); d->init(); } QJsonObject SettingsManager::getGlobalSettings() { return d->m_settingsData.value(QStringLiteral("Global")).toObject(); } QJsonObject SettingsManager::getAllAppSettings() { return d->m_settingsData.value(QStringLiteral("Applications")).toObject(); } QJsonObject SettingsManager::getAppSettings(const QString &appDesktopName) { if(appDesktopName == QStringLiteral("default") || appDesktopName.isEmpty()) { return d->m_applicationDefaultSettings; } QJsonValue value = d->m_settingsData.value(QStringLiteral("Applications")).toObject().value(appDesktopName); if(value.isUndefined()) { return {}; } return value.toObject(); } QJsonObject SettingsManager::getAppDefaultSettings() { return d->m_applicationDefaultSettings; } void SettingsManager::getAppList(QStringList &defaultAppList, QStringList &otherAppList) { auto checkDefaultApp = [](const QJsonObject& appData) -> bool{ if (appData.value("ConfigurationSource").toString() == QStringLiteral("Default")) { return true; } return false; }; QJsonObject applicationsData = d->m_settingsData.value(QStringLiteral("Applications")).toObject(); for(const QString &appName : applicationsData.keys()) { QJsonObject appData = applicationsData.value(appName).toObject(); if (checkDefaultApp(appData)) { defaultAppList << appName; } else { otherAppList << appName; } } } SettingsManager *SettingsManager::self() { std::call_once(flag, [ & ] { s_self = new SettingsManager(); }); return s_self; } bool SettingsManager::setGlobalSettings(SettingsProperty::Property key, const QVariant &value) { if(!GLOBAL_SETTINGS.contains(key)) { return false; } auto info = SettingsPropertiesInfo(key); QString valueToSet = info.valueToString(value); QJsonObject data = d->m_settingsData.value(QStringLiteral("Global")).toObject(); data.insert(info.name(), valueToSet); d->m_settingsData.insert(QStringLiteral("Global"), data); QLockFile lockFile(SETTINGS_FILE_PATH + QStringLiteral("ukui-notification-settings.json.lock")); lockFile.lock(); d->save2SettingsFile(d->m_settingsData); lockFile.unlock(); return true; } bool SettingsManager::setAppSettings(const QString &appDesktopName, SettingsProperty::Property key, const QVariant &value) { if(!SINGLE_APPLICATION_SETTINGS.contains(key)) { return false; } QJsonObject appsData = d->m_settingsData.value(QStringLiteral("Applications")).toObject(); QJsonValue dataValue = appsData.value(appDesktopName); if(dataValue.isUndefined()) { return false; } QJsonObject oneAppData = dataValue.toObject(); auto info = SettingsPropertiesInfo(key); QString valueToSet = info.valueToString(value); if(oneAppData.value(info.name()).toString() == valueToSet) { return false; } oneAppData.insert(info.name(), valueToSet); appsData.insert(appDesktopName, oneAppData); d->m_settingsData.insert(QStringLiteral("Applications"), appsData); QLockFile lockFile(SETTINGS_FILE_PATH + QStringLiteral("ukui-notification-settings.json.lock")); lockFile.lock(); d->save2SettingsFile(d->m_settingsData); lockFile.unlock(); return true; } bool SettingsManager::addAppSettings(const QString &appDesktopName, const QString &configurationSource) { if (appDesktopName.isEmpty()) { qWarning() << "SettingsManager::addAppSettings:" << "app desktop name is empty."; return false; } QJsonObject appsData = d->m_settingsData.value(QStringLiteral("Applications")).toObject(); //标记配置来源 d->m_applicationDefaultSettings.insert(QStringLiteral("ConfigurationSource"), configurationSource); appsData.insert(appDesktopName, d->m_applicationDefaultSettings); d->m_settingsData.insert(QStringLiteral("Applications"), appsData); QLockFile lockFile(SETTINGS_FILE_PATH + QStringLiteral("ukui-notification-settings.json.lock")); lockFile.lock(); d->m_watcher->removePath(SETTINGS_FILE_PATH_NAME); d->save2SettingsFile(d->m_settingsData); d->m_watcher->addPath(SETTINGS_FILE_PATH_NAME); lockFile.unlock(); return true; } bool SettingsManager::deleteAppSettings(const QString &appDesktopName) { if (appDesktopName.isEmpty()) { qWarning() << "SettingsManager::deleteAppSettings:" << "app desktop name is empty."; return false; } QJsonObject appsData = d->m_settingsData.value(QStringLiteral("Applications")).toObject(); if (!appsData.contains(appDesktopName)) { qWarning() << "SettingsManager::deleteAppSettings:" << "Applications settings not containns "<< appDesktopName; return false; } appsData.remove(appDesktopName); d->m_settingsData.insert(QStringLiteral("Applications"), appsData); QLockFile lockFile(SETTINGS_FILE_PATH + QStringLiteral("ukui-notification-settings.json.lock")); lockFile.lock(); d->m_watcher->removePath(SETTINGS_FILE_PATH_NAME); d->save2SettingsFile(d->m_settingsData); d->m_watcher->addPath(SETTINGS_FILE_PATH_NAME); lockFile.unlock(); return true; } bool SettingsManager::hasAppSettings(const QString &appDesktopName) { if (appDesktopName.isEmpty()) { qWarning() << "SettingsManager::hasAppSettings" << "app desktop name is empty."; return false; } return !d->m_settingsData.value(QStringLiteral("Applications")).toObject().value(appDesktopName).isUndefined(); } bool SettingsManager::isInAllowList(const QString &appDesktopName) { if (appDesktopName.isEmpty()) { qWarning() << "SettingsManager::isInAllowList:" <<"app desktop name is empty."; return false; } return d->m_allowListData.value(QStringLiteral("Applications")).toObject().keys().contains(appDesktopName); } ukui-notification/libukui-notification/notification-settings/notification-global-settings.cpp0000664000175000017500000003605515160523746032125 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "notification-global-settings.h" #include #include #include #include #include #include #include #include #include "settings-manager.h" #include "settings-properties.h" #include "settings-properties-info.h" namespace UkuiNotification{ class NotificationGlobalSettingsPrivate { friend class NotificationGlobalSettings; public: ~NotificationGlobalSettingsPrivate() { if (m_usdInterface) { delete m_usdInterface; m_usdInterface = nullptr; } if(m_timeChecktimer) { delete m_timeChecktimer; m_timeChecktimer = nullptr; } } private: QJsonObject m_settings; QDBusInterface *m_usdInterface = nullptr; int m_currentScreenMode = 0; //0-仅主屏;1-镜像;2-扩展;3-仅副屏 QTimer *m_timeChecktimer = nullptr; bool m_isDnD = false; }; } using namespace UkuiNotification;// UkuiNotification /*! \class UkuiNotification::NotificationGlobalSettings \inmodule UkuiNotification \inheaderfile notification-settings/notification-global-settings.h \brief 提供通知系统的全局配置管理功能. 该类负责管理通知系统的全局设置,包括勿扰模式(DND)的配置、时间设置以及屏幕状态相关的设置。 主要功能包括: \list \li 勿扰模式的开启/关闭状态管理 \li 勿扰模式计划开启/关闭时间设置 \li 多屏幕和全屏状态下的勿扰模式设置 \li 通知接收和闹钟在勿扰模式下警报设置 \endlist */ /*! Constructor */ NotificationGlobalSettings::NotificationGlobalSettings(QObject *parent) : QObject(parent), d(new NotificationGlobalSettingsPrivate()) { qmlRegisterUncreatableType("org.ukui.notification.client", 1, 0, "NotificationGlobalSettings", ""); connect(SettingsManager::self(), &SettingsManager::settingsDataChanged, this, &NotificationGlobalSettings::settingsDataChanged); d->m_settings = SettingsManager::self()->getGlobalSettings(); d->m_usdInterface = new QDBusInterface("org.ukui.SettingsDaemon", "/org/ukui/SettingsDaemon/xrandr", "org.ukui.SettingsDaemon.xrandr"); if(!d->m_usdInterface->isValid()) { qWarning() << "NotificationGlobalSettings: Fail to creat org.ukui.SettingsDaemon dbus interface!"; return; } QDBusReply reply = d->m_usdInterface->call("getScreenMode", "ukui-notification-server"); if (reply.isValid()) { d->m_currentScreenMode = reply.value(); } else { qWarning()<<"NotificationGlobalSettings: Call getScreenMode failed!"; } connect(d->m_usdInterface, SIGNAL(screenModeChanged(int)), this, SLOT(screenModeChanged(int))); d->m_timeChecktimer = new QTimer; d->m_timeChecktimer->setSingleShot(true); //设置为精密定时器 d->m_timeChecktimer->setTimerType(Qt::PreciseTimer); connect(d->m_timeChecktimer, &QTimer::timeout, this, &NotificationGlobalSettings::checkTimeForDND); d->m_isDnD = isDND(); checkTimeForDND(); } /*! Destructor */ NotificationGlobalSettings::~NotificationGlobalSettings() { if(d) { delete d; d = nullptr; } } /*! \property NotificationGlobalSettings::scheduleTurnOnDND 此属性管理勿扰模式计划开关,开启之后会根据计划时间开启/关闭勿扰模式. \sa scheduleTurnOnDNDTime, scheduleTurnOffDNDTime */ bool NotificationGlobalSettings::scheduleTurnOnDND() { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::ScheduleTurnOnDND).name()).toVariant().toBool(); } /*! \property NotificationGlobalSettings::scheduleTurnOnDNDTime 此属性为勿扰模式计划开启时间 \sa scheduleTurnOffDNDTime */ QTime NotificationGlobalSettings::scheduleTurnOnDNDTime() { SettingsPropertiesInfo dndOnTimeInfo(SettingsProperty::ScheduleTurnOnDNDTime); QString dndOnTimeStr = d->m_settings.value(dndOnTimeInfo.name()).toString(); // 字符串为空 if (dndOnTimeStr.isEmpty()) { qWarning() << "ScheduleTurnOnDNDTime is empty, using default value:" << dndOnTimeInfo.defaultValue(); return QTime::fromString(dndOnTimeInfo.defaultValue(), "HHmm"); } static const QStringList timeFormats = {"HHmm", "HH:mm"}; //解析时间字符串 for (const auto &format : timeFormats) { QTime dndOnTime = QTime::fromString(dndOnTimeStr, format); if (dndOnTime.isValid()) { return dndOnTime; } } qWarning() << "Invalid ScheduleTurnOnDNDTime format:" << dndOnTimeStr << ", using default value:" << dndOnTimeInfo.defaultValue(); return QTime::fromString(dndOnTimeInfo.defaultValue(), "HHmm"); } /*! \property NotificationGlobalSettings::scheduleTurnOffDNDTime 此属性为勿扰模式计划关闭时间 \sa scheduleTurnOnDNDTime */ QTime NotificationGlobalSettings::scheduleTurnOffDNDTime() { SettingsPropertiesInfo dndOffTimeInfo(SettingsProperty::ScheduleTurnOffDNDTime); QString dndOffTimeStr = d->m_settings.value(dndOffTimeInfo.name()).toString(); if (dndOffTimeStr.isEmpty()) { qWarning() << "ScheduleTurnOffDNDTime is empty, using default value:" << dndOffTimeInfo.defaultValue(); return QTime::fromString(dndOffTimeInfo.defaultValue(), "HHmm"); } static const QStringList timeFormats = {"HHmm", "HH:mm"}; for (const auto &format : timeFormats) { QTime dndOffTime = QTime::fromString(dndOffTimeStr, format); if (dndOffTime.isValid()) { return dndOffTime; } } qWarning() << "Invalid ScheduleTurnOffDNDTime format:" << dndOffTimeStr << ", using default value:" << dndOffTimeInfo.defaultValue(); return QTime::fromString(dndOffTimeInfo.defaultValue(), "HHmm"); } /*! \property NotificationGlobalSettings::DNDWhileMultiScreen 此属性表示多屏幕下是否进入勿扰模式开关 \sa DNDWhileFullScreen */ bool NotificationGlobalSettings::DNDWhileMultiScreen() { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::DNDWhileMultiScreen).name()).toVariant().toBool(); } /*! \property NotificationGlobalSettings::DNDWhileFullScreen 此属性表示全屏下是否进入勿扰模式开关 \sa DNDWhileMultiScreen */ bool NotificationGlobalSettings::DNDWhileFullScreen() { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::DNDWhileFullScreen).name()).toVariant().toBool(); } /*! \property NotificationGlobalSettings::notifyAlarmWhileDND 此属性表示勿扰模式下是否允许闹钟提示 */ bool NotificationGlobalSettings::notifyAlarmWhileDND() { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::NotifyAlarmWhileDND).name()).toVariant().toBool(); } /*! \property NotificationGlobalSettings::receiveNotificationsFromApps 此属性表示是否允许来自应用的通知 */ bool NotificationGlobalSettings::receiveNotificationsFromApps() { return d->m_settings.value(SettingsPropertiesInfo(SettingsProperty::ReceiveNotificationsFromApps).name()).toVariant().toBool(); } void NotificationGlobalSettings::settingsDataChanged() { QJsonObject data = SettingsManager::self()->getGlobalSettings(); for(SettingsProperty::Property property : GLOBAL_SETTINGS) { QString name = SettingsPropertiesInfo(property).name(); QJsonValue value = data.value(name); if(d->m_settings.value(name) != value) { d->m_settings.insert(name, value); switch (property) { case SettingsProperty::ScheduleTurnOnDND: Q_EMIT scheduleTurnOnDNDChanged(value.toVariant().toBool()); checkTimeForDND(); break; case SettingsProperty::ScheduleTurnOnDNDTime: Q_EMIT scheduleTurnOnDNDTimeChanged(QTime::fromString(value.toString(), "HHmm")); checkTimeForDND(); break; case SettingsProperty::ScheduleTurnOffDNDTime: Q_EMIT scheduleTurnOffDNDTimeChanged(QTime::fromString(value.toString(), "HHmm")); checkTimeForDND(); break; case SettingsProperty::DNDWhileMultiScreen: Q_EMIT DNDWhileMultiScreenChanged(value.toVariant().toBool()); checkDNDMode(); break; case SettingsProperty::DNDWhileFullScreen: Q_EMIT DNDWhileFullScreenChanged(value.toVariant().toBool()); checkDNDMode(); break; case SettingsProperty::NotifyAlarmWhileDND: Q_EMIT notifyAlarmWhileDNDChanged(value.toVariant().toBool()); break; case SettingsProperty::ReceiveNotificationsFromApps: Q_EMIT receiveNotificationsFromAppsChanged(value.toVariant().toBool()); break; default: break; } } } } void NotificationGlobalSettings::setScheduleTurnOnDND(bool enable) { SettingsManager::self()->setGlobalSettings(SettingsProperty::ScheduleTurnOnDND, enable); } void NotificationGlobalSettings::setScheduleTurnOnDNDTime(const QTime &time) { SettingsManager::self()->setGlobalSettings(SettingsProperty::ScheduleTurnOnDNDTime, time); } void NotificationGlobalSettings::setScheduleTurnOffDNDTime(const QTime &time) { SettingsManager::self()->setGlobalSettings(SettingsProperty::ScheduleTurnOffDNDTime, time); } void NotificationGlobalSettings::setDNDWhileMultiScreen(bool enable) { SettingsManager::self()->setGlobalSettings(SettingsProperty::DNDWhileMultiScreen, enable); } void NotificationGlobalSettings::setDNDWhileFullScreen(bool enable) { SettingsManager::self()->setGlobalSettings(SettingsProperty::DNDWhileFullScreen, enable); } void NotificationGlobalSettings::setNotifyAlarmWhileDND(bool enable) { SettingsManager::self()->setGlobalSettings(SettingsProperty::NotifyAlarmWhileDND, enable); } void NotificationGlobalSettings::setReceiveNotificationsFromApps(bool enable) { SettingsManager::self()->setGlobalSettings(SettingsProperty::ReceiveNotificationsFromApps, enable); } /*! \readonly \property NotificationGlobalSettings::DND 此属性表示当前是否为勿扰模式 */ bool NotificationGlobalSettings::isDND() { bool dnd = false; if(scheduleTurnOnDND()) { const QTime currentTime = QTime::currentTime(); const QTime dndOnTime = scheduleTurnOnDNDTime(); const QTime dndOffTime = scheduleTurnOffDNDTime(); if (dndOnTime > dndOffTime) { dnd = (currentTime >= dndOnTime) || (currentTime < dndOffTime); } else { dnd = (currentTime >= dndOnTime) && (currentTime < dndOffTime); } } if(!dnd) { if(DNDWhileMultiScreen()) { if(d->m_currentScreenMode == 1 || d->m_currentScreenMode == 2) { dnd = true; } } } if(!dnd) { if(DNDWhileFullScreen()) { QDBusReply registeredReply = QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("com.kylin.Wlcom")); if (registeredReply.isValid() && registeredReply.value()) { QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("com.kylin.Wlcom"), QStringLiteral("/com/kylin/Wlcom/View"), QStringLiteral("com.kylin.Wlcom.View"), QStringLiteral("HaveFullScreenActiveWindow")); QDBusReply reply = QDBusConnection::sessionBus().call(msg); if(reply.isValid()) { dnd = reply.value(); } } else { QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("haveFullScreenActiveWindow")); QDBusReply reply = QDBusConnection::sessionBus().call(msg); if(reply.isValid()) { dnd = reply.value(); } } } } return dnd; } void NotificationGlobalSettings::screenModeChanged(int mode) { qDebug() << "NotificationGlobalSettings::screenModeChanged : " << mode; d->m_currentScreenMode = mode; checkDNDMode(); } void NotificationGlobalSettings::checkDNDMode() { bool dnd = isDND(); if (d->m_isDnD != dnd) { qDebug() << "NotificationGlobalSettings::checkDNDMode DND is changed: " << dnd; d->m_isDnD = dnd; Q_EMIT dndChanged(dnd); } } void NotificationGlobalSettings::checkTimeForDND() { checkDNDMode(); if (!scheduleTurnOnDND()) { // 勿扰模式开关关闭,关闭定时器 if (d->m_timeChecktimer->isActive()) { d->m_timeChecktimer->stop(); } return; } QTime currentTime = QTime::currentTime(); QTime dndOnTime = scheduleTurnOnDNDTime(); QTime dndOffTime = scheduleTurnOffDNDTime(); int msec = 60000; // 1分钟 if (dndOnTime == dndOffTime) {// 开启关闭时间一致,启动定时器无意义 if (d->m_timeChecktimer->isActive()) { d->m_timeChecktimer->stop(); } return; } else if (dndOnTime > dndOffTime) { if (currentTime >= dndOffTime && currentTime < dndOnTime) { msec = currentTime.msecsTo(dndOnTime); } else { msec = currentTime.msecsTo(dndOffTime); } } else { if (currentTime >= dndOnTime && currentTime < dndOffTime) { msec = currentTime.msecsTo(dndOffTime); } else { msec = currentTime.msecsTo(dndOnTime); } } //跨天处理 static constexpr int MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000; if (msec < 0) { msec += MILLISECONDS_PER_DAY; } if (d->m_timeChecktimer->isActive()) { d->m_timeChecktimer->stop(); } d->m_timeChecktimer->start(msec); }ukui-notification/libukui-notification/notification-settings/single-application-settings.h0000664000175000017500000000614315160523746031423 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_SINGLE_APPLICATION_SETTINGS_H #define UKUI_NOTIFICATION_SINGLE_APPLICATION_SETTINGS_H #include #include "settings-properties.h" #include namespace UkuiNotification { class SingleApplicationSettingsPrivate; /** * @short 表示单个应用的设置通知设置. * @author iaom */ class SingleApplicationSettings : public QObject { Q_OBJECT Q_PROPERTY(bool allowNotify READ allowNotify WRITE setAllowNotify NOTIFY allowNotifyChanged) Q_PROPERTY(bool allowSound READ allowSound WRITE setAllowSound NOTIFY allowSoundChanged) Q_PROPERTY(bool showContentOnLockScreen READ showContentOnLockScreen WRITE setShowContentOnLockScreen NOTIFY showContentOnLockScreenChanged) Q_PROPERTY(bool showNotificationOnLockScreen READ showNotificationOnLockScreen WRITE setShowNotificationOnLockScreen NOTIFY showNotificationOnLockScreenChanged) // Q_PROPERTY(SettingsProperty::Property PopupStyle READ popupStyle WRITE setPopupStyle NOTIFY popupStyleChanged) public: explicit SingleApplicationSettings(const QString &desktopEntry = QString(), QObject *parent = nullptr); SingleApplicationSettings(const SingleApplicationSettings &other); SingleApplicationSettings &operator=(const SingleApplicationSettings &other); SingleApplicationSettings &operator=(SingleApplicationSettings &&other) Q_DECL_NOEXCEPT; ~SingleApplicationSettings(); bool allowNotify() const; void setAllowNotify(bool enable); bool allowSound() const ; void setAllowSound(bool enable); bool showContentOnLockScreen() const ; void setShowContentOnLockScreen(bool enable); bool showNotificationOnLockScreen() const; void setShowNotificationOnLockScreen(bool enable); // SettingsProperty::Property popupStyle() const; // void setPopupStyle(SettingsProperty::Property style); QString desktopEntry() const; Q_SIGNALS: void allowNotifyChanged(bool); void allowSoundChanged(bool); void showContentOnLockScreenChanged(bool); void showNotificationOnLockScreenChanged(bool); void popupStyleChanged(SettingsProperty::Property); void uninstalled(); private Q_SLOTS: void init(); void settingsDataChanged(const QString& desktopEntry); void appUninstalled(const QString &desktopEntry); private: SingleApplicationSettingsPrivate *d = nullptr; }; } #endif //UKUI_NOTIFICATION_SINGLE_APPLICATION_SETTINGS_H ukui-notification/libukui-notification/notification-settings/applications-settings.h0000664000175000017500000000536015160523734030324 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_APPLICATIONS_SETTINGS_H #define UKUI_NOTIFICATION_APPLICATIONS_SETTINGS_H #include #include #include "single-application-settings.h" #include "popup-notification.h" namespace UkuiNotification{ typedef QMap ApplicationsSettingsMap; class ApplicationsSettingsPrivate; /** * @short 用于获取应用的设置. * @author iaom */ class ApplicationsSettings : public QObject { Q_OBJECT public: static ApplicationsSettings *self(); ~ApplicationsSettings(); /** * 获取某条通知的配置 * @param notification 表示一条通知 * @return 返回的指针不需要使用者回收 */ SingleApplicationSettings *creatSettings(const PopupNotification ¬ification); SingleApplicationSettings *creatSettings(QString desktopEntry); ApplicationsSettingsMap &getAllApplicationsSettings(); /** * @brief getAppSettings * 获取当前用户某个应用通知相关配置信息。 * @param appDesktopName 传"default"获取配置默认值 */ QJsonObject getAppSettings(const QString &appDesktopName); bool setAppSetting(const QString &appDesktopName, SettingsProperty::Property key, const QVariant &value); bool hasAppSettings(const QString &appDesktopName); bool hasAppSettings(const PopupNotification ¬ification); /** * @brief 是否在白名单内 * @param * @return */ bool isInAllowList(const QString &appDesktopName); bool isInAllowList(const PopupNotification ¬ification); Q_SIGNALS: void applicationUninstalled(const QString &desktopEntry); void settingsUpdated(const QString& desktopEntry); void applicationInstalled(const QString &desktopEntry); private Q_SLOTS: private: ApplicationsSettings(QObject *parent = nullptr); void settingsDataChanged(); void onApplicationUninstalled(const QString &desktopEntry); ApplicationsSettingsPrivate *d = nullptr; }; } #endif //UKUI_NOTIFICATION_APPLICATIONS_SETTINGS_H ukui-notification/libukui-notification/notification-settings/settings-properties-info.h0000664000175000017500000000460715160523734030766 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef SETTINGS_PROPERTIES_INFO_H #define SETTINGS_PROPERTIES_INFO_H #include #include #include #include "settings-properties.h" #include namespace UkuiNotification { class SettingsPropertiesInfoPrivate; /** * \class SettingsPropertiesInfo SettingsPropertiesInfo.h */ class Q_DECL_IMPORT SettingsPropertiesInfo : public QObject { Q_OBJECT public: SettingsPropertiesInfo(); SettingsPropertiesInfo(SettingsProperty::Property property); SettingsPropertiesInfo(const SettingsPropertiesInfo& pi); ~SettingsPropertiesInfo(); SettingsPropertiesInfo& operator=(const SettingsPropertiesInfo& rhs); bool operator==(const SettingsPropertiesInfo& rhs) const; /** * The enumeration which represents this property */ SettingsProperty::Property property() const; /** * The internal unique name used to refer to the property */ QString name() const; /** * A user visible name of the property */ QString displayName() const; /** * The type the value of this property should be. * Eg - Property::Height should be an integer */ QMetaType::Type valueType() const; QString defaultValue() const; QString valueToString(const QVariant &value) const; /** * Construct a SettingsPropertiesInfo from the internal property name. * The internal property name is case insensitive */ static SettingsPropertiesInfo fromName(const QString& name); private: const std::unique_ptr d; }; } // namespace Q_DECLARE_METATYPE(UkuiNotification::SettingsPropertiesInfo) #endif // SETTINGS_PROPERTIES_INFO_H ukui-notification/libukui-notification/notification-settings/settings-properties.h0000664000175000017500000000777415160523734030045 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef SETTINGS_PROPERTIES #define SETTINGS_PROPERTIES #include #include namespace UkuiNotification { namespace SettingsProperty { Q_NAMESPACE /** * @brief The Property enum contains all settings property types * */ enum Property { Invalid = 0, //Global settings about DND mode ScheduleTurnOnDND, //是否在时间段内自动开启勿扰模式,bool类型,默认值false ScheduleTurnOnDNDTime, //勿扰模式开启时间,QDateTime类型,默认值00:00 ScheduleTurnOffDNDTime, //勿扰模式结束时间,QDateTime类型,默认值00:00 DNDWhileMultiScreen, //多屏启动时是否启动勿扰模式,bool类型,默认值false DNDWhileFullScreen, //全屏状态下是否启动勿扰模式,bool类型,默认值false NotifyAlarmWhileDND, //勿扰模式下是否允许闹钟提示,bool类型,默认值false //Show notifications from applications ReceiveNotificationsFromApps, //是否获取来自应用程序的通知,bool类型,默认值true //single app notification settings AllowNotify = ReceiveNotificationsFromApps + 1, //是否接收当前应用通知,bool类型,默认值true AllowSound, //是否打开通知提示声,bool类型,默认值true ShowContentOnLockScreen, //锁屏界面是否显示通知内容信息,bool类型,默认值false ShowNotificationOnLockScreen, //锁屏界面是否显示通知,bool类型,默认值false // PopupStyle, //通知样式,appNotificationStyle类型,默认值Mutative // // //single app notification settings中的 popupStyle 类型取值范围 // TransientPopup = PopupStyle +1, //横幅模式,显示在右上角,会自动消失 // ResidentPopup, //提示模式,会保留在屏幕上,直到被关闭 // NoPopup //无,通知不会显示在屏幕上,但是会进入通知中心 ConfigurationSource = 100 //用于标记配置来源 }; typedef QMap PropertyMap; } static const QList GLOBAL_SETTINGS { SettingsProperty::ScheduleTurnOnDND, SettingsProperty::ScheduleTurnOnDNDTime, SettingsProperty::ScheduleTurnOffDNDTime, SettingsProperty::DNDWhileMultiScreen, SettingsProperty::DNDWhileFullScreen, SettingsProperty::NotifyAlarmWhileDND, SettingsProperty::ReceiveNotificationsFromApps }; static const QList SINGLE_APPLICATION_SETTINGS { SettingsProperty::AllowNotify, SettingsProperty::AllowSound, SettingsProperty::ShowContentOnLockScreen, SettingsProperty::ShowNotificationOnLockScreen, // SettingsProperty::PopupStyle, SettingsProperty::Property::ConfigurationSource }; } // namespace UkuiNotification Q_DECLARE_METATYPE(UkuiNotification::SettingsProperty::Property) static void registerSettingsPropertyMetaTypeOnce() { static bool registered = []() { qRegisterMetaType("UkuiNotification::SettingsProperty::Property"); return true; }(); } #endif ukui-notification/libukui-notification/notification-settings/settings-manager-private.h0000664000175000017500000000561615160523734030724 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef NotificationSettingsPrivate_H #define NotificationSettingsPrivate_H #include "settings-manager.h" #include #include #include #include #include "settings-properties.h" namespace UkuiNotification { /** * @brief NOTIFICATION_SETTINGS_VERSION * 通知配置文件版本号,用于判断是否需要更新配置文件。 * 1.0 -> 2.0 -> 2.1 * 1.0版本:存储所有应用通知配置 * 2.0版本: 清空旧版本版本配置,按需增加应用通知配置 * 2.1版本: 增加通知配置来源属性 */ #define NOTIFICATION_SETTINGS_VERSION "2.1" class SettingsManagerPrivate : public QObject { friend class SettingsManager; Q_OBJECT public: explicit SettingsManagerPrivate(QObject* parent = nullptr); ~SettingsManagerPrivate(); void init(); private Q_SLOTS: /** * @brief checkAndLoad * 检查通知配置文件,不存在则初始化生成默认配置文件,存在则根据配置文件版本判断是否更新配置文件。 */ void checkAndLoad(); private: /** * @brief createSettingsFile * 初始化创建通知配置文件。 */ void createSettingsFile(); /** * @brief updateSettingsFile * 更新通知配置文件。 */ void updateSettingsFile(const QString& oldVersion, const QString& newVersion, QJsonObject& data); /** * @brief getAppInfo * 从搜索应用数据库服务中获取desktop信息。 */ QStringList getAppInfo(); void initSettingsData(QJsonObject &data); void checkApplicationList(QJsonObject &data); QJsonObject loadAllowListData(); public Q_SLOTS: void desktopFileDelete(const QStringList &data); Q_SIGNALS: void settingsUpdateFinished(); void appUninstalled(const QString &desktopEntry); private: void save2SettingsFile(const QJsonObject &jsonDocData); QJsonObject m_settingsData; QFileSystemWatcher *m_watcher = nullptr; UkuiSearch::ApplicationInfo& m_applicationInfo; QJsonObject m_applicationDefaultSettings; bool m_needCheckApplist = true; const QJsonObject m_allowListData; }; } #endif // NotificationSettingsPrivate_H ukui-notification/libukui-notification/notification-settings/applications-settings.cpp0000664000175000017500000001737015160523746030666 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "applications-settings.h" #include #include #include #include "settings-manager.h" #include #include "utils.h" using namespace UkuiNotification; static std::once_flag flag; static ApplicationsSettings *s_self; namespace UkuiNotification{ class ApplicationsSettingsPrivate { friend class ApplicationsSettings; private: ApplicationsSettingsMap m_cache; QJsonObject m_settingsData; }; } /*! 获取 ApplicationsSettings 全局单例实例. */ ApplicationsSettings *UkuiNotification::ApplicationsSettings::self() { std::call_once(flag, [ & ] { s_self = new ApplicationsSettings(); }); return s_self; } /*! \class UkuiNotification::ApplicationsSettings \inmodule UkuiNotification \inheaderfile notifications-settings/applications-settings.h \brief 提供应用程序通知设置的管理功能. 该类负责管理所有应用程序的通知设置,使用单例模式设计,通过self()方法获取实例. */ /*! \fn void UkuiNotification::ApplicationsSettings::applicationUninstalled(const QString &desktopEntry) 此信号在应用程序被卸载时触发. */ /*! \fn void UkuiNotification::ApplicationsSettings::settingsUpdated(const QString& desktopEntry) 此信号在应用程序通知设置被更新时触发. */ /*! \fn void UkuiNotification::ApplicationsSettings::applicationInstalled(const QString &desktopEntry) 此信号在应用程序安装时触发. */ /*! Constructor */ ApplicationsSettings::ApplicationsSettings(QObject *parent) : QObject(parent), d(new ApplicationsSettingsPrivate) { d->m_settingsData = SettingsManager::self()->getAllAppSettings(); connect(SettingsManager::self(), &SettingsManager::appUninstalled, this, &ApplicationsSettings::onApplicationUninstalled); connect(SettingsManager::self(), &SettingsManager::settingsDataChanged, this, &ApplicationsSettings::settingsDataChanged); qmlRegisterUncreatableType("org.ukui.notification.client", 1, 0, "SingleApplicationSettings", ""); } /*! Destructor */ ApplicationsSettings::~ApplicationsSettings() { if(d) { qDeleteAll(d->m_cache); d->m_cache.clear(); delete d; d = nullptr; } } /*! \brief 获取某条通知的配置。 \sa creatSettings(QString desktopEntry) */ SingleApplicationSettings *ApplicationsSettings::creatSettings(const PopupNotification ¬ification) { return creatSettings(notification.desktopEntry()); } /*! 获取所有应用的通知配置。 */ ApplicationsSettingsMap &ApplicationsSettings::getAllApplicationsSettings() { for(const QString &desktopEntry : d->m_settingsData.keys()) { if(!d->m_cache.contains(desktopEntry)) { d->m_cache.insert(desktopEntry, new SingleApplicationSettings(desktopEntry)); } } return d->m_cache; } /*! 根据 \a appDesktopName 获取当前用户某个应用通知相关配置信息。 传入 "default" 获取配置默认值。 */ QJsonObject ApplicationsSettings::getAppSettings(const QString &appDesktopName) { if(appDesktopName == QStringLiteral("default") || appDesktopName.isEmpty()) { return SettingsManager::self()->getAppDefaultSettings(); } QJsonValue value = d->m_settingsData.value(appDesktopName); if(value.isUndefined()) { return SettingsManager::self()->getAppDefaultSettings();; } return value.toObject(); } /*! 设置应用通知相关配置。 \a appDesktopName 应用 desktop 名称。 \a key 通知的某个属性配置项。 \a value 对应属性配置值。 返回 \c true 表示设置成功,\c false 表示设置失败。 */ bool ApplicationsSettings::setAppSetting(const QString &appDesktopName, SettingsProperty::Property key, const QVariant &value) { return SettingsManager::self()->setAppSettings(appDesktopName, key, value); } /*! 根据 \a appDesktopName, 查询是否存在应用通知相关配置。 */ bool ApplicationsSettings::hasAppSettings(const QString &appDesktopName) { return SettingsManager::self()->hasAppSettings(appDesktopName); } /*! 通过一条通知 \a notification , 查询是否存在应用通知相关配置。 */ bool ApplicationsSettings::hasAppSettings(const PopupNotification ¬ification) { return hasAppSettings(notification.desktopEntry()); } /*! 根据 \a appDesktopName , 查询是否在白名单内。 白名单内的应用相关的通知配置不会暴露给应用设置。 */ bool ApplicationsSettings::isInAllowList(const QString &appDesktopName) { return SettingsManager::self()->isInAllowList(appDesktopName); } /*! \sa isInAllowList(const QString &appDesktopName) */ bool ApplicationsSettings::isInAllowList(const PopupNotification ¬ification) { return SettingsManager::self()->isInAllowList(notification.desktopEntry()); } void ApplicationsSettings::settingsDataChanged() { QJsonObject data = SettingsManager::self()->getAllAppSettings(); if(d->m_settingsData == data) { return; } //更新现有app 配置 for (const QString &desktopEntry : data.keys()) { if (d->m_settingsData.contains(desktopEntry)) { const QJsonValue&& oldValue = d->m_settingsData.value(desktopEntry); const QJsonValue&& newValue = data.value(desktopEntry); if ( oldValue != newValue) { d->m_settingsData.insert(desktopEntry, newValue); Q_EMIT settingsUpdated(desktopEntry); } } } //新增 QStringList needAddList = StringListDiff(data.keys(), d->m_settingsData.keys()); //删除 QStringList needRemoveList = StringListDiff(d->m_settingsData.keys(), data.keys()); for(const QString &desktopEntry : needAddList) { d->m_settingsData.insert(desktopEntry, data.value(desktopEntry)); Q_EMIT applicationInstalled(desktopEntry); } for(const QString &desktopEntry : needRemoveList) { d->m_settingsData.remove(desktopEntry); Q_EMIT applicationUninstalled(desktopEntry); auto* singleSetting = d->m_cache.take(desktopEntry); if (singleSetting) { delete singleSetting; } } } void ApplicationsSettings::onApplicationUninstalled(const QString &desktopEntry) { if (d->m_settingsData.contains(desktopEntry)) { d->m_settingsData.remove(desktopEntry); Q_EMIT applicationUninstalled(desktopEntry); auto* singleSetting = d->m_cache.take(desktopEntry); if (singleSetting) { delete singleSetting; } } } /*! \brief 根据 \a desktopEntry 获取应用的通知配置 */ SingleApplicationSettings *ApplicationsSettings::creatSettings(QString desktopEntry) { if(desktopEntry.isEmpty()) { desktopEntry = QStringLiteral("default"); } if(d->m_cache.contains(desktopEntry)) { return d->m_cache[desktopEntry]; } else { return d->m_cache.insert(desktopEntry, new SingleApplicationSettings(desktopEntry)).value(); } } ukui-notification/libukui-notification/notification-settings/settings-properties-info.cpp0000664000175000017500000002546515160523734031326 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "settings-properties-info.h" #include #include using namespace UkuiNotification; class UkuiNotification::SettingsPropertiesInfoPrivate { public: SettingsProperty::Property m_property; QString m_name; QString m_displayName; QMetaType::Type m_valueType; QString m_defaultValue; QMetaType::Type m_settingsPropertyMetaType; }; /*! \class UkuiNotification::SettingsPropertiesInfo \inmodule UkuiNotification \inheaderfile notification-settings/settings-properties-info.h \brief 封装通知设置属性的元数据信息 该类用于存储单个通知设置属性的完整描述信息,包括属性标识符、内部名称、本地化显示名称、 值类型、默认值等。提供了属性访问、名称到属性的转换、值字符串化等功能,是通知设置系统中 属性元数据管理的核心类。 */ /*! Constructor */ SettingsPropertiesInfo::SettingsPropertiesInfo(): d(new SettingsPropertiesInfoPrivate) { registerSettingsPropertyMetaTypeOnce(); d->m_property = SettingsProperty::Invalid; d->m_name = QStringLiteral("Invalid"); d->m_valueType = QMetaType::UnknownType; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) d->m_settingsPropertyMetaType = static_cast(QMetaType::type("UkuiNotification::SettingsProperty::Property")); #else d->m_settingsPropertyMetaType = static_cast(QMetaType::fromName("UkuiNotification::SettingsProperty::Property").id()); #endif } /*! 通过委托构造调用默认构造函数完成基础初始化,随后根据传入的属性枚举值设置具体的属性元数据, */ SettingsPropertiesInfo::SettingsPropertiesInfo(SettingsProperty::Property property) : SettingsPropertiesInfo() { d->m_property = property; switch (property) { case SettingsProperty::ScheduleTurnOnDND: d->m_name = QStringLiteral("ScheduleTurnOnDND"); d->m_displayName = tr("Schedule turn on"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "false"; break; case SettingsProperty::ScheduleTurnOnDNDTime: d->m_name = QStringLiteral("ScheduleTurnOnDNDTime"); d->m_displayName = tr("Schedule turn on time"); d->m_valueType = QMetaType::QTime; d->m_defaultValue = "0000"; break; case SettingsProperty::ScheduleTurnOffDNDTime: d->m_name = QStringLiteral("ScheduleTurnOffDNDTime"); d->m_displayName = tr("Schedule turn off time"); d->m_valueType = QMetaType::QTime; d->m_defaultValue = "0000"; break; case SettingsProperty::DNDWhileMultiScreen: d->m_name = QStringLiteral("DNDWhileMultiScreen"); d->m_displayName = tr("Turn on while multi-screen connected"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "false"; break; case SettingsProperty::DNDWhileFullScreen: d->m_name = QStringLiteral("DNDWhileFullScreen"); d->m_displayName = tr("Turn on in full screen mode"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "false"; break; case SettingsProperty::NotifyAlarmWhileDND: d->m_name = QStringLiteral("NotifyAlarmWhileDND"); d->m_displayName = tr("Allow alarm to notify in do not disturb mode"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "false"; break; case SettingsProperty::ReceiveNotificationsFromApps: d->m_name = QStringLiteral("ReceiveNotificationsFromApps"); d->m_displayName = tr("Get notifications from applications"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "true"; break; case SettingsProperty::AllowNotify: d->m_name = QStringLiteral("AllowNotify"); d->m_displayName = tr("Allow notify"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "true"; break; case SettingsProperty::AllowSound: d->m_name = QStringLiteral("AllowSound"); d->m_displayName = tr("Allow sound for notifications"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "true"; break; case SettingsProperty::ShowContentOnLockScreen: d->m_name = QStringLiteral("ShowContentOnLockScreen"); d->m_displayName = tr("Show notification content on lock screen"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "false"; break; case SettingsProperty::ShowNotificationOnLockScreen: d->m_name = QStringLiteral("ShowNotificationOnLockScreen"); d->m_displayName = tr("Show notifications on lock screen"); d->m_valueType = QMetaType::Bool; d->m_defaultValue = "false"; break; // case SettingsProperty::PopupStyle: // d->m_name = QStringLiteral("popupStyle"); // d->m_displayName = tr("Style of popup notification"); // d->m_valueType = d->m_settingsPropertyMetaType; // d->m_defaultValue = "TransientPopup"; // break; // // case SettingsProperty::TransientPopup: // d->m_name = QStringLiteral("TransientPopup"); // d->m_displayName = tr("Popup: displayed in the upper right corner of the screen, will automatically disappear"); // d->m_valueType = QMetaType::Int; // break; // // case SettingsProperty::ResidentPopup: // d->m_name = QStringLiteral("ResidentPopup"); // d->m_displayName = tr("Notice: will remain on the screen until it is closed"); // d->m_valueType = QMetaType::Int; // break; // // case SettingsProperty::NoPopup: // d->m_name = QStringLiteral("NoPopup"); // d->m_displayName = tr("None: notifications will not be displayed on the screen, only be put into notification center"); // d->m_valueType = QMetaType::Int; // break; case SettingsProperty::ConfigurationSource: d->m_name = QStringLiteral("ConfigurationSource"); d->m_displayName = tr("Configuration source"); d->m_valueType = QMetaType::QString; d->m_defaultValue = "Default"; break; case SettingsProperty::Invalid: d->m_name = QStringLiteral("Invalid"); d->m_valueType = QMetaType::UnknownType; break; // NOTE: new properties must also be added to ::fromName() } } /*! Copy Constructor. */ SettingsPropertiesInfo::SettingsPropertiesInfo(const SettingsPropertiesInfo& pi) : d(new SettingsPropertiesInfoPrivate(*pi.d)) { } /*! Destructor. */ SettingsPropertiesInfo::~SettingsPropertiesInfo() = default; /*! Copy Assignment Operator. */ SettingsPropertiesInfo& SettingsPropertiesInfo::operator=(const SettingsPropertiesInfo& rhs) { *d = *rhs.d; return *this; } /*! Equality Comparison Operator. */ bool SettingsPropertiesInfo::operator==(const SettingsPropertiesInfo& rhs) const { return d->m_name == rhs.d->m_name && d->m_displayName == rhs.d->m_displayName && d->m_property == rhs.d->m_property && d->m_valueType == rhs.d->m_valueType; } /*! 返回当前属性用于显示显示的名称. */ QString SettingsPropertiesInfo::displayName() const { return d->m_displayName; } /*! 返回当前属性的唯一 name. */ QString SettingsPropertiesInfo::name() const { return d->m_name; } /*! 返回当前属性的枚举类型. \sa SettingsProperty::Property */ SettingsProperty::Property SettingsPropertiesInfo::property() const { return d->m_property; } /*! 返回当前属性的值类型. \sa QMetaType::Type */ QMetaType::Type SettingsPropertiesInfo::valueType() const { return d->m_valueType; } /*! 根据属性 \a name 获取对应的属性数据. */ SettingsPropertiesInfo SettingsPropertiesInfo::fromName(const QString& name) { static QHash propertyHash = { { QStringLiteral("ScheduleTurnOnDND"), SettingsProperty::ScheduleTurnOnDND }, { QStringLiteral("ScheduleTurnOnDNDTime"), SettingsProperty::ScheduleTurnOnDNDTime }, { QStringLiteral("ScheduleTurnOffDNDTime"), SettingsProperty::ScheduleTurnOffDNDTime }, { QStringLiteral("DNDWhileMultiScreen"), SettingsProperty::DNDWhileMultiScreen }, { QStringLiteral("DNDWhileFullScreen"), SettingsProperty::DNDWhileFullScreen }, { QStringLiteral("NotifyAlarmWhileDND"), SettingsProperty::NotifyAlarmWhileDND }, { QStringLiteral("ReceiveNotificationsFromApps"), SettingsProperty::ReceiveNotificationsFromApps }, { QStringLiteral("AllowNotify"), SettingsProperty::AllowNotify }, { QStringLiteral("AllowSound"), SettingsProperty::AllowSound }, { QStringLiteral("ShowContentOnLockScreen"), SettingsProperty::ShowContentOnLockScreen }, { QStringLiteral("ShowNotificationOnLockScreen"), SettingsProperty::ShowNotificationOnLockScreen }, // { QStringLiteral("popupStyle"), SettingsProperty::PopupStyle }, // { QStringLiteral("TransientPopup"), SettingsProperty::TransientPopup }, // { QStringLiteral("ResidentPopup"), SettingsProperty::ResidentPopup }, // { QStringLiteral("NoPopup"), SettingsProperty::NoPopup } { QStringLiteral("ConfigurationSource"), SettingsProperty::ConfigurationSource }, }; return {propertyHash.value(name)}; } /*! 返回当前属性的默认值. */ QString SettingsPropertiesInfo::defaultValue() const { return d->m_defaultValue; } /*! 将属性 \a value 的值转换为字符串. */ QString SettingsPropertiesInfo::valueToString(const QVariant &value) const { if(d->m_valueType == d->m_settingsPropertyMetaType) { return SettingsPropertiesInfo(static_cast(value.toInt())).name(); } else if(d->m_valueType == QMetaType::QTime) { return value.toTime().toString("HHmm"); } else { return value.toString(); } } ukui-notification/libukui-notification/utils.cpp0000664000175000017500000000531315160523734021145 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "utils.h" #include #include #include #include using namespace UkuiNotification; UkuiSearch::ApplicationInfo &Utils::applicationInfo() { static UkuiSearch::ApplicationInfo s_applicationInfo; return s_applicationInfo; } QString Utils::desktopEntryFromPid(uint pid, bool isFullPath) { QString desktop; if(applicationInfo().tranPidToDesktopFp(pid, desktop)) { if (isFullPath) { return desktop; } return desktopEntry2Name(desktop); } return {}; } QString Utils::displayFromPid(uint pid) { QFile environFile(QStringLiteral("/proc/%1/environ").arg(QString::number(pid))); if (environFile.open(QIODevice::ReadOnly | QIODevice::Text)) { const QByteArray DISPLAY = UkuiQuick::WindowProxy::isWayland() ? QByteArrayLiteral("WAYLAND_DISPLAY") : QByteArrayLiteral("DISPLAY"); const auto lines = environFile.readAll().split('\0'); for (const QByteArray &line : lines) { const int equalsIdx = line.indexOf('='); if (equalsIdx <= 0) { continue; } const QByteArray key = line.left(equalsIdx); if (key == DISPLAY) { const QByteArray value = line.mid(equalsIdx + 1); return value; } } } return {}; } QString Utils::desktopEntryFromName(QString desktopFileName) { QString desktopFilePathName; applicationInfo().desktopFilePathFromName(desktopFileName, desktopFilePathName); return desktopFilePathName; } QString Utils::appNameForDesktopEntry(const QString &desktopFileName) { auto appInfo = applicationInfo().getInfo(desktopFileName, UkuiSearch::ApplicationProperty::LocalName); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (appInfo.isValid() && appInfo.type() == QVariant::String) { #else if (appInfo.isValid() && appInfo.typeId() == QVariant::String) { #endif return appInfo.toString(); } return {}; }ukui-notification/libukui-notification/popup-notification.cpp0000664000175000017500000003655415160523734023647 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "popup-notification.h" #include #include #include namespace UkuiNotification { class PopupNotificationPrivate { public: PopupNotificationPrivate(); ~PopupNotificationPrivate(); QImage parseImageHint(const QDBusArgument &arg); void loadImageFromPath(const QString &path); QSize maximumImageSize(); uint m_id = 0; QString m_applicationName; QString m_applicationIconName; QString m_summary; QString m_body; QList> m_actions; bool m_hasDefaultAction = false; QString m_defaultActionLabel; QVariantMap m_hints = QVariantMap(); QString m_category; QImage m_image; QString m_icon; QDateTime m_createdTime; QString m_desktopEntry; PopupNotification::Urgency m_urgency = PopupNotification::NormalUrgency; int m_timeout = -1; bool m_resident = false; bool m_transient = false; QString m_soundFile; QString m_soundName; bool m_suppressSound = false; QString m_display; QStringList m_actionState; bool m_noFold = false; int m_popupTimeout = 6000; //ms }; } using namespace UkuiNotification; PopupNotificationPrivate::PopupNotificationPrivate() { } PopupNotificationPrivate::~PopupNotificationPrivate() = default; QImage PopupNotificationPrivate::parseImageHint(const QDBusArgument &arg) { //copy from plasma-workspace int width, height, rowStride, hasAlpha, bitsPerSample, channels; QByteArray pixels; char *ptr; char *end; arg.beginStructure(); arg >> width >> height >> rowStride >> hasAlpha >> bitsPerSample >> channels >> pixels; arg.endStructure(); auto copyLineRGB32 = [](QRgb *dst, const char *src, int width) { const char *end = src + width * 3; for (; src != end; ++dst, src += 3) { *dst = qRgb(src[0], src[1], src[2]); } }; auto copyLineARGB32 = [](QRgb *dst, const char *src, int width) { const char *end = src + width * 4; for (; src != end; ++dst, src += 4) { *dst = qRgba(src[0], src[1], src[2], src[3]); } }; QImage::Format format = QImage::Format_Invalid; void (*fcn)(QRgb *, const char *, int) = nullptr; if (bitsPerSample == 8) { if (channels == 4) { format = QImage::Format_ARGB32; fcn = copyLineARGB32; } else if (channels == 3) { format = QImage::Format_RGB32; fcn = copyLineRGB32; } } if (format == QImage::Format_Invalid) { qWarning() << "Unsupported image format (hasAlpha:" << hasAlpha << "bitsPerSample:" << bitsPerSample << "channels:" << channels << ")"; return QImage(); } QImage image(width, height, format); ptr = pixels.data(); end = ptr + pixels.length(); for (int y = 0; y < height; ++y, ptr += rowStride) { if (ptr + channels * width > end) { qWarning() << "Image data is incomplete. y:" << y << "height:" << height; break; } fcn((QRgb *)image.scanLine(y), ptr, width); } return image; } void PopupNotificationPrivate::loadImageFromPath(const QString &path) { //copy from plasma-workspace QUrl imageUrl; if (path.startsWith(QLatin1Char('/'))) { imageUrl = QUrl::fromLocalFile(path); } else if (path.contains(QLatin1Char('/'))) { imageUrl = QUrl(path); if (!imageUrl.isLocalFile()) { qDebug() << "Refused to load image from" << path << "which isn't a valid local location."; return; } } if (!imageUrl.isValid()) { m_icon = path; return; } QImageReader reader(imageUrl.toLocalFile()); reader.setAutoTransform(true); const QSize imageSize = reader.size(); if (imageSize.isValid() && (imageSize.width() > maximumImageSize().width() || imageSize.height() > maximumImageSize().height())) { const QSize thumbnailSize = imageSize.scaled(maximumImageSize(), Qt::KeepAspectRatio); reader.setScaledSize(thumbnailSize); } m_image = reader.read(); } QSize PopupNotificationPrivate::maximumImageSize() { return QSize(256, 256); } /*! \class UkuiNotification::PopupNotification \inmodule UkuiNotification \inheaderfile popup-notification.h \brief 表示一条通知,包含一条通知消息的全部. PopupNotification 类封装了一条通知的所有属性和行为,包括通知ID、应用程序名称、图标、摘要、正文、动作、提示信息、类别、图片、声音等。 */ /*! \enum PopupNotification::Urgency 通知的紧急程度. \value LowUrgency 低:不弹窗提醒,直接进入通知中心;重复应用通知会折叠 \value NormalUrgency 普通:弹窗默认6s后关闭,进入通知中心;重复应用通知会折叠 \value CriticalUrgency 重要:通知弹窗默认常驻,可点击关闭;通知不会折叠 */ /*! \typedef ActionList \relates UkuiNotification 同 QList> */ /*! Construct from \a id. */ PopupNotification::PopupNotification(uint id) : d(new PopupNotificationPrivate()) { d->m_id = id; } /*! Copy constructor from \a other. */ PopupNotification::PopupNotification(const PopupNotification &other) : d(new PopupNotificationPrivate(*other.d)) { } /*! Copy assignment operator from \a other. */ PopupNotification &PopupNotification::operator=( const PopupNotification &other) { *d = *other.d; return *this; } /*! Move assignment operator from \a other. */ PopupNotification &PopupNotification::operator=(PopupNotification &&other) Q_DECL_NOEXCEPT { d = other.d; other.d = nullptr; return *this; } /*! Destructor */ PopupNotification::~PopupNotification() { if(d) { delete d; d = nullptr; } } /*! \readonly \property PopupNotification::id \brief 通知的ID */ uint PopupNotification::id() const { return d->m_id; } /*! \property PopupNotification::applicationName \brief 应用程序名称. */ QString PopupNotification::applicationName() const { return d->m_applicationName; } void PopupNotification::setApplicationName(const QString &applicationName) { d->m_applicationName = applicationName; } /*! \property PopupNotification::applicationIconName \brief 应用程序图标名称. */ QString PopupNotification::applicationIconName() const { return d->m_applicationIconName; } void PopupNotification::setApplicationIconName(const QString &applicationIconName) { d->m_applicationIconName = applicationIconName; } /*! \property PopupNotification::summary \brief 通知消息的摘要. */ QString PopupNotification::summary() const { return d->m_summary; } void PopupNotification::setSummary(const QString &summary) { d->m_summary = summary; } /*! \property PopupNotification::body \brief 通知消息的正文. */ QString PopupNotification::body() const { return d->m_body; } void PopupNotification::setBody(const QString &body) { d->m_body = body; } /*! \readonly \property PopupNotification::hasDefaultAction \brief 通知消息是否有默认 action,通常用于点击通知弹窗时执行。 */ bool PopupNotification::hasDefaultAction() const { return d->m_hasDefaultAction; } QString PopupNotification::defaultActionLabel() { return d->m_defaultActionLabel; } void PopupNotification::setActions(const QStringList &actions) { if (actions.count() % 2 != 0) { qWarning() << "List of actions must contain an even number of items, tried to set actions to" << actions; return; } d->m_hasDefaultAction = false; for (int i = 0; i < actions.count(); i += 2) { const QString &key = actions.at(i); const QString &label = actions.at(i + 1); if (!d->m_hasDefaultAction && key == QLatin1String("default")) { d->m_hasDefaultAction = true; d->m_defaultActionLabel = label; } d->m_actions.append({key, label}); } } /*! \readonly \property PopupNotification::actions \brief 通知消息的 action 列表. 通知 action 列表,表示通知包含的 actions 及执行动作信息,列表中两个为一组,偶数位(从0开始)表示一条 action 的唯一标识,奇数位表示要显示给用户的的内容。 一般点击消息体产生的 action 为 “default”,对应的内容无要求,一般不会显示给用户(但是需要在发送协议中和 action 拼成一组)。有额外需要用户操作的 action 则会在通知弹窗里以按钮形式展示。 */ QList> PopupNotification::actions() const { return d->m_actions; } QVariantMap PopupNotification::hints() const { return d->m_hints; } void PopupNotification::setHints(const QVariantMap &hints) { d->m_hints = hints; d->m_desktopEntry = hints.value(QStringLiteral("desktop-entry")).toString(); bool ok; int urgency = hints.value(QStringLiteral("urgency")).toInt(&ok); if(ok) { switch (urgency) { default: case 0: //低等级,不弹窗 setUrgency(Urgency::LowUrgency); d->m_popupTimeout = 0; break; case 1: //中等级,弹窗时间默认6秒 setUrgency(Urgency::NormalUrgency); d->m_popupTimeout = 6000; break; case 2: //高等级,默认弹窗常驻,不可折叠 setUrgency(Urgency::CriticalUrgency); d->m_popupTimeout = -1; d->m_noFold = true; break; } } d->m_createdTime = QDateTime::fromString(hints.value(QStringLiteral("x-ukui-createdTime")).toString()); d->m_resident = hints.value(QStringLiteral("resident")).toBool(); d->m_transient = hints.value(QStringLiteral("transient")).toBool(); d->m_category = hints.value(QStringLiteral("category")).toString(); auto end = hints.end(); auto it = hints.find(QStringLiteral("image-data")); if (it != end) { d->m_image = d->parseImageHint(it->value()); if (!d->m_image.isNull()) { const QSize max = d->maximumImageSize(); if (d->m_image.size().width() > max.width() || d->m_image.size().height() > max.height()) { d->m_image = d->m_image.scaled(max, Qt::KeepAspectRatio, Qt::SmoothTransformation); } } } if (d->m_image.isNull()) { it = hints.find(QStringLiteral("image-path")); if (it != end) { d->loadImageFromPath(it->toString()); } } d->m_soundFile = hints.value(QStringLiteral("sound-file")).toString(); d->m_soundName = hints.value(QStringLiteral("sound-name")).toString(); d->m_suppressSound = hints.value(QStringLiteral("suppress-sound")).toBool(); d->m_display = hints.value(QStringLiteral("x-ukui-display")).toString(); d->m_actionState = hints.value(QStringLiteral("x-ukui-action-state")).toStringList(); QVariant tmp = hints.value(QStringLiteral("x-ukui-no-fold")); if(!tmp.isNull()) { d->m_noFold = tmp.toBool(); } tmp = hints.value(QStringLiteral("x-ukui-popup-timeout")); if(!tmp.isNull()) { d->m_popupTimeout = tmp.toInt(); } } /*! \property PopupNotification::timeout \brief 通知消息的超时时间. */ int PopupNotification::timeout() const { return d->m_timeout; } void PopupNotification::setTimeout(int timeout) { d->m_timeout = timeout; } /*! \readonly \property PopupNotification::createdTime \brief 通知消息的创建时间. */ QDateTime PopupNotification::createdTime() const { return d->m_createdTime; } /*! \readonly \property PopupNotification::enableActionIcons \brief 是否支持 hints 中的 action-icon 功能. */ bool PopupNotification::enableActionIcons() const { //TODO 可以支持action-icon return false; } /*! \readonly \property PopupNotification::category \brief 通知消息的分类. */ QString PopupNotification::category() const { return d->m_category; } QString PopupNotification::desktopEntry() const { return d->m_desktopEntry; } /*! \readonly \property PopupNotification::image \brief 对应image-data字段. */ QImage PopupNotification::image() const { return d->m_image; } /*! \readonly \property PopupNotification::icon \brief 当加载 image-data 失败,或通过 image-path 加载 image 失败时(image-path 不是 URL),icon 会被设置为 image-path 数据。 */ QString PopupNotification::icon() const { return d->m_icon; } /*! \readonly \property PopupNotification::resident \brief 通知消息是否常驻. 当设置为true时,通知中心将不会在用户点击 action 按钮后自动移除消息。仅当用户关闭或被通知发送者关闭才会移除通知。 */ bool PopupNotification::resident() const { return d->m_resident; } /*! \readonly \property PopupNotification::soundFile \brief 通知发送时播放的声音文件路径。 */ QString PopupNotification::soundFile() const { return d->m_soundFile; } /*! \readonly \property PopupNotification::soundName \brief 声音主题中的声音名称。 */ QString PopupNotification::soundName() const { return d->m_soundName; } /*! \readonly \property PopupNotification::suppressSound \brief 指定通知服务静音,通常用于通知发送者播放自己的声音。 */ bool PopupNotification::suppressSound() const { return d->m_suppressSound; } /*! \readonly \property PopupNotification::transient \brief 设置为 true 后,通知服务将通知视为临时的(不会一直存在) */ bool PopupNotification::transient() const { return d->m_transient; } /*! \readonly \property PopupNotification::display \brief 表示当前通知要显示在哪个DISPLAY上. */ QString PopupNotification::display() const { return d->m_display; } void PopupNotification::setUrgency(PopupNotification::Urgency urgency) { d->m_urgency = urgency; } PopupNotification::Urgency PopupNotification::urgency() const { return d->m_urgency; } /*! \readonly \property PopupNotification::actionState \brief 和 action 对应,依次表示每个 action 的状态(包括 default action). */ QStringList PopupNotification::actionState() const { return d->m_actionState; } /*! \readonly \property PopupNotification::noFold \brief 设置为true后,通知将不会被折叠. */ bool PopupNotification::noFold() const { return d->m_noFold; } /*! \readonly \property PopupNotification::popupTimeout \brief 通知弹窗持续时间. */ int PopupNotification::popupTimeout() const { return d->m_popupTimeout; } ukui-notification/libukui-notification/notification-close-reason.h0000664000175000017500000000310215160523734024522 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_NOTIFICATIONCLOSEREASON_H #define UKUI_NOTIFICATION_NOTIFICATIONCLOSEREASON_H #include #include "ukui-notification_global.h" namespace UkuiNotification { /** * @short 通知被关闭的原因. * @author iaom */ class UKUINOTIFICATION_EXPORT NotificationCloseReason { Q_GADGET public: /** * The reason a notification was closed */ enum CloseReason { /** * 通知过期. */ Expired = 1, /** * 通知被用户关闭. */ DismissedByUser = 2, /** * 通知被发送者通过调用CloseNotification接口关闭 */ Revoked = 3, /** * 未定义/保留原因 */ Undefined = 4, }; Q_ENUM(CloseReason) }; } #endif //UKUI_NOTIFICATION_NOTIFICATIONCLOSEREASON_Hukui-notification/libukui-notification/ukui-notification_global.h0000664000175000017500000000200615160523734024427 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUINOTIFICATION_GLOBAL_H #define UKUINOTIFICATION_GLOBAL_H #include #if defined(UKUINOTIFICATION_LIBRARY) # define UKUINOTIFICATION_EXPORT Q_DECL_EXPORT #else # define UKUINOTIFICATION_EXPORT Q_DECL_IMPORT #endif #endif // UKUINOTIFICATION_GLOBAL_H ukui-notification/libukui-notification/utils.h0000664000175000017500000000527015160523734020614 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_UTILS_H #define UKUI_NOTIFICATION_UTILS_H #include #include #include namespace UkuiNotification { /** * @short 提供一些方便的接口. * @author iaom */ namespace Utils { /** * @brief 获取全局UkuiSearch::ApplicationInfo 实例 * @return */ UkuiSearch::ApplicationInfo& applicationInfo(); /** * @brief 根据进程号@p pid 获取应用的desktop文件,isFullPath 是否获取全路径的标志位。 * @return isFullPath==true 获取desktop文件全路径, 否则获取desktop文件名 (不含后缀) */ QString desktopEntryFromPid(uint pid, bool isFullPath = false); /** * @brief 根据进程号@p pid 获取应用所在的DISPLAY。 * @return DISPLAY的值 */ QString displayFromPid(uint pid); /** * @brief 根据desktop文件名(不带后缀)获取全路径。 * @return desktop文件全路径 */ QString desktopEntryFromName(QString desktopFileName); /** * @brief 从desktop文件全路径截取desktop文件名(不含后缀) * @param desktop文件全路径 * @return desktop 文件名 */ inline QString desktopEntry2Name(const QString& desktopFileName) { if (desktopFileName.endsWith(".desktop")) { return QFileInfo(desktopFileName).completeBaseName(); } return QFileInfo(desktopFileName).fileName(); }; /** * @brief 获取应用名称, 通过desktop全路径 * @return */ QString appNameForDesktopEntry(const QString& desktopFileName); /** * * @return 返回a中存在b中不存在的元素, 求差集 */ #define StringListDiff \ ([](const QStringList& a, const QStringList& b) { \ QSet setA(a.begin(), a.end()); \ QSet setB(b.begin(), b.end()); \ return QStringList(setA.subtract(setB).values()); \ }) } } #endif //UKUI_NOTIFICATION_UTILS_H ukui-notification/libukui-notification/popup-notification.h0000664000175000017500000002034615160523734023304 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_POPUP_NOTIFICATION_H #define UKUI_NOTIFICATION_POPUP_NOTIFICATION_H #include "ukui-notification_global.h" #include #include #include #include #include #include #include #include #include namespace UkuiNotification { class PopupNotificationPrivate; typedef QList> ActionList; /** * @short 表示一条通知。 * @author iaom */ class UKUINOTIFICATION_EXPORT PopupNotification { friend class NotificationSettingsTest; Q_GADGET /** * 通知ID。 */ Q_PROPERTY(uint id READ id) /** * 应用名称。 */ Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName) /** * 应用图标名。 */ Q_PROPERTY(QString applicationIconName READ applicationIconName WRITE setApplicationIconName) /** * 通知摘要。 */ Q_PROPERTY(QString summary READ summary WRITE setSummary) /** * 通知消息体。 */ Q_PROPERTY(QString body READ body WRITE setBody) /** * 通知创建时间。 */ Q_PROPERTY(QDateTime createdTime READ createdTime) /** * 是否有默认action,通常用于点击通知弹窗时执行。 */ Q_PROPERTY(bool hasDefaultAction READ hasDefaultAction) /** * 通知action列表,表示通知包含的actions及执行动作信息,列表中两个为一组,偶数位(从0开始)表示一条action的唯一标识,奇数位表示要显示给用户的的内容。 * 一般点击消息体产生的action为“default”,对应的内容无要求,一般不会显示给用户(但是需要在发送协议中和action拼成一组)。有额外需要用户操作的action则会在通知弹窗里以按钮形式展示。 */ Q_PROPERTY(ActionList actions READ actions) /** * 通知超时失效时间(通知失效后会发送NotificationClosed信号,并且通知弹窗无法再继续操作)-1:系统默认;0 不会超时; >0 表示超时时间。 */ Q_PROPERTY(int timeout READ timeout WRITE setTimeout) /** * 是否支持hints中的action-icon功能。 */ Q_PROPERTY(bool enableActionIcons READ enableActionIcons) /** * 对应hints中的image-data字段。 */ Q_PROPERTY(QImage image READ image) /** * 当加载image-data失败,或通过image-path加载image失败时(image-path不是URL),icon会被设置为image-path数据。 */ Q_PROPERTY(QString icon READ icon) /** * 当设置为true时,通知中心将不会在用户点击action按钮后自动移除消息。仅当用户关闭或被通知发送者关闭才会移除通知。 */ Q_PROPERTY(bool resident READ resident) /** * 设置为true后,通知服务将通知视为临时的(不会一直存在)。 */ Q_PROPERTY(bool transient READ transient) /** * 通知发送时播放的声音文件路径。 */ Q_PROPERTY(QString soundFile READ soundFile) /** * 声音主题中的声音名称。 */ Q_PROPERTY(QString soundName READ soundName) /** * 指定通知服务静音,通常用于通知发送者播放自己的声音。 */ Q_PROPERTY(bool suppressSound READ suppressSound) /** * 当前通知的种类。 */ Q_PROPERTY(QString category READ category) /** * 紧急程度。 */ Q_PROPERTY(Urgency urgency READ urgency WRITE setUrgency) /** * 表示当前通知要显示在哪个DISPLAY上。 */ Q_PROPERTY(QString display READ display) /** * 和action对应,依次表示每个action的状态(包括default action)。 */ Q_PROPERTY(QStringList actionState READ actionState) /** * 设置为true后,通知将不会被折叠。 */ Q_PROPERTY(bool noFold READ noFold) /** * 通知弹窗持续时间,超过此时间后被收纳进通知中心(单位秒)。-1:表示消息通知常驻,不会收纳进通知中心;0:表示通知将直接进入侧边栏通知中心,不会弹窗;>0: 表示通知弹窗持续时间。 */ Q_PROPERTY(int popupTimeout READ popupTimeout) public: /** * The notification urgency. */ enum Urgency { /** * 低:不弹窗提醒,直接进入通知中心;重复应用通知会折叠。 */ LowUrgency = 0, /** * 普通:弹窗默认6s后关闭,进入通知中心;重复应用通知会折叠。 */ NormalUrgency = 1, /** * 重要:通知弹窗默认常驻,可点击关闭;通知不会折叠。 */ CriticalUrgency = 2, }; Q_ENUM(Urgency) explicit PopupNotification(uint id = 0); PopupNotification(const PopupNotification &other); PopupNotification &operator=(const PopupNotification &other); PopupNotification &operator=(PopupNotification &&other) Q_DECL_NOEXCEPT; ~PopupNotification(); /** * 通知ID。 */ uint id() const; /** * 应用名称。 */ QString applicationName() const; void setApplicationName(const QString &applicationName); /** * 应用图标名。 */ QString applicationIconName() const; void setApplicationIconName(const QString &applicationIconName); /** * 通知摘要。 */ QString summary() const; void setSummary(const QString &summary); /** * 通知消息体。 */ QString body() const; void setBody(const QString &body); /** * 是否有默认action,通常用于点击通知弹窗时执行。 */ bool hasDefaultAction() const; /** * 默认action的label名称。 */ QString defaultActionLabel(); void setActions(const QStringList &actions); ActionList actions() const; QStringList actionState() const; QVariantMap hints() const; void setHints(const QVariantMap &hints); int timeout() const; void setTimeout(int timeout); QDateTime createdTime() const; //m_hints /** * 使用图标显示action * @return */ bool enableActionIcons() const; /** * 分类 * @return */ QString category() const; /** * desktop名称(不带.desktop后缀) * @return */ QString desktopEntry() const; /** * 对应image-data字段 * @return */ QImage image() const; /** * 当加载image-data失败,或通过image-path加载image失败时(image-path不是URL),icon会被设置为image-path数据 * @return */ QString icon() const; /** * 是否持续显示,不会自动移除,直到被用户手动或发送者删除 * @return */ bool resident() const; /** * 通知发送时播放的声音文件路径 * @return */ QString soundFile() const; /** * 声音主题中的声音名称 * @return */ QString soundName() const; /** * 是否静音 * @return */ bool suppressSound() const; /** * 暂时通知(会自动移除) * @return */ bool transient() const; Urgency urgency() const; void setUrgency(Urgency urgency); /** * 通知发送者所在的display * @return */ QString display() const; /** * 是否不折叠 * @return */ bool noFold() const; /** * 弹窗持续时间 * @return */ int popupTimeout() const; private: PopupNotificationPrivate *d = nullptr; }; } #endif //UKUI_NOTIFICATION_POPUP_NOTIFICATION_H ukui-notification/notification-ukcc-plugin/0000775000175000017500000000000015160523746020057 5ustar fengfengukui-notification/notification-ukcc-plugin/translations/0000775000175000017500000000000015160523746022600 5ustar fengfengukui-notification/notification-ukcc-plugin/translations/de.ts0000664000175000017500000001146615160523746023550 0ustar fengfeng Notice Notice Bemerken NotFaze Mode 勿扰模式 Do not disturb mode Modus "Nicht stören" /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (Benachrichtigungsbanner, Eingabeaufforderungen werden ausgeblendet und Benachrichtigungstöne werden stummgeschaltet) Automatically turn on Automatisch einschalten /Notice/Do not disturb mode Mode/Automatically turn on to An Automatically turn on when multiple screens are connected Automatisches Einschalten, wenn mehrere Bildschirme angeschlossen sind /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode Automatisches Öffnen im Vollbildmodus /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode Automatische Alarmerinnerungen im Modus "Nicht stören" zulassen /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings Einstellungen für Hinweise Get notifications from the app Erhalten Sie Benachrichtigungen von der App /notice/Get notifications from the app NoticeMenu Beep sound when notified Piepton bei Benachrichtigung Show message on screenlock Nachricht auf der Bildschirmsperre anzeigen Show noticfication on screenlock Benachrichtigung auf Bildschirmsperre anzeigen Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/ky.ts0000664000175000017500000001213415160523746023574 0ustar fengfeng Notice Notice ۇقتۇرۇۇ NotFaze Mode 勿扰模式 Do not disturb mode تااسىئر قىلبوو ۉلگۉسۉ /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (ۇقتۇرۇۇ لوزۇنكىلىرى، ئەسكەرتىشلەر جاشىرىنعان بولوت ، ۇقتۇرۇۇ دووشسۇز بولوت ) Automatically turn on اپتوماتتىك قوزعوتۇۇ /Notice/Do not disturb mode Mode/Automatically turn on to عا Automatically turn on when multiple screens are connected كۅپ ەكىران ۇلانعاندا اپتوماتتىك اچىلات /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode پۉتۉن ەكىران ابالىندا اپتوماتتىك اچىلات /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode ئاۋارە قىلبوو ابالىندا قوڭعۇراقتۇۇ ساات ەسكەرتۉۉگۅ ۇرۇقسات جاسالات. /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings ۇقتۇرۇۇ Get notifications from the app ئەپتىن گەلگەن ۇقتۇرۇۇعا ەە بولۇۇ /notice/Get notifications from the app NoticeMenu Beep sound when notified ۇقتۇرۇۇ جاساعاندا ەسكەرتۉۉ وبونۇ Show message on screenlock ەكىران قۇلۇپتوو كۅرۉنمۅ بەتىندە ۇچۇر مازمۇنۇن كۅرسۅتۅت. Show noticfication on screenlock ەكىران قۇلۇپتوو كۅرۉنمۅ بەتىندە ۇقتۇرۇۇ كۅرسۅتۉۉ Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/zh_CN.ts0000664000175000017500000001107215160523746024152 0ustar fengfeng Notice Notice 通知 NotFaze Mode 勿扰模式 Do not disturb mode 勿扰模式 /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (通知横幅、提示将会隐藏,通知声音将会静音) Automatically turn on 自动开启 /Notice/Do not disturb mode Mode/Automatically turn on to Automatically turn on when multiple screens are connected 多屏连接时自动开启 /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode 全屏模式下自动开启 /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode 勿扰模式下允许闹钟提示 /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings 通知 Get notifications from the app 获取来自应用的通知 /notice/Get notifications from the app NoticeMenu Beep sound when notified 通知时提示声音 Show message on screenlock 在锁屏界面显示消息内容 Show noticfication on screenlock 在锁屏界面显示通知 Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/kk.ts0000664000175000017500000001211215160523746023552 0ustar fengfeng Notice Notice ۇقتٸرۋ NotFaze Mode 勿扰模式 Do not disturb mode جارا ورىنداماستىق فورماسى /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (ۇقتٸرۋ لوزۇنكىلىرى، ئەسكەرتىشلەر جاسىرىلعان بولادٸ، ۇقتٸرۋ دٸبٸسسز بولادٸ) Automatically turn on اۆتوماتتى قوزعالتۋ /Notice/Do not disturb mode Mode/Automatically turn on to عا Automatically turn on when multiple screens are connected كوپ ەكٸران جالعانعاندا اۆتوماتتى اشٸلدٸ /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode پۇتٸن ەكٸران كۇيىندە اۆتوماتتى اشٸلدٸ /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode اۋرە ورىنداماستىق كۇيىندە قوڭىراۋلىق ساعات ەسكەرتكى رۇحسات قىلىندى. /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings ۇقتٸرۋ Get notifications from the app ئەپتىن كەل ۇقتٸرۋعا يە بولۋ /notice/Get notifications from the app NoticeMenu Beep sound when notified ۇقتٸرۋ قىلعاندا ەسكەرتپەۋ داۋىسى Show message on screenlock ەكٸران قۇلپىلاۋ كورىنبە بەتىندە حابار مازمۇندى كورسەتەدى. Show noticfication on screenlock ەكٸران قۇلپىلاۋ كورىنبە بەتىندە ۇقتٸرۋ كورسەتۋ Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/ar.ts0000664000175000017500000001161715160523746023560 0ustar fengfeng Notice Notice لاحظ NotFaze Mode 勿扰模式 Do not disturb mode وضع عدم الإزعاج /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (سيتم إخفاء لافتات الإشعارات والمطالبات وسيتم كتم أصوات الإشعارات) Automatically turn on التفعيل التلقائي /Notice/Do not disturb mode Mode/Automatically turn on to ل Automatically turn on when multiple screens are connected التشغيل التلقائي عند توصيل شاشات متعددة /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode فتح تلقائيا في وضع ملء الشاشة /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode السماح بتذكيرات التنبيه التلقائي في وضع عدم الإزعاج /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings إعدادات الإشعار Get notifications from the app الحصول على إشعارات من التطبيق /notice/Get notifications from the app NoticeMenu Beep sound when notified صوت صفير عند الإخطار Show message on screenlock إظهار الرسالة على قفل الشاشة Show noticfication on screenlock إظهار الإشعارات على قفل الشاشة Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/ug.ts0000664000175000017500000001220715160523746023565 0ustar fengfeng Notice Notice ئۇقتۇرۇش NotFaze Mode 勿扰模式 Do not disturb mode دەخلى قىلماسلىق ئەندىزىسى /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (ئۇقتۇرۇش لوزۇنكىلىرى، ئەسكەرتىشلەر يوشۇرۇنغان بولىدۇ، ئۇقتۇرۇش ئاۋازسىز بولىدۇ) Automatically turn on ئاپتوماتىك قوزغىتىش /Notice/Do not disturb mode Mode/Automatically turn on to غا Automatically turn on when multiple screens are connected كۆپ ئېكران ئۇلانغاندا ئاپتوماتىك ئېچىلىدۇ /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode پۈتۈن ئېكران ھالىتىدە ئاپتوماتىك ئېچىلىدۇ /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode ئاۋارە قىلماسلىق ھالىتىدە قوڭغۇراقلىق سائەت ئەسكەرتىشكە رۇخسەت قىلىنىدۇ. /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings ئۇقتۇرۇش Get notifications from the app ئەپتىن كەلگەن ئۇقتۇرۇشقا ئېرىشىش /notice/Get notifications from the app NoticeMenu Beep sound when notified ئۇقتۇرۇش قىلغاندا ئەسكەرتىش ئاۋازى Show message on screenlock ئېكران قۇلۇپلاش كۆرۈنمە يۈزىدە ئۇچۇر مەزمۇنىنى كۆرسىتىدۇ. Show noticfication on screenlock ئېكران قۇلۇپلاش كۆرۈنمە يۈزىدە ئۇقتۇرۇش كۆرسىتىش Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/bo_CN.ts0000664000175000017500000001457215160523746024141 0ustar fengfeng Notice Notice བརྡ་ཐོ། NotFaze Mode མི་དམངས་ཀྱི་དཔེ་དབྱིབས་མིན་པ། Do not disturb mode མི་དམངས་ཀྱི་དཔེ་དབྱིབས་མིན་པ། /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (བརྡ་ཐོ་གཏོང་བའི་འཕྲེད་འགེལ་སྦྱར་ཡིག་དང་། བརྡ་གཏོང་ཡི་གེ་སྦས་སྐུང་བྱས་ནས་བརྡ་ཁྱབ་ཀྱི་སྒྲ་གྲགས་ཡོང་། ) Automatically turn on རང་འགུལ་གྱིས་ཁ་ཕྱེ་བ། /Notice/Do not disturb mode Mode/Automatically turn on to དེ་ལྟར་བྱས་ན་ Automatically turn on when multiple screens are connected བརྙན་ཤེལ་མང་པོ་སྦྲེལ་མཐུད་བྱེད་སྐབས་རང་འགུལ་གྱིས་ཁ་ཕྱེ་བ། /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode བརྙན་ཤེལ་ཧྲིལ་པོའི་རྣམ་པའི་ཐོག་ནས་རང་འགུལ་གྱིས་སྒོ་ /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode རང་འགུལ་གྱིས་ཉེན་བརྡ་གཏོང་བའི་དྲན་སྐུལ་བྱེད་སྟངས་ལ་སུན་པོ་བཟོ་མི་རུང་། /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings བརྡ་ཐོའི་སྒྲིག་བཀོད། Get notifications from the app ཉེར་སྤྱོད་གོ་རིམ་ཁྲོད་ནས་བརྡ་ཐོ་གཏོང་དགོས། /notice/Get notifications from the app NoticeMenu Beep sound when notified བརྡ་ཐོ་གཏོང་སྐབས་སྐད་ཅོར་རྒྱག་པ། Show message on screenlock བརྙན་ཤེལ་སྟེང་ནས་ཆ་འཕྲིན་མངོན་པ། Show noticfication on screenlock བརྙན་ཤེལ་སྟེང་ནས་དོ་སྣང་བྱེད་པ། Notification Style བརྡ་ཐོ་གཏོང་སྟངས། Banner: Appears in the upper right corner of the screen, and disappears automatically འཕྲེད་འགེལ་ཡི་གེ། བརྙན་ཤེལ་གྱི་གཡས་ཟུར་དུ་མངོན་པ་མ་ཟད། རང་འགུལ་གྱིས་མེད་པར་གྱུར་པ། Tip:It will be kept on the screen until it is closed རྩེ་མོ། འཆར་ངོས་སུ་ཉར་ཚགས་བྱས་ནས་སྒོ་མ་བརྒྱབ་གོང་ལ་ཉར་ཚགས་བྱེད་དགོས། None:Notifications will not be displayed on the screen, but will go to the notification center གཅིག་ཀྱང་མ་ལུས་པར་འཆར་ངོས་སུ་བརྡ་ཐོ་མི་མངོན་པར་བརྡ་ཁྱབ་ལྟེ་གནས་སུ་འགྲོ་རྒྱུ་རེད། ukui-notification/notification-ukcc-plugin/translations/vi.ts0000664000175000017500000001147415160523746023575 0ustar fengfeng Notice Notice Thông báo NotFaze Mode 勿扰模式 Do not disturb mode Chế độ không làm phiền /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (Biểu ngữ thông báo, lời nhắc sẽ bị ẩn và âm thanh thông báo sẽ bị tắt tiếng) Automatically turn on Tự động bật /Notice/Do not disturb mode Mode/Automatically turn on to đến Automatically turn on when multiple screens are connected Tự động bật khi nhiều màn hình được kết nối /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode Tự động mở ở chế độ toàn màn hình /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode Cho phép nhắc nhở báo thức tự động ở chế độ Không làm phiền /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings Cài đặt thông báo Get notifications from the app Nhận thông báo từ ứng dụng /notice/Get notifications from the app NoticeMenu Beep sound when notified Âm thanh bíp khi được thông báo Show message on screenlock Hiển thị tin nhắn trên khóa màn hình Show noticfication on screenlock Hiển thị thông báo trên khóa màn hình Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/mn.ts0000664000175000017500000001333415160523746023566 0ustar fengfeng Notice Notice ᠮᠡᠳᠡᠭᠳᠡᠯ NotFaze Mode 勿扰模式 Do not disturb mode ᠬᠠᠷᠰᠢᠯᠠᠬᠤ ᠵᠢ ᠵᠣᠭᠰᠣᠭᠠᠬᠤ ᠮᠤᠳᠦ᠋ᠯ /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) ( ᠮᠡᠳᠡᠭᠳᠡᠯ ᠤ᠋ᠨ ᠡᠯᠬᠦᠬᠡᠰᠦ᠂ ᠰᠠᠨᠠᠭᠤᠯᠤᠮᠵᠢ ᠨᠢᠭᠤᠴᠠᠯᠠᠬᠤ᠂ ᠮᠡᠳᠡᠭᠳᠡᠯ ᠤ᠋ᠨ ᠲᠤᠬᠢᠶ᠎ᠠ ᠳᠠᠭᠤ ᠥᠬᠡᠢ ᠪᠤᠯᠬᠤ) Automatically turn on ᠠᠦ᠋ᠲ᠋ᠣ᠋ ᠪᠡᠷ ᠡᠬᠢᠯᠡᠬᠦᠯᠬᠦ /Notice/Do not disturb mode Mode/Automatically turn on to ᠡᠴᠡ Automatically turn on when multiple screens are connected ᠣᠯᠠᠨ ᠳᠡᠯᠭᠡᠴᠡᠨ ᠳ᠋ᠤ᠌ ᠵᠠᠯᠭᠠᠬᠤ ᠦᠶ᠎ᠡ ᠳ᠋ᠤ᠌ ᠠᠦ᠋ᠲ᠋ᠣ᠋ ᠪᠡᠷ ᠡᠬᠢᠯᠡᠬᠦᠯᠬᠦ /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode ᠪᠦᠳᠦᠨ ᠳᠡᠯᠭᠡᠴᠡ ᠵᠢᠨ ᠪᠠᠢᠳᠠᠯ ᠳᠤᠤᠷ᠎ᠡ ᠳᠠᠬᠢᠨ ᠡᠬᠢᠯᠡᠬᠦᠯᠬᠦ /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode ᠬᠠᠷᠰᠢᠯᠠᠬᠤ ᠵᠢ ᠬᠣᠷᠢᠭᠯᠠᠬᠤ ᠪᠠᠢᠳᠠᠯ ᠳᠤᠤᠷ᠎ᠡ ᠰᠡᠷᠢᠬᠦᠯᠬᠡᠳᠦ ᠴᠠᠭ ᠤ᠋ᠨ ᠰᠠᠨᠠᠭᠤᠯᠬᠤ ᠵᠢ ᠵᠥᠪᠰᠢᠶᠡᠷᠡᠬᠦ /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings ᠮᠡᠳᠡᠭᠳᠡᠯ Get notifications from the app ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠡᠴᠡ ᠢᠷᠡᠯᠳᠡᠢ ᠮᠡᠳᠡᠭᠳᠡᠯ ᠢ᠋ ᠤᠯᠬᠤ /notice/Get notifications from the app NoticeMenu Beep sound when notified ᠮᠡᠳᠡᠭᠳᠡᠬᠦ ᠦᠶ᠎ᠡ ᠵᠢᠨ ᠰᠠᠨᠠᠭᠤᠯᠬᠤ ᠳᠠᠭᠤ Show message on screenlock ᠣᠨᠢᠰᠤᠯᠠᠬᠤ ᠵᠠᠭᠠᠭ ᠭᠠᠳᠠᠷᠭᠤ ᠳᠡᠭᠡᠷ᠎ᠡ ᠰᠤᠷᠠᠭ ᠵᠠᠩᠬᠢ ᠵᠢᠨ ᠠᠭᠤᠯᠭ᠎ᠠ ᠵᠢ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ Show noticfication on screenlock ᠣᠨᠢᠰᠤᠯᠠᠬᠤ ᠵᠠᠭᠠᠭ ᠭᠠᠳᠠᠷᠭᠤ ᠳᠡᠭᠡᠷ᠎ᠡ ᠮᠡᠳᠡᠭᠳᠡᠯ ᠢ᠋ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/fr.ts0000664000175000017500000001147515160523746023567 0ustar fengfeng Notice Notice Remarquer NotFaze Mode 勿扰模式 Do not disturb mode Mode Ne pas déranger /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (Les bannières de notification, les invites seront masquées et les sons de notification seront désactivés) Automatically turn on Activer automatiquement /Notice/Do not disturb mode Mode/Automatically turn on to À Automatically turn on when multiple screens are connected S’allume automatiquement lorsque plusieurs écrans sont connectés /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode Ouverture automatique en mode plein écran /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode Autoriser les rappels automatiques d’alarme en mode Ne pas déranger /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings Paramètres de l’avis Get notifications from the app Recevoir des notifications de l’application /notice/Get notifications from the app NoticeMenu Beep sound when notified Bip sonore lors de la notification Show message on screenlock Afficher le message sur le verrouillage de l’écran Show noticfication on screenlock Afficher la notification sur le verrouillage de l’écran Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/en_US.ts0000664000175000017500000001137215160523746024165 0ustar fengfeng Notice Notice Notice NotFaze Mode NotFaze Mode Do not disturb mode /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (Notification banners, prompts will be hidden, and notification sounds will be muted) Automatically turn on Automatically turn on /Notice/Do not disturb mode Mode/Automatically turn on to to Automatically turn on when multiple screens are connected Automatically turn on when multiple screens are connected /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode Automatically open in full screen mode /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode Allow automatic alarm reminders in Do Not Disturb mode /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings Notice Settings Get notifications from the app Get notifications from the app /notice/Get notifications from the app NoticeMenu Beep sound when notified Beep sound when notified Show message on screenlock Show message on screenlock Show noticfication on screenlock Show noticfication on screenlock Notification Style Notification Style Banner: Appears in the upper right corner of the screen, and disappears automatically Banner: Appears in the upper right corner of the screen, and disappears automatically Tip:It will be kept on the screen until it is closed Tip:It will be kept on the screen until it is closed None:Notifications will not be displayed on the screen, but will go to the notification center None:Notifications will not be displayed on the screen, but will go to the notification center ukui-notification/notification-ukcc-plugin/translations/es.ts0000664000175000017500000001143515160523746023563 0ustar fengfeng Notice Notice Notar NotFaze Mode 勿扰模式 Do not disturb mode Modo No molestar /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (Los banners de notificación, las indicaciones se ocultarán y los sonidos de notificación se silenciarán) Automatically turn on Encendido automático /Notice/Do not disturb mode Mode/Automatically turn on to Para Automatically turn on when multiple screens are connected Se enciende automáticamente cuando hay varias pantallas conectadas /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode Apertura automática en modo de pantalla completa /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode Permitir recordatorios de alarma automáticos en el modo No molestar /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings Configuración de avisos Get notifications from the app Recibir notificaciones de la aplicación /notice/Get notifications from the app NoticeMenu Beep sound when notified Sonido de pitido cuando se notifica Show message on screenlock Mostrar mensaje en el bloqueo de pantalla Show noticfication on screenlock Mostrar notificación en el bloqueo de pantalla Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/translations/zh_HK.ts0000664000175000017500000001107615160523746024160 0ustar fengfeng Notice Notice 通知 NotFaze Mode 勿扰模式 Do not disturb mode 勿擾模式 /Notice/Do not disturb mode Mode (Notification banners, prompts will be hidden, and notification sounds will be muted) (通知橫幅、提示將會隱藏,通知聲音將會靜音) Automatically turn on 自動開啟 /Notice/Do not disturb mode Mode/Automatically turn on to Automatically turn on when multiple screens are connected 多屏連接時自動開啟 /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected Automatically open in full screen mode 全屏模式下自動開啟 /Notice/Do not disturb mode/Automatically open in full screen mode Allow automatic alarm reminders in Do Not Disturb mode 勿擾模式下允許鬧鐘提示 /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode Notice Settings 通知 Get notifications from the app 獲取來自應用的通知 /notice/Get notifications from the app NoticeMenu Beep sound when notified 通知時提示聲音 Show message on screenlock 在鎖屏介面顯示消息內容 Show noticfication on screenlock 在鎖屏介面顯示通知 Notification Style 通知样式 Banner: Appears in the upper right corner of the screen, and disappears automatically 横幅:显示在屏幕右上角,会自动消失 Tip:It will be kept on the screen until it is closed 提示:会保留在屏幕上,直到被关闭 None:Notifications will not be displayed on the screen, but will go to the notification center 无:通知不会显示在屏幕上,但会进入通知中心 ukui-notification/notification-ukcc-plugin/notice-menu.h0000664000175000017500000000405515160523746022457 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef NOTICEMENU_H #define NOTICEMENU_H #include #include #include #include #include #include #include "applications-settings.h" using namespace kdk; class NoticeMenu : public QMenu { Q_OBJECT public: explicit NoticeMenu(QWidget *parent = nullptr); void initStatus(UkuiNotification::SingleApplicationSettings *settings); void setVoiceEnable(bool state); void setDetailShowOnLockScreenEnable(bool state); void setShowOnLockScreenEnable(bool state); void setPopupStyle(UkuiNotification::SettingsProperty::Property style); static QFrame *setLine(); private: void initUi(); void setFrame(QFrame *frame, QString str, KSwitchButton *btn); void setFrame(QFrame *frame, QString str, QRadioButton *btn); void setConnect(); private: KSwitchButton *m_voiceBtn = nullptr; KSwitchButton *m_detailBtn = nullptr; KSwitchButton *m_showBtn = nullptr; QButtonGroup *m_styleGroup = nullptr; QRadioButton *m_noneBtn = nullptr; QRadioButton *m_mutativeBtn = nullptr; QRadioButton *m_alwaysBtn = nullptr; protected: void showEvent(QShowEvent *event) override; Q_SIGNALS: void voiceSignals(bool checked); void detailSignals(bool checked); void showSignals(bool checked); void styleBtnSignals(int id); }; #endif // NOTICEMENU_H ukui-notification/notification-ukcc-plugin/CMakeLists.txt0000664000175000017500000000361715160523746022626 0ustar fengfeng set(notification-ukcc-plugin_LIB_SRCS notification-ukcc-plugin.cpp notification-ukcc-plugin.h notice-menu.cpp notice-menu.h) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Widgets LinguistTools REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets LinguistTools REQUIRED) find_package(PkgConfig REQUIRED) set(UKUI_NOTIFICATION_EXTERNAL_LIBS "") set(UKUI_NOTIFICATION_PC_PKGS kysdk-applications) foreach(PC_LIB IN ITEMS ${UKUI_NOTIFICATION_PC_PKGS}) pkg_check_modules(${PC_LIB} REQUIRED IMPORTED_TARGET ${PC_LIB}) if(${${PC_LIB}_FOUND}) include_directories(${${PC_LIB}_INCLUDE_DIRS}) link_directories(${${PC_LIB}_LIBRARY_DIRS}) list(APPEND UKUI_NOTIFICATION_EXTERNAL_LIBS ${${PC_LIB}_LIBRARIES}) endif() endforeach() include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) include_directories(../libukui-notification/notification-settings) include_directories(../libukui-notification) file(GLOB TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts) # 更新翻译并创建.qm文件 if(COMMAND qt_create_translation) qt_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) else() qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) endif() add_library(notification-ukcc-plugin SHARED ${notification-ukcc-plugin_LIB_SRCS} ${QM_FILES} ) target_link_libraries(notification-ukcc-plugin PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::DBus Qt${QT_VERSION_MAJOR}::Network ukui-notification ukcc ${UKUI_NOTIFICATION_EXTERNAL_LIBS} ) install(TARGETS notification-ukcc-plugin DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-control-center) install(FILES ${TS_FILES} ${QM_FILES} DESTINATION /usr/share/ukui-notification/notification-ukcc-plugin/translations) ukui-notification/notification-ukcc-plugin/notice-menu.cpp0000664000175000017500000001632015160523746023010 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include "notice-menu.h" #include #include #include NoticeMenu::NoticeMenu(QWidget *parent) : QMenu(parent) { setFixedSize(380, 190); initUi(); setConnect(); } void NoticeMenu::initStatus(UkuiNotification::SingleApplicationSettings *settings) { m_voiceBtn->blockSignals(true); m_showBtn->blockSignals(true); m_detailBtn->blockSignals(true); // m_styleGroup->blockSignals(true); m_voiceBtn->setChecked(settings->allowSound()); m_detailBtn->setChecked(settings->showContentOnLockScreen()); m_showBtn->setChecked(settings->showNotificationOnLockScreen()); // int styleId = 0; // UkuiNotification::SettingsProperty::Property style = settings->popupStyle(); // if (style == UkuiNotification::SettingsProperty::TransientPopup) { // styleId = 0; // } else if (style == UkuiNotification::SettingsProperty::ResidentPopup) { // styleId = 1; // } else if (style == UkuiNotification::SettingsProperty::NoPopup) { // styleId = 2; // } // m_styleGroup->button(styleId)->setChecked(true); m_voiceBtn->blockSignals(false); m_showBtn->blockSignals(false); m_detailBtn->blockSignals(false); // m_styleGroup->blockSignals(false); } void NoticeMenu::setVoiceEnable(bool state) { m_voiceBtn->blockSignals(true); m_voiceBtn->setChecked(state); m_voiceBtn->blockSignals(false); } void NoticeMenu::setDetailShowOnLockScreenEnable(bool state) { m_detailBtn->blockSignals(true); m_detailBtn->setChecked(state); m_detailBtn->blockSignals(false); } void NoticeMenu::setShowOnLockScreenEnable(bool state) { m_showBtn->blockSignals(true); m_showBtn->setChecked(state); m_showBtn->blockSignals(false); } void NoticeMenu::setPopupStyle(UkuiNotification::SettingsProperty::Property style) { Q_UNUSED(style) // int styleId = 0; // if (style == UkuiNotification::SettingsProperty::TransientPopup) { // styleId = 0; // } else if (style == UkuiNotification::SettingsProperty::ResidentPopup) { // styleId = 1; // } else if (style == UkuiNotification::SettingsProperty::NoPopup) { // styleId = 2; // } // m_styleGroup->blockSignals(true); // m_styleGroup->button(styleId)->setChecked(true); // m_styleGroup->blockSignals(false); } void NoticeMenu::initUi() { QVBoxLayout *menuLyt = new QVBoxLayout(this); menuLyt->setSpacing(0); menuLyt->setContentsMargins(8, 0, 8, 0); QFrame *voiceFrame = new QFrame(this); m_voiceBtn = new KSwitchButton; m_voiceBtn->setTranslucent(true); setFrame(voiceFrame, tr("Beep sound when notified"), m_voiceBtn); QFrame *line_1 = setLine(); QFrame *detailFrame = new QFrame(this); m_detailBtn = new KSwitchButton; m_detailBtn->setTranslucent(true); setFrame(detailFrame, tr("Show message on screenlock"), m_detailBtn); QFrame *line_2 = setLine(); QFrame *showFrame = new QFrame(this); m_showBtn = new KSwitchButton; m_showBtn->setTranslucent(true); setFrame(showFrame, tr("Show noticfication on screenlock"), m_showBtn); // QFrame *line_3 = setLine(); // QLabel *styletitleLabel = new QLabel(tr("Notification Style"), this); // styletitleLabel->setContentsMargins(24, 0, 0, 0); // // m_styleGroup = new QButtonGroup(this); // // QFrame *mutativeFrame = new QFrame(this); // m_mutativeBtn = new QRadioButton; // m_styleGroup->addButton(m_mutativeBtn, 0); // setFrame(mutativeFrame, tr("Banner: Appears in the upper right corner of the screen, and disappears automatically"), m_mutativeBtn); // // QFrame *alwaysFrame = new QFrame(this); // m_alwaysBtn = new QRadioButton; // m_styleGroup->addButton(m_alwaysBtn, 1); // setFrame(alwaysFrame, tr("Tip:It will be kept on the screen until it is closed"), m_alwaysBtn); // // QFrame *noneFrame = new QFrame(this); // m_noneBtn = new QRadioButton; // m_styleGroup->addButton(m_noneBtn, 2); // setFrame(noneFrame, tr("None:Notifications will not be displayed on the screen, but will go to the notification center"), m_noneBtn); menuLyt->addWidget(voiceFrame); menuLyt->addWidget(line_1); menuLyt->addWidget(detailFrame); menuLyt->addWidget(line_2); menuLyt->addWidget(showFrame); // menuLyt->addWidget(line_3); menuLyt->addSpacing(16); // menuLyt->addWidget(styletitleLabel); // menuLyt->addWidget(mutativeFrame); // menuLyt->addWidget(alwaysFrame); // menuLyt->addWidget(noneFrame); menuLyt->addStretch(); // 隐藏未实现模块 // voiceFrame->hide(); // line_1->hide(); // detailFrame->hide(); // line_2->hide(); // line_3->hide(); // styletitleLabel->hide(); // mutativeFrame->hide(); // alwaysFrame->hide(); // noneFrame->hide(); // setFixedHeight(60); } void NoticeMenu::setFrame(QFrame *frame, QString str, KSwitchButton *btn) { frame->setFixedHeight(60); frame->setFrameShape(QFrame::NoFrame); QHBoxLayout *hLyt = new QHBoxLayout(frame); hLyt->setContentsMargins(24, 0, 24, 0); hLyt->setSpacing(8); FixLabel *label = new FixLabel(str, frame); label->setFixedWidth(250); hLyt->addWidget(label); hLyt->addStretch(); hLyt->addWidget(btn); } void NoticeMenu::setFrame(QFrame *frame, QString str, QRadioButton *btn) { frame->setFixedHeight(48); frame->setFrameShape(QFrame::NoFrame); QHBoxLayout *hLyt = new QHBoxLayout(frame); hLyt->setContentsMargins(24, 0, 24, 0); FixLabel *label = new FixLabel(str, frame); label->setFixedWidth(288); hLyt->addWidget(btn); hLyt->addWidget(label); hLyt->addStretch(); } QFrame *NoticeMenu::setLine() { QFrame *line = new QFrame(); line->setMinimumSize(QSize(0, 1)); line->setMaximumSize(QSize(16777215, 1)); line->setLineWidth(0); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); return line; } void NoticeMenu::setConnect() { connect(m_voiceBtn, &KSwitchButton::stateChanged, this, &NoticeMenu::voiceSignals); connect(m_detailBtn, &KSwitchButton::stateChanged, this, &NoticeMenu::detailSignals); connect(m_showBtn, &KSwitchButton::stateChanged, this, &NoticeMenu::showSignals); // connect(m_styleGroup, QOverload::of(&QButtonGroup::buttonClicked), this, &NoticeMenu::styleBtnSignals); } void NoticeMenu::showEvent(QShowEvent *event) { int menuXPos = this->pos().x(); int menuWidth = this->size().width()-4; int buttonWidth = 36; QPoint pos = QPoint(menuXPos - menuWidth + buttonWidth, this->pos().y()); this->move(pos); QMenu::showEvent(event); } ukui-notification/notification-ukcc-plugin/notification-ukcc-plugin.cpp0000664000175000017500000007307715160523746025506 0ustar fengfeng /* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include "notification-ukcc-plugin.h" #include "notice-menu.h" #include #include #include #include #include #include "security-control-config.h" #include "utils.h" #include using namespace UkuiNotification; #define THEME_QT_SCHEMA "org.ukui.style" static std::once_flag onceFlag; UkuiSearch::ApplicationInfo& appInfo() { return Utils::applicationInfo(); } class ToolButton : public QToolButton { public: explicit ToolButton(QWidget *parent = nullptr): QToolButton(parent) { } protected: void paintEvent(QPaintEvent *event) override; }; Notice::Notice() { QTranslator* translator = new QTranslator(this); if(!translator->load("/usr/share/ukui-notification/notification-ukcc-plugin/translations/" + QLocale::system().name())) { qWarning() << "/usr/share/ukui-notification/notification-ukcc-plugin/translations/" + QLocale::system().name() << "load failed"; } qApp->installTranslator(translator); m_pluginName = tr("Notice"); m_pluginType = SYSTEM; } Notice::~Notice() { if (m_globalSettings) { delete m_globalSettings; m_globalSettings = nullptr; } } QString Notice::plugini18nName() { return m_pluginName; } int Notice::pluginTypes() { return m_pluginType; } QWidget *Notice::pluginUi() { std::call_once(onceFlag, [ & ] { if (QGSettings::isSchemaInstalled(THEME_QT_SCHEMA)) { QByteArray id(THEME_QT_SCHEMA); m_themeSetting = new QGSettings(id, QByteArray(), this); } if (!m_globalSettings) { m_globalSettings = new NotificationGlobalSettings(); } m_pluginWidget = new QWidget; m_pluginWidget->setAttribute(Qt::WA_DeleteOnClose); initUi(m_pluginWidget); initSearchText(); initNoticeStatus(); initConnection(); initListUI(); }); return m_pluginWidget; } const QString Notice::name() const { return QStringLiteral("Notice"); } QString Notice::translationPath() const { return QStringLiteral("/usr/share/ukui-notification/notification-ukcc-plugin/translations/%1.ts"); } bool Notice::isShowOnHomePage() const { return false; } QIcon Notice::icon() const { return QIcon::fromTheme("ukui-tool-symbolic"); } bool Notice::isEnable() const { return true; } void Notice::initUi(QWidget *widget) { QVBoxLayout *mverticalLayout = new QVBoxLayout(widget); mverticalLayout->setSpacing(0); mverticalLayout->setContentsMargins(0, 0, 0, 0); QFrame *notFazeFrame = new QFrame(widget); initNotFaze(notFazeFrame); QWidget *Noticewidget = new QWidget(widget); Noticewidget->setMinimumSize(QSize(550, 0)); Noticewidget->setMaximumSize(QSize(16777215, 16777215)); QVBoxLayout *NoticeLayout = new QVBoxLayout(Noticewidget); NoticeLayout->setContentsMargins(0, 0, 0, 0); NoticeLayout->setSpacing(8); m_noticeLabel = new TitleLabel(Noticewidget); m_notFazeLabel = new TitleLabel(); //~ contents_path /Notice/Do not disturb mode Mode m_notFazeLabel->setText(tr("Do not disturb mode")); LightLabel *notFazeLabel = new LightLabel(tr("(Notification banners, prompts will be hidden, and notification sounds will be muted)")); QFrame *distrubFrame = new QFrame(widget); distrubFrame->setMinimumWidth(550); distrubFrame->setMaximumWidth(16777215); QHBoxLayout *distrubLyt = new QHBoxLayout(distrubFrame); distrubLyt->setContentsMargins(0, 0, 0, 0); distrubLyt->addWidget(m_notFazeLabel); distrubLyt->addSpacing(4); distrubLyt->addWidget(notFazeLabel, Qt::AlignLeft); m_getNoticeFrame = new QFrame(Noticewidget); m_getNoticeFrame->setMinimumSize(QSize(550, 60)); m_getNoticeFrame->setMaximumSize(QSize(16777215, 60)); m_getNoticeFrame->setFrameShape(QFrame::Box); QHBoxLayout *mGetNoticeLayout = new QHBoxLayout(m_getNoticeFrame); mGetNoticeLayout->setContentsMargins(16,0,16,0); m_getNoticeLabel = new QLabel(m_getNoticeFrame); m_getNoticeLabel->setFixedWidth(550); m_enableSwitchBtn = new KSwitchButton(m_getNoticeFrame); m_enableSwitchBtn->setObjectName("getnoticeinfo"); mGetNoticeLayout->addWidget(m_getNoticeLabel,Qt::AlignLeft); mGetNoticeLayout->addStretch(); mGetNoticeLayout->addWidget(m_enableSwitchBtn); m_noticeAppFrame = new QFrame(Noticewidget); m_noticeAppFrame->setMinimumSize(QSize(550, 0)); m_noticeAppFrame->setMaximumSize(QSize(16777215, 16777215)); m_noticeAppFrame->setFrameShape(QFrame::Box); m_appListVerticalLayout = new QVBoxLayout(m_noticeAppFrame); m_appListVerticalLayout->setContentsMargins(0, 0, 0, 0); m_appListVerticalLayout->setSpacing(0); NoticeLayout->addWidget(m_noticeLabel); NoticeLayout->addWidget(m_getNoticeFrame); NoticeLayout->addWidget(m_noticeAppFrame); NoticeLayout->addStretch(); if (1) { mverticalLayout->addWidget(distrubFrame); mverticalLayout->addSpacing(8); mverticalLayout->addWidget(notFazeFrame); mverticalLayout->addSpacing(32); } else { distrubFrame->hide(); notFazeFrame->hide(); } mverticalLayout->addWidget(Noticewidget); } void Notice::initNotFaze(QFrame *frame) { frame->setMinimumSize(QSize(550, 0)); frame->setMaximumSize(QSize(16777215, 16777215)); frame->setFrameShape(QFrame::Box); QVBoxLayout *notFazeLyt = new QVBoxLayout(frame); notFazeLyt->setContentsMargins(0, 0, 0, 0); notFazeLyt->setSpacing(0); QFrame *line_1 = NoticeMenu::setLine(); QFrame *line_2 = NoticeMenu::setLine(); QFrame *line_3 = NoticeMenu::setLine(); QFrame *autoOpenFrame = new QFrame(frame); autoOpenFrame->setMinimumSize(550, 60); autoOpenFrame->setMaximumSize(16777215, 60); QHBoxLayout *autoLyt = new QHBoxLayout(autoOpenFrame); autoLyt->setContentsMargins(16, 0, 16, 0); //~ contents_path /Notice/Do not disturb mode Mode/Automatically turn on QLabel *autoOpenLabel = new QLabel(tr("Automatically turn on"), autoOpenFrame); m_openTimeHComboBox = new QComboBox(autoOpenFrame); m_openTimeHComboBox->setObjectName("opentimehour"); m_openTimeHComboBox->setFixedWidth(64); m_openTimeMComboBox = new QComboBox(autoOpenFrame); m_openTimeMComboBox->setObjectName("opentimeminute"); m_openTimeMComboBox->setFixedWidth(64); m_closeTimeHComboBox = new QComboBox(autoOpenFrame); m_closeTimeHComboBox->setObjectName("closetimehour"); m_closeTimeHComboBox->setFixedWidth(64); m_closeTimeMComboBox = new QComboBox(autoOpenFrame); m_closeTimeMComboBox->setObjectName("closetimeminute"); m_closeTimeMComboBox->setFixedWidth(64); for (int i = 0; i < 24; i++) { m_openTimeHComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); m_closeTimeHComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); } for (int i = 0; i < 60; i++) { m_openTimeMComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); m_closeTimeMComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); } QLabel * label_1 = new QLabel(autoOpenFrame); label_1->setFixedWidth(20); label_1->setText(tr("to")); QLabel *label_2 = new QLabel(autoOpenFrame); label_2->setFixedWidth(4); label_2->setText(":"); QLabel *label_3 = new QLabel(autoOpenFrame); label_3->setFixedWidth(4); label_3->setText(":"); m_autoOpenSwitchBtn = new KSwitchButton(autoOpenFrame); m_autoOpenSwitchBtn->setObjectName("autoopen"); autoLyt->addWidget(autoOpenLabel); autoLyt->addStretch(); autoLyt->addWidget(m_openTimeHComboBox); autoLyt->addWidget(label_2); autoLyt->addWidget(m_openTimeMComboBox); autoLyt->addWidget(label_1); autoLyt->addWidget(m_closeTimeHComboBox); autoLyt->addWidget(label_3); autoLyt->addWidget(m_closeTimeMComboBox); autoLyt->addSpacing(24); autoLyt->addWidget(m_autoOpenSwitchBtn); QFrame *multiScreenFrame = new QFrame(frame); m_multiScreenSwitchBtn= new KSwitchButton(); m_multiScreenSwitchBtn->setObjectName("multiscreen"); //~ contents_path /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected setFrame(multiScreenFrame, m_multiScreenSwitchBtn, tr("Automatically turn on when multiple screens are connected")); QFrame *fullScreenFrame = new QFrame(frame); m_fullScreenSwitchBtn= new KSwitchButton(); m_fullScreenSwitchBtn->setObjectName("fullscreen"); //~ contents_path /Notice/Do not disturb mode/Automatically open in full screen mode setFrame(fullScreenFrame, m_fullScreenSwitchBtn, tr("Automatically open in full screen mode")); QFrame *allowAlarmrRemindersFrame = new QFrame(frame); m_allowAlarmSwitchBtn= new KSwitchButton(); m_allowAlarmSwitchBtn->setObjectName("allowAlarmr"); //~ contents_path /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode setFrame(allowAlarmrRemindersFrame, m_allowAlarmSwitchBtn, tr("Allow automatic alarm reminders in Do Not Disturb mode")); notFazeLyt->addWidget(autoOpenFrame); notFazeLyt->addWidget(line_1); notFazeLyt->addWidget(multiScreenFrame); notFazeLyt->addWidget(line_2); notFazeLyt->addWidget(fullScreenFrame); notFazeLyt->addWidget(line_3); notFazeLyt->addWidget(allowAlarmrRemindersFrame); } void Notice::setFrame(QFrame *frame, KSwitchButton *btn, QString str) { frame->setMinimumSize(QSize(550, 60)); frame->setMaximumSize(QSize(16777215, 60)); frame->setFrameShape(QFrame::NoFrame); QHBoxLayout *hLyt = new QHBoxLayout(frame); hLyt->setContentsMargins(16, 0, 16, 0); QLabel *label = new QLabel(str, frame); hLyt->addWidget(label); hLyt->addStretch(); hLyt->addWidget(btn); } void Notice::initSearchText() { m_noticeLabel->setText(tr("Notice Settings")); //~ contents_path /notice/Get notifications from the app m_getNoticeLabel->setText(tr("Get notifications from the app")); } void Notice::initConnection() { if (m_globalSettings) { connect(m_openTimeHComboBox, &QComboBox::currentTextChanged, this, [&](const QString &text){ //Utils::buriedSettings(name(), "open time(hour) when auto turn on do not disturb mode", QString("settings"), text); m_globalSettings->setScheduleTurnOnDNDTime(QTime::fromString(text + ":" + m_openTimeMComboBox->currentText(), "hh:mm")); }); connect(m_openTimeMComboBox, &QComboBox::currentTextChanged, this, [&](const QString &text){ //Utils::buriedSettings(name(), "open time(minute) when auto turn on do not disturb mode", QString("settings"), m_openTimeMCombox->currentText()); m_globalSettings->setScheduleTurnOnDNDTime(QTime::fromString(text + ":" + m_openTimeHComboBox->currentText(), "mm:hh")); }); connect(m_closeTimeHComboBox, &QComboBox::currentTextChanged, this, [&](const QString &text){ //Utils::buriedSettings(name(), "close time(hour) when auto turn on do not disturb mode", QString("settings"), m_closeTimeMCombox->currentText()); m_globalSettings->setScheduleTurnOffDNDTime(QTime::fromString(text + ":" + m_closeTimeMComboBox->currentText(), "hh:mm")); }); connect(m_closeTimeMComboBox, &QComboBox::currentTextChanged, this, [&](const QString &text){ //Utils::buriedSettings(name(), "close time(minute) when auto turn on do not disturb mode", QString("settings"), m_closeTimeMCombox->currentText()); m_globalSettings->setScheduleTurnOffDNDTime(QTime::fromString(text + ":" + m_closeTimeHComboBox->currentText(), "mm:hh")); }); connect(m_autoOpenSwitchBtn, &KSwitchButton::stateChanged, [&](bool state) { //Utils::buriedSettings(name(), "whether auto turn on do not disturb mode", QString("settings"), state ? "true" : "false"); m_globalSettings->setScheduleTurnOnDND(state); setComBoxStatus(state); }); connect(m_multiScreenSwitchBtn, &KSwitchButton::stateChanged, [&](bool state) { //Utils::buriedSettings(name(), "whether auto turn on do not disturb mode", QString("settings"), state ? "true" : "false"); m_globalSettings->setDNDWhileMultiScreen(state); }); connect(m_fullScreenSwitchBtn, &KSwitchButton::stateChanged, [&](bool state) { //Utils::buriedSettings(name(), "whether auto turn on do not disturb mode", QString("settings"), state ? "true" : "false"); m_globalSettings->setDNDWhileFullScreen(state); }); connect(m_allowAlarmSwitchBtn, &KSwitchButton::stateChanged, [&](bool state) { //Utils::buriedSettings(name(), "whether auto turn on do not disturb mode", QString("settings"), state ? "true" : "false"); m_globalSettings->setNotifyAlarmWhileDND(state); }); connect(m_enableSwitchBtn, &KSwitchButton::stateChanged, [&](bool state){ //Utils::buriedSettings(name(), "whether to get the notification from the app", QString("settings"), state ? "true" : "false"); if (SecurityControlConfig::instance().isNotificationEnable()) { m_globalSettings->setReceiveNotificationsFromApps(state); } setHiddenNoticeApp(state); }); connect(m_globalSettings, &NotificationGlobalSettings::scheduleTurnOnDNDChanged, this, [&](bool state) { m_autoOpenSwitchBtn->blockSignals(true); m_autoOpenSwitchBtn->setChecked(state); m_autoOpenSwitchBtn->blockSignals(false); setComBoxStatus(state); }); connect(m_globalSettings, &NotificationGlobalSettings::scheduleTurnOnDNDTimeChanged, this, [&](QTime time) { m_openTimeHComboBox->blockSignals(true); m_openTimeHComboBox->setCurrentText(time.toString("hh")); m_openTimeHComboBox->blockSignals(false); m_openTimeMComboBox->blockSignals(true); m_openTimeMComboBox->setCurrentText(time.toString("mm")); m_openTimeMComboBox->blockSignals(false); }); connect(m_globalSettings, &NotificationGlobalSettings::scheduleTurnOffDNDTimeChanged, this, [&](QTime time) { m_closeTimeHComboBox->blockSignals(true); m_closeTimeHComboBox->setCurrentText(time.toString("hh")); m_closeTimeHComboBox->blockSignals(false); m_closeTimeMComboBox->blockSignals(true); m_closeTimeMComboBox->setCurrentText(time.toString("mm")); m_closeTimeMComboBox->blockSignals(false); }); connect(m_globalSettings, &NotificationGlobalSettings::DNDWhileMultiScreenChanged, this, [&](bool state) { m_multiScreenSwitchBtn->blockSignals(true); m_multiScreenSwitchBtn->setChecked(state); m_multiScreenSwitchBtn->blockSignals(false); }); connect(m_globalSettings, &NotificationGlobalSettings::DNDWhileFullScreenChanged, this, [&](bool state) { m_fullScreenSwitchBtn->blockSignals(true); m_fullScreenSwitchBtn->setChecked(state); m_fullScreenSwitchBtn->blockSignals(false); }); connect(m_globalSettings, &NotificationGlobalSettings::notifyAlarmWhileDNDChanged, this, [&](bool state) { m_allowAlarmSwitchBtn->blockSignals(true); m_allowAlarmSwitchBtn->setChecked(state); m_allowAlarmSwitchBtn->blockSignals(false); }); connect(m_globalSettings, &NotificationGlobalSettings::receiveNotificationsFromAppsChanged, this, [&](bool state) { m_enableSwitchBtn->blockSignals(true); m_enableSwitchBtn->setChecked(state); m_enableSwitchBtn->blockSignals(false); setHiddenNoticeApp(state); }); } connect(&SecurityControlConfig::instance(), &SecurityControlConfig::configChanged, this, [&] { bool enableNotification = SecurityControlConfig::instance().isNotificationEnable(); qDebug() << "Security config changed, enable notification" << enableNotification; if (!enableNotification) { m_enableSwitchBtn->blockSignals(true); m_enableSwitchBtn->setChecked(enableNotification); m_enableSwitchBtn->blockSignals(false); m_enableSwitchBtn->setEnabled(enableNotification); setHiddenNoticeApp(enableNotification); } }); connect(&SecurityControlConfig::instance(), &SecurityControlConfig::exitControl, this, [&] { bool state = m_globalSettings->receiveNotificationsFromApps(); qDebug() << "Exit control, reset state" << state; m_enableSwitchBtn->setEnabled(true); m_enableSwitchBtn->blockSignals(true); m_enableSwitchBtn->setChecked(state); m_enableSwitchBtn->blockSignals(false); setHiddenNoticeApp(state); }); } void Notice::initNoticeStatus() { if (m_globalSettings) { m_autoOpenSwitchBtn->blockSignals(true); m_autoOpenSwitchBtn->setChecked(m_globalSettings->scheduleTurnOnDND()); setComBoxStatus(m_autoOpenSwitchBtn->isChecked()); m_autoOpenSwitchBtn->blockSignals(false); QTime openTime = m_globalSettings->scheduleTurnOnDNDTime(); m_openTimeHComboBox->blockSignals(true); m_openTimeHComboBox->setCurrentText(openTime.toString("hh")); m_openTimeHComboBox->blockSignals(false); m_openTimeMComboBox->blockSignals(true); m_openTimeMComboBox->setCurrentText(openTime.toString("mm")); m_openTimeMComboBox->blockSignals(false); QTime closeTime = m_globalSettings->scheduleTurnOffDNDTime(); m_closeTimeHComboBox->blockSignals(true); m_closeTimeHComboBox->setCurrentText(closeTime.toString("hh")); m_closeTimeHComboBox->blockSignals(false); m_closeTimeMComboBox->blockSignals(true); m_closeTimeMComboBox->setCurrentText(closeTime.toString("mm")); m_closeTimeMComboBox->blockSignals(false); m_multiScreenSwitchBtn->blockSignals(true); m_multiScreenSwitchBtn->setChecked(m_globalSettings->DNDWhileMultiScreen()); m_multiScreenSwitchBtn->blockSignals(false); m_fullScreenSwitchBtn->blockSignals(true); m_fullScreenSwitchBtn->setChecked(m_globalSettings->DNDWhileFullScreen()); m_fullScreenSwitchBtn->blockSignals(false); m_allowAlarmSwitchBtn->blockSignals(true); m_allowAlarmSwitchBtn->setChecked(m_globalSettings->notifyAlarmWhileDND()); m_allowAlarmSwitchBtn->blockSignals(false); m_enableSwitchBtn->blockSignals(true); m_enableSwitchBtn->setChecked(SecurityControlConfig::instance().isNotificationEnable() && m_globalSettings->receiveNotificationsFromApps()); m_enableSwitchBtn->blockSignals(false); m_enableSwitchBtn->setEnabled(SecurityControlConfig::instance().isNotificationEnable()); } setHiddenNoticeApp(m_enableSwitchBtn->isChecked()); } void Notice::initListUI() { const UkuiSearch::ApplicationProperties& properties = { UkuiSearch::ApplicationProperty::LocalName, UkuiSearch::ApplicationProperty::Icon }; connect(this, &Notice::appDataInfo, this, &Notice::addItemUi, Qt::QueuedConnection); (void)QtConcurrent::run([=](){ auto convertAppinfoMap = [](const UkuiSearch::ApplicationInfoMap& appInfoMap) -> UkuiSearch::ApplicationInfoMap { //全路径desktop map, 转换为desktop文件名的 map UkuiSearch::ApplicationInfoMap newAppInfoMap; for (auto it = appInfoMap.begin(); it != appInfoMap.end(); ++it) { QString newKey = Utils::desktopEntry2Name(it.key()); if (!newAppInfoMap.contains(newKey)) { newAppInfoMap.insert(newKey, it.value()); } } return newAppInfoMap; }; const UkuiSearch::ApplicationInfoMap& appInfoMap = appInfo().getInfo(properties); Q_EMIT appDataInfo(convertAppinfoMap(appInfoMap)); }); connect(ApplicationsSettings::self(), &ApplicationsSettings::applicationInstalled, this, [=](const QString &appDesktopName){ const UkuiSearch::ApplicationProperties& properties = { UkuiSearch::ApplicationProperty::LocalName, UkuiSearch::ApplicationProperty::Icon }; (void)QtConcurrent::run([=](){ UkuiSearch::ApplicationPropertyMap dataMap = appInfo().getInfo(Utils::desktopEntryFromName(appDesktopName) , properties); UkuiSearch::ApplicationInfoMap appInfoMap = {{appDesktopName, dataMap}}; Q_EMIT appDataInfo(appInfoMap); }); }); } void Notice::addItemUi(const UkuiSearch::ApplicationInfoMap &appInfoMap) { if (appInfoMap.count() == 1) { QString desktopEntry = appInfoMap.keys().at(0); UkuiSearch::ApplicationPropertyMap dataMap = appInfoMap.value(desktopEntry); if (!m_appList.contains(desktopEntry)) { initItemUi(desktopEntry, dataMap, ApplicationsSettings::self()->creatSettings(desktopEntry)); m_appList.append(desktopEntry); } } else { ApplicationsSettingsMap dataMap = ApplicationsSettings::self()->getAllApplicationsSettings(); ApplicationsSettingsMap::const_iterator i = dataMap.constBegin(); m_appList.clear(); while(i != dataMap.constEnd()) { const QString& desktopPath = i.key(); if (appInfoMap.contains(desktopPath)) { initItemUi(desktopPath, appInfoMap[desktopPath], i.value()); m_appList.append(desktopPath); } else { qWarning() << "Can't find application info for: " << desktopPath; } ++i; } } } void Notice::initItemUi(const QString &desktopPath, const UkuiSearch::ApplicationPropertyMap& properties, SingleApplicationSettings *settings) { QString localName = properties[UkuiSearch::ApplicationProperty::LocalName].toString(); QString iconName = properties[UkuiSearch::ApplicationProperty::Icon].toString(); QString fileName = desktopPath.left(desktopPath.indexOf(QLatin1Char('.'))); QFrame *baseWidget = new QFrame(m_noticeAppFrame); baseWidget->setMinimumWidth(550); baseWidget->setMaximumWidth(16777215); baseWidget->setFixedHeight(60); baseWidget->setFrameShape(QFrame::Shape::NoFrame); baseWidget->setAttribute(Qt::WA_DeleteOnClose); QLabel *iconLabel = new QLabel(baseWidget); iconLabel->setFixedSize(32, 32); setAppIcon(iconLabel, iconName); connect(m_themeSetting, &QGSettings::changed, [&, iconLabel, iconName](const QString &key){ if (key == "iconThemeName") setAppIcon(iconLabel, iconName); }); QHBoxLayout *devHorLayout = new QHBoxLayout(baseWidget); devHorLayout->setSpacing(8); devHorLayout->setContentsMargins(16, 0, 16, 0); QLabel *nameLabel = new QLabel(baseWidget); nameLabel->setText(localName); ToolButton *setBtn = new ToolButton(baseWidget); setBtn->setProperty("useButtonPalette", true); setBtn->setPopupMode(QToolButton::InstantPopup); setBtn->setAutoRaise(true); setBtn->setFixedSize(QSize(36, 36)); setBtn->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic")); NoticeMenu *menu = new NoticeMenu(setBtn); setBtn->setMenu(menu); KSwitchButton *appSwitch = new KSwitchButton(baseWidget); devHorLayout->addWidget(iconLabel); devHorLayout->addWidget(nameLabel); devHorLayout->addStretch(); devHorLayout->addWidget(setBtn); devHorLayout->addWidget(appSwitch); m_appListVerticalLayout->addWidget(baseWidget); if (m_appListVerticalLayout->count() >= 2) { QFrame *line = new QFrame(m_pluginWidget); line->setMinimumSize(QSize(0, 1)); line->setMaximumSize(QSize(16777215, 1)); line->setLineWidth(0); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); m_appListVerticalLayout->insertWidget(m_appListVerticalLayout->count() - 1, line); } appSwitch->blockSignals(true); appSwitch->setChecked(settings->allowNotify()); appSwitch->blockSignals(false); menu->blockSignals(true); menu->initStatus(settings); menu->blockSignals(false); connect(appSwitch, &KSwitchButton::stateChanged, [=](bool state) { //Utils::buriedSettings(name(), "whether auto turn on do not disturb mode", QString("settings"), state ? "true" : "false"); ApplicationsSettings::self()->setAppSetting(desktopPath, SettingsProperty::AllowNotify, state); }); connect(settings, &SingleApplicationSettings::allowNotifyChanged, [=](bool state) { appSwitch->blockSignals(true); appSwitch->setChecked(state); appSwitch->blockSignals(false); }); connect(settings, &SingleApplicationSettings::allowSoundChanged, [=](bool state) { menu->blockSignals(true); menu->setVoiceEnable(state); menu->blockSignals(false); }); connect(settings, &SingleApplicationSettings::showContentOnLockScreenChanged, [=](bool state) { menu->blockSignals(true); menu->setDetailShowOnLockScreenEnable(state); menu->blockSignals(false); }); connect(settings, &SingleApplicationSettings::showNotificationOnLockScreenChanged, [=](bool state) { menu->blockSignals(true); menu->setShowOnLockScreenEnable(state); menu->blockSignals(false); }); connect(settings, &SingleApplicationSettings::popupStyleChanged, [=](SettingsProperty::Property style) { menu->blockSignals(true); menu->setPopupStyle(style); menu->blockSignals(false); }); connect(settings, &SingleApplicationSettings::uninstalled, [=]() { for (int i = 0; i < m_appList.length(); i++) { if (desktopPath == m_appList.at(i)) { m_appList.removeAt(i); if (i == 0) { removeLayoutItem(i); removeLayoutItem(i); } else { removeLayoutItem(i * 2 - 1); removeLayoutItem(i * 2 - 1); } } } }); connect(menu, &NoticeMenu::voiceSignals, [=](bool checked) { //Common::buriedSettings(name(), "whether prompt sound during notification", QString("settings"), checked ? "true" : "false"); ApplicationsSettings::self()->setAppSetting(desktopPath, SettingsProperty::AllowSound, checked); }); connect(menu, &NoticeMenu::detailSignals, [=](bool checked) { //Common::buriedSettings(name(), "whether to show the message content in the lock screen interface", QString("settings"), checked ? "true" : "false"); ApplicationsSettings::self()->setAppSetting(desktopPath, SettingsProperty::ShowContentOnLockScreen, checked); }); connect(menu, &NoticeMenu::showSignals, [=](bool checked) { //Common::buriedSettings(name(), "whether to show the notice in the lock screen interface", QString("settings"), checked ? "true" : "false"); ApplicationsSettings::self()->setAppSetting(desktopPath, SettingsProperty::ShowNotificationOnLockScreen, checked); }); // connect(menu, &NoticeMenu::styleBtnSignals, [=](int id) { // QString str("mutative"); // SettingsProperty::Property style = SettingsProperty::TransientPopup; // if (id == 0) { // str = "mutative"; // style = SettingsProperty::TransientPopup; // } else if (id == 1) { // str = "always"; // style = SettingsProperty::ResidentPopup; // } else if (id == 2) { // str = "none"; // style = SettingsProperty::NoPopup; // } // //Common::buriedSettings(name(), "set notice style", QString("settings"), str); // ApplicationsSettings::self()->setAppSetting(desktopPath, SettingsProperty::PopupStyle, style); // }); } void Notice::setAppIcon(QLabel *iconlabel, const QString &icon) { QFileInfo iconFile(QString("/usr/share/pixmaps/" + icon + ".png")); QPixmap pixmap; QIcon currentIcon = QIcon::fromTheme(icon); if (!currentIcon.isNull()) { pixmap = currentIcon.pixmap(QSize(32, 32)); } else if (iconFile.exists()) { pixmap = QPixmap(iconFile.filePath()).scaled(32, 32); } else { pixmap = QPixmap(QString(":/img/plugins/autoboot/desktop.png")); } iconlabel->setPixmap(pixmap); } void Notice::setHiddenNoticeApp(bool status) { m_noticeAppFrame->setVisible(status); } void Notice::setComBoxStatus(bool status) { m_openTimeHComboBox->setEnabled(status); m_closeTimeHComboBox->setEnabled(status); m_openTimeMComboBox->setEnabled(status); m_closeTimeMComboBox->setEnabled(status); } void Notice::removeLayoutItem(int i) { if ((i >= 0)&&(m_appListVerticalLayout->count() > i)) { QWidget* widget = m_appListVerticalLayout->itemAt(i)->widget(); if (widget) { m_appListVerticalLayout->removeWidget(widget); widget->deleteLater(); } } } void ToolButton::paintEvent(QPaintEvent *event) { QPalette palette; palette.setColor(QPalette::Button, palette.base().color()); this->setPalette(palette); QToolButton::paintEvent(event); } ukui-notification/notification-ukcc-plugin/notification-ukcc-plugin.h0000664000175000017500000000652515160523734025142 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef NOTIFICATION_UKCC_PLUGIN_H #define NOTIFICATION_UKCC_PLUGIN_H #include #include #include #include #include #include #include #include "applications-settings.h" #include "notification-global-settings.h" using namespace kdk; class Notice : public QObject, CommonInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface") Q_INTERFACES(CommonInterface) public: Notice(); ~Notice(); QString plugini18nName() Q_DECL_OVERRIDE; int pluginTypes() Q_DECL_OVERRIDE; QWidget * pluginUi() Q_DECL_OVERRIDE; const QString name() const Q_DECL_OVERRIDE; QString translationPath() const override; bool isShowOnHomePage() const Q_DECL_OVERRIDE; QIcon icon() const Q_DECL_OVERRIDE; bool isEnable() const Q_DECL_OVERRIDE; void initUi(QWidget *widget); void initNotFaze(QFrame *frame); void setFrame(QFrame *frame, KSwitchButton *btn, QString str); void initSearchText(); void initConnection(); void initNoticeStatus(); void initListUI(); void addItemUi(const UkuiSearch::ApplicationInfoMap& appInfoMap); void initItemUi(const QString &desktopPath, const UkuiSearch::ApplicationPropertyMap& properties, UkuiNotification::SingleApplicationSettings *settings); void setAppIcon(QLabel *iconlabel, const QString &icon); Q_SIGNALS: void appDataInfo(const UkuiSearch::ApplicationInfoMap&); private: void setHiddenNoticeApp(bool status); void setComBoxStatus(bool status); void removeLayoutItem(int i); private: QString m_pluginName; int m_pluginType; QVector m_appList; QWidget *m_pluginWidget = nullptr; TitleLabel *m_noticeLabel = nullptr; TitleLabel *m_notFazeLabel = nullptr; QLabel *m_getNoticeLabel = nullptr; QFrame *m_noticeAppFrame = nullptr; QFrame *m_getNoticeFrame = nullptr; KSwitchButton *m_autoOpenSwitchBtn = nullptr; KSwitchButton *m_multiScreenSwitchBtn = nullptr; KSwitchButton *m_fullScreenSwitchBtn = nullptr; KSwitchButton *m_allowAlarmSwitchBtn = nullptr; KSwitchButton *m_enableSwitchBtn = nullptr; QComboBox *m_openTimeHComboBox = nullptr; QComboBox *m_openTimeMComboBox = nullptr; QComboBox *m_closeTimeHComboBox = nullptr; QComboBox *m_closeTimeMComboBox = nullptr; QGSettings *m_themeSetting = nullptr; QVBoxLayout *m_appListVerticalLayout = nullptr; UkuiNotification::NotificationGlobalSettings *m_globalSettings = nullptr; }; #endif // NOTIFICATION_UKCC_PLUGIN_H ukui-notification/README.en.md0000664000175000017500000000007015160523734015024 0ustar fengfeng# ukui-notification #### Description ukui-notification ukui-notification/notification-server/0000775000175000017500000000000015160523746017144 5ustar fengfengukui-notification/notification-server/translations/0000775000175000017500000000000015160523746021665 5ustar fengfengukui-notification/notification-server/translations/de.ts0000664000175000017500000000232215160523734022621 0ustar fengfeng NotificationControlRegister System notification System-Benachrichtigungen Whether to allow "%1" to send system notifications Gibt an, ob '%1' das Senden von Systembenachrichtigungen zugelassen werden soll If not, you will no longer receive any prompt messages from the app Wenn nicht, erhalten Sie keine Eingabeaufforderungen mehr von der App Disallow Unstatthaft Allow erlauben NotificationServer::NotificationServerApplication Quit notification server Opt-out vom Benachrichtigungsdienst ukui-notification/notification-server/translations/ky.ts0000664000175000017500000000211415160523746022656 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow جول قويما Allow ۇرۇقسات NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/zh_CN.ts0000664000175000017500000000216715160523734023241 0ustar fengfeng NotificationControlRegister System notification 系统通知 Whether to allow "%1" to send system notifications 是否允许“%1”发送系统通知 If not, you will no longer receive any prompt messages from the app 若不允许,将不再接收该应用的任何提示消息 Disallow 不允许 Allow 允许 NotificationServer::NotificationServerApplication Quit notification server 退出通知服务 ukui-notification/notification-server/translations/kk.ts0000664000175000017500000000211615160523746022642 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow جول قويما Allow ماقۇلداۋ NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/ar.ts0000664000175000017500000000212115160523746022633 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow Allow NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/ug.ts0000664000175000017500000000211415160523746022646 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow يول قويما Allow ئىجازەت NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/bo_CN.ts0000664000175000017500000000212415160523746023214 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow Allow ཆོག་པ་ NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/vi.ts0000664000175000017500000000212115160523746022647 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow Allow NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/mn.ts0000664000175000017500000000214015160523746022644 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow Allow ᠵᠥᠪᠰᠢᠶᠡᠷᠡᠬᠦ NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/fr.ts0000664000175000017500000000234515160523734022645 0ustar fengfeng NotificationControlRegister System notification Notifications système Whether to allow "%1" to send system notifications S’il faut autoriser ' %1' pour envoyer des notifications système If not, you will no longer receive any prompt messages from the app Si ce n’est pas le cas, vous ne recevrez plus de messages d’invite de l’application Disallow Non autorisé Allow permettre NotificationServer::NotificationServerApplication Quit notification server Désactivation du service de notification ukui-notification/notification-server/translations/en_US.ts0000664000175000017500000000212415160523734023242 0ustar fengfeng NotificationControlRegister System notification Whether to allow "%1" to send system notifications If not, you will no longer receive any prompt messages from the app Disallow Allow NotificationServer::NotificationServerApplication Quit notification server ukui-notification/notification-server/translations/es.ts0000664000175000017500000000233115160523734022640 0ustar fengfeng NotificationControlRegister System notification Notificaciones del sistema Whether to allow "%1" to send system notifications Si se debe permitir que '%1' envíe notificaciones del sistema If not, you will no longer receive any prompt messages from the app De lo contrario, ya no recibirá ningún mensaje de aviso de la aplicación Disallow No permitido Allow conceder NotificationServer::NotificationServerApplication Quit notification server Exclusión voluntaria del servicio de notificación ukui-notification/notification-server/translations/zh_HK.ts0000664000175000017500000000217015160523734023235 0ustar fengfeng NotificationControlRegister System notification 系統通知 Whether to allow "%1" to send system notifications 是否允許「%1」 發送系統通知 If not, you will no longer receive any prompt messages from the app 若不允許,將不再接收該應用的任何提示消息 Disallow 不允許 Allow 允許 NotificationServer::NotificationServerApplication Quit notification server 退出通知服務 ukui-notification/notification-server/server.cpp0000664000175000017500000002527315160523746021167 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include #include #include "server.h" #include "server-private.h" #include "notificationsadaptor.h" #include "notificationserveradaptor.h" #include "notificationsettingsadaptor.h" #include "notification-server-config.h" #include "utils.h" #include "notification-close-reason.h" #include "notification-settings/settings-manager.h" #include "notification-manager.h" #include "security-control-config.h" using namespace NotificationServer; using namespace UkuiNotification; ServerPrivate::ServerPrivate(QObject *parent) : QObject(parent) , m_notificationWatchers(new QDBusServiceWatcher(this)) , m_notificationControlRegister(new NotificationControlRegister) , m_notificationDefaultDirWatcher(new NotificationDefaultDirWatcher(m_notificationControlRegister, this)) , m_notificationSettingsQuery(new NotificaitonSettingsQuery(this)) { SecurityControlConfig::instance(); m_notificationWatchers->setConnection(QDBusConnection::sessionBus()); m_notificationWatchers->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); connect(m_notificationWatchers, &QDBusServiceWatcher::serviceUnregistered, m_notificationWatchers, &QDBusServiceWatcher::removeWatchedService); connect(this, &ServerPrivate::NotificationClosed, &NotificationManager::self() ,&NotificationManager::onNotificationClosed); connect(m_notificationSettingsQuery, &NotificaitonSettingsQuery::alarmSoundAllowedChanged, this, &ServerPrivate::AlarmSoundAllowedChanged); } ServerPrivate::~ServerPrivate() = default; QStringList ServerPrivate::GetCapabilities() const { return QStringList(); } uint ServerPrivate::Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout) { if (!SecurityControlConfig::instance().isNotificationEnable()) { qWarning() << "Under security control! All notifications are disabled now!"; return 0; } uint id = 0; if(replaces_id > 0) { id = replaces_id; } else { id = m_increasedNotificationId++; } QVariantMap newHints = hints; newHints.insert(QStringLiteral("x-ukui-createdTime"), QDateTime::currentDateTime().toString()); uint pid = 0; if (calledFromDBus()) { QDBusReply pidReply = connection().interface()->servicePid(message().service()); if(pidReply.isValid()) { pid = pidReply.value(); } } if (newHints.value(QStringLiteral("x-ukui-display")).toString().isEmpty() && pid > 0) { newHints.insert(QStringLiteral("x-ukui-display"), UkuiNotification::Utils::displayFromPid(pid)); } QString desktopEntry = newHints.value(QStringLiteral("desktop-entry")).toString(); const QString& checkDesktopEntry = UkuiNotification::Utils::desktopEntryFromName(desktopEntry); if (!checkDesktopEntry.isEmpty()) { desktopEntry = UkuiNotification::Utils::desktopEntry2Name(checkDesktopEntry); } if (desktopEntry.isEmpty() && pid > 0) { qInfo() << "check desktop from name failed, try from pid" << pid; desktopEntry = UkuiNotification::Utils::desktopEntryFromPid(pid); } newHints.insert(QStringLiteral("desktop-entry"), desktopEntry); qDebug() << "New message received:" << app_name << id << app_icon << summary << body << actions << hints << timeout << "new hints" << newHints; //APP 第一次发送通知,注册到控制面板管控 if (calledFromDBus()) { if (desktopEntry.isEmpty()) { qWarning() << "Failed to retrieve desktop file" << app_name << pid; } //非dbus调用发送的通知不进行注册 m_notificationControlRegister->registerNotificationControl(desktopEntry); } if (m_notificationWatchers->watchedServices().isEmpty()) { NotificationPtr notification = std::make_shared(); notification->setAppName(app_name); notification->setId(id); notification->setAppIcon(app_icon); notification->setSummary(summary); notification->setBody(body); notification->setActions(actions); notification->setHints(newHints); notification->setTimeout(timeout); m_notificationsCache.insert(id, notification); return id; } for(const QString &service : m_notificationWatchers->watchedServices()) { QDBusMessage msg = QDBusMessage::createMethodCall(service, QStringLiteral("/NotificationClient"), QStringLiteral("org.ukui.NotificationClient"), QStringLiteral("Notify")); msg.setArguments({app_name, id, app_icon, summary, body, actions, newHints, timeout}); QDBusConnection::sessionBus().call(msg, QDBus::NoBlock); } return id; } QString ServerPrivate::GetServerInformation(QString &vendor, QString &version, QString &spec_version) const { vendor = QStringLiteral("Kylin"); version = QLatin1String(NOTIFICATION_SERVER_VERSION); spec_version = QStringLiteral("1.2"); return QStringLiteral("UKUI"); } void ServerPrivate::CloseNotification(uint id) { if(m_notificationsCache.contains(id)) { m_notificationsCache.remove(id); } qDebug() << "CloseNotification(Revoked)" << id; Q_EMIT NotificationClosed(id, UkuiNotification::NotificationCloseReason::Revoked); } bool ServerPrivate::init() { new NotificationsAdaptor(this); new NotificationServerAdaptor(this); new NotificationSettingsAdaptor(this); QDBusConnection conn = QDBusConnection::sessionBus(); if(!conn.registerObject(notificationServicePath(), this)) { qWarning() << "Failed to register Notification DBus object!" << conn.lastError().message(); return false; } auto registration = conn.interface()->registerService(notificationServiceName(), QDBusConnectionInterface::ReplaceExistingService, QDBusConnectionInterface::DontAllowReplacement); if (registration.value() != QDBusConnectionInterface::ServiceRegistered) { qWarning() << "Failed to register Notification service on DBus!"; return false; } UkuiNotification::SettingsManager::self(); return true; } QString ServerPrivate::notificationServiceName() { return QStringLiteral("org.freedesktop.Notifications"); } QString ServerPrivate::notificationServicePath() { return QStringLiteral("/org/freedesktop/Notifications"); } QString ServerPrivate::notificationServiceInterface() { return QStringLiteral("org.freedesktop.Notifications");; } void ServerPrivate::RegisterClient() { m_notificationWatchers->addWatchedService(message().service()); qDebug() << "Watched services:" << m_notificationWatchers->watchedServices(); sendCache(); } void ServerPrivate::UnRegisterClient() { m_notificationWatchers->removeWatchedService(message().service()); } void ServerPrivate::CloseNotification(uint id, uint reason) { if(m_notificationsCache.contains(id)) { m_notificationsCache.remove(id); } qDebug() << "CloseNotification" << id << reason; Q_EMIT NotificationClosed(id, reason); } void ServerPrivate::InvokeAction(uint id, const QString &action_key) { NotificationManager::self().invokedAction(id, action_key); qDebug() << "InvokeAction" << id << action_key; Q_EMIT ActionInvoked(id, action_key); } void ServerPrivate::sendCache() { for(const uint &id : m_notificationsCache.keys()) { auto notification = m_notificationsCache.take(id); for(const QString &service : m_notificationWatchers->watchedServices()) { QDBusMessage msg = QDBusMessage::createMethodCall(service, QStringLiteral("/NotificationClient"), QStringLiteral("org.ukui.NotificationClient"), QStringLiteral("Notify")); msg.setArguments({notification->appName(), notification->id(), notification->appIcon(), notification->summary(), notification->body(), notification->actions(), notification->hints(), notification->timeout()}); QDBusConnection::sessionBus().call(msg, QDBus::NoBlock); } } } void ServerPrivate::UpdateUnreadMessagesNumber(const QString &desktopEntry, uint number) { Q_EMIT UnreadMessagesNumberUpdated(desktopEntry, number); } void ServerPrivate::RegisterNotificationControl(const QString &desktopEntry) { if (UkuiNotification::Utils::desktopEntryFromName(desktopEntry).isEmpty()) { qWarning() << "RegisterNotificationControl failed: " << desktopEntry << "is illegal."; return; } m_notificationControlRegister->registerNotificationControl(desktopEntry, NotificationControlRegister::RegisterMode::Interface); } bool ServerPrivate::IsAlarmSoundAllowed() { return m_notificationSettingsQuery->isAlarmSoundAllowed(); } bool ServerPrivate::IsSoundAllowed(const QString& desktopEntry) { return m_notificationSettingsQuery->isSoundAllowed(desktopEntry); } Server::Server(QObject *parent): QObject(parent), d(new ServerPrivate(this)) { } Server &Server::self() { static Server self; return self; } bool Server::init() { return d->init(); } uint Server::notify(NotificationPtr notification) { return d->Notify(notification->appName(), notification->replaceId(), notification->appIcon(), notification->summary(), notification->body(), notification->actions(), notification->hints(), notification->timeout()); } void Server::closeNotification(uint id) { d->CloseNotification(id); } Server::~Server() = default; ukui-notification/notification-server/notification-server-application.cpp0000664000175000017500000000535215160523734026145 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include #include #include #include "notification-server-application.h" #include #include #include "notification-server-config.h" #include "server.h" using namespace NotificationServer; NotificationServerApplication::NotificationServerApplication(int &argc, char **argv, const QString &applicationName) : QtSingleCoreApplication(applicationName, argc, argv) { setApplicationVersion(NOTIFICATION_SERVER_VERSION); qApp->setProperty("IS_UKUI_NOTIFICATION_SERVER", QVariant(true)); if (!this->isRunning()) { connect(this, &QtSingleCoreApplication::messageReceived, [=](QString msg) { this->parseCmd(msg, true); }); Server::self().init(); installQTranslator(); } parseCmd(arguments().join(" ").toUtf8(), !isRunning()); } NotificationServerApplication::~NotificationServerApplication() { } void NotificationServerApplication::parseCmd(QString msg, bool isPrimary) { QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption quitOption(QStringList()<<"q"<<"quit", tr("Quit notification server")); parser.addOption(quitOption); if (isPrimary) { const QStringList args = QString(msg).split(' '); parser.process(args); if (parser.isSet(quitOption)) { qApp->quit(); return; } } else { if (arguments().count() < 2) { parser.showHelp(); } parser.process(arguments()); sendMessage(msg); } } void NotificationServerApplication::installQTranslator() { QTranslator* translator = new QTranslator(this); if(!translator->load(QLocale(), QStringLiteral(""), QStringLiteral(""), QStringLiteral("/usr/share/ukui-notification/notification-server/translations/"))) { qWarning() << "/usr/share/ukui-notification/notification-server/translations/" + QLocale::system().name() << "load failed"; } qApp->installTranslator(translator); } ukui-notification/notification-server/notification-manager.h0000664000175000017500000000257415160523734023420 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #ifndef NOTIFICATIONMANAGER_H #define NOTIFICATIONMANAGER_H #include #include #include "notification.h" namespace NotificationServer { class NotificationManager : public QObject { Q_OBJECT public: static NotificationManager& self(); Q_DISABLE_COPY(NotificationManager) void notify(NotificationPtr notification); void invokedAction(const uint, const QString&); public Q_SLOTS: void onNotificationClosed(uint id, uint reason); private: explicit NotificationManager(QObject *parent = nullptr); ~NotificationManager(); QMap m_notifications; }; } #endif // NOTIFICATIONMANAGER_H ukui-notification/notification-server/CMakeLists.txt0000664000175000017500000000710115160523746021703 0ustar fengfengset(VERSION_MAJOR 1) set(VERSION_MINOR 1) set(VERSION_MICRO 0) #changelog v1.0.0->v1.1.0:超时时间统一为单位为ms set(NOTIFICATION_SERVER_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}) find_package(PkgConfig REQUIRED) set(UKUI_NOTIFICATION_PC_PKGS ukui-search) foreach(PC_LIB IN ITEMS ${UKUI_NOTIFICATION_PC_PKGS}) pkg_check_modules(${PC_LIB} REQUIRED ${PC_LIB}) if(${${PC_LIB}_FOUND}) include_directories(${${PC_LIB}_INCLUDE_DIRS}) link_directories(${${PC_LIB}_LIBRARY_DIRS}) list(APPEND UKUI_NOTIFICATION_EXTERNAL_LIBS ${${PC_LIB}_LIBRARIES}) endif() endforeach() configure_file (notification-server-config.h.in notification-server-config.h @ONLY) set(3rdParties_DIR ../3rd-parties/qtsingleapplication/src/) set(notificationServer_SRCS server.h server-private.h server.cpp main.cpp ${3rdParties_DIR}qtsinglecoreapplication.h ${3rdParties_DIR}qtsinglecoreapplication.cpp ${3rdParties_DIR}qtlocalpeer.h ${3rdParties_DIR}qtlocalpeer.cpp notification-server-application.cpp notification-server-application.h log-utils.h log-utils.cpp notification-control-register.h notification-control-register.cpp notification-manager.cpp notification-manager.h notification.cpp notification.h notification-default-dir-watcher.cpp notification-default-dir-watcher.h notificaiton-settings-query.cpp notificaiton-settings-query.h ) if(COMMAND qt_add_dbus_adaptor) qt_add_dbus_adaptor(notificationServer_SRCS ../dbus/org.freedesktop.Notifications.xml server-private.h NotificationServer::ServerPrivate) qt_add_dbus_adaptor(notificationServer_SRCS ../dbus/org.ukui.NotificationServer.xml server-private.h NotificationServer::ServerPrivate) qt_add_dbus_adaptor(notificationServer_SRCS ../dbus/org.ukui.NotificationSettings.xml server-private.h NotificationServer::ServerPrivate) else() qt5_add_dbus_adaptor(notificationServer_SRCS ../dbus/org.freedesktop.Notifications.xml server-private.h NotificationServer::ServerPrivate) qt5_add_dbus_adaptor(notificationServer_SRCS ../dbus/org.ukui.NotificationServer.xml server-private.h NotificationServer::ServerPrivate) qt5_add_dbus_adaptor(notificationServer_SRCS ../dbus/org.ukui.NotificationSettings.xml server-private.h NotificationServer::ServerPrivate) endif() file(GLOB TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts) if(COMMAND qt_create_translation) qt_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) else() qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) endif() add_executable(ukui-notification-server ${notificationServer_SRCS} ${QM_FILES}) include_directories(../libukui-notification) target_include_directories(ukui-notification-server PUBLIC ${3rdParties_DIR}) target_link_libraries(ukui-notification-server PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::DBus Qt${QT_VERSION_MAJOR}::Network ukui-notification ${UKUI_NOTIFICATION_EXTERNAL_LIBS} ) set(DBUS_SERVICE_FILE data/org.freedesktop.Notifications.service) set(DESKTOP_FILE data/ukui-notification-server.desktop) install(TARGETS ukui-notification-server DESTINATION /usr/bin) install(FILES ${DBUS_SERVICE_FILE} DESTINATION /usr/share/dbus-1/services) install(FILES ${DESKTOP_FILE} DESTINATION /etc/xdg/autostart) install(FILES ${TS_FILES} ${QM_FILES} DESTINATION /usr/share/ukui-notification/notification-server/translations) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/conf/notification-allowlist.json DESTINATION /etc/ukui/ukui-notification/) ukui-notification/notification-server/main.cpp0000664000175000017500000000276615160523734020604 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include #include #include "notification-server-application.h" #include "log-utils.h" int main(int argc, char *argv[]) { // QTranslator translator; // const QStringList uiLanguages = QLocale::system().uiLanguages(); // for (const QString &locale : uiLanguages) { // const QString baseName = "ukui-notification_" + QLocale(locale).name(); // if (translator.load(":/i18n/" + baseName)) { // a.installTranslator(&translator); // break; // } // } LogUtils::initLogFile("ukui-notification-server"); qInstallMessageHandler(LogUtils::messageOutput); NotificationServer::NotificationServerApplication app(argc, argv); if(app.isRunning()) { return 0; } return app.exec(); } ukui-notification/notification-server/notification-default-dir-watcher.cpp0000664000175000017500000002206115160523734026165 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #include "notification-default-dir-watcher.h" #include #include #include #include #include #include #include "notification-settings/settings-manager.h" static const QStringList DEFAULT_APP_LIST_PATHS = {"/etc/ukui/ukui-notification/default-app", "/opt/system/conf/ukui/ukui-notification/default-app" }; NotificationDefaultDirWatcher::NotificationDefaultDirWatcher(const std::unique_ptr& notificationControlRegister, QObject *parent) : QObject{parent} , m_fileSystemWatcher(new UkuiSearch::FileSystemWatcher()) , m_notificationControlRegister(notificationControlRegister) { //监听默认目录 updateWatcherPath(); connect(m_fileSystemWatcher.get(), &UkuiSearch::FileSystemWatcher::created, this, &NotificationDefaultDirWatcher::onDefaultAppFileAdd); connect(m_fileSystemWatcher.get(), &UkuiSearch::FileSystemWatcher::moveTo, this, &NotificationDefaultDirWatcher::onDefaultAppFileAdd); connect(m_fileSystemWatcher.get(), &UkuiSearch::FileSystemWatcher::moved, this, &NotificationDefaultDirWatcher::onDefaultAppFileDeleted); connect(m_fileSystemWatcher.get(), &UkuiSearch::FileSystemWatcher::deleted, this, &NotificationDefaultDirWatcher::onDefaultAppFileDeleted); connect(m_fileSystemWatcher.get(), &UkuiSearch::FileSystemWatcher::modified, this, &NotificationDefaultDirWatcher::onDefaultAppFileModified); connect(&UkuiNotification::Utils::applicationInfo(), &UkuiSearch::ApplicationInfo::appDBItems2BAdd, [this] (const QStringList& desktopEntries){ //应用安装 const QStringList defaultAppList = getDefaultAppList(); for ( const QString& desktopEntry : desktopEntries) { const QString desktop = UkuiNotification::Utils::desktopEntry2Name(desktopEntry); if (defaultAppList.contains(desktop)) { registerDefaultApp(desktop); qDebug() << "[NotificationDefaultDirWatcher] Registering default app:" << desktop; } } }); connect(&UkuiNotification::Utils::applicationInfo(), &UkuiSearch::ApplicationInfo::appDBItems2BDelete, [this] (const QStringList& desktopEntries){ //应用卸载 for ( const QString& desktopEntry : desktopEntries) { const QString desktop = UkuiNotification::Utils::desktopEntry2Name(desktopEntry); unRegisterDefaultApp(desktop); qDebug() << "[NotificationDefaultDirWatcher] Unregistering default app:" << desktop; } }); } void NotificationDefaultDirWatcher::onDefaultAppFileAdd(const QString &path, bool isDir) { handleDefaultAppFileChanged(path, isDir, false); } void NotificationDefaultDirWatcher::onDefaultAppFileDeleted(const QString &path, bool isDir) { handleDefaultAppFileChanged(path, isDir, true); } void NotificationDefaultDirWatcher::onDefaultAppFileModified(const QString &path) { handleDefaultAppFileChanged(path, false, true); } /** * @brief 如果监听的目录不存在,获取上一级目录 * @param path * @return */ QString NotificationDefaultDirWatcher::findFirstExistingAncestorDir(const QString &path) { QDir dir(path); while (true) { const QString absolutePath = dir.absolutePath(); if (dir.exists()) { return absolutePath; } if (absolutePath == "/") { return absolutePath; } if (!dir.cdUp()) { qWarning() << "NotificationDefaultDirWatcher::findFirstExistingAncestorDir: Failed to cdUp from path " << absolutePath; return absolutePath; } } } /** * @brief DEFAULT_APP_LIST_PATHS * 默认目录创建时, 更新监听目录为默认目录 * 路径删除时,获取默认目录的上一级目录监听 */ void NotificationDefaultDirWatcher::updateWatcherPath() { if (!m_watcherPaths.isEmpty()) { for (const QString& path : m_watcherPaths) { m_fileSystemWatcher->removeWatch(path); } } for (const QString& defaultPath : DEFAULT_APP_LIST_PATHS) { m_watcherPaths << findFirstExistingAncestorDir(defaultPath); } m_fileSystemWatcher->addWatch(m_watcherPaths); qDebug() << "Notification watch path is updated:" << m_watcherPaths; //刷新默认列表 refreshDefaultAppListMap(); } /** * @brief 获取默认的列表 * @return */ QStringList NotificationDefaultDirWatcher::getDefaultAppList() { QStringList defaultAppList; for (const QString& defaultPath : DEFAULT_APP_LIST_PATHS) { QDir dir(defaultPath); if (!dir.exists()) { continue; } for (const QString &fileName : dir.entryList(QDir::Files)) { const QStringList desktopEntries = getDefaultAppDesktopEntries(dir.absoluteFilePath(fileName)); for (const QString& appDesktop : desktopEntries) { if (!defaultAppList.contains(appDesktop)) { defaultAppList << appDesktop; } } } } return defaultAppList; } /** * @brief 读取文件的"DesktopEntries"内容 * @param path * @return */ QStringList NotificationDefaultDirWatcher::getDefaultAppDesktopEntries(const QString& path) { QFile file(path); if (!file.exists()) { qWarning() << "NotificationDefaultDirWatcher::getDefaultAppDesktopEntries" << file.fileName() << "is not exists"; return QStringList(); } if (!file.open(QFile::ReadOnly)) { qWarning() << "NotificationDefaultDirWatcher::getDefaultAppDesktopEntries" << file.fileName() << "open failed"; return QStringList(); } QByteArray byteArray = file.readAll(); file.close(); QJsonParseError errRpt; QJsonDocument jsonDocument(QJsonDocument::fromJson(byteArray, &errRpt)); if (errRpt.error != QJsonParseError::NoError) { qWarning() << "NotificationDefaultDirWatcher::getDefaultAppDesktopEntries Incorrect configuration files " << file.fileName() << "JSON parse error"; return QStringList(); } QJsonObject jsonObject = jsonDocument.object(); if (!jsonObject.contains("DesktopEntries")) { return QStringList(); } return jsonObject.value("DesktopEntries").toString().split(","); } /** * @brief 加载DEFAULT_APP_LIST_PATHS 下的默认配置 */ void NotificationDefaultDirWatcher::refreshDefaultAppListMap() { const QStringList newDefaultApplist = getDefaultAppList(); QStringList oldDefaultApplist; QStringList otherApplist; UkuiNotification::SettingsManager::self()->getAppList(oldDefaultApplist, otherApplist); //新增 QStringList newAddList = StringListDiff(newDefaultApplist, oldDefaultApplist); //删除 QStringList newRemoveList = StringListDiff(oldDefaultApplist, newDefaultApplist); for (const QString& desktop : newAddList) { if (otherApplist.contains(desktop)) { //新增默认应用,已经存在配置,需要更新配置来源 updateDefaultApp(desktop); } else { registerDefaultApp(desktop); } } for (const QString& desktop : newRemoveList) { unRegisterDefaultApp(desktop); } } /** * @brief 默认应用的配置文件改变 * @param path * @param isDir * @param isDelete */ void NotificationDefaultDirWatcher::handleDefaultAppFileChanged(const QString &path, bool isDir, bool isDelete) { if (isDir) { //改变的目录符合预期时,进行更新 if (DEFAULT_APP_LIST_PATHS.contains(path)) { updateWatcherPath(); } } else { //读取默认配置内容,更改配置 for (const QString& defaultAppPath : DEFAULT_APP_LIST_PATHS) { if (path.startsWith(defaultAppPath) && path.endsWith(QStringLiteral(".json"))) { refreshDefaultAppListMap(); } } } } void NotificationDefaultDirWatcher::registerDefaultApp(const QString &desktop) { m_notificationControlRegister->registerNotificationControl(desktop, NotificationControlRegister::RegisterMode::Default); } void NotificationDefaultDirWatcher::unRegisterDefaultApp(const QString &desktop) { m_notificationControlRegister->unRegisterNotificationControl(desktop); } void NotificationDefaultDirWatcher::updateDefaultApp(const QString &desktop) { m_notificationControlRegister->updateNotificationControl(desktop, NotificationControlRegister::RegisterMode::Default); } ukui-notification/notification-server/notificaiton-settings-query.h0000664000175000017500000000311415160523734025000 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #ifndef NOTIFICAITONSETTINGSQUERY_H #define NOTIFICAITONSETTINGSQUERY_H #include #include #include class NotificaitonSettingsQuery : public QObject { Q_OBJECT public: explicit NotificaitonSettingsQuery(QObject* parent = nullptr); ~NotificaitonSettingsQuery() = default; bool isAlarmSoundAllowed() const; bool isSoundAllowed(const QString& desktopEntry) const; Q_SIGNALS: void alarmSoundAllowedChanged(bool); private Q_SLOTS: void checkAlarmSoundAllowed(); private: UkuiNotification::NotificationGlobalSettings* m_notificationGlobalSettings{nullptr}; UkuiNotification::SingleApplicationSettings* m_alarmSingleAppSettings{nullptr}; bool m_alarmSoundAllowed{false}; }; #endif //NOTIFICAITONSETTINGSQUERY_H ukui-notification/notification-server/notificaiton-settings-query.cpp0000664000175000017500000001112415160523734025333 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #include "notificaiton-settings-query.h" #include using namespace UkuiNotification; NotificaitonSettingsQuery::NotificaitonSettingsQuery(QObject* parent) :QObject(parent) { m_notificationGlobalSettings = new NotificationGlobalSettings(this); connect(m_notificationGlobalSettings, &NotificationGlobalSettings::dndChanged, this, &NotificaitonSettingsQuery::checkAlarmSoundAllowed); connect(m_notificationGlobalSettings, &NotificationGlobalSettings::receiveNotificationsFromAppsChanged, this, &NotificaitonSettingsQuery::checkAlarmSoundAllowed); connect(m_notificationGlobalSettings, &NotificationGlobalSettings::notifyAlarmWhileDNDChanged, this, &NotificaitonSettingsQuery::checkAlarmSoundAllowed); //获取闹钟配置 m_alarmSingleAppSettings = new SingleApplicationSettings(QStringLiteral("ukui-clock"), this); if (m_alarmSingleAppSettings) { connect(m_alarmSingleAppSettings, &SingleApplicationSettings::allowNotifyChanged, this, &NotificaitonSettingsQuery::checkAlarmSoundAllowed); connect(m_alarmSingleAppSettings, &SingleApplicationSettings::allowSoundChanged, this, &NotificaitonSettingsQuery::checkAlarmSoundAllowed); } } bool NotificaitonSettingsQuery::isAlarmSoundAllowed() const { //勿扰模式 bool isDND = m_notificationGlobalSettings->isDND(); //勿扰模式允许闹钟提示 bool notifyAlarmWhileDND = m_notificationGlobalSettings->notifyAlarmWhileDND(); if (isDND && !notifyAlarmWhileDND) { //勿扰模式,不允许闹钟提示 return false; } //允许获取应用的通知 bool isAllowedReceiveNotifications = m_notificationGlobalSettings->receiveNotificationsFromApps(); //闹钟配置 bool clockAllowedNotify = m_alarmSingleAppSettings->allowNotify(); bool clockAllowedSound = m_alarmSingleAppSettings->allowSound(); return isAllowedReceiveNotifications && clockAllowedNotify && clockAllowedSound; } bool NotificaitonSettingsQuery::isSoundAllowed(const QString& desktopEntry) const { if (desktopEntry.isEmpty()) { qWarning() << "NotificaitonSettingsQuery::isSoundAllowed : desktop is empty"; return false; } QString desktop = desktopEntry; if (desktop.startsWith("/")) { desktop = Utils::desktopEntry2Name(desktop); } qDebug() << "NotificaitonSettingsQuery::isSoundAllowed : " << desktop << "obtains the playback prompt sound status ."; //勿扰模式 bool isDND = m_notificationGlobalSettings->isDND(); //获取是否允许获取通知 bool isAllowedReceiveNotifications = m_notificationGlobalSettings->receiveNotificationsFromApps(); //勿扰模式允许闹钟提示 bool notifyAlarmWhileDND = false; //默认单个应用配置 bool singleAppAllowedNotify = true; bool SingleAppAllowedSound = true; if (desktop == QStringLiteral("ukui-clock")) { //查询闹钟时才获取notifyAlarmWhileDND的实际状态 notifyAlarmWhileDND = m_notificationGlobalSettings->notifyAlarmWhileDND(); singleAppAllowedNotify = m_alarmSingleAppSettings->allowNotify(); SingleAppAllowedSound = m_alarmSingleAppSettings->allowSound(); } else { const SingleApplicationSettings singleAppSettings(desktop); singleAppAllowedNotify = singleAppSettings.allowNotify(); SingleAppAllowedSound = singleAppSettings.allowSound(); } return (!isDND || notifyAlarmWhileDND) && isAllowedReceiveNotifications && singleAppAllowedNotify && SingleAppAllowedSound; } void NotificaitonSettingsQuery::checkAlarmSoundAllowed() { bool alarmSoundAllowed = isAlarmSoundAllowed(); if (m_alarmSoundAllowed != alarmSoundAllowed) { qDebug() << "NotificaitonSettingsQuery::checkAlarmSoundAllowed AlarmSoundAllowed changed: " << alarmSoundAllowed; m_alarmSoundAllowed = alarmSoundAllowed; Q_EMIT alarmSoundAllowedChanged(alarmSoundAllowed); } } ukui-notification/notification-server/server.h0000664000175000017500000000241615160523734020623 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_SERVER_H #define UKUI_NOTIFICATION_SERVER_H #include #include "notification.h" namespace NotificationServer { class ServerPrivate; class Server : public QObject { Q_OBJECT public: static Server &self(); ~Server(); bool init(); uint notify(NotificationPtr notification); void closeNotification(uint id); private: explicit Server(QObject *parent = nullptr); Q_DISABLE_COPY(Server) ServerPrivate *d = nullptr; }; } // NotificationServer #endif //UKUI_NOTIFICATION_SERVER_H ukui-notification/notification-server/conf/0000775000175000017500000000000015160523746020071 5ustar fengfengukui-notification/notification-server/conf/notification-allowlist.json0000664000175000017500000000627415160523734025470 0ustar fengfeng{ "Applications": { "kylin-updateresult-notify": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-reboot-installnotify": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-stepinstall-notify": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "ksc-defender": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "ksc-defender-trust-measure-notify": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "ksc-virus-dialog": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-activation-volume": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-activation-check-deactivate": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-activation-autostart": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-activation-prompt-autostart": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-camera": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "kylin-recorder": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "ukui-powermanagement-daemon": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "secriskbox": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" }, "peony": { "AllowNotify": "true", "AllowSound": "true", "ShowContentOnLockScreen": "false", "ShowNotificationOnLockScreen": "false" } } } ukui-notification/notification-server/notification.h0000664000175000017500000000432015160523734021777 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #ifndef NOTIFICATION_H #define NOTIFICATION_H #include #include namespace NotificationServer { class NotificationPrivate; class NotificationAction : public QObject { Q_OBJECT public: explicit NotificationAction(QObject* parent = nullptr); ~NotificationAction() = default; void active(); Q_SIGNALS: void actionActived(); }; class Notification : public std::enable_shared_from_this { public: Notification(); Notification& operator=(const Notification& other); ~Notification(); QString appName() const; uint id() const; uint replaceId() const; QString appIcon() const; QString summary() const; QString body() const; QStringList actions() const; QVariantMap hints() const; int timeout() const; void setAppName(const QString &appName); void setId(uint id); void setReplaceId(uint replaceId); void setAppIcon(const QString &appIcon); void setSummary(const QString &summary); void setBody(const QString &body); void setActions(const QStringList &actions); void setHints(const QVariantMap &hints); void setTimeout(int timeout); NotificationAction* addAction(const QString& actionId, const QString& label); NotificationAction* findAction(const QString& actionId); void activeAction(const QString& actionId); void send(); private: NotificationPrivate* d{nullptr}; }; using NotificationPtr = std::shared_ptr; } #endif // NOTIFICATION_H ukui-notification/notification-server/notification-control-register.cpp0000664000175000017500000001060215160523746025635 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #include #include #include "notification-control-register.h" #include "notification-settings/settings-manager.h" #include "notification.h" #include "notification-manager.h" #include "utils.h" using namespace NotificationServer; NotificationControlRegister::NotificationControlRegister(QObject *parent) : QObject{parent} { } void NotificationControlRegister::registerNotificationControl(const QString &desktopEntry, RegisterMode mode) { if (desktopEntry.isEmpty()) { qWarning() << "registerNotificationControl filed :" << "desktop entry is empty ."; return; } //白名单检测 if (UkuiNotification::SettingsManager::self()->isInAllowList(desktopEntry)) { qDebug() << desktopEntry << "notification configuration is in allow list"; return; } //配置存在 if (UkuiNotification::SettingsManager::self()->hasAppSettings(desktopEntry)) { return; } qDebug() << "need add settings: " << desktopEntry << "notification configuration does not exist"; //添加配置 if (!UkuiNotification::SettingsManager::self()->addAppSettings(desktopEntry, registerModeToString(mode))) { qWarning() << "Failed to add app settings :" << desktopEntry; return; } if (mode == RegisterMode::Notice) { QTimer::singleShot(6000, [desktopEntry]() { const QString& desktopFullPath = UkuiNotification::Utils::desktopEntryFromName(desktopEntry); if (desktopFullPath.isEmpty()) { qWarning() << "Failed to query desktop files through desktop entry :" << desktopEntry; return; } QString appName = UkuiNotification::Utils::appNameForDesktopEntry(desktopFullPath); if (appName.isEmpty()) { qWarning() << "Failed to retrieve app name, using desktop entry." << desktopFullPath ; appName = desktopEntry; } auto notification = std::make_shared(); notification->setAppName(tr("System notification")); notification->setAppIcon("ukui-control-center"); notification->setSummary(tr("Whether to allow \"%1\" to send system notifications").arg(appName)); notification->setBody(tr("If not, you will no longer receive any prompt messages from the app")); //hints QVariantMap hints; hints.insert("urgency", 2); notification->setHints(hints); //actions auto* disallowAction = notification->addAction("Disallow", tr("Disallow")); auto* allowAction = notification->addAction("Allow", tr("Allow")); notification->send(); auto actionOption = [desktopEntry] (NotificationAction* action, bool isAllow) { if (action) { connect(action, &NotificationAction::actionActived, [desktopEntry, isAllow] () { UkuiNotification::SettingsManager::self()->setAppSettings(desktopEntry, UkuiNotification::SettingsProperty::AllowNotify, isAllow); }); } }; actionOption(disallowAction, false); actionOption(allowAction, true); }); } } void NotificationControlRegister::unRegisterNotificationControl(const QString &desktopEntry) { UkuiNotification::SettingsManager::self()->deleteAppSettings(desktopEntry); } void NotificationControlRegister::updateNotificationControl(const QString& desktopEntry, RegisterMode mode) { UkuiNotification::SettingsManager::self()->setAppSettings(desktopEntry, UkuiNotification::SettingsProperty::ConfigurationSource ,registerModeToString(mode)); } ukui-notification/notification-server/notification.cpp0000664000175000017500000000772315160523734022344 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #include #include #include #include "notification.h" #include "notification-manager.h" namespace NotificationServer{ class NotificationPrivate { public: NotificationPrivate() = default; ~NotificationPrivate(); QString m_appName; uint m_id = 0; uint m_replaceId = 0; QString m_appIcon; QString m_summary; QString m_body; QStringList m_actions; QVariantMap m_hints; int m_timeout = -1; QMap m_notificationActions; }; } using namespace NotificationServer; NotificationPrivate::~NotificationPrivate() { qDeleteAll(m_notificationActions); m_notificationActions.clear(); } NotificationAction::NotificationAction(QObject* parent) : QObject(parent) { } void NotificationAction::active() { Q_EMIT actionActived(); } Notification::Notification() : d(new NotificationPrivate) { } Notification::~Notification() { if (d) { delete d; d = nullptr; } } uint Notification::id() const { return d->m_id; } void Notification::setId(uint id) { d->m_id = id; } uint Notification::replaceId() const { return d->m_replaceId; } void Notification::setReplaceId(uint replaceId) { d->m_replaceId = replaceId; } QString Notification::appName() const { return d->m_appName; } void Notification::setAppName(const QString &appName) { d->m_appName = appName; } QString Notification::appIcon() const { return d->m_appIcon; } void Notification::setAppIcon(const QString &appIcon) { d->m_appIcon = appIcon; } QString Notification::summary() const { return d->m_summary; } void Notification::setSummary(const QString &summary) { d->m_summary = summary; } QString Notification::body() const { return d->m_body; } void Notification::setBody(const QString &body) { d->m_body = body; } QStringList Notification::actions() const { return d->m_actions; } void Notification::setActions(const QStringList &actions) { if (actions.count() % 2 != 0) { qWarning() << "List of actions must contain an even number of items, tried to set actions to" << actions; return; } for (int i = 0; i < actions.count(); i += 2) { const QString &actionId = actions.at(i); const QString &label = actions.at(i + 1); addAction(actionId, label); } } QVariantMap Notification::hints() const { return d->m_hints; } void Notification::setHints(const QVariantMap &hints) { d->m_hints = hints; } int Notification::timeout() const { return d->m_timeout; } void Notification::setTimeout(int timeout) { d->m_timeout = timeout; } NotificationAction* Notification::addAction(const QString& actionId, const QString &label) { d->m_actions << actionId << label; NotificationAction* action = new NotificationAction; d->m_notificationActions.insert(actionId, action); return action; } NotificationAction *Notification::findAction(const QString &actionId) { return d->m_notificationActions[actionId]; } void Notification::activeAction(const QString &actionId) { auto* action = d->m_notificationActions[actionId]; if (action) { action->active(); } } void Notification::send() { NotificationManager::self().notify(shared_from_this()); } ukui-notification/notification-server/log-utils.h0000664000175000017500000000242715160523746021241 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef LOGUTILS_H #define LOGUTILS_H #include class LogUtils { public: static void initLogFile(const QString &fileName); static void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg); private: static void checkLogFile(); static bool checkFileSize(const QString &fileName); static void clearFile(const QString &fileName); static quint64 m_startUpTime; static int m_logFileId; static QString m_logFileName; static QString m_currentLogFile; }; #endif // LOGUTILS_H ukui-notification/notification-server/notification-default-dir-watcher.h0000664000175000017500000000403715160523734025635 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #ifndef NOTIFICATIONDEFAULTDIRWATCHER_H #define NOTIFICATIONDEFAULTDIRWATCHER_H #include #include #include #include "file-system-watcher.h" #include "notification-control-register.h" class NotificationDefaultDirWatcher : public QObject { Q_OBJECT public: explicit NotificationDefaultDirWatcher(const std::unique_ptr&, QObject *parent = nullptr); private Q_SLOTS: void onDefaultAppFileAdd(const QString& path, bool isDir); void onDefaultAppFileDeleted(const QString& path, bool isDir); void onDefaultAppFileModified(const QString& path); private: QString findFirstExistingAncestorDir(const QString& path); void updateWatcherPath(); QStringList getDefaultAppList(); QStringList getDefaultAppDesktopEntries(const QString& path); void refreshDefaultAppListMap(); void handleDefaultAppFileChanged(const QString& path, bool isDir, bool); void registerDefaultApp(const QString& desktop); void unRegisterDefaultApp(const QString& desktop); void updateDefaultApp(const QString &desktop); QStringList m_watcherPaths; std::unique_ptr m_fileSystemWatcher; const std::unique_ptr& m_notificationControlRegister; }; #endif // NOTIFICATIONDEFAULTDIRWATCHER_H ukui-notification/notification-server/notification-control-register.h0000664000175000017500000000326515160523746025311 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #ifndef NOTIFICATIONCONTROLREGISTER_H #define NOTIFICATIONCONTROLREGISTER_H #include class NotificationControlRegister : public QObject { Q_OBJECT public: enum class RegisterMode {Default, Notice, Interface}; static QString registerModeToString(RegisterMode mode) { switch (mode) { default: case RegisterMode::Default: return "Default"; case RegisterMode::Notice: return "Notice"; case RegisterMode::Interface: return "Interface"; } } explicit NotificationControlRegister(QObject* parent = nullptr); ~NotificationControlRegister() = default; void registerNotificationControl(const QString& desktopEntry, RegisterMode mode = RegisterMode::Notice); void unRegisterNotificationControl(const QString& desktopEntry); void updateNotificationControl(const QString& desktopEntry, RegisterMode mode); }; #endif // NOTIFICATIONCONTROLREGISTER_H ukui-notification/notification-server/server-private.h0000664000175000017500000000710715160523746022300 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_SERVER_PRIVATE_H #define UKUI_NOTIFICATION_SERVER_PRIVATE_H #include #include #include #include "notification-control-register.h" #include "notification.h" #include "notification-default-dir-watcher.h" #include "notificaiton-settings-query.h" class QDBusServiceWatcher; namespace NotificationServer { class ServerPrivate : public QObject, protected QDBusContext { Q_OBJECT //dbus interface public: QStringList GetCapabilities() const; uint Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout); void CloseNotification(uint id); QString GetServerInformation(QString &vendor, QString &version, QString &spec_version) const; /** * 注册成为通知中心客户端 */ void RegisterClient(); /** * 注销 */ void UnRegisterClient(); /** * 通知中心关闭通知 * @param id 通知id * @param reason 关闭原因 */ void CloseNotification(uint id, uint); void InvokeAction(uint id, const QString &action_key); void UpdateUnreadMessagesNumber(const QString &desktopEntry, uint number); /** * @brief RegisterNotificationControl * @param desktop 文件名,不带后缀 */ void RegisterNotificationControl(const QString &desktopEntry); /*! * @brief 是否允许闹钟播放提示音 * @return */ bool IsAlarmSoundAllowed(); /*! *@brief 获取单个应用是否允许播放声音 * @param desktop 文件名,不带后缀 * @return bool */ bool IsSoundAllowed(const QString &desktopEntry); Q_SIGNALS: void NotificationClosed(uint id, uint reason); void ActionInvoked(uint id, const QString &actionKey); void ActivationToken(uint id, const QString &ActivationToken); void UnreadMessagesNumberUpdated(const QString &desktopEntry, uint number); void AlarmSoundAllowedChanged(bool); public: explicit ServerPrivate(QObject *parent = nullptr); ~ServerPrivate() override; bool init(); static QString notificationServiceName(); static QString notificationServicePath(); static QString notificationServiceInterface(); private: void sendCache(); QDBusServiceWatcher *m_notificationWatchers = nullptr; uint m_increasedNotificationId = 1; QMap m_notificationsCache; std::unique_ptr m_notificationControlRegister; NotificationDefaultDirWatcher* m_notificationDefaultDirWatcher{nullptr}; NotificaitonSettingsQuery* m_notificationSettingsQuery{nullptr}; }; } // NotificationServer #endif //UKUI_NOTIFICATION_SERVER_PRIVATE_H ukui-notification/notification-server/notification-server-application.h0000664000175000017500000000254615160523734025614 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_NOTIFICATION_SERVER_APPLICATION_H #define UKUI_NOTIFICATION_NOTIFICATION_SERVER_APPLICATION_H #include #include "qtsinglecoreapplication.h" namespace NotificationServer { class NotificationServerApplication : public QtSingleCoreApplication { Q_OBJECT public: NotificationServerApplication(int &argc, char *argv[], const QString &applicationName = "ukui-notification-server"); ~NotificationServerApplication(); protected Q_SLOTS: void parseCmd(QString msg, bool isPrimary); private: void installQTranslator(); }; } #endif //UKUI_NOTIFICATION_NOTIFICATION_SERVER_APPLICATION_H ukui-notification/notification-server/notification-server-config.h.in0000664000175000017500000000207615160523734025161 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef NOTIFICATION_SERVER_CONFIG_H_IN #define NOTIFICATION_SERVER_CONFIG_H_IN #define VERSION_MAJOR "@VERSION_MAJOR@" #define VERSION_MINOR "@VERSION_MINOR@" #define VERSION_MICRO "@VERSION_MICRO@" #define NOTIFICATION_SERVER_VERSION "@NOTIFICATION_SERVER_VERSION@" #endif // NOTIFICATION_SERVER_CONFIG_H_INNOTIFICATION_SERVER_VERSIONukui-notification/notification-server/notification-manager.cpp0000664000175000017500000000344215160523734023746 0ustar fengfeng/* * Copyright (C) 2025, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: sundagao */ #include #include #include #include "notification-manager.h" #include "server.h" #include using namespace NotificationServer; NotificationManager& NotificationManager::self() { static NotificationManager instance; return instance; } void NotificationManager::notify(NotificationPtr notification) { uint id = NotificationServer::Server::self().notify(notification); m_notifications.insert(id, notification); } void NotificationManager::invokedAction(uint id, const QString& actionId) { auto notification = m_notifications[id]; if (notification) { notification->activeAction(actionId); } } void NotificationManager::onNotificationClosed(uint id, uint reason) { Q_UNUSED(reason) auto iter = m_notifications.find(id); if (iter != m_notifications.end()) { m_notifications.erase(iter); } } NotificationManager::NotificationManager(QObject *parent) : QObject{parent} { } NotificationManager::~NotificationManager() { m_notifications.clear(); } ukui-notification/notification-server/log-utils.cpp0000664000175000017500000001125115160523746021567 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "log-utils.h" #include #include #include #include #include #define LOG_FILE_COUNT 2 #define MAX_LOG_FILE_SIZE 4194304 #define MAX_LOG_CHECK_INTERVAL 43200000 quint64 LogUtils::m_startUpTime = 0; int LogUtils::m_logFileId = -1; QString LogUtils::m_logFileName; QString LogUtils::m_currentLogFile; static QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.log/ukui-notification/"; void LogUtils::messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { checkLogFile(); QByteArray localMsg = msg.toLocal8Bit(); QByteArray currentDate = QDate::currentDate().toString("yyyy-MM-dd").toLocal8Bit(); QByteArray currentTime = QTime::currentTime().toString().toLocal8Bit(); const char *file = context.file ? context.file : ""; const char *function = context.function ? context.function : ""; FILE *log_file = fopen(m_currentLogFile.toLocal8Bit().constData(), "a+"); switch (type) { case QtDebugMsg: if (!log_file) { break; } fprintf(log_file, "[%s %s] [Debug] %s (%s:%u, %s)\n", currentDate.constData(), currentTime.constData(), localMsg.constData(), file, context.line, function); break; case QtInfoMsg: fprintf(log_file? log_file: stdout, "\033[32m[%s %s] [Info] %s \033[0m(%s:%u, %s)\n", currentDate.constData(), currentTime.constData(), localMsg.constData(), file, context.line, function); break; case QtWarningMsg: fprintf(log_file? log_file: stderr, "\033[33m[%s %s] [Warning] %s \033[0m(%s:%u, %s)\n", currentDate.constData(), currentTime.constData(), localMsg.constData(), file, context.line, function); break; case QtCriticalMsg: fprintf(log_file? log_file: stderr, "\033[31m[%s %s] [Critical] %s \033[0m(%s:%u, %s)\n", currentDate.constData(), currentTime.constData(), localMsg.constData(), file, context.line, function); break; case QtFatalMsg: fprintf(log_file? log_file: stderr, "\033[1;31m[%s %s] [Fatal] %s \033[0m(%s:%u, %s)\n", currentDate.constData(), currentTime.constData(), localMsg.constData(), file, context.line, function); break; } if (log_file) { fclose(log_file); } } void LogUtils::initLogFile(const QString &fileName) { QDir dir; if (!dir.exists(logFilePath)) { if (!dir.mkpath(logFilePath)) { qWarning() << "Unable to create" << logFilePath; return; } } m_logFileName = logFilePath + fileName + "-%1.log"; for (int i = 0; i < LOG_FILE_COUNT; ++i) { m_currentLogFile = m_logFileName.arg(i); if (QFile::exists(m_currentLogFile)) { if (checkFileSize(m_currentLogFile)) { m_logFileId = i; break; } } else { QFile file(m_currentLogFile); file.open(QIODevice::WriteOnly); file.close(); } } if (m_logFileId < 0) { m_logFileId = 0; m_currentLogFile = m_logFileName.arg(m_logFileId); clearFile(m_currentLogFile); } qInfo() << "Current log file:" << m_currentLogFile; } void LogUtils::checkLogFile() { quint64 logTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); quint64 spacing = std::max(logTime, m_startUpTime) - std::min(logTime, m_startUpTime); if (spacing <= MAX_LOG_CHECK_INTERVAL || checkFileSize(m_currentLogFile)) { return; } m_logFileId = ((m_logFileId + 1) % LOG_FILE_COUNT); m_currentLogFile = m_logFileName.arg(m_logFileId); if (!checkFileSize(m_currentLogFile)) { clearFile(m_currentLogFile); } } bool LogUtils::checkFileSize(const QString &fileName) { return QFile(fileName).size() < MAX_LOG_FILE_SIZE; } void LogUtils::clearFile(const QString &fileName) { QFile file(fileName); file.open(QIODevice::WriteOnly); file.write(""); file.flush(); file.close(); } ukui-notification/notification-server/data/0000775000175000017500000000000015160523734020052 5ustar fengfengukui-notification/notification-server/data/ukui-notification-server.desktop0000664000175000017500000000056515160523734026420 0ustar fengfeng[Desktop Entry] Name=ukui-notification-server Name[zh_CN]=通知服务 GenericName=ukui-notification-server GenericName[zh_CN]=通知服务 Comment=ukui-notification-server Comment[zh_CN]=通知服务 Exec=/usr/bin/ukui-notification-server %U Type=Application #Icon= X-UKUI-AutoRestart=true OnlyShowIn=UKUI NoDisplay=true X-UKUI-Autostart-Phase=Application Terminal=false ukui-notification/notification-server/data/org.freedesktop.Notifications.service0000664000175000017500000000013115160523734027340 0ustar fengfeng[D-BUS Service] Name=org.freedesktop.Notifications Exec=/usr/bin/ukui-notification-serverukui-notification/test/0000775000175000017500000000000015160523734014126 5ustar fengfengukui-notification/test/CMakeLists.txt0000664000175000017500000000103215160523734016662 0ustar fengfengset(notificationClientTest_SRCS notification-client-test.cpp notification-client-test.h main.cpp notification-settings-test.cpp notification-settings-test.h) include_directories(${CMAKE_SOURCE_DIR}/libukui-notification ${CMAKE_SOURCE_DIR}/libukui-notification/notification-settings) add_executable(ukui-notification-test ${notificationClientTest_SRCS}) target_link_libraries(ukui-notification-test PRIVATE Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Gui ukui-notification )ukui-notification/test/main.cpp0000664000175000017500000000202115160523734015551 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include #include #include "notification-client-test.h" #include "notification-settings-test.h" int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); // NotificationClientTest ct; NotificationSettingsTest setting; return app.exec(); }ukui-notification/test/notification-client-test.cpp0000664000175000017500000000312215160523734021547 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "notification-client-test.h" #include NotificationClientTest::NotificationClientTest(QObject *parent) : QObject(parent) { m_client = new UkuiNotification::NotificationClient(this); connect(m_client, &UkuiNotification::NotificationClient::newNotification, [&](const UkuiNotification::PopupNotification ¬ification){ qDebug() << notification.applicationName() << notification.applicationIconName() << notification.summary() << notification.body() << notification.actions() << notification.hints() << notification.timeout(); }); qDebug() << "Register client" << m_client->registerClient(); } NotificationClientTest::~NotificationClientTest() { } ukui-notification/test/notification-settings-test.h0000664000175000017500000000250515160523734021602 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_NOTIFICATION_SETTINGS_TEST_H #define UKUI_NOTIFICATION_NOTIFICATION_SETTINGS_TEST_H #include #include "applications-settings.h" #include "notification-global-settings.h" class NotificationSettingsTest : public QObject { Q_OBJECT public: explicit NotificationSettingsTest(QObject *parent = nullptr); ~NotificationSettingsTest(); void initConnection(UkuiNotification::SingleApplicationSettings *setting); private: UkuiNotification::NotificationGlobalSettings *m_globalSettings = nullptr; }; #endif //UKUI_NOTIFICATION_NOTIFICATION_SETTINGS_TEST_H ukui-notification/test/notification-client-test.h0000664000175000017500000000226115160523734021217 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #ifndef UKUI_NOTIFICATION_NOTIFICATION_CLIENT_TEST_H #define UKUI_NOTIFICATION_NOTIFICATION_CLIENT_TEST_H #include "notification-client.h" #include class NotificationClientTest : public QObject { Q_OBJECT public: explicit NotificationClientTest(QObject *parent = nullptr); ~NotificationClientTest(); private: UkuiNotification::NotificationClient *m_client = nullptr; }; #endif //UKUI_NOTIFICATION_NOTIFICATION_CLIENT_TEST_H ukui-notification/test/notification-settings-test.cpp0000664000175000017500000000737715160523734022151 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: iaom */ #include "notification-settings-test.h" #include "popup-notification.h" NotificationSettingsTest::NotificationSettingsTest(QObject *parent) : QObject(parent) { UkuiNotification::ApplicationsSettingsMap &map = UkuiNotification::ApplicationsSettings::self()->getAllApplicationsSettings(); for(const QString &key : map.keys()) { initConnection(map.value(key)); } m_globalSettings = new UkuiNotification::NotificationGlobalSettings(this); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOnDNDChanged, this, [&](bool value){ qDebug() << "scheduleTurnOnDNDChanged" << value; }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOnDNDTimeChanged, this, [&](QTime value){ qDebug() << "scheduleTurnOnDNDTimeChanged" << value; }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOffDNDTimeChanged, this, [&](QTime value){ qDebug() << "scheduleTurnOffDNDTimeChanged" << value; }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::DNDWhileMultiScreenChanged, this, [&](bool value){ qDebug() << "DNDWhileMultiScreenChanged" << value; }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::DNDWhileFullScreenChanged, this, [&](bool value){ qDebug() << "DNDWhileFullScreenChanged" << value; }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::notifyAlarmWhileDNDChanged, this, [&](bool value){ qDebug() << "notifyAlarmWhileDNDChanged" << value; }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::receiveNotificationsFromAppsChanged, this, [&](bool value){ qDebug() << "receiveNotificationsFromAppsChanged" << value; }); } NotificationSettingsTest::~NotificationSettingsTest() { } void NotificationSettingsTest::initConnection(UkuiNotification::SingleApplicationSettings *setting) { connect(setting, &UkuiNotification::SingleApplicationSettings::allowNotifyChanged, this, [&](bool value){ qDebug() << "allowNotifyChanged" << value; }); connect(setting, &UkuiNotification::SingleApplicationSettings::allowSoundChanged, this, [&](bool value){ qDebug() << "allowSoundChanged" << value; }); connect(setting, &UkuiNotification::SingleApplicationSettings::showContentOnLockScreenChanged, this, [&](bool value){ qDebug() << "showContentOnLockScreenChanged" << value; }); connect(setting, &UkuiNotification::SingleApplicationSettings::showNotificationOnLockScreenChanged, this, [&](bool value){ qDebug() << "showNotificationOnLockScreenChanged" << value; }); connect(setting, &UkuiNotification::SingleApplicationSettings::popupStyleChanged, this, [&](UkuiNotification::SettingsProperty::Property value){ qDebug() << "popupStyleChanged" << value; }); connect(setting, &UkuiNotification::SingleApplicationSettings::uninstalled, this, [&](){ qDebug() << "uninstalled"; }); } ukui-notification/3rd-parties/0000775000175000017500000000000015160523734015304 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/0000775000175000017500000000000015160523734021356 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/src/0000775000175000017500000000000015160523734022145 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/src/qtlocalpeer.h0000664000175000017500000000144515160523734024635 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #ifndef QTLOCALPEER_H #define QTLOCALPEER_H #include #include #include #include "qtlockedfile.h" class QtLocalPeer : public QObject { Q_OBJECT public: QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); bool isClient(); bool sendMessage(const QString &message, int timeout); QString applicationId() const { return id; } Q_SIGNALS: void messageReceived(const QString &message); protected Q_SLOTS: void receiveConnection(); protected: QString id; QString socketName; QLocalServer* server; QtLP_Private::QtLockedFile lockFile; private: static const char* ack; }; #endif // QTLOCALPEER_H ukui-notification/3rd-parties/qtsingleapplication/src/qtsingleapplication.pri0000664000175000017500000000111015160523734026724 0ustar fengfenginclude(../common.pri) INCLUDEPATH += $$PWD DEPENDPATH += $$PWD QT *= network greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets qtsingleapplication-uselib:!qtsingleapplication-buildlib { LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME } else { SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h } win32 { contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT } ukui-notification/3rd-parties/qtsingleapplication/src/CMakeLists.txt0000664000175000017500000000011615160523734024703 0ustar fengfengtarget_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})ukui-notification/3rd-parties/qtsingleapplication/src/qtlockedfile.cpp0000664000175000017500000001020215160523734025312 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include "qtlockedfile.h" /*! \class QtLockedFile \brief The QtLockedFile class extends QFile with advisory locking functions. A file may be locked in read or write mode. Multiple instances of \e QtLockedFile, created in multiple processes running on the same machine, may have a file locked in read mode. Exactly one instance may have it locked in write mode. A read and a write lock cannot exist simultaneously on the same file. The file locks are advisory. This means that nothing prevents another process from manipulating a locked file using QFile or file system functions offered by the OS. Serialization is only guaranteed if all processes that access the file use QLockedFile. Also, while holding a lock on a file, a process must not open the same file again (through any API), or locks can be unexpectedly lost. The lock provided by an instance of \e QtLockedFile is released whenever the program terminates. This is true even when the program crashes and no destructors are called. */ /*! \enum QtLockedFile::LockMode This enum describes the available lock modes. \value ReadLock A read lock. \value WriteLock A write lock. \value NoLock Neither a read lock nor a write lock. */ /*! Constructs an unlocked \e QtLockedFile object. This constructor behaves in the same way as \e QFile::QFile(). \sa QFile::QFile() */ QtLockedFile::QtLockedFile() : QFile() { #ifdef Q_OS_WIN wmutex = 0; rmutex = 0; #endif m_lock_mode = NoLock; } /*! Constructs an unlocked QtLockedFile object with file \a name. This constructor behaves in the same way as \e QFile::QFile(const QString&). \sa QFile::QFile() */ QtLockedFile::QtLockedFile(const QString &name) : QFile(name) { #ifdef Q_OS_WIN wmutex = 0; rmutex = 0; #endif m_lock_mode = NoLock; } /*! Opens the file in OpenMode \a mode. This is identical to QFile::open(), with the one exception that the Truncate mode flag is disallowed. Truncation would conflict with the advisory file locking, since the file would be modified before the write lock is obtained. If truncation is required, use resize(0) after obtaining the write lock. Returns true if successful; otherwise false. \sa QFile::open(), QFile::resize() */ bool QtLockedFile::open(OpenMode mode) { if (mode & QIODevice::Truncate) { qWarning("QtLockedFile::open(): Truncate mode not allowed."); return false; } return QFile::open(mode); } /*! Returns \e true if this object has a in read or write lock; otherwise returns \e false. \sa lockMode() */ bool QtLockedFile::isLocked() const { return m_lock_mode != NoLock; } /*! Returns the type of lock currently held by this object, or \e QtLockedFile::NoLock. \sa isLocked() */ QtLockedFile::LockMode QtLockedFile::lockMode() const { return m_lock_mode; } /*! \fn bool QtLockedFile::lock(LockMode mode, bool block = true) Obtains a lock of type \a mode. The file must be opened before it can be locked. If \a block is true, this function will block until the lock is aquired. If \a block is false, this function returns \e false immediately if the lock cannot be aquired. If this object already has a lock of type \a mode, this function returns \e true immediately. If this object has a lock of a different type than \a mode, the lock is first released and then a new lock is obtained. This function returns \e true if, after it executes, the file is locked by this object, and \e false otherwise. \sa unlock(), isLocked(), lockMode() */ /*! \fn bool QtLockedFile::unlock() Releases a lock. If the object has no lock, this function returns immediately. This function returns \e true if, after it executes, the file is not locked by this object, and \e false otherwise. \sa lock(), isLocked(), lockMode() */ /*! \fn QtLockedFile::~QtLockedFile() Destroys the \e QtLockedFile object. If any locks were held, they are released. */ ukui-notification/3rd-parties/qtsingleapplication/src/qtlockedfile.h0000664000175000017500000000254715160523734024774 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #ifndef QTLOCKEDFILE_H #define QTLOCKEDFILE_H #include #ifdef Q_OS_WIN #include #endif #if defined(Q_OS_WIN) # if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) # define QT_QTLOCKEDFILE_EXPORT # elif defined(QT_QTLOCKEDFILE_IMPORT) # if defined(QT_QTLOCKEDFILE_EXPORT) # undef QT_QTLOCKEDFILE_EXPORT # endif # define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) # elif defined(QT_QTLOCKEDFILE_EXPORT) # undef QT_QTLOCKEDFILE_EXPORT # define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) # endif #else # define QT_QTLOCKEDFILE_EXPORT #endif namespace QtLP_Private { class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile { public: enum LockMode { NoLock = 0, ReadLock, WriteLock }; QtLockedFile(); QtLockedFile(const QString &name); ~QtLockedFile(); bool open(OpenMode mode); bool lock(LockMode mode, bool block = true); bool unlock(); bool isLocked() const; LockMode lockMode() const; private: #ifdef Q_OS_WIN Qt::HANDLE wmutex; Qt::HANDLE rmutex; QVector rmutexes; QString mutexname; Qt::HANDLE getMutexHandle(int idx, bool doCreate); bool waitMutex(Qt::HANDLE mutex, bool doBlock); #endif LockMode m_lock_mode; }; } #endif ukui-notification/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.h0000664000175000017500000000126515160523734027245 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #ifndef QTSINGLECOREAPPLICATION_H #define QTSINGLECOREAPPLICATION_H #include class QtLocalPeer; class QtSingleCoreApplication : public QCoreApplication { Q_OBJECT public: QtSingleCoreApplication(int &argc, char **argv); QtSingleCoreApplication(const QString &id, int &argc, char **argv); bool isRunning(); QString id() const; public Q_SLOTS: bool sendMessage(const QString &message, int timeout = 5000); Q_SIGNALS: void messageReceived(const QString &message); private: QtLocalPeer* peer; }; #endif // QTSINGLECOREAPPLICATION_H ukui-notification/3rd-parties/qtsingleapplication/src/QtLockedFile0000664000175000017500000000003215160523734024371 0ustar fengfeng#include "qtlockedfile.h" ukui-notification/3rd-parties/qtsingleapplication/src/qtlockedfile_unix.cpp0000664000175000017500000000305415160523734026364 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include #include #include #include #include "qtlockedfile.h" bool QtLockedFile::lock(LockMode mode, bool block) { if (!isOpen()) { qWarning("QtLockedFile::lock(): file is not opened"); return false; } if (mode == NoLock) return unlock(); if (mode == m_lock_mode) return true; if (m_lock_mode != NoLock) unlock(); struct flock fl; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; int cmd = block ? F_SETLKW : F_SETLK; int ret = fcntl(handle(), cmd, &fl); if (ret == -1) { if (errno != EINTR && errno != EAGAIN) qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); return false; } m_lock_mode = mode; return true; } bool QtLockedFile::unlock() { if (!isOpen()) { qWarning("QtLockedFile::unlock(): file is not opened"); return false; } if (!isLocked()) return true; struct flock fl; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; fl.l_type = F_UNLCK; int ret = fcntl(handle(), F_SETLKW, &fl); if (ret == -1) { qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); return false; } m_lock_mode = NoLock; return true; } QtLockedFile::~QtLockedFile() { if (isOpen()) unlock(); } ukui-notification/3rd-parties/qtsingleapplication/src/qtsingleapplication.cpp0000664000175000017500000002325015160523734026725 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include "qtsingleapplication.h" #include "qtlocalpeer.h" #include /*! \class QtSingleApplication qtsingleapplication.h \brief The QtSingleApplication class provides an API to detect and communicate with running instances of an application. This class allows you to create applications where only one instance should be running at a time. I.e., if the user tries to launch another instance, the already running instance will be activated instead. Another usecase is a client-server system, where the first started instance will assume the role of server, and the later instances will act as clients of that server. By default, the full path of the executable file is used to determine whether two processes are instances of the same application. You can also provide an explicit identifier string that will be compared instead. The application should create the QtSingleApplication object early in the startup phase, and call isRunning() to find out if another instance of this application is already running. If isRunning() returns false, it means that no other instance is running, and this instance has assumed the role as the running instance. In this case, the application should continue with the initialization of the application user interface before entering the event loop with exec(), as normal. The messageReceived() signal will be emitted when the running application receives messages from another instance of the same application. When a message is received it might be helpful to the user to raise the application so that it becomes visible. To facilitate this, QtSingleApplication provides the setActivationWindow() function and the activateWindow() slot. If isRunning() returns true, another instance is already running. It may be alerted to the fact that another instance has started by using the sendMessage() function. Also data such as startup parameters (e.g. the name of the file the user wanted this new instance to open) can be passed to the running instance with this function. Then, the application should terminate (or enter client mode). If isRunning() returns true, but sendMessage() fails, that is an indication that the running instance is frozen. Here's an example that shows how to convert an existing application to use QtSingleApplication. It is very simple and does not make use of all QtSingleApplication's functionality (see the examples for that). \code // Original int main(int argc, char **argv) { QApplication app(argc, argv); MyMainWidget mmw; mmw.show(); return app.exec(); } // Single instance int main(int argc, char **argv) { QtSingleApplication app(argc, argv); if (app.isRunning()) return !app.sendMessage(someDataString); MyMainWidget mmw; app.setActivationWindow(&mmw); mmw.show(); return app.exec(); } \endcode Once this QtSingleApplication instance is destroyed (normally when the process exits or crashes), when the user next attempts to run the application this instance will not, of course, be encountered. The next instance to call isRunning() or sendMessage() will assume the role as the new running instance. For console (non-GUI) applications, QtSingleCoreApplication may be used instead of this class, to avoid the dependency on the QtGui library. \sa QtSingleCoreApplication */ void QtSingleApplication::sysInit(const QString &appId) { actWin = 0; peer = new QtLocalPeer(this, appId); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); } /*! Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). \a argc, \a argv, and \a GUIenabled are passed on to the QAppliation constructor. If you are creating a console application (i.e. setting \a GUIenabled to false), you may consider using QtSingleCoreApplication instead. */ QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled) : QApplication(argc, argv, GUIenabled) { sysInit(); } /*! Creates a QtSingleApplication object with the application identifier \a appId. \a argc and \a argv are passed on to the QAppliation constructor. */ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv) : QApplication(argc, argv) { sysInit(appId); } #if QT_VERSION < 0x050000 /*! Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). \a argc, \a argv, and \a type are passed on to the QAppliation constructor. */ QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) : QApplication(argc, argv, type) { sysInit(); } # if defined(Q_WS_X11) /*! Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). \a dpy, \a visual, and \a cmap are passed on to the QApplication constructor. */ QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, visual, cmap) { sysInit(); } /*! Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a argv, \a visual, and \a cmap are passed on to the QApplication constructor. */ QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, argc, argv, visual, cmap) { sysInit(); } /*! Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be \a appId. \a dpy, \a argc, \a argv, \a visual, and \a cmap are passed on to the QApplication constructor. */ QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, argc, argv, visual, cmap) { sysInit(appId); } # endif // Q_WS_X11 #endif // QT_VERSION < 0x050000 /*! Returns true if another instance of this application is running; otherwise false. This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session). \sa sendMessage() */ bool QtSingleApplication::isRunning() { return peer->isClient(); } /*! Tries to send the text \a message to the currently running instance. The QtSingleApplication object in the running instance will emit the messageReceived() signal when it receives the message. This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within \a timeout milliseconds, this function return false. \sa isRunning(), messageReceived() */ bool QtSingleApplication::sendMessage(const QString &message, int timeout) { return peer->sendMessage(message, timeout); } /*! Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application. */ QString QtSingleApplication::id() const { return peer->applicationId(); } /*! Sets the activation window of this application to \a aw. The activation window is the widget that will be activated by activateWindow(). This is typically the application's main window. If \a activateOnMessage is true (the default), the window will be activated automatically every time a message is received, just prior to the messageReceived() signal being emitted. \sa activateWindow(), messageReceived() */ void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) { actWin = aw; if (activateOnMessage) connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); else disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); } /*! Returns the applications activation window if one has been set by calling setActivationWindow(), otherwise returns 0. \sa setActivationWindow() */ QWidget* QtSingleApplication::activationWindow() const { return actWin; } /*! De-minimizes, raises, and activates this application's activation window. This function does nothing if no activation window has been set. This is a convenience function to show the user that this application instance has been activated when he has tried to start another instance. This function should typically be called in response to the messageReceived() signal. By default, that will happen automatically, if an activation window has been set. \sa setActivationWindow(), messageReceived(), initialize() */ void QtSingleApplication::activateWindow() { if (actWin) { actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); actWin->raise(); actWin->activateWindow(); } } /*! \fn void QtSingleApplication::messageReceived(const QString& message) This signal is emitted when the current instance receives a \a message from another instance of this application. \sa sendMessage(), setActivationWindow(), activateWindow() */ /*! \fn void QtSingleApplication::initialize(bool dummy = true) \obsolete */ ukui-notification/3rd-parties/qtsingleapplication/src/qtlocalpeer.cpp0000664000175000017500000001215215160523734025165 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include "qtlocalpeer.h" #include #include #include #include #if defined(Q_OS_WIN) #include #include typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); static PProcessIdToSessionId pProcessIdToSessionId = 0; #endif #if defined(Q_OS_UNIX) #include #include #include #endif namespace QtLP_Private { #include "qtlockedfile.cpp" #if defined(Q_OS_WIN) #include "qtlockedfile_win.cpp" #else #include "qtlockedfile_unix.cpp" #endif } const char* QtLocalPeer::ack = "ack"; QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) : QObject(parent), id(appId) { QString prefix = id; if (id.isEmpty()) { id = QCoreApplication::applicationFilePath(); #if defined(Q_OS_WIN) id = id.toLower(); #endif prefix = id.section(QLatin1Char('/'), -1); } prefix.remove(QRegularExpression("[^a-zA-Z]")); prefix.truncate(6); QByteArray idc = id.toUtf8(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) quint16 idNum = qChecksum(idc.constData(), idc.size()); #else quint16 idNum = qChecksum(QByteArrayView(idc.constData(), idc.size())); #endif socketName = QLatin1String("qtsingleapp-") + prefix + QLatin1Char('-') + QString::number(idNum, 16); #if defined(Q_OS_WIN) if (!pProcessIdToSessionId) { QLibrary lib("kernel32"); pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); } if (pProcessIdToSessionId) { DWORD sessionId = 0; pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); socketName += QLatin1Char('-') + QString::number(sessionId, 16); } #else socketName += QLatin1Char('-') + QString::number(::getuid(), 16); #endif server = new QLocalServer(this); QString lockName = QDir(QDir::tempPath()).absolutePath() + QLatin1Char('/') + socketName + QLatin1String("-lockfile"); lockFile.setFileName(lockName); lockFile.open(QIODevice::ReadWrite); } bool QtLocalPeer::isClient() { if (lockFile.isLocked()) return false; if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) return true; bool res = server->listen(socketName); #if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) // ### Workaround if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); res = server->listen(socketName); } #endif if (!res) qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); return false; } bool QtLocalPeer::sendMessage(const QString &message, int timeout) { if (!isClient()) return false; QLocalSocket socket; bool connOk = false; for(int i = 0; i < 2; i++) { // Try twice, in case the other instance is just starting up socket.connectToServer(socketName); connOk = socket.waitForConnected(timeout/2); if (connOk || i) break; int ms = 250; #if defined(Q_OS_WIN) Sleep(DWORD(ms)); #else struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; nanosleep(&ts, NULL); #endif } if (!connOk) return false; QByteArray uMsg(message.toUtf8()); QDataStream ds(&socket); ds.writeBytes(uMsg.constData(), uMsg.size()); bool res = socket.waitForBytesWritten(timeout); if (res) { res &= socket.waitForReadyRead(timeout); // wait for ack if (res) res &= (socket.read(qstrlen(ack)) == ack); } return res; } void QtLocalPeer::receiveConnection() { QLocalSocket* socket = server->nextPendingConnection(); if (!socket) return; while (true) { if (socket->state() == QLocalSocket::UnconnectedState) { qWarning("QtLocalPeer: Peer disconnected"); delete socket; return; } if (socket->bytesAvailable() >= qint64(sizeof(quint32))) break; socket->waitForReadyRead(); } QDataStream ds(socket); QByteArray uMsg; quint32 remaining; ds >> remaining; uMsg.resize(remaining); int got = 0; char* uMsgBuf = uMsg.data(); do { got = ds.readRawData(uMsgBuf, remaining); remaining -= got; uMsgBuf += got; } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); if (got < 0) { qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); delete socket; return; } QString message(QString::fromUtf8(uMsg)); socket->write(ack, qstrlen(ack)); socket->waitForBytesWritten(1000); socket->waitForDisconnected(1000); // make sure client reads ack delete socket; emit messageReceived(message); //### (might take a long time to return) } ukui-notification/3rd-parties/qtsingleapplication/src/qtsingleapplication.h0000664000175000017500000000405715160523734026376 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #ifndef QTSINGLEAPPLICATION_H #define QTSINGLEAPPLICATION_H #include class QtLocalPeer; #if defined(Q_OS_WIN) # if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) # define QT_QTSINGLEAPPLICATION_EXPORT # elif defined(QT_QTSINGLEAPPLICATION_IMPORT) # if defined(QT_QTSINGLEAPPLICATION_EXPORT) # undef QT_QTSINGLEAPPLICATION_EXPORT # endif # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) # elif defined(QT_QTSINGLEAPPLICATION_EXPORT) # undef QT_QTSINGLEAPPLICATION_EXPORT # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) # endif #else # define QT_QTSINGLEAPPLICATION_EXPORT #endif class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication { Q_OBJECT public: QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); QtSingleApplication(const QString &id, int &argc, char **argv); #if QT_VERSION < 0x050000 QtSingleApplication(int &argc, char **argv, Type type); # if defined(Q_WS_X11) QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); # endif // Q_WS_X11 #endif // QT_VERSION < 0x050000 bool isRunning(); QString id() const; void setActivationWindow(QWidget* aw, bool activateOnMessage = true); QWidget* activationWindow() const; // Obsolete: void initialize(bool dummy = true) { isRunning(); Q_UNUSED(dummy) } public Q_SLOTS: bool sendMessage(const QString &message, int timeout = 5000); void activateWindow(); Q_SIGNALS: void messageReceived(const QString &message); private: void sysInit(const QString &appId = QString()); QtLocalPeer *peer; QWidget *actWin; }; #endif // QTSINGLEAPPLICATION_H ukui-notification/3rd-parties/qtsingleapplication/src/qtlockedfile_win.cpp0000664000175000017500000001112115160523734026170 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include "qtlockedfile.h" #include #include #define MUTEX_PREFIX "QtLockedFile mutex " // Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS #define MAX_READERS MAXIMUM_WAIT_OBJECTS #if QT_VERSION >= 0x050000 #define QT_WA(unicode, ansi) unicode #endif Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) { if (mutexname.isEmpty()) { QFileInfo fi(*this); mutexname = QString::fromLatin1(MUTEX_PREFIX) + fi.absoluteFilePath().toLower(); } QString mname(mutexname); if (idx >= 0) mname += QString::number(idx); Qt::HANDLE mutex; if (doCreate) { QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); if (!mutex) { qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); return 0; } } else { QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); if (!mutex) { if (GetLastError() != ERROR_FILE_NOT_FOUND) qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); return 0; } } return mutex; } bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) { Q_ASSERT(mutex); DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); switch (res) { case WAIT_OBJECT_0: case WAIT_ABANDONED: return true; break; case WAIT_TIMEOUT: break; default: qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); } return false; } bool QtLockedFile::lock(LockMode mode, bool block) { if (!isOpen()) { qWarning("QtLockedFile::lock(): file is not opened"); return false; } if (mode == NoLock) return unlock(); if (mode == m_lock_mode) return true; if (m_lock_mode != NoLock) unlock(); if (!wmutex && !(wmutex = getMutexHandle(-1, true))) return false; if (!waitMutex(wmutex, block)) return false; if (mode == ReadLock) { int idx = 0; for (; idx < MAX_READERS; idx++) { rmutex = getMutexHandle(idx, false); if (!rmutex || waitMutex(rmutex, false)) break; CloseHandle(rmutex); } bool ok = true; if (idx >= MAX_READERS) { qWarning("QtLockedFile::lock(): too many readers"); rmutex = 0; ok = false; } else if (!rmutex) { rmutex = getMutexHandle(idx, true); if (!rmutex || !waitMutex(rmutex, false)) ok = false; } if (!ok && rmutex) { CloseHandle(rmutex); rmutex = 0; } ReleaseMutex(wmutex); if (!ok) return false; } else { Q_ASSERT(rmutexes.isEmpty()); for (int i = 0; i < MAX_READERS; i++) { Qt::HANDLE mutex = getMutexHandle(i, false); if (mutex) rmutexes.append(mutex); } if (rmutexes.size()) { DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), TRUE, block ? INFINITE : 0); if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { if (res != WAIT_TIMEOUT) qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky unlock(); return false; } } } m_lock_mode = mode; return true; } bool QtLockedFile::unlock() { if (!isOpen()) { qWarning("QtLockedFile::unlock(): file is not opened"); return false; } if (!isLocked()) return true; if (m_lock_mode == ReadLock) { ReleaseMutex(rmutex); CloseHandle(rmutex); rmutex = 0; } else { foreach(Qt::HANDLE mutex, rmutexes) { ReleaseMutex(mutex); CloseHandle(mutex); } rmutexes.clear(); ReleaseMutex(wmutex); } m_lock_mode = QtLockedFile::NoLock; return true; } QtLockedFile::~QtLockedFile() { if (isOpen()) unlock(); if (wmutex) CloseHandle(wmutex); } ukui-notification/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.pri0000664000175000017500000000050415160523734027603 0ustar fengfengINCLUDEPATH += $$PWD DEPENDPATH += $$PWD HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp QT *= network win32:contains(TEMPLATE, lib):contains(CONFIG, shared) { DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport) } ukui-notification/3rd-parties/qtsingleapplication/src/qtsinglecoreapplication.cpp0000664000175000017500000000661515160523734027604 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include "qtsinglecoreapplication.h" #include "qtlocalpeer.h" /*! \class QtSingleCoreApplication qtsinglecoreapplication.h \brief A variant of the QtSingleApplication class for non-GUI applications. This class is a variant of QtSingleApplication suited for use in console (non-GUI) applications. It is an extension of QCoreApplication (instead of QApplication). It does not require the QtGui library. The API and usage is identical to QtSingleApplication, except that functions relating to the "activation window" are not present, for obvious reasons. Please refer to the QtSingleApplication documentation for explanation of the usage. A QtSingleCoreApplication instance can communicate to a QtSingleApplication instance if they share the same application id. Hence, this class can be used to create a light-weight command-line tool that sends commands to a GUI application. \sa QtSingleApplication */ /*! Creates a QtSingleCoreApplication object. The application identifier will be QCoreApplication::applicationFilePath(). \a argc and \a argv are passed on to the QCoreAppliation constructor. */ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); } /*! Creates a QtSingleCoreApplication object with the application identifier \a appId. \a argc and \a argv are passed on to the QCoreAppliation constructor. */ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this, appId); connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); } /*! Returns true if another instance of this application is running; otherwise false. This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session). \sa sendMessage() */ bool QtSingleCoreApplication::isRunning() { return peer->isClient(); } /*! Tries to send the text \a message to the currently running instance. The QtSingleCoreApplication object in the running instance will emit the messageReceived() signal when it receives the message. This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within \a timeout milliseconds, this function return false. \sa isRunning(), messageReceived() */ bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) { return peer->sendMessage(message, timeout); } /*! Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application. */ QString QtSingleCoreApplication::id() const { return peer->applicationId(); } /*! \fn void QtSingleCoreApplication::messageReceived(const QString& message) This signal is emitted when the current instance receives a \a message from another instance of this application. \sa sendMessage() */ ukui-notification/3rd-parties/qtsingleapplication/src/QtSingleApplication0000664000175000017500000000004115160523734025775 0ustar fengfeng#include "qtsingleapplication.h" ukui-notification/3rd-parties/qtsingleapplication/doc/0000775000175000017500000000000015160523734022123 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/doc/images/0000775000175000017500000000000015160523734023370 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/doc/images/qt-logo.png0000664000175000017500000000775315160523734025474 0ustar fengfengPNG  IHDR9C:uIDATxb?bhJnJnJnJnJnJnԡ Є`r'Q( !!Nb_p??F&F312G.yG&ޏ?}eWSSgb( ~™t齸g0sVv`fcdY8E$xdUUex$xd9DDr=#gdd|Uףw9D- 2b8Ͽebddceᔐ╗SWScaB#cfd]-I\ _20110`xzw/).#'˯"ǯ*˫,+')@lY@}fۯͼ 2@d$1H')&#'ç,ϯ*˧,#/%́XgfdOX8Y9s2GC3g@ fFff.3O|v ,l%?fR_|bb`y엉3+ԇ,̌,4 "ͭ32>{E4އ ˯NԦ+Qefdϛ?6:&Ǜ?|"=\n$FFfF /0"`ddf cfbb`dx՛o yAP ,,eebWaá,QܬLL>5Lll10 m00wTVxOÚ bGB8GtUմXplII ׶R/@2 Y{ ]d9#ule+}N6XfJ"խJ13002³ @K"ŭzo?1000@{ lϿ`?ï2"ecgd H.fFfɆ}Ͽߌ"٭윌 y02000Ac<\po/."?;#ߛ!hgddd\<|\300<|?j"-U L9D8E i[ZP?z5fF6? o"b')~?3311g/ ֯cz߿>pvfL~g'""٭Qd'i `Ϳ'?HۅǞy?200 %)h1.7?."ͭ 32yVfFfGyO/:?LL [,?/?^}|:`luX-tN X"_CkǶ>w:7WlSofFcOv{OD7톚)*$@d"7$1CRgɉi[!.f&v_#ɧ{='JXXc`agպ]R\̅?ӧ_ᄏvѦ_2"g|fە(m )\!&&&F{ ba~>qci.O?l-"s܅Ǐ<Ϟn%hm)tN6P߿0H~̌,|ןhmF>1:19_/رcc7k䱞]ۯ咒SaB[?|}kf~?ɍkF/>9*qpQ( @##ïe1| QXn_ #ơp7B]X?F[a'K+ q/̌,,L L 7tDʡz /#300VnC")"/?110qp￿l_GVWNOU_UIPSCؐ?\e``=_R(2r-d?ÿ_?+78$$ +:xBVFn^?cbdd@yĂf```aba㔆L)J sI2Ҥ!#3 > ^y^~o (?+33d:.cfL(H*sJ`Mg222ڥž15,l l"< QtSingleApplication Class Reference
  Home

QtSingleApplication Class Reference

The QtSingleApplication class provides an API to detect and communicate with running instances of an application. More...

 #include <QtSingleApplication>

Inherits QApplication.


Public Functions

QtSingleApplication ( int & argc, char ** argv, bool GUIenabled = true )
QtSingleApplication ( const QString & appId, int & argc, char ** argv )
QtSingleApplication ( int & argc, char ** argv, Type type )
QtSingleApplication ( Display * dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
QtSingleApplication ( Display * dpy, int & argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
QtSingleApplication ( Display * dpy, const QString & appId, int argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
QWidget * activationWindow () const
QString id () const
bool isRunning ()
void setActivationWindow ( QWidget * aw, bool activateOnMessage = true )

Public Slots

void activateWindow ()
bool sendMessage ( const QString & message, int timeout = 5000 )

Signals

void messageReceived ( const QString & message )

Additional Inherited Members


Detailed Description

The QtSingleApplication class provides an API to detect and communicate with running instances of an application.

This class allows you to create applications where only one instance should be running at a time. I.e., if the user tries to launch another instance, the already running instance will be activated instead. Another usecase is a client-server system, where the first started instance will assume the role of server, and the later instances will act as clients of that server.

By default, the full path of the executable file is used to determine whether two processes are instances of the same application. You can also provide an explicit identifier string that will be compared instead.

The application should create the QtSingleApplication object early in the startup phase, and call isRunning() to find out if another instance of this application is already running. If isRunning() returns false, it means that no other instance is running, and this instance has assumed the role as the running instance. In this case, the application should continue with the initialization of the application user interface before entering the event loop with exec(), as normal.

The messageReceived() signal will be emitted when the running application receives messages from another instance of the same application. When a message is received it might be helpful to the user to raise the application so that it becomes visible. To facilitate this, QtSingleApplication provides the setActivationWindow() function and the activateWindow() slot.

If isRunning() returns true, another instance is already running. It may be alerted to the fact that another instance has started by using the sendMessage() function. Also data such as startup parameters (e.g. the name of the file the user wanted this new instance to open) can be passed to the running instance with this function. Then, the application should terminate (or enter client mode).

If isRunning() returns true, but sendMessage() fails, that is an indication that the running instance is frozen.

Here's an example that shows how to convert an existing application to use QtSingleApplication. It is very simple and does not make use of all QtSingleApplication's functionality (see the examples for that).

 // Original
 int main(int argc, char **argv)
 {
     QApplication app(argc, argv);

     MyMainWidget mmw;
     mmw.show();
     return app.exec();
 }

 // Single instance
 int main(int argc, char **argv)
 {
     QtSingleApplication app(argc, argv);

     if (app.isRunning())
         return !app.sendMessage(someDataString);

     MyMainWidget mmw;
     app.setActivationWindow(&mmw);
     mmw.show();
     return app.exec();
 }

Once this QtSingleApplication instance is destroyed (normally when the process exits or crashes), when the user next attempts to run the application this instance will not, of course, be encountered. The next instance to call isRunning() or sendMessage() will assume the role as the new running instance.

For console (non-GUI) applications, QtSingleCoreApplication may be used instead of this class, to avoid the dependency on the QtGui library.

See also QtSingleCoreApplication.


Member Function Documentation

QtSingleApplication::QtSingleApplication ( int & argc, char ** argv, bool GUIenabled = true )

Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). argc, argv, and GUIenabled are passed on to the QAppliation constructor.

If you are creating a console application (i.e. setting GUIenabled to false), you may consider using QtSingleCoreApplication instead.

QtSingleApplication::QtSingleApplication ( const QString & appId, int & argc, char ** argv )

Creates a QtSingleApplication object with the application identifier appId. argc and argv are passed on to the QAppliation constructor.

QtSingleApplication::QtSingleApplication ( int & argc, char ** argv, Type type )

Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). argc, argv, and type are passed on to the QAppliation constructor.

QtSingleApplication::QtSingleApplication ( Display * dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )

Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). dpy, visual, and cmap are passed on to the QApplication constructor.

QtSingleApplication::QtSingleApplication ( Display * dpy, int & argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )

Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). dpy, argc, argv, visual, and cmap are passed on to the QApplication constructor.

QtSingleApplication::QtSingleApplication ( Display * dpy, const QString & appId, int argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )

Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be appId. dpy, argc, argv, visual, and cmap are passed on to the QApplication constructor.

void QtSingleApplication::activateWindow ()   [slot]

De-minimizes, raises, and activates this application's activation window. This function does nothing if no activation window has been set.

This is a convenience function to show the user that this application instance has been activated when he has tried to start another instance.

This function should typically be called in response to the messageReceived() signal. By default, that will happen automatically, if an activation window has been set.

See also setActivationWindow(), messageReceived(), and initialize().

QWidget * QtSingleApplication::activationWindow () const

Returns the applications activation window if one has been set by calling setActivationWindow(), otherwise returns 0.

See also setActivationWindow().

QString QtSingleApplication::id () const

Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application.

bool QtSingleApplication::isRunning ()

Returns true if another instance of this application is running; otherwise false.

This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session).

See also sendMessage().

void QtSingleApplication::messageReceived ( const QString & message )   [signal]

This signal is emitted when the current instance receives a message from another instance of this application.

See also sendMessage(), setActivationWindow(), and activateWindow().

bool QtSingleApplication::sendMessage ( const QString & message, int timeout = 5000 )   [slot]

Tries to send the text message to the currently running instance. The QtSingleApplication object in the running instance will emit the messageReceived() signal when it receives the message.

This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within timeout milliseconds, this function return false.

See also isRunning() and messageReceived().

void QtSingleApplication::setActivationWindow ( QWidget * aw, bool activateOnMessage = true )

Sets the activation window of this application to aw. The activation window is the widget that will be activated by activateWindow(). This is typically the application's main window.

If activateOnMessage is true (the default), the window will be activated automatically every time a message is received, just prior to the messageReceived() signal being emitted.

See also activationWindow(), activateWindow(), and messageReceived().


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-members.html0000664000175000017500000007370215160523734031470 0ustar fengfeng List of All Members for QtSingleApplication
  Home

List of All Members for QtSingleApplication

This is the complete list of members for QtSingleApplication, including inherited members.


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.dcf0000664000175000017500000000507115160523734027622 0ustar fengfeng
QtSingleApplication activateWindow activationWindow id isRunning messageReceived sendMessage setActivationWindow
QtSingleCoreApplication id isRunning messageReceived sendMessage
A non-GUI example
A Trivial Example
Loading Documents
Single Application
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-trivial.html0000664000175000017500000001243415160523734033134 0ustar fengfeng A Trivial Example
  Home

A Trivial Example

The application in this example has a log-view that displays messages sent by further instances of the same application.

The example demonstrates the use of the QtSingleApplication class to detect and communicate with a running instance of the application using the sendMessage() API. The messageReceived() signal is used to display received messages in a QTextEdit log.

 /****************************************************************************
 **
 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 ** Contact: http://www.qt-project.org/legal
 **
 ** This file is part of the Qt Solutions component.
 **
 ** You may use this file under the terms of the BSD license as follows:
 **
 ** "Redistribution and use in source and binary forms, with or without
 ** modification, are permitted provided that the following conditions are
 ** met:
 **   * Redistributions of source code must retain the above copyright
 **     notice, this list of conditions and the following disclaimer.
 **   * Redistributions in binary form must reproduce the above copyright
 **     notice, this list of conditions and the following disclaimer in
 **     the documentation and/or other materials provided with the
 **     distribution.
 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
 **     the names of its contributors may be used to endorse or promote
 **     products derived from this software without specific prior written
 **     permission.
 **
 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 **
 ****************************************************************************/

 #include <qtsingleapplication.h>
 #include <QtGui/QTextEdit>

 class TextEdit : public QTextEdit
 {
     Q_OBJECT
 public:
     TextEdit(QWidget *parent = 0)
         : QTextEdit(parent)
     {}
 public slots:
     void append(const QString &str)
     {
         QTextEdit::append(str);
     }
 };

 #include "main.moc"

 int main(int argc, char **argv)
 {
     QtSingleApplication instance(argc, argv);

The example has only the main entry point function. A QtSingleApplication object is created immediately.

     if (instance.sendMessage("Wake up!"))
         return 0;

If another instance of this application is already running, sendMessage() will succeed, and this instance just exits immediately.

     TextEdit logview;
     logview.setReadOnly(true);
     logview.show();

Otherwise the instance continues as normal and creates the user interface.

     instance.setActivationWindow(&logview);

     QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
                      &logview, SLOT(append(const QString&)));

     return instance.exec();

The logview object is also set as the application's activation window. Every time a message is received, the window will be raised and activated automatically.

The messageReceived() signal is also connected to the QTextEdit's append() slot. Every message received from further instances of this application will be displayed in the log.

Finally the event loop is entered.


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/images/0000775000175000017500000000000015160523734024334 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/doc/html/images/qt-logo.png0000664000175000017500000000775315160523734026440 0ustar fengfengPNG  IHDR9C:uIDATxb?bhJnJnJnJnJnJnԡ Є`r'Q( !!Nb_p??F&F312G.yG&ޏ?}eWSSgb( ~™t齸g0sVv`fcdY8E$xdUUex$xd9DDr=#gdd|Uףw9D- 2b8Ͽebddceᔐ╗SWScaB#cfd]-I\ _20110`xzw/).#'˯"ǯ*˫,+')@lY@}fۯͼ 2@d$1H')&#'ç,ϯ*˧,#/%́XgfdOX8Y9s2GC3g@ fFff.3O|v ,l%?fR_|bb`y엉3+ԇ,̌,4 "ͭ32>{E4އ ˯NԦ+Qefdϛ?6:&Ǜ?|"=\n$FFfF /0"`ddf cfbb`dx՛o yAP ,,eebWaá,QܬLL>5Lll10 m00wTVxOÚ bGB8GtUմXplII ׶R/@2 Y{ ]d9#ule+}N6XfJ"խJ13002³ @K"ŭzo?1000@{ lϿ`?ï2"ecgd H.fFfɆ}Ͽߌ"٭윌 y02000Ac<\po/."?;#ߛ!hgddd\<|\300<|?j"-U L9D8E i[ZP?z5fF6? o"b')~?3311g/ ֯cz߿>pvfL~g'""٭Qd'i `Ϳ'?HۅǞy?200 %)h1.7?."ͭ 32yVfFfGyO/:?LL [,?/?^}|:`luX-tN X"_CkǶ>w:7WlSofFcOv{OD7톚)*$@d"7$1CRgɉi[!.f&v_#ɧ{='JXXc`agպ]R\̅?ӧ_ᄏvѦ_2"g|fە(m )\!&&&F{ ba~>qci.O?l-"s܅Ǐ<Ϟn%hm)tN6P߿0H~̌,|ןhmF>1:19_/رcc7k䱞]ۯ咒SaB[?|}kf~?ɍkF/>9*qpQ( @##ïe1| QXn_ #ơp7B]X?F[a'K+ q/̌,,L L 7tDʡz /#300VnC")"/?110qp￿l_GVWNOU_UIPSCؐ?\e``=_R(2r-d?ÿ_?+78$$ +:xBVFn^?cbdd@yĂf```aba㔆L)J sI2Ҥ!#3 > ^y^~o (?+33d:.cfL(H*sJ`Mg222ڥž15,l l"< A non-GUI example
  Home

A non-GUI example

This example shows how to use the single-application functionality in a console application. It does not require the QtGui library at all.

The only differences from the GUI application usage demonstrated in the other examples are:

1) The .pro file should include qtsinglecoreapplication.pri instead of qtsingleapplication.pri

2) The class name is QtSingleCoreApplication instead of QtSingleApplication.

3) No calls are made regarding window activation, for obvious reasons.

console.pro:

 TEMPLATE   = app
 CONFIG    += console
 SOURCES   += main.cpp
 include(../../src/qtsinglecoreapplication.pri)
 QT -= gui

main.cpp:

 /****************************************************************************
 **
 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 ** Contact: http://www.qt-project.org/legal
 **
 ** This file is part of the Qt Solutions component.
 **
 ** You may use this file under the terms of the BSD license as follows:
 **
 ** "Redistribution and use in source and binary forms, with or without
 ** modification, are permitted provided that the following conditions are
 ** met:
 **   * Redistributions of source code must retain the above copyright
 **     notice, this list of conditions and the following disclaimer.
 **   * Redistributions in binary form must reproduce the above copyright
 **     notice, this list of conditions and the following disclaimer in
 **     the documentation and/or other materials provided with the
 **     distribution.
 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
 **     the names of its contributors may be used to endorse or promote
 **     products derived from this software without specific prior written
 **     permission.
 **
 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 **
 ****************************************************************************/

 #include "qtsinglecoreapplication.h"
 #include <QtCore/QDebug>

 void report(const QString& msg)
 {
     qDebug("[%i] %s", (int)QCoreApplication::applicationPid(), qPrintable(msg));
 }

 class MainClass : public QObject
 {
     Q_OBJECT
 public:
     MainClass()
         : QObject()
         {}

 public slots:
     void handleMessage(const QString& message)
         {
             report( "Message received: \"" + message + "\"");
         }
 };

 int main(int argc, char **argv)
 {
     report("Starting up");

     QtSingleCoreApplication app(argc, argv);

     if (app.isRunning()) {
         QString msg(QString("Hi master, I am %1.").arg(QCoreApplication::applicationPid()));
         bool sentok = app.sendMessage(msg, 2000);
         QString rep("Another instance is running, so I will exit.");
         rep += sentok ? " Message sent ok." : " Message sending failed; the other instance may be frozen.";
         report(rep);
         return 0;
     } else {
         report("No other instance is running; so I will.");
         MainClass mainObj;
         QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
                          &mainObj, SLOT(handleMessage(const QString&)));
         return app.exec();
     }
 }

 #include "main.moc"


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-example-loader.html0000664000175000017500000001670015160523734032730 0ustar fengfeng Loading Documents
  Home

Loading Documents

The application in this example loads or prints the documents passed as commandline parameters to further instances of this application.

 /****************************************************************************
 **
 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 ** Contact: http://www.qt-project.org/legal
 **
 ** This file is part of the Qt Solutions component.
 **
 ** You may use this file under the terms of the BSD license as follows:
 **
 ** "Redistribution and use in source and binary forms, with or without
 ** modification, are permitted provided that the following conditions are
 ** met:
 **   * Redistributions of source code must retain the above copyright
 **     notice, this list of conditions and the following disclaimer.
 **   * Redistributions in binary form must reproduce the above copyright
 **     notice, this list of conditions and the following disclaimer in
 **     the documentation and/or other materials provided with the
 **     distribution.
 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
 **     the names of its contributors may be used to endorse or promote
 **     products derived from this software without specific prior written
 **     permission.
 **
 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 **
 ****************************************************************************/

 #include <qtsingleapplication.h>
 #include <QtCore/QFile>
 #include <QtGui/QMainWindow>
 #include <QtGui/QPrinter>
 #include <QtGui/QPainter>
 #include <QtGui/QTextEdit>
 #include <QtGui/QMdiArea>
 #include <QtCore/QTextStream>

 class MainWindow : public QMainWindow
 {
     Q_OBJECT
 public:
     MainWindow();

 public slots:
     void handleMessage(const QString& message);

 signals:
     void needToShow();

 private:
     QMdiArea *workspace;
 };

The user interface in this application is a QMainWindow subclass with a QMdiArea as the central widget. It implements a slot handleMessage() that will be connected to the messageReceived() signal of the QtSingleApplication class.

 MainWindow::MainWindow()
 {
     workspace = new QMdiArea(this);

     setCentralWidget(workspace);
 }

The MainWindow constructor creates a minimal user interface.

 void MainWindow::handleMessage(const QString& message)
 {
     enum Action {
         Nothing,
         Open,
         Print
     } action;

     action = Nothing;
     QString filename = message;
     if (message.toLower().startsWith("/print ")) {
         filename = filename.mid(7);
         action = Print;
     } else if (!message.isEmpty()) {
         action = Open;
     }
     if (action == Nothing) {
         emit needToShow();
         return;
     }

     QFile file(filename);
     QString contents;
     if (file.open(QIODevice::ReadOnly))
         contents = file.readAll();
     else
         contents = "[[Error: Could not load file " + filename + "]]";

     QTextEdit *view = new QTextEdit;
     view->setPlainText(contents);

     switch(action) {

The handleMessage() slot interprets the message passed in as a filename that can be prepended with /print to indicate that the file should just be printed rather than loaded.

     case Print:
         {
             QPrinter printer;
             view->print(&printer);
             delete view;
         }
         break;

     case Open:
         {
             workspace->addSubWindow(view);
             view->setWindowTitle(message);
             view->show();
             emit needToShow();
         }
         break;
     default:
         break;
     };
 }

Loading the file will also activate the window.

 #include "main.moc"

 int main(int argc, char **argv)
 {
     QtSingleApplication instance("File loader QtSingleApplication example", argc, argv);
     QString message;
     for (int a = 1; a < argc; ++a) {
         message += argv[a];
         if (a < argc-1)
             message += " ";
     }

     if (instance.sendMessage(message))
         return 0;

The main entry point function creates a QtSingleApplication object, and creates a message to send to a running instance of the application. If the message was sent successfully the process exits immediately.

     MainWindow mw;
     mw.handleMessage(message);
     mw.show();

     QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
                      &mw, SLOT(handleMessage(const QString&)));

     instance.setActivationWindow(&mw, false);
     QObject::connect(&mw, SIGNAL(needToShow()), &instance, SLOT(activateWindow()));

     return instance.exec();
 }

If the message could not be sent the application starts up. Note that false is passed to the call to setActivationWindow() to prevent automatic activation for every message received, e.g. when the application should just print a file. Instead, the message handling function determines whether activation is requested, and signals that by emitting the needToShow() signal. This is then simply connected directly to QtSingleApplication's activateWindow() slot.


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication.html0000664000175000017500000002356615160523734030714 0ustar fengfeng QtSingleCoreApplication Class Reference
  Home

QtSingleCoreApplication Class Reference

A variant of the QtSingleApplication class for non-GUI applications. More...

 #include <QtSingleCoreApplication>

Inherits QCoreApplication.


Public Functions

QtSingleCoreApplication ( int & argc, char ** argv )
QtSingleCoreApplication ( const QString & appId, int & argc, char ** argv )
QString id () const
bool isRunning ()

Public Slots

bool sendMessage ( const QString & message, int timeout = 5000 )

Signals

void messageReceived ( const QString & message )

Additional Inherited Members


Detailed Description

A variant of the QtSingleApplication class for non-GUI applications.

This class is a variant of QtSingleApplication suited for use in console (non-GUI) applications. It is an extension of QCoreApplication (instead of QApplication). It does not require the QtGui library.

The API and usage is identical to QtSingleApplication, except that functions relating to the "activation window" are not present, for obvious reasons. Please refer to the QtSingleApplication documentation for explanation of the usage.

A QtSingleCoreApplication instance can communicate to a QtSingleApplication instance if they share the same application id. Hence, this class can be used to create a light-weight command-line tool that sends commands to a GUI application.

See also QtSingleApplication.


Member Function Documentation

QtSingleCoreApplication::QtSingleCoreApplication ( int & argc, char ** argv )

Creates a QtSingleCoreApplication object. The application identifier will be QCoreApplication::applicationFilePath(). argc and argv are passed on to the QCoreAppliation constructor.

QtSingleCoreApplication::QtSingleCoreApplication ( const QString & appId, int & argc, char ** argv )

Creates a QtSingleCoreApplication object with the application identifier appId. argc and argv are passed on to the QCoreAppliation constructor.

QString QtSingleCoreApplication::id () const

Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application.

bool QtSingleCoreApplication::isRunning ()

Returns true if another instance of this application is running; otherwise false.

This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session).

See also sendMessage().

void QtSingleCoreApplication::messageReceived ( const QString & message )   [signal]

This signal is emitted when the current instance receives a message from another instance of this application.

See also sendMessage().

bool QtSingleCoreApplication::sendMessage ( const QString & message, int timeout = 5000 )   [slot]

Tries to send the text message to the currently running instance. The QtSingleCoreApplication object in the running instance will emit the messageReceived() signal when it receives the message.

This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within timeout milliseconds, this function return false.

See also isRunning() and messageReceived().


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsinglecoreapplication-members.html0000664000175000017500000003577715160523734032353 0ustar fengfeng List of All Members for QtSingleCoreApplication
  Home

List of All Members for QtSingleCoreApplication

This is the complete list of members for QtSingleCoreApplication, including inherited members.


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.index0000664000175000017500000003171415160523734030200 0ustar fengfeng ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication-obsolete.html0000664000175000017500000000372115160523734031644 0ustar fengfeng Obsolete Members for QtSingleApplication
  Home

Obsolete Members for QtSingleApplication

The following class members are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

Public Functions

void initialize ( bool dummy = true )   (obsolete)

Member Function Documentation

void QtSingleApplication::initialize ( bool dummy = true )


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/doc/html/qtsingleapplication.qhp0000664000175000017500000000741115160523734027656 0ustar fengfeng com.nokia.qtsolutions.qtsingleapplication_head qdoc qt solutions qtsingleapplication qt solutions qtsingleapplication
qtsingleapplication.html index.html qtsingleapplication-example-trivial.html qtsinglecoreapplication.html qtsingleapplication-example-loader.html qtsinglecoreapplication-example-console.html classic.css images/qt-logo.png ukui-notification/3rd-parties/qtsingleapplication/doc/html/index.html0000664000175000017500000000527515160523734025075 0ustar fengfeng Single Application
  Home

Single Application

Description

The QtSingleApplication component provides support for applications that can be only started once per user.

For some applications it is useful or even critical that they are started only once by any user. Future attempts to start the application should activate any already running instance, and possibly perform requested actions, e.g. loading a file, in that instance.

The QtSingleApplication class provides an interface to detect a running instance, and to send command strings to that instance. For console (non-GUI) applications, the QtSingleCoreApplication variant is provided, which avoids dependency on QtGui.

Classes

Examples

Tested platforms

  • Qt 4.4, 4.5 / Windows XP / MSVC.NET 2005
  • Qt 4.4, 4.5 / Linux / gcc
  • Qt 4.4, 4.5 / MacOS X 10.5 / gcc


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions
ukui-notification/3rd-parties/qtsingleapplication/configure.bat0000664000175000017500000000176215160523734024035 0ustar fengfeng:: Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). :: SPDX-License-Identifier: BSD-3-Clause @echo off rem rem "Main" rem if not "%1"=="" ( if not "%1"=="-library" ( call :PrintUsage goto EOF ) ) if exist config.pri. del config.pri if "%1"=="-library" ( echo Configuring to build this component as a dynamic library. echo SOLUTIONS_LIBRARY = yes > config.pri ) echo . echo This component is now configured. echo . echo To build the component library (if requested) and example(s), echo run qmake and your make or nmake command. echo . echo To remove or reconfigure, run make (nmake) distclean. echo . goto EOF :PrintUsage echo Usage: configure.bat [-library] echo . echo -library: Build the component as a dynamic library (DLL). Default is to echo include the component source directly in the application. echo A DLL may be preferable for technical or licensing (LGPL) reasons. echo . goto EOF :EOF ukui-notification/3rd-parties/qtsingleapplication/common.pri0000664000175000017500000000124715160523734023366 0ustar fengfengexists(config.pri):infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtsingleapplication-uselib TEMPLATE += fakelib greaterThan(QT_MAJOR_VERSION, 5)|\ if(equals(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 4))|\ if(equals(QT_MAJOR_VERSION, 5):equals(QT_MINOR_VERSION, 4):greaterThan(QT_PATCH_VERSION, 1)) { QTSINGLEAPPLICATION_LIBNAME = $$qt5LibraryTarget(QtSolutions_SingleApplication-head) } else { QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-head) } TEMPLATE -= fakelib QTSINGLEAPPLICATION_LIBDIR = $$PWD/lib unix:qtsingleapplication-uselib:!qtsingleapplication-buildlib:QMAKE_RPATHDIR += $$QTSINGLEAPPLICATION_LIBDIR ukui-notification/3rd-parties/qtsingleapplication/qtsingleapplication.pro0000664000175000017500000000016515160523734026154 0ustar fengfengTEMPLATE=subdirs CONFIG += ordered include(common.pri) qtsingleapplication-uselib:SUBDIRS=buildlib SUBDIRS+=examples ukui-notification/3rd-parties/qtsingleapplication/README.TXT0000664000175000017500000000164115160523734022716 0ustar fengfengQt Solutions Component: Single Application The QtSingleApplication component provides support for applications that can be only started once per user. Version history: 2.0: - Version 1.3 ported to Qt 4. 2.1: - Fix compilation problem on Mac. 2.2: - Really fix the Mac compilation problem. - Mac: fix crash due to wrong object releasing. - Mac: Fix memory leak. 2.3: - Windows: Force creation of internal widget to make it work with Qt 4.2. 2.4: - Fix the system for automatic window raising on message reception. NOTE: minor API change. 2.5: - Mac: Fix isRunning() to work and report correctly. 2.6: - - initialize() is now obsolete, no longer necessary to call it - - Fixed race condition where multiple instances migth be started - - QtSingleCoreApplication variant provided for non-GUI (console) usage - Complete reimplementation. Visible changes: - LGPL release. ukui-notification/3rd-parties/qtsingleapplication/INSTALL.TXT0000664000175000017500000002237415160523734023075 0ustar fengfengINSTALLATION INSTRUCTIONS These instructions refer to the package you are installing as some-package.tar.gz or some-package.zip. The .zip file is intended for use on Windows. The directory you choose for the installation will be referred to as your-install-dir. Note to Qt Visual Studio Integration users: In the instructions below, instead of building from command line with nmake, you can use the menu command 'Qt->Open Solution from .pro file' on the .pro files in the example and plugin directories, and then build from within Visual Studio. Unpacking and installation -------------------------- 1. Unpacking the archive (if you have not done so already). On Unix and Mac OS X (in a terminal window): cd your-install-dir gunzip some-package.tar.gz tar xvf some-package.tar This creates the subdirectory some-package containing the files. On Windows: Unpack the .zip archive by right-clicking it in explorer and choosing "Extract All...". If your version of Windows does not have zip support, you can use the infozip tools available from www.info-zip.org. If you are using the infozip tools (in a command prompt window): cd your-install-dir unzip some-package.zip 2. Configuring the package. The configure script is called "configure" on unix/mac and "configure.bat" on Windows. It should be run from a command line after cd'ing to the package directory. You can choose whether you want to use the component by including its source code directly into your project, or build the component as a dynamic shared library (DLL) that is loaded into the application at run-time. The latter may be preferable for technical or licensing (LGPL) reasons. If you want to build a DLL, run the configure script with the argument "-library". Also see the note about usage below. (Components that are Qt plugins, e.g. styles and image formats, are by default built as a plugin DLL.) The configure script will prompt you in some cases for further information. Answer these questions and carefully read the license text before accepting the license conditions. The package cannot be used if you do not accept the license conditions. 3. Building the component and examples (when required). If a DLL is to be built, or if you would like to build the examples, next give the commands qmake make [or nmake if your are using Microsoft Visual C++] The example program(s) can be found in the directory called "examples" or "example". Components that are Qt plugins, e.g. styles and image formats, are ready to be used as soon as they are built, so the rest of this installation instruction can be skipped. 4. Building the Qt Designer plugin (optional). Some of the widget components are provided with plugins for Qt Designer. To build and install the plugin, cd into the some-package/plugin directory and give the commands qmake make [or nmake if your are using Microsoft Visual C++] Restart Qt Designer to make it load the new widget plugin. Note: If you are using the built-in Qt Designer from the Qt Visual Studio Integration, you will need to manually copy the plugin DLL file, i.e. copy %QTDIR%\plugins\designer\some-component.dll to the Qt Visual Studio Integration plugin path, typically: C:\Program Files\Trolltech\Qt VS Integration\plugins Note: If you for some reason are using a Qt Designer that is built in debug mode, you will need to build the plugin in debug mode also. Edit the file plugin.pro in the plugin directory, changing 'release' to 'debug' in the CONFIG line, before running qmake. Solutions components are intended to be used directly from the package directory during development, so there is no 'make install' procedure. Using a component in your project --------------------------------- To use this component in your project, add the following line to the project's .pro file (or do the equivalent in your IDE): include(your-install-dir/some-package/src/some-package.pri) This adds the package's sources and headers to the SOURCES and HEADERS project variables respectively (or, if the component has been configured as a DLL, it adds that library to the LIBS variable), and updates INCLUDEPATH to contain the package's src directory. Additionally, the .pri file may include some dependencies needed by the package. To include a header file from the package in your sources, you can now simply use: #include or alternatively, in pre-Qt 4 style: #include Refer to the documentation to see the classes and headers this components provides. Install documentation (optional) -------------------------------- The HTML documentation for the package's classes is located in the your-install-dir/some-package/doc/html/index.html. You can open this file and read the documentation with any web browser. To install the documentation into Qt Assistant (for Qt version 4.4 and later): 1. In Assistant, open the Edit->Preferences dialog and choose the Documentation tab. Click the Add... button and select the file your-install-dir/some-package/doc/html/some-package.qch For Qt versions prior to 4.4, do instead the following: 1. The directory your-install-dir/some-package/doc/html contains a file called some-package.dcf. Execute the following commands in a shell, command prompt or terminal window: cd your-install-dir/some-package/doc/html/ assistant -addContentFile some-package.dcf The next time you start Qt Assistant, you can access the package's documentation. Removing the documentation from assistant ----------------------------------------- If you have installed the documentation into Qt Assistant, and want to uninstall it, do as follows, for Qt version 4.4 and later: 1. In Assistant, open the Edit->Preferences dialog and choose the Documentation tab. In the list of Registered Documentation, select the item com.nokia.qtsolutions.some-package_version, and click the Remove button. For Qt versions prior to 4.4, do instead the following: 1. The directory your-install-dir/some-package/doc/html contains a file called some-package.dcf. Execute the following commands in a shell, command prompt or terminal window: cd your-install-dir/some-package/doc/html/ assistant -removeContentFile some-package.dcf Using the component as a DLL ---------------------------- 1. Normal components The shared library (DLL) is built and placed in the some-package/lib directory. It is intended to be used directly from there during development. When appropriate, both debug and release versions are built, since the run-time linker will in some cases refuse to load a debug-built DLL into a release-built application or vice versa. The following steps are taken by default to help the dynamic linker to locate the DLL at run-time (during development): Unix: The some-package.pri file will add linker instructions to add the some-package/lib directory to the rpath of the executable. (When distributing, or if your system does not support rpath, you can copy the shared library to another place that is searched by the dynamic linker, e.g. the "lib" directory of your Qt installation.) Mac: The full path to the library is hardcoded into the library itself, from where it is copied into the executable at link time, and ready by the dynamic linker at run-time. (When distributing, you will want to edit these hardcoded paths in the same way as for the Qt DLLs. Refer to the document "Deploying an Application on Mac OS X" in the Qt Reference Documentation.) Windows: the .dll file(s) are copied into the "bin" directory of your Qt installation. The Qt installation will already have set up that directory to be searched by the dynamic linker. 2. Plugins For Qt Solutions plugins (e.g. image formats), both debug and release versions of the plugin are built by default when appropriate, since in some cases the release Qt library will not load a debug plugin, and vice versa. The plugins are automatically copied into the plugins directory of your Qt installation when built, so no further setup is required. Plugins may also be built statically, i.e. as a library that will be linked into your application executable, and so will not need to be redistributed as a separate plugin DLL to end users. Static building is required if Qt itself is built statically. To do it, just add "static" to the CONFIG variable in the plugin/plugin.pro file before building. Refer to the "Static Plugins" section in the chapter "How to Create Qt Plugins" for explanation of how to use a static plugin in your application. The source code of the example program(s) will also typically contain the relevant instructions as comments. Uninstalling ------------ The following command will remove any fils that have been automatically placed outside the package directory itself during installation and building make distclean [or nmake if your are using Microsoft Visual C++] If Qt Assistant documentation or Qt Designer plugins have been installed, they can be uninstalled manually, ref. above. Enjoy! :) - The Qt Solutions Team. ukui-notification/3rd-parties/qtsingleapplication/examples/0000775000175000017500000000000015160523734023174 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/examples/examples.pro0000664000175000017500000000011115160523734025525 0ustar fengfengTEMPLATE = subdirs SUBDIRS = trivial \ loader \ console ukui-notification/3rd-parties/qtsingleapplication/examples/trivial/0000775000175000017500000000000015160523734024646 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/examples/trivial/trivial.qdoc0000664000175000017500000000271115160523734027171 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause /*! \page qtsingleapplication-example-trivial.html \title A Trivial Example The application in this example has a log-view that displays messages sent by further instances of the same application. The example demonstrates the use of the QtSingleApplication class to detect and communicate with a running instance of the application using the sendMessage() API. The messageReceived() signal is used to display received messages in a QTextEdit log. \quotefromfile trivial/main.cpp \printuntil instance The example has only the \c main entry point function. A QtSingleApplication object is created immediately. \printuntil return If another instance of this application is already running, sendMessage() will succeed, and this instance just exits immediately. \printuntil show() Otherwise the instance continues as normal and creates the user interface. \printuntil return instance.exec(); The \c logview object is also set as the application's activation window. Every time a message is received, the window will be raised and activated automatically. The messageReceived() signal is also connected to the QTextEdit's append() slot. Every message received from further instances of this application will be displayed in the log. Finally the event loop is entered. */ ukui-notification/3rd-parties/qtsingleapplication/examples/trivial/trivial.pro0000664000175000017500000000012115160523734027034 0ustar fengfengTEMPLATE = app include(../../src/qtsingleapplication.pri) SOURCES += main.cpp ukui-notification/3rd-parties/qtsingleapplication/examples/trivial/main.cpp0000664000175000017500000000145215160523734026300 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include #include class TextEdit : public QTextEdit { Q_OBJECT public: TextEdit(QWidget *parent = 0) : QTextEdit(parent) {} public slots: void append(const QString &str) { QTextEdit::append(str); } }; #include "main.moc" int main(int argc, char **argv) { QtSingleApplication instance(argc, argv); if (instance.sendMessage("Wake up!")) return 0; TextEdit logview; logview.setReadOnly(true); logview.show(); instance.setActivationWindow(&logview); QObject::connect(&instance, SIGNAL(messageReceived(const QString&)), &logview, SLOT(append(const QString&))); return instance.exec(); } ukui-notification/3rd-parties/qtsingleapplication/examples/loader/0000775000175000017500000000000015160523734024442 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/examples/loader/loader.pro0000664000175000017500000000020615160523734026430 0ustar fengfenggreaterThan(QT_MAJOR_VERSION, 4): QT += printsupport TEMPLATE = app include(../../src/qtsingleapplication.pri) SOURCES += main.cpp ukui-notification/3rd-parties/qtsingleapplication/examples/loader/file1.qsl0000664000175000017500000000000715160523734026160 0ustar fengfengFile 1 ukui-notification/3rd-parties/qtsingleapplication/examples/loader/main.cpp0000664000175000017500000000432415160523734026075 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include #include #include #include #include #include #include #include class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); public slots: void handleMessage(const QString& message); signals: void needToShow(); private: QMdiArea *workspace; }; MainWindow::MainWindow() { workspace = new QMdiArea(this); setCentralWidget(workspace); } void MainWindow::handleMessage(const QString& message) { enum Action { Nothing, Open, Print } action; action = Nothing; QString filename = message; if (message.toLower().startsWith("/print ")) { filename = filename.mid(7); action = Print; } else if (!message.isEmpty()) { action = Open; } if (action == Nothing) { emit needToShow(); return; } QFile file(filename); QString contents; if (file.open(QIODevice::ReadOnly)) contents = file.readAll(); else contents = "[[Error: Could not load file " + filename + "]]"; QTextEdit *view = new QTextEdit; view->setPlainText(contents); switch(action) { case Print: { QPrinter printer; view->print(&printer); delete view; } break; case Open: { workspace->addSubWindow(view); view->setWindowTitle(message); view->show(); emit needToShow(); } break; default: break; }; } #include "main.moc" int main(int argc, char **argv) { QtSingleApplication instance("File loader QtSingleApplication example", argc, argv); QString message; for (int a = 1; a < argc; ++a) { message += argv[a]; if (a < argc-1) message += " "; } if (instance.sendMessage(message)) return 0; MainWindow mw; mw.handleMessage(message); mw.show(); QObject::connect(&instance, SIGNAL(messageReceived(const QString&)), &mw, SLOT(handleMessage(const QString&))); instance.setActivationWindow(&mw, false); QObject::connect(&mw, SIGNAL(needToShow()), &instance, SLOT(activateWindow())); return instance.exec(); } ukui-notification/3rd-parties/qtsingleapplication/examples/loader/file2.qsl0000664000175000017500000000000715160523734026161 0ustar fengfengFile 2 ukui-notification/3rd-parties/qtsingleapplication/examples/loader/loader.qdoc0000664000175000017500000000335515160523734026566 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause /*! \page qtsingleapplication-example-loader.html \title Loading Documents The application in this example loads or prints the documents passed as commandline parameters to further instances of this application. \quotefromfile loader/main.cpp \printuntil }; The user interface in this application is a QMainWindow subclass with a QMdiArea as the central widget. It implements a slot \c handleMessage() that will be connected to the messageReceived() signal of the QtSingleApplication class. \printuntil } The MainWindow constructor creates a minimal user interface. \printto case Print: The handleMessage() slot interprets the message passed in as a filename that can be prepended with \e /print to indicate that the file should just be printed rather than loaded. \printto #include Loading the file will also activate the window. \printto mw The \c main entry point function creates a QtSingleApplication object, and creates a message to send to a running instance of the application. If the message was sent successfully the process exits immediately. \printuntil } If the message could not be sent the application starts up. Note that \c false is passed to the call to setActivationWindow() to prevent automatic activation for every message received, e.g. when the application should just print a file. Instead, the message handling function determines whether activation is requested, and signals that by emitting the needToShow() signal. This is then simply connected directly to QtSingleApplication's activateWindow() slot. */ ukui-notification/3rd-parties/qtsingleapplication/examples/console/0000775000175000017500000000000015160523734024636 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/examples/console/console.pro0000664000175000017500000000016515160523734027024 0ustar fengfengTEMPLATE = app CONFIG += console SOURCES += main.cpp include(../../src/qtsinglecoreapplication.pri) QT -= gui ukui-notification/3rd-parties/qtsingleapplication/examples/console/console.qdoc0000664000175000017500000000150115160523734027145 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause /*! \page qtsinglecoreapplication-example-console.html \title A non-GUI example This example shows how to use the single-application functionality in a console application. It does not require the \c QtGui library at all. The only differences from the GUI application usage demonstrated in the other examples are: 1) The \c.pro file should include \c qtsinglecoreapplication.pri instead of \c qtsingleapplication.pri 2) The class name is \c QtSingleCoreApplication instead of \c QtSingleApplication. 3) No calls are made regarding window activation, for obvious reasons. console.pro: \quotefile console/console.pro main.cpp: \quotefile console/main.cpp */ ukui-notification/3rd-parties/qtsingleapplication/examples/console/main.cpp0000664000175000017500000000245615160523734026275 0ustar fengfeng// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). // SPDX-License-Identifier: BSD-3-Clause #include "qtsinglecoreapplication.h" #include void report(const QString& msg) { qDebug("[%i] %s", (int)QCoreApplication::applicationPid(), qPrintable(msg)); } class MainClass : public QObject { Q_OBJECT public: MainClass() : QObject() {} public slots: void handleMessage(const QString& message) { report( "Message received: \"" + message + "\""); } }; int main(int argc, char **argv) { report("Starting up"); QtSingleCoreApplication app(argc, argv); if (app.isRunning()) { QString msg(QString("Hi master, I am %1.").arg(QCoreApplication::applicationPid())); bool sentok = app.sendMessage(msg, 2000); QString rep("Another instance is running, so I will exit."); rep += sentok ? " Message sent ok." : " Message sending failed; the other instance may be frozen."; report(rep); return 0; } else { report("No other instance is running; so I will."); MainClass mainObj; QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &mainObj, SLOT(handleMessage(const QString&))); return app.exec(); } } #include "main.moc" ukui-notification/3rd-parties/qtsingleapplication/buildlib/0000775000175000017500000000000015160523734023144 5ustar fengfengukui-notification/3rd-parties/qtsingleapplication/buildlib/buildlib.pro0000664000175000017500000000072115160523734025454 0ustar fengfengTEMPLATE=lib CONFIG += qt dll qtsingleapplication-buildlib mac:CONFIG += absolute_library_soname win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all include(../src/qtsingleapplication.pri) TARGET = $$QTSINGLEAPPLICATION_LIBNAME DESTDIR = $$QTSINGLEAPPLICATION_LIBDIR win32 { DLLDESTDIR = $$[QT_INSTALL_BINS] QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\$${QTSINGLEAPPLICATION_LIBNAME}.dll } target.path = $$DESTDIR INSTALLS += target ukui-notification/3rd-parties/qtsingleapplication/configure0000775000175000017500000000126115160523734023265 0ustar fengfeng#!/bin/sh if [ "x$1" != "x" -a "x$1" != "x-library" ]; then echo "Usage: $0 [-library]" echo echo "-library: Build the component as a dynamic library (DLL). Default is to" echo " include the component source code directly in the application." echo exit 0 fi rm -f config.pri if [ "x$1" = "x-library" ]; then echo "Configuring to build this component as a dynamic library." echo "SOLUTIONS_LIBRARY = yes" > config.pri fi echo echo "This component is now configured." echo echo "To build the component library (if requested) and example(s)," echo "run qmake and your make command." echo echo "To remove or reconfigure, run make distclean." echo