diff --git a/LICENSES/GPL-2.0-or-later.txt b/LICENSES/GPL-2.0-or-later.txt new file mode 100644 index 0000000..1d80ac3 --- /dev/null +++ b/LICENSES/GPL-2.0-or-later.txt @@ -0,0 +1,319 @@ +GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. + +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software +is covered by the GNU Lesser General Public License instead.) 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 this service 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 make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or +for a fee, you must give the recipients all the rights that you have. 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. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If +the software is modified by someone else and passed on, we want its recipients +to know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will individually +obtain patent licenses, in effect making the program proprietary. To prevent +this, we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms +of this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or translated +into another language. (Hereinafter, translation is included without limitation +in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running the Program +is not restricted, and the output from the Program is covered only if its +contents constitute a work based on the Program (independent of having been +made by running the Program). Whether that is true depends on what the Program +does. + +1. You may copy and distribute 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 and disclaimer of warranty; +keep intact all the notices that refer to this License and to the absence +of any warranty; and give any other recipients of the Program a copy of this +License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, +thus forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + +a) You must cause the modified files to carry prominent notices stating that +you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or +in part contains or is derived from the Program or any part thereof, to be +licensed as a whole at no charge to all third parties under the terms of this +License. + +c) If the modified program normally reads commands interactively when run, +you must cause it, when started running for such interactive use in the most +ordinary way, to print or display an announcement including an appropriate +copyright notice and a notice that there is no warranty (or else, saying that +you provide a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this License. +(Exception: if the Program itself is interactive but does not normally print +such an announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Program, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Program. + +In addition, mere aggregation of another work not based on the Program with +the Program (or with a work based on the Program) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under Section +2) in object code or executable form under the terms of Sections 1 and 2 above +provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, +which must be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give +any third party, for a charge no more than your cost of physically performing +source distribution, a complete machine-readable copy of the corresponding +source code, to be distributed under the terms of Sections 1 and 2 above on +a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for noncommercial +distribution and only if you received the program in object code or executable +form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy the +source code from the same place counts as distribution of the source code, +even though third parties are not compelled to copy the source along with +the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except +as expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses terminated +so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Program or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Program +(or any work based on the Program), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor +to copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of +the rights granted herein. You are not responsible for enforcing compliance +by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Program at all. For example, if a +patent license would not permit royalty-free redistribution of the Program +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system, which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Program under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of +the 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 +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Program does not specify a version number of this License, you may choose +any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing and reuse +of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +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. +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 convey 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 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when +it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be +called something other than `show w' and `show c'; they could even be mouse-clicks +or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' +(which makes passes at compilers) written by James Hacker. + +, 1 April 1989 Ty Coon, President of Vice This 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. diff --git a/LICENSES/LGPL-2.0-only.txt b/LICENSES/LGPL-2.0-only.txt new file mode 100644 index 0000000..5c96471 --- /dev/null +++ b/LICENSES/LGPL-2.0-only.txt @@ -0,0 +1,446 @@ +GNU LIBRARY GENERAL PUBLIC LICENSE + +Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. + +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is numbered 2 because +it goes with version 2 of the ordinary GPL.] + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public Licenses are intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. + +This license, the Library General Public License, applies to some specially +designated Free Software Foundation software, and to any other libraries whose +authors decide to use it. You can use it for your libraries, 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 this service 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 make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the library, or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for +a fee, you must give the recipients all the rights that we gave you. You must +make sure that they, too, receive or can get the source code. If you link +a program with the library, you must provide complete object files to the +recipients so that they can relink them with the library, after making changes +to the library and recompiling it. And you must show them these terms so they +know their rights. + +Our method of protecting your rights has two steps: (1) copyright the library, +and (2) offer you this license which gives you legal permission to copy, distribute +and/or modify the library. + +Also, for each distributor's protection, we want to make certain that everyone +understands that there is no warranty for this free library. If the library +is modified by someone else and passed on, we want its recipients to know +that what they have is not the original version, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that companies distributing free software will individually +obtain patent licenses, thus in effect transforming the program into proprietary +software. To prevent this, we have made it clear that any patent must be licensed +for everyone's free use or not licensed at all. + +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License, which was designed for utility programs. This license, +the GNU Library General Public License, applies to certain designated libraries. +This license is quite different from the ordinary one; be sure to read it +in full, and don't assume that anything in it is the same as in the ordinary +license. + +The reason we have a separate public license for some libraries is that they +blur the distinction we usually make between modifying or adding to a program +and simply using it. Linking a program with a library, without changing the +library, is in some sense simply using the library, and is analogous to running +a utility program or application program. However, in a textual and legal +sense, the linked executable is a combined work, a derivative of the original +library, and the ordinary General Public License treats it as such. + +Because of this blurred distinction, using the ordinary General Public License +for libraries did not effectively promote software sharing, because most developers +did not use the libraries. We concluded that weaker conditions might promote +sharing better. + +However, unrestricted linking of non-free programs would deprive the users +of those programs of all benefit from the free status of the libraries themselves. +This Library General Public License is intended to permit developers of non-free +programs to use free libraries, while preserving your freedom as a user of +such programs to change the free libraries that are incorporated in them. +(We have not seen how to achieve this as regards changes in header files, +but we have achieved it as regards changes in the actual functions of the +Library.) The hope is that this will lead to faster development of free libraries. + +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code derived +from the library, while the latter only works together with the library. + +Note that it is possible for a library to be covered by the ordinary General +Public License rather than by this special one. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library which contains a +notice placed by the copyright holder or other authorized party saying it +may be distributed under the terms of this Library General Public License +(also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared +so as to be conveniently linked with application programs (which use some +of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has +been distributed under these terms. A "work based on the Library" means either +the Library or any derivative work under copyright law: that is to say, a +work containing the Library or a portion of it, either verbatim or with modifications +and/or translated straightforwardly into another language. (Hereinafter, translation +is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications +to it. For a library, complete source code means all the source code for all +modules it contains, plus any associated interface definition files, plus +the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running a program +using the Library is not restricted, and output from such a program is covered +only if its contents constitute a work based on the Library (independent of +the use of the Library in a tool for writing it). Whether that is true depends +on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and disclaimer +of warranty; keep intact all the notices that refer to this License and to +the absence of any warranty; and distribute a copy of this License along with +the Library. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, +thus forming a work based on the Library, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + + a) The modified work must itself be a software library. + +b) You must cause the files modified to carry prominent notices stating that +you changed the files and the date of any change. + +c) You must cause the whole of the work to be licensed at no charge to all +third parties under the terms of this License. + +d) If a facility in the modified Library refers to a function or a table of +data to be supplied by an application program that uses the facility, other +than as an argument passed when the facility is invoked, then you must make +a good faith effort to ensure that, in the event an application does not supply +such function or table, the facility still operates, and performs whatever +part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose +that is entirely well-defined independent of the application. Therefore, Subsection +2d requires that any application-supplied function or table used by this function +must be optional: if the application does not supply it, the square root function +must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Library, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Library, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Library. + +In addition, mere aggregation of another work not based on the Library with +the Library (or with a work based on the Library) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may opt to apply the terms of the ordinary GNU General Public License +instead of this License to a given copy of the Library. To do this, you must +alter all the notices that refer to this License, so that they refer to the +ordinary GNU General Public License, version 2, instead of to this License. +(If a newer version than version 2 of the ordinary GNU General Public License +has appeared, then you can specify that version instead if you wish.) Do not +make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, +so the ordinary GNU General Public License applies to all subsequent copies +and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library +into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of +it, under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you accompany it with the complete corresponding +machine-readable source code, which must be distributed under the terms of +Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated +place, then offering equivalent access to copy the source code from the same +place satisfies the requirement to distribute the source code, even though +third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but +is designed to work with the Library by being compiled or linked with it, +is called a "work that uses the Library". Such a work, in isolation, is not +a derivative work of the Library, and therefore falls outside the scope of +this License. + +However, linking a "work that uses the Library" with the Library creates an +executable that is a derivative of the Library (because it contains portions +of the Library), rather than a "work that uses the library". The executable +is therefore covered by this License. Section 6 states terms for distribution +of such executables. + +When a "work that uses the Library" uses material from a header file that +is part of the Library, the object code for the work may be a derivative work +of the Library even though the source code is not. Whether this is true is +especially significant if the work can be linked without the Library, or if +the work is itself a library. The threshold for this to be true is not precisely +defined by law. + +If such an object file uses only numerical parameters, data structure layouts +and accessors, and small macros and small inline functions (ten lines or less +in length), then the use of the object file is unrestricted, regardless of +whether it is legally a derivative work. (Executables containing this object +code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute +the object code for the work under the terms of Section 6. Any executables +containing that work also fall under Section 6, whether or not they are linked +directly with the Library itself. + +6. As an exception to the Sections above, you may also compile or link a "work +that uses the Library" with the Library to produce a work containing portions +of the Library, and distribute that work under terms of your choice, provided +that the terms permit modification of the work for the customer's own use +and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library +is used in it and that the Library and its use are covered by this License. +You must supply a copy of this License. If the work during execution displays +copyright notices, you must include the copyright notice for the Library among +them, as well as a reference directing the user to the copy of this License. +Also, you must do one of these things: + +a) Accompany the work with the complete corresponding machine-readable source +code for the Library including whatever changes were used in the work (which +must be distributed under Sections 1 and 2 above); and, if the work is an +executable linked with the Library, with the complete machine-readable "work +that uses the Library", as object code and/or source code, so that the user +can modify the Library and then relink to produce a modified executable containing +the modified Library. (It is understood that the user who changes the contents +of definitions files in the Library will not necessarily be able to recompile +the application to use the modified definitions.) + +b) Accompany the work with a written offer, valid for at least three years, +to give the same user the materials specified in Subsection 6a, above, for +a charge no more than the cost of performing this distribution. + +c) If distribution of the work is made by offering access to copy from a designated +place, offer equivalent access to copy the above specified materials from +the same place. + +d) Verify that the user has already received a copy of these materials or +that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must +include any data and utility programs needed for reproducing the executable +from it. However, as a special exception, the source code distributed need +not include anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the operating +system on which the executable runs, unless that component itself accompanies +the executable. + +It may happen that this requirement contradicts the license restrictions of +other proprietary libraries that do not normally accompany the operating system. +Such a contradiction means you cannot use both them and the Library together +in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side +in a single library together with other library facilities not covered by +this License, and distribute such a combined library, provided that the separate +distribution of the work based on the Library and of the other library facilities +is otherwise permitted, and provided that you do these two things: + +a) Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities. This must be distributed +under the terms of the Sections above. + +b) Give prominent notice with the combined library of the fact that part of +it is a work based on the Library, and explaining where to find the accompanying +uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library +except as expressly provided under this License. Any attempt otherwise to +copy, modify, sublicense, link with, or distribute the Library is void, and +will automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will not +have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Library or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Library +(or any work based on the Library), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), +the recipient automatically receives a license from the original licensor +to copy, distribute, link with or modify the Library subject to these terms +and conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties to this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Library at all. For example, if a +patent license would not permit royalty-free redistribution of the Library +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Library under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of +the Library General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address +new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Library does not specify a license version number, you may choose any version +ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs +whose distribution conditions are incompatible with these, write to the author +to ask for permission. For software which is copyrighted by the Free Software +Foundation, write to the Free Software Foundation; we sometimes make exceptions +for this. Our decision will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY +"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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible +use to the public, we recommend making it free software that everyone can +redistribute and change. You can do so by permitting redistribution under +these terms (or, alternatively, under the terms of the ordinary General Public +License). + +To apply these terms, attach the following notices to the library. It is safest +to attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the "copyright" +line and a pointer to where the full notice is found. + +one line to give the library's name and an idea of what it does. + +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or modify it under +the terms of the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your option) +any later version. + +This library 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 Library General Public License for more +details. + +You should have received a copy of the GNU Library General Public License +along with this library; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the library, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in + +the library `Frob' (a library for tweaking knobs) written + +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 + +Ty Coon, President of Vice + +That's all there is to it! diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..204b93d --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/examples/KIdleTest.cpp b/examples/KIdleTest.cpp index 85341ca..ad25452 100644 --- a/examples/KIdleTest.cpp +++ b/examples/KIdleTest.cpp @@ -1,80 +1,67 @@ -/*************************************************************************** - * Copyright (C) 2009 by Dario Freddi * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "KIdleTest.h" #include #include "kidletime.h" //@@snippet_begin(initialize) KIdleTest::KIdleTest() { // connect to idle events connect(KIdleTime::instance(), &KIdleTime::resumingFromIdle, this, &KIdleTest::resumeEvent); connect(KIdleTime::instance(), SIGNAL(timeoutReached(int,int)), this, SLOT(timeoutReached(int,int))); // register to get informed for the very next user event KIdleTime::instance()->catchNextResumeEvent(); printf("Your idle time is %d\n", KIdleTime::instance()->idleTime()); printf("Welcome!! Move your mouse or do something to start...\n"); } //@@snippet_end KIdleTest::~KIdleTest() { } //@@snippet_begin(resumeEvent) void KIdleTest::resumeEvent() { KIdleTime::instance()->removeAllIdleTimeouts(); printf("Great! Now stay idle for 5 seconds to get a nice message. From 10" "seconds on, you can move your mouse to get back here.\n"); printf("If you will stay idle for too long, I will simulate your activity" "after 25 seconds, and make everything start back\n"); KIdleTime::instance()->addIdleTimeout(5000); KIdleTime::instance()->addIdleTimeout(10000); KIdleTime::instance()->addIdleTimeout(25000); } //@@snippet_end //@@snippet_begin(timeoutReached) void KIdleTest::timeoutReached(int id, int timeout) { Q_UNUSED(id) if (timeout == 5000) { printf("5 seconds passed, stay still some more...\n"); } else if (timeout == 10000) { KIdleTime::instance()->catchNextResumeEvent(); printf("Cool. You can move your mouse to start over\n"); } else if (timeout == 25000) { printf("Uff, you're annoying me. Let's start again. I'm simulating your" "activity now\n"); KIdleTime::instance()->simulateUserActivity(); } else { qDebug() << "OUCH"; } } //@@snippet_end diff --git a/examples/KIdleTest.h b/examples/KIdleTest.h index ef81842..2b3ccbe 100644 --- a/examples/KIdleTest.h +++ b/examples/KIdleTest.h @@ -1,38 +1,25 @@ -/*************************************************************************** - * Copyright (C) 2009 by Dario Freddi * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #ifndef KIDLETEST_H #define KIDLETEST_H #include class KIdleTest : public QObject { Q_OBJECT public: KIdleTest(); virtual ~KIdleTest(); public Q_SLOTS: void timeoutReached(int id, int timeout); void resumeEvent(); }; #endif /* KIDLETEST_H */ diff --git a/examples/main.cpp b/examples/main.cpp index d059133..5f48702 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -1,30 +1,17 @@ -/*************************************************************************** - * Copyright (C) 2009 by Dario Freddi * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include #include "KIdleTest.h" int main(int argc, char **argv) { QApplication app(argc, argv); KIdleTest t; return app.exec(); } diff --git a/src/abstractsystempoller.cpp b/src/abstractsystempoller.cpp index aee016e..79748e4 100644 --- a/src/abstractsystempoller.cpp +++ b/src/abstractsystempoller.cpp @@ -1,29 +1,17 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #include "abstractsystempoller.h" AbstractSystemPoller::AbstractSystemPoller(QObject *parent) : QObject(parent) { } AbstractSystemPoller::~AbstractSystemPoller() { } diff --git a/src/abstractsystempoller.h b/src/abstractsystempoller.h index b7cb37a..e07ccab 100644 --- a/src/abstractsystempoller.h +++ b/src/abstractsystempoller.h @@ -1,56 +1,44 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #ifndef ABSTRACTSYSTEMPOLLER_H #define ABSTRACTSYSTEMPOLLER_H #include #include class KIDLETIME_EXPORT AbstractSystemPoller : public QObject { Q_OBJECT public: AbstractSystemPoller(QObject *parent = nullptr); virtual ~AbstractSystemPoller(); virtual bool isAvailable() = 0; virtual bool setUpPoller() = 0; virtual void unloadPoller() = 0; public Q_SLOTS: virtual void addTimeout(int nextTimeout) = 0; virtual void removeTimeout(int nextTimeout) = 0; virtual QList timeouts() const = 0; virtual int forcePollRequest() = 0; virtual void catchIdleEvent() = 0; virtual void stopCatchingIdleEvents() = 0; virtual void simulateUserActivity() = 0; Q_SIGNALS: void resumingFromIdle(); void timeoutReached(int msec); }; Q_DECLARE_INTERFACE(AbstractSystemPoller, "org.kde.kidletime.AbstractSystemPoller") #endif /* ABSTRACTSYSTEMPOLLER_H */ diff --git a/src/kidletime.cpp b/src/kidletime.cpp index f2914cc..a020346 100644 --- a/src/kidletime.cpp +++ b/src/kidletime.cpp @@ -1,287 +1,275 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #include "kidletime.h" #include #include "abstractsystempoller.h" #include "logging.h" #include #include #include #include #include #include class KIdleTimeHelper { public: KIdleTimeHelper() : q(nullptr) {} ~KIdleTimeHelper() { delete q; } KIdleTimeHelper(const KIdleTimeHelper &) = delete; KIdleTimeHelper &operator=(const KIdleTimeHelper &) = delete; KIdleTime *q; }; Q_GLOBAL_STATIC(KIdleTimeHelper, s_globalKIdleTime) KIdleTime *KIdleTime::instance() { if (!s_globalKIdleTime()->q) { new KIdleTime; } return s_globalKIdleTime()->q; } class KIdleTimePrivate { Q_DECLARE_PUBLIC(KIdleTime) KIdleTime *q_ptr; public: KIdleTimePrivate() : catchResume(false), currentId(0) {} void loadSystem(); void unloadCurrentSystem(); void _k_resumingFromIdle(); void _k_timeoutReached(int msec); QPointer poller; bool catchResume; int currentId; QHash associations; }; KIdleTime::KIdleTime() : QObject(nullptr) , d_ptr(new KIdleTimePrivate()) { Q_ASSERT(!s_globalKIdleTime()->q); s_globalKIdleTime()->q = this; d_ptr->q_ptr = this; Q_D(KIdleTime); d->loadSystem(); connect(d->poller.data(), SIGNAL(resumingFromIdle()), this, SLOT(_k_resumingFromIdle())); connect(d->poller.data(), SIGNAL(timeoutReached(int)), this, SLOT(_k_timeoutReached(int))); } KIdleTime::~KIdleTime() { Q_D(KIdleTime); d->unloadCurrentSystem(); delete d_ptr; } void KIdleTime::catchNextResumeEvent() { Q_D(KIdleTime); if (!d->catchResume && d->poller) { d->catchResume = true; d->poller.data()->catchIdleEvent(); } } void KIdleTime::stopCatchingResumeEvent() { Q_D(KIdleTime); if (d->catchResume && d->poller) { d->catchResume = false; d->poller.data()->stopCatchingIdleEvents(); } } int KIdleTime::addIdleTimeout(int msec) { Q_D(KIdleTime); if (Q_UNLIKELY(!d->poller)) { return 0; } d->poller.data()->addTimeout(msec); ++d->currentId; d->associations[d->currentId] = msec; return d->currentId; } void KIdleTime::removeIdleTimeout(int identifier) { Q_D(KIdleTime); if (!d->associations.contains(identifier) || !d->poller) { return; } int msec = d->associations[identifier]; d->associations.remove(identifier); if (!d->associations.values().contains(msec)) { d->poller.data()->removeTimeout(msec); } } void KIdleTime::removeAllIdleTimeouts() { Q_D(KIdleTime); QHash< int, int >::iterator i = d->associations.begin(); QSet< int > removed; removed.reserve(d->associations.size()); while (i != d->associations.end()) { int msec = d->associations[i.key()]; i = d->associations.erase(i); if (!removed.contains(msec) && d->poller) { d->poller.data()->removeTimeout(msec); removed.insert(msec); } } } static QStringList pluginCandidates() { QStringList ret; const QStringList libPath = QCoreApplication::libraryPaths(); for (const QString &path : libPath ) { const QDir pluginDir(path + QLatin1String("/kf5/org.kde.kidletime.platforms")); if (!pluginDir.exists()) { continue; } for (const QString &entry : pluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { ret << pluginDir.absoluteFilePath(entry); } } return ret; } static AbstractSystemPoller *loadPoller() { const QStringList lstPlugins = pluginCandidates(); for (const QString &candidate : lstPlugins) { if (!QLibrary::isLibrary(candidate)) { continue; } QPluginLoader loader(candidate); QJsonObject metaData = loader.metaData(); const QJsonArray platforms = metaData.value(QStringLiteral("MetaData")).toObject().value(QStringLiteral("platforms")).toArray(); for (auto it = platforms.begin(); it != platforms.end(); ++it) { if (QString::compare(QGuiApplication::platformName(), (*it).toString(), Qt::CaseInsensitive) == 0) { AbstractSystemPoller *poller = qobject_cast< AbstractSystemPoller* >(loader.instance()); if (poller) { qCDebug(KIDLETIME) << "Trying plugin" << candidate; if (poller->isAvailable()) { qCDebug(KIDLETIME) << "Using" << candidate << "for platform" << QGuiApplication::platformName(); return poller; } delete poller; } } } } return nullptr; } void KIdleTimePrivate::loadSystem() { if (!poller.isNull()) { unloadCurrentSystem(); } // load plugin poller = loadPoller(); if (poller && !poller->isAvailable()) { poller = nullptr; } if (!poller.isNull()) { poller.data()->setUpPoller(); } } void KIdleTimePrivate::unloadCurrentSystem() { if (!poller.isNull()) { poller.data()->unloadPoller(); poller.data()->deleteLater(); } } void KIdleTimePrivate::_k_resumingFromIdle() { Q_Q(KIdleTime); if (catchResume) { emit q->resumingFromIdle(); q->stopCatchingResumeEvent(); } } void KIdleTimePrivate::_k_timeoutReached(int msec) { Q_Q(KIdleTime); if (associations.values().contains(msec)) { const auto listKeys = associations.keys(msec); for (int key : listKeys) { emit q->timeoutReached(key); emit q->timeoutReached(key, msec); } } } void KIdleTime::simulateUserActivity() { Q_D(KIdleTime); if (Q_LIKELY(d->poller)) { d->poller.data()->simulateUserActivity(); } } int KIdleTime::idleTime() const { Q_D(const KIdleTime); if (Q_LIKELY(d->poller)) { return d->poller.data()->forcePollRequest(); } return 0; } QHash KIdleTime::idleTimeouts() const { Q_D(const KIdleTime); return d->associations; } #include "moc_kidletime.cpp" diff --git a/src/kidletime.h b/src/kidletime.h index 0c442e4..0037ccd 100644 --- a/src/kidletime.h +++ b/src/kidletime.h @@ -1,197 +1,185 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #ifndef KIDLETIME_H #define KIDLETIME_H #include #include #include class KIdleTimePrivate; /** * @class KIdleTime kidletime.h KIdleTime * * KIdleTime is a singleton reporting information on idle time. It is useful not * only for finding out about the current idle time of the PC, but also for getting * notified upon idle time events, such as custom timeouts, or user activity. * * @note All the intervals and times in this library are in milliseconds, unless * specified otherwise * * @author Dario Freddi * * @since 4.4 */ class KIDLETIME_EXPORT KIdleTime : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(KIdleTime) Q_DISABLE_COPY(KIdleTime) public: /** * Returns the singleton instance. Use this method to access KIdleTime * * @returns the instance of KIdleTime */ static KIdleTime *instance(); /** * The destructor */ virtual ~KIdleTime(); /** * Retrieves the idle time of the system, in milliseconds * * @returns the idle time of the system */ int idleTime() const; /** * Returns the list of timeout identifiers associated with their duration, in milliseconds, * the library is currently listening to. * * @see addIdleTimeout * @see removeIdleTimeout * @see timeoutReached */ QHash idleTimeouts() const; /** * Attempts to simulate user activity. This implies that after calling this * method, the idle time of the system will become 0 and eventually \link resumingFromIdle \endlink * will be triggered * * @see resumingFromIdle */ void simulateUserActivity(); public Q_SLOTS: /** * Adds a new timeout to catch. When calling this method, after the system will be idle for * \c msec milliseconds, the signal \c timeoutReached will be triggered. Please note that until you will * call \c removeIdleTimeout or \c removeAllIdleTimeouts, the signal will be triggered every * time the system will be idle for \c msec milliseconds. This function also returns an unique * token for the timeout just added to allow easier identification. * * @param msec the time, in milliseconds, after which the signal will be triggered * * @returns an unique identifier for the timeout being added, that will be streamed by timeoutReached * * @see removeIdleTimeout * @see removeAllIdleTimeouts * @see timeoutReached * */ int addIdleTimeout(int msec); /** * Stops catching the idle timeout identified by the token \c identifier, * if it was registered earlier with addIdleTimeout. * Otherwise does nothing. * * @param identifier the token returned from addIdleTimeout of the timeout you want to stop listening to */ void removeIdleTimeout(int identifier); /** * Stops catching every set timeout (if any). This means that after calling this method, the signal * \link timeoutReached \endlink won't be called again until you will add another timeout * * @see timeoutReached * @see addIdleTimeout */ void removeAllIdleTimeouts(); /** * Catches the next resume from idle event. This means that whenever user activity will be registered, or * \link simulateUserActivity \endlink is called, the signal \link resumingFromIdle \endlink will be triggered. *

* Please note that this method will trigger the signal just for the very first resume event after the call: * this means you explicitly have to request to track every single resume event you are interested in. * * @note This behavior is due to the fact that a resume event happens whenever the user sends an input to the * system. This would lead to a massive amount of signals being delivered when the PC is being used. * Moreover, you are usually interested in catching just significant resume events, such as the ones after * a significant period of inactivity. For tracking user input, you can use the more efficient methods provided * by Qt. The purpose of this library is just monitoring the activity of the user. * * @see resumingFromIdle * @see simulateUserActivity * */ void catchNextResumeEvent(); /** * Stops listening for resume event. This function serves for canceling \c catchNextResumeEvent, as it * will have effect just when \c catchNextResumeEvent has been called and \c resumingFromIdle not * yet triggered * * @see resumingFromIdle * @see catchNextResumeEvent * */ void stopCatchingResumeEvent(); Q_SIGNALS: /** * Triggered, if KIdleTime is catching resume events, when the system resumes from an idle state. This means * that either \link simulateUserActivity \endlink was called or the user sent an input to the system. * * @see catchNextResumeEvent */ void resumingFromIdle(); /** * Triggered when the system has been idle for x milliseconds, identified by the previously set * timeout. *

* This signal is triggered whenever each timeout previously registered with \link addIdleTimeout \endlink * is reached. * * @param identifier the identifier of the timeout the system has reached * * @see addIdleTimeout * @see removeIdleTimeout */ void timeoutReached(int identifier); /** * Overload. Streams the duration as well. It is guaranteed that \c msec will exactly * correspond to the timeout registered with \link addIdleTimeout \endlink * * @param msec the time, in milliseconds, the system has been idle for * * @see addIdleTimeout * @see removeIdleTimeout */ void timeoutReached(int identifier, int msec); private: KIdleTime(); KIdleTimePrivate *const d_ptr; Q_PRIVATE_SLOT(d_func(), void _k_resumingFromIdle()) Q_PRIVATE_SLOT(d_func(), void _k_timeoutReached(int)) }; #endif /* KIDLETIME_H */ diff --git a/src/plugins/osx/macpoller.cpp b/src/plugins/osx/macpoller.cpp index ddcef13..fb4cde3 100644 --- a/src/plugins/osx/macpoller.cpp +++ b/src/plugins/osx/macpoller.cpp @@ -1,228 +1,216 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - Copyright (C) 2003 Tarkvara Design Inc. (from KVIrc source code) - Copyright (c) 2008 Roman Jarosz - Copyright (c) 2008 the Kopete developers - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * SPDX-FileCopyrightText: 2003 Tarkvara Design Inc. (from KVIrc source code) + * SPDX-FileCopyrightText: 2008 Roman Jarosz + * SPDX-FileCopyrightText: 2008 the Kopete developers + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #include "macpoller.h" // Why does Apple have to make this so complicated? static OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr) { OSStatus err; FSRef frameworksFolderRef; CFURLRef baseURL; CFURLRef bundleURL; if (bundlePtr == nil) { return (-1); } *bundlePtr = nil; baseURL = nil; bundleURL = nil; err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef); if (err == noErr) { baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef); if (baseURL == nil) { err = coreFoundationUnknownErr; } } if (err == noErr) { bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, framework, false); if (bundleURL == nil) { err = coreFoundationUnknownErr; } } if (err == noErr) { *bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL); if (*bundlePtr == nil) { err = coreFoundationUnknownErr; } } if (err == noErr) { if (!CFBundleLoadExecutable(*bundlePtr)) { err = coreFoundationUnknownErr; } } // Clean up. if (err != noErr && *bundlePtr != nil) { CFRelease(*bundlePtr); *bundlePtr = nil; } if (bundleURL != nil) { CFRelease(bundleURL); } if (baseURL != nil) { CFRelease(baseURL); } return err; } pascal void MacPoller::IdleTimerAction(EventLoopTimerRef, EventLoopIdleTimerMessage inState, void *inUserData) { Q_ASSERT(inUserData); switch (inState) { case kEventLoopIdleTimerStarted: case kEventLoopIdleTimerStopped: // Get invoked with this constant at the start of the idle period, // or whenever user activity cancels the idle. ((MacPoller *)inUserData)->m_secondsIdle = 0; ((MacPoller *)inUserData)->triggerResume(); break; case kEventLoopIdleTimerIdling: // Called every time the timer fires (i.e. every second). ((MacPoller *)inUserData)->m_secondsIdle++; ((MacPoller *)inUserData)->poll(); break; } } // Typedef for the function we're getting back from CFBundleGetFunctionPointerForName. typedef OSStatus(*InstallEventLoopIdleTimerPtr)(EventLoopRef inEventLoop, EventTimerInterval inFireDelay, EventTimerInterval inInterval, EventLoopIdleTimerUPP inTimerProc, void *inTimerData, EventLoopTimerRef *outTimer); MacPoller::MacPoller(QObject *parent) : AbstractSystemPoller(parent) , m_timerRef(0) , m_secondsIdle(0) , m_catch(false) { } MacPoller::~MacPoller() { } void MacPoller::unloadPoller() { RemoveEventLoopTimer(m_timerRef); } bool MacPoller::isAvailable() { return true; } bool MacPoller::setUpPoller() { // May already be init'ed. if (m_timerRef) { return true; } // According to the docs, InstallEventLoopIdleTimer is new in 10.2. // According to the headers, it has been around since 10.0. // One of them is lying. We'll play it safe and weak-link the function. // Load the "Carbon.framework" bundle. CFBundleRef carbonBundle; if (LoadFrameworkBundle(CFSTR("Carbon.framework"), &carbonBundle) != noErr) { return false; } // Load the Mach-O function pointers for the routine we will be using. InstallEventLoopIdleTimerPtr myInstallEventLoopIdleTimer = (InstallEventLoopIdleTimerPtr)CFBundleGetFunctionPointerForName(carbonBundle, CFSTR("InstallEventLoopIdleTimer")); if (myInstallEventLoopIdleTimer == 0) { return false; } EventLoopIdleTimerUPP timerUPP = NewEventLoopIdleTimerUPP(IdleTimerAction); if ((*myInstallEventLoopIdleTimer)(GetMainEventLoop(), kEventDurationSecond, kEventDurationSecond, timerUPP, this, &m_timerRef)) { return true; } return false; } QList MacPoller::timeouts() const { return m_timeouts; } void MacPoller::addTimeout(int nextTimeout) { m_timeouts.append(nextTimeout); poll(); } int MacPoller::poll() { int idle = m_secondsIdle * 1000; // Check if we reached a timeout.. for (int i : qAsConst(m_timeouts)) { if ((i - idle < 1000 && i > idle) || (idle - i < 1000 && idle > i)) { // Bingo! emit timeoutReached(i); } } return idle; } int MacPoller::forcePollRequest() { return poll(); } void MacPoller::removeTimeout(int timeout) { m_timeouts.removeOne(timeout); poll(); } void MacPoller::catchIdleEvent() { m_catch = true; } void MacPoller::stopCatchingIdleEvents() { m_catch = false; } void MacPoller::triggerResume() { if (m_catch) { emit resumingFromIdle(); stopCatchingIdleEvents(); } } void MacPoller::simulateUserActivity() { // TODO } diff --git a/src/plugins/osx/macpoller.h b/src/plugins/osx/macpoller.h index ef51ea5..22a29c8 100644 --- a/src/plugins/osx/macpoller.h +++ b/src/plugins/osx/macpoller.h @@ -1,62 +1,50 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #ifndef MACPOLLER_H #define MACPOLLER_H #include "abstractsystempoller.h" #include class MacPoller: public AbstractSystemPoller { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "osx.json") Q_INTERFACES(AbstractSystemPoller) public: MacPoller(QObject *parent = 0); virtual ~MacPoller(); bool isAvailable(); bool setUpPoller(); void unloadPoller(); static pascal void IdleTimerAction(EventLoopTimerRef, EventLoopIdleTimerMessage inState, void *inUserData); public Q_SLOTS: void addTimeout(int nextTimeout); void removeTimeout(int nextTimeout); QList timeouts() const; int forcePollRequest(); void catchIdleEvent(); void stopCatchingIdleEvents(); void simulateUserActivity(); void triggerResume(); private Q_SLOTS: int poll(); private: QList m_timeouts; EventLoopTimerRef m_timerRef; int m_secondsIdle; bool m_catch; }; #endif /* MACPOLLER_H */ diff --git a/src/plugins/windows/windowspoller.cpp b/src/plugins/windows/windowspoller.cpp index d3749e5..0a04147 100644 --- a/src/plugins/windows/windowspoller.cpp +++ b/src/plugins/windows/windowspoller.cpp @@ -1,90 +1,78 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #include "windowspoller.h" #include #include WindowsPoller::WindowsPoller(QObject *parent) : WidgetBasedPoller(parent) { } WindowsPoller::~WindowsPoller() { } int WindowsPoller::getIdleTime() { #ifndef _WIN32_WCE int idle = 0; LASTINPUTINFO lii; memset(&lii, 0, sizeof(lii)); lii.cbSize = sizeof(lii); BOOL ok = GetLastInputInfo(&lii); if (ok) { idle = GetTickCount() - lii.dwTime; } return idle; #else return GetIdleTime(); #endif } bool WindowsPoller::additionalSetUp() { m_idleTimer = new QTimer(this); connect(m_idleTimer, SIGNAL(timeout()), this, SLOT(checkForIdle())); return true; } void WindowsPoller::simulateUserActivity() { int width = GetSystemMetrics(SM_CXSCREEN); int height = GetSystemMetrics(SM_CYSCREEN); int x = (int)100 * 65536 / width; int y = (int)100 * 65536 / height; mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x, y, NULL, NULL); } void WindowsPoller::catchIdleEvent() { m_idleTimer->start(800); } void WindowsPoller::stopCatchingIdleEvents() { m_idleTimer->stop(); } void WindowsPoller::checkForIdle() { if (getIdleTime() < 1000) { stopCatchingIdleEvents(); emit resumingFromIdle(); } } diff --git a/src/plugins/windows/windowspoller.h b/src/plugins/windows/windowspoller.h index d44f335..f00989f 100644 --- a/src/plugins/windows/windowspoller.h +++ b/src/plugins/windows/windowspoller.h @@ -1,52 +1,40 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #ifndef WINDOWSPOLLER_H #define WINDOWSPOLLER_H #include "widgetbasedpoller.h" class QTimer; class WindowsPoller : public WidgetBasedPoller { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "windows.json") Q_INTERFACES(AbstractSystemPoller) public: WindowsPoller(QObject *parent = 0); virtual ~WindowsPoller(); public Q_SLOTS: void simulateUserActivity(); void catchIdleEvent(); void stopCatchingIdleEvents(); private: bool additionalSetUp(); private Q_SLOTS: int getIdleTime(); void checkForIdle(); private: QTimer *m_idleTimer; }; #endif /* WINDOWSPOLLER_H */ diff --git a/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp b/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp index cfccbc5..2969442 100644 --- a/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp +++ b/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp @@ -1,76 +1,64 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #include "xscreensaverbasedpoller.h" #include #include #include #include XScreensaverBasedPoller::XScreensaverBasedPoller(QObject *parent) : WidgetBasedPoller(parent), m_screenSaverIface(nullptr) { } XScreensaverBasedPoller::~XScreensaverBasedPoller() { } bool XScreensaverBasedPoller::additionalSetUp() { m_screenSaverIface = new OrgFreedesktopScreenSaverInterface(QLatin1String("org.freedesktop.ScreenSaver"), QLatin1String("/ScreenSaver"), QDBusConnection::sessionBus(), this); connect(m_screenSaverIface, SIGNAL(ActiveChanged(bool)), SLOT(screensaverActivated(bool))); return true; } void XScreensaverBasedPoller::screensaverActivated(bool activated) { // We care only if it has been disactivated if (!activated) { m_screenSaverIface->SimulateUserActivity(); emit resumingFromIdle(); } } int XScreensaverBasedPoller::getIdleTime() { XScreenSaverInfo *mitInfo = nullptr; mitInfo = XScreenSaverAllocInfo(); XScreenSaverQueryInfo(QX11Info::display(), DefaultRootWindow(QX11Info::display()), mitInfo); int ret = mitInfo->idle; XFree(mitInfo); return ret; } void XScreensaverBasedPoller::simulateUserActivity() { stopCatchingIdleEvents(); XResetScreenSaver(QX11Info::display()); XFlush(QX11Info::display()); emit resumingFromIdle(); } diff --git a/src/plugins/xscreensaver/xscreensaverbasedpoller.h b/src/plugins/xscreensaver/xscreensaverbasedpoller.h index 3128547..8309519 100644 --- a/src/plugins/xscreensaver/xscreensaverbasedpoller.h +++ b/src/plugins/xscreensaver/xscreensaverbasedpoller.h @@ -1,50 +1,38 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #ifndef XSCREENSAVERBASEDPOLLER_H #define XSCREENSAVERBASEDPOLLER_H #include "widgetbasedpoller.h" #include "screensaver_interface.h" class XScreensaverBasedPoller: public WidgetBasedPoller { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "xcb.json") Q_INTERFACES(AbstractSystemPoller) public: explicit XScreensaverBasedPoller(QObject *parent = nullptr); ~XScreensaverBasedPoller() override; public Q_SLOTS: void simulateUserActivity() override; private: bool additionalSetUp() override; private Q_SLOTS: void screensaverActivated(bool activated); int getIdleTime() override; private: OrgFreedesktopScreenSaverInterface *m_screenSaverIface; }; #endif /* XSCREENSAVERBASEDPOLLER_H_ */ diff --git a/src/plugins/xsync/fixx11h.h b/src/plugins/xsync/fixx11h.h index f516802..ab61fbc 100644 --- a/src/plugins/xsync/fixx11h.h +++ b/src/plugins/xsync/fixx11h.h @@ -1,301 +1,283 @@ -/**************************************************************************** - - Copyright (C) 2003 Lubos Lunak - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -****************************************************************************/ +/* + * SPDX-FileCopyrightText: 2003 Lubos Lunak + * + * SPDX-License-Identifier: MIT + */ //#ifdef don't do this, this file is supposed to be included //#define multiple times #include /* Usage: If you get compile errors caused by X11 includes (the line where first error appears contains word like None, Unsorted, Below, etc.), put #include in the .cpp file (not .h file!) between the place where X11 headers are included and the place where the file with compile error is included (or the place where the compile error in the .cpp file occurs). This file remaps X11 #defines to const variables or inline functions. The side effect may be that these symbols may now refer to different variables (e.g. if X11 #defined NoButton, after this file is included NoButton would no longer be X11's NoButton, but Qt::NoButton instead). At this time, there's no conflict known that could cause problems. The original X11 symbols are still accessible (e.g. for None) as X::None, XNone, and also still None, unless name lookup finds different None first (in the current class, etc.) Use 'Unsorted', 'Bool' and 'index' as templates. */ namespace X { // template ---> // Affects: Should be without side effects. #ifdef Unsorted #ifndef FIXX11H_Unsorted #define FIXX11H_Unsorted const int XUnsorted = Unsorted; #undef Unsorted const int Unsorted = XUnsorted; #endif #undef Unsorted #endif // template <--- // Affects: Should be without side effects. #ifdef None #ifndef FIXX11H_None #define FIXX11H_None const XID XNone = None; #undef None const XID None = XNone; #endif #undef None #endif // template ---> // Affects: Should be without side effects. #ifdef Bool #ifndef FIXX11H_Bool #define FIXX11H_Bool #ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */ #undef Bool #else typedef Bool XBool; #undef Bool typedef XBool Bool; #endif #endif #undef Bool #define _XTYPEDEF_BOOL #endif // template <--- // Affects: Should be without side effects. #ifdef KeyPress #ifndef FIXX11H_KeyPress #define FIXX11H_KeyPress const int XKeyPress = KeyPress; #undef KeyPress const int KeyPress = XKeyPress; #endif #undef KeyPress #endif // Affects: Should be without side effects. #ifdef KeyRelease #ifndef FIXX11H_KeyRelease #define FIXX11H_KeyRelease const int XKeyRelease = KeyRelease; #undef KeyRelease const int KeyRelease = XKeyRelease; #endif #undef KeyRelease #endif // Affects: Should be without side effects. #ifdef Above #ifndef FIXX11H_Above #define FIXX11H_Above const int XAbove = Above; #undef Above const int Above = XAbove; #endif #undef Above #endif // Affects: Should be without side effects. #ifdef Below #ifndef FIXX11H_Below #define FIXX11H_Below const int XBelow = Below; #undef Below const int Below = XBelow; #endif #undef Below #endif // Affects: Should be without side effects. #ifdef FocusIn #ifndef FIXX11H_FocusIn #define FIXX11H_FocusIn const int XFocusIn = FocusIn; #undef FocusIn const int FocusIn = XFocusIn; #endif #undef FocusIn #endif // Affects: Should be without side effects. #ifdef FocusOut #ifndef FIXX11H_FocusOut #define FIXX11H_FocusOut const int XFocusOut = FocusOut; #undef FocusOut const int FocusOut = XFocusOut; #endif #undef FocusOut #endif // Affects: Should be without side effects. #ifdef Always #ifndef FIXX11H_Always #define FIXX11H_Always const int XAlways = Always; #undef Always const int Always = XAlways; #endif #undef Always #endif // Affects: Should be without side effects. #ifdef Expose #ifndef FIXX11H_Expose #define FIXX11H_Expose const int XExpose = Expose; #undef Expose const int Expose = XExpose; #endif #undef Expose #endif // Affects: Should be without side effects. #ifdef Success #ifndef FIXX11H_Success #define FIXX11H_Success const int XSuccess = Success; #undef Success const int Success = XSuccess; #endif #undef Success #endif // Affects: Should be without side effects. #ifdef GrayScale #ifndef FIXX11H_GrayScale #define FIXX11H_GrayScale const int XGrayScale = GrayScale; #undef GrayScale const int GrayScale = XGrayScale; #endif #undef GrayScale #endif // Affects: Should be without side effects. #ifdef Status #ifndef FIXX11H_Status #define FIXX11H_Status typedef Status XStatus; #undef Status typedef XStatus Status; #endif #undef Status #endif // template ---> // Affects: Should be without side effects. #ifdef CursorShape #ifndef FIXX11H_CursorShape #define FIXX11H_CursorShape const int XCursorShape = CursorShape; #undef CursorShape const int CursorShape = XCursorShape; #endif #undef CursorShape #endif // template <--- // template ---> // Affects: Should be without side effects. #ifdef FontChange #ifndef FIXX11H_FontChange #define FIXX11H_FontChange const int XFontChange = FontChange; #undef FontChange const int FontChange = XFontChange; #endif #undef FontChange #endif // template <--- // Affects: Should be without side effects. #ifdef NormalState #ifndef FIXX11H_NormalState #define FIXX11H_NormalState const int XNormalState = NormalState; #undef NormalState const int NormalState = XNormalState; #endif #undef NormalState #endif // template ---> // Affects: Should be without side effects. #ifdef index #ifndef FIXX11H_index #define FIXX11H_index inline const char *Xindex(const char *s, int c) { return index(s, c); } #undef index inline const char *index(const char *s, int c) { return Xindex(s, c); } #endif #undef index #endif // template <--- #ifdef rindex // Affects: Should be without side effects. #ifndef FIXX11H_rindex #define FIXX11H_rindex inline const char *Xrindex(const char *s, int c) { return rindex(s, c); } #undef rindex inline const char *rindex(const char *s, int c) { return Xrindex(s, c); } #endif #undef rindex #endif } using namespace X; diff --git a/src/plugins/xsync/xsyncbasedpoller.cpp b/src/plugins/xsync/xsyncbasedpoller.cpp index b4fbf13..7fd278a 100644 --- a/src/plugins/xsync/xsyncbasedpoller.cpp +++ b/src/plugins/xsync/xsyncbasedpoller.cpp @@ -1,346 +1,334 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi + SPDX-FileCopyrightText: 2009 Dario Freddi - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-only */ // Exceptionnally, include QCoreApplication before our own header, because that one includes X11 headers (#define None...) #include #include "xsync_logging.h" #include "xsyncbasedpoller.h" #include #include #include // XGetXCBConnection #include class XSyncBasedPollerHelper : public QAbstractNativeEventFilter { public: XSyncBasedPollerHelper() : q(nullptr), isActive(false) {} ~XSyncBasedPollerHelper() { delete q; } bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override { Q_UNUSED(result); if (isActive && eventType == "xcb_generic_event_t") { q->xcbEvent(reinterpret_cast(message)); } return false; } XSyncBasedPoller *q; bool isActive; }; Q_GLOBAL_STATIC(XSyncBasedPollerHelper, s_globalXSyncBasedPoller) XSyncBasedPoller *XSyncBasedPoller::instance() { if (!s_globalXSyncBasedPoller()->q) { new XSyncBasedPoller; } return s_globalXSyncBasedPoller()->q; } XSyncBasedPoller::XSyncBasedPoller(QObject *parent) : AbstractSystemPoller(parent) , m_display(QX11Info::display()) , m_xcb_connection(nullptr) , m_idleCounter(None) , m_resetAlarm(None) , m_available(true) { Q_ASSERT(!s_globalXSyncBasedPoller()->q); s_globalXSyncBasedPoller()->q = this; if (Q_UNLIKELY(!m_display)) { m_available = false; qCWarning(KIDLETIME_XSYNC_PLUGIN) << "xcb sync could not find display"; return; } m_xcb_connection = XGetXCBConnection(m_display); QCoreApplication::instance()->installNativeEventFilter(s_globalXSyncBasedPoller()); const xcb_query_extension_reply_t *sync_reply = xcb_get_extension_data(m_xcb_connection, &xcb_sync_id); if (!sync_reply || !sync_reply->present) { qCWarning(KIDLETIME_XSYNC_PLUGIN) << "xcb sync extension not found"; m_available = false; return; } m_sync_event = sync_reply->first_event; #if 0 // Workaround for https://bugs.freedesktop.org/show_bug.cgi?id=23403 #define xcb_sync_systemcounter_name(sc) (((char *) &(sc)->name_len) + 2) xcb_sync_list_system_counters_cookie_t cookie = xcb_sync_list_system_counters(m_xcb_connection); xcb_sync_list_system_counters_reply_t *reply = xcb_sync_list_system_counters_reply(m_xcb_connection, cookie, NULL); xcb_sync_systemcounter_iterator_t iter; for (iter = xcb_sync_list_system_counters_counters_iterator(reply); iter.rem; xcb_sync_systemcounter_next(&iter)) { printf("%d: %.*s\n", iter.data->counter, iter.data->name_len, xcb_sync_systemcounter_name(iter.data)); /* Extra info for debugging: */ printf(" Actual name: %.*s\n", iter.data->name_len, ((char *) &iter.data->name_len) + 2); } int xcbcounters = xcb_sync_list_system_counters_counters_length(reply); xcb_sync_systemcounter_iterator_t it = xcb_sync_list_system_counters_counters_iterator(reply); for (int i = 0; i < xcbcounters; ++i) { qCDebug(KIDLETIME_XSYNC_PLUGIN) << it.data->counter << it.rem << it.index; qCDebug(KIDLETIME_XSYNC_PLUGIN) << "name length" << xcb_sync_systemcounter_name_length(it.data); QByteArray name(xcb_sync_systemcounter_name(it.data), xcb_sync_systemcounter_name_length(it.data)); qCDebug(KIDLETIME_XSYNC_PLUGIN) << name; xcb_sync_systemcounter_next(&it); } delete reply; #endif int sync_major, sync_minor; int old_sync_event, old_sync_error; if (!XSyncQueryExtension(m_display, &old_sync_event, &old_sync_error)) { m_available = false; return; } if (!XSyncInitialize(m_display, &sync_major, &sync_minor)) { m_available = false; return; } int ncounters; XSyncSystemCounter *counters = XSyncListSystemCounters(m_display, &ncounters); bool idleFound = false; qCDebug(KIDLETIME_XSYNC_PLUGIN) << ncounters << "counters"; for (int i = 0; i < ncounters; ++i) { qCDebug(KIDLETIME_XSYNC_PLUGIN) << counters[i].name << counters[i].counter; if (!strcmp(counters[i].name, "IDLETIME")) { m_idleCounter = counters[i].counter; idleFound = true; break; } } XSyncFreeSystemCounterList(counters); if (!idleFound) { m_available = false; } if (m_available) { qCDebug(KIDLETIME_XSYNC_PLUGIN) << "XSync seems available and ready"; } else { qCDebug(KIDLETIME_XSYNC_PLUGIN) << "XSync seems not available"; } } XSyncBasedPoller::~XSyncBasedPoller() { } bool XSyncBasedPoller::isAvailable() { return m_available; } bool XSyncBasedPoller::setUpPoller() { if (!isAvailable()) { return false; } qCDebug(KIDLETIME_XSYNC_PLUGIN) << "XSync Inited"; s_globalXSyncBasedPoller()->isActive = true; qCDebug(KIDLETIME_XSYNC_PLUGIN) << "Supported, init completed"; return true; } void XSyncBasedPoller::unloadPoller() { s_globalXSyncBasedPoller()->isActive = false; } void XSyncBasedPoller::addTimeout(int nextTimeout) { /* We need to set the counter to the idle time + the value * requested for next timeout */ // If there's already an alarm for the requested timeout, skip if (m_timeoutAlarm.contains(nextTimeout)) { return; } XSyncValue timeout; XSyncAlarm newalarm = None; XSyncIntToValue(&timeout, nextTimeout); setAlarm(m_display, &newalarm, m_idleCounter, XSyncPositiveComparison, timeout); m_timeoutAlarm.insert(nextTimeout, newalarm); } int XSyncBasedPoller::forcePollRequest() { return poll(); } int XSyncBasedPoller::poll() { XSyncValue idleTime; XSyncQueryCounter(m_display, m_idleCounter, &idleTime); return XSyncValueLow32(idleTime); } void XSyncBasedPoller::removeTimeout(int timeout) { if (m_timeoutAlarm.contains(timeout)) { XSyncAlarm a = m_timeoutAlarm[timeout]; XSyncDestroyAlarm(m_display, a); m_timeoutAlarm.remove(timeout); } } QList XSyncBasedPoller::timeouts() const { return m_timeoutAlarm.keys(); } void XSyncBasedPoller::stopCatchingIdleEvents() { if (m_resetAlarm != None) { XSyncDestroyAlarm(m_display, m_resetAlarm); m_resetAlarm = None; } } void XSyncBasedPoller::catchIdleEvent() { XSyncValue idleTime; XSyncQueryCounter(m_display, m_idleCounter, &idleTime); /* Set the reset alarm to fire the next time idleCounter < the * current counter value. XSyncNegativeComparison means <= so * we have to subtract 1 from the counter value */ //NOTE: this must be a int, else compilation might fail int overflow; XSyncValue add; XSyncValue plusone; XSyncIntToValue(&add, -1); XSyncValueAdd(&plusone, idleTime, add, &overflow); setAlarm(m_display, &m_resetAlarm, m_idleCounter, XSyncNegativeComparison, plusone); } void XSyncBasedPoller::reloadAlarms() { XSyncValue timeout; for (QHash::iterator i = m_timeoutAlarm.begin(); i != m_timeoutAlarm.end(); ++i) { XSyncIntToValue(&timeout, i.key()); setAlarm(m_display, &(i.value()), m_idleCounter, XSyncPositiveComparison, timeout); } } bool XSyncBasedPoller::xcbEvent(xcb_generic_event_t *event) { // qCDebug(KIDLETIME_XSYNC_PLUGIN) << event->response_type << "waiting for" << m_sync_event+XCB_SYNC_ALARM_NOTIFY; if (event->response_type != m_sync_event + XCB_SYNC_ALARM_NOTIFY) { return false; } xcb_sync_alarm_notify_event_t *alarmEvent = reinterpret_cast(event); if (alarmEvent->state == XCB_SYNC_ALARMSTATE_DESTROYED) { return false; } for (QHash::const_iterator i = m_timeoutAlarm.constBegin(); i != m_timeoutAlarm.constEnd(); ++i) { if (alarmEvent->alarm == i.value()) { /* Bling! Caught! */ emit timeoutReached(i.key()); // Update the alarm to fire back if the system gets inactive for the same time catchIdleEvent(); return false; } } if (alarmEvent->alarm == m_resetAlarm) { /* Resuming from idle here! */ stopCatchingIdleEvents(); reloadAlarms(); emit resumingFromIdle(); } return false; } void XSyncBasedPoller::setAlarm(Display *dpy, XSyncAlarm *alarm, XSyncCounter counter, XSyncTestType test, XSyncValue value) { XSyncAlarmAttributes attr; XSyncValue delta; unsigned int flags; XSyncIntToValue(&delta, 0); attr.trigger.counter = counter; attr.trigger.value_type = XSyncAbsolute; attr.trigger.test_type = test; attr.trigger.wait_value = value; attr.delta = delta; flags = XSyncCACounter | XSyncCAValueType | XSyncCATestType | XSyncCAValue | XSyncCADelta; if (*alarm) { //xcb_sync_change_alarm_checked(m_xcb_connection, alarmId, ... XSyncChangeAlarm(dpy, *alarm, flags, &attr); } else { *alarm = XSyncCreateAlarm(dpy, flags, &attr); qCDebug(KIDLETIME_XSYNC_PLUGIN) << "Created alarm" << *alarm; } XFlush(m_display); } void XSyncBasedPoller::simulateUserActivity() { XResetScreenSaver(m_display); XFlush(m_display); } diff --git a/src/plugins/xsync/xsyncbasedpoller.h b/src/plugins/xsync/xsyncbasedpoller.h index 1452838..0d34ead 100644 --- a/src/plugins/xsync/xsyncbasedpoller.h +++ b/src/plugins/xsync/xsyncbasedpoller.h @@ -1,79 +1,67 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #ifndef XSYNCBASEDPOLLER_H #define XSYNCBASEDPOLLER_H #include "abstractsystempoller.h" #include #include #include #include #include #include "fixx11h.h" class XSyncBasedPoller : public AbstractSystemPoller { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "xcb.json") Q_INTERFACES(AbstractSystemPoller) public: static XSyncBasedPoller *instance(); explicit XSyncBasedPoller(QObject *parent = nullptr); ~XSyncBasedPoller() override; bool isAvailable() override; bool setUpPoller() override; void unloadPoller() override; bool xcbEvent(xcb_generic_event_t *event); public Q_SLOTS: void addTimeout(int nextTimeout) override; void removeTimeout(int nextTimeout) override; QList timeouts() const override; int forcePollRequest() override; void catchIdleEvent() override; void stopCatchingIdleEvents() override; void simulateUserActivity() override; private Q_SLOTS: int poll(); void reloadAlarms(); private: void setAlarm(Display *dpy, XSyncAlarm *alarm, XSyncCounter counter, XSyncTestType test, XSyncValue value); private: Display *m_display; xcb_connection_t *m_xcb_connection; int m_sync_event; XSyncCounter m_idleCounter; QHash m_timeoutAlarm; XSyncAlarm m_resetAlarm; bool m_available; }; #endif /* XSYNCBASEDPOLLER_H */ diff --git a/src/widgetbasedpoller.cpp b/src/widgetbasedpoller.cpp index 5959cc3..1949b37 100644 --- a/src/widgetbasedpoller.cpp +++ b/src/widgetbasedpoller.cpp @@ -1,164 +1,152 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #include "widgetbasedpoller.h" #include #include #include WidgetBasedPoller::WidgetBasedPoller(QObject *parent) : AbstractSystemPoller(parent) { } WidgetBasedPoller::~WidgetBasedPoller() { } bool WidgetBasedPoller::isAvailable() { return true; } bool WidgetBasedPoller::setUpPoller() { m_pollTimer = new QTimer(this); //setup idle timer, with some smart polling connect(m_pollTimer, &QTimer::timeout, this, &WidgetBasedPoller::poll); // This code was taken from Lithium/KDE4Powersave m_grabber = new QWidget(nullptr, Qt::X11BypassWindowManagerHint); m_grabber->move(-1000, -1000); m_grabber->setMouseTracking(true); m_grabber->installEventFilter(this); m_grabber->setObjectName(QStringLiteral("KIdleGrabberWidget")); return additionalSetUp(); } void WidgetBasedPoller::unloadPoller() { m_pollTimer->deleteLater(); m_grabber->deleteLater(); } QList WidgetBasedPoller::timeouts() const { return m_timeouts; } void WidgetBasedPoller::addTimeout(int nextTimeout) { m_timeouts.append(nextTimeout); poll(); } bool WidgetBasedPoller::eventFilter(QObject *object, QEvent *event) { if (object == m_grabber && (event->type() == QEvent::MouseMove || event->type() == QEvent::KeyPress)) { detectedActivity(); return true; } else if (object != m_grabber) { // If it's not the grabber, fallback to default event filter return false; } // Otherwise, simply ignore it return false; } void WidgetBasedPoller::waitForActivity() { // This code was taken from Lithium/KDE4Powersave m_grabber->show(); m_grabber->grabMouse(); m_grabber->grabKeyboard(); } void WidgetBasedPoller::detectedActivity() { stopCatchingIdleEvents(); emit resumingFromIdle(); } void WidgetBasedPoller::releaseInputLock() { m_grabber->releaseMouse(); m_grabber->releaseKeyboard(); m_grabber->hide(); } int WidgetBasedPoller::poll() { int idle = getIdleTime(); // Check if we reached a timeout.. for(int timeOut : qAsConst(m_timeouts)) { if ( ( timeOut - idle < 300 && timeOut >= idle ) || ( idle - timeOut < 300 && idle > timeOut ) ) { // Bingo! emit timeoutReached( timeOut ); } } // Let's check the timer now! int mintime = 0; for (int i : qAsConst(m_timeouts)) { if (i > idle && (i < mintime || mintime == 0)) { mintime = i; } } //qDebug() << "mintime " << mintime << "idle " << idle; if (mintime != 0) { m_pollTimer->start(mintime - idle); } else { m_pollTimer->stop(); } return idle; } int WidgetBasedPoller::forcePollRequest() { return poll(); } void WidgetBasedPoller::removeTimeout(int timeout) { m_timeouts.removeOne(timeout); poll(); } void WidgetBasedPoller::catchIdleEvent() { waitForActivity(); } void WidgetBasedPoller::stopCatchingIdleEvents() { releaseInputLock(); } diff --git a/src/widgetbasedpoller.h b/src/widgetbasedpoller.h index cef33f1..5737093 100644 --- a/src/widgetbasedpoller.h +++ b/src/widgetbasedpoller.h @@ -1,68 +1,56 @@ /* This file is part of the KDE libraries - Copyright (C) 2009 Dario Freddi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ + * SPDX-FileCopyrightText: 2009 Dario Freddi + * + * SPDX-License-Identifier: LGPL-2.0-only + */ #ifndef WIDGETBASEDPOLLER_H #define WIDGETBASEDPOLLER_H #include #include "abstractsystempoller.h" class QTimer; class QEvent; class KIDLETIME_EXPORT WidgetBasedPoller : public AbstractSystemPoller { Q_OBJECT public: explicit WidgetBasedPoller(QObject *parent = nullptr); ~WidgetBasedPoller() override; bool isAvailable() override; bool setUpPoller() override; void unloadPoller() override; protected: bool eventFilter(QObject *object, QEvent *event) override; public Q_SLOTS: void addTimeout(int nextTimeout) override; void removeTimeout(int nextTimeout) override; QList timeouts() const override; int forcePollRequest() override; void catchIdleEvent() override; void stopCatchingIdleEvents() override; private Q_SLOTS: int poll(); virtual int getIdleTime() = 0; void detectedActivity(); void waitForActivity(); void releaseInputLock(); private: virtual bool additionalSetUp() = 0; private: QTimer *m_pollTimer; QWidget *m_grabber; QList m_timeouts; }; #endif /* WIDGETBASEDPOLLER_H */