diff options
43 files changed, 1045 insertions, 445 deletions
@@ -1,27 +1,674 @@ -Copyright (c) 2014, Jouni Roivas -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -* Neither the name of the {organization} nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. @@ -1,5 +1,6 @@ pebbled ======= +[](https://gitter.im/smokku/pebble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Unofficial Pebble watch support for SailfishOS/Jolla diff --git a/app/pebble.png b/app/pebble.png Binary files differindex 7907dd8..88e6a8d 100644 --- a/app/pebble.png +++ b/app/pebble.png diff --git a/app/qml/pages/AboutPage.qml b/app/qml/pages/AboutPage.qml index 8fd009e..12f4d53 100644 --- a/app/qml/pages/AboutPage.qml +++ b/app/qml/pages/AboutPage.qml @@ -84,13 +84,13 @@ Page { onClicked: Qt.openUrlExternally("https://github.com/smokku/pebble/issues") } Button { - text: "Send application log to developer" + text: "Send issue e-mail to developer" anchors { left: parent.left right: parent.right margins: Theme.paddingLarge } - onClicked: Qt.openUrlExternally("mailto:bugs@xiaoka.com?subject=pebbled issue&body=please describe your issue&attachment=/home/nemo/.cache/pebbled/pebble.log") + onClicked: Qt.openUrlExternally("mailto:bugs@xiaoka.com?subject=pebbled issue&body=describe your issue here") } } } diff --git a/daemon/appmanager.cpp b/daemon/appmanager.cpp index 8745160..c10cf22 100644 --- a/daemon/appmanager.cpp +++ b/daemon/appmanager.cpp @@ -17,7 +17,7 @@ struct ResourceEntry { } AppManager::AppManager(QObject *parent) - : QObject(parent), + : QObject(parent), l(metaObject()->className()), _watcher(new QFileSystemWatcher(this)) { connect(_watcher, &QFileSystemWatcher::directoryChanged, @@ -29,7 +29,7 @@ AppManager::AppManager(QObject *parent) logger()->warn() << "could not create dir" << dataDir.absoluteFilePath("apps"); } } - logger()->debug() << "install apps in" << dataDir.absoluteFilePath("apps"); + qCDebug(l) << "install apps in" << dataDir.absoluteFilePath("apps"); rescan(); } @@ -73,9 +73,9 @@ void AppManager::rescan() Q_FOREACH(const QString &path, appPaths()) { QDir dir(path); _watcher->addPath(dir.absolutePath()); - logger()->debug() << "scanning dir" << dir.absolutePath(); + qCDebug(l) << "scanning dir" << dir.absolutePath(); QStringList entries = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Executable); - logger()->debug() << "scanning dir results" << entries; + qCDebug(l) << "scanning dir results" << entries; Q_FOREACH(const QString &path, entries) { QString appPath = dir.absoluteFilePath(path); _watcher->addPath(appPath); @@ -86,22 +86,22 @@ void AppManager::rescan() } } - logger()->debug() << "now watching" << _watcher->directories() << _watcher->files(); + qCDebug(l) << "now watching" << _watcher->directories() << _watcher->files(); emit appsChanged(); } void AppManager::scanApp(const QString &path) { - logger()->debug() << "scanning app" << path; + qCDebug(l) << "scanning app" << path; QDir appDir(path); if (!appDir.isReadable()) { - logger()->warn() << "app" << appDir.absolutePath() << "is not readable"; + qCWarning(l) << "app" << appDir.absolutePath() << "is not readable"; return; } QFile appInfoFile(path + "/appinfo.json"); if (!appInfoFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - logger()->warn() << "cannot open app info file" << appInfoFile.fileName() << ":" + qCWarning(l) << "cannot open app info file" << appInfoFile.fileName() << ":" << appInfoFile.errorString(); return; } @@ -109,7 +109,7 @@ void AppManager::scanApp(const QString &path) QJsonParseError parseError; QJsonDocument doc = QJsonDocument::fromJson(appInfoFile.readAll(), &parseError); if (parseError.error != QJsonParseError::NoError) { - logger()->warn() << "cannot parse app info file" << appInfoFile.fileName() << ":" + qCWarning(l) << "cannot parse app info file" << appInfoFile.fileName() << ":" << parseError.errorString(); return; } @@ -181,7 +181,7 @@ void AppManager::scanApp(const QString &path) info.setPath(path); if (info.uuid().isNull() || info.shortName().isEmpty()) { - logger()->warn() << "invalid or empty uuid/name in" << appInfoFile.fileName(); + qCWarning(l) << "invalid or empty uuid/name in" << appInfoFile.fileName(); return; } @@ -189,14 +189,14 @@ void AppManager::scanApp(const QString &path) _names.insert(info.shortName(), info.uuid()); const char *type = info.isWatchface() ? "watchface" : "app"; - logger()->debug() << "found installed" << type << info.shortName() << info.versionLabel() << "with uuid" << info.uuid().toString(); + qCDebug(l) << "found installed" << type << info.shortName() << info.versionLabel() << "with uuid" << info.uuid().toString(); } QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_id) const { QFile f(file); if (!f.open(QIODevice::ReadOnly)) { - logger()->warn() << "cannot open resource file" << f.fileName(); + qCWarning(l) << "cannot open resource file" << f.fileName(); return QByteArray(); } @@ -207,7 +207,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i u.readLE<quint32>(); // crc for entire file u.readLE<quint32>(); // timestamp - logger()->debug() << "reading" << num_files << "resources from" << file; + qCDebug(l) << "reading" << num_files << "resources from" << file; QList<ResourceEntry> table; @@ -219,7 +219,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i e.crc = u.readLE<quint32>(); if (u.bad()) { - logger()->warn() << "short read on resource file"; + qCWarning(l) << "short read on resource file"; return QByteArray(); } @@ -227,7 +227,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i } if (wanted_id >= table.size()) { - logger()->warn() << "specified resource does not exist"; + qCWarning(l) << "specified resource does not exist"; return QByteArray(); } @@ -241,7 +241,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i crc.addData(res); if (crc.result() != e.crc) { - logger()->warn() << "CRC failure in resource" << e.index << "on file" << file; + qCWarning(l) << "CRC failure in resource" << e.index << "on file" << file; return QByteArray(); } diff --git a/daemon/appmanager.h b/daemon/appmanager.h index d5e5ba1..e96ffe5 100644 --- a/daemon/appmanager.h +++ b/daemon/appmanager.h @@ -5,13 +5,13 @@ #include <QHash> #include <QUuid> #include <QFileSystemWatcher> -#include <Log4Qt/Logger> +#include <QLoggingCategory> #include "appinfo.h" class AppManager : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit AppManager(QObject *parent = 0); diff --git a/daemon/appmsgmanager.cpp b/daemon/appmsgmanager.cpp index eda1eb4..1a4a424 100644 --- a/daemon/appmsgmanager.cpp +++ b/daemon/appmsgmanager.cpp @@ -7,7 +7,8 @@ // TODO D-Bus server for non JS kit apps!!!! AppMsgManager::AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *parent) - : QObject(parent), apps(apps), watch(watch), _lastTransactionId(0), _timeout(new QTimer(this)) + : QObject(parent), l(metaObject()->className()), apps(apps), + watch(watch), _lastTransactionId(0), _timeout(new QTimer(this)) { connect(watch, &WatchConnector::connectedChanged, this, &AppMsgManager::handleWatchConnectedChanged); @@ -45,7 +46,7 @@ AppMsgManager::AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *p handleAckMessage(data, false); break; default: - logger()->warn() << "Unknown application message type:" << int(data.at(0)); + qCWarning(l) << "Unknown application message type:" << int(data.at(0)); break; } @@ -62,7 +63,7 @@ void AppMsgManager::send(const QUuid &uuid, const QVariantMap &data, const std:: trans.ackCallback = ackCallback; trans.nackCallback = nackCallback; - logger()->debug() << "Queueing appmsg" << trans.transactionId << "to" << trans.uuid + qCDebug(l) << "Queueing appmsg" << trans.transactionId << "to" << trans.uuid << "with dict" << trans.dict; _pending.enqueue(trans); @@ -104,7 +105,7 @@ void AppMsgManager::launchApp(const QUuid &uuid) WatchConnector::Dict dict; dict.insert(1, WatchConnector::launcherSTARTED); - logger()->debug() << "Sending message to launcher" << uuid << dict; + qCDebug(l) << "Sending message to launcher" << uuid << dict; QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict); watch->sendMessage(WatchConnector::watchLAUNCHER, msg); @@ -115,7 +116,7 @@ void AppMsgManager::closeApp(const QUuid &uuid) WatchConnector::Dict dict; dict.insert(1, WatchConnector::launcherSTOPPED); - logger()->debug() << "Sending message to launcher" << uuid << dict; + qCDebug(l) << "Sending message to launcher" << uuid << dict; QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict); watch->sendMessage(WatchConnector::watchLAUNCHER, msg); @@ -125,7 +126,7 @@ WatchConnector::Dict AppMsgManager::mapAppKeys(const QUuid &uuid, const QVariant { AppInfo info = apps->info(uuid); if (info.uuid() != uuid) { - logger()->warn() << "Unknown app GUID while sending message:" << uuid; + qCWarning(l) << "Unknown app GUID while sending message:" << uuid; } WatchConnector::Dict d; @@ -141,7 +142,7 @@ WatchConnector::Dict AppMsgManager::mapAppKeys(const QUuid &uuid, const QVariant if (ok) { d.insert(num, it.value()); } else { - logger()->warn() << "Unknown appKey" << it.key() << "for app with GUID" << uuid; + qCWarning(l) << "Unknown appKey" << it.key() << "for app with GUID" << uuid; } } } @@ -153,7 +154,7 @@ QVariantMap AppMsgManager::mapAppKeys(const QUuid &uuid, const WatchConnector::D { AppInfo info = apps->info(uuid); if (info.uuid() != uuid) { - logger()->warn() << "Unknown app GUID while sending message:" << uuid; + qCWarning(l) << "Unknown app GUID while sending message:" << uuid; } QVariantMap data; @@ -162,7 +163,7 @@ QVariantMap AppMsgManager::mapAppKeys(const QUuid &uuid, const WatchConnector::D if (info.hasAppKeyValue(it.key())) { data.insert(info.appKeyForValue(it.key()), it.value()); } else { - logger()->warn() << "Unknown appKey value" << it.key() << "for app with GUID" << uuid; + qCWarning(l) << "Unknown appKey value" << it.key() << "for app with GUID" << uuid; data.insert(QString::number(it.key()), it.value()); } } @@ -174,6 +175,7 @@ bool AppMsgManager::unpackPushMessage(const QByteArray &msg, quint8 *transaction { Unpacker u(msg); quint8 code = u.read<quint8>(); + Q_UNUSED(code); Q_ASSERT(code == WatchConnector::appmsgPUSH); *transaction = u.read<quint8>(); @@ -225,29 +227,29 @@ void AppMsgManager::handleLauncherPushMessage(const QByteArray &data) // Failed to parse! // Since we're the only one handling this endpoint, // all messages must be accepted - logger()->warn() << "Failed to parser LAUNCHER PUSH message"; + qCWarning(l) << "Failed to parser LAUNCHER PUSH message"; return; } if (!dict.contains(1)) { - logger()->warn() << "LAUNCHER message has no item in dict"; + qCWarning(l) << "LAUNCHER message has no item in dict"; return; } switch (dict.value(1).toInt()) { case WatchConnector::launcherSTARTED: - logger()->debug() << "App starting in watch:" << uuid; + qCDebug(l) << "App starting in watch:" << uuid; this->watch->sendMessage(WatchConnector::watchLAUNCHER, buildAckMessage(transaction)); emit appStarted(uuid); break; case WatchConnector::launcherSTOPPED: - logger()->debug() << "App stopping in watch:" << uuid; + qCDebug(l) << "App stopping in watch:" << uuid; this->watch->sendMessage(WatchConnector::watchLAUNCHER, buildAckMessage(transaction)); emit appStopped(uuid); break; default: - logger()->warn() << "LAUNCHER pushed unknown message:" << uuid << dict; + qCWarning(l) << "LAUNCHER pushed unknown message:" << uuid << dict; this->watch->sendMessage(WatchConnector::watchLAUNCHER, buildNackMessage(transaction)); break; @@ -261,16 +263,16 @@ void AppMsgManager::handlePushMessage(const QByteArray &data) WatchConnector::Dict dict; if (!unpackPushMessage(data, &transaction, &uuid, &dict)) { - logger()->warn() << "Failed to parse APP_MSG PUSH"; + qCWarning(l) << "Failed to parse APP_MSG PUSH"; watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE, buildNackMessage(transaction)); return; } - logger()->debug() << "Received appmsg PUSH from" << uuid << "with" << dict; + qCDebug(l) << "Received appmsg PUSH from" << uuid << "with" << dict; QVariantMap msg = mapAppKeys(uuid, dict); - logger()->debug() << "Mapped dict" << msg; + qCDebug(l) << "Mapped dict" << msg; bool result; @@ -283,11 +285,11 @@ void AppMsgManager::handlePushMessage(const QByteArray &data) } if (result) { - logger()->debug() << "ACKing transaction" << transaction; + qCDebug(l) << "ACKing transaction" << transaction; watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE, buildAckMessage(transaction)); } else { - logger()->info() << "NACKing transaction" << transaction; + qCDebug(l) << "NACKing transaction" << transaction; watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE, buildNackMessage(transaction)); } @@ -296,26 +298,26 @@ void AppMsgManager::handlePushMessage(const QByteArray &data) void AppMsgManager::handleAckMessage(const QByteArray &data, bool ack) { if (data.size() < 2) { - logger()->warn() << "invalid ack/nack message size"; + qCWarning(l) << "invalid ack/nack message size"; return; } - const quint8 type = data[0]; + const quint8 type = data[0]; Q_UNUSED(type); const quint8 recv_transaction = data[1]; Q_ASSERT(type == WatchConnector::appmsgACK || type == WatchConnector::appmsgNACK); if (_pending.empty()) { - logger()->warn() << "received an ack/nack for transaction" << recv_transaction << "but no transaction is pending"; + qCWarning(l) << "received an ack/nack for transaction" << recv_transaction << "but no transaction is pending"; return; } PendingTransaction &trans = _pending.head(); if (trans.transactionId != recv_transaction) { - logger()->warn() << "received an ack/nack but for the wrong transaction"; + qCWarning(l) << "received an ack/nack but for the wrong transaction"; } - logger()->debug() << "Got " << (ack ? "ACK" : "NACK") << " to transaction" << trans.transactionId; + qCDebug(l) << "Got " << (ack ? "ACK" : "NACK") << " to transaction" << trans.transactionId; _timeout->stop(); @@ -351,7 +353,7 @@ void AppMsgManager::handleTimeout() Q_ASSERT(!_pending.empty()); PendingTransaction trans = _pending.dequeue(); - logger()->warn() << "timeout on appmsg transaction" << trans.transactionId; + qCWarning(l) << "timeout on appmsg transaction" << trans.transactionId; if (trans.nackCallback) { trans.nackCallback(); diff --git a/daemon/appmsgmanager.h b/daemon/appmsgmanager.h index e52c544..0a3acba 100644 --- a/daemon/appmsgmanager.h +++ b/daemon/appmsgmanager.h @@ -11,7 +11,7 @@ class AppMsgManager : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *parent); diff --git a/daemon/bankmanager.cpp b/daemon/bankmanager.cpp index 7bc7f91..f0aa68b 100644 --- a/daemon/bankmanager.cpp +++ b/daemon/bankmanager.cpp @@ -7,17 +7,17 @@ #if 0 // TODO -- This is how language files seems to be installed. if (slot == -4) { - logger()->debug() << "starting lang install"; + qCDebug(l) << "starting lang install"; QFile *pbl = new QFile(QDir::home().absoluteFilePath("es.pbl")); if (!pbl->open(QIODevice::ReadOnly)) { - logger()->warn() << "Failed to open pbl"; + qCWarning(l) << "Failed to open pbl"; return false; } upload->uploadFile("lang", pbl, [this]() { - logger()->debug() << "success"; + qCDebug(l) << "success"; }, [this](int code) { - logger()->warn() << "Some error" << code; + qCWarning(l) << "Some error" << code; }); return true; @@ -25,7 +25,8 @@ if (slot == -4) { #endif BankManager::BankManager(WatchConnector *watch, UploadManager *upload, AppManager *apps, QObject *parent) : - QObject(parent), watch(watch), upload(upload), apps(apps), _refresh(new QTimer(this)) + QObject(parent), l(metaObject()->className()), + watch(watch), upload(upload), apps(apps), _refresh(new QTimer(this)) { connect(watch, &WatchConnector::connectedChanged, this, &BankManager::handleWatchConnected); @@ -55,43 +56,43 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) { AppInfo info = apps->info(uuid); if (info.uuid() != uuid) { - logger()->warn() << "uuid" << uuid << "is not installed"; + qCWarning(l) << "uuid" << uuid << "is not installed"; return false; } if (slot == -1) { slot = findUnusedSlot(); if (slot == -1) { - logger()->warn() << "no free slots!"; + qCWarning(l) << "no free slots!"; return false; } } if (slot < 0 || slot > _slots.size()) { - logger()->warn() << "invalid slot index"; + qCWarning(l) << "invalid slot index"; return false; } if (_slots[slot].used) { - logger()->warn() << "slot in use"; + qCWarning(l) << "slot in use"; return false; } QDir appDir(info.path()); - logger()->debug() << "about to install app from" << appDir.absolutePath() << "into slot" << slot; + qCDebug(l) << "about to install app from" << appDir.absolutePath() << "into slot" << slot; QFile *binaryFile = new QFile(appDir.absoluteFilePath("pebble-app.bin"), this); if (!binaryFile->open(QIODevice::ReadOnly)) { - logger()->warn() << "failed to open" << binaryFile->fileName() << ":" << binaryFile->errorString(); + qCWarning(l) << "failed to open" << binaryFile->fileName() << ":" << binaryFile->errorString(); delete binaryFile; return false; } - logger()->debug() << "binary file size is" << binaryFile->size(); + qCDebug(l) << "binary file size is" << binaryFile->size(); QFile *resourceFile = 0; if (appDir.exists("app_resources.pbpack")) { resourceFile = new QFile(appDir.absoluteFilePath("app_resources.pbpack"), this); if (!resourceFile->open(QIODevice::ReadOnly)) { - logger()->warn() << "failed to open" << resourceFile->fileName() << ":" << resourceFile->errorString(); + qCWarning(l) << "failed to open" << resourceFile->fileName() << ":" << resourceFile->errorString(); delete resourceFile; return false; } @@ -104,27 +105,27 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) upload->uploadAppBinary(slot, binaryFile, [this, binaryFile, resourceFile, slot]() { - logger()->debug() << "app binary upload succesful"; + qCDebug(l) << "app binary upload succesful"; delete binaryFile; // Proceed to upload the resource file if (resourceFile) { upload->uploadAppResources(slot, resourceFile, [this, resourceFile, slot]() { - logger()->debug() << "app resources upload succesful"; + qCDebug(l) << "app resources upload succesful"; delete resourceFile; // Upload succesful // Tell the watch to reload the slot refreshWatchApp(slot, [this]() { - logger()->debug() << "app refresh succesful"; + qCDebug(l) << "app refresh succesful"; _refresh->start(); }, [this](int code) { - logger()->warn() << "app refresh failed" << code; + qCWarning(l) << "app refresh failed" << code; _refresh->start(); }); }, [this, resourceFile](int code) { - logger()->warn() << "app resources upload failed" << code; + qCWarning(l) << "app resources upload failed" << code; delete resourceFile; _refresh->start(); @@ -134,15 +135,15 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) // No resource file // Tell the watch to reload the slot refreshWatchApp(slot, [this]() { - logger()->debug() << "app refresh succesful"; + qCDebug(l) << "app refresh succesful"; _refresh->start(); }, [this](int code) { - logger()->warn() << "app refresh failed" << code; + qCWarning(l) << "app refresh failed" << code; _refresh->start(); }); } }, [this, binaryFile, resourceFile](int code) { - logger()->warn() << "app binary upload failed" << code; + qCWarning(l) << "app binary upload failed" << code; delete binaryFile; delete resourceFile; @@ -155,15 +156,15 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) bool BankManager::unloadApp(int slot) { if (slot < 0 || slot > _slots.size()) { - logger()->warn() << "invalid slot index"; + qCWarning(l) << "invalid slot index"; return false; } if (!_slots[slot].used) { - logger()->warn() << "slot is empty"; + qCWarning(l) << "slot is empty"; return false; } - logger()->debug() << "going to unload app" << _slots[slot].name << "in slot" << slot; + qCDebug(l) << "going to unload app" << _slots[slot].name << "in slot" << slot; int installId = _slots[slot].id; @@ -184,10 +185,10 @@ bool BankManager::unloadApp(int slot) uint result = u.read<quint32>(); switch (result) { case Success: /* Success */ - logger()->debug() << "sucessfully unloaded app"; + qCDebug(l) << "sucessfully unloaded app"; break; default: - logger()->warn() << "could not unload app. result code:" << result; + qCWarning(l) << "could not unload app. result code:" << result; break; } @@ -201,7 +202,7 @@ bool BankManager::unloadApp(int slot) void BankManager::refresh() { - logger()->debug() << "refreshing bank status"; + qCDebug(l) << "refreshing bank status"; watch->sendMessage(WatchConnector::watchAPP_MANAGER, QByteArray(1, WatchConnector::appmgrGET_APPBANK_STATUS), @@ -211,7 +212,7 @@ void BankManager::refresh() } if (data.size() < 9) { - logger()->warn() << "invalid getAppbankStatus response"; + qCWarning(l) << "invalid getAppbankStatus response"; return true; } @@ -222,7 +223,7 @@ void BankManager::refresh() unsigned int num_banks = u.read<quint32>(); unsigned int apps_installed = u.read<quint32>(); - logger()->debug() << "Bank status:" << apps_installed << "/" << num_banks; + qCDebug(l) << "Bank status:" << apps_installed << "/" << num_banks; _slots.resize(num_banks); for (unsigned int i = 0; i < num_banks; i++) { @@ -244,12 +245,12 @@ void BankManager::refresh() unsigned short version = u.read<quint16>(); if (index < 0 || index >= _slots.size()) { - logger()->warn() << "Invalid slot index" << index; + qCWarning(l) << "Invalid slot index" << index; continue; } if (u.bad()) { - logger()->warn() << "short read"; + qCWarning(l) << "short read"; return true; } @@ -264,7 +265,7 @@ void BankManager::refresh() QUuid uuid = info.uuid(); _slots[index].uuid = uuid; - logger()->debug() << index << id << name << company << flags << version << uuid; + qCDebug(l) << index << id << name << company << flags << version << uuid; } emit this->slotsChanged(); @@ -332,10 +333,10 @@ void BankManager::getAppbankUuids(const function<void(const QList<QUuid> &)>& ca if (data.at(0) != WatchConnector::appmgrGET_APPBANK_UUIDS) { return false; } - logger()->debug() << "getAppbankUuids response" << data.toHex(); + qCDebug(l) << "getAppbankUuids response" << data.toHex(); if (data.size() < 5) { - logger()->warn() << "invalid getAppbankUuids response"; + qCWarning(l) << "invalid getAppbankUuids response"; return true; } @@ -345,24 +346,24 @@ void BankManager::getAppbankUuids(const function<void(const QList<QUuid> &)>& ca unsigned int apps_installed = u.read<quint32>(); - logger()->debug() << apps_installed; + qCDebug(l) << apps_installed; QList<QUuid> uuids; for (unsigned int i = 0; i < apps_installed; i++) { QUuid uuid = u.readUuid(); - logger()->debug() << uuid.toString(); + qCDebug(l) << uuid.toString(); if (u.bad()) { - logger()->warn() << "short read"; + qCWarning(l) << "short read"; return true; } uuids.push_back(uuid); } - logger()->debug() << "finished"; + qCDebug(l) << "finished"; callback(uuids); diff --git a/daemon/bankmanager.h b/daemon/bankmanager.h index 871db6b..7532812 100644 --- a/daemon/bankmanager.h +++ b/daemon/bankmanager.h @@ -8,7 +8,7 @@ class BankManager : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit BankManager(WatchConnector *watch, UploadManager *upload, AppManager *apps, QObject *parent = 0); diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index b745e5c..178f04d 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -34,8 +34,7 @@ #include <QFile> #include <QDir> #include <QFileInfo> -#include <Log4Qt/LogManager> -#include <Log4Qt/PropertyConfigurator> +#include <QLoggingCategory> void signalhandler(int sig) { @@ -49,34 +48,21 @@ void signalhandler(int sig) } } -void initLogging() -{ - // Sailfish OS-specific locations for the app settings files and app's own files - const QString logConfigFilePath(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).at(0) - + "pebble/log4qt.conf"); - const QString fallbackLogConfigPath("/usr/share/pebble/log4qt.conf"); - - const QString& usedConfigFile = QFile::exists(logConfigFilePath) ? logConfigFilePath : fallbackLogConfigPath; - Log4Qt::PropertyConfigurator::configure(usedConfigFile); - - // For capturing qDebug() and console.log() messages - // Note that console.log() might fail in Sailfish OS device builds. Not sure why, but it seems like - // console.log() exactly in Sailfish OS device release builds doesn't go through the same qDebug() channel - Log4Qt::LogManager::setHandleQtMessages(true); - - qDebug() << "Using following log config file:" << usedConfigFile; -} - int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); app.setApplicationName("pebble"); // Use the same appname as the UI. - // Init logging should be called after app object creation as initLogging() will examine - // QCoreApplication for determining the .conf files locations - initLogging(); + QStringList filterRules; + + filterRules << (argc > 1 and QString("-d") == argv[0] ? + "*.debug=false" : "*.debug=true"); + + // Init logging should be called after app object creation + QLoggingCategory::setFilterRules(filterRules.join("\n")); - Log4Qt::Logger::logger(QLatin1String("Main Logger"))->info() << argv[0] << APP_VERSION; + QLoggingCategory l("main"); + qCDebug(l) << argv[0] << APP_VERSION; Settings settings; Manager manager(&settings); diff --git a/daemon/daemon.pro b/daemon/daemon.pro index 6eea288..1c287d0 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -2,14 +2,11 @@ TARGET = pebbled CONFIG += console CONFIG += link_pkgconfig -QT -= gui -QT += bluetooth dbus contacts gui qml positioning +QT += core gui qml bluetooth dbus contacts positioning PKGCONFIG += mlite5 icu-i18n CONFIG += c++11 -LIBS += -llog4qt - DEFINES += APP_VERSION=\\\"$$VERSION\\\" SOURCES += \ @@ -54,14 +51,12 @@ HEADERS += \ uploadmanager.h \ stm32crc.h -OTHER_FILES += \ - ../log4qt-debug.conf \ - ../log4qt-release.conf \ - js/typedarray.js - DBUS_ADAPTORS += ../org.pebbled.Watch.xml -INSTALLS += target systemd confile js +OTHER_FILES += $$DBUS_ADAPTORS \ + js/typedarray.js + +INSTALLS += target systemd js target.path = /usr/bin @@ -71,14 +66,5 @@ systemd.path = /usr/lib/systemd/user js.files = js/* js.path = /usr/share/pebble/js -CONFIG(debug, debug|release) { - confile.extra = cp $$PWD/../log4qt-debug.conf $$OUT_PWD/../log4qt.conf -} else { - confile.extra = cp $$PWD/../log4qt-release.conf $$OUT_PWD/../log4qt.conf -} - -confile.files = $$OUT_PWD/../log4qt.conf -confile.path = /usr/share/pebble - # unnecesary includes, just so QtCreator could find headers... :-( INCLUDEPATH += $$[QT_HOST_PREFIX]/include/mlite5 diff --git a/daemon/datalogmanager.cpp b/daemon/datalogmanager.cpp index 8026e15..c3562ef 100644 --- a/daemon/datalogmanager.cpp +++ b/daemon/datalogmanager.cpp @@ -2,11 +2,11 @@ #include "unpacker.h" DataLogManager::DataLogManager(WatchConnector *watch, QObject *parent) : - QObject(parent), watch(watch) + QObject(parent), l(metaObject()->className()), watch(watch) { watch->setEndpointHandler(WatchConnector::watchDATA_LOGGING, [this](const QByteArray& data) { if (data.size() < 2) { - logger()->warn() << "small data_logging packet"; + qCWarning(l) << "small data_logging packet"; return false; } @@ -15,13 +15,13 @@ DataLogManager::DataLogManager(WatchConnector *watch, QObject *parent) : switch (command) { case WatchConnector::datalogOPEN: - logger()->debug() << "open datalog session" << session; + qCDebug(l) << "open datalog session" << session; return true; case WatchConnector::datalogCLOSE: - logger()->debug() << "close datalog session" << session; + qCDebug(l) << "close datalog session" << session; return true; case WatchConnector::datalogTIMEOUT: - logger()->debug() << "timeout datalog session" << session; + qCDebug(l) << "timeout datalog session" << session; return true; case WatchConnector::datalogDATA: handleDataCommand(session, data.mid(2)); @@ -38,5 +38,5 @@ void DataLogManager::handleDataCommand(int session, const QByteArray &data) // TODO Seemingly related to analytics, so not important. - logger()->debug() << "got datalog data" << session << data.size(); + qCDebug(l) << "got datalog data" << session << data.size(); } diff --git a/daemon/datalogmanager.h b/daemon/datalogmanager.h index 47fc948..b36875a 100644 --- a/daemon/datalogmanager.h +++ b/daemon/datalogmanager.h @@ -6,7 +6,7 @@ class DataLogManager : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit DataLogManager(WatchConnector *watch, QObject *parent = 0); diff --git a/daemon/dbusconnector.cpp b/daemon/dbusconnector.cpp index 1f3ffc2..197a12f 100644 --- a/daemon/dbusconnector.cpp +++ b/daemon/dbusconnector.cpp @@ -13,9 +13,8 @@ //dbus-send --system --dest=org.bluez --print-reply $devpath org.bluez.Input.Connect DBusConnector::DBusConnector(QObject *parent) : - QObject(parent) -{ -} + QObject(parent), l(metaObject()->className()) +{} bool DBusConnector::findPebble() { @@ -25,14 +24,14 @@ bool DBusConnector::findPebble() QDBusMessage::createMethodCall("org.bluez", "/", "org.bluez.Manager", "ListAdapters")); if (not ListAdaptersReply.isValid()) { - logger()->error() << ListAdaptersReply.error().message(); + qCCritical(l) << ListAdaptersReply.error().message(); return false; } QList<QDBusObjectPath> adapters = ListAdaptersReply.value(); if (adapters.isEmpty()) { - logger()->debug() << "No BT adapters found"; + qCDebug(l) << "No BT adapters found"; return false; } @@ -40,7 +39,7 @@ bool DBusConnector::findPebble() QDBusMessage::createMethodCall("org.bluez", adapters[0].path(), "org.bluez.Adapter", "GetProperties")); if (not AdapterPropertiesReply.isValid()) { - logger()->error() << AdapterPropertiesReply.error().message(); + qCCritical(l) << AdapterPropertiesReply.error().message(); return false; } @@ -52,16 +51,16 @@ bool DBusConnector::findPebble() QDBusMessage::createMethodCall("org.bluez", path.path(), "org.bluez.Device", "GetProperties")); if (not DevicePropertiesReply.isValid()) { - logger()->error() << DevicePropertiesReply.error().message(); + qCCritical(l) << DevicePropertiesReply.error().message(); continue; } const QVariantMap &dict = DevicePropertiesReply.value(); QString tmp = dict["Name"].toString(); - logger()->debug() << "Found BT device:" << tmp; + qCDebug(l) << "Found BT device:" << tmp; if (tmp.startsWith("Pebble")) { - logger()->debug() << "Found Pebble:" << tmp; + qCDebug(l) << "Found Pebble:" << tmp; pebbleProps = dict; emit pebbleChanged(); return true; diff --git a/daemon/dbusconnector.h b/daemon/dbusconnector.h index 7ed3d56..6b48f99 100644 --- a/daemon/dbusconnector.h +++ b/daemon/dbusconnector.h @@ -4,14 +4,14 @@ #include <QObject> #include <QStringList> #include <QVariantMap> -#include <Log4Qt/Logger> +#include <QLoggingCategory> // TODO Remove this. class DBusConnector : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_PROPERTY(QVariantMap pebble READ pebble NOTIFY pebbleChanged) QVariantMap pebbleProps; diff --git a/daemon/jskitmanager.cpp b/daemon/jskitmanager.cpp index 5c72acc..f6a3f24 100644 --- a/daemon/jskitmanager.cpp +++ b/daemon/jskitmanager.cpp @@ -5,7 +5,8 @@ #include "jskitobjects.h" JSKitManager::JSKitManager(WatchConnector *watch, AppManager *apps, AppMsgManager *appmsg, Settings *settings, QObject *parent) : - QObject(parent), _watch(watch), _apps(apps), _appmsg(appmsg), _settings(settings), _engine(0) + QObject(parent), l(metaObject()->className()), + _watch(watch), _apps(apps), _appmsg(appmsg), _settings(settings), _engine(0) { connect(_appmsg, &AppMsgManager::appStarted, this, &JSKitManager::handleAppStarted); connect(_appmsg, &AppMsgManager::appStopped, this, &JSKitManager::handleAppStopped); @@ -39,10 +40,10 @@ QString JSKitManager::describeError(QJSValue error) void JSKitManager::showConfiguration() { if (_engine) { - logger()->debug() << "requesting configuration"; + qCDebug(l) << "requesting configuration"; _jspebble->invokeCallbacks("showConfiguration"); } else { - logger()->warn() << "requested to show configuration, but JS engine is not running"; + qCWarning(l) << "requested to show configuration, but JS engine is not running"; } } @@ -52,11 +53,11 @@ void JSKitManager::handleWebviewClosed(const QString &result) QJSValue eventObj = _engine->newObject(); eventObj.setProperty("response", _engine->toScriptValue(result)); - logger()->debug() << "webview closed with the following result: " << result; + qCDebug(l) << "webview closed with the following result: " << result; _jspebble->invokeCallbacks("webviewclosed", QJSValueList({eventObj})); } else { - logger()->warn() << "webview closed event, but JS engine is not running"; + qCWarning(l) << "webview closed event, but JS engine is not running"; } } @@ -64,7 +65,7 @@ void JSKitManager::handleAppStarted(const QUuid &uuid) { AppInfo info = _apps->info(uuid); if (!info.uuid().isNull() && info.isJSKit()) { - logger()->debug() << "Preparing to start JSKit app" << info.uuid() << info.shortName(); + qCDebug(l) << "Preparing to start JSKit app" << info.uuid() << info.shortName(); _curApp = info; startJsApp(); } @@ -74,7 +75,7 @@ void JSKitManager::handleAppStopped(const QUuid &uuid) { if (!_curApp.uuid().isNull()) { if (_curApp.uuid() != uuid) { - logger()->warn() << "Closed app with invalid UUID"; + qCWarning(l) << "Closed app with invalid UUID"; } stopJsApp(); @@ -85,10 +86,10 @@ void JSKitManager::handleAppStopped(const QUuid &uuid) void JSKitManager::handleAppMessage(const QUuid &uuid, const QVariantMap &msg) { if (_curApp.uuid() == uuid) { - logger()->debug() << "received a message for the current JSKit app"; + qCDebug(l) << "received a message for the current JSKit app"; if (!_engine) { - logger()->debug() << "but engine is stopped"; + qCDebug(l) << "but engine is stopped"; return; } @@ -105,19 +106,19 @@ bool JSKitManager::loadJsFile(const QString &filename) QFile file(filename); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - logger()->warn() << "Failed to load JS file:" << file.fileName(); + qCWarning(l) << "Failed to load JS file:" << file.fileName(); return false; } - logger()->debug() << "now parsing" << file.fileName(); + qCDebug(l) << "now parsing" << file.fileName(); QJSValue result = _engine->evaluate(QString::fromUtf8(file.readAll()), file.fileName()); if (result.isError()) { - logger()->warn() << "error while evaluating JS script:" << describeError(result); + qCWarning(l) << "error while evaluating JS script:" << describeError(result); return false; } - logger()->debug() << "JS script evaluated"; + qCDebug(l) << "JS script evaluated"; return true; } @@ -126,7 +127,7 @@ void JSKitManager::startJsApp() { if (_engine) stopJsApp(); if (_curApp.uuid().isNull()) { - logger()->warn() << "Attempting to start JS app with invalid UUID"; + qCWarning(l) << "Attempting to start JS app with invalid UUID"; return; } @@ -136,7 +137,7 @@ void JSKitManager::startJsApp() _jsstorage = new JSKitLocalStorage(_curApp.uuid(), this); _jsgeo = new JSKitGeolocation(this); - logger()->debug() << "starting JS app"; + qCDebug(l) << "starting JS app"; QJSValue globalObj = _engine->globalObject(); @@ -185,7 +186,7 @@ void JSKitManager::stopJsApp() { if (!_engine) return; // Nothing to do! - logger()->debug() << "stopping JS app"; + qCDebug(l) << "stopping JS app"; if (!_curApp.uuid().isNull()) { _appmsg->clearMessageHandler(_curApp.uuid()); diff --git a/daemon/jskitmanager.h b/daemon/jskitmanager.h index 871ab8e..4482f34 100644 --- a/daemon/jskitmanager.h +++ b/daemon/jskitmanager.h @@ -14,7 +14,7 @@ class JSKitGeolocation; class JSKitManager : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit JSKitManager(WatchConnector *watch, AppManager *apps, AppMsgManager *appmsg, Settings *settings, QObject *parent = 0); diff --git a/daemon/jskitobjects.cpp b/daemon/jskitobjects.cpp index fe924e8..2aca027 100644 --- a/daemon/jskitobjects.cpp +++ b/daemon/jskitobjects.cpp @@ -11,7 +11,7 @@ static const char *token_salt = "0feeb7416d3c4546a19b04bccd8419b1"; JSKitPebble::JSKitPebble(const AppInfo &info, JSKitManager *mgr) - : QObject(mgr), _appInfo(info), _mgr(mgr) + : QObject(mgr), l(metaObject()->className()), _appInfo(info), _mgr(mgr) { } @@ -44,35 +44,35 @@ uint JSKitPebble::sendAppMessage(QJSValue message, QJSValue callbackForAck, QJSV QPointer<JSKitPebble> pebbObj = this; uint transactionId = _mgr->_appmsg->nextTransactionId(); - logger()->debug() << "sendAppMessage" << data; + qCDebug(l) << "sendAppMessage" << data; _mgr->_appmsg->send(_appInfo.uuid(), data, [pebbObj, transactionId, callbackForAck]() mutable { if (pebbObj.isNull()) return; if (callbackForAck.isCallable()) { - pebbObj->logger()->debug() << "Invoking ack callback"; + qCDebug(pebbObj->l) << "Invoking ack callback"; QJSValue event = pebbObj->buildAckEventObject(transactionId); QJSValue result = callbackForAck.call(QJSValueList({event})); if (result.isError()) { - pebbObj->logger()->warn() << "error while invoking ACK callback" << callbackForAck.toString() << ":" + qCWarning(pebbObj->l) << "error while invoking ACK callback" << callbackForAck.toString() << ":" << JSKitManager::describeError(result); } } else { - pebbObj->logger()->debug() << "Ack callback not callable"; + qCDebug(pebbObj->l) << "Ack callback not callable"; } }, [pebbObj, transactionId, callbackForNack]() mutable { if (pebbObj.isNull()) return; if (callbackForNack.isCallable()) { - pebbObj->logger()->debug() << "Invoking nack callback"; + qCDebug(pebbObj->l) << "Invoking nack callback"; QJSValue event = pebbObj->buildAckEventObject(transactionId, "NACK from watch"); QJSValue result = callbackForNack.call(QJSValueList({event})); if (result.isError()) { - pebbObj->logger()->warn() << "error while invoking NACK callback" << callbackForNack.toString() << ":" + qCWarning(pebbObj->l) << "error while invoking NACK callback" << callbackForNack.toString() << ":" << JSKitManager::describeError(result); } } else { - pebbObj->logger()->debug() << "Nack callback not callable"; + qCDebug(pebbObj->l) << "Nack callback not callable"; } }); @@ -81,13 +81,13 @@ uint JSKitPebble::sendAppMessage(QJSValue message, QJSValue callbackForAck, QJSV void JSKitPebble::showSimpleNotificationOnPebble(const QString &title, const QString &body) { - logger()->debug() << "showSimpleNotificationOnPebble" << title << body; + qCDebug(l) << "showSimpleNotificationOnPebble" << title << body; emit _mgr->appNotification(_appInfo.uuid(), title, body); } void JSKitPebble::openURL(const QUrl &url) { - logger()->debug() << "opening url" << url.toString(); + qCDebug(l) << "opening url" << url.toString(); emit _mgr->appOpenUrl(url); } @@ -102,13 +102,13 @@ QString JSKitPebble::getAccountToken() const QString token = _mgr->_settings->property("accountToken").toString(); if (token.isEmpty()) { token = QUuid::createUuid().toString(); - logger()->debug() << "created new account token" << token; + qCDebug(l) << "created new account token" << token; _mgr->_settings->setProperty("accountToken", token); } hasher.addData(token.toLatin1()); QString hash = hasher.result().toHex(); - logger()->debug() << "returning account token" << hash; + qCDebug(l) << "returning account token" << hash; return hash; } @@ -122,7 +122,7 @@ QString JSKitPebble::getWatchToken() const hasher.addData(_mgr->_watch->serialNumber().toLatin1()); QString hash = hasher.result().toHex(); - logger()->debug() << "returning watch token" << hash; + qCDebug(l) << "returning watch token" << hash; return hash; } @@ -158,23 +158,23 @@ void JSKitPebble::invokeCallbacks(const QString &type, const QJSValueList &args) QList<QJSValue> &callbacks = _callbacks[type]; for (QList<QJSValue>::iterator it = callbacks.begin(); it != callbacks.end(); ++it) { - logger()->debug() << "invoking callback" << type << it->toString(); + qCDebug(l) << "invoking callback" << type << it->toString(); QJSValue result = it->call(args); if (result.isError()) { - logger()->warn() << "error while invoking callback" << type << it->toString() << ":" + qCWarning(l) << "error while invoking callback" << type << it->toString() << ":" << JSKitManager::describeError(result); } } } JSKitConsole::JSKitConsole(JSKitManager *mgr) - : QObject(mgr) + : QObject(mgr), l(metaObject()->className()) { } void JSKitConsole::log(const QString &msg) { - logger()->info() << msg; + qCDebug(l) << msg; } JSKitLocalStorage::JSKitLocalStorage(const QUuid &uuid, JSKitManager *mgr) @@ -237,17 +237,17 @@ QString JSKitLocalStorage::getStorageFileFor(const QUuid &uuid) } JSKitXMLHttpRequest::JSKitXMLHttpRequest(JSKitManager *mgr, QObject *parent) - : QObject(parent), _mgr(mgr), + : QObject(parent), l(metaObject()->className()), _mgr(mgr), _net(new QNetworkAccessManager(this)), _timeout(0), _reply(0) { - logger()->debug() << "constructed"; + qCDebug(l) << "constructed"; connect(_net, &QNetworkAccessManager::authenticationRequired, this, &JSKitXMLHttpRequest::handleAuthenticationRequired); } JSKitXMLHttpRequest::~JSKitXMLHttpRequest() { - logger()->debug() << "destructed"; + qCDebug(l) << "destructed"; } void JSKitXMLHttpRequest::open(const QString &method, const QString &url, bool async, const QString &username, const QString &password) @@ -263,12 +263,12 @@ void JSKitXMLHttpRequest::open(const QString &method, const QString &url, bool a _verb = method; Q_UNUSED(async); - logger()->debug() << "opened to URL" << _request.url().toString(); + qCDebug(l) << "opened to URL" << _request.url().toString(); } void JSKitXMLHttpRequest::setRequestHeader(const QString &header, const QString &value) { - logger()->debug() << "setRequestHeader" << header << value; + qCDebug(l) << "setRequestHeader" << header << value; _request.setRawHeader(header.toLatin1(), value.toLatin1()); } @@ -299,12 +299,12 @@ void JSKitXMLHttpRequest::send(const QJSValue &data) byteData.append(array.property(i).toInt()); } - logger()->debug() << "passed an ArrayBufferView of" << byteData.length() << "bytes"; + qCDebug(l) << "passed an ArrayBufferView of" << byteData.length() << "bytes"; } else { - logger()->warn() << "passed an unknown/invalid ArrayBuffer" << data.toString(); + qCWarning(l) << "passed an unknown/invalid ArrayBuffer" << data.toString(); } } else { - logger()->warn() << "passed an unknown object" << data.toString(); + qCWarning(l) << "passed an unknown object" << data.toString(); } } @@ -317,7 +317,7 @@ void JSKitXMLHttpRequest::send(const QJSValue &data) buffer = 0; } - logger()->debug() << "sending" << _verb << "to" << _request.url() << "with" << QString::fromUtf8(byteData); + qCDebug(l) << "sending" << _verb << "to" << _request.url() << "with" << QString::fromUtf8(byteData); _reply = _net->sendCustomRequest(_request, _verb.toLatin1(), buffer); connect(_reply, &QNetworkReply::finished, @@ -416,7 +416,7 @@ QString JSKitXMLHttpRequest::responseType() const void JSKitXMLHttpRequest::setResponseType(const QString &type) { - logger()->debug() << "response type set to" << type; + qCDebug(l) << "response type set to" << type; _responseType = type; } @@ -436,13 +436,13 @@ QJSValue JSKitXMLHttpRequest::response() const array.setProperty(i, engine->toScriptValue<int>(_response[i])); } arrayBuf.setProperty("_bytes", array); - logger()->debug() << "returning ArrayBuffer of" << _response.size() << "bytes"; + qCDebug(l) << "returning ArrayBuffer of" << _response.size() << "bytes"; } else { - logger()->warn() << "Cannot find proto of ArrayBuffer"; + qCWarning(l) << "Cannot find proto of ArrayBuffer"; } return arrayBuf; } else { - logger()->warn() << "unsupported responseType:" << _responseType; + qCWarning(l) << "unsupported responseType:" << _responseType; return engine->toScriptValue<void*>(0); } } @@ -455,12 +455,12 @@ QString JSKitXMLHttpRequest::responseText() const void JSKitXMLHttpRequest::handleReplyFinished() { if (!_reply) { - logger()->info() << "reply finished too late"; + qCDebug(l) << "reply finished too late"; return; } _response = _reply->readAll(); - logger()->debug() << "reply finished, reply text:" << QString::fromUtf8(_response); + qCDebug(l) << "reply finished, reply text:" << QString::fromUtf8(_response); emit readyStateChanged(); emit statusChanged(); @@ -469,34 +469,34 @@ void JSKitXMLHttpRequest::handleReplyFinished() emit responseTextChanged(); if (_onload.isCallable()) { - logger()->debug() << "going to call onload handler:" << _onload.toString(); + qCDebug(l) << "going to call onload handler:" << _onload.toString(); QJSValue result = _onload.callWithInstance(_mgr->engine()->newQObject(this)); if (result.isError()) { - logger()->warn() << "JS error on onload handler:" << JSKitManager::describeError(result); + qCWarning(l) << "JS error on onload handler:" << JSKitManager::describeError(result); } } else { - logger()->debug() << "No onload set"; + qCDebug(l) << "No onload set"; } } void JSKitXMLHttpRequest::handleReplyError(QNetworkReply::NetworkError code) { if (!_reply) { - logger()->info() << "reply error too late"; + qCDebug(l) << "reply error too late"; return; } - logger()->info() << "reply error" << code; + qCDebug(l) << "reply error" << code; emit readyStateChanged(); emit statusChanged(); emit statusTextChanged(); if (_onerror.isCallable()) { - logger()->debug() << "going to call onerror handler:" << _onload.toString(); + qCDebug(l) << "going to call onerror handler:" << _onload.toString(); QJSValue result = _onerror.callWithInstance(_mgr->engine()->newQObject(this)); if (result.isError()) { - logger()->warn() << "JS error on onerror handler:" << JSKitManager::describeError(result); + qCWarning(l) << "JS error on onerror handler:" << JSKitManager::describeError(result); } } } @@ -504,21 +504,22 @@ void JSKitXMLHttpRequest::handleReplyError(QNetworkReply::NetworkError code) void JSKitXMLHttpRequest::handleAuthenticationRequired(QNetworkReply *reply, QAuthenticator *auth) { if (_reply == reply) { - logger()->debug() << "authentication required"; + qCDebug(l) << "authentication required"; if (!_username.isEmpty() || !_password.isEmpty()) { - logger()->debug() << "using provided authorization:" << _username; + qCDebug(l) << "using provided authorization:" << _username; auth->setUser(_username); auth->setPassword(_password); } else { - logger()->debug() << "no username or password provided"; + qCDebug(l) << "no username or password provided"; } } } JSKitGeolocation::JSKitGeolocation(JSKitManager *mgr) - : QObject(mgr), _mgr(mgr), _source(0), _lastWatchId(0) + : QObject(mgr), l(metaObject()->className()), + _mgr(mgr), _source(0), _lastWatchId(0) { } @@ -539,16 +540,16 @@ void JSKitGeolocation::clearWatch(int watchId) void JSKitGeolocation::handleError(QGeoPositionInfoSource::Error error) { - logger()->warn() << "positioning error: " << error; + qCWarning(l) << "positioning error: " << error; // TODO } void JSKitGeolocation::handlePosition(const QGeoPositionInfo &pos) { - logger()->debug() << "got position at" << pos.timestamp() << "type" << pos.coordinate().type(); + qCDebug(l) << "got position at" << pos.timestamp() << "type" << pos.coordinate().type(); if (_watches.empty()) { - logger()->warn() << "got position update but no one is watching"; + qCWarning(l) << "got position update but no one is watching"; _source->stopUpdates(); // Just in case. return; } @@ -569,10 +570,10 @@ void JSKitGeolocation::handlePosition(const QGeoPositionInfo &pos) void JSKitGeolocation::handleTimeout() { - logger()->info() << "positioning timeout"; + qCDebug(l) << "positioning timeout"; if (_watches.empty()) { - logger()->warn() << "got position timeout but no one is watching"; + qCWarning(l) << "got position timeout but no one is watching"; _source->stopUpdates(); return; } @@ -581,7 +582,7 @@ void JSKitGeolocation::handleTimeout() for (auto it = _watches.begin(); it != _watches.end(); /*no adv*/) { if (it->timer.hasExpired(it->timeout)) { - logger()->info() << "positioning timeout for watch" << it->watchId + qCDebug(l) << "positioning timeout for watch" << it->watchId << ", watch is" << it->timer.elapsed() << "ms old, timeout is" << it->timeout; invokeCallback(it->errorCallback, obj); @@ -603,11 +604,11 @@ void JSKitGeolocation::updateTimeouts() { int once_timeout = -1, updates_timeout = -1; - logger()->debug() << Q_FUNC_INFO; + qCDebug(l) << Q_FUNC_INFO; Q_FOREACH(const Watcher &watcher, _watches) { qint64 rem_timeout = watcher.timeout - watcher.timer.elapsed(); - logger()->debug() << "watch" << watcher.watchId << "rem timeout" << rem_timeout; + qCDebug(l) << "watch" << watcher.watchId << "rem timeout" << rem_timeout; if (rem_timeout >= 0) { // In case it is too large... rem_timeout = qMin<qint64>(rem_timeout, std::numeric_limits<int>::max()); @@ -620,16 +621,16 @@ void JSKitGeolocation::updateTimeouts() } if (updates_timeout >= 0) { - logger()->debug() << "setting location update interval to" << updates_timeout; + qCDebug(l) << "setting location update interval to" << updates_timeout; _source->setUpdateInterval(updates_timeout); _source->startUpdates(); } else { - logger()->debug() << "stopping updates"; + qCDebug(l) << "stopping updates"; _source->stopUpdates(); } if (once_timeout >= 0) { - logger()->debug() << "requesting single location update with timeout" << once_timeout; + qCDebug(l) << "requesting single location update with timeout" << once_timeout; _source->requestUpdate(once_timeout); } } @@ -646,7 +647,7 @@ int JSKitGeolocation::setupWatcher(const QJSValue &successCallback, const QJSVal qlonglong maximumAge = options.value("maximumAge", 0).toLongLong(); - logger()->debug() << "setting up watcher, gps=" << watcher.highAccuracy << "timeout=" << watcher.timeout << "maximumAge=" << maximumAge << "once=" << once; + qCDebug(l) << "setting up watcher, gps=" << watcher.highAccuracy << "timeout=" << watcher.timeout << "maximumAge=" << maximumAge << "once=" << once; if (!_source) { _source = QGeoPositionInfoSource::createDefaultSource(this); @@ -661,7 +662,7 @@ int JSKitGeolocation::setupWatcher(const QJSValue &successCallback, const QJSVal if (maximumAge > 0) { QDateTime threshold = QDateTime::currentDateTime().addMSecs(-qint64(maximumAge)); QGeoPositionInfo pos = _source->lastKnownPosition(watcher.highAccuracy); - logger()->debug() << "got pos timestamp" << pos.timestamp() << " but we want" << threshold; + qCDebug(l) << "got pos timestamp" << pos.timestamp() << " but we want" << threshold; if (pos.isValid() && pos.timestamp() >= threshold) { invokeCallback(watcher.successCallback, buildPositionObject(pos)); if (once) { @@ -678,7 +679,7 @@ int JSKitGeolocation::setupWatcher(const QJSValue &successCallback, const QJSVal watcher.timer.start(); _watches.append(watcher); - logger()->debug() << "added new watch" << watcher.watchId; + qCDebug(l) << "added new watch" << watcher.watchId; QMetaObject::invokeMethod(this, "updateTimeouts", Qt::QueuedConnection); @@ -689,7 +690,7 @@ void JSKitGeolocation::removeWatcher(int watchId) { Watcher watcher; - logger()->debug() << "removing watchId" << watcher.watchId; + qCDebug(l) << "removing watchId" << watcher.watchId; for (int i = 0; i < _watches.size(); i++) { if (_watches[i].watchId == watchId) { @@ -699,7 +700,7 @@ void JSKitGeolocation::removeWatcher(int watchId) } if (watcher.watchId != watchId) { - logger()->warn() << "watchId not found"; + qCWarning(l) << "watchId not found"; return; } @@ -761,12 +762,12 @@ QJSValue JSKitGeolocation::buildPositionErrorObject(PositionError error, const Q void JSKitGeolocation::invokeCallback(QJSValue callback, QJSValue event) { if (callback.isCallable()) { - logger()->debug() << "invoking callback" << callback.toString(); + qCDebug(l) << "invoking callback" << callback.toString(); QJSValue result = callback.call(QJSValueList({event})); if (result.isError()) { - logger()->warn() << "while invoking callback: " << JSKitManager::describeError(result); + qCWarning(l) << "while invoking callback: " << JSKitManager::describeError(result); } } else { - logger()->warn() << "callback is not callable"; + qCWarning(l) << "callback is not callable"; } } diff --git a/daemon/jskitobjects.h b/daemon/jskitobjects.h index 532ce1b..1477fc6 100644 --- a/daemon/jskitobjects.h +++ b/daemon/jskitobjects.h @@ -11,7 +11,7 @@ class JSKitPebble : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit JSKitPebble(const AppInfo &appInfo, JSKitManager *mgr); @@ -44,7 +44,7 @@ private: class JSKitConsole : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit JSKitConsole(JSKitManager *mgr); @@ -84,7 +84,7 @@ private: class JSKitXMLHttpRequest : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_ENUMS(ReadyStates) Q_PROPERTY(QJSValue onload READ onload WRITE setOnload) @@ -168,7 +168,7 @@ class JSKitGeolocation : public QObject { Q_OBJECT Q_ENUMS(PositionError) - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; struct Watcher; diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 32b313f..6498c68 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -6,7 +6,7 @@ #include "watch_adaptor.h" Manager::Manager(Settings *settings, QObject *parent) : - QObject(parent), settings(settings), + QObject(parent), l(metaObject()->className()), settings(settings), proxy(new PebbledProxy(this)), watch(new WatchConnector(this)), dbus(new DBusConnector(this)), @@ -80,7 +80,7 @@ Manager::Manager(Settings *settings, QObject *parent) : notification.setImage("icon-system-bluetooth-device"); if (btDevice.isValid()) { - logger()->debug() << "BT local name:" << btDevice.name(); + qCDebug(l) << "BT local name:" << btDevice.name(); connect(dbus, SIGNAL(pebbleChanged()), SLOT(onPebbleChanged())); dbus->findPebble(); } @@ -92,12 +92,12 @@ Manager::~Manager() void Manager::onSettingChanged(const QString &key) { - logger()->debug() << __FUNCTION__ << key << ":" << settings->property(qPrintable(key)); + qCDebug(l) << __FUNCTION__ << key << ":" << settings->property(qPrintable(key)); } void Manager::onSettingsChanged() { - logger()->warn() << __FUNCTION__ << "Not implemented!"; + qCWarning(l) << __FUNCTION__ << "Not implemented!"; } void Manager::onPebbleChanged() @@ -105,7 +105,7 @@ void Manager::onPebbleChanged() const QVariantMap & pebble = dbus->pebble(); QString name = pebble["Name"].toString(); if (name.isEmpty()) { - logger()->debug() << "Pebble gone"; + qCDebug(l) << "Pebble gone"; } else { watch->deviceConnect(name, pebble["Address"].toString()); } @@ -116,23 +116,23 @@ void Manager::onConnectedChanged() QString message = QString("%1 %2") .arg(watch->name().isEmpty() ? "Pebble" : watch->name()) .arg(watch->isConnected() ? "connected" : "disconnected"); - logger()->debug() << message; + qCDebug(l) << message; if (notification.isPublished()) notification.remove(); notification.setBody(message); if (!notification.publish()) { - logger()->debug() << "Failed publishing notification"; + qCDebug(l) << "Failed publishing notification"; } } void Manager::onActiveVoiceCallChanged() { - logger()->debug() << "Manager::onActiveVoiceCallChanged()"; + qCDebug(l) << "Manager::onActiveVoiceCallChanged()"; QVariant incomingCallNotification = settings->property("incomingCallNotification"); if (incomingCallNotification.isValid() && !incomingCallNotification.toBool()) { - logger()->debug() << "Ignoring ActiveVoiceCallChanged because of setting!"; + qCDebug(l) << "Ignoring ActiveVoiceCallChanged because of setting!"; return; } @@ -148,12 +148,12 @@ void Manager::onActiveVoiceCallStatusChanged() { VoiceCallHandler* handler = voice->activeVoiceCall(); if (!handler) { - logger()->debug() << "ActiveVoiceCall destroyed"; + qCDebug(l) << "ActiveVoiceCall destroyed"; watch->endPhoneCall(); return; } - logger()->debug() << "handlerId:" << handler->handlerId() + qCDebug(l) << "handlerId:" << handler->handlerId() << "providerId:" << handler->providerId() << "status:" << handler->status() << "statusText:" << handler->statusText() @@ -161,28 +161,28 @@ void Manager::onActiveVoiceCallStatusChanged() << "incoming:" << handler->isIncoming(); if (!watch->isConnected()) { - logger()->debug() << "Watch is not connected"; + qCDebug(l) << "Watch is not connected"; return; } switch ((VoiceCallHandler::VoiceCallStatus)handler->status()) { case VoiceCallHandler::STATUS_ALERTING: case VoiceCallHandler::STATUS_DIALING: - logger()->debug() << "Tell outgoing:" << handler->lineId(); + qCDebug(l) << "Tell outgoing:" << handler->lineId(); watch->ring(handler->lineId(), findPersonByNumber(handler->lineId()), false); break; case VoiceCallHandler::STATUS_INCOMING: case VoiceCallHandler::STATUS_WAITING: - logger()->debug() << "Tell incoming:" << handler->lineId(); + qCDebug(l) << "Tell incoming:" << handler->lineId(); watch->ring(handler->lineId(), findPersonByNumber(handler->lineId())); break; case VoiceCallHandler::STATUS_NULL: case VoiceCallHandler::STATUS_DISCONNECTED: - logger()->debug() << "Endphone"; + qCDebug(l) << "Endphone"; watch->endPhoneCall(); break; case VoiceCallHandler::STATUS_ACTIVE: - logger()->debug() << "Startphone"; + qCDebug(l) << "Startphone"; watch->startPhoneCall(); break; case VoiceCallHandler::STATUS_HELD: @@ -208,7 +208,7 @@ QString Manager::findPersonByNumber(QString number) void Manager::onVoiceError(const QString &message) { - logger()->error() << "Error:" << message; + qCCritical(l) << "Error:" << message; } @@ -262,11 +262,11 @@ QString Manager::getCurrentProfile() const QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "get_profile")); if (profile.isValid()) { QString currentProfile = profile.value(); - logger()->debug() << "Got profile" << currentProfile; + qCDebug(l) << "Got profile" << currentProfile; return currentProfile; } - logger()->error() << profile.error().message(); + qCCritical(l) << profile.error().message(); return QString(); } @@ -294,11 +294,11 @@ void Manager::applyProfile() << newProfile); if (res.isValid()) { if (!res.value()) { - logger()->error() << "Unable to set profile" << newProfile; + qCCritical(l) << "Unable to set profile" << newProfile; } } else { - logger()->error() << res.error().message(); + qCCritical(l) << res.error().message(); } } } @@ -309,11 +309,11 @@ void Manager::transliterateMessage(const QString &text) UErrorCode status = U_ZERO_ERROR; transliterator.reset(icu::Transliterator::createInstance(icu::UnicodeString::fromUTF8("Any-Latin; Latin-ASCII"),UTRANS_FORWARD, status)); if (U_FAILURE(status)) { - logger()->warn() << "Error creaing ICU Transliterator \"Any-Latin; Latin-ASCII\":" << u_errorName(status); + qCWarning(l) << "Error creaing ICU Transliterator \"Any-Latin; Latin-ASCII\":" << u_errorName(status); } } if (!transliterator.isNull()) { - logger()->debug() << "String before transliteration:" << text; + qCDebug(l) << "String before transliteration:" << text; icu::UnicodeString uword = icu::UnicodeString::fromUTF8(text.toStdString()); transliterator->transliterate(uword); @@ -322,7 +322,7 @@ void Manager::transliterateMessage(const QString &text) uword.toUTF8String(translited); const_cast<QString&>(text) = QString::fromStdString(translited); - logger()->debug() << "String after transliteration:" << text; + qCDebug(l) << "String after transliteration:" << text; } } @@ -413,14 +413,14 @@ QString PebbledProxy::StartAppConfiguration(const QString &uuid) QDBusConnection conn = connection(); if (manager()->currentAppUuid != uuid) { - logger()->warn() << "Called StartAppConfiguration but the uuid" << uuid << "is not running"; + qCWarning(l) << "Called StartAppConfiguration but the uuid" << uuid << "is not running"; sendErrorReply(msg.interface() + ".Error.AppNotRunning", "The requested app is not currently opened in the watch"); return QString(); } if (!manager()->js->isJSKitAppRunning()) { - logger()->warn() << "Called StartAppConfiguration but the uuid" << uuid << "is not a JS app"; + qCWarning(l) << "Called StartAppConfiguration but the uuid" << uuid << "is not a JS app"; sendErrorReply(msg.interface() + ".Error.JSNotActive", "The requested app is not a PebbleKit JS application"); return QString(); diff --git a/daemon/manager.h b/daemon/manager.h index efe9b82..9a4ed0f 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -20,7 +20,7 @@ #include <QtContacts/QContactManager> #include <QtContacts/QContactDetailFilter> #include <MNotification> -#include <Log4Qt/Logger> +#include <QLoggingCategory> #include <unicode/translit.h> @@ -31,7 +31,7 @@ class PebbledProxy; class Manager : public QObject, protected QDBusContext { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; friend class PebbledProxy; @@ -103,7 +103,7 @@ private slots: class PebbledProxy : public QObject, protected QDBusContext { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_PROPERTY(QString Name READ Name NOTIFY NameChanged) Q_PROPERTY(QString Address READ Address NOTIFY AddressChanged) @@ -116,7 +116,8 @@ class PebbledProxy : public QObject, protected QDBusContext inline QVariantMap pebble() const { return manager()->dbus->pebble(); } public: - inline explicit PebbledProxy(QObject *parent) : QObject(parent) {} + inline explicit PebbledProxy(QObject *parent) + : QObject(parent), l(metaObject()->className()) {} inline QString Name() const { return pebble()["Name"].toString(); } inline QString Address() const { return pebble()["Address"].toString(); } diff --git a/daemon/musicmanager.cpp b/daemon/musicmanager.cpp index d34ae5c..385abbf 100644 --- a/daemon/musicmanager.cpp +++ b/daemon/musicmanager.cpp @@ -3,7 +3,8 @@ #include "musicmanager.h" MusicManager::MusicManager(WatchConnector *watch, QObject *parent) - : QObject(parent), watch(watch), _watcher(new QDBusServiceWatcher(this)) + : QObject(parent), l(metaObject()->className()), + watch(watch), _watcher(new QDBusServiceWatcher(this)) { QDBusConnection bus = QDBusConnection::sessionBus(); QDBusConnectionInterface *bus_iface = bus.interface(); @@ -46,7 +47,7 @@ MusicManager::MusicManager(WatchConnector *watch, QObject *parent) void MusicManager::switchToService(const QString &service) { if (_curService != service) { - logger()->debug() << "switching to mpris service" << service; + qCDebug(l) << "switching to mpris service" << service; _curService = service; if (_curService.isEmpty()) { @@ -66,10 +67,10 @@ void MusicManager::fetchMetadataFromService() call << "org.mpris.MediaPlayer2.Player" << "Metadata"; QDBusReply<QDBusVariant> reply = QDBusConnection::sessionBus().call(call); if (reply.isValid()) { - logger()->debug() << "got mpris metadata from service" << _curService; + qCDebug(l) << "got mpris metadata from service" << _curService; _curMetadata = qdbus_cast<QVariantMap>(reply.value().variant().value<QDBusArgument>()); } else { - logger()->error() << reply.error().message(); + qCWarning(l) << reply.error().message(); } } } @@ -82,7 +83,7 @@ void MusicManager::sendCurrentMprisMetadata() QString album = _curMetadata.value("xesam:album").toString().left(30); QString artist = _curMetadata.value("xesam:artist").toString().left(30); - logger()->debug() << "sending mpris metadata:" << track << album << artist; + qCDebug(l) << "sending mpris metadata:" << track << album << artist; watch->sendMusicNowPlaying(track, album, artist); } @@ -92,7 +93,7 @@ void MusicManager::callMprisMethod(const QString &method) Q_ASSERT(!method.isEmpty()); Q_ASSERT(!_curService.isEmpty()); - logger()->debug() << _curService << "->" << method; + qCDebug(l) << _curService << "->" << method; QDBusConnection bus = QDBusConnection::sessionBus(); QDBusMessage call = QDBusMessage::createMethodCall(_curService, @@ -103,16 +104,16 @@ void MusicManager::callMprisMethod(const QString &method) QDBusError err = bus.call(call); if (err.isValid()) { - logger()->error() << "while calling mpris method on" << _curService << ":" << err.message(); + qCWarning(l) << "while calling mpris method on" << _curService << ":" << err.message(); } } void MusicManager::handleMusicControl(WatchConnector::MusicControl operation) { - logger()->debug() << "operation from watch:" << operation; + qCDebug(l) << "operation from watch:" << operation; if (_curService.isEmpty()) { - logger()->info() << "can't do any music operation, no mpris interface active"; + qCDebug(l) << "can't do any music operation, no mpris interface active"; return; } @@ -148,17 +149,17 @@ void MusicManager::handleMusicControl(WatchConnector::MusicControl operation) else { volume -= 0.1; } - logger()->debug() << "Setting volume" << volume; + qCDebug(l) << "Setting volume" << volume; call = QDBusMessage::createMethodCall(_curService, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Set"); call << "org.mpris.MediaPlayer2.Player" << "Volume" << QVariant::fromValue(QDBusVariant(volume)); QDBusError err = QDBusConnection::sessionBus().call(call); if (err.isValid()) { - logger()->error() << err.message(); + qCWarning(l) << err.message(); } } else { - logger()->error() << volumeReply.error().message(); + qCWarning(l) << volumeReply.error().message(); } } break; @@ -168,7 +169,7 @@ void MusicManager::handleMusicControl(WatchConnector::MusicControl operation) break; default: - logger()->warn() << "Operation" << operation << "not supported"; + qCWarning(l) << "Operation" << operation << "not supported"; break; } } @@ -194,7 +195,7 @@ void MusicManager::handleMprisPropertiesChanged(const QString &interface, const if (changed.contains("Metadata")) { QVariantMap metadata = qdbus_cast<QVariantMap>(changed.value("Metadata").value<QDBusArgument>()); - logger()->debug() << "received new metadata" << metadata; + qCDebug(l) << "received new metadata" << metadata; _curMetadata = metadata; } diff --git a/daemon/musicmanager.h b/daemon/musicmanager.h index 89e5fd7..14aa6fb 100644 --- a/daemon/musicmanager.h +++ b/daemon/musicmanager.h @@ -9,7 +9,7 @@ class MusicManager : public QObject, protected QDBusContext { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit MusicManager(WatchConnector *watch, QObject *parent = 0); diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index 079bdb0..d983539 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -26,7 +26,7 @@ public: }; NotificationManager::NotificationManager(Settings *settings, QObject *parent) - : QObject(parent), d_ptr(new NotificationManagerPrivate(this)), settings(settings) + : QObject(parent), l(metaObject()->className()), d_ptr(new NotificationManagerPrivate(this)), settings(settings) { Q_D(NotificationManager); QDBusConnection::sessionBus().registerObject("/org/freedesktop/Notifications", this, QDBusConnection::ExportAllSlots); @@ -117,8 +117,8 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons return 0; } - logger()->debug() << Q_FUNC_INFO << "Got notification via dbus from" << this->getCleanAppName(app_name); - logger()->debug() << hints; + qCDebug(l) << Q_FUNC_INFO << "Got notification via dbus from" << this->getCleanAppName(app_name); + qCDebug(l) << hints; // Avoid sending a reply for this method call, since we've received it because we're eavesdropping. // The actual target of the method call will send the proper reply. @@ -128,7 +128,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons if (app_name == "messageserver5") { QVariant notificationsEmails = settings->property("notificationsEmails"); if (!notificationsEmails.isValid() || !notificationsEmails.toBool()) { - logger()->debug() << "Ignoring email notification because of setting!"; + qCDebug(l) << "Ignoring email notification because of setting!"; return 0; } @@ -151,13 +151,13 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons if (category == "x-nemo.call.missed") { QVariant notificationsMissedCall = settings->property("notificationsMissedCall"); if (notificationsMissedCall.isValid() && !notificationsMissedCall.toBool()) { - logger()->debug() << "Ignoring MissedCall notification because of setting!"; + qCDebug(l) << "Ignoring MissedCall notification because of setting!"; return 0; } } else { QVariant notificationsCommhistoryd = settings->property("notificationsCommhistoryd"); if (notificationsCommhistoryd.isValid() && !notificationsCommhistoryd.toBool()) { - logger()->debug() << "Ignoring commhistoryd notification because of setting!"; + qCDebug(l) << "Ignoring commhistoryd notification because of setting!"; return 0; } } @@ -168,7 +168,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons } else if (app_name == "harbour-mitakuuluu2-server") { QVariant notificationsMitakuuluu = settings->property("notificationsMitakuuluu"); if (notificationsMitakuuluu.isValid() && !notificationsMitakuuluu.toBool()) { - logger()->debug() << "Ignoring mitakuuluu notification because of setting!"; + qCDebug(l) << "Ignoring mitakuuluu notification because of setting!"; return 0; } @@ -178,7 +178,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons } else if (app_name == "twitter-notifications-client") { QVariant notificationsTwitter = settings->property("notificationsTwitter"); if (notificationsTwitter.isValid() && !notificationsTwitter.toBool()) { - logger()->debug() << "Ignoring twitter notification because of setting!"; + qCDebug(l) << "Ignoring twitter notification because of setting!"; return 0; } @@ -193,17 +193,17 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons QStringHash categoryParams = this->getCategoryParams(category); int prio = categoryParams.value("x-nemo-priority", "0").toInt(); - logger()->debug() << "MSG Prio:" << prio; + qCDebug(l) << "MSG Prio:" << prio; QVariant notificationsAll = settings->property("notificationsAll"); if ((!notificationsAll.isValid() || !notificationsAll.toBool()) && prio <= 10) { - logger()->debug() << "Ignoring notification because of setting! (all)"; + qCDebug(l) << "Ignoring notification because of setting! (all)"; return 0; } QVariant notificationsOther = settings->property("notificationsOther"); if (notificationsOther.isValid() && !notificationsOther.toBool() && prio < 90) { - logger()->debug() << "Ignoring notification because of setting! (other)"; + qCDebug(l) << "Ignoring notification because of setting! (other)"; return 0; } @@ -222,7 +222,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons //Never send empty data and subject if (data.isEmpty() && subject.isEmpty()) { - logger()->warn() << Q_FUNC_INFO << "Empty subject and data in dbus app:" << app_name; + qCWarning(l) << Q_FUNC_INFO << "Empty subject and data in dbus app:" << app_name; return 0; } diff --git a/daemon/notificationmanager.h b/daemon/notificationmanager.h index 0432f00..037ff07 100644 --- a/daemon/notificationmanager.h +++ b/daemon/notificationmanager.h @@ -3,7 +3,7 @@ #include <QObject> #include <QtDBus/QDBusContext> -#include <Log4Qt/Logger> +#include <QLoggingCategory> #include "settings.h" #include <QDBusInterface> @@ -14,7 +14,7 @@ typedef QHash<QString, QString> QStringHash; class NotificationManager : public QObject, protected QDBusContext { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Notifications") Q_PROPERTY(QDBusInterface* interface READ interface) diff --git a/daemon/packer.cpp b/daemon/packer.cpp index df32a4a..abbb873 100644 --- a/daemon/packer.cpp +++ b/daemon/packer.cpp @@ -1,6 +1,8 @@ #include "packer.h" #include "watchconnector.h" +QLoggingCategory Packer::l("Packer"); + void Packer::writeBytes(int n, const QByteArray &b) { if (b.size() > n) { @@ -29,7 +31,7 @@ void Packer::writeDict(const QMap<int, QVariant> &d) { int size = d.size(); if (size > 0xFF) { - logger()->warn() << "Dictionary is too large to encode"; + qCWarning(l) << "Dictionary is too large to encode"; writeLE<quint8>(0); return; } @@ -110,7 +112,7 @@ void Packer::writeDict(const QMap<int, QVariant> &d) } default: - logger()->warn() << "Unknown dict item type:" << it.value().typeName(); + qCWarning(l) << "Unknown dict item type:" << it.value().typeName(); /* Fallthrough */ case QMetaType::QString: case QMetaType::QUrl: diff --git a/daemon/packer.h b/daemon/packer.h index ceb6593..fbf5f4b 100644 --- a/daemon/packer.h +++ b/daemon/packer.h @@ -6,11 +6,11 @@ #include <QString> #include <QUuid> #include <QVariantMap> -#include <Log4Qt/Logger> +#include <QLoggingCategory> class Packer { - LOG4QT_DECLARE_STATIC_LOGGER(logger, Packer) + static QLoggingCategory l; public: Packer(QByteArray *buf); diff --git a/daemon/unpacker.cpp b/daemon/unpacker.cpp index e904db8..1f1d564 100644 --- a/daemon/unpacker.cpp +++ b/daemon/unpacker.cpp @@ -1,6 +1,8 @@ #include "unpacker.h" #include "watchconnector.h" +QLoggingCategory Unpacker::l("Unpacker"); + QByteArray Unpacker::readBytes(int n) { if (checkBad(n)) return QByteArray(); diff --git a/daemon/unpacker.h b/daemon/unpacker.h index 000c3e8..46e6d57 100644 --- a/daemon/unpacker.h +++ b/daemon/unpacker.h @@ -6,11 +6,11 @@ #include <QString> #include <QUuid> #include <QVariantMap> -#include <Log4Qt/Logger> +#include <QLoggingCategory> class Unpacker { - LOG4QT_DECLARE_STATIC_LOGGER(logger, Unpacker) + static QLoggingCategory l; public: Unpacker(const QByteArray &data); diff --git a/daemon/uploadmanager.cpp b/daemon/uploadmanager.cpp index 5976fe6..b379880 100644 --- a/daemon/uploadmanager.cpp +++ b/daemon/uploadmanager.cpp @@ -7,12 +7,13 @@ static const int CHUNK_SIZE = 2000; using std::function; UploadManager::UploadManager(WatchConnector *watch, QObject *parent) : - QObject(parent), watch(watch), _lastUploadId(0), _state(StateNotStarted) + QObject(parent), l(metaObject()->className()), watch(watch), + _lastUploadId(0), _state(StateNotStarted) { watch->setEndpointHandler(WatchConnector::watchPUTBYTES, [this](const QByteArray &msg) { if (_pending.empty()) { - logger()->warn() << "putbytes message, but queue is empty!"; + qCWarning(l) << "putbytes message, but queue is empty!"; return false; } handleMessage(msg); @@ -40,7 +41,7 @@ uint UploadManager::upload(WatchConnector::UploadType type, int index, const QSt upload.progressCallback = progressCallback; if (upload.remaining <= 0) { - logger()->warn() << "upload is empty"; + qCWarning(l) << "upload is empty"; if (errorCallback) { errorCallback(-1); return -1; @@ -75,13 +76,13 @@ uint UploadManager::uploadFile(const QString &filename, QIODevice *device, Succe void UploadManager::cancel(uint id, int code) { if (_pending.empty()) { - logger()->warn() << "cannot cancel, empty queue"; + qCWarning(l) << "cannot cancel, empty queue"; return; } if (id == _pending.head().id) { PendingUpload upload = _pending.dequeue(); - logger()->debug() << "aborting current upload" << id << "(code:" << code << ")"; + qCDebug(l) << "aborting current upload" << id << "(code:" << code << ")"; if (_state != StateNotStarted && _state != StateWaitForToken && _state != StateComplete) { QByteArray msg; @@ -89,7 +90,7 @@ void UploadManager::cancel(uint id, int code) p.write<quint8>(WatchConnector::putbytesABORT); p.write<quint32>(_token); - logger()->debug() << "sending abort for upload" << id; + qCDebug(l) << "sending abort for upload" << id; watch->sendMessage(WatchConnector::watchPUTBYTES, msg); } @@ -107,7 +108,7 @@ void UploadManager::cancel(uint id, int code) } else { for (int i = 1; i < _pending.size(); ++i) { if (_pending[i].id == id) { - logger()->debug() << "cancelling upload" << id << "(code:" << code << ")"; + qCDebug(l) << "cancelling upload" << id << "(code:" << code << ")"; if (_pending[i].errorCallback) { _pending[i].errorCallback(code); } @@ -115,7 +116,7 @@ void UploadManager::cancel(uint id, int code) return; } } - logger()->warn() << "cannot cancel, id" << id << "not found"; + qCWarning(l) << "cannot cancel, id" << id << "not found"; } } @@ -135,7 +136,7 @@ void UploadManager::startNextUpload() p.writeCString(upload.filename); } - logger()->debug() << "starting new upload, size:" << upload.remaining << ", type:" << upload.type << ", slot:" << upload.index; + qCDebug(l) << "starting new upload, size:" << upload.remaining << ", type:" << upload.type << ", slot:" << upload.index; _state = StateWaitForToken; watch->sendMessage(WatchConnector::watchPUTBYTES, msg); @@ -150,7 +151,7 @@ void UploadManager::handleMessage(const QByteArray &msg) int status = u.read<quint8>(); if (u.bad() || status != 1) { - logger()->warn() << "upload" << upload.id << "got error code=" << status; + qCWarning(l) << "upload" << upload.id << "got error code=" << status; cancel(upload.id, status); return; } @@ -158,14 +159,14 @@ void UploadManager::handleMessage(const QByteArray &msg) quint32 recv_token = u.read<quint32>(); if (u.bad()) { - logger()->warn() << "upload" << upload.id << ": could not read the token"; + qCWarning(l) << "upload" << upload.id << ": could not read the token"; cancel(upload.id, -1); return; } if (_state != StateNotStarted && _state != StateWaitForToken && _state != StateComplete) { if (recv_token != _token) { - logger()->warn() << "upload" << upload.id << ": invalid token"; + qCWarning(l) << "upload" << upload.id << ": invalid token"; cancel(upload.id, -1); return; } @@ -173,16 +174,16 @@ void UploadManager::handleMessage(const QByteArray &msg) switch (_state) { case StateNotStarted: - logger()->warn() << "got packet when upload is not started"; + qCWarning(l) << "got packet when upload is not started"; break; case StateWaitForToken: - logger()->debug() << "token received"; + qCDebug(l) << "token received"; _token = recv_token; _state = StateInProgress; /* fallthrough */ case StateInProgress: - logger()->debug() << "moving to the next chunk"; + qCDebug(l) << "moving to the next chunk"; if (upload.progressCallback) { // Report that the previous chunk has been succesfully uploaded upload.progressCallback(1.0 - (qreal(upload.remaining) / upload.size)); @@ -193,7 +194,7 @@ void UploadManager::handleMessage(const QByteArray &msg) return; } } else { - logger()->debug() << "no additional chunks, commit"; + qCDebug(l) << "no additional chunks, commit"; _state = StateCommit; if (!commit(upload)) { cancel(upload.id, -1); @@ -202,7 +203,7 @@ void UploadManager::handleMessage(const QByteArray &msg) } break; case StateCommit: - logger()->debug() << "commited succesfully"; + qCDebug(l) << "commited succesfully"; if (upload.progressCallback) { // Report that all chunks have been succesfully uploaded upload.progressCallback(1.0); @@ -214,7 +215,7 @@ void UploadManager::handleMessage(const QByteArray &msg) } break; case StateComplete: - logger()->debug() << "upload" << upload.id << "succesful, invoking callback"; + qCDebug(l) << "upload" << upload.id << "succesful, invoking callback"; if (upload.successCallback) { upload.successCallback(); } @@ -226,7 +227,7 @@ void UploadManager::handleMessage(const QByteArray &msg) } break; default: - logger()->warn() << "received message in wrong state"; + qCWarning(l) << "received message in wrong state"; break; } } @@ -237,7 +238,7 @@ bool UploadManager::uploadNextChunk(PendingUpload &upload) if (upload.remaining < CHUNK_SIZE && chunk.size() < upload.remaining) { // Short read! - logger()->warn() << "short read during upload" << upload.id; + qCWarning(l) << "short read during upload" << upload.id; return false; } @@ -251,14 +252,14 @@ bool UploadManager::uploadNextChunk(PendingUpload &upload) p.write<quint32>(chunk.size()); msg.append(chunk); - logger()->debug() << "sending a chunk of" << chunk.size() << "bytes"; + qCDebug(l) << "sending a chunk of" << chunk.size() << "bytes"; watch->sendMessage(WatchConnector::watchPUTBYTES, msg); upload.remaining -= chunk.size(); upload.crc.addData(chunk); - logger()->debug() << "remaining" << upload.remaining << "/" << upload.size << "bytes"; + qCDebug(l) << "remaining" << upload.remaining << "/" << upload.size << "bytes"; return true; } @@ -274,7 +275,7 @@ bool UploadManager::commit(PendingUpload &upload) p.write<quint32>(_token); p.write<quint32>(upload.crc.result()); - logger()->debug() << "commiting upload" << upload.id + qCDebug(l) << "commiting upload" << upload.id << "with crc" << qPrintable(QString("0x%1").arg(upload.crc.result(), 0, 16)); watch->sendMessage(WatchConnector::watchPUTBYTES, msg); @@ -291,7 +292,7 @@ bool UploadManager::complete(PendingUpload &upload) p.write<quint8>(WatchConnector::putbytesCOMPLETE); p.write<quint32>(_token); - logger()->debug() << "completing upload" << upload.id; + qCDebug(l) << "completing upload" << upload.id; watch->sendMessage(WatchConnector::watchPUTBYTES, msg); diff --git a/daemon/uploadmanager.h b/daemon/uploadmanager.h index 45453b6..1980f96 100644 --- a/daemon/uploadmanager.h +++ b/daemon/uploadmanager.h @@ -9,7 +9,7 @@ class UploadManager : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; public: explicit UploadManager(WatchConnector *watch, QObject *parent = 0); diff --git a/daemon/voicecallhandler.cpp b/daemon/voicecallhandler.cpp index 8b638b8..cce1792 100644 --- a/daemon/voicecallhandler.cpp +++ b/daemon/voicecallhandler.cpp @@ -43,10 +43,10 @@ public: Constructs a new proxy interface for the provided voice call handlerId. */ VoiceCallHandler::VoiceCallHandler(const QString &handlerId, QObject *parent) - : QObject(parent), d_ptr(new VoiceCallHandlerPrivate(this, handlerId)) + : QObject(parent), l(metaObject()->className()), d_ptr(new VoiceCallHandlerPrivate(this, handlerId)) { Q_D(VoiceCallHandler); - logger()->debug() << QString("Creating D-Bus interface to: ") + handlerId; + qCDebug(l) << QString("Creating D-Bus interface to: ") + handlerId; d->interface = new QDBusInterface("org.nemomobile.voicecall", "/calls/" + handlerId, "org.nemomobile.voicecall.VoiceCall", @@ -89,7 +89,7 @@ void VoiceCallHandler::initialize(bool notifyError) } } else { - logger()->error() << d->interface->lastError().name() << d->interface->lastError().message(); + qCCritical(l) << d->interface->lastError().name() << d->interface->lastError().message(); } } @@ -103,7 +103,7 @@ bool VoiceCallHandler::getProperties() QDBusReply<QVariantMap> reply = props.call("GetAll", d->interface->interface()); if (reply.isValid()) { QVariantMap props = reply.value(); - logger()->debug() << props; + qCDebug(l) << props; d->providerId = props["providerId"].toString(); d->duration = props["duration"].toInt(); d->status = props["status"].toInt(); @@ -116,7 +116,7 @@ bool VoiceCallHandler::getProperties() return true; } else { - logger()->error() << "Failed to get VoiceCall properties from VCM D-Bus service."; + qCCritical(l) << "Failed to get VoiceCall properties from VCM D-Bus service."; return false; } } @@ -124,7 +124,7 @@ bool VoiceCallHandler::getProperties() void VoiceCallHandler::onDurationChanged(int duration) { Q_D(VoiceCallHandler); - //logger()->debug() <<"onDurationChanged"<<duration; + //qCDebug(l) <<"onDurationChanged"<<duration; d->duration = duration; emit durationChanged(); } @@ -132,7 +132,7 @@ void VoiceCallHandler::onDurationChanged(int duration) void VoiceCallHandler::onStatusChanged(int status, QString statusText) { Q_D(VoiceCallHandler); - logger()->debug() <<"onStatusChanged" << status << statusText; + qCDebug(l) <<"onStatusChanged" << status << statusText; d->status = status; d->statusText = statusText; // we still fetch all properties to be sure all properties are present. @@ -143,7 +143,7 @@ void VoiceCallHandler::onStatusChanged(int status, QString statusText) void VoiceCallHandler::onLineIdChanged(QString lineId) { Q_D(VoiceCallHandler); - logger()->debug() << "onLineIdChanged" << lineId; + qCDebug(l) << "onLineIdChanged" << lineId; d->lineId = lineId; emit lineIdChanged(); } @@ -151,7 +151,7 @@ void VoiceCallHandler::onLineIdChanged(QString lineId) void VoiceCallHandler::onStartedAtChanged(const QDateTime &startedAt) { Q_D(VoiceCallHandler); - logger()->debug() << "onStartedAtChanged" << startedAt; + qCDebug(l) << "onStartedAtChanged" << startedAt; d->startedAt = d->interface->property("startedAt").toDateTime(); emit startedAtChanged(); } @@ -159,7 +159,7 @@ void VoiceCallHandler::onStartedAtChanged(const QDateTime &startedAt) void VoiceCallHandler::onEmergencyChanged(bool isEmergency) { Q_D(VoiceCallHandler); - logger()->debug() << "onEmergencyChanged" << isEmergency; + qCDebug(l) << "onEmergencyChanged" << isEmergency; d->emergency = isEmergency; emit emergencyChanged(); } @@ -167,7 +167,7 @@ void VoiceCallHandler::onEmergencyChanged(bool isEmergency) void VoiceCallHandler::onMultipartyChanged(bool isMultiparty) { Q_D(VoiceCallHandler); - logger()->debug() << "onMultipartyChanged" << isMultiparty; + qCDebug(l) << "onMultipartyChanged" << isMultiparty; d->multiparty = isMultiparty; emit multipartyChanged(); } @@ -175,7 +175,7 @@ void VoiceCallHandler::onMultipartyChanged(bool isMultiparty) void VoiceCallHandler::onForwardedChanged(bool isForwarded) { Q_D(VoiceCallHandler); - logger()->debug() << "onForwardedChanged" << isForwarded; + qCDebug(l) << "onForwardedChanged" << isForwarded; d->forwarded = isForwarded; emit forwardedChanged(); } @@ -341,10 +341,10 @@ void VoiceCallHandler::onPendingCallFinished(QDBusPendingCallWatcher *watcher) QDBusPendingReply<bool> reply = *watcher; if (reply.isError()) { - logger()->error() << QString::fromLatin1("Received error reply for member: %1 (%2)").arg(reply.reply().member()).arg(reply.error().message()); + qCCritical(l) << QString::fromLatin1("Received error reply for member: %1 (%2)").arg(reply.reply().member()).arg(reply.error().message()); emit this->error(reply.error().message()); watcher->deleteLater(); } else { - logger()->debug() << QString::fromLatin1("Received successful reply for member: %1").arg(reply.reply().member()); + qCDebug(l) << QString::fromLatin1("Received successful reply for member: %1").arg(reply.reply().member()); } } diff --git a/daemon/voicecallhandler.h b/daemon/voicecallhandler.h index f7fbb8b..fb20ac7 100644 --- a/daemon/voicecallhandler.h +++ b/daemon/voicecallhandler.h @@ -4,12 +4,12 @@ #include <QObject> #include <QDateTime> #include <QDBusPendingCallWatcher> -#include <Log4Qt/Logger> +#include <QLoggingCategory> class VoiceCallHandler : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_ENUMS(VoiceCallStatus) diff --git a/daemon/voicecallmanager.cpp b/daemon/voicecallmanager.cpp index 9fd4339..afb3629 100644 --- a/daemon/voicecallmanager.cpp +++ b/daemon/voicecallmanager.cpp @@ -30,7 +30,7 @@ public: }; VoiceCallManager::VoiceCallManager(Settings *settings, QObject *parent) - : QObject(parent), d_ptr(new VoiceCallManagerPrivate(this)), settings(settings) + : QObject(parent), l(metaObject()->className()), d_ptr(new VoiceCallManagerPrivate(this)), settings(settings) { this->initialize(); } @@ -98,7 +98,7 @@ QString VoiceCallManager::defaultProviderId() const { Q_D(const VoiceCallManager); if(d->providers.count() == 0) { - logger()->debug() << Q_FUNC_INFO << "No provider added"; + qCDebug(l) << Q_FUNC_INFO << "No provider added"; return QString::null; } @@ -295,7 +295,7 @@ void VoiceCallManager::onPendingCallFinished(QDBusPendingCallWatcher *watcher) if (reply.isError()) { emit this->error(reply.error().message()); } else { - logger()->debug() << QString("Received successful reply for member: ") + reply.reply().member(); + qCDebug(l) << QString("Received successful reply for member: ") + reply.reply().member(); } watcher->deleteLater(); @@ -308,7 +308,7 @@ void VoiceCallManager::onPendingSilenceFinished(QDBusPendingCallWatcher *watcher if (reply.isError()) { emit this->error(reply.error().message()); } else { - logger()->debug() << QString("Received successful reply for member: ") + reply.reply().member(); + qCDebug(l) << QString("Received successful reply for member: ") + reply.reply().member(); } watcher->deleteLater(); diff --git a/daemon/voicecallmanager.h b/daemon/voicecallmanager.h index 5c21269..ec51230 100644 --- a/daemon/voicecallmanager.h +++ b/daemon/voicecallmanager.h @@ -7,7 +7,7 @@ #include <QObject> #include <QDBusInterface> #include <QDBusPendingCallWatcher> -#include <Log4Qt/Logger> +#include <QLoggingCategory> class VoiceCallProviderData { @@ -28,7 +28,7 @@ typedef QList<VoiceCallHandler*> VoiceCallHandlerList; class VoiceCallManager : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_PROPERTY(QDBusInterface* interface READ interface) diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index 27a5511..ef032f7 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -8,7 +8,7 @@ static const int RECONNECT_TIMEOUT = 500; //ms static const bool PROTOCOL_DEBUG = false; WatchConnector::WatchConnector(QObject *parent) : - QObject(parent), socket(nullptr), is_connected(false) + QObject(parent), l(metaObject()->className()), socket(nullptr), is_connected(false) { reconnectTimer.setSingleShot(true); connect(&reconnectTimer, SIGNAL(timeout()), SLOT(reconnect())); @@ -38,18 +38,18 @@ WatchConnector::WatchConnector(QObject *parent) : QByteArray address = u.readBytes(6); if (u.bad()) { - logger()->warn() << "short read while reading firmware version"; + qCWarning(l) << "short read while reading firmware version"; } - logger()->debug() << "got version information" - << version << version_string << commit - << is_recovery << hw_platform << metadata_version; - logger()->debug() << "recovery version information" - << safe_version << safe_version_string << safe_commit - << safe_is_recovery << safe_hw_platform << safe_metadata_version; - logger()->debug() << "hardware information" << bootLoaderTimestamp << hardwareRevision; - logger()->debug() << "serial number" << serialNumber.left(3) << "..."; - logger()->debug() << "bt address" << address.toHex(); + qCDebug(l) << "got version information" + << version << version_string << commit + << is_recovery << hw_platform << metadata_version; + qCDebug(l) << "recovery version information" + << safe_version << safe_version_string << safe_commit + << safe_is_recovery << safe_hw_platform << safe_metadata_version; + qCDebug(l) << "hardware information" << bootLoaderTimestamp << hardwareRevision; + qCDebug(l) << "serial number" << serialNumber.left(3) << "..."; + qCDebug(l) << "bt address" << address.toHex(); this->_serialNumber = serialNumber; @@ -65,10 +65,10 @@ void WatchConnector::deviceDiscovered(const QBluetoothDeviceInfo &device) { //FIXME TODO: Configurable if (device.name().startsWith("Pebble")) { - logger()->debug() << "Found Pebble:" << device.name() << '(' << device.address().toString() << ')'; + qCDebug(l) << "Found Pebble:" << device.name() << '(' << device.address().toString() << ')'; handleWatch(device.name(), device.address().toString()); } else { - logger()->debug() << "Found other device:" << device.name() << '(' << device.address().toString() << ')'; + qCDebug(l) << "Found other device:" << device.name() << '(' << device.address().toString() << ')'; } } @@ -79,7 +79,7 @@ void WatchConnector::deviceConnect(const QString &name, const QString &address) void WatchConnector::reconnect() { - logger()->debug() << "reconnect" << _last_name; + qCDebug(l) << "reconnect" << _last_name; if (!_last_name.isEmpty() && !_last_address.isEmpty()) { deviceConnect(_last_name, _last_address); } @@ -87,16 +87,16 @@ void WatchConnector::reconnect() void WatchConnector::disconnect() { - logger()->debug() << "disconnecting"; + qCDebug(l) << "disconnecting"; socket->close(); socket->deleteLater(); reconnectTimer.stop(); - logger()->debug() << "stopped reconnect timer"; + qCDebug(l) << "stopped reconnect timer"; } void WatchConnector::handleWatch(const QString &name, const QString &address) { - logger()->debug() << "handleWatch" << name << address; + qCDebug(l) << "handleWatch" << name << address; reconnectTimer.stop(); if (socket != nullptr && socket->isOpen()) { socket->close(); @@ -113,12 +113,8 @@ void WatchConnector::handleWatch(const QString &name, const QString &address) _serialNumber.clear(); } - logger()->debug() << "Creating socket"; -#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) - socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket); -#else + qCDebug(l) << "Creating socket"; socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol); -#endif connect(socket, SIGNAL(readyRead()), SLOT(onReadSocket())); connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(onBytesWritten(qint64))); connect(socket, SIGNAL(connected()), SLOT(onConnected())); @@ -181,8 +177,8 @@ bool WatchConnector::dispatchMessage(uint endpoint, const QByteArray &data) } } - logger()->info() << "message to endpoint" << decodeEndpoint(endpoint) << "was not dispatched"; - logger()->debug() << data.toHex(); + qCDebug(l) << "message to endpoint" << decodeEndpoint(endpoint) << "was not dispatched"; + qCDebug(l) << data.toHex(); return false; } @@ -190,7 +186,7 @@ void WatchConnector::onReadSocket() { static const int header_length = 4; - logger()->debug() << "readyRead bytesAvailable =" << socket->bytesAvailable(); + qCDebug(l) << "readyRead bytesAvailable =" << socket->bytesAvailable(); QBluetoothSocket *socket = qobject_cast<QBluetoothSocket *>(sender()); Q_ASSERT(socket && socket == this->socket); @@ -207,19 +203,19 @@ void WatchConnector::onReadSocket() // Sanity checks on the message_length if (message_length == 0) { - logger()->warn() << "received empty message"; + qCWarning(l) << "received empty message"; socket->read(header_length); // skip this header continue; // check if there are additional headers. } else if (message_length > 8 * 1024) { // Protocol does not allow messages more than 8K long, seemingly. - logger()->warn() << "received message size too long: " << message_length; + qCWarning(l) << "received message size too long: " << message_length; socket->readAll(); // drop entire input buffer return; } // Now wait for the entire message if (socket->bytesAvailable() < header_length + message_length) { - logger()->debug() << "incomplete msg body in read buffer"; + qCDebug(l) << "incomplete msg body in read buffer"; return; // try again once more data comes in } @@ -230,8 +226,8 @@ void WatchConnector::onReadSocket() // Now read the rest of the message QByteArray data = socket->read(message_length); - logger()->debug() << "received message of length" << message_length << "to endpoint" << decodeEndpoint(endpoint); - if (PROTOCOL_DEBUG) logger()->trace() << data.toHex(); + qCDebug(l) << "received message of length" << message_length << "to endpoint" << decodeEndpoint(endpoint); + if (PROTOCOL_DEBUG) qCDebug(l) << data.toHex(); dispatchMessage(endpoint, data); } @@ -239,14 +235,14 @@ void WatchConnector::onReadSocket() void WatchConnector::onConnected() { - logger()->debug() << "Connected!"; + qCDebug(l) << "Connected!"; bool was_connected = is_connected; is_connected = true; reconnectTimer.stop(); reconnectTimer.setInterval(0); if (!was_connected) { if (!writeData.isEmpty()) { - logger()->info() << "Found" << writeData.length() << "bytes in write buffer - resending"; + qCDebug(l) << "Found" << writeData.length() << "bytes in write buffer - resending"; sendData(writeData); } if (_serialNumber.isEmpty()) { @@ -259,7 +255,7 @@ void WatchConnector::onConnected() void WatchConnector::onDisconnected() { - logger()->debug() << "Disconnected!"; + qCDebug(l) << "Disconnected!"; bool was_connected = is_connected; is_connected = false; @@ -279,15 +275,15 @@ void WatchConnector::onDisconnected() reconnectTimer.setInterval(reconnectTimer.interval() + RECONNECT_TIMEOUT); } reconnectTimer.start(); - logger()->debug() << "will reconnect in" << reconnectTimer.interval() << "ms"; + qCDebug(l) << "will reconnect in" << reconnectTimer.interval() << "ms"; } void WatchConnector::onError(QBluetoothSocket::SocketError error) { if (error == QBluetoothSocket::UnknownSocketError) { - logger()->info() << error << socket->errorString(); + qCDebug(l) << error << socket->errorString(); } else { - logger()->error() << "error connecting Pebble:" << error << socket->errorString(); + qCCritical(l) << "error connecting Pebble:" << error << socket->errorString(); } } @@ -295,11 +291,11 @@ void WatchConnector::sendData(const QByteArray &data) { writeData.append(data); if (socket == nullptr) { - logger()->debug() << "no socket - reconnecting"; + qCDebug(l) << "no socket - reconnecting"; reconnect(); } else if (is_connected) { - logger()->debug() << "writing" << data.length() << "bytes to socket"; - if (PROTOCOL_DEBUG) logger()->trace() << data.toHex(); + qCDebug(l) << "writing" << data.length() << "bytes to socket"; + if (PROTOCOL_DEBUG) qCDebug(l) << data.toHex(); socket->write(data); } } @@ -307,12 +303,12 @@ void WatchConnector::sendData(const QByteArray &data) void WatchConnector::onBytesWritten(qint64 bytes) { writeData.remove(0, bytes); - logger()->debug() << "socket written" << bytes << "bytes," << writeData.length() << "left"; + qCDebug(l) << "socket written" << bytes << "bytes," << writeData.length() << "left"; } void WatchConnector::sendMessage(uint endpoint, const QByteArray &data, const EndpointHandlerFunc &callback) { - logger()->debug() << "sending message to endpoint" << decodeEndpoint(endpoint); + qCDebug(l) << "sending message to endpoint" << decodeEndpoint(endpoint); QByteArray msg; // First send the length diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h index 45fd3c7..6c28e88 100644 --- a/daemon/watchconnector.h +++ b/daemon/watchconnector.h @@ -38,12 +38,12 @@ #include <QBluetoothDeviceInfo> #include <QBluetoothSocket> #include <QBluetoothServiceInfo> -#include <Log4Qt/Logger> +#include <QLoggingCategory> class WatchConnector : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_ENUMS(Endpoint) diff --git a/log4qt-debug.conf b/log4qt-debug.conf deleted file mode 100644 index 1baed5d..0000000 --- a/log4qt-debug.conf +++ /dev/null @@ -1,13 +0,0 @@ -log4j.rootLogger=TRACE, consolelog, syslog - -log4j.appender.consolelog=org.apache.log4j.ColorConsoleAppender -log4j.appender.consolelog.layout=org.apache.log4j.SimpleTimeLayout - -log4j.appender.syslog=org.apache.log4j.SystemLogAppender -log4j.appender.syslog.layout=org.apache.log4j.SimpleLayout -log4j.appender.syslog.serviceName=journalctl -log4j.appender.syslog.threshold=ERROR - -log4j.appender.filelog=org.apache.log4j.DailyRollingFileAppender -log4j.appender.filelog.layout=org.apache.log4j.SimpleTimeLayout -log4j.appender.filelog.file=/tmp/pebble.log diff --git a/log4qt-release.conf b/log4qt-release.conf deleted file mode 100644 index 9934a60..0000000 --- a/log4qt-release.conf +++ /dev/null @@ -1,13 +0,0 @@ -log4j.rootLogger=INFO, consolelog, syslog - -log4j.appender.consolelog=org.apache.log4j.ColorConsoleAppender -log4j.appender.consolelog.layout=org.apache.log4j.SimpleTimeLayout - -log4j.appender.syslog=org.apache.log4j.SystemLogAppender -log4j.appender.syslog.layout=org.apache.log4j.SimpleLayout -log4j.appender.syslog.serviceName=journalctl -log4j.appender.syslog.threshold=ERROR - -log4j.appender.filelog=org.apache.log4j.DailyRollingFileAppender -log4j.appender.filelog.layout=org.apache.log4j.SimpleTimeLayout -log4j.appender.filelog.file=/tmp/pebble.log diff --git a/rpm/pebble.changes b/rpm/pebble.changes index 23fbf57..8d64ff9 100644 --- a/rpm/pebble.changes +++ b/rpm/pebble.changes @@ -1,3 +1,7 @@ +* Tue Dec 23 2014 Tomasz Sterna <tomek@xiaoka.com> 0.13 +- Update for Qt 5.2 +- Logging using Qt logging categories + * Tue Sep 30 2014 Tomasz Sterna <tomek@xiaoka.com> 0.12 - Do not use invoker to run pebbled @@ -36,7 +40,7 @@ * Fri Jul 18 2014 Tomasz Sterna <tomek@xiaoka.com> 0.6 - Music Control via MPRIS -* Sun Jul 13 2014 Tomasz Sterna <tomek@xiaoka.com> 0.6 +* Sun Jul 13 2014 Tomasz Sterna <tomek@xiaoka.com> 0.5 - Fixed incoming call notification - support for PHONE_VERSION endpoint diff --git a/rpm/pebble.spec b/rpm/pebble.spec index 02cbe6c..bd86a5c 100644 --- a/rpm/pebble.spec +++ b/rpm/pebble.spec @@ -13,7 +13,7 @@ Name: pebble %{!?qtc_make:%define qtc_make make} %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Support for Pebble watch in SailfishOS -Version: 0.12.1c +Version: 0.13.js1 Release: 1 Group: Qt/Qt License: GPL3 @@ -31,7 +31,6 @@ BuildRequires: pkgconfig(Qt5Core) BuildRequires: pkgconfig(mlite5) BuildRequires: pkgconfig(sailfishapp) >= 0.0.10 BuildRequires: pkgconfig(icu-i18n) -BuildRequires: log4qt-devel BuildRequires: desktop-file-utils %description @@ -86,6 +85,5 @@ systemctl --user daemon-reload %{_datadir}/icons/hicolor/86x86/apps/%{name}.png %{_libdir}/systemd/user/%{name}d.service %{_libdir}/systemd/user/user-session.target.wants/%{name}d.service -%{_datadir}/%{name}/log4qt.conf # >> files # << files diff --git a/rpm/pebble.yaml b/rpm/pebble.yaml index c788c27..4681e9c 100644 --- a/rpm/pebble.yaml +++ b/rpm/pebble.yaml @@ -1,6 +1,6 @@ Name: pebble Summary: Support for Pebble watch in SailfishOS -Version: 0.12.1b +Version: 0.13.js1 Release: 1 Group: Qt/Qt URL: http://getpebble.com/ @@ -23,8 +23,6 @@ PkgConfigBR: - mlite5 - sailfishapp >= 0.0.10 - icu-i18n -PkgBR: -- log4qt-devel Requires: - sailfishsilica-qt5 >= 0.10.9 - systemd-user-session-targets @@ -37,4 +35,3 @@ Files: - '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png' - '%{_libdir}/systemd/user/%{name}d.service' - '%{_libdir}/systemd/user/user-session.target.wants/%{name}d.service' -- '%{_datadir}/%{name}/log4qt.conf' |
