From e995685ecd3a755339d1ed2a71476d05be9bc65d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:43:34 +0200 Subject: [PATCH 01/17] Update singleapplication (use of a qt5 alternative) --- 3rdparty/qtsingleapplication/CMakeLists.txt | 27 - 3rdparty/qtsingleapplication/LICENSE.LGPL | 504 ------------------ 3rdparty/qtsingleapplication/QtLockedFile | 1 - .../qtsingleapplication/QtSingleApplication | 1 - 3rdparty/qtsingleapplication/qtlocalpeer.cpp | 218 -------- 3rdparty/qtsingleapplication/qtlocalpeer.h | 85 --- 3rdparty/qtsingleapplication/qtlockedfile.cpp | 199 ------- 3rdparty/qtsingleapplication/qtlockedfile.h | 101 ---- .../qtsingleapplication/qtlockedfile_unix.cpp | 121 ----- .../qtsingleapplication/qtlockedfile_win.cpp | 213 -------- .../qtsingleapplication.cpp | 369 ------------- .../qtsingleapplication/qtsingleapplication.h | 109 ---- .../qtsingleapplication.patch | 231 -------- .../qtsinglecoreapplication.cpp | 169 ------ .../qtsinglecoreapplication.h | 77 --- 3rdparty/singleapplication/CMakeLists.txt | 20 + 3rdparty/singleapplication/LICENSE | 21 + .../singleapplication/singleapplication.cpp | 48 ++ .../singleapplication/singleapplication.h | 32 ++ .../singlecoreapplication.cpp | 48 ++ .../singleapplication/singlecoreapplication.h | 32 ++ 21 files changed, 201 insertions(+), 2425 deletions(-) delete mode 100644 3rdparty/qtsingleapplication/CMakeLists.txt delete mode 100644 3rdparty/qtsingleapplication/LICENSE.LGPL delete mode 100644 3rdparty/qtsingleapplication/QtLockedFile delete mode 100644 3rdparty/qtsingleapplication/QtSingleApplication delete mode 100644 3rdparty/qtsingleapplication/qtlocalpeer.cpp delete mode 100644 3rdparty/qtsingleapplication/qtlocalpeer.h delete mode 100644 3rdparty/qtsingleapplication/qtlockedfile.cpp delete mode 100644 3rdparty/qtsingleapplication/qtlockedfile.h delete mode 100644 3rdparty/qtsingleapplication/qtlockedfile_unix.cpp delete mode 100644 3rdparty/qtsingleapplication/qtlockedfile_win.cpp delete mode 100644 3rdparty/qtsingleapplication/qtsingleapplication.cpp delete mode 100644 3rdparty/qtsingleapplication/qtsingleapplication.h delete mode 100644 3rdparty/qtsingleapplication/qtsingleapplication.patch delete mode 100644 3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp delete mode 100644 3rdparty/qtsingleapplication/qtsinglecoreapplication.h create mode 100644 3rdparty/singleapplication/CMakeLists.txt create mode 100644 3rdparty/singleapplication/LICENSE create mode 100644 3rdparty/singleapplication/singleapplication.cpp create mode 100644 3rdparty/singleapplication/singleapplication.h create mode 100644 3rdparty/singleapplication/singlecoreapplication.cpp create mode 100644 3rdparty/singleapplication/singlecoreapplication.h diff --git a/3rdparty/qtsingleapplication/CMakeLists.txt b/3rdparty/qtsingleapplication/CMakeLists.txt deleted file mode 100644 index 1d78baba4..000000000 --- a/3rdparty/qtsingleapplication/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -set(SINGLEAPP-SOURCES - qtlocalpeer.cpp - qtlockedfile.cpp - qtsingleapplication.cpp - qtsinglecoreapplication.cpp -) - -set(SINGLEAPP-MOC-HEADERS - qtlocalpeer.h - qtsingleapplication.h - qtsinglecoreapplication.h -) - -if(WIN32) - set(SINGLEAPP-SOURCES ${SINGLEAPP-SOURCES} qtlockedfile_win.cpp) -elseif(WIN32) - set(SINGLEAPP-SOURCES ${SINGLEAPP-SOURCES} qtlockedfile_unix.cpp) -endif(WIN32) - -QT4_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS}) - -ADD_LIBRARY(qtsingleapplication STATIC - ${SINGLEAPP-SOURCES} - ${SINGLEAPP-SOURCES-MOC} -) diff --git a/3rdparty/qtsingleapplication/LICENSE.LGPL b/3rdparty/qtsingleapplication/LICENSE.LGPL deleted file mode 100644 index 5ab7695ab..000000000 --- a/3rdparty/qtsingleapplication/LICENSE.LGPL +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/3rdparty/qtsingleapplication/QtLockedFile b/3rdparty/qtsingleapplication/QtLockedFile deleted file mode 100644 index 16b48ba9d..000000000 --- a/3rdparty/qtsingleapplication/QtLockedFile +++ /dev/null @@ -1 +0,0 @@ -#include "qtlockedfile.h" diff --git a/3rdparty/qtsingleapplication/QtSingleApplication b/3rdparty/qtsingleapplication/QtSingleApplication deleted file mode 100644 index d111bf72d..000000000 --- a/3rdparty/qtsingleapplication/QtSingleApplication +++ /dev/null @@ -1 +0,0 @@ -#include "qtsingleapplication.h" diff --git a/3rdparty/qtsingleapplication/qtlocalpeer.cpp b/3rdparty/qtsingleapplication/qtlocalpeer.cpp deleted file mode 100644 index c0b6b81b6..000000000 --- a/3rdparty/qtsingleapplication/qtlocalpeer.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - - -#include "qtlocalpeer.h" -#include -#include -#include - -#if defined(Q_OS_WIN) -#include -#include -typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); -static PProcessIdToSessionId pProcessIdToSessionId = 0; -#endif -#if defined(Q_OS_UNIX) -#include -#endif - -#include "qtlockedfile.cpp" -#if defined(Q_OS_WIN) -#include "qtlockedfile_win.cpp" -#else -#include "qtlockedfile_unix.cpp" -#endif - -const char* QtLocalPeer::ack = "ack"; - -QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) - : QObject(parent), id(appId) -{ - QString prefix = id; - if (id.isEmpty()) { - id = QCoreApplication::applicationFilePath(); -#if defined(Q_OS_WIN) - id = id.toLower(); -#endif - prefix = id.section(QLatin1Char('/'), -1); - } - prefix.remove(QRegExp("[^a-zA-Z]")); - prefix.truncate(6); - - QByteArray idc = id.toUtf8(); - quint16 idNum = qChecksum(idc.constData(), idc.size()); - socketName = QLatin1String("qtsingleapp-") + prefix - + QLatin1Char('-') + QString::number(idNum, 16); - -#if defined(Q_OS_WIN) - if (!pProcessIdToSessionId) { - QLibrary lib("kernel32"); - pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); - } - if (pProcessIdToSessionId) { - DWORD sessionId = 0; - pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); - socketName += QLatin1Char('-') + QString::number(sessionId, 16); - } -#else - socketName += QLatin1Char('-') + QString::number(::getuid(), 16); -#endif - - server = new QLocalServer(this); - QString lockName = QDir(QDir::tempPath()).absolutePath() - + QLatin1Char('/') + socketName - + QLatin1String("-lockfile"); - lockFile.setFileName(lockName); - lockFileCreated = !lockFile.exists(); - lockFile.open(QIODevice::ReadWrite); -} - - - -bool QtLocalPeer::isClient() -{ - if (lockFile.isLocked()) - return false; - - if (!lockFile.lock(QtLockedFile::WriteLock, false)) - return true; - - bool res = server->listen(socketName); -#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) - // ### Workaround - if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { - QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); - res = server->listen(socketName); - } -#endif - if (!res) - qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); - QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); - return false; -} - - -bool QtLocalPeer::sendMessage(const QString &message, int timeout) -{ - return sendMessage(message.toUtf8(), timeout); -} - -bool QtLocalPeer::sendMessage(const char* message, int timeout) -{ - return sendMessage(QByteArray(message), timeout); -} - -bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout) -{ - if (!isClient()) - return false; - - QLocalSocket socket; - bool connOk = false; - for(int i = 0; i < 2; i++) { - // Try twice, in case the other instance is just starting up - socket.connectToServer(socketName); - connOk = socket.waitForConnected(timeout/2); - if (connOk || i) - break; - int ms = 250; -#if defined(Q_OS_WIN) - Sleep(DWORD(ms)); -#else - struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; - nanosleep(&ts, NULL); -#endif - } - if (!connOk) - return false; - - QDataStream ds(&socket); - ds.writeBytes(message.constData(), message.size()); - bool res = socket.waitForBytesWritten(timeout); - res &= socket.waitForReadyRead(timeout); // wait for ack - res &= (socket.read(qstrlen(ack)) == ack); - return res; -} - - -void QtLocalPeer::receiveConnection() -{ - QLocalSocket* socket = server->nextPendingConnection(); - if (!socket) - return; - - while (socket->bytesAvailable() < (int)sizeof(quint32)) - socket->waitForReadyRead(); - QDataStream ds(socket); - QByteArray uMsg; - quint32 remaining; - ds >> remaining; - uMsg.resize(remaining); - int got = 0; - char* uMsgBuf = uMsg.data(); - do { - got = ds.readRawData(uMsgBuf, remaining); - remaining -= got; - uMsgBuf += got; - } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); - if (got < 0) { - qWarning() << "QtLocalPeer: Message reception failed" << socket->errorString(); - delete socket; - return; - } - socket->write(ack, qstrlen(ack)); - socket->waitForBytesWritten(1000); - delete socket; - emit messageReceived(uMsg); //### (might take a long time to return) - emit messageReceived(QString::fromUtf8(uMsg)); -} - -QtLocalPeer::~QtLocalPeer () -{ - if (lockFileCreated) - lockFile.remove(); -} diff --git a/3rdparty/qtsingleapplication/qtlocalpeer.h b/3rdparty/qtsingleapplication/qtlocalpeer.h deleted file mode 100644 index 82b894633..000000000 --- a/3rdparty/qtsingleapplication/qtlocalpeer.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - - -#include -#include -#include - -#include "qtlockedfile.h" - -class QtLocalPeer : public QObject -{ - Q_OBJECT - -public: - QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); - ~QtLocalPeer (); - bool isClient(); - bool sendMessage(const QString &message, int timeout); - bool sendMessage(const QByteArray &message, int timeout); - bool sendMessage(const char* message, int timeout); - QString applicationId() const - { return id; } - -Q_SIGNALS: - void messageReceived(const QString &message); - void messageReceived(const QByteArray &message); - void messageReceived(const char* message); - -protected Q_SLOTS: - void receiveConnection(); - -protected: - QString id; - QString socketName; - QLocalServer* server; - QtLockedFile lockFile; - -private: - static const char* ack; - bool lockFileCreated; -}; diff --git a/3rdparty/qtsingleapplication/qtlockedfile.cpp b/3rdparty/qtsingleapplication/qtlockedfile.cpp deleted file mode 100644 index 2cf080584..000000000 --- a/3rdparty/qtsingleapplication/qtlockedfile.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#include "qtlockedfile.h" - -/*! - \class QtLockedFile - - \brief The QtLockedFile class extends QFile with advisory locking - functions. - - A file may be locked in read or write mode. Multiple instances of - \e QtLockedFile, created in multiple processes running on the same - machine, may have a file locked in read mode. Exactly one instance - may have it locked in write mode. A read and a write lock cannot - exist simultaneously on the same file. - - The file locks are advisory. This means that nothing prevents - another process from manipulating a locked file using QFile or - file system functions offered by the OS. Serialization is only - guaranteed if all processes that access the file use - QLockedFile. Also, while holding a lock on a file, a process - must not open the same file again (through any API), or locks - can be unexpectedly lost. - - The lock provided by an instance of \e QtLockedFile is released - whenever the program terminates. This is true even when the - program crashes and no destructors are called. -*/ - -/*! \enum QtLockedFile::LockMode - - This enum describes the available lock modes. - - \value ReadLock A read lock. - \value WriteLock A write lock. - \value NoLock Neither a read lock nor a write lock. -*/ - -/*! - Constructs an unlocked \e QtLockedFile object. This constructor - behaves in the same way as \e QFile::QFile(). - - \sa QFile::QFile() -*/ -QtLockedFile::QtLockedFile() - : QFile() -{ -#ifdef Q_OS_WIN - wmutex = 0; - rmutex = 0; -#endif - m_lock_mode = NoLock; -} - -/*! - Constructs an unlocked QtLockedFile object with file \a name. This - constructor behaves in the same way as \e QFile::QFile(const - QString&). - - \sa QFile::QFile() -*/ -QtLockedFile::QtLockedFile(const QString &name) - : QFile(name) -{ -#ifdef Q_OS_WIN - wmutex = 0; - rmutex = 0; -#endif - m_lock_mode = NoLock; -} - -/*! - Opens the file in OpenMode \a mode. - - This is identical to QFile::open(), with the one exception that the - Truncate mode flag is disallowed. Truncation would conflict with the - advisory file locking, since the file would be modified before the - write lock is obtained. If truncation is required, use resize(0) - after obtaining the write lock. - - Returns true if successful; otherwise false. - - \sa QFile::open(), QFile::resize() -*/ -bool QtLockedFile::open(OpenMode mode) -{ - if (mode & QIODevice::Truncate) { - qWarning("QtLockedFile::open(): Truncate mode not allowed."); - return false; - } - return QFile::open(mode); -} - -/*! - Returns \e true if this object has a in read or write lock; - otherwise returns \e false. - - \sa lockMode() -*/ -bool QtLockedFile::isLocked() const -{ - return m_lock_mode != NoLock; -} - -/*! - Returns the type of lock currently held by this object, or \e - QtLockedFile::NoLock. - - \sa isLocked() -*/ -QtLockedFile::LockMode QtLockedFile::lockMode() const -{ - return m_lock_mode; -} - -/*! - \fn bool QtLockedFile::lock(LockMode mode, bool block = true) - - Obtains a lock of type \a mode. The file must be opened before it - can be locked. - - If \a block is true, this function will block until the lock is - aquired. If \a block is false, this function returns \e false - immediately if the lock cannot be aquired. - - If this object already has a lock of type \a mode, this function - returns \e true immediately. If this object has a lock of a - different type than \a mode, the lock is first released and then a - new lock is obtained. - - This function returns \e true if, after it executes, the file is - locked by this object, and \e false otherwise. - - \sa unlock(), isLocked(), lockMode() -*/ - -/*! - \fn bool QtLockedFile::unlock() - - Releases a lock. - - If the object has no lock, this function returns immediately. - - This function returns \e true if, after it executes, the file is - not locked by this object, and \e false otherwise. - - \sa lock(), isLocked(), lockMode() -*/ - -/*! - \fn QtLockedFile::~QtLockedFile() - - Destroys the \e QtLockedFile object. If any locks were held, they - are released. -*/ diff --git a/3rdparty/qtsingleapplication/qtlockedfile.h b/3rdparty/qtsingleapplication/qtlockedfile.h deleted file mode 100644 index 1d3b918ec..000000000 --- a/3rdparty/qtsingleapplication/qtlockedfile.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QTLOCKEDFILE_H -#define QTLOCKEDFILE_H - -#include -#ifdef Q_OS_WIN -#include -#endif - -#if defined(Q_WS_WIN) -# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) -# define QT_QTLOCKEDFILE_EXPORT -# elif defined(QT_QTLOCKEDFILE_IMPORT) -# if defined(QT_QTLOCKEDFILE_EXPORT) -# undef QT_QTLOCKEDFILE_EXPORT -# endif -# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) -# elif defined(QT_QTLOCKEDFILE_EXPORT) -# undef QT_QTLOCKEDFILE_EXPORT -# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) -# endif -#else -# define QT_QTLOCKEDFILE_EXPORT -#endif - -class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile -{ -public: - enum LockMode { NoLock = 0, ReadLock, WriteLock }; - - QtLockedFile(); - QtLockedFile(const QString &name); - ~QtLockedFile(); - - bool open(OpenMode mode); - - bool lock(LockMode mode, bool block = true); - bool unlock(); - bool isLocked() const; - LockMode lockMode() const; - -private: -#ifdef Q_OS_WIN - Qt::HANDLE wmutex; - Qt::HANDLE rmutex; - QVector rmutexes; - QString mutexname; - - Qt::HANDLE getMutexHandle(int idx, bool doCreate); - bool waitMutex(Qt::HANDLE mutex, bool doBlock); - -#endif - LockMode m_lock_mode; -}; - -#endif diff --git a/3rdparty/qtsingleapplication/qtlockedfile_unix.cpp b/3rdparty/qtsingleapplication/qtlockedfile_unix.cpp deleted file mode 100644 index 2881bdd2c..000000000 --- a/3rdparty/qtsingleapplication/qtlockedfile_unix.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#include -#include -#include -#include - -#include "qtlockedfile.h" - -bool QtLockedFile::lock(LockMode mode, bool block) -{ - if (!isOpen()) { - qWarning("QtLockedFile::lock(): file is not opened"); - return false; - } - - if (mode == NoLock) - return unlock(); - - if (mode == m_lock_mode) - return true; - - if (m_lock_mode != NoLock) - unlock(); - - struct flock fl; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; - fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; - int cmd = block ? F_SETLKW : F_SETLK; - int ret = fcntl(handle(), cmd, &fl); - - if (ret == -1) { - if (errno != EINTR && errno != EAGAIN) - qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); - return false; - } - - - m_lock_mode = mode; - return true; -} - - -bool QtLockedFile::unlock() -{ - if (!isOpen()) { - qWarning("QtLockedFile::unlock(): file is not opened"); - return false; - } - - if (!isLocked()) - return true; - - struct flock fl; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; - fl.l_type = F_UNLCK; - int ret = fcntl(handle(), F_SETLKW, &fl); - - if (ret == -1) { - qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); - return false; - } - - m_lock_mode = NoLock; - return true; -} - -QtLockedFile::~QtLockedFile() -{ - if (isOpen()) - unlock(); -} - diff --git a/3rdparty/qtsingleapplication/qtlockedfile_win.cpp b/3rdparty/qtsingleapplication/qtlockedfile_win.cpp deleted file mode 100644 index f41bb67d8..000000000 --- a/3rdparty/qtsingleapplication/qtlockedfile_win.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#include "qtlockedfile.h" -#include -#include - -#define MUTEX_PREFIX "QtLockedFile mutex " -// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS -#define MAX_READERS MAXIMUM_WAIT_OBJECTS - -Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) -{ - if (mutexname.isEmpty()) { - QFileInfo fi(*this); - mutexname = QString::fromLatin1(MUTEX_PREFIX) - + fi.absoluteFilePath().toLower(); - } - QString mname(mutexname); - if (idx >= 0) - mname += QString::number(idx); - - Qt::HANDLE mutex; - if (doCreate) { - QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); }, - { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); - if (!mutex) { - qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); - return 0; - } - } - else { - QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); }, - { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); - if (!mutex) { - if (GetLastError() != ERROR_FILE_NOT_FOUND) - qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); - return 0; - } - } - return mutex; -} - -bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) -{ - Q_ASSERT(mutex); - DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); - switch (res) { - case WAIT_OBJECT_0: - case WAIT_ABANDONED: - return true; - break; - case WAIT_TIMEOUT: - break; - default: - qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); - } - return false; -} - - - -bool QtLockedFile::lock(LockMode mode, bool block) -{ - if (!isOpen()) { - qWarning("QtLockedFile::lock(): file is not opened"); - return false; - } - - if (mode == NoLock) - return unlock(); - - if (mode == m_lock_mode) - return true; - - if (m_lock_mode != NoLock) - unlock(); - - if (!wmutex && !(wmutex = getMutexHandle(-1, true))) - return false; - - if (!waitMutex(wmutex, block)) - return false; - - if (mode == ReadLock) { - int idx = 0; - for (; idx < MAX_READERS; idx++) { - rmutex = getMutexHandle(idx, false); - if (!rmutex || waitMutex(rmutex, false)) - break; - CloseHandle(rmutex); - } - bool ok = true; - if (idx >= MAX_READERS) { - qWarning("QtLockedFile::lock(): too many readers"); - rmutex = 0; - ok = false; - } - else if (!rmutex) { - rmutex = getMutexHandle(idx, true); - if (!rmutex || !waitMutex(rmutex, false)) - ok = false; - } - if (!ok && rmutex) { - CloseHandle(rmutex); - rmutex = 0; - } - ReleaseMutex(wmutex); - if (!ok) - return false; - } - else { - Q_ASSERT(rmutexes.isEmpty()); - for (int i = 0; i < MAX_READERS; i++) { - Qt::HANDLE mutex = getMutexHandle(i, false); - if (mutex) - rmutexes.append(mutex); - } - if (rmutexes.size()) { - DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), - TRUE, block ? INFINITE : 0); - if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { - if (res != WAIT_TIMEOUT) - qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); - m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky - unlock(); - return false; - } - } - } - - m_lock_mode = mode; - return true; -} - -bool QtLockedFile::unlock() -{ - if (!isOpen()) { - qWarning("QtLockedFile::unlock(): file is not opened"); - return false; - } - - if (!isLocked()) - return true; - - if (m_lock_mode == ReadLock) { - ReleaseMutex(rmutex); - CloseHandle(rmutex); - rmutex = 0; - } - else { - foreach(Qt::HANDLE mutex, rmutexes) { - ReleaseMutex(mutex); - CloseHandle(mutex); - } - rmutexes.clear(); - ReleaseMutex(wmutex); - } - - m_lock_mode = QtLockedFile::NoLock; - return true; -} - -QtLockedFile::~QtLockedFile() -{ - if (isOpen()) - unlock(); - if (wmutex) - CloseHandle(wmutex); -} diff --git a/3rdparty/qtsingleapplication/qtsingleapplication.cpp b/3rdparty/qtsingleapplication/qtsingleapplication.cpp deleted file mode 100644 index a7e19eed1..000000000 --- a/3rdparty/qtsingleapplication/qtsingleapplication.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - - -#include "qtsingleapplication.h" -#include "qtlocalpeer.h" -#include - - -/*! - \class QtSingleApplication qtsingleapplication.h - \brief The QtSingleApplication class provides an API to detect and - communicate with running instances of an application. - - This class allows you to create applications where only one - instance should be running at a time. I.e., if the user tries to - launch another instance, the already running instance will be - activated instead. Another usecase is a client-server system, - where the first started instance will assume the role of server, - and the later instances will act as clients of that server. - - By default, the full path of the executable file is used to - determine whether two processes are instances of the same - application. You can also provide an explicit identifier string - that will be compared instead. - - The application should create the QtSingleApplication object early - in the startup phase, and call isRunning() or sendMessage() to - find out if another instance of this application is already - running. Startup parameters (e.g. the name of the file the user - wanted this new instance to open) can be passed to the running - instance in the sendMessage() function. - - If isRunning() or sendMessage() returns false, it means that no - other instance is running, and this instance has assumed the role - as the running instance. The application should continue with the - initialization of the application user interface before entering - the event loop with exec(), as normal. The messageReceived() - signal will be emitted when the application receives messages from - another instance of the same application. - - If isRunning() or sendMessage() returns true, another instance is - already running, and the application should terminate or enter - client mode. - - If a message is received it might be helpful to the user to raise - the application so that it becomes visible. To facilitate this, - QtSingleApplication provides the setActivationWindow() function - and the activateWindow() slot. - - Here's an example that shows how to convert an existing - application to use QtSingleApplication. It is very simple and does - not make use of all QtSingleApplication's functionality (see the - examples for that). - - \code - // Original - int main(int argc, char **argv) - { - QApplication app(argc, argv); - - MyMainWidget mmw; - - mmw.show(); - return app.exec(); - } - - // Single instance - int main(int argc, char **argv) - { - QtSingleApplication app(argc, argv); - - if (app.isRunning()) - return 0; - - MyMainWidget mmw; - - app.setActivationWindow(&mmw); - - mmw.show(); - return app.exec(); - } - \endcode - - Once this QtSingleApplication instance is destroyed(for example, - when the user quits), when the user next attempts to run the - application this instance will not, of course, be encountered. The - next instance to call isRunning() or sendMessage() will assume the - role as the new running instance. - - For console (non-GUI) applications, QtSingleCoreApplication may be - used instead of this class, to avoid the dependency on the QtGui - library. - - \sa QtSingleCoreApplication -*/ - - -void QtSingleApplication::sysInit(const QString &appId) -{ - actWin = 0; - peer = new QtLocalPeer(this, appId); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); - connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); - connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*))); -} - - -/*! - Creates a QtSingleApplication object. The application identifier - will be QCoreApplication::applicationFilePath(). \a argc, \a - argv, and \a GUIenabled are passed on to the QAppliation constructor. - - If you are creating a console application (i.e. setting \a - GUIenabled to false), you may consider using - QtSingleCoreApplication instead. -*/ - -QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled) - : QApplication(argc, argv, GUIenabled) -{ - sysInit(); -} - - -/*! - Creates a QtSingleApplication object with the application - identifier \a appId. \a argc and \a argv are passed on to the - QAppliation constructor. -*/ - -QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv) - : QApplication(argc, argv) -{ - sysInit(appId); -} - - -/*! - Creates a QtSingleApplication object. The application identifier - will be QCoreApplication::applicationFilePath(). \a argc, \a - argv, and \a type are passed on to the QAppliation constructor. -*/ -QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) - : QApplication(argc, argv, type) -{ - sysInit(); -} - - -#if defined(Q_WS_X11) -/*! - Special constructor for X11, ref. the documentation of - QApplication's corresponding constructor. The application identifier - will be QCoreApplication::applicationFilePath(). \a dpy, \a visual, - and \a cmap are passed on to the QApplication constructor. -*/ -QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap) - : QApplication(dpy, visual, cmap) -{ - sysInit(); -} - -/*! - Special constructor for X11, ref. the documentation of - QApplication's corresponding constructor. The application identifier - will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a - argv, \a visual, and \a cmap are passed on to the QApplication - constructor. -*/ -QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) - : QApplication(dpy, argc, argv, visual, cmap) -{ - sysInit(); -} - -/*! - Special constructor for X11, ref. the documentation of - QApplication's corresponding constructor. The application identifier - will be \a appId. \a dpy, \a argc, \a - argv, \a visual, and \a cmap are passed on to the QApplication - constructor. -*/ -QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) - : QApplication(dpy, argc, argv, visual, cmap) -{ - sysInit(appId); -} -#endif - - -/*! - Returns true if another instance of this application is running; - otherwise false. - - This function does not find instances of this application that are - being run by a different user (on Windows: that are running in - another session). - - \sa sendMessage() -*/ - -bool QtSingleApplication::isRunning() -{ - return peer->isClient(); -} - - -/*! - Tries to send the text \a message to the currently running - instance. The QtSingleApplication object in the running instance - will emit the messageReceived() signal when it receives the - message. - - This function returns true if the message has been sent to, and - processed by, the current instance. If there is no instance - currently running, or if the running instance fails to process the - message within \a timeout milliseconds, this function return false. - - \sa isRunning(), messageReceived() -*/ -bool QtSingleApplication::sendMessage(const QString &message, int timeout) -{ - return peer->sendMessage(message, timeout); -} - -bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout) -{ - return peer->sendMessage(message, timeout); -} - -bool QtSingleApplication::sendMessage(const char* message, int timeout) -{ - return peer->sendMessage(message, timeout); -} - - -/*! - Returns the application identifier. Two processes with the same - identifier will be regarded as instances of the same application. -*/ -QString QtSingleApplication::id() const -{ - return peer->applicationId(); -} - - -/*! - Sets the activation window of this application to \a aw. The - activation window is the widget that will be activated by - activateWindow(). This is typically the application's main window. - - If \a activateOnMessage is true (the default), the window will be - activated automatically every time a message is received, just prior - to the messageReceived() signal being emitted. - - \sa activateWindow(), messageReceived() -*/ - -void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) -{ - actWin = aw; - if (activateOnMessage) { - connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); - connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow())); - connect(peer, SIGNAL(messageReceived(const char*)), this, SLOT(activateWindow())); - } - else { - disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); - disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow())); - disconnect(peer, SIGNAL(messageReceived(const char*)), this, SLOT(activateWindow())); - } -} - - -/*! - Returns the applications activation window if one has been set by - calling setActivationWindow(), otherwise returns 0. - - \sa setActivationWindow() -*/ -QWidget* QtSingleApplication::activationWindow() const -{ - return actWin; -} - - -/*! - De-minimizes, raises, and activates this application's activation window. - This function does nothing if no activation window has been set. - - This is a convenience function to show the user that this - application instance has been activated when he has tried to start - another instance. - - This function should typically be called in response to the - messageReceived() signal. By default, that will happen - automatically, if an activation window has been set. - - \sa setActivationWindow(), messageReceived(), initialize() -*/ -void QtSingleApplication::activateWindow() -{ - if (actWin) { - actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); - actWin->raise(); - actWin->activateWindow(); - } -} - - -/*! - \fn void QtSingleApplication::messageReceived(const QString& message) - - This signal is emitted when the current instance receives a \a - message from another instance of this application. - - \sa sendMessage(), setActivationWindow(), activateWindow() -*/ - - -/*! - \fn void QtSingleApplication::initialize(bool dummy = true) - - \obsolete -*/ diff --git a/3rdparty/qtsingleapplication/qtsingleapplication.h b/3rdparty/qtsingleapplication/qtsingleapplication.h deleted file mode 100644 index ba0507cb8..000000000 --- a/3rdparty/qtsingleapplication/qtsingleapplication.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - - -#include - -class QtLocalPeer; - -#if defined(Q_WS_WIN) -# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) -# define QT_QTSINGLEAPPLICATION_EXPORT -# elif defined(QT_QTSINGLEAPPLICATION_IMPORT) -# if defined(QT_QTSINGLEAPPLICATION_EXPORT) -# undef QT_QTSINGLEAPPLICATION_EXPORT -# endif -# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) -# elif defined(QT_QTSINGLEAPPLICATION_EXPORT) -# undef QT_QTSINGLEAPPLICATION_EXPORT -# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) -# endif -#else -# define QT_QTSINGLEAPPLICATION_EXPORT -#endif - -class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication -{ - Q_OBJECT - -public: - QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); - QtSingleApplication(const QString &id, int &argc, char **argv); - QtSingleApplication(int &argc, char **argv, Type type); -#if defined(Q_WS_X11) - QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); - QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); - QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); -#endif - - bool isRunning(); - QString id() const; - - void setActivationWindow(QWidget* aw, bool activateOnMessage = true); - QWidget* activationWindow() const; - - // Obsolete: - void initialize(bool dummy = true) - { isRunning(); Q_UNUSED(dummy) } - -public Q_SLOTS: - bool sendMessage(const QString &message, int timeout = 5000); - bool sendMessage(const QByteArray &message, int timeout = 5000); - bool sendMessage(const char* message, int timeout = 5000); - void activateWindow(); - - -Q_SIGNALS: - void messageReceived(const QString &message); - void messageReceived(const QByteArray &message); - void messageReceived(const char* message); - - -private: - void sysInit(const QString &appId = QString()); - QtLocalPeer *peer; - QWidget *actWin; -}; diff --git a/3rdparty/qtsingleapplication/qtsingleapplication.patch b/3rdparty/qtsingleapplication/qtsingleapplication.patch deleted file mode 100644 index a65e64ac7..000000000 --- a/3rdparty/qtsingleapplication/qtsingleapplication.patch +++ /dev/null @@ -1,231 +0,0 @@ -diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp qtsingleapplication/qtlocalpeer.cpp ---- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp 2009-12-16 10:43:33.000000000 +0000 -+++ qtsingleapplication/qtlocalpeer.cpp 2010-07-10 16:26:50.000000000 +0100 -@@ -48,6 +48,7 @@ - #include "qtlocalpeer.h" - #include - #include -+#include - - #if defined(Q_OS_WIN) - #include -@@ -59,14 +60,12 @@ - #include - #endif - --namespace QtLP_Private { - #include "qtlockedfile.cpp" - #if defined(Q_OS_WIN) - #include "qtlockedfile_win.cpp" - #else - #include "qtlockedfile_unix.cpp" - #endif --} - - const char* QtLocalPeer::ack = "ack"; - -@@ -118,7 +117,7 @@ - if (lockFile.isLocked()) - return false; - -- if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) -+ if (!lockFile.lock(QtLockedFile::WriteLock, false)) - return true; - - bool res = server->listen(socketName); -@@ -138,6 +137,11 @@ - - bool QtLocalPeer::sendMessage(const QString &message, int timeout) - { -+ return sendMessage(message.toUtf8(), timeout); -+} -+ -+bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout) -+{ - if (!isClient()) - return false; - -@@ -160,9 +164,8 @@ - if (!connOk) - return false; - -- QByteArray uMsg(message.toUtf8()); - QDataStream ds(&socket); -- ds.writeBytes(uMsg.constData(), uMsg.size()); -+ ds.writeBytes(message.constData(), message.size()); - bool res = socket.waitForBytesWritten(timeout); - res &= socket.waitForReadyRead(timeout); // wait for ack - res &= (socket.read(qstrlen(ack)) == ack); -@@ -195,9 +198,9 @@ - delete socket; - return; - } -- QString message(QString::fromUtf8(uMsg)); - socket->write(ack, qstrlen(ack)); - socket->waitForBytesWritten(1000); - delete socket; -- emit messageReceived(message); //### (might take a long time to return) -+ emit messageReceived(uMsg); //### (might take a long time to return) -+ emit messageReceived(QString::fromUtf8(uMsg)); - } -diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h qtsingleapplication/qtlocalpeer.h ---- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h 2009-12-16 10:43:33.000000000 +0000 -+++ qtsingleapplication/qtlocalpeer.h 2010-07-10 16:26:16.000000000 +0100 -@@ -49,9 +49,7 @@ - #include - #include - --namespace QtLP_Private { - #include "qtlockedfile.h" --} - - class QtLocalPeer : public QObject - { -@@ -61,11 +59,13 @@ - QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); - bool isClient(); - bool sendMessage(const QString &message, int timeout); -+ bool sendMessage(const QByteArray &message, int timeout); - QString applicationId() const - { return id; } - - Q_SIGNALS: - void messageReceived(const QString &message); -+ void messageReceived(const QByteArray &message); - - protected Q_SLOTS: - void receiveConnection(); -@@ -74,7 +74,7 @@ - QString id; - QString socketName; - QLocalServer* server; -- QtLP_Private::QtLockedFile lockFile; -+ QtLockedFile lockFile; - - private: - static const char* ack; -diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp qtsingleapplication/qtlockedfile_win.cpp ---- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp 2009-12-16 10:43:33.000000000 +0000 -+++ qtsingleapplication/qtlockedfile_win.cpp 2010-07-10 16:26:33.000000000 +0100 -@@ -65,7 +65,7 @@ - - Qt::HANDLE mutex; - if (doCreate) { -- QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, -+ QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); }, - { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); - if (!mutex) { - qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); -@@ -73,7 +73,7 @@ - } - } - else { -- QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, -+ QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); }, - { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); - if (!mutex) { - if (GetLastError() != ERROR_FILE_NOT_FOUND) -diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp qtsingleapplication/qtsingleapplication.cpp ---- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp 2009-12-16 10:43:33.000000000 +0000 -+++ qtsingleapplication/qtsingleapplication.cpp 2010-07-10 16:23:53.000000000 +0100 -@@ -144,6 +144,7 @@ - actWin = 0; - peer = new QtLocalPeer(this, appId); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); -+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); - } - - -@@ -265,6 +266,11 @@ - return peer->sendMessage(message, timeout); - } - -+bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout) -+{ -+ return peer->sendMessage(message, timeout); -+} -+ - - /*! - Returns the application identifier. Two processes with the same -@@ -291,10 +297,14 @@ - void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) - { - actWin = aw; -- if (activateOnMessage) -+ if (activateOnMessage) { - connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); -- else -+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow())); -+ } -+ else { - disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); -+ disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow())); -+ } - } - - -diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h qtsingleapplication/qtsingleapplication.h ---- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h 2009-12-16 10:43:33.000000000 +0000 -+++ qtsingleapplication/qtsingleapplication.h 2010-07-10 16:23:53.000000000 +0100 -@@ -91,11 +91,13 @@ - - public Q_SLOTS: - bool sendMessage(const QString &message, int timeout = 5000); -+ bool sendMessage(const QByteArray &message, int timeout = 5000); - void activateWindow(); - - - Q_SIGNALS: - void messageReceived(const QString &message); -+ void messageReceived(const QByteArray &message); - - - private: -diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp qtsingleapplication/qtsinglecoreapplication.cpp ---- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp 2009-12-16 10:43:33.000000000 +0000 -+++ qtsingleapplication/qtsinglecoreapplication.cpp 2010-07-10 16:32:33.000000000 +0100 -@@ -81,6 +81,7 @@ - { - peer = new QtLocalPeer(this); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); -+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); - } - - -@@ -94,6 +95,7 @@ - { - peer = new QtLocalPeer(this, appId); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); -+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); - } - - -@@ -133,6 +135,11 @@ - return peer->sendMessage(message, timeout); - } - -+bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout) -+{ -+ return peer->sendMessage(message, timeout); -+} -+ - - /*! - Returns the application identifier. Two processes with the same -diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h qtsingleapplication/qtsinglecoreapplication.h ---- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h 2009-12-16 10:43:33.000000000 +0000 -+++ qtsingleapplication/qtsinglecoreapplication.h 2010-07-10 16:32:33.000000000 +0100 -@@ -62,10 +62,12 @@ - - public Q_SLOTS: - bool sendMessage(const QString &message, int timeout = 5000); -+ bool sendMessage(const QByteArray &message, int timeout = 5000); - - - Q_SIGNALS: - void messageReceived(const QString &message); -+ void messageReceived(const QByteArray &message); - - - private: diff --git a/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp b/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp deleted file mode 100644 index 38e16584a..000000000 --- a/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - - -#include "qtsinglecoreapplication.h" -#include "qtlocalpeer.h" - -/*! - \class QtSingleCoreApplication qtsinglecoreapplication.h - \brief A variant of the QtSingleApplication class for non-GUI applications. - - This class is a variant of QtSingleApplication suited for use in - console (non-GUI) applications. It is an extension of - QCoreApplication (instead of QApplication). It does not require - the QtGui library. - - The API and usage is identical to QtSingleApplication, except that - functions relating to the "activation window" are not present, for - obvious reasons. Please refer to the QtSingleApplication - documentation for explanation of the usage. - - A QtSingleCoreApplication instance can communicate to a - QtSingleApplication instance if they share the same application - id. Hence, this class can be used to create a light-weight - command-line tool that sends commands to a GUI application. - - \sa QtSingleApplication -*/ - -/*! - Creates a QtSingleCoreApplication object. The application identifier - will be QCoreApplication::applicationFilePath(). \a argc and \a - argv are passed on to the QCoreAppliation constructor. -*/ - -QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) - : QCoreApplication(argc, argv) -{ - peer = new QtLocalPeer(this); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); - connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); - connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*))); -} - - -/*! - Creates a QtSingleCoreApplication object with the application - identifier \a appId. \a argc and \a argv are passed on to the - QCoreAppliation constructor. -*/ -QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) - : QCoreApplication(argc, argv) -{ - peer = new QtLocalPeer(this, appId); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); - connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&))); - connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*))); -} - - -/*! - Returns true if another instance of this application is running; - otherwise false. - - This function does not find instances of this application that are - being run by a different user (on Windows: that are running in - another session). - - \sa sendMessage() -*/ - -bool QtSingleCoreApplication::isRunning() -{ - return peer->isClient(); -} - - -/*! - Tries to send the text \a message to the currently running - instance. The QtSingleCoreApplication object in the running instance - will emit the messageReceived() signal when it receives the - message. - - This function returns true if the message has been sent to, and - processed by, the current instance. If there is no instance - currently running, or if the running instance fails to process the - message within \a timeout milliseconds, this function return false. - - \sa isRunning(), messageReceived() -*/ - -bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) -{ - return peer->sendMessage(message, timeout); -} - -bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout) -{ - return peer->sendMessage(message, timeout); -} - -bool QtSingleCoreApplication::sendMessage(const char* message, int timeout) -{ - return peer->sendMessage(message, timeout); -} - - -/*! - Returns the application identifier. Two processes with the same - identifier will be regarded as instances of the same application. -*/ - -QString QtSingleCoreApplication::id() const -{ - return peer->applicationId(); -} - - -/*! - \fn void QtSingleCoreApplication::messageReceived(const QString& message) - - This signal is emitted when the current instance receives a \a - message from another instance of this application. - - \sa sendMessage() -*/ diff --git a/3rdparty/qtsingleapplication/qtsinglecoreapplication.h b/3rdparty/qtsingleapplication/qtsinglecoreapplication.h deleted file mode 100644 index f80946da5..000000000 --- a/3rdparty/qtsingleapplication/qtsinglecoreapplication.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of a Qt Solutions component. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Solutions Commercial License Agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** Please note Third Party Software included with Qt Solutions may impose -** additional restrictions and it is the user's responsibility to ensure -** that they have met the licensing requirements of the GPL, LGPL, or Qt -** Solutions Commercial license and the relevant license of the Third -** Party Software they are using. -** -** If you are unsure which license is appropriate for your use, please -** contact Nokia at qt-info@nokia.com. -** -****************************************************************************/ - - -#include - -class QtLocalPeer; - -class QtSingleCoreApplication : public QCoreApplication -{ - Q_OBJECT - -public: - QtSingleCoreApplication(int &argc, char **argv); - QtSingleCoreApplication(const QString &id, int &argc, char **argv); - - bool isRunning(); - QString id() const; - -public Q_SLOTS: - bool sendMessage(const QString &message, int timeout = 5000); - bool sendMessage(const QByteArray &message, int timeout = 5000); - bool sendMessage(const char* message, int timeout = 5000); - - -Q_SIGNALS: - void messageReceived(const QString &message); - void messageReceived(const QByteArray &message); - void messageReceived(const char* message); - - -private: - QtLocalPeer* peer; -}; diff --git a/3rdparty/singleapplication/CMakeLists.txt b/3rdparty/singleapplication/CMakeLists.txt new file mode 100644 index 000000000..f4711c0f5 --- /dev/null +++ b/3rdparty/singleapplication/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.6) + +set(SINGLEAPP-SOURCES + singleapplication.cpp + singlecoreapplication.cpp +) + +set(SINGLEAPP-MOC-HEADERS + singleapplication.h + singlecoreapplication.h +) + +QT5_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS}) + +ADD_LIBRARY(singleapplication STATIC + ${SINGLEAPP-SOURCES} + ${SINGLEAPP-SOURCES-MOC} +) + +QT5_USE_MODULES(singleapplication Core Network Widgets) diff --git a/3rdparty/singleapplication/LICENSE b/3rdparty/singleapplication/LICENSE new file mode 100644 index 000000000..5c0006b9a --- /dev/null +++ b/3rdparty/singleapplication/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Itay Grudev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/3rdparty/singleapplication/singleapplication.cpp b/3rdparty/singleapplication/singleapplication.cpp new file mode 100644 index 000000000..9f71a62cb --- /dev/null +++ b/3rdparty/singleapplication/singleapplication.cpp @@ -0,0 +1,48 @@ +#include "singleapplication.h" +#include + +/** + * @brief Constructor. Checks and fires up LocalServer or closes the program + * if another instance already exists + * @param argc + * @param argv + */ +SingleApplication::SingleApplication(int &argc, char **argv) + : QApplication(argc, argv) +{ + QString serverName = QApplication::organizationName() + QApplication::applicationName(); + serverName.replace(QRegExp("[^\\w\\-. ]"), ""); + + // Attempt to connect to the LocalServer + socket = new QLocalSocket(); + socket->connectToServer(serverName); + if(socket->waitForConnected(1000)){ + socket->close(); + ::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function + } else { + // If the connection is insuccessful, this is the main process + // So we create a Local Server + server = new QLocalServer(); + server->removeServer(serverName); + server->listen(serverName); + QObject::connect(server, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished())); + } +} + +/** + * @brief Destructor + */ +SingleApplication::~SingleApplication() +{ + server->close(); +} + +/** + * @brief Executed when the showUp command is sent to LocalServer + */ +void SingleApplication::slotConnectionEstablished() +{ + server->nextPendingConnection(); + emit showUp(); +} + diff --git a/3rdparty/singleapplication/singleapplication.h b/3rdparty/singleapplication/singleapplication.h new file mode 100644 index 000000000..3550eace0 --- /dev/null +++ b/3rdparty/singleapplication/singleapplication.h @@ -0,0 +1,32 @@ +#ifndef SINGLE_APPLICATION_H +#define SINGLE_APPLICATION_H + +#include +#include +#include + +/** + * @brief The SingleApplication class handles multipe instances of the same Application + * @see QApplication + */ +class SingleApplication : public QApplication +{ + Q_OBJECT +public: + explicit SingleApplication(int &, char **); + ~SingleApplication(); + +signals: + void showUp(); + +private slots: + void slotConnectionEstablished(); + +private: + QLocalSocket *socket; + QLocalServer *server; + +}; + +#endif // SINGLE_APPLICATION_H + diff --git a/3rdparty/singleapplication/singlecoreapplication.cpp b/3rdparty/singleapplication/singlecoreapplication.cpp new file mode 100644 index 000000000..587b3fa53 --- /dev/null +++ b/3rdparty/singleapplication/singlecoreapplication.cpp @@ -0,0 +1,48 @@ +#include "singlecoreapplication.h" +#include + +/** + * @brief Constructor. Checks and fires up LocalServer or closes the program + * if another instance already exists + * @param argc + * @param argv + */ +SingleCoreApplication::SingleCoreApplication(int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + QString serverName = QCoreApplication::organizationName() + QCoreApplication::applicationName(); + serverName.replace(QRegExp("[^\\w\\-. ]"), ""); + + // Attempt to connect to the LocalServer + socket = new QLocalSocket(); + socket->connectToServer(serverName); + if(socket->waitForConnected(1000)){ + socket->close(); + ::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function + } else { + // If the connection is insuccessful, this is the main process + // So we create a Local Server + server = new QLocalServer(); + server->removeServer(serverName); + server->listen(serverName); + QObject::connect(server, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished())); + } +} + +/** + * @brief Destructor + */ +SingleCoreApplication::~SingleCoreApplication() +{ + server->close(); +} + +/** + * @brief Executed when the showUp command is sent to LocalServer + */ +void SingleCoreApplication::slotConnectionEstablished() +{ + server->nextPendingConnection(); + emit showUp(); +} + diff --git a/3rdparty/singleapplication/singlecoreapplication.h b/3rdparty/singleapplication/singlecoreapplication.h new file mode 100644 index 000000000..b3a404d03 --- /dev/null +++ b/3rdparty/singleapplication/singlecoreapplication.h @@ -0,0 +1,32 @@ +#ifndef SINGLE_CORE_APPLICATION_H +#define SINGLE_CORE_APPLICATION_H + +#include +#include +#include + +/** + * @brief The SingleCoreApplication class handles multipe instances of the same Application + * @see QApplication + */ +class SingleCoreApplication : public QCoreApplication +{ + Q_OBJECT +public: + explicit SingleCoreApplication(int &, char **); + ~SingleCoreApplication(); + +signals: + void showUp(); + +private slots: + void slotConnectionEstablished(); + +private: + QLocalSocket *socket; + QLocalServer *server; + +}; + +#endif // SINGLE_CORE_APPLICATION_H + From 2495c6cc617ee2c7260cba7d873f41699f635397 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:44:11 +0200 Subject: [PATCH 02/17] Update of libmygpo for qt5 --- 3rdparty/libmygpo-qt5/AUTHORS | 3 + 3rdparty/libmygpo-qt5/CMakeLists.txt | 50 ++ 3rdparty/libmygpo-qt5/LICENSE | 502 ++++++++++++++++++ 3rdparty/libmygpo-qt5/Mygpo-qtConfig.cmake.in | 18 + .../Mygpo-qtConfigVersion.cmake.in | 10 + 3rdparty/libmygpo-qt5/README | 52 ++ .../cmake/modules/FindQJSON.cmake | 50 ++ .../src}/AddRemoveResult.cpp | 8 +- .../src}/AddRemoveResult.h | 0 .../src}/AddRemoveResult_p.h | 0 .../src}/ApiRequest.cpp | 2 +- .../src}/ApiRequest.h | 12 +- .../src}/ApiRequest_p.h | 0 .../src}/CMakeLists.txt | 17 +- .../src}/Config.cpp | 0 .../src}/Config.h | 0 .../src}/Config_p.h | 0 .../src}/Device.cpp | 0 .../src}/Device.h | 0 .../src}/DeviceList.cpp | 5 +- .../src}/DeviceList.h | 0 .../src}/DeviceList_p.h | 0 .../src}/DeviceSyncResult.cpp | 7 +- .../src}/DeviceSyncResult.h | 0 .../src}/DeviceSyncResult_p.h | 0 .../src}/DeviceUpdates.cpp | 5 +- .../src}/DeviceUpdates.h | 0 .../src}/DeviceUpdates_p.h | 0 .../src}/Device_p.h | 0 .../src}/Episode.cpp | 5 +- .../src}/Episode.h | 0 .../src}/EpisodeAction.cpp | 5 +- .../src}/EpisodeAction.h | 0 .../src}/EpisodeActionList.cpp | 5 +- .../src}/EpisodeActionList.h | 0 .../src}/EpisodeActionList_p.h | 0 .../src}/EpisodeAction_p.h | 0 .../src}/EpisodeList.cpp | 5 +- .../src}/EpisodeList.h | 0 .../src}/EpisodeList_p.h | 0 .../src}/Episode_p.h | 0 .../src}/JsonCreator.cpp | 20 +- .../src}/JsonCreator.h | 0 .../src}/Podcast.cpp | 7 +- .../src}/Podcast.h | 0 .../src}/PodcastList.cpp | 5 +- .../src}/PodcastList.h | 0 .../src}/PodcastList_p.h | 0 .../src}/Podcast_p.h | 0 .../src}/RequestHandler.cpp | 2 +- .../src}/RequestHandler.h | 0 .../src}/Settings.cpp | 6 +- .../src}/Settings.h | 0 .../src}/Settings_p.h | 0 .../{libmygpo-qt => libmygpo-qt5/src}/Tag.cpp | 0 .../{libmygpo-qt => libmygpo-qt5/src}/Tag.h | 0 .../src}/TagList.cpp | 5 +- .../src}/TagList.h | 0 .../src}/TagList_p.h | 0 .../{libmygpo-qt => libmygpo-qt5/src}/Tag_p.h | 0 .../src}/UrlBuilder.cpp | 3 +- .../src}/UrlBuilder.h | 0 .../src}/Version.h.in | 0 .../src}/mygpo_export.h | 0 .../libmygpo-qt5/src/qjsonwrapper/Json.cpp | 123 +++++ 3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.h | 36 ++ 66 files changed, 894 insertions(+), 74 deletions(-) create mode 100644 3rdparty/libmygpo-qt5/AUTHORS create mode 100644 3rdparty/libmygpo-qt5/CMakeLists.txt create mode 100644 3rdparty/libmygpo-qt5/LICENSE create mode 100644 3rdparty/libmygpo-qt5/Mygpo-qtConfig.cmake.in create mode 100644 3rdparty/libmygpo-qt5/Mygpo-qtConfigVersion.cmake.in create mode 100644 3rdparty/libmygpo-qt5/README create mode 100644 3rdparty/libmygpo-qt5/cmake/modules/FindQJSON.cmake rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/AddRemoveResult.cpp (97%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/AddRemoveResult.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/AddRemoveResult_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/ApiRequest.cpp (99%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/ApiRequest.h (98%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/ApiRequest_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/CMakeLists.txt (67%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Config.cpp (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Config.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Config_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Device.cpp (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Device.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceList.cpp (97%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceList.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceList_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceSyncResult.cpp (97%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceSyncResult.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceSyncResult_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceUpdates.cpp (98%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceUpdates.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/DeviceUpdates_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Device_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Episode.cpp (98%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Episode.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeAction.cpp (98%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeAction.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeActionList.cpp (98%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeActionList.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeActionList_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeAction_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeList.cpp (97%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeList.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/EpisodeList_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Episode_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/JsonCreator.cpp (94%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/JsonCreator.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Podcast.cpp (97%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Podcast.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/PodcastList.cpp (97%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/PodcastList.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/PodcastList_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Podcast_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/RequestHandler.cpp (99%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/RequestHandler.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Settings.cpp (96%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Settings.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Settings_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Tag.cpp (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Tag.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/TagList.cpp (97%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/TagList.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/TagList_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Tag_p.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/UrlBuilder.cpp (98%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/UrlBuilder.h (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/Version.h.in (100%) rename 3rdparty/{libmygpo-qt => libmygpo-qt5/src}/mygpo_export.h (100%) create mode 100644 3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.cpp create mode 100644 3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.h diff --git a/3rdparty/libmygpo-qt5/AUTHORS b/3rdparty/libmygpo-qt5/AUTHORS new file mode 100644 index 000000000..9080afb9e --- /dev/null +++ b/3rdparty/libmygpo-qt5/AUTHORS @@ -0,0 +1,3 @@ +Stefan Derkits +Christian Wagner +Felix Winter diff --git a/3rdparty/libmygpo-qt5/CMakeLists.txt b/3rdparty/libmygpo-qt5/CMakeLists.txt new file mode 100644 index 000000000..dd47ad1ac --- /dev/null +++ b/3rdparty/libmygpo-qt5/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required( VERSION 2.6 FATAL_ERROR ) + +set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII" ) + +set(MYGPO_QT_VERSION_SUFFIX 5) + +macro(qt_wrap_cpp) + qt5_wrap_cpp(${ARGN}) +endmacro() + +# pkg-config names of QtCore and QtNetwork are Qt5Core and Qt5Network for +# Qt5 +set(MYGPO_QT_MAJOR_VERSION "5") +set(MYGPO_QT4_QJSON_DEP "") + +# Don't use absolute path in Mygpo-qtTargets-$buildType.cmake +# (This will have no effect with CMake < 2.8) +# set(QT_USE_IMPORTED_TARGETS TRUE) + +set( MYGPO_QT_VERSION_MAJOR "1" ) +set( MYGPO_QT_VERSION_MINOR "0" ) +set( MYGPO_QT_VERSION_PATCH "8" ) +set( MYGPO_QT_VERSION "${MYGPO_QT_VERSION_MAJOR}.${MYGPO_QT_VERSION_MINOR}.${MYGPO_QT_VERSION_PATCH}" ) + +#Configure Version.h.in with the actual version number +configure_file( src/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/Version.h ) + +include(CheckCXXCompilerFlag) + +if (CMAKE_COMPILER_IS_GNUCXX) + ADD_DEFINITIONS( -Wcast-align -Wchar-subscripts -Wpointer-arith + -Wwrite-strings -Wpacked -Wformat-security -Wmissing-format-attribute + -Wold-style-cast -Woverloaded-virtual -Wnon-virtual-dtor -Wall -Wextra + -Wformat=2 -Wundef -Wstack-protector -Wmissing-include-dirs + -Winit-self -Wunsafe-loop-optimizations -ggdb3 -fno-inline -DQT_STRICT_ITERATORS ) + if ( NOT WIN32 ) + add_definitions( -fvisibility=hidden ) + endif() + + check_cxx_compiler_flag( -Wlogical-op GNUCXX_HAS_WLOGICAL_OP ) + if ( GNUCXX_HAS_WLOGICAL_OP ) + add_definitions( -Wlogical-op ) + endif() +endif(CMAKE_COMPILER_IS_GNUCXX) + + +set(MYGPO_QT_TARGET_NAME mygpo-qt${MYGPO_QT_VERSION_SUFFIX} CACHE INTERNAL "" FORCE ) + +add_subdirectory( src ) diff --git a/3rdparty/libmygpo-qt5/LICENSE b/3rdparty/libmygpo-qt5/LICENSE new file mode 100644 index 000000000..4362b4915 --- /dev/null +++ b/3rdparty/libmygpo-qt5/LICENSE @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/3rdparty/libmygpo-qt5/Mygpo-qtConfig.cmake.in b/3rdparty/libmygpo-qt5/Mygpo-qtConfig.cmake.in new file mode 100644 index 000000000..17873a74c --- /dev/null +++ b/3rdparty/libmygpo-qt5/Mygpo-qtConfig.cmake.in @@ -0,0 +1,18 @@ +get_filename_component(myDir ${CMAKE_CURRENT_LIST_FILE} PATH) # get the directory where I myself am +get_filename_component(rootDir ${myDir}/@relInstallDir@ ABSOLUTE) # get the chosen install prefix + +# set the version of myself +set(MYGPO_QT_VERSION_MAJOR @MYGPO_QT_VERSION_MAJOR@) +set(MYGPO_QT_VERSION_MINOR @MYGPO_QT_VERSION_MINOR@) +set(MYGPO_QT_VERSION_PATCH @MYGPO_QT_VERSION_PATCH@) +set(MYGPO_QT_VERSION ${MYGPO_QT_VERSION_MAJOR}.${MYGPO_QT_VERSION_MINOR}.${MYGPO_QT_VERSION_PATCH} ) + +# what is my include directory +set(LIBMYGPO_QT_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@") + +# import the exported targets +include(${myDir}/Mygpo-qtTargets.cmake) + +# set the expected library variable +set(LIBMYGPO_QT_LIBRARIES mygpo-qt ) +set(LIBMYGPO_QT_FOUND "True") diff --git a/3rdparty/libmygpo-qt5/Mygpo-qtConfigVersion.cmake.in b/3rdparty/libmygpo-qt5/Mygpo-qtConfigVersion.cmake.in new file mode 100644 index 000000000..1126fdfc3 --- /dev/null +++ b/3rdparty/libmygpo-qt5/Mygpo-qtConfigVersion.cmake.in @@ -0,0 +1,10 @@ +set(PACKAGE_VERSION @MYGPO_QT_VERSION_MAJOR@.@MYGPO_QT_VERSION_MINOR@.@MYGPO_QT_VERSION_PATCH@) + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") +endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) diff --git a/3rdparty/libmygpo-qt5/README b/3rdparty/libmygpo-qt5/README new file mode 100644 index 000000000..656949d9f --- /dev/null +++ b/3rdparty/libmygpo-qt5/README @@ -0,0 +1,52 @@ +========== README ========== + +=== What is libmygpo-qt === + +libmygpo-qt is a Qt Library that wraps the gpodder.net Web API (http://wiki.gpodder.org/wiki/Web_Services/API_2) + +=== Copyright & License === + +Copyright 2010 - 2014 Stefan Derkits (stefan@derkits.at) , Christian Wagner (christian.wagner86@gmx.at) & Felix Winter (ixos01@gmail.com) + +See COPYING File for License + +=== Maintainer === + +Current Maintainer: Stefan Derkits (HorusHorrendus @ irc.freenode.net) + +=== Requirements === + +-) Qt 4.6 or higher +-) Cmake 2.6 or higher +-) QJson + +=== Qt5 Support === + +libmygpo-qt version 1.0.8 supports also building the library with Qt5. The API is the same as in the Qt4 library. To build the library with Qt5 add "-DBUILD_WITH_QT4=OFF" to your CMake +command line. Please note that Qt5 support is still experimental. If you find anything to not work with Qt5, please report a bug. + +==== Qt5 Requirements === + +-) CMake 2.8.9 or higher +-) Qt 5.2 or higher + +=== Links === + +Homepage: http://wiki.gpodder.org/wiki/Libmygpo-qt +Git Repo: https://github.com/gpodder/libmygpo-qt +Doxygen Documentation: http://stefan.derkits.at/libmygpo-doc/ +Bugreports: http://bugs.gpodder.org +Contact: gpodder@freelists.org +IRC Channel: #gpodder on FreeNode (irc.freenode.net) + +=== How to Install === + +-) Create Directory "build" +-) change into build and run "cmake .. -DCMAKE_BUILD_TYPE=Debug" +-) make +-) make install (might need root) + +To use libmygpo-qt include the Header "ApiRequest.h" into your Code. You can find the cflags & linker flags for libmygpo-qt either via pkg-config (.pc file will be installed to your System) +or via cmake (Mygpo-qtConfig.cmake will be installed to your system). + +You can check the Example Application to see how you can use libmygpo-qt in your Application diff --git a/3rdparty/libmygpo-qt5/cmake/modules/FindQJSON.cmake b/3rdparty/libmygpo-qt5/cmake/modules/FindQJSON.cmake new file mode 100644 index 000000000..936d93b3c --- /dev/null +++ b/3rdparty/libmygpo-qt5/cmake/modules/FindQJSON.cmake @@ -0,0 +1,50 @@ +# Find QJSON - JSON handling library for Qt +# +# This module defines +# QJSON_FOUND - whether the qsjon library was found +# QJSON_LIBRARIES - the qjson library +# QJSON_INCLUDE_DIR - the include path of the qjson library +# + +if (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES) + + # Already in cache + set (QJSON_FOUND TRUE) + +else (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES) + + if (NOT WIN32) + # use pkg-config to get the values of QJSON_INCLUDE_DIRS + # and QJSON_LIBRARY_DIRS to add as hints to the find commands. + include (FindPkgConfig) + pkg_check_modules (QJSON REQUIRED QJson>=0.5) + endif (NOT WIN32) + + find_library (QJSON_LIBRARIES + NAMES + qjson + PATHS + ${QJSON_LIBRARY_DIRS} + ${LIB_INSTALL_DIR} + ${KDE4_LIB_DIR} + ) + + find_path (QJSON_INCLUDE_DIR + NAMES + parser.h + PATH_SUFFIXES + qjson + PATHS + ${QJSON_INCLUDE_DIRS} + ${INCLUDE_INSTALL_DIR} + ${KDE4_INCLUDE_DIR} + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(QJSON DEFAULT_MSG QJSON_LIBRARIES QJSON_INCLUDE_DIR) + + if ( UNIX AND NOT APPLE ) + set ( QJSON_LIBRARIES "${QJSON_LIBRARIES} ${QJSON_LDFLAGS}" CACHE INTERNAL "") + endif () + +endif (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES) diff --git a/3rdparty/libmygpo-qt/AddRemoveResult.cpp b/3rdparty/libmygpo-qt5/src/AddRemoveResult.cpp similarity index 97% rename from 3rdparty/libmygpo-qt/AddRemoveResult.cpp rename to 3rdparty/libmygpo-qt5/src/AddRemoveResult.cpp index 1127b0391..83c0c60db 100644 --- a/3rdparty/libmygpo-qt/AddRemoveResult.cpp +++ b/3rdparty/libmygpo-qt5/src/AddRemoveResult.cpp @@ -20,11 +20,11 @@ * USA * ***************************************************************************/ -#include - #include "AddRemoveResult.h" #include "AddRemoveResult_p.h" +#include "qjsonwrapper/Json.h" + using namespace mygpo; AddRemoveResultPrivate::AddRemoveResultPrivate( AddRemoveResult* qq, QNetworkReply* reply ) : q( qq ), m_reply( reply ), m_error( QNetworkReply::NoError ) @@ -64,7 +64,6 @@ QList< QPair< QUrl, QUrl > > AddRemoveResultPrivate::updateUrlsList() const bool AddRemoveResultPrivate::parse( const QVariant& data ) { - QJson::Parser parser; if( !data.canConvert( QVariant::Map ) ) return false; QVariantMap resultMap = data.toMap(); @@ -78,9 +77,8 @@ bool AddRemoveResultPrivate::parse( const QVariant& data ) bool AddRemoveResultPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); diff --git a/3rdparty/libmygpo-qt/AddRemoveResult.h b/3rdparty/libmygpo-qt5/src/AddRemoveResult.h similarity index 100% rename from 3rdparty/libmygpo-qt/AddRemoveResult.h rename to 3rdparty/libmygpo-qt5/src/AddRemoveResult.h diff --git a/3rdparty/libmygpo-qt/AddRemoveResult_p.h b/3rdparty/libmygpo-qt5/src/AddRemoveResult_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/AddRemoveResult_p.h rename to 3rdparty/libmygpo-qt5/src/AddRemoveResult_p.h diff --git a/3rdparty/libmygpo-qt/ApiRequest.cpp b/3rdparty/libmygpo-qt5/src/ApiRequest.cpp similarity index 99% rename from 3rdparty/libmygpo-qt/ApiRequest.cpp rename to 3rdparty/libmygpo-qt5/src/ApiRequest.cpp index b3c533f2a..469a7a1ff 100644 --- a/3rdparty/libmygpo-qt/ApiRequest.cpp +++ b/3rdparty/libmygpo-qt5/src/ApiRequest.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * This file is part of libmygpo-qt * -* Copyright (c) 2010 - 2013 Stefan Derkits * +* Copyright (c) 2010 - 2014 Stefan Derkits * * Copyright (c) 2010 - 2011 Christian Wagner * * Copyright (c) 2010 - 2011 Felix Winter * * * diff --git a/3rdparty/libmygpo-qt/ApiRequest.h b/3rdparty/libmygpo-qt5/src/ApiRequest.h similarity index 98% rename from 3rdparty/libmygpo-qt/ApiRequest.h rename to 3rdparty/libmygpo-qt5/src/ApiRequest.h index 982db49ba..c61119295 100644 --- a/3rdparty/libmygpo-qt/ApiRequest.h +++ b/3rdparty/libmygpo-qt5/src/ApiRequest.h @@ -1,6 +1,6 @@ /*************************************************************************** * This file is part of libmygpo-qt * -* Copyright (c) 2010 - 2013 Stefan Derkits * +* Copyright (c) 2010 - 2014 Stefan Derkits * * Copyright (c) 2010 - 2011 Christian Wagner * * Copyright (c) 2010 - 2011 Felix Winter * * * @@ -84,7 +84,7 @@ public: */ QNetworkReply* suggestionsOpml( uint count ); - QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device ); + QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device = QString() ); /** * Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists" @@ -111,7 +111,7 @@ public: */ QNetworkReply* suggestionsTxt( uint count ); - QNetworkReply* downloadSubscriptionsTxt( const QString& username, const QString& device ); + QNetworkReply* downloadSubscriptionsTxt( const QString& username, const QString& device = QString() ); /** * Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists" @@ -153,9 +153,9 @@ public: * */ PodcastListPtr suggestions( uint count ); - - QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device ); - + + QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device = QString() ); + //ADVANCED API /** diff --git a/3rdparty/libmygpo-qt/ApiRequest_p.h b/3rdparty/libmygpo-qt5/src/ApiRequest_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/ApiRequest_p.h rename to 3rdparty/libmygpo-qt5/src/ApiRequest_p.h diff --git a/3rdparty/libmygpo-qt/CMakeLists.txt b/3rdparty/libmygpo-qt5/src/CMakeLists.txt similarity index 67% rename from 3rdparty/libmygpo-qt/CMakeLists.txt rename to 3rdparty/libmygpo-qt5/src/CMakeLists.txt index c09d91448..98950a4ba 100644 --- a/3rdparty/libmygpo-qt/CMakeLists.txt +++ b/3rdparty/libmygpo-qt5/src/CMakeLists.txt @@ -1,11 +1,5 @@ -# Extra bits for Clementine. -set( MYGPO_QT_VERSION_MAJOR "1" ) -set( MYGPO_QT_VERSION_MINOR "0" ) -set( MYGPO_QT_VERSION_PATCH "7" ) -configure_file( Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/Version.h ) -include_directories("${QJSON_INCLUDEDIR}/qjson") -include_directories( ${QT_INCLUDES} ${QJSON_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${QJSON_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) set ( LIBMYGPO_QT_SRC Config.cpp @@ -27,6 +21,7 @@ set ( LIBMYGPO_QT_SRC DeviceUpdates.cpp DeviceList.cpp Device.cpp + qjsonwrapper/Json.cpp ) set ( LIBMYGPO_QT_MOC_H @@ -80,9 +75,9 @@ set ( LIBMYGPO_QT_INSTALL_H AddRemoveResult.h ) -QT4_WRAP_CPP(LIBMYGPO_QT_MOC_SRC ${LIBMYGPO_QT_MOC_H} ) +QT_WRAP_CPP(LIBMYGPO_QT_MOC_SRC ${LIBMYGPO_QT_MOC_H} ) -add_library( mygpo-qt STATIC ${LIBMYGPO_QT_SRC} ${LIBMYGPO_QT_MOC_SRC} ) +add_library( ${MYGPO_QT_TARGET_NAME} STATIC ${LIBMYGPO_QT_SRC} ${LIBMYGPO_QT_MOC_SRC} ) -target_link_libraries( mygpo-qt ${QJSON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} ) -set_target_properties( mygpo-qt PROPERTIES VERSION ${MYGPO_QT_VERSION} SOVERSION ${MYGPO_QT_SONAME} DEFINE_SYMBOL MYGPO_MAKEDLL) +target_link_libraries( ${MYGPO_QT_TARGET_NAME} ${QJSON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} ) +qt5_use_modules( ${MYGPO_QT_TARGET_NAME} Core Network ) diff --git a/3rdparty/libmygpo-qt/Config.cpp b/3rdparty/libmygpo-qt5/src/Config.cpp similarity index 100% rename from 3rdparty/libmygpo-qt/Config.cpp rename to 3rdparty/libmygpo-qt5/src/Config.cpp diff --git a/3rdparty/libmygpo-qt/Config.h b/3rdparty/libmygpo-qt5/src/Config.h similarity index 100% rename from 3rdparty/libmygpo-qt/Config.h rename to 3rdparty/libmygpo-qt5/src/Config.h diff --git a/3rdparty/libmygpo-qt/Config_p.h b/3rdparty/libmygpo-qt5/src/Config_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/Config_p.h rename to 3rdparty/libmygpo-qt5/src/Config_p.h diff --git a/3rdparty/libmygpo-qt/Device.cpp b/3rdparty/libmygpo-qt5/src/Device.cpp similarity index 100% rename from 3rdparty/libmygpo-qt/Device.cpp rename to 3rdparty/libmygpo-qt5/src/Device.cpp diff --git a/3rdparty/libmygpo-qt/Device.h b/3rdparty/libmygpo-qt5/src/Device.h similarity index 100% rename from 3rdparty/libmygpo-qt/Device.h rename to 3rdparty/libmygpo-qt5/src/Device.h diff --git a/3rdparty/libmygpo-qt/DeviceList.cpp b/3rdparty/libmygpo-qt5/src/DeviceList.cpp similarity index 97% rename from 3rdparty/libmygpo-qt/DeviceList.cpp rename to 3rdparty/libmygpo-qt5/src/DeviceList.cpp index 46defc258..e972318cc 100644 --- a/3rdparty/libmygpo-qt/DeviceList.cpp +++ b/3rdparty/libmygpo-qt5/src/DeviceList.cpp @@ -22,7 +22,7 @@ #include "DeviceList_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -73,9 +73,8 @@ bool DeviceListPrivate::parse( const QVariant& data ) bool DeviceListPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); diff --git a/3rdparty/libmygpo-qt/DeviceList.h b/3rdparty/libmygpo-qt5/src/DeviceList.h similarity index 100% rename from 3rdparty/libmygpo-qt/DeviceList.h rename to 3rdparty/libmygpo-qt5/src/DeviceList.h diff --git a/3rdparty/libmygpo-qt/DeviceList_p.h b/3rdparty/libmygpo-qt5/src/DeviceList_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/DeviceList_p.h rename to 3rdparty/libmygpo-qt5/src/DeviceList_p.h diff --git a/3rdparty/libmygpo-qt/DeviceSyncResult.cpp b/3rdparty/libmygpo-qt5/src/DeviceSyncResult.cpp similarity index 97% rename from 3rdparty/libmygpo-qt/DeviceSyncResult.cpp rename to 3rdparty/libmygpo-qt5/src/DeviceSyncResult.cpp index b71f05588..1ee70494e 100644 --- a/3rdparty/libmygpo-qt/DeviceSyncResult.cpp +++ b/3rdparty/libmygpo-qt5/src/DeviceSyncResult.cpp @@ -20,7 +20,7 @@ #include "DeviceSyncResult_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -85,9 +85,8 @@ bool DeviceSyncResultPrivate::parse( const QVariant& data ) bool DeviceSyncResultPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); @@ -108,7 +107,7 @@ void DeviceSyncResultPrivate::parseData() emit q->parseError(); } } - m_reply->deleteLater(); + m_reply->deleteLater(); } void DeviceSyncResultPrivate::error( QNetworkReply::NetworkError error ) diff --git a/3rdparty/libmygpo-qt/DeviceSyncResult.h b/3rdparty/libmygpo-qt5/src/DeviceSyncResult.h similarity index 100% rename from 3rdparty/libmygpo-qt/DeviceSyncResult.h rename to 3rdparty/libmygpo-qt5/src/DeviceSyncResult.h diff --git a/3rdparty/libmygpo-qt/DeviceSyncResult_p.h b/3rdparty/libmygpo-qt5/src/DeviceSyncResult_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/DeviceSyncResult_p.h rename to 3rdparty/libmygpo-qt5/src/DeviceSyncResult_p.h diff --git a/3rdparty/libmygpo-qt/DeviceUpdates.cpp b/3rdparty/libmygpo-qt5/src/DeviceUpdates.cpp similarity index 98% rename from 3rdparty/libmygpo-qt/DeviceUpdates.cpp rename to 3rdparty/libmygpo-qt5/src/DeviceUpdates.cpp index c74b52fcb..04653c569 100644 --- a/3rdparty/libmygpo-qt/DeviceUpdates.cpp +++ b/3rdparty/libmygpo-qt5/src/DeviceUpdates.cpp @@ -22,7 +22,7 @@ #include "DeviceUpdates_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -102,9 +102,8 @@ bool DeviceUpdatesPrivate::parse( const QVariant& data ) bool DeviceUpdatesPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); diff --git a/3rdparty/libmygpo-qt/DeviceUpdates.h b/3rdparty/libmygpo-qt5/src/DeviceUpdates.h similarity index 100% rename from 3rdparty/libmygpo-qt/DeviceUpdates.h rename to 3rdparty/libmygpo-qt5/src/DeviceUpdates.h diff --git a/3rdparty/libmygpo-qt/DeviceUpdates_p.h b/3rdparty/libmygpo-qt5/src/DeviceUpdates_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/DeviceUpdates_p.h rename to 3rdparty/libmygpo-qt5/src/DeviceUpdates_p.h diff --git a/3rdparty/libmygpo-qt/Device_p.h b/3rdparty/libmygpo-qt5/src/Device_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/Device_p.h rename to 3rdparty/libmygpo-qt5/src/Device_p.h diff --git a/3rdparty/libmygpo-qt/Episode.cpp b/3rdparty/libmygpo-qt5/src/Episode.cpp similarity index 98% rename from 3rdparty/libmygpo-qt/Episode.cpp rename to 3rdparty/libmygpo-qt5/src/Episode.cpp index 921b72f7d..196de323f 100644 --- a/3rdparty/libmygpo-qt/Episode.cpp +++ b/3rdparty/libmygpo-qt5/src/Episode.cpp @@ -22,7 +22,7 @@ #include "Episode_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -115,9 +115,8 @@ bool EpisodePrivate::parse ( const QVariant& data ) bool EpisodePrivate::parse ( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse ( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if ( ok ) { if ( !parse ( variant ) ) return false; diff --git a/3rdparty/libmygpo-qt/Episode.h b/3rdparty/libmygpo-qt5/src/Episode.h similarity index 100% rename from 3rdparty/libmygpo-qt/Episode.h rename to 3rdparty/libmygpo-qt5/src/Episode.h diff --git a/3rdparty/libmygpo-qt/EpisodeAction.cpp b/3rdparty/libmygpo-qt5/src/EpisodeAction.cpp similarity index 98% rename from 3rdparty/libmygpo-qt/EpisodeAction.cpp rename to 3rdparty/libmygpo-qt5/src/EpisodeAction.cpp index ad1f0e5e3..95536be02 100644 --- a/3rdparty/libmygpo-qt/EpisodeAction.cpp +++ b/3rdparty/libmygpo-qt5/src/EpisodeAction.cpp @@ -22,7 +22,7 @@ #include "EpisodeAction_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -163,9 +163,8 @@ bool EpisodeActionPrivate::parseActionType( const QString& data ) bool EpisodeActionPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { if( !parse( variant ) ) return false; diff --git a/3rdparty/libmygpo-qt/EpisodeAction.h b/3rdparty/libmygpo-qt5/src/EpisodeAction.h similarity index 100% rename from 3rdparty/libmygpo-qt/EpisodeAction.h rename to 3rdparty/libmygpo-qt5/src/EpisodeAction.h diff --git a/3rdparty/libmygpo-qt/EpisodeActionList.cpp b/3rdparty/libmygpo-qt5/src/EpisodeActionList.cpp similarity index 98% rename from 3rdparty/libmygpo-qt/EpisodeActionList.cpp rename to 3rdparty/libmygpo-qt5/src/EpisodeActionList.cpp index 426f0e895..4c221cc7a 100644 --- a/3rdparty/libmygpo-qt/EpisodeActionList.cpp +++ b/3rdparty/libmygpo-qt5/src/EpisodeActionList.cpp @@ -22,7 +22,7 @@ #include "EpisodeActionList_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -88,9 +88,8 @@ bool EpisodeActionListPrivate::parse( const QVariant& data ) bool EpisodeActionListPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); diff --git a/3rdparty/libmygpo-qt/EpisodeActionList.h b/3rdparty/libmygpo-qt5/src/EpisodeActionList.h similarity index 100% rename from 3rdparty/libmygpo-qt/EpisodeActionList.h rename to 3rdparty/libmygpo-qt5/src/EpisodeActionList.h diff --git a/3rdparty/libmygpo-qt/EpisodeActionList_p.h b/3rdparty/libmygpo-qt5/src/EpisodeActionList_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/EpisodeActionList_p.h rename to 3rdparty/libmygpo-qt5/src/EpisodeActionList_p.h diff --git a/3rdparty/libmygpo-qt/EpisodeAction_p.h b/3rdparty/libmygpo-qt5/src/EpisodeAction_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/EpisodeAction_p.h rename to 3rdparty/libmygpo-qt5/src/EpisodeAction_p.h diff --git a/3rdparty/libmygpo-qt/EpisodeList.cpp b/3rdparty/libmygpo-qt5/src/EpisodeList.cpp similarity index 97% rename from 3rdparty/libmygpo-qt/EpisodeList.cpp rename to 3rdparty/libmygpo-qt5/src/EpisodeList.cpp index e003f2333..6a9de5de3 100644 --- a/3rdparty/libmygpo-qt/EpisodeList.cpp +++ b/3rdparty/libmygpo-qt5/src/EpisodeList.cpp @@ -22,7 +22,7 @@ #include "EpisodeList_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -71,9 +71,8 @@ bool EpisodeListPrivate::parse( const QVariant& data ) bool EpisodeListPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); diff --git a/3rdparty/libmygpo-qt/EpisodeList.h b/3rdparty/libmygpo-qt5/src/EpisodeList.h similarity index 100% rename from 3rdparty/libmygpo-qt/EpisodeList.h rename to 3rdparty/libmygpo-qt5/src/EpisodeList.h diff --git a/3rdparty/libmygpo-qt/EpisodeList_p.h b/3rdparty/libmygpo-qt5/src/EpisodeList_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/EpisodeList_p.h rename to 3rdparty/libmygpo-qt5/src/EpisodeList_p.h diff --git a/3rdparty/libmygpo-qt/Episode_p.h b/3rdparty/libmygpo-qt5/src/Episode_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/Episode_p.h rename to 3rdparty/libmygpo-qt5/src/Episode_p.h diff --git a/3rdparty/libmygpo-qt/JsonCreator.cpp b/3rdparty/libmygpo-qt5/src/JsonCreator.cpp similarity index 94% rename from 3rdparty/libmygpo-qt/JsonCreator.cpp rename to 3rdparty/libmygpo-qt5/src/JsonCreator.cpp index fc148a0f6..9c4f0bcc4 100644 --- a/3rdparty/libmygpo-qt/JsonCreator.cpp +++ b/3rdparty/libmygpo-qt5/src/JsonCreator.cpp @@ -20,47 +20,44 @@ * USA * ***************************************************************************/ -#include +//#include #include #include #include #include -#include - #include "JsonCreator.h" +#include "qjsonwrapper/Json.h" + using namespace mygpo; static qulonglong c_maxlonglong = (2^64)-1; QByteArray JsonCreator::addRemoveSubsToJSON( const QList< QUrl >& add, const QList< QUrl >& remove ) { - QJson::Serializer serializer; QVariantMap jsonData; QVariant addVar( urlListToQVariantList( add ) ); QVariant removeVar( urlListToQVariantList( remove ) ); jsonData.insert( QString( QLatin1String( "add" ) ), addVar ); jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar ); - QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) ); + QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) ); return jsonByteArray; } QByteArray JsonCreator::saveSettingsToJSON( const QMap< QString, QVariant >& set, const QList< QString >& remove ) { - QJson::Serializer serializer; QVariantMap jsonData; //QVariant setVar(stringMapToQVariantMap(set)); QVariant removeVar( stringListToQVariantList( remove ) ); jsonData.insert( QString( QLatin1String( "set" ) ), set ); jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar ); - QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) ); + QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) ); return jsonByteArray; } QByteArray JsonCreator::episodeActionListToJSON( const QList& episodeActions ) { - QJson::Serializer serializer; QVariantList jsonData; foreach( const EpisodeActionPtr episodeAction, episodeActions ) @@ -68,19 +65,18 @@ QByteArray JsonCreator::episodeActionListToJSON( const QList& jsonData.append( episodeActionToQVariantMap( episodeAction ) ); } - QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) ); + QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) ); return jsonByteArray; } QByteArray JsonCreator::renameDeviceStringToJSON( const QString& caption, const QString& type ) { - QJson::Serializer serializer; QVariantMap jsonData; QVariant captionVar( caption ); QVariant typeVar( type ); jsonData.insert( QString( QLatin1String( "caption" ) ), captionVar ); jsonData.insert( QString( QLatin1String( "type" ) ), typeVar ); - QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) ); + QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) ); return jsonByteArray; } @@ -130,7 +126,7 @@ QByteArray JsonCreator::deviceSynchronizationListsToJSON(const QList< QStringLis jsonStr.append(syncVar); jsonStr.append(QLatin1String(" ,\"stop-synchronize\" : ")); jsonStr.append(stopVar); - jsonStr.append(QLatin1String(" }\n")); + jsonStr.append(QLatin1String(" }")); return jsonStr.toLocal8Bit(); } diff --git a/3rdparty/libmygpo-qt/JsonCreator.h b/3rdparty/libmygpo-qt5/src/JsonCreator.h similarity index 100% rename from 3rdparty/libmygpo-qt/JsonCreator.h rename to 3rdparty/libmygpo-qt5/src/JsonCreator.h diff --git a/3rdparty/libmygpo-qt/Podcast.cpp b/3rdparty/libmygpo-qt5/src/Podcast.cpp similarity index 97% rename from 3rdparty/libmygpo-qt/Podcast.cpp rename to 3rdparty/libmygpo-qt5/src/Podcast.cpp index 589505452..bad7900dc 100644 --- a/3rdparty/libmygpo-qt/Podcast.cpp +++ b/3rdparty/libmygpo-qt5/src/Podcast.cpp @@ -22,7 +22,7 @@ #include "Podcast_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -181,9 +181,8 @@ bool PodcastPrivate::parse( const QVariant& data ) bool PodcastPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if ( ok ) { if ( !parse( variant ) ) return false; @@ -197,8 +196,6 @@ bool PodcastPrivate::parse( const QByteArray& data ) void PodcastPrivate::parseData() { - //parsen und signal senden - QJson::Parser parser; if ( parse( m_reply->readAll( ) ) ) { emit q->finished(); diff --git a/3rdparty/libmygpo-qt/Podcast.h b/3rdparty/libmygpo-qt5/src/Podcast.h similarity index 100% rename from 3rdparty/libmygpo-qt/Podcast.h rename to 3rdparty/libmygpo-qt5/src/Podcast.h diff --git a/3rdparty/libmygpo-qt/PodcastList.cpp b/3rdparty/libmygpo-qt5/src/PodcastList.cpp similarity index 97% rename from 3rdparty/libmygpo-qt/PodcastList.cpp rename to 3rdparty/libmygpo-qt5/src/PodcastList.cpp index 7e2d9c4a4..fbd398796 100644 --- a/3rdparty/libmygpo-qt/PodcastList.cpp +++ b/3rdparty/libmygpo-qt5/src/PodcastList.cpp @@ -22,7 +22,7 @@ #include "PodcastList_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -71,9 +71,8 @@ bool PodcastListPrivate::parse( const QVariant& data ) bool PodcastListPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); diff --git a/3rdparty/libmygpo-qt/PodcastList.h b/3rdparty/libmygpo-qt5/src/PodcastList.h similarity index 100% rename from 3rdparty/libmygpo-qt/PodcastList.h rename to 3rdparty/libmygpo-qt5/src/PodcastList.h diff --git a/3rdparty/libmygpo-qt/PodcastList_p.h b/3rdparty/libmygpo-qt5/src/PodcastList_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/PodcastList_p.h rename to 3rdparty/libmygpo-qt5/src/PodcastList_p.h diff --git a/3rdparty/libmygpo-qt/Podcast_p.h b/3rdparty/libmygpo-qt5/src/Podcast_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/Podcast_p.h rename to 3rdparty/libmygpo-qt5/src/Podcast_p.h diff --git a/3rdparty/libmygpo-qt/RequestHandler.cpp b/3rdparty/libmygpo-qt5/src/RequestHandler.cpp similarity index 99% rename from 3rdparty/libmygpo-qt/RequestHandler.cpp rename to 3rdparty/libmygpo-qt5/src/RequestHandler.cpp index dea1a62db..af504c5c5 100644 --- a/3rdparty/libmygpo-qt/RequestHandler.cpp +++ b/3rdparty/libmygpo-qt5/src/RequestHandler.cpp @@ -77,5 +77,5 @@ void RequestHandler::addAuthData( QNetworkRequest& request ) void RequestHandler::addUserAgent( QNetworkRequest &request ) { - request.setRawHeader("User-Agent", Config::instance()->userAgent().toAscii() ); + request.setRawHeader("User-Agent", Config::instance()->userAgent().toLatin1() ); } diff --git a/3rdparty/libmygpo-qt/RequestHandler.h b/3rdparty/libmygpo-qt5/src/RequestHandler.h similarity index 100% rename from 3rdparty/libmygpo-qt/RequestHandler.h rename to 3rdparty/libmygpo-qt5/src/RequestHandler.h diff --git a/3rdparty/libmygpo-qt/Settings.cpp b/3rdparty/libmygpo-qt5/src/Settings.cpp similarity index 96% rename from 3rdparty/libmygpo-qt/Settings.cpp rename to 3rdparty/libmygpo-qt5/src/Settings.cpp index a9045d9a1..c27e01c87 100644 --- a/3rdparty/libmygpo-qt/Settings.cpp +++ b/3rdparty/libmygpo-qt5/src/Settings.cpp @@ -22,7 +22,7 @@ #include "Settings_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -49,9 +49,8 @@ bool SettingsPrivate::parse( const QVariant& data ) bool SettingsPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); @@ -63,7 +62,6 @@ void SettingsPrivate::parseData() { if( m_reply->error() == QNetworkReply::NoError ) { - QJson::Parser parser; if( parse( m_reply->readAll() ) ) { emit q->finished(); diff --git a/3rdparty/libmygpo-qt/Settings.h b/3rdparty/libmygpo-qt5/src/Settings.h similarity index 100% rename from 3rdparty/libmygpo-qt/Settings.h rename to 3rdparty/libmygpo-qt5/src/Settings.h diff --git a/3rdparty/libmygpo-qt/Settings_p.h b/3rdparty/libmygpo-qt5/src/Settings_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/Settings_p.h rename to 3rdparty/libmygpo-qt5/src/Settings_p.h diff --git a/3rdparty/libmygpo-qt/Tag.cpp b/3rdparty/libmygpo-qt5/src/Tag.cpp similarity index 100% rename from 3rdparty/libmygpo-qt/Tag.cpp rename to 3rdparty/libmygpo-qt5/src/Tag.cpp diff --git a/3rdparty/libmygpo-qt/Tag.h b/3rdparty/libmygpo-qt5/src/Tag.h similarity index 100% rename from 3rdparty/libmygpo-qt/Tag.h rename to 3rdparty/libmygpo-qt5/src/Tag.h diff --git a/3rdparty/libmygpo-qt/TagList.cpp b/3rdparty/libmygpo-qt5/src/TagList.cpp similarity index 97% rename from 3rdparty/libmygpo-qt/TagList.cpp rename to 3rdparty/libmygpo-qt5/src/TagList.cpp index d975a7273..4c19749cf 100644 --- a/3rdparty/libmygpo-qt/TagList.cpp +++ b/3rdparty/libmygpo-qt5/src/TagList.cpp @@ -22,7 +22,7 @@ #include "TagList_p.h" -#include +#include "qjsonwrapper/Json.h" using namespace mygpo; @@ -70,9 +70,8 @@ bool TagListPrivate::parse( const QVariant& data ) bool TagListPrivate::parse( const QByteArray& data ) { - QJson::Parser parser; bool ok; - QVariant variant = parser.parse( data, &ok ); + QVariant variant = QJsonWrapper::parseJson( data, &ok ); if( ok ) { ok = ( parse( variant ) ); diff --git a/3rdparty/libmygpo-qt/TagList.h b/3rdparty/libmygpo-qt5/src/TagList.h similarity index 100% rename from 3rdparty/libmygpo-qt/TagList.h rename to 3rdparty/libmygpo-qt5/src/TagList.h diff --git a/3rdparty/libmygpo-qt/TagList_p.h b/3rdparty/libmygpo-qt5/src/TagList_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/TagList_p.h rename to 3rdparty/libmygpo-qt5/src/TagList_p.h diff --git a/3rdparty/libmygpo-qt/Tag_p.h b/3rdparty/libmygpo-qt5/src/Tag_p.h similarity index 100% rename from 3rdparty/libmygpo-qt/Tag_p.h rename to 3rdparty/libmygpo-qt5/src/Tag_p.h diff --git a/3rdparty/libmygpo-qt/UrlBuilder.cpp b/3rdparty/libmygpo-qt5/src/UrlBuilder.cpp similarity index 98% rename from 3rdparty/libmygpo-qt/UrlBuilder.cpp rename to 3rdparty/libmygpo-qt5/src/UrlBuilder.cpp index e0ba7649a..eebcc3060 100644 --- a/3rdparty/libmygpo-qt/UrlBuilder.cpp +++ b/3rdparty/libmygpo-qt5/src/UrlBuilder.cpp @@ -74,7 +74,8 @@ QString UrlBuilder::getPodcastSearchUrl( const QString& query, Format f ) QString UrlBuilder::getSubscriptionsUrl( const QString& username, const QString& device, UrlBuilder::Format f) { - return s_server % QLatin1String( "/subscriptions/" ) % username % QLatin1String( "/" ) % device % getFormatExtension( f ); + QString deviceString = device.isNull() ? QString(QLatin1String("")) : (QLatin1String( "/" ) % device); + return s_server % QLatin1String( "/subscriptions/" ) % username % deviceString % getFormatExtension( f ); } QString UrlBuilder::getTopTagsUrl( uint i ) diff --git a/3rdparty/libmygpo-qt/UrlBuilder.h b/3rdparty/libmygpo-qt5/src/UrlBuilder.h similarity index 100% rename from 3rdparty/libmygpo-qt/UrlBuilder.h rename to 3rdparty/libmygpo-qt5/src/UrlBuilder.h diff --git a/3rdparty/libmygpo-qt/Version.h.in b/3rdparty/libmygpo-qt5/src/Version.h.in similarity index 100% rename from 3rdparty/libmygpo-qt/Version.h.in rename to 3rdparty/libmygpo-qt5/src/Version.h.in diff --git a/3rdparty/libmygpo-qt/mygpo_export.h b/3rdparty/libmygpo-qt5/src/mygpo_export.h similarity index 100% rename from 3rdparty/libmygpo-qt/mygpo_export.h rename to 3rdparty/libmygpo-qt5/src/mygpo_export.h diff --git a/3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.cpp b/3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.cpp new file mode 100644 index 000000000..4a8c2ac36 --- /dev/null +++ b/3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.cpp @@ -0,0 +1,123 @@ +/* Copyright 2014, Uwe L. Korn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "Json.h" + +// Qt version specific includes +#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) + #include + #include +#else + #include + #include + #include +#endif + +namespace QJsonWrapper +{ + +QVariantMap +qobject2qvariant( const QObject* object ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) + QVariantMap map; + if ( object == NULL ) + { + return map; + } + + const QMetaObject* metaObject = object->metaObject(); + for ( int i = 0; i < metaObject->propertyCount(); ++i ) + { + QMetaProperty metaproperty = metaObject->property( i ); + if ( metaproperty.isReadable() ) + { + map[ QLatin1String( metaproperty.name() ) ] = object->property( metaproperty.name() ); + } + } + return map; +#else + return QJson::QObjectHelper::qobject2qvariant( object ); +#endif +} + + +void +qvariant2qobject( const QVariantMap& variant, QObject* object ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) + for ( QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter ) + { + QVariant property = object->property( iter.key().toLatin1() ); + Q_ASSERT( property.isValid() ); + if ( property.isValid() ) + { + QVariant value = iter.value(); + if ( value.canConvert( property.type() ) ) + { + value.convert( property.type() ); + object->setProperty( iter.key().toLatin1(), value ); + } else if ( QString( QLatin1String("QVariant") ).compare( QLatin1String( property.typeName() ) ) == 0 ) { + object->setProperty( iter.key().toLatin1(), value ); + } + } + } +#else + QJson::QObjectHelper::qvariant2qobject( variant, object ); +#endif +} + + +QVariant +parseJson( const QByteArray& jsonData, bool* ok ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) + QJsonParseError error; + QJsonDocument doc = QJsonDocument::fromJson( jsonData, &error ); + if ( ok != NULL ) + { + *ok = ( error.error == QJsonParseError::NoError ); + } + return doc.toVariant(); +#else + QJson::Parser p; + return p.parse( jsonData, ok ); +#endif +} + + +QByteArray +toJson( const QVariant &variant, bool* ok ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) + QJsonDocument doc = QJsonDocument::fromVariant( variant ); + if ( ok != NULL ) + { + *ok = !doc.isNull(); + } + return doc.toJson( QJsonDocument::Compact ); +#else + QJson::Serializer serializer; + return serializer.serialize( variant, ok ); +#endif +} + +} diff --git a/3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.h b/3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.h new file mode 100644 index 000000000..36d53a0f9 --- /dev/null +++ b/3rdparty/libmygpo-qt5/src/qjsonwrapper/Json.h @@ -0,0 +1,36 @@ +/* Copyright 2014, Uwe L. Korn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once +#ifndef QJSONWRAPPER_JSON_H +#define QJSONWRAPPER_JSON_H + +#include + +namespace QJsonWrapper +{ + QVariantMap qobject2qvariant( const QObject* object ); + void qvariant2qobject( const QVariantMap& variant, QObject* object ); + QVariant parseJson( const QByteArray& jsonData, bool* ok = 0 ); + QByteArray toJson( const QVariant &variant, bool* ok = 0 ); +} + +#endif // QJSONWRAPPER_JSON_H From 11938e3d79d4952b87831100898baaf0f78d7700 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:45:04 +0200 Subject: [PATCH 03/17] Update of qsqlite (Qt 5.0.0 version) --- 3rdparty/qsqlite/CMakeLists.txt | 11 +- .../qsqlite/clementinesqlcachedresult.cpp | 65 ++++--- 3rdparty/qsqlite/clementinesqlcachedresult.h | 63 ++++--- 3rdparty/qsqlite/qsql_sqlite.cpp | 171 +++++++++++------- 3rdparty/qsqlite/qsql_sqlite.h | 27 +-- 3rdparty/qsqlite/qsqlite.json | 3 + 3rdparty/qsqlite/smain.cpp | 65 ++----- 3rdparty/qsqlite/smain.h | 51 ++++++ 3rdparty/qsqlite/smain.patch | 11 -- 9 files changed, 278 insertions(+), 189 deletions(-) create mode 100644 3rdparty/qsqlite/qsqlite.json create mode 100644 3rdparty/qsqlite/smain.h delete mode 100644 3rdparty/qsqlite/smain.patch diff --git a/3rdparty/qsqlite/CMakeLists.txt b/3rdparty/qsqlite/CMakeLists.txt index 48ac16161..cd958d93c 100644 --- a/3rdparty/qsqlite/CMakeLists.txt +++ b/3rdparty/qsqlite/CMakeLists.txt @@ -5,18 +5,19 @@ add_definitions(-DQT_STATICPLUGIN) # Source files set(SQLITE-SOURCES qsql_sqlite.cpp - smain.cpp clementinesqlcachedresult.cpp + smain.cpp ) # Header files that have Q_OBJECT in set(SQLITE-MOC-HEADERS qsql_sqlite.h + smain.h ) set(SQLITE-WIN32-RESOURCES qsqlite_resource.rc) -qt4_wrap_cpp(SQLITE-SOURCES-MOC ${SQLITE-MOC-HEADERS}) +qt5_wrap_cpp(SQLITE-SOURCES-MOC ${SQLITE-MOC-HEADERS}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) @@ -40,7 +41,9 @@ add_library(qsqlite STATIC ${SQLITE-SOURCES-MOC} ${SQLITE-WIN32-RESOURCES} ) + +set_property(TARGET qsqlite PROPERTY QT_STATICPLUGIN 1) + target_link_libraries(qsqlite - ${SQLITE_LIBRARIES} - ${QT_LIBRARIES} + Qt5::Core Qt5::Sql ) diff --git a/3rdparty/qsqlite/clementinesqlcachedresult.cpp b/3rdparty/qsqlite/clementinesqlcachedresult.cpp index adca3ffec..5b3d4c1f7 100644 --- a/3rdparty/qsqlite/clementinesqlcachedresult.cpp +++ b/3rdparty/qsqlite/clementinesqlcachedresult.cpp @@ -1,17 +1,18 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtSql module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,30 +22,31 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "clementinesqlcachedresult.h" - #include #include #include +#include "clementinesqlcachedresult.h" + +QT_BEGIN_NAMESPACE + /* ClementineSqlCachedResult is a convenience class for databases that only allow forward only fetching. It will cache all the results so we can iterate @@ -302,12 +304,19 @@ ClementineSqlCachedResult::ValueCache &ClementineSqlCachedResult::cache() void ClementineSqlCachedResult::virtual_hook(int id, void *data) { - switch (id) { - case QSqlResult::DetachFromResultSet: - case QSqlResult::SetNumericalPrecision: - cleanup(); - break; - default: - QSqlResult::virtual_hook(id, data); - } + QSqlResult::virtual_hook(id, data); } + +void ClementineSqlCachedResult::detachFromResultSet() +{ + cleanup(); +} + +void ClementineSqlCachedResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) +{ + QSqlResult::setNumericalPrecisionPolicy(policy); + cleanup(); +} + + +QT_END_NAMESPACE diff --git a/3rdparty/qsqlite/clementinesqlcachedresult.h b/3rdparty/qsqlite/clementinesqlcachedresult.h index 1951789da..7447f2605 100644 --- a/3rdparty/qsqlite/clementinesqlcachedresult.h +++ b/3rdparty/qsqlite/clementinesqlcachedresult.h @@ -1,17 +1,18 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtSql module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,35 +22,47 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef CLEMENTINECACHEDRESULT_P_H -#define CLEMENTINECACHEDRESULT_P_H +#ifndef QSQLCACHEDRESULT_P_H +#define QSQLCACHEDRESULT_P_H -#include +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtSql/qsqlresult.h" + +QT_BEGIN_NAMESPACE class QVariant; template class QVector; class ClementineSqlCachedResultPrivate; -class ClementineSqlCachedResult: public QSqlResult +class Q_SQL_EXPORT ClementineSqlCachedResult: public QSqlResult { public: virtual ~ClementineSqlCachedResult(); @@ -77,9 +90,13 @@ protected: ValueCache &cache(); void virtual_hook(int id, void *data); + void detachFromResultSet(); + void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy); private: bool cacheNext(); ClementineSqlCachedResultPrivate *d; }; -#endif // CLEMENTINESQLCACHEDRESULT_P_H +QT_END_NAMESPACE + +#endif // QSQLCACHEDRESULT_P_H diff --git a/3rdparty/qsqlite/qsql_sqlite.cpp b/3rdparty/qsqlite/qsql_sqlite.cpp index c7caae1b1..33d022848 100644 --- a/3rdparty/qsqlite/qsql_sqlite.cpp +++ b/3rdparty/qsqlite/qsql_sqlite.cpp @@ -1,17 +1,18 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtSql module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,8 +22,8 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage @@ -33,8 +34,7 @@ ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -59,7 +59,10 @@ #include +Q_DECLARE_OPAQUE_POINTER(sqlite3*) Q_DECLARE_METATYPE(sqlite3*) + +Q_DECLARE_OPAQUE_POINTER(sqlite3_stmt*) Q_DECLARE_METATYPE(sqlite3_stmt*) QT_BEGIN_NAMESPACE @@ -84,10 +87,14 @@ static QVariant::Type qGetColumnType(const QString &tpName) return QVariant::Int; if (typeName == QLatin1String("double") || typeName == QLatin1String("float") + || typeName == QLatin1String("real") || typeName.startsWith(QLatin1String("numeric"))) return QVariant::Double; if (typeName == QLatin1String("blob")) return QVariant::ByteArray; + if (typeName == QLatin1String("boolean") + || typeName == QLatin1String("bool")) + return QVariant::Bool; return QVariant::String; } @@ -95,7 +102,7 @@ static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::Er int errorCode = -1) { return QSqlError(descr, - QString::fromUtf16(static_cast(sqlite3_errmsg16(access))), + QString(reinterpret_cast(sqlite3_errmsg16(access))), type, errorCode); } @@ -104,6 +111,7 @@ class QSQLiteDriverPrivate public: inline QSQLiteDriverPrivate() : access(0) {} sqlite3 *access; + QList results; }; @@ -162,19 +170,44 @@ void QSQLiteResultPrivate::initColumns(bool emptyResultset) q->init(nCols); for (int i = 0; i < nCols; ++i) { - QString colName = QString::fromUtf16( - static_cast(sqlite3_column_name16(stmt, i)) + QString colName = QString(reinterpret_cast( + sqlite3_column_name16(stmt, i)) ).remove(QLatin1Char('"')); // must use typeName for resolving the type to match QSqliteDriver::record - QString typeName = QString::fromUtf16( - static_cast(sqlite3_column_decltype16(stmt, i))); - - int dotIdx = colName.lastIndexOf(QLatin1Char('.')); - QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(typeName)); - + QString typeName = QString(reinterpret_cast( + sqlite3_column_decltype16(stmt, i))); // sqlite3_column_type is documented to have undefined behavior if the result set is empty int stp = emptyResultset ? -1 : sqlite3_column_type(stmt, i); + + QVariant::Type fieldType; + + if (!typeName.isEmpty()) { + fieldType = qGetColumnType(typeName); + } else { + // Get the proper type for the field based on stp value + switch (stp) { + case SQLITE_INTEGER: + fieldType = QVariant::Int; + break; + case SQLITE_FLOAT: + fieldType = QVariant::Double; + break; + case SQLITE_BLOB: + fieldType = QVariant::ByteArray; + break; + case SQLITE_TEXT: + fieldType = QVariant::String; + break; + case SQLITE_NULL: + default: + fieldType = QVariant::Invalid; + break; + } + } + + int dotIdx = colName.lastIndexOf(QLatin1Char('.')); + QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), fieldType); fld.setSqlType(stp); rInf.append(fld); } @@ -245,9 +278,9 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu values[i + idx] = QVariant(QVariant::String); break; default: - values[i + idx] = QString::fromUtf16(static_cast( + values[i + idx] = QString(reinterpret_cast( sqlite3_column_text16(stmt, i)), - sqlite3_column_bytes16(stmt, i) / sizeof(ushort)); + sqlite3_column_bytes16(stmt, i) / sizeof(QChar)); break; } } @@ -259,6 +292,7 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu q->setAt(QSql::AfterLastRow); sqlite3_reset(stmt); return false; + case SQLITE_CONSTRAINT: case SQLITE_ERROR: // SQLITE_ERROR is a generic error code and we must call sqlite3_reset() // to get the specific error message. @@ -285,24 +319,21 @@ QSQLiteResult::QSQLiteResult(const QSQLiteDriver* db) { d = new QSQLiteResultPrivate(this); d->access = db->d->access; + db->d->results.append(this); } QSQLiteResult::~QSQLiteResult() { + const QSqlDriver *sqlDriver = driver(); + if (sqlDriver) + qobject_cast(sqlDriver)->d->results.removeOne(this); d->cleanup(); delete d; } void QSQLiteResult::virtual_hook(int id, void *data) { - switch (id) { - case QSqlResult::DetachFromResultSet: - if (d->stmt) - sqlite3_reset(d->stmt); - break; - default: - ClementineSqlCachedResult::virtual_hook(id, data); - } + ClementineSqlCachedResult::virtual_hook(id, data); } bool QSQLiteResult::reset(const QString &query) @@ -321,12 +352,14 @@ bool QSQLiteResult::prepare(const QString &query) setSelect(false); + const void *pzTail = NULL; + #if (SQLITE_VERSION_NUMBER >= 3003011) int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), - &d->stmt, 0); + &d->stmt, &pzTail); #else int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), - &d->stmt, 0); + &d->stmt, &pzTail); #endif if (res != SQLITE_OK) { @@ -334,6 +367,11 @@ bool QSQLiteResult::prepare(const QString &query) "Unable to execute statement"), QSqlError::StatementError, res)); d->finalize(); return false; + } else if (pzTail && !QString(reinterpret_cast(pzTail)).trimmed().isEmpty()) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult", + "Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE)); + d->finalize(); + return false; } return true; } @@ -371,6 +409,7 @@ bool QSQLiteResult::exec() ba->size(), SQLITE_STATIC); break; } case QVariant::Int: + case QVariant::Bool: res = sqlite3_bind_int(d->stmt, i + 1, value.toInt()); break; case QVariant::Double: @@ -403,7 +442,7 @@ bool QSQLiteResult::exec() } } else { setLastError(QSqlError(QCoreApplication::translate("QSQLiteResult", - "Parameter count mismatch"), QString(), QSqlError::StatementError)); + "Parameter count mismatch") + QString::number(paramCount, 10) + "/" + QString::number(values.count(), 10), QString(), QSqlError::StatementError)); return false; } d->skippedStatus = d->fetchNext(d->firstRow, 0, true); @@ -449,9 +488,15 @@ QSqlRecord QSQLiteResult::record() const return d->rInf; } +void QSQLiteResult::detachFromResultSet() +{ + if (d->stmt) + sqlite3_reset(d->stmt); +} + QVariant QSQLiteResult::handle() const { - return qVariantFromValue(d->stmt); + return QVariant::fromValue(d->stmt); } ///////////////////////////////////////////////////////// @@ -500,32 +545,6 @@ bool QSQLiteDriver::hasFeature(DriverFeature f) const return false; } -static int qGetSqliteTimeout(QString opts) -{ - enum { DefaultTimeout = 5000 }; - - opts.remove(QLatin1Char(' ')); - foreach(QString option, opts.split(QLatin1Char(';'))) { - if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) { - bool ok; - int nt = option.mid(21).toInt(&ok); - if (ok) - return nt; - } - } - return DefaultTimeout; -} - -static int qGetSqliteOpenMode(QString opts) -{ - opts.remove(QLatin1Char(' ')); - foreach(QString option, opts.split(QLatin1Char(';'))) { - if (option == QLatin1String("QSQLITE_OPEN_READONLY")) - return SQLITE_OPEN_READONLY; - } - return SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; -} - /* SQLite dbs have no user name, passwords, hosts or ports. just file names. @@ -537,13 +556,35 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c if (db.isEmpty()) return false; + bool sharedCache = false; + int openMode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, timeOut=5000; + QStringList opts=QString(conOpts).remove(QLatin1Char(' ')).split(QLatin1Char(';')); + foreach(const QString &option, opts) { + if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) { + bool ok; + int nt = option.mid(21).toInt(&ok); + if (ok) + timeOut = nt; + } + if (option == QLatin1String("QSQLITE_OPEN_READONLY")) + openMode = SQLITE_OPEN_READONLY; + if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE")) + sharedCache = true; + } - if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, qGetSqliteOpenMode(conOpts), NULL) == SQLITE_OK) { - sqlite3_busy_timeout(d->access, qGetSqliteTimeout(conOpts)); + sqlite3_enable_shared_cache(sharedCache); + + if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) { + sqlite3_busy_timeout(d->access, timeOut); setOpen(true); setOpenError(false); return true; } else { + if (d->access) { + sqlite3_close(d->access); + d->access = 0; + } + setLastError(qMakeError(d->access, tr("Error opening database"), QSqlError::ConnectionError)); setOpenError(true); @@ -554,6 +595,10 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c void QSQLiteDriver::close() { if (isOpen()) { + foreach (QSQLiteResult *result, d->results) { + result->d->finalize(); + } + if (sqlite3_close(d->access) != SQLITE_OK) setLastError(qMakeError(d->access, tr("Error closing database"), QSqlError::ConnectionError)); @@ -705,7 +750,7 @@ QSqlRecord QSQLiteDriver::record(const QString &tbl) const QVariant QSQLiteDriver::handle() const { - return qVariantFromValue(d->access); + return QVariant::fromValue(d->access); } QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const diff --git a/3rdparty/qsqlite/qsql_sqlite.h b/3rdparty/qsqlite/qsql_sqlite.h index f949aefe8..78db7303b 100644 --- a/3rdparty/qsqlite/qsql_sqlite.h +++ b/3rdparty/qsqlite/qsql_sqlite.h @@ -1,17 +1,18 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtSql module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,8 +22,8 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage @@ -33,8 +34,7 @@ ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -42,8 +42,8 @@ #ifndef QSQL_SQLITE_H #define QSQL_SQLITE_H -#include -#include +#include +#include #include "clementinesqlcachedresult.h" struct sqlite3; @@ -79,6 +79,7 @@ protected: int numRowsAffected(); QVariant lastInsertId() const; QSqlRecord record() const; + void detachFromResultSet(); void virtual_hook(int id, void *data); private: diff --git a/3rdparty/qsqlite/qsqlite.json b/3rdparty/qsqlite/qsqlite.json new file mode 100644 index 000000000..0c105eade --- /dev/null +++ b/3rdparty/qsqlite/qsqlite.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QSQLITE" ] +} diff --git a/3rdparty/qsqlite/smain.cpp b/3rdparty/qsqlite/smain.cpp index 4fb132b5e..35b6b5d71 100644 --- a/3rdparty/qsqlite/smain.cpp +++ b/3rdparty/qsqlite/smain.cpp @@ -1,59 +1,40 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include -#include -#include "qsql_sqlite.h" +#include "smain.h" QT_BEGIN_NAMESPACE -class QSQLiteDriverPlugin : public QSqlDriverPlugin -{ -public: - QSQLiteDriverPlugin(); - - QSqlDriver* create(const QString &); - QStringList keys() const; -}; - QSQLiteDriverPlugin::QSQLiteDriverPlugin() : QSqlDriverPlugin() { @@ -68,14 +49,4 @@ QSqlDriver* QSQLiteDriverPlugin::create(const QString &name) return 0; } -QStringList QSQLiteDriverPlugin::keys() const -{ - QStringList l; - l << QLatin1String("QSQLITE"); - return l; -} - -Q_EXPORT_STATIC_PLUGIN(QSQLiteDriverPlugin) -Q_EXPORT_PLUGIN2(qsqlite, QSQLiteDriverPlugin) - QT_END_NAMESPACE diff --git a/3rdparty/qsqlite/smain.h b/3rdparty/qsqlite/smain.h new file mode 100644 index 000000000..1d91a4544 --- /dev/null +++ b/3rdparty/qsqlite/smain.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "qsql_sqlite.h" + +QT_BEGIN_NAMESPACE + +class QSQLiteDriverPlugin : public QSqlDriverPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "qsqlite.json") + +public: + QSQLiteDriverPlugin(); + + QSqlDriver* create(const QString &); +}; + +QT_END_NAMESPACE diff --git a/3rdparty/qsqlite/smain.patch b/3rdparty/qsqlite/smain.patch deleted file mode 100644 index e5e596ecc..000000000 --- a/3rdparty/qsqlite/smain.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- smain.cpp.old 2010-03-22 17:34:03.000000000 +0000 -+++ smain.cpp 2010-03-22 17:34:08.000000000 +0000 -@@ -41,7 +41,7 @@ - - #include - #include --#include "../../../../src/sql/drivers/sqlite/qsql_sqlite.h" -+#include "qsql_sqlite.h" - - QT_BEGIN_NAMESPACE - From 39f120d405fd7bca2a31664509d1a5aa377a0761 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:45:27 +0200 Subject: [PATCH 04/17] Update qxt to qt5 --- 3rdparty/qxt/CMakeLists.txt | 5 +- 3rdparty/qxt/media-keys.patch | 432 ---------------------- 3rdparty/qxt/meta-modifier.patch | 15 - 3rdparty/qxt/qxtglobal.cpp | 76 ++-- 3rdparty/qxt/qxtglobal.h | 92 +++-- 3rdparty/qxt/qxtglobalshortcut.cpp | 87 +++-- 3rdparty/qxt/qxtglobalshortcut.h | 55 +-- 3rdparty/qxt/qxtglobalshortcut_mac.cpp | 461 +++++++++++++----------- 3rdparty/qxt/qxtglobalshortcut_p.h | 147 ++++---- 3rdparty/qxt/qxtglobalshortcut_win.cpp | 476 +++++++++++++------------ 3rdparty/qxt/qxtglobalshortcut_x11.cpp | 373 ++++++++++++------- 11 files changed, 1019 insertions(+), 1200 deletions(-) delete mode 100644 3rdparty/qxt/media-keys.patch delete mode 100644 3rdparty/qxt/meta-modifier.patch diff --git a/3rdparty/qxt/CMakeLists.txt b/3rdparty/qxt/CMakeLists.txt index 73954ffc9..af8765568 100644 --- a/3rdparty/qxt/CMakeLists.txt +++ b/3rdparty/qxt/CMakeLists.txt @@ -11,6 +11,7 @@ set(QXT-MOC-HEADERS find_package(X11) include_directories(${X11_INCLUDE_DIR}) +include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) if(WIN32) set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_win.cpp) @@ -20,9 +21,11 @@ else(WIN32) set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_x11.cpp) endif(WIN32) -QT4_WRAP_CPP(QXT-SOURCES-MOC ${QXT-MOC-HEADERS}) +QT5_WRAP_CPP(QXT-SOURCES-MOC ${QXT-MOC-HEADERS}) ADD_LIBRARY(qxt STATIC ${QXT-SOURCES} ${QXT-SOURCES-MOC} ) + +QT5_USE_MODULES(qxt Core Widgets X11Extras) diff --git a/3rdparty/qxt/media-keys.patch b/3rdparty/qxt/media-keys.patch deleted file mode 100644 index 31e52f3da..000000000 --- a/3rdparty/qxt/media-keys.patch +++ /dev/null @@ -1,432 +0,0 @@ -diff -ru libqxt-old/src/gui/keymapper_x11.h libqxt/src/gui/keymapper_x11.h ---- libqxt-old/src/gui/keymapper_x11.h 2010-04-21 15:17:56.000000000 +0100 -+++ libqxt/src/gui/keymapper_x11.h 2010-04-21 15:18:16.000000000 +0100 -@@ -0,0 +1,364 @@ -+#ifndef KEYMAPPER_X11_H -+#define KEYMAPPER_X11_H -+ -+// (davidsansome) Nicked from qkeymapper_x11.cpp -+ -+#include -+ -+#define XK_MISCELLANY -+#define XK_LATIN1 -+#define XK_KOREAN -+#define XK_XKB_KEYS -+#include -+ -+// -+// Keyboard event translation -+// -+ -+#ifndef XK_ISO_Left_Tab -+#define XK_ISO_Left_Tab 0xFE20 -+#endif -+ -+#ifndef XK_dead_hook -+#define XK_dead_hook 0xFE61 -+#endif -+ -+#ifndef XK_dead_horn -+#define XK_dead_horn 0xFE62 -+#endif -+ -+#ifndef XK_Codeinput -+#define XK_Codeinput 0xFF37 -+#endif -+ -+#ifndef XK_Kanji_Bangou -+#define XK_Kanji_Bangou 0xFF37 /* same as codeinput */ -+#endif -+ -+// Fix old X libraries -+#ifndef XK_KP_Home -+#define XK_KP_Home 0xFF95 -+#endif -+#ifndef XK_KP_Left -+#define XK_KP_Left 0xFF96 -+#endif -+#ifndef XK_KP_Up -+#define XK_KP_Up 0xFF97 -+#endif -+#ifndef XK_KP_Right -+#define XK_KP_Right 0xFF98 -+#endif -+#ifndef XK_KP_Down -+#define XK_KP_Down 0xFF99 -+#endif -+#ifndef XK_KP_Prior -+#define XK_KP_Prior 0xFF9A -+#endif -+#ifndef XK_KP_Next -+#define XK_KP_Next 0xFF9B -+#endif -+#ifndef XK_KP_End -+#define XK_KP_End 0xFF9C -+#endif -+#ifndef XK_KP_Insert -+#define XK_KP_Insert 0xFF9E -+#endif -+#ifndef XK_KP_Delete -+#define XK_KP_Delete 0xFF9F -+#endif -+ -+// the next lines are taken from XFree > 4.0 (X11/XF86keysyms.h), defining some special -+// multimedia keys. They are included here as not every system has them. -+#define XF86XK_Standby 0x1008FF10 -+#define XF86XK_AudioLowerVolume 0x1008FF11 -+#define XF86XK_AudioMute 0x1008FF12 -+#define XF86XK_AudioRaiseVolume 0x1008FF13 -+#define XF86XK_AudioPlay 0x1008FF14 -+#define XF86XK_AudioStop 0x1008FF15 -+#define XF86XK_AudioPrev 0x1008FF16 -+#define XF86XK_AudioNext 0x1008FF17 -+#define XF86XK_HomePage 0x1008FF18 -+#define XF86XK_Calculator 0x1008FF1D -+#define XF86XK_Mail 0x1008FF19 -+#define XF86XK_Start 0x1008FF1A -+#define XF86XK_Search 0x1008FF1B -+#define XF86XK_AudioRecord 0x1008FF1C -+#define XF86XK_Back 0x1008FF26 -+#define XF86XK_Forward 0x1008FF27 -+#define XF86XK_Stop 0x1008FF28 -+#define XF86XK_Refresh 0x1008FF29 -+#define XF86XK_Favorites 0x1008FF30 -+#define XF86XK_AudioPause 0x1008FF31 -+#define XF86XK_AudioMedia 0x1008FF32 -+#define XF86XK_MyComputer 0x1008FF33 -+#define XF86XK_OpenURL 0x1008FF38 -+#define XF86XK_Launch0 0x1008FF40 -+#define XF86XK_Launch1 0x1008FF41 -+#define XF86XK_Launch2 0x1008FF42 -+#define XF86XK_Launch3 0x1008FF43 -+#define XF86XK_Launch4 0x1008FF44 -+#define XF86XK_Launch5 0x1008FF45 -+#define XF86XK_Launch6 0x1008FF46 -+#define XF86XK_Launch7 0x1008FF47 -+#define XF86XK_Launch8 0x1008FF48 -+#define XF86XK_Launch9 0x1008FF49 -+#define XF86XK_LaunchA 0x1008FF4A -+#define XF86XK_LaunchB 0x1008FF4B -+#define XF86XK_LaunchC 0x1008FF4C -+#define XF86XK_LaunchD 0x1008FF4D -+#define XF86XK_LaunchE 0x1008FF4E -+#define XF86XK_LaunchF 0x1008FF4F -+// end of XF86keysyms.h -+ -+// Special keys used by Qtopia, mapped into the X11 private keypad range. -+#define QTOPIAXK_Select 0x11000601 -+#define QTOPIAXK_Yes 0x11000602 -+#define QTOPIAXK_No 0x11000603 -+#define QTOPIAXK_Cancel 0x11000604 -+#define QTOPIAXK_Printer 0x11000605 -+#define QTOPIAXK_Execute 0x11000606 -+#define QTOPIAXK_Sleep 0x11000607 -+#define QTOPIAXK_Play 0x11000608 -+#define QTOPIAXK_Zoom 0x11000609 -+#define QTOPIAXK_Context1 0x1100060A -+#define QTOPIAXK_Context2 0x1100060B -+#define QTOPIAXK_Context3 0x1100060C -+#define QTOPIAXK_Context4 0x1100060D -+#define QTOPIAXK_Call 0x1100060E -+#define QTOPIAXK_Hangup 0x1100060F -+#define QTOPIAXK_Flip 0x11000610 -+ -+// keyboard mapping table -+static const unsigned int KeyTbl[] = { -+ -+ // misc keys -+ -+ XK_Escape, Qt::Key_Escape, -+ XK_Tab, Qt::Key_Tab, -+ XK_ISO_Left_Tab, Qt::Key_Backtab, -+ XK_BackSpace, Qt::Key_Backspace, -+ XK_Return, Qt::Key_Return, -+ XK_Insert, Qt::Key_Insert, -+ XK_Delete, Qt::Key_Delete, -+ XK_Clear, Qt::Key_Delete, -+ XK_Pause, Qt::Key_Pause, -+ XK_Print, Qt::Key_Print, -+ 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq -+ 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq -+ -+ // cursor movement -+ -+ XK_Home, Qt::Key_Home, -+ XK_End, Qt::Key_End, -+ XK_Left, Qt::Key_Left, -+ XK_Up, Qt::Key_Up, -+ XK_Right, Qt::Key_Right, -+ XK_Down, Qt::Key_Down, -+ XK_Prior, Qt::Key_PageUp, -+ XK_Next, Qt::Key_PageDown, -+ -+ // modifiers -+ -+ XK_Shift_L, Qt::Key_Shift, -+ XK_Shift_R, Qt::Key_Shift, -+ XK_Shift_Lock, Qt::Key_Shift, -+ XK_Control_L, Qt::Key_Control, -+ XK_Control_R, Qt::Key_Control, -+ XK_Meta_L, Qt::Key_Meta, -+ XK_Meta_R, Qt::Key_Meta, -+ XK_Alt_L, Qt::Key_Alt, -+ XK_Alt_R, Qt::Key_Alt, -+ XK_Caps_Lock, Qt::Key_CapsLock, -+ XK_Num_Lock, Qt::Key_NumLock, -+ XK_Scroll_Lock, Qt::Key_ScrollLock, -+ XK_Super_L, Qt::Key_Super_L, -+ XK_Super_R, Qt::Key_Super_R, -+ XK_Menu, Qt::Key_Menu, -+ XK_Hyper_L, Qt::Key_Hyper_L, -+ XK_Hyper_R, Qt::Key_Hyper_R, -+ XK_Help, Qt::Key_Help, -+ 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab -+ 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11) -+ 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12) -+ -+ // numeric and function keypad keys -+ -+ XK_KP_Space, Qt::Key_Space, -+ XK_KP_Tab, Qt::Key_Tab, -+ XK_KP_Enter, Qt::Key_Enter, -+ //XK_KP_F1, Qt::Key_F1, -+ //XK_KP_F2, Qt::Key_F2, -+ //XK_KP_F3, Qt::Key_F3, -+ //XK_KP_F4, Qt::Key_F4, -+ XK_KP_Home, Qt::Key_Home, -+ XK_KP_Left, Qt::Key_Left, -+ XK_KP_Up, Qt::Key_Up, -+ XK_KP_Right, Qt::Key_Right, -+ XK_KP_Down, Qt::Key_Down, -+ XK_KP_Prior, Qt::Key_PageUp, -+ XK_KP_Next, Qt::Key_PageDown, -+ XK_KP_End, Qt::Key_End, -+ XK_KP_Begin, Qt::Key_Clear, -+ XK_KP_Insert, Qt::Key_Insert, -+ XK_KP_Delete, Qt::Key_Delete, -+ XK_KP_Equal, Qt::Key_Equal, -+ XK_KP_Multiply, Qt::Key_Asterisk, -+ XK_KP_Add, Qt::Key_Plus, -+ XK_KP_Separator, Qt::Key_Comma, -+ XK_KP_Subtract, Qt::Key_Minus, -+ XK_KP_Decimal, Qt::Key_Period, -+ XK_KP_Divide, Qt::Key_Slash, -+ -+ // International input method support keys -+ -+ // International & multi-key character composition -+ XK_ISO_Level3_Shift, Qt::Key_AltGr, -+ XK_Multi_key, Qt::Key_Multi_key, -+ XK_Codeinput, Qt::Key_Codeinput, -+ XK_SingleCandidate, Qt::Key_SingleCandidate, -+ XK_MultipleCandidate, Qt::Key_MultipleCandidate, -+ XK_PreviousCandidate, Qt::Key_PreviousCandidate, -+ -+ // Misc Functions -+ XK_Mode_switch, Qt::Key_Mode_switch, -+ XK_script_switch, Qt::Key_Mode_switch, -+ -+ // Japanese keyboard support -+ XK_Kanji, Qt::Key_Kanji, -+ XK_Muhenkan, Qt::Key_Muhenkan, -+ //XK_Henkan_Mode, Qt::Key_Henkan_Mode, -+ XK_Henkan_Mode, Qt::Key_Henkan, -+ XK_Henkan, Qt::Key_Henkan, -+ XK_Romaji, Qt::Key_Romaji, -+ XK_Hiragana, Qt::Key_Hiragana, -+ XK_Katakana, Qt::Key_Katakana, -+ XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana, -+ XK_Zenkaku, Qt::Key_Zenkaku, -+ XK_Hankaku, Qt::Key_Hankaku, -+ XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku, -+ XK_Touroku, Qt::Key_Touroku, -+ XK_Massyo, Qt::Key_Massyo, -+ XK_Kana_Lock, Qt::Key_Kana_Lock, -+ XK_Kana_Shift, Qt::Key_Kana_Shift, -+ XK_Eisu_Shift, Qt::Key_Eisu_Shift, -+ XK_Eisu_toggle, Qt::Key_Eisu_toggle, -+ //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou, -+ //XK_Zen_Koho, Qt::Key_Zen_Koho, -+ //XK_Mae_Koho, Qt::Key_Mae_Koho, -+ XK_Kanji_Bangou, Qt::Key_Codeinput, -+ XK_Zen_Koho, Qt::Key_MultipleCandidate, -+ XK_Mae_Koho, Qt::Key_PreviousCandidate, -+ -+#ifdef XK_KOREAN -+ // Korean keyboard support -+ XK_Hangul, Qt::Key_Hangul, -+ XK_Hangul_Start, Qt::Key_Hangul_Start, -+ XK_Hangul_End, Qt::Key_Hangul_End, -+ XK_Hangul_Hanja, Qt::Key_Hangul_Hanja, -+ XK_Hangul_Jamo, Qt::Key_Hangul_Jamo, -+ XK_Hangul_Romaja, Qt::Key_Hangul_Romaja, -+ //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput, -+ XK_Hangul_Codeinput, Qt::Key_Codeinput, -+ XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja, -+ XK_Hangul_Banja, Qt::Key_Hangul_Banja, -+ XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja, -+ XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja, -+ //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate, -+ //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate, -+ //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate, -+ XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate, -+ XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate, -+ XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate, -+ XK_Hangul_Special, Qt::Key_Hangul_Special, -+ //XK_Hangul_switch, Qt::Key_Hangul_switch, -+ XK_Hangul_switch, Qt::Key_Mode_switch, -+#endif // XK_KOREAN -+ -+ // dead keys -+ XK_dead_grave, Qt::Key_Dead_Grave, -+ XK_dead_acute, Qt::Key_Dead_Acute, -+ XK_dead_circumflex, Qt::Key_Dead_Circumflex, -+ XK_dead_tilde, Qt::Key_Dead_Tilde, -+ XK_dead_macron, Qt::Key_Dead_Macron, -+ XK_dead_breve, Qt::Key_Dead_Breve, -+ XK_dead_abovedot, Qt::Key_Dead_Abovedot, -+ XK_dead_diaeresis, Qt::Key_Dead_Diaeresis, -+ XK_dead_abovering, Qt::Key_Dead_Abovering, -+ XK_dead_doubleacute, Qt::Key_Dead_Doubleacute, -+ XK_dead_caron, Qt::Key_Dead_Caron, -+ XK_dead_cedilla, Qt::Key_Dead_Cedilla, -+ XK_dead_ogonek, Qt::Key_Dead_Ogonek, -+ XK_dead_iota, Qt::Key_Dead_Iota, -+ XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, -+ XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, -+ XK_dead_belowdot, Qt::Key_Dead_Belowdot, -+ XK_dead_hook, Qt::Key_Dead_Hook, -+ XK_dead_horn, Qt::Key_Dead_Horn, -+ -+ // Special multimedia keys -+ // currently only tested with MS internet keyboard -+ -+ // browsing keys -+ XF86XK_Back, Qt::Key_Back, -+ XF86XK_Forward, Qt::Key_Forward, -+ XF86XK_Stop, Qt::Key_Stop, -+ XF86XK_Refresh, Qt::Key_Refresh, -+ XF86XK_Favorites, Qt::Key_Favorites, -+ XF86XK_AudioMedia, Qt::Key_LaunchMedia, -+ XF86XK_OpenURL, Qt::Key_OpenUrl, -+ XF86XK_HomePage, Qt::Key_HomePage, -+ XF86XK_Search, Qt::Key_Search, -+ -+ // media keys -+ XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, -+ XF86XK_AudioMute, Qt::Key_VolumeMute, -+ XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, -+ XF86XK_AudioPlay, Qt::Key_MediaPlay, -+ XF86XK_AudioStop, Qt::Key_MediaStop, -+ XF86XK_AudioPrev, Qt::Key_MediaPrevious, -+ XF86XK_AudioNext, Qt::Key_MediaNext, -+ XF86XK_AudioRecord, Qt::Key_MediaRecord, -+ -+ // launch keys -+ XF86XK_Mail, Qt::Key_LaunchMail, -+ XF86XK_MyComputer, Qt::Key_Launch0, -+ XF86XK_Calculator, Qt::Key_Launch1, -+ XF86XK_Standby, Qt::Key_Standby, -+ -+ XF86XK_Launch0, Qt::Key_Launch2, -+ XF86XK_Launch1, Qt::Key_Launch3, -+ XF86XK_Launch2, Qt::Key_Launch4, -+ XF86XK_Launch3, Qt::Key_Launch5, -+ XF86XK_Launch4, Qt::Key_Launch6, -+ XF86XK_Launch5, Qt::Key_Launch7, -+ XF86XK_Launch6, Qt::Key_Launch8, -+ XF86XK_Launch7, Qt::Key_Launch9, -+ XF86XK_Launch8, Qt::Key_LaunchA, -+ XF86XK_Launch9, Qt::Key_LaunchB, -+ XF86XK_LaunchA, Qt::Key_LaunchC, -+ XF86XK_LaunchB, Qt::Key_LaunchD, -+ XF86XK_LaunchC, Qt::Key_LaunchE, -+ XF86XK_LaunchD, Qt::Key_LaunchF, -+ -+ // Qtopia keys -+ QTOPIAXK_Select, Qt::Key_Select, -+ QTOPIAXK_Yes, Qt::Key_Yes, -+ QTOPIAXK_No, Qt::Key_No, -+ QTOPIAXK_Cancel, Qt::Key_Cancel, -+ QTOPIAXK_Printer, Qt::Key_Printer, -+ QTOPIAXK_Execute, Qt::Key_Execute, -+ QTOPIAXK_Sleep, Qt::Key_Sleep, -+ QTOPIAXK_Play, Qt::Key_Play, -+ QTOPIAXK_Zoom, Qt::Key_Zoom, -+ QTOPIAXK_Context1, Qt::Key_Context1, -+ QTOPIAXK_Context2, Qt::Key_Context2, -+ QTOPIAXK_Context3, Qt::Key_Context3, -+ QTOPIAXK_Context4, Qt::Key_Context4, -+ QTOPIAXK_Call, Qt::Key_Call, -+ QTOPIAXK_Hangup, Qt::Key_Hangup, -+ QTOPIAXK_Flip, Qt::Key_Flip, -+ -+ 0, 0 -+}; -+ -+#endif // KEYMAPPER_X11_H -diff -ru libqxt-old/src/gui/qxtglobalshortcut_win.cpp libqxt/src/gui/qxtglobalshortcut_win.cpp ---- libqxt-old/src/gui/qxtglobalshortcut_win.cpp 2010-04-21 15:17:56.000000000 +0100 -+++ libqxt/src/gui/qxtglobalshortcut_win.cpp 2010-04-21 15:18:16.000000000 +0100 -@@ -156,6 +156,21 @@ - case Qt::Key_Slash: - return VK_DIVIDE; - -+ case Qt::Key_MediaNext: -+ return VK_MEDIA_NEXT_TRACK; -+ case Qt::Key_MediaPrevious: -+ return VK_MEDIA_PREV_TRACK; -+ case Qt::Key_MediaStop: -+ return VK_MEDIA_STOP; -+ case Qt::Key_MediaPlay: -+ return VK_MEDIA_PLAY_PAUSE; -+ case Qt::Key_VolumeDown: -+ return VK_VOLUME_DOWN; -+ case Qt::Key_VolumeUp: -+ return VK_VOLUME_UP; -+ case Qt::Key_VolumeMute: -+ return VK_VOLUME_MUTE; -+ - // numbers - case Qt::Key_0: - case Qt::Key_1: -diff -ru libqxt-old/src/gui/qxtglobalshortcut_x11.cpp libqxt/src/gui/qxtglobalshortcut_x11.cpp ---- libqxt-old/src/gui/qxtglobalshortcut_x11.cpp 2010-04-21 15:17:56.000000000 +0100 -+++ libqxt/src/gui/qxtglobalshortcut_x11.cpp 2010-04-21 15:18:16.000000000 +0100 -@@ -26,6 +26,8 @@ - #include - #include - -+#include "keymapper_x11.h" -+ - static int (*original_x_errhandler)(Display* display, XErrorEvent* event); - - static int qxt_x_errhandler(Display* display, XErrorEvent *event) -@@ -81,8 +83,25 @@ - - quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) - { -+ // (davidsansome) Try the table from QKeyMapper first - this seems to be -+ // the only way to get Keysyms for the media keys. -+ unsigned int keysym = 0; -+ int i = 0; -+ while (KeyTbl[i]) { -+ if (KeyTbl[i+1] == static_cast(key)) { -+ keysym = KeyTbl[i]; -+ break; -+ } -+ i += 2; -+ } -+ -+ // If that didn't work then fall back on XStringToKeysym -+ if (!keysym) { -+ keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); -+ } -+ - Display* display = QX11Info::display(); -- return XKeysymToKeycode(display, XStringToKeysym(QKeySequence(key).toString().toLatin1().data())); -+ return XKeysymToKeycode(display, keysym); - } - - bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) diff --git a/3rdparty/qxt/meta-modifier.patch b/3rdparty/qxt/meta-modifier.patch deleted file mode 100644 index f77b97a57..000000000 --- a/3rdparty/qxt/meta-modifier.patch +++ /dev/null @@ -1,15 +0,0 @@ -Index: qxtglobalshortcut_x11.cpp -=================================================================== ---- qxtglobalshortcut_x11.cpp (revision 1208) -+++ qxtglobalshortcut_x11.cpp (working copy) -@@ -74,8 +74,9 @@ - native |= ControlMask; - if (modifiers & Qt::AltModifier) - native |= Mod1Mask; -+ if (modifiers & Qt::MetaModifier) -+ native |= Mod4Mask; - // TODO: resolve these? -- //if (modifiers & Qt::MetaModifier) - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; diff --git a/3rdparty/qxt/qxtglobal.cpp b/3rdparty/qxt/qxtglobal.cpp index fe7b9e782..3da47c146 100644 --- a/3rdparty/qxt/qxtglobal.cpp +++ b/3rdparty/qxt/qxtglobal.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #include "qxtglobal.h" @@ -74,7 +80,7 @@ \sa QXT_VERSION_STR */ -const char* qxtVersion() +const char * qxtVersion() { return QXT_VERSION_STR; } @@ -170,13 +176,14 @@ void MyTestPrivate::doQuux() { * \relates * Declares that a public class has a related private class. * - * This shuold be put in the private section of the public class. The parameter is the name of the public class. + * This shuold be put in the private section of the public class. The + * parameter \a PUB must be the name of the public class. */ /*! * \macro QXT_DECLARE_PUBLIC(PUB) * \relates - * Declares that a private class has a related public class. + * Declares that a private class has a related public class named \a PUB. * * This may be put anywhere in the declaration of the private class. The parameter is the name of the public class. */ @@ -187,23 +194,26 @@ void MyTestPrivate::doQuux() { * Initializes resources owned by the private class. * * This should be called from the public class's constructor, - * before qxt_d() is used for the first time. The parameter is the name of the public class. + * before qxt_d() is used for the first time. The parameter \a PUB must be + * the name of the public class. */ /*! * \macro QXT_D(PUB) * \relates - * Returns a reference in the current scope named "d" to the private class. + * Returns a reference in the current scope named "d" to the private class + * associated with the public class \a PUB. * - * This function is only available in a class using \a QXT_DECLARE_PRIVATE. + * This function is only available in a class using QXT_DECLARE_PRIVATE(). */ /*! * \macro QXT_P(PUB) * \relates - * Creates a reference in the current scope named "q" to the public class. + * Creates a reference in the current scope named "q" to the public class + * named \a PUB. * - * This macro only works in a class using \a QXT_DECLARE_PUBLIC. + * This macro only works in a class using QXT_DECLARE_PUBLIC(). */ /*! @@ -228,7 +238,7 @@ void MyTestPrivate::doQuux() { * \relates * Returns a reference to the public class. * - * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + * This function is only available in a class using QXT_DECLARE_PUBLIC(). */ /*! @@ -236,6 +246,6 @@ void MyTestPrivate::doQuux() { * \relates * Returns a const reference to the public class. * - * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + * This function is only available in a class using QXT_DECLARE_PUBLIC(). * This overload will be automatically used in const functions. */ diff --git a/3rdparty/qxt/qxtglobal.h b/3rdparty/qxt/qxtglobal.h index 575372dcd..7d5abfbe0 100644 --- a/3rdparty/qxt/qxtglobal.h +++ b/3rdparty/qxt/qxtglobal.h @@ -1,47 +1,57 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 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. +** +** +*****************************************************************************/ #ifndef QXTGLOBAL_H #define QXTGLOBAL_H #include -#define QXT_VERSION 0x000600 -#define QXT_VERSION_STR "0.6.0" +#define QXT_VERSION 0x000700 +#define QXT_VERSION_STR "0.7.0" //--------------------------global macros------------------------------ #ifndef QXT_NO_MACROS +#ifndef _countof +#define _countof(x) (sizeof(x)/sizeof(*x)) +#endif + #endif // QXT_NO_MACROS //--------------------------export macros------------------------------ #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_CORE) # define QXT_CORE_EXPORT Q_DECL_EXPORT # else @@ -51,7 +61,7 @@ # define QXT_CORE_EXPORT #endif // BUILD_QXT_CORE -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_GUI) # define QXT_GUI_EXPORT Q_DECL_EXPORT # else @@ -61,7 +71,7 @@ # define QXT_GUI_EXPORT #endif // BUILD_QXT_GUI -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_NETWORK) # define QXT_NETWORK_EXPORT Q_DECL_EXPORT # else @@ -71,7 +81,7 @@ # define QXT_NETWORK_EXPORT #endif // BUILD_QXT_NETWORK -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_SQL) # define QXT_SQL_EXPORT Q_DECL_EXPORT # else @@ -81,7 +91,7 @@ # define QXT_SQL_EXPORT #endif // BUILD_QXT_SQL -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_WEB) # define QXT_WEB_EXPORT Q_DECL_EXPORT # else @@ -91,7 +101,7 @@ # define QXT_WEB_EXPORT #endif // BUILD_QXT_WEB -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_BERKELEY) # define QXT_BERKELEY_EXPORT Q_DECL_EXPORT # else @@ -101,7 +111,7 @@ # define QXT_BERKELEY_EXPORT #endif // BUILD_QXT_BERKELEY -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_ZEROCONF) # define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT # else @@ -111,7 +121,7 @@ # define QXT_ZEROCONF_EXPORT #endif // QXT_ZEROCONF_EXPORT -#if defined BUILD_QXT_CORE || defined BUILD_QXT_GUI || defined BUILD_QXT_SQL || defined BUILD_QXT_NETWORK || defined BUILD_QXT_WEB || defined BUILD_QXT_BERKELEY || defined BUILD_QXT_ZEROCONF +#if defined(BUILD_QXT_CORE) || defined(BUILD_QXT_GUI) || defined(BUILD_QXT_SQL) || defined(BUILD_QXT_NETWORK) || defined(BUILD_QXT_WEB) || defined(BUILD_QXT_BERKELEY) || defined(BUILD_QXT_ZEROCONF) # define BUILD_QXT #endif @@ -167,6 +177,14 @@ protected: { return *qxt_p_ptr; } + inline PUB* qxt_ptr() + { + return qxt_p_ptr; + } + inline const PUB* qxt_ptr() const + { + return qxt_p_ptr; + } private: PUB* qxt_p_ptr; @@ -198,6 +216,14 @@ public: { return *static_cast(pvt); } + inline PVT * operator->() + { + return static_cast(pvt); + } + inline const PVT * operator->() const + { + return static_cast(pvt); + } private: QxtPrivateInterface(const QxtPrivateInterface&) { } QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } diff --git a/3rdparty/qxt/qxtglobalshortcut.cpp b/3rdparty/qxt/qxtglobalshortcut.cpp index ef378f965..6ea380ca7 100644 --- a/3rdparty/qxt/qxtglobalshortcut.cpp +++ b/3rdparty/qxt/qxtglobalshortcut.cpp @@ -1,47 +1,69 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ #include "qxtglobalshortcut.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + #include "qxtglobalshortcut_p.h" #include #include bool QxtGlobalShortcutPrivate::error = false; +#ifndef Q_WS_MAC int QxtGlobalShortcutPrivate::ref = 0; +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; +#endif +#endif // Q_WS_MAC QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) { +#ifndef Q_WS_MAC if (!ref++) +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); +#else + QAbstractEventDispatcher::instance()->installNativeEventFilter(this); +#endif +#endif // Q_WS_MAC } QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() { +#ifndef Q_WS_MAC if (!--ref) +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) QAbstractEventDispatcher::instance()->setEventFilter(prevEventFilter); +#else + QAbstractEventDispatcher::instance()->removeNativeEventFilter(this); +#endif +#endif // Q_WS_MAC } bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) @@ -52,19 +74,23 @@ bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) const quint32 nativeKey = nativeKeycode(key); const quint32 nativeMods = nativeModifiers(mods); const bool res = registerShortcut(nativeKey, nativeMods); - shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); - if (!res) + if (res) + shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); + else qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); return res; } bool QxtGlobalShortcutPrivate::unsetShortcut() { + bool res = false; const quint32 nativeKey = nativeKeycode(key); const quint32 nativeMods = nativeModifiers(mods); - const bool res = unregisterShortcut(nativeKey, nativeMods); - shortcuts.remove(qMakePair(nativeKey, nativeMods)); - if (!res) + if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) + res = unregisterShortcut(nativeKey, nativeMods); + if (res) + shortcuts.remove(qMakePair(nativeKey, nativeMods)); + else qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); key = Qt::Key(0); mods = Qt::KeyboardModifiers(0); @@ -80,7 +106,7 @@ void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativ /*! \class QxtGlobalShortcut - \inmodule QxtGui + \inmodule QxtWidgets \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". A global shortcut triggers even if the application is not active. This @@ -189,3 +215,4 @@ void QxtGlobalShortcut::setDisabled(bool disabled) { qxt_d().enabled = !disabled; } + diff --git a/3rdparty/qxt/qxtglobalshortcut.h b/3rdparty/qxt/qxtglobalshortcut.h index a97ba2ddb..907e04c5d 100644 --- a/3rdparty/qxt/qxtglobalshortcut.h +++ b/3rdparty/qxt/qxtglobalshortcut.h @@ -1,28 +1,34 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ #ifndef QXTGLOBALSHORTCUT_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 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. +** +** +*****************************************************************************/ + #define QXTGLOBALSHORTCUT_H #include "qxtglobal.h" @@ -56,3 +62,4 @@ Q_SIGNALS: }; #endif // QXTGLOBALSHORTCUT_H + diff --git a/3rdparty/qxt/qxtglobalshortcut_mac.cpp b/3rdparty/qxt/qxtglobalshortcut_mac.cpp index 0bcea7f36..58b9a9043 100644 --- a/3rdparty/qxt/qxtglobalshortcut_mac.cpp +++ b/3rdparty/qxt/qxtglobalshortcut_mac.cpp @@ -1,207 +1,258 @@ +#include /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#include -#include "qxtglobalshortcut_p.h" -#include -#include -#include -#include +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 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. +** +** +*****************************************************************************/ -typedef QPair Identifier; -static QMap keyRefs; -static QHash keyIDs; -static quint32 hotKeySerial = 0; -static bool qxt_mac_handler_installed = false; - -OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) -{ - // pass event to the app event filter - Q_UNUSED(data); - qApp->macEventFilter(nextHandler, event); - return noErr; -} - -bool QxtGlobalShortcutPrivate::eventFilter(void* message) -//bool QxtGlobalShortcutPrivate::macEventFilter(EventHandlerCallRef caller, EventRef event) -{ - EventRef event = (EventRef) message; - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) - { - EventHotKeyID keyID; - GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); - Identifier id = keyIDs.key(keyID.id); - activateShortcut(id.second, id.first); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= shiftKeyBit; - if (modifiers & Qt::ControlModifier) - native |= cmdKey; - if (modifiers & Qt::AltModifier) - native |= optionKey; - if (modifiers & Qt::MetaModifier) - native |= controlKey; - if (modifiers & Qt::KeypadModifier) - native |= kEventKeyModifierNumLockMask; - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - UTF16Char ch; - // Constants found in NSEvent.h from AppKit.framework - if (key == Qt::Key_Up) ch = 0xF700; - else if (key == Qt::Key_Down) ch = 0xF701; - else if (key == Qt::Key_Left) ch = 0xF702; - else if (key == Qt::Key_Right) ch = 0xF703; - else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) - ch = key - Qt::Key_F1 + 0xF704; - else if (key == Qt::Key_Insert) ch = 0xF727; - else if (key == Qt::Key_Delete) ch = 0xF728; - else if (key == Qt::Key_Home) ch = 0xF729; - else if (key == Qt::Key_End) ch = 0xF72B; - else if (key == Qt::Key_PageUp) ch = 0xF72C; - else if (key == Qt::Key_PageDown) ch = 0xF72D; - else if (key == Qt::Key_Print) ch = 0xF72E; - else if (key == Qt::Key_ScrollLock) ch = 0xF72F; - else if (key == Qt::Key_Pause) ch = 0xF730; - else if (key == Qt::Key_SysReq) ch = 0xF731; - else if (key == Qt::Key_Stop) ch = 0xF734; - else if (key == Qt::Key_Menu) ch = 0xF735; - else if (key == Qt::Key_Select) ch = 0xF741; - else if (key == Qt::Key_Execute) ch = 0xF742; - else if (key == Qt::Key_Help) ch = 0xF746; - else if (key == Qt::Key_Mode_switch) ch = 0xF747; - else if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; - - KeyboardLayoutRef layout; - KeyboardLayoutKind layoutKind; - KLGetCurrentKeyboardLayout(&layout); - KLGetKeyboardLayoutProperty(layout, kKLKind, const_cast(reinterpret_cast(&layoutKind))); - - if (layoutKind == kKLKCHRKind) - { // no Unicode available - if (ch > 255) return 0; - - char* data; - KLGetKeyboardLayoutProperty(layout, kKLKCHRData, const_cast(reinterpret_cast(&data))); - int ct = *reinterpret_cast(data + 258); - for (int i = 0; i < ct; i++) - { - char* keyTable = data + 260 + 128 * i; - for (int j = 0; j < 128; j++) - { - if (keyTable[j] == ch) return j; - } - } - - return 0; - } - - char* data; - KLGetKeyboardLayoutProperty(layout, kKLuchrData, const_cast(reinterpret_cast(&data))); - UCKeyboardLayout* header = reinterpret_cast(data); - UCKeyboardTypeHeader* table = header->keyboardTypeList; - - for (quint32 i=0; i < header->keyboardTypeCount; i++) - { - UCKeyStateRecordsIndex* stateRec = 0; - if (table[i].keyStateRecordsIndexOffset != 0) - { - stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); - if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; - } - - UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); - if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; - - for (quint32 j=0; j < charTable->keyToCharTableCount; j++) - { - UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); - for (quint32 k=0; k < charTable->keyToCharTableSize; k++) - { - if (keyToChar[k] & kUCKeyOutputTestForIndexMask) - { - long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; - if (stateRec && idx < stateRec->keyStateRecordCount) - { - UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); - if (rec->stateZeroCharData == ch) return k; - } - } - else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) - { - if (keyToChar[k] == ch) return k; - } - } // for k - } // for j - } // for i - - return 0; -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - if (!qxt_mac_handler_installed) - { - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); - } - - EventHotKeyID keyID; - keyID.signature = 'cute'; - keyID.id = ++hotKeySerial; - - EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); - if (rv) - { - keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); - keyRefs.insert(keyID.id, ref); - } - qDebug() << ref; - return rv; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Identifier id(nativeMods, nativeKey); - if (!keyIDs.contains(id)) return false; - - EventHotKeyRef ref = keyRefs.take(keyIDs[id]); - keyIDs.remove(id); - return !UnregisterEventHotKey(ref); -} +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + switch (key) + { + case Qt::Key_Return: + return kVK_Return; + case Qt::Key_Enter: + return kVK_ANSI_KeypadEnter; + case Qt::Key_Tab: + return kVK_Tab; + case Qt::Key_Space: + return kVK_Space; + case Qt::Key_Backspace: + return kVK_Delete; + case Qt::Key_Control: + return kVK_Command; + case Qt::Key_Shift: + return kVK_Shift; + case Qt::Key_CapsLock: + return kVK_CapsLock; + case Qt::Key_Option: + return kVK_Option; + case Qt::Key_Meta: + return kVK_Control; + case Qt::Key_F17: + return kVK_F17; + case Qt::Key_VolumeUp: + return kVK_VolumeUp; + case Qt::Key_VolumeDown: + return kVK_VolumeDown; + case Qt::Key_F18: + return kVK_F18; + case Qt::Key_F19: + return kVK_F19; + case Qt::Key_F20: + return kVK_F20; + case Qt::Key_F5: + return kVK_F5; + case Qt::Key_F6: + return kVK_F6; + case Qt::Key_F7: + return kVK_F7; + case Qt::Key_F3: + return kVK_F3; + case Qt::Key_F8: + return kVK_F8; + case Qt::Key_F9: + return kVK_F9; + case Qt::Key_F11: + return kVK_F11; + case Qt::Key_F13: + return kVK_F13; + case Qt::Key_F16: + return kVK_F16; + case Qt::Key_F14: + return kVK_F14; + case Qt::Key_F10: + return kVK_F10; + case Qt::Key_F12: + return kVK_F12; + case Qt::Key_F15: + return kVK_F15; + case Qt::Key_Help: + return kVK_Help; + case Qt::Key_Home: + return kVK_Home; + case Qt::Key_PageUp: + return kVK_PageUp; + case Qt::Key_Delete: + return kVK_ForwardDelete; + case Qt::Key_F4: + return kVK_F4; + case Qt::Key_End: + return kVK_End; + case Qt::Key_F2: + return kVK_F2; + case Qt::Key_PageDown: + return kVK_PageDown; + case Qt::Key_F1: + return kVK_F1; + case Qt::Key_Left: + return kVK_LeftArrow; + case Qt::Key_Right: + return kVK_RightArrow; + case Qt::Key_Down: + return kVK_DownArrow; + case Qt::Key_Up: + return kVK_UpArrow; + default: + ; + } + + if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + CFDataRef currentLayoutData; + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + + if (currentKeyboard == NULL) + return 0; + + currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFRelease(currentKeyboard); + if (currentLayoutData == NULL) + return 0; + + UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + uint8_t *data = (uint8_t*)header; + // God, would a little documentation for this shit kill you... + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} diff --git a/3rdparty/qxt/qxtglobalshortcut_p.h b/3rdparty/qxt/qxtglobalshortcut_p.h index 4570396fe..1a788852e 100644 --- a/3rdparty/qxt/qxtglobalshortcut_p.h +++ b/3rdparty/qxt/qxtglobalshortcut_p.h @@ -1,63 +1,84 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#ifndef QXTGLOBALSHORTCUT_P_H -#define QXTGLOBALSHORTCUT_P_H - -#include "qxtglobalshortcut.h" -#include -#include -#include - -class QxtGlobalShortcutPrivate : public QxtPrivate -{ -public: - QXT_DECLARE_PUBLIC(QxtGlobalShortcut) - QxtGlobalShortcutPrivate(); - ~QxtGlobalShortcutPrivate(); - - bool enabled; - Qt::Key key; - Qt::KeyboardModifiers mods; - - bool setShortcut(const QKeySequence& shortcut); - bool unsetShortcut(); - - static bool error; - static int ref; - static QAbstractEventDispatcher::EventFilter prevEventFilter; - static bool eventFilter(void* message); - -private: - static quint32 nativeKeycode(Qt::Key keycode); - static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers); - - static bool registerShortcut(quint32 nativeKey, quint32 nativeMods); - static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); - static void activateShortcut(quint32 nativeKey, quint32 nativeMods); - - static QHash, QxtGlobalShortcut*> shortcuts; -}; - -#endif // QXTGLOBALSHORTCUT_P_H +#ifndef QXTGLOBALSHORTCUT_P_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 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. +** +** +*****************************************************************************/ + +#define QXTGLOBALSHORTCUT_P_H + +#include "qxtglobalshortcut.h" +#include +#include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +#include +#endif + + +class QxtGlobalShortcutPrivate : public QxtPrivate +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + ,public QAbstractNativeEventFilter +#endif +{ +public: + QXT_DECLARE_PUBLIC(QxtGlobalShortcut) + QxtGlobalShortcutPrivate(); + ~QxtGlobalShortcutPrivate(); + + bool enabled; + Qt::Key key; + Qt::KeyboardModifiers mods; + + bool setShortcut(const QKeySequence& shortcut); + bool unsetShortcut(); + + static bool error; +#ifndef Q_WS_MAC + static int ref; +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + static QAbstractEventDispatcher::EventFilter prevEventFilter; + static bool eventFilter(void* message); +#else + virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result); +#endif // QT_VERSION < QT_VERSION_CHECK(5,0,0) +#endif // Q_WS_MAC + + static void activateShortcut(quint32 nativeKey, quint32 nativeMods); + +private: + static quint32 nativeKeycode(Qt::Key keycode); + static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers); + + static bool registerShortcut(quint32 nativeKey, quint32 nativeMods); + static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); + + static QHash, QxtGlobalShortcut*> shortcuts; +}; + +#endif // QXTGLOBALSHORTCUT_P_H diff --git a/3rdparty/qxt/qxtglobalshortcut_win.cpp b/3rdparty/qxt/qxtglobalshortcut_win.cpp index d81f1089d..1f4b611d9 100644 --- a/3rdparty/qxt/qxtglobalshortcut_win.cpp +++ b/3rdparty/qxt/qxtglobalshortcut_win.cpp @@ -1,229 +1,247 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include - -bool QxtGlobalShortcutPrivate::eventFilter(void* message) -{ - MSG* msg = static_cast(message); - if (msg->message == WM_HOTKEY) - { - const quint32 keycode = HIWORD(msg->lParam); - const quint32 modifiers = LOWORD(msg->lParam); - activateShortcut(keycode, modifiers); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - // MOD_ALT, MOD_CONTROL, (MOD_KEYUP), MOD_SHIFT, MOD_WIN - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= MOD_SHIFT; - if (modifiers & Qt::ControlModifier) - native |= MOD_CONTROL; - if (modifiers & Qt::AltModifier) - native |= MOD_ALT; - if (modifiers & Qt::MetaModifier) - native |= MOD_WIN; - // TODO: resolve these? - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - switch (key) - { - case Qt::Key_Escape: - return VK_ESCAPE; - case Qt::Key_Tab: - case Qt::Key_Backtab: - return VK_TAB; - case Qt::Key_Backspace: - return VK_BACK; - case Qt::Key_Return: - case Qt::Key_Enter: - return VK_RETURN; - case Qt::Key_Insert: - return VK_INSERT; - case Qt::Key_Delete: - return VK_DELETE; - case Qt::Key_Pause: - return VK_PAUSE; - case Qt::Key_Print: - return VK_PRINT; - case Qt::Key_Clear: - return VK_CLEAR; - case Qt::Key_Home: - return VK_HOME; - case Qt::Key_End: - return VK_END; - case Qt::Key_Left: - return VK_LEFT; - case Qt::Key_Up: - return VK_UP; - case Qt::Key_Right: - return VK_RIGHT; - case Qt::Key_Down: - return VK_DOWN; - case Qt::Key_PageUp: - return VK_PRIOR; - case Qt::Key_PageDown: - return VK_NEXT; - case Qt::Key_F1: - return VK_F1; - case Qt::Key_F2: - return VK_F2; - case Qt::Key_F3: - return VK_F3; - case Qt::Key_F4: - return VK_F4; - case Qt::Key_F5: - return VK_F5; - case Qt::Key_F6: - return VK_F6; - case Qt::Key_F7: - return VK_F7; - case Qt::Key_F8: - return VK_F8; - case Qt::Key_F9: - return VK_F9; - case Qt::Key_F10: - return VK_F10; - case Qt::Key_F11: - return VK_F11; - case Qt::Key_F12: - return VK_F12; - case Qt::Key_F13: - return VK_F13; - case Qt::Key_F14: - return VK_F14; - case Qt::Key_F15: - return VK_F15; - case Qt::Key_F16: - return VK_F16; - case Qt::Key_F17: - return VK_F17; - case Qt::Key_F18: - return VK_F18; - case Qt::Key_F19: - return VK_F19; - case Qt::Key_F20: - return VK_F20; - case Qt::Key_F21: - return VK_F21; - case Qt::Key_F22: - return VK_F22; - case Qt::Key_F23: - return VK_F23; - case Qt::Key_F24: - return VK_F24; - case Qt::Key_Space: - return VK_SPACE; - case Qt::Key_Asterisk: - return VK_MULTIPLY; - case Qt::Key_Plus: - return VK_ADD; - case Qt::Key_Comma: - return VK_SEPARATOR; - case Qt::Key_Minus: - return VK_SUBTRACT; - case Qt::Key_Slash: - return VK_DIVIDE; - - case Qt::Key_MediaNext: - return VK_MEDIA_NEXT_TRACK; - case Qt::Key_MediaPrevious: - return VK_MEDIA_PREV_TRACK; - case Qt::Key_MediaStop: - return VK_MEDIA_STOP; - case Qt::Key_MediaPlay: - return VK_MEDIA_PLAY_PAUSE; - case Qt::Key_VolumeDown: - return VK_VOLUME_DOWN; - case Qt::Key_VolumeUp: - return VK_VOLUME_UP; - case Qt::Key_VolumeMute: - return VK_VOLUME_MUTE; - - // numbers - case Qt::Key_0: - case Qt::Key_1: - case Qt::Key_2: - case Qt::Key_3: - case Qt::Key_4: - case Qt::Key_5: - case Qt::Key_6: - case Qt::Key_7: - case Qt::Key_8: - case Qt::Key_9: - return key; - - // letters - case Qt::Key_A: - case Qt::Key_B: - case Qt::Key_C: - case Qt::Key_D: - case Qt::Key_E: - case Qt::Key_F: - case Qt::Key_G: - case Qt::Key_H: - case Qt::Key_I: - case Qt::Key_J: - case Qt::Key_K: - case Qt::Key_L: - case Qt::Key_M: - case Qt::Key_N: - case Qt::Key_O: - case Qt::Key_P: - case Qt::Key_Q: - case Qt::Key_R: - case Qt::Key_S: - case Qt::Key_T: - case Qt::Key_U: - case Qt::Key_V: - case Qt::Key_W: - case Qt::Key_X: - case Qt::Key_Y: - case Qt::Key_Z: - return key; - - default: - return 0; - } -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - return RegisterHotKey(0, nativeMods ^ nativeKey, nativeMods, nativeKey); -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - return UnregisterHotKey(0, nativeMods ^ nativeKey); -} +#include "qxtglobalshortcut_p.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include + + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +bool QxtGlobalShortcutPrivate::eventFilter(void* message) +{ +#else +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void * message, long * result) +{ + Q_UNUSED(eventType); + Q_UNUSED(result); +#endif + MSG* msg = static_cast(message); + if (msg->message == WM_HOTKEY) + { + const quint32 keycode = HIWORD(msg->lParam); + const quint32 modifiers = LOWORD(msg->lParam); + activateShortcut(keycode, modifiers); + } + return false; +} + + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // MOD_ALT, MOD_CONTROL, (MOD_KEYUP), MOD_SHIFT, MOD_WIN + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= MOD_SHIFT; + if (modifiers & Qt::ControlModifier) + native |= MOD_CONTROL; + if (modifiers & Qt::AltModifier) + native |= MOD_ALT; + if (modifiers & Qt::MetaModifier) + native |= MOD_WIN; + // TODO: resolve these? + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + switch (key) + { + case Qt::Key_Escape: + return VK_ESCAPE; + case Qt::Key_Tab: + case Qt::Key_Backtab: + return VK_TAB; + case Qt::Key_Backspace: + return VK_BACK; + case Qt::Key_Return: + case Qt::Key_Enter: + return VK_RETURN; + case Qt::Key_Insert: + return VK_INSERT; + case Qt::Key_Delete: + return VK_DELETE; + case Qt::Key_Pause: + return VK_PAUSE; + case Qt::Key_Print: + return VK_PRINT; + case Qt::Key_Clear: + return VK_CLEAR; + case Qt::Key_Home: + return VK_HOME; + case Qt::Key_End: + return VK_END; + case Qt::Key_Left: + return VK_LEFT; + case Qt::Key_Up: + return VK_UP; + case Qt::Key_Right: + return VK_RIGHT; + case Qt::Key_Down: + return VK_DOWN; + case Qt::Key_PageUp: + return VK_PRIOR; + case Qt::Key_PageDown: + return VK_NEXT; + case Qt::Key_F1: + return VK_F1; + case Qt::Key_F2: + return VK_F2; + case Qt::Key_F3: + return VK_F3; + case Qt::Key_F4: + return VK_F4; + case Qt::Key_F5: + return VK_F5; + case Qt::Key_F6: + return VK_F6; + case Qt::Key_F7: + return VK_F7; + case Qt::Key_F8: + return VK_F8; + case Qt::Key_F9: + return VK_F9; + case Qt::Key_F10: + return VK_F10; + case Qt::Key_F11: + return VK_F11; + case Qt::Key_F12: + return VK_F12; + case Qt::Key_F13: + return VK_F13; + case Qt::Key_F14: + return VK_F14; + case Qt::Key_F15: + return VK_F15; + case Qt::Key_F16: + return VK_F16; + case Qt::Key_F17: + return VK_F17; + case Qt::Key_F18: + return VK_F18; + case Qt::Key_F19: + return VK_F19; + case Qt::Key_F20: + return VK_F20; + case Qt::Key_F21: + return VK_F21; + case Qt::Key_F22: + return VK_F22; + case Qt::Key_F23: + return VK_F23; + case Qt::Key_F24: + return VK_F24; + case Qt::Key_Space: + return VK_SPACE; + case Qt::Key_Asterisk: + return VK_MULTIPLY; + case Qt::Key_Plus: + return VK_ADD; + case Qt::Key_Comma: + return VK_SEPARATOR; + case Qt::Key_Minus: + return VK_SUBTRACT; + case Qt::Key_Slash: + return VK_DIVIDE; + case Qt::Key_MediaNext: + return VK_MEDIA_NEXT_TRACK; + case Qt::Key_MediaPrevious: + return VK_MEDIA_PREV_TRACK; + case Qt::Key_MediaPlay: + return VK_MEDIA_PLAY_PAUSE; + case Qt::Key_MediaStop: + return VK_MEDIA_STOP; + // couldn't find those in VK_* + //case Qt::Key_MediaLast: + //case Qt::Key_MediaRecord: + case Qt::Key_VolumeDown: + return VK_VOLUME_DOWN; + case Qt::Key_VolumeUp: + return VK_VOLUME_UP; + case Qt::Key_VolumeMute: + return VK_VOLUME_MUTE; + + // numbers + case Qt::Key_0: + case Qt::Key_1: + case Qt::Key_2: + case Qt::Key_3: + case Qt::Key_4: + case Qt::Key_5: + case Qt::Key_6: + case Qt::Key_7: + case Qt::Key_8: + case Qt::Key_9: + return key; + + // letters + case Qt::Key_A: + case Qt::Key_B: + case Qt::Key_C: + case Qt::Key_D: + case Qt::Key_E: + case Qt::Key_F: + case Qt::Key_G: + case Qt::Key_H: + case Qt::Key_I: + case Qt::Key_J: + case Qt::Key_K: + case Qt::Key_L: + case Qt::Key_M: + case Qt::Key_N: + case Qt::Key_O: + case Qt::Key_P: + case Qt::Key_Q: + case Qt::Key_R: + case Qt::Key_S: + case Qt::Key_T: + case Qt::Key_U: + case Qt::Key_V: + case Qt::Key_W: + case Qt::Key_X: + case Qt::Key_Y: + case Qt::Key_Z: + return key; + + default: + return 0; + } +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + return RegisterHotKey(0, nativeMods ^ nativeKey, nativeMods, nativeKey); +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + return UnregisterHotKey(0, nativeMods ^ nativeKey); +} diff --git a/3rdparty/qxt/qxtglobalshortcut_x11.cpp b/3rdparty/qxt/qxtglobalshortcut_x11.cpp index c22894dc1..7ecbdf24a 100644 --- a/3rdparty/qxt/qxtglobalshortcut_x11.cpp +++ b/3rdparty/qxt/qxtglobalshortcut_x11.cpp @@ -1,135 +1,238 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include -#include - -#include "keymapper_x11.h" - -static int (*original_x_errhandler)(Display* display, XErrorEvent* event); - -static int qxt_x_errhandler(Display* display, XErrorEvent *event) -{ - Q_UNUSED(display); - switch (event->error_code) - { - case BadAccess: - case BadValue: - case BadWindow: - if (event->request_code == 33 /* X_GrabKey */ || - event->request_code == 34 /* X_UngrabKey */) - { - QxtGlobalShortcutPrivate::error = true; - //TODO: - //char errstr[256]; - //XGetErrorText(dpy, err->error_code, errstr, 256); - } - default: - return 0; - } -} - -bool QxtGlobalShortcutPrivate::eventFilter(void* message) -{ - XEvent* event = static_cast(message); - if (event->type == KeyPress) - { - XKeyEvent* key = (XKeyEvent*) event; - activateShortcut(key->keycode, - // Mod1Mask == Alt, Mod4Mask == Meta - key->state & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= ShiftMask; - if (modifiers & Qt::ControlModifier) - native |= ControlMask; - if (modifiers & Qt::AltModifier) - native |= Mod1Mask; - if (modifiers & Qt::MetaModifier) - native |= Mod4Mask; - // TODO: resolve these? - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - // (davidsansome) Try the table from QKeyMapper first - this seems to be - // the only way to get Keysyms for the media keys. - unsigned int keysym = 0; - int i = 0; - while (KeyTbl[i]) { - if (KeyTbl[i+1] == static_cast(key)) { - keysym = KeyTbl[i]; - break; - } - i += 2; - } - - // If that didn't work then fall back on XStringToKeysym - if (!keysym) { - keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); - } - - Display* display = QX11Info::display(); - return XKeysymToKeycode(display, keysym); -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Display* display = QX11Info::display(); - Window window = QX11Info::appRootWindow(); - Bool owner = True; - int pointer = GrabModeAsync; - int keyboard = GrabModeAsync; - error = false; - original_x_errhandler = XSetErrorHandler(qxt_x_errhandler); - XGrabKey(display, nativeKey, nativeMods, window, owner, pointer, keyboard); - XGrabKey(display, nativeKey, nativeMods | Mod2Mask, window, owner, pointer, keyboard); // allow numlock - XSync(display, False); - XSetErrorHandler(original_x_errhandler); - return !error; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Display* display = QX11Info::display(); - Window window = QX11Info::appRootWindow(); - error = false; - original_x_errhandler = XSetErrorHandler(qxt_x_errhandler); - XUngrabKey(display, nativeKey, nativeMods, window); - XUngrabKey(display, nativeKey, nativeMods | Mod2Mask, window); // allow numlock - XSync(display, False); - XSetErrorHandler(original_x_errhandler); - return !error; -} +#include "qxtglobalshortcut_p.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** 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 LibQxt project 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 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. +** +** +*****************************************************************************/ + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +# include +#else +# include +# include +# include +#endif +#include +#include + +namespace { + +const QVector maskModifiers = QVector() + << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); + +typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); + +class QxtX11ErrorHandler { +public: + static bool error; + + static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) + { + Q_UNUSED(display); + switch (event->error_code) + { + case BadAccess: + case BadValue: + case BadWindow: + if (event->request_code == 33 /* X_GrabKey */ || + event->request_code == 34 /* X_UngrabKey */) + { + error = true; + //TODO: + //char errstr[256]; + //XGetErrorText(dpy, err->error_code, errstr, 256); + } + } + return 0; + } + + QxtX11ErrorHandler() + { + error = false; + m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); + } + + ~QxtX11ErrorHandler() + { + XSetErrorHandler(m_previousErrorHandler); + } + +private: + X11ErrorHandler m_previousErrorHandler; +}; + +bool QxtX11ErrorHandler::error = false; + +class QxtX11Data { +public: + QxtX11Data() + { +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + m_display = QX11Info::display(); +#else + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + void *display = native->nativeResourceForScreen(QByteArray("display"), + QGuiApplication::primaryScreen()); + m_display = reinterpret_cast(display); +#endif + } + + bool isValid() + { + return m_display != 0; + } + + Display *display() + { + Q_ASSERT(isValid()); + return m_display; + } + + Window rootWindow() + { + return DefaultRootWindow(display()); + } + + bool grabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { + XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, + GrabModeAsync, GrabModeAsync); + } + + if (errorHandler.error) { + ungrabKey(keycode, modifiers, window); + return false; + } + + return true; + } + + bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + foreach (quint32 maskMods, maskModifiers) { + XUngrabKey(display(), keycode, modifiers | maskMods, window); + } + + return !errorHandler.error; + } + +private: + Display *m_display; +}; + +} // namespace + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +bool QxtGlobalShortcutPrivate::eventFilter(void *message) +{ + XEvent *event = static_cast(message); + if (event->type == KeyPress) + { + XKeyEvent *key = reinterpret_cast(event); + unsigned int keycode = key->keycode; + unsigned int keystate = key->state; +#else +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void *message, long *result) +{ + Q_UNUSED(result); + + xcb_key_press_event_t *kev = 0; + if (eventType == "xcb_generic_event_t") { + xcb_generic_event_t *ev = static_cast(message); + if ((ev->response_type & 127) == XCB_KEY_PRESS) + kev = static_cast(message); + } + + if (kev != 0) { + unsigned int keycode = kev->detail; + unsigned int keystate = 0; + if(kev->state & XCB_MOD_MASK_1) + keystate |= Mod1Mask; + if(kev->state & XCB_MOD_MASK_CONTROL) + keystate |= ControlMask; + if(kev->state & XCB_MOD_MASK_4) + keystate |= Mod4Mask; + if(kev->state & XCB_MOD_MASK_SHIFT) + keystate |= ShiftMask; +#endif + activateShortcut(keycode, + // Mod1Mask == Alt, Mod4Mask == Meta + keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); + } + return false; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= ShiftMask; + if (modifiers & Qt::ControlModifier) + native |= ControlMask; + if (modifiers & Qt::AltModifier) + native |= Mod1Mask; + if (modifiers & Qt::MetaModifier) + native |= Mod4Mask; + + // TODO: resolve these? + //if (modifiers & Qt::MetaModifier) + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + QxtX11Data x11; + if (!x11.isValid()) + return 0; + + KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); + if (keysym == NoSymbol) + keysym = static_cast(key); + + return XKeysymToKeycode(x11.display(), keysym); +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); +} From 6830cb92f79a8c609342263b0f3edec7407f177d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:48:34 +0200 Subject: [PATCH 05/17] Update cmakelist of 3rdparties to qt5 --- 3rdparty/fancytabwidget/CMakeLists.txt | 2 +- 3rdparty/qocoa/CMakeLists.txt | 4 ++-- 3rdparty/qtiocompressor/CMakeLists.txt | 4 +++- 3rdparty/vreen/vreen/CMakeLists.txt | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/3rdparty/fancytabwidget/CMakeLists.txt b/3rdparty/fancytabwidget/CMakeLists.txt index bdc7b8e28..122f38a57 100644 --- a/3rdparty/fancytabwidget/CMakeLists.txt +++ b/3rdparty/fancytabwidget/CMakeLists.txt @@ -9,7 +9,7 @@ set(HEADERS fancytabwidget.h ) -qt4_wrap_cpp(MOC ${HEADERS}) +qt5_wrap_cpp(MOC ${HEADERS}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/3rdparty/qocoa/CMakeLists.txt b/3rdparty/qocoa/CMakeLists.txt index 92ac7ce29..b3b7fa4aa 100644 --- a/3rdparty/qocoa/CMakeLists.txt +++ b/3rdparty/qocoa/CMakeLists.txt @@ -6,7 +6,7 @@ set(HEADERS qprogressindicatorspinning.h ) -qt4_wrap_cpp(MOC_SOURCES ${HEADERS}) +qt5_wrap_cpp(MOC_SOURCES ${HEADERS}) if(APPLE) list(APPEND SOURCES @@ -23,7 +23,7 @@ else() set(RESOURCES qprogressindicatorspinning_nonmac.qrc ) - qt4_add_resources(RESOURCES_SOURCES ${RESOURCES}) + qt5_add_resources(RESOURCES_SOURCES ${RESOURCES}) endif() add_library(Qocoa STATIC diff --git a/3rdparty/qtiocompressor/CMakeLists.txt b/3rdparty/qtiocompressor/CMakeLists.txt index f339daba9..03578c554 100644 --- a/3rdparty/qtiocompressor/CMakeLists.txt +++ b/3rdparty/qtiocompressor/CMakeLists.txt @@ -8,9 +8,11 @@ set(IOCOMPRESSOR-MOC-HEADERS qtiocompressor.h ) -QT4_WRAP_CPP(IOCOMPRESSOR-SOURCES-MOC ${IOCOMPRESSOR-MOC-HEADERS}) +QT5_WRAP_CPP(IOCOMPRESSOR-SOURCES-MOC ${IOCOMPRESSOR-MOC-HEADERS}) ADD_LIBRARY(qtiocompressor STATIC ${IOCOMPRESSOR-SOURCES} ${IOCOMPRESSOR-SOURCES-MOC} ) + +QT5_USE_MODULES(qtiocompressor Core) diff --git a/3rdparty/vreen/vreen/CMakeLists.txt b/3rdparty/vreen/vreen/CMakeLists.txt index 80ddde319..44241581e 100644 --- a/3rdparty/vreen/vreen/CMakeLists.txt +++ b/3rdparty/vreen/vreen/CMakeLists.txt @@ -16,7 +16,7 @@ option(VREEN_WITH_EXAMPLES "Enable vreen tests" ON) option(VREEN_WITH_TESTS "Enable vreen examples" ON) option(VREEN_INSTALL_HEADERS "Install devel headers for vreen" ON) option(VREEN_DEVELOPER_BUILD "Install devel headers for vreen" OFF) -option(USE_QT5 "Build with Qt 5" OFF) +option(USE_QT5 "Build with Qt 5" ON) #TODO check if vars is defined set(RLIBDIR bin) From f5414d5535b4a943f8ec9343cf350538abc64ca6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:49:34 +0200 Subject: [PATCH 06/17] Update main cmakelists to qt5 --- CMakeLists.txt | 104 +++++++++++++++++-------------------- cmake/OptionalSource.cmake | 2 +- cmake/Translations.cmake | 2 +- 3 files changed, 51 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d813928c..7fccae8aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,15 +33,22 @@ if (UNIX AND NOT APPLE) set(LINUX 1) endif (UNIX AND NOT APPLE) -find_package(Qt4 4.5.0 REQUIRED QtCore QtGui QtOpenGL QtSql QtNetwork QtXml) +set(QT_MIN_VERSION 5.0.0) + +find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core OpenGL Sql Network Xml Widgets Concurrent) +find_package(X11) +if(X11_FOUND) + find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras) +endif() + if(NOT APPLE) - find_package(Qt4 COMPONENTS QtWebKit) + find_package(Qt5 COMPONENTS WebKitWidgets) endif(NOT APPLE) # Find Qt's lconvert binary. Try qt's binary dir first, fall back to looking in PATH -find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert lconvert-qt4 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH) -find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert lconvert-qt4) +find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert lconvert-qt5 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH) +find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert lconvert-qt5) if(APPLE) if(NOT QT_MAC_USE_COCOA) @@ -68,11 +75,10 @@ pkg_check_modules(GSTREAMER_BASE REQUIRED gstreamer-base-1.0) pkg_check_modules(GSTREAMER_TAG REQUIRED gstreamer-tag-1.0) pkg_check_modules(LIBGPOD libgpod-1.0>=0.7.92) pkg_check_modules(LIBMTP libmtp>=1.0) -pkg_check_modules(LIBMYGPO_QT libmygpo-qt>=1.0.7) +pkg_check_modules(LIBMYGPO_QT5 libmygpo-qt5>=1.0.7) pkg_check_modules(LIBPULSE libpulse) pkg_check_modules(LIBXML libxml-2.0) -pkg_check_modules(QCA qca2) -pkg_check_modules(QJSON REQUIRED QJson) +pkg_check_modules(QCA_QT5 qca2-qt5) pkg_check_modules(SPOTIFY libspotify>=12.1.45) pkg_check_modules(TAGLIB REQUIRED taglib>=1.6) @@ -138,7 +144,6 @@ endif(${CMAKE_BUILD_TYPE} MATCHES "Release") # Set up definitions and paths add_definitions(${QT_DEFINITIONS}) link_directories(${TAGLIB_LIBRARY_DIRS}) -link_directories(${QJSON_LIBRARY_DIRS}) link_directories(${GSTREAMER_LIBRARY_DIRS}) # Don't try to use webkit if their include directories couldn't be found. @@ -148,7 +153,6 @@ endif (NOT QT_QTWEBKIT_INCLUDE_DIR) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${TAGLIB_INCLUDE_DIRS}) -include_directories(${QJSON_INCLUDE_DIRS}) include_directories(${GSTREAMER_INCLUDE_DIRS}) include_directories(${GSTREAMER_APP_INCLUDE_DIRS}) include_directories(${GSTREAMER_AUDIO_INCLUDE_DIRS}) @@ -188,96 +192,96 @@ endif(WIN32) optional_component(BREAKPAD OFF "Crash reporting") -optional_component(GOOGLE_DRIVE ON "Google Drive support" +optional_component(GOOGLE_DRIVE OFF "Google Drive support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(DROPBOX ON "Dropbox support" +optional_component(DROPBOX OFF "Dropbox support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(SKYDRIVE ON "Skydrive support" +optional_component(SKYDRIVE OFF "Skydrive support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(BOX ON "Box support" +optional_component(BOX OFF "Box support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(VK ON "Vk.com support") +optional_component(VK OFF "Vk.com support") -optional_component(SEAFILE ON "Seafile support" +optional_component(SEAFILE OFF "Seafile support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(AUDIOCD ON "Devices: Audio CD support" +optional_component(AUDIOCD OFF "Devices: Audio CD support" DEPENDS "libcdio" CDIO_FOUND ) -optional_component(LIBGPOD ON "Devices: iPod classic support" +optional_component(LIBGPOD OFF "Devices: iPod classic support" DEPENDS "libgpod" LIBGPOD_FOUND ) -optional_component(GIO ON "Devices: GIO device backend" +optional_component(GIO OFF "Devices: GIO device backend" DEPENDS "libgio" GIO_FOUND DEPENDS "Linux or Windows" "NOT APPLE" ) -optional_component(LIBMTP ON "Devices: MTP support" +optional_component(LIBMTP OFF "Devices: MTP support" DEPENDS "libmtp" LIBMTP_FOUND ) -optional_component(LIBLASTFM ON "Last.fm support" +optional_component(LIBLASTFM OFF "Last.fm support" DEPENDS "liblastfm" LASTFM_LIBRARIES LASTFM_INCLUDE_DIRS ) -optional_component(DBUS ON "D-Bus support" +optional_component(DBUS OFF "D-Bus support" DEPENDS "Linux" LINUX ) -optional_component(WIIMOTEDEV ON "Wiimote support" +optional_component(WIIMOTEDEV OFF "Wiimote support" DEPENDS "D-Bus support" HAVE_DBUS ) -optional_component(DEVICEKIT ON "Devices: DeviceKit backend" +optional_component(DEVICEKIT OFF "Devices: DeviceKit backend" DEPENDS "D-Bus support" HAVE_DBUS ) -optional_component(SPOTIFY_BLOB ON "Spotify support: non-GPL binary helper" +optional_component(SPOTIFY_BLOB OFF "Spotify support: non-GPL binary helper" DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE DEPENDS "libspotify" SPOTIFY_FOUND ) -optional_component(MOODBAR ON "Moodbar support" +optional_component(MOODBAR OFF "Moodbar support" DEPENDS "fftw3" FFTW3_FOUND ) -optional_component(SPARKLE ON "Sparkle integration" +optional_component(SPARKLE OFF "Sparkle integration" DEPENDS "Mac OS X" APPLE DEPENDS "Sparkle" SPARKLE ) -optional_component(LIBPULSE ON "Pulse audio integration" +optional_component(LIBPULSE OFF "Pulse audio integration" DEPENDS "libpulse" LIBPULSE_FOUND ) -optional_component(VISUALISATIONS ON "Visualisations") +optional_component(VISUALISATIONS OFF "Visualisations") -if(NOT HAVE_SPOTIFY_BLOB AND NOT QCA_FOUND) - message(FATAL_ERROR "Either QCA must be available or the non-GPL Spotify " +if(NOT HAVE_SPOTIFY_BLOB AND NOT QCA_QT5_FOUND) + message(FATAL_ERROR "Either QCA-qt5 must be available or the non-GPL Spotify " "code must be compiled in") -elseif(QCA_FOUND) +elseif(QCA_QT5_FOUND) set(HAVE_SPOTIFY_DOWNLOADER ON) endif() # Find DBus if it's enabled if (HAVE_DBUS) - find_package(Qt4 REQUIRED QtDbus) + find_package(Qt5 COMPONENTS DBus) endif () if (HAVE_VK) @@ -287,7 +291,7 @@ if (HAVE_VK) endif(HAVE_VK) # We can include the Qt definitions now -include(${QT_USE_FILE}) +set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Sql Qt5::Network Qt5::Xml Qt5::Widgets Qt5::Concurrent Qt5::X11Extras) # Remove GLU and GL from the link line - they're not really required # and don't exist on my mingw toolchain @@ -317,18 +321,9 @@ endif(ENABLE_VISUALISATIONS) add_subdirectory(3rdparty/qsqlite) include_directories("3rdparty/qsqlite") -# When/if upstream accepts our patches then these options can be used to link -# to system installed qtsingleapplication instead. -option(USE_SYSTEM_QTSINGLEAPPLICATION "Don't set this option unless your system QtSingleApplication library has been compiled with the Clementine patches in 3rdparty" OFF) -if(USE_SYSTEM_QTSINGLEAPPLICATION) - find_path(QTSINGLEAPPLICATION_INCLUDE_DIRS qtsingleapplication.h PATH_SUFFIXES QtSolutions) - find_library(QTSINGLEAPPLICATION_LIBRARIES QtSolutions_SingleApplication-2.6) - find_library(QTSINGLECOREAPPLICATION_LIBRARIES QtSolutions_SingleCoreApplication-2.6) -else(USE_SYSTEM_QTSINGLEAPPLICATION) - add_subdirectory(3rdparty/qtsingleapplication) - set(QTSINGLEAPPLICATION_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qtsingleapplication) - set(QTSINGLEAPPLICATION_LIBRARIES qtsingleapplication) -endif(USE_SYSTEM_QTSINGLEAPPLICATION) +add_subdirectory(3rdparty/singleapplication) +set(SINGLEAPPLICATION_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/singleapplication) +set(SINGLEAPPLICATION_LIBRARIES singleapplication) # QtIoCompressor isn't patched, so we can use a system version if it's # available @@ -358,8 +353,8 @@ else (USE_SYSTEM_QXT) endif (NOT APPLE) endif (USE_SYSTEM_QXT) -find_path(ECHONEST_INCLUDE_DIRS echonest/echonest_export.h) -find_library(ECHONEST_LIBRARIES echonest) +find_path(ECHONEST5_INCLUDE_DIRS echonest5/echonest_export.h) +find_library(ECHONEST5_LIBRARIES echonest5) # Use system gmock if it's available # We need to look for both gmock and gtest @@ -388,15 +383,14 @@ else() set(SHA2_LIBRARIES sha2) endif() -# Use the system libmygpo-qt if a recent enough version was found -if(LIBMYGPO_QT_FOUND) - set(MYGPOQT_LIBRARIES ${LIBMYGPO_QT_LIBRARIES}) - set(MYGPOQT_INCLUDE_DIRS ${LIBMYGPO_QT_INCLUDE_DIRS}) +# Use the system libmygpo-qt5 if a recent enough version was found +if(LIBMYGPO_QT5_FOUND) + set(MYGPOQT5_LIBRARIES ${LIBMYGPO_QT5_LIBRARIES}) + set(MYGPOQT5_INCLUDE_DIRS ${LIBMYGPO_QT5_INCLUDE_DIRS}) else() - add_definitions(-DMYGPO_EXPORT=) - add_subdirectory(3rdparty/libmygpo-qt) - set(MYGPOQT_LIBRARIES mygpo-qt) - set(MYGPOQT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/3rdparty/libmygpo-qt/) + add_subdirectory(3rdparty/libmygpo-qt5) + set(MYGPOQT5_LIBRARIES mygpo-qt5) + set(MYGPOQT5_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libmygpo-qt5/src) endif() # Qocoa diff --git a/cmake/OptionalSource.cmake b/cmake/OptionalSource.cmake index 2b816984f..d543e21f9 100644 --- a/cmake/OptionalSource.cmake +++ b/cmake/OptionalSource.cmake @@ -15,7 +15,7 @@ macro(optional_source TOGGLE) list(APPEND OTHER_SOURCES ${OPTIONAL_SOURCE_HEADERS}) set(_uic_sources) - qt4_wrap_ui(_uic_sources ${OPTIONAL_SOURCE_UI}) + qt5_wrap_ui(_uic_sources ${OPTIONAL_SOURCE_UI}) list(APPEND OTHER_SOURCES ${_uic_sources}) list(APPEND OTHER_UIC_SOURCES ${_uic_sources}) endif(${TOGGLE}) diff --git a/cmake/Translations.cmake b/cmake/Translations.cmake index 462145e2c..8ec962992 100644 --- a/cmake/Translations.cmake +++ b/cmake/Translations.cmake @@ -68,5 +68,5 @@ macro(add_po outfiles po_prefix) file(APPEND ${_qrc} "${po_prefix}${_lang}.qm") endforeach(_lang) file(APPEND ${_qrc} "") - qt4_add_resources(${outfiles} ${_qrc}) + qt5_add_resources(${outfiles} ${_qrc}) endmacro(add_po) From 419eb61b546df442844f86fdef04e615737b7b2c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:49:59 +0200 Subject: [PATCH 07/17] Update Clementine spec to qt5 --- dist/clementine.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/clementine.spec.in b/dist/clementine.spec.in index 9717fd265..7ab96e58a 100644 --- a/dist/clementine.spec.in +++ b/dist/clementine.spec.in @@ -10,7 +10,7 @@ Source0: %{name}-@CLEMENTINE_VERSION_SPARKLE@.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: desktop-file-utils liblastfm-devel taglib-devel gettext -BuildRequires: qt4-devel boost-devel gcc-c++ glew-devel libgpod-devel +BuildRequires: qt5-devel boost-devel gcc-c++ glew-devel libgpod-devel BuildRequires: cmake gstreamer1-devel gstreamer1-plugins-base-devel BuildRequires: libmtp-devel protobuf-devel protobuf-compiler libcdio-devel BuildRequires: qjson-devel qca2-devel fftw-devel sparsehash-devel From ded70d655549da40d15c22a3bc4860c0a13c8d76 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:51:40 +0200 Subject: [PATCH 08/17] Update internals CMakeLits to qt5 --- ext/clementine-spotifyblob/CMakeLists.txt | 2 +- ext/clementine-tagreader/CMakeLists.txt | 4 +- ext/libclementine-common/CMakeLists.txt | 4 +- ext/libclementine-tagreader/CMakeLists.txt | 2 +- gst/moodbar/CMakeLists.txt | 2 + src/CMakeLists.txt | 52 ++++++++++----------- tests/CMakeLists.txt | 4 +- tools/ultimate_lyrics_parser/CMakeLists.txt | 3 +- 8 files changed, 39 insertions(+), 34 deletions(-) diff --git a/ext/clementine-spotifyblob/CMakeLists.txt b/ext/clementine-spotifyblob/CMakeLists.txt index f971216b5..96d558c39 100644 --- a/ext/clementine-spotifyblob/CMakeLists.txt +++ b/ext/clementine-spotifyblob/CMakeLists.txt @@ -28,7 +28,7 @@ if(APPLE) list(APPEND SOURCES spotify_utilities.mm) endif(APPLE) -qt4_wrap_cpp(MOC ${HEADERS}) +qt5_wrap_cpp(MOC ${HEADERS}) if(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT ENABLE_WIN32_CONSOLE) set(win32_build_flag WIN32) diff --git a/ext/clementine-tagreader/CMakeLists.txt b/ext/clementine-tagreader/CMakeLists.txt index b88169697..bee991195 100644 --- a/ext/clementine-tagreader/CMakeLists.txt +++ b/ext/clementine-tagreader/CMakeLists.txt @@ -16,8 +16,8 @@ set(SOURCES tagreaderworker.cpp ) -qt4_wrap_cpp(MOC ${HEADERS}) -qt4_add_resources(QRC data/data.qrc) +qt5_wrap_cpp(MOC ${HEADERS}) +qt5_add_resources(QRC data/data.qrc) add_executable(clementine-tagreader ${SOURCES} diff --git a/ext/libclementine-common/CMakeLists.txt b/ext/libclementine-common/CMakeLists.txt index db5b4c0aa..13e3c0a73 100644 --- a/ext/libclementine-common/CMakeLists.txt +++ b/ext/libclementine-common/CMakeLists.txt @@ -21,7 +21,7 @@ set(HEADERS core/workerpool.h ) -qt4_wrap_cpp(MOC ${HEADERS}) +qt5_wrap_cpp(MOC ${HEADERS}) add_library(libclementine-common STATIC ${SOURCES} @@ -33,3 +33,5 @@ target_link_libraries(libclementine-common ${TAGLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) + +QT5_USE_MODULES(libclementine-common Core Network) diff --git a/ext/libclementine-tagreader/CMakeLists.txt b/ext/libclementine-tagreader/CMakeLists.txt index 52372a16b..ba9e3ff31 100644 --- a/ext/libclementine-tagreader/CMakeLists.txt +++ b/ext/libclementine-tagreader/CMakeLists.txt @@ -27,7 +27,7 @@ optional_source(HAVE_GOOGLE_DRIVE cloudstream.h ) -qt4_wrap_cpp(MOC ${HEADERS}) +qt5_wrap_cpp(MOC ${HEADERS}) protobuf_generate_cpp(PROTO_SOURCES PROTO_HEADERS ${MESSAGES}) diff --git a/gst/moodbar/CMakeLists.txt b/gst/moodbar/CMakeLists.txt index 44c136253..2606c1baa 100644 --- a/gst/moodbar/CMakeLists.txt +++ b/gst/moodbar/CMakeLists.txt @@ -27,3 +27,5 @@ target_link_libraries(gstmoodbar ${GSTREAMER_BASE_LIBRARIES} ${FFTW3_FFTW_LIBRARY} ) + +QT5_USE_MODULES(gstmoodbar Core) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 917db286a..b9cc0d438 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,13 +32,13 @@ include_directories(${GLIB_INCLUDE_DIRS}) include_directories(${LIBXML_INCLUDE_DIRS}) include_directories(${GOBJECT_INCLUDE_DIRS}) include_directories(${LIBPROJECTM_INCLUDE_DIRS}) -include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIRS}) +include_directories(${SINGLEAPPLICATION_INCLUDE_DIRS}) include_directories(${QTIOCOMPRESSOR_INCLUDE_DIRS}) include_directories(${QXT_INCLUDE_DIRS}) -include_directories(${ECHONEST_INCLUDE_DIRS}) +include_directories(${ECHONEST5_INCLUDE_DIRS}) include_directories(${SHA2_INCLUDE_DIRS}) include_directories(${CHROMAPRINT_INCLUDE_DIRS}) -include_directories(${MYGPOQT_INCLUDE_DIRS}) +include_directories(${MYGPOQT5_INCLUDE_DIRS}) find_package(OpenGL) include_directories(${OPENGL_INCLUDE_DIR}) @@ -852,7 +852,7 @@ optional_source(HAVE_SPOTIFY_DOWNLOADER HEADERS internet/spotify/spotifyblobdownloader.h INCLUDE_DIRECTORIES - ${QCA_INCLUDE_DIRS} + ${QCA_QT5_INCLUDE_DIRS} ) # Platform specific - OS X @@ -896,39 +896,39 @@ if(HAVE_DBUS) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dbus) # MPRIS DBUS interfaces - qt4_add_dbus_adaptor(SOURCES + qt5_add_dbus_adaptor(SOURCES dbus/org.freedesktop.MediaPlayer.player.xml core/mpris1.h mpris::Mpris1Player core/mpris_player MprisPlayer) - qt4_add_dbus_adaptor(SOURCES + qt5_add_dbus_adaptor(SOURCES dbus/org.freedesktop.MediaPlayer.root.xml core/mpris1.h mpris::Mpris1Root core/mpris_root MprisRoot) - qt4_add_dbus_adaptor(SOURCES + qt5_add_dbus_adaptor(SOURCES dbus/org.freedesktop.MediaPlayer.tracklist.xml core/mpris1.h mpris::Mpris1TrackList core/mpris_tracklist MprisTrackList) # MPRIS 2.0 DBUS interfaces - qt4_add_dbus_adaptor(SOURCES + qt5_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.Player.xml core/mpris2.h mpris::Mpris2 core/mpris2_player Mpris2Player) - qt4_add_dbus_adaptor(SOURCES + qt5_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.xml core/mpris2.h mpris::Mpris2 core/mpris2_root Mpris2Root) - qt4_add_dbus_adaptor(SOURCES + qt5_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.TrackList.xml core/mpris2.h mpris::Mpris2 core/mpris2_tracklist Mpris2TrackList) # MPRIS 2.1 DBUS interfaces - qt4_add_dbus_adaptor(SOURCES + qt5_add_dbus_adaptor(SOURCES dbus/org.mpris.MediaPlayer2.Playlists.xml core/mpris2.h mpris::Mpris2 core/mpris2_playlists Mpris2Playlists) # org.freedesktop.Notifications DBUS interface - qt4_add_dbus_interface(SOURCES + qt5_add_dbus_interface(SOURCES dbus/org.freedesktop.Notifications.xml dbus/notification) # org.gnome.SettingsDaemon interface - qt4_add_dbus_interface(SOURCES + qt5_add_dbus_interface(SOURCES dbus/org.gnome.SettingsDaemon.MediaKeys.xml dbus/gnomesettingsdaemon) @@ -966,17 +966,17 @@ if(HAVE_DBUS) PROPERTIES NO_NAMESPACE dbus/udisks) set_source_files_properties(dbus/org.freedesktop.UDisks.Device.xml PROPERTIES NO_NAMESPACE dbus/udisksdevice) - qt4_add_dbus_interface(SOURCES + qt5_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks.xml dbus/udisks) - qt4_add_dbus_interface(SOURCES + qt5_add_dbus_interface(SOURCES dbus/org.freedesktop.UDisks.Device.xml dbus/udisksdevice) endif(HAVE_DEVICEKIT) # Wiimotedev interface classes if(ENABLE_WIIMOTEDEV) - qt4_add_dbus_interface(SOURCES + qt5_add_dbus_interface(SOURCES dbus/org.wiimotedev.deviceEvents.xml dbus/wiimotedev) endif(ENABLE_WIIMOTEDEV) @@ -1197,9 +1197,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) -qt4_wrap_cpp(MOC ${HEADERS}) -qt4_wrap_ui(UIC ${UI}) -qt4_add_resources(QRC ${RESOURCES}) +qt5_wrap_cpp(MOC ${HEADERS}) +qt5_wrap_ui(UIC ${UI}) +qt5_add_resources(QRC ${RESOURCES}) + add_pot(POT ${CMAKE_CURRENT_SOURCE_DIR}/translations/header @@ -1232,18 +1233,17 @@ target_link_libraries(clementine_lib libclementine-remote ${SHA2_LIBRARIES} ${TAGLIB_LIBRARIES} - ${MYGPOQT_LIBRARIES} + ${MYGPOQT5_LIBRARIES} ${CHROMAPRINT_LIBRARIES} - ${ECHONEST_LIBRARIES} + ${ECHONEST5_LIBRARIES} ${GOBJECT_LIBRARIES} ${GLIB_LIBRARIES} - ${QJSON_LIBRARIES} ${QT_LIBRARIES} ${GSTREAMER_BASE_LIBRARIES} ${GSTREAMER_LIBRARIES} ${GSTREAMER_APP_LIBRARIES} ${GSTREAMER_TAG_LIBRARIES} - ${QTSINGLEAPPLICATION_LIBRARIES} + ${SINGLEAPPLICATION_LIBRARIES} ${QTSINGLECOREAPPLICATION_LIBRARIES} ${QTIOCOMPRESSOR_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} @@ -1297,9 +1297,9 @@ endif(HAVE_BREAKPAD) if(HAVE_SPOTIFY_DOWNLOADER) target_link_libraries(clementine_lib - ${QCA_LIBRARIES} + ${QCA_QT5_LIBRARIES} ) - link_directories(${QCA_LIBRARY_DIRS}) + link_directories(${QCA_QT5_LIBRARY_DIRS}) endif(HAVE_SPOTIFY_DOWNLOADER) if(HAVE_LIBPULSE) @@ -1352,7 +1352,7 @@ if (UNIX AND NOT APPLE) endif () endif () -add_dependencies(clementine_lib qtsingleapplication) +add_dependencies(clementine_lib singleapplication) ############################################################################### diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f7d0a42ac..7c46c02d2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -69,7 +69,7 @@ set(TESTUTILS-MOC-HEADERS testobjectdecorators.h ) -qt4_wrap_cpp(TESTUTILS-SOURCES-MOC ${TESTUTILS-MOC-HEADERS}) +qt5_wrap_cpp(TESTUTILS-SOURCES-MOC ${TESTUTILS-MOC-HEADERS}) add_library(test_utils STATIC EXCLUDE_FROM_ALL ${TESTUTILS-SOURCES} ${TESTUTILS-SOURCES-MOC}) target_link_libraries(test_utils ${GMOCK_LIBRARIES} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY}) @@ -83,7 +83,7 @@ add_custom_target(build_tests ) add_dependencies(test build_tests) -qt4_add_resources(TEST-RESOURCE-SOURCES data/testdata.qrc) +qt5_add_resources(TEST-RESOURCE-SOURCES data/testdata.qrc) add_library(test_gui_main STATIC EXCLUDE_FROM_ALL ${TEST-RESOURCE-SOURCES} main.cpp) target_link_libraries(test_gui_main clementine_lib) diff --git a/tools/ultimate_lyrics_parser/CMakeLists.txt b/tools/ultimate_lyrics_parser/CMakeLists.txt index 7c41e6601..e410d2eb4 100644 --- a/tools/ultimate_lyrics_parser/CMakeLists.txt +++ b/tools/ultimate_lyrics_parser/CMakeLists.txt @@ -4,4 +4,5 @@ set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-Woverloaded-virtual -Wall -Wno-sign-compare ${CMAKE_CXX_FLAGS}") add_executable(ultimate_lyrics_parser EXCLUDE_FROM_ALL main.cpp) -target_link_libraries(ultimate_lyrics_parser ${QT_LIBRARIES}) + +target_link_libraries(ultimate_lyrics_parser Qt5::Core) From 8b226c21710864c6f92d124647c65ba8dc4873eb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 11 Apr 2015 22:52:31 +0200 Subject: [PATCH 09/17] Update non optionnals sources to qt5 --- ext/libclementine-common/core/logging.cpp | 23 ++- src/core/database.cpp | 44 ++-- src/core/mergedproxymodel.cpp | 9 +- src/core/metatypes.cpp | 2 +- src/core/organiseformat.h | 1 + src/core/potranslator.h | 2 +- src/core/qxtglobalshortcutbackend.cpp | 1 - src/core/qxtglobalshortcutbackend.h | 1 + src/covers/amazoncoverprovider.cpp | 9 +- src/covers/musicbrainzcoverprovider.cpp | 7 +- src/dbus/org.mpris.MediaPlayer2.TrackList.xml | 15 +- src/devices/devicedatabasebackend.cpp | 24 +-- src/devices/deviceproperties.cpp | 2 +- src/engines/gstengine.cpp | 2 +- src/engines/gstenginepipeline.cpp | 2 +- src/globalsearch/globalsearchsettingspage.cpp | 4 +- src/internet/core/geolocator.cpp | 16 +- .../core/internetshowsettingspage.cpp | 4 +- src/internet/core/oauthenticator.cpp | 55 ++--- .../digitally/digitallyimportedclient.cpp | 63 +++--- .../grooveshark/groovesharkservice.cpp | 191 +++++++++-------- src/internet/grooveshark/groovesharkservice.h | 16 +- src/internet/icecast/icecastbackend.cpp | 21 +- src/internet/icecast/icecastmodel.cpp | 3 +- .../jamendo/jamendodynamicplaylist.cpp | 32 +-- src/internet/jamendo/jamendoservice.cpp | 6 +- .../magnatune/magnatunedownloaddialog.cpp | 11 +- src/internet/magnatune/magnatuneservice.cpp | 2 +- src/internet/podcasts/itunessearchpage.cpp | 41 ++-- src/internet/podcasts/podcastbackend.cpp | 81 ++++---- src/internet/podcasts/podcastparser.cpp | 12 +- src/internet/podcasts/podcasturlloader.cpp | 6 +- src/internet/soundcloud/soundcloudservice.cpp | 100 ++++----- src/internet/soundcloud/soundcloudservice.h | 9 +- src/internet/subsonic/subsonicservice.cpp | 23 ++- src/internet/subsonic/subsonicurlhandler.cpp | 6 +- src/library/librarybackend.cpp | 192 +++++++++--------- src/library/librarymodel.cpp | 3 +- src/library/libraryquery.cpp | 3 +- src/main.cpp | 49 +---- src/musicbrainz/acoustidclient.cpp | 39 ++-- src/musicbrainz/chromaprinter.cpp | 2 +- src/musicbrainz/musicbrainzclient.cpp | 9 +- src/networkremote/outgoingdatacreator.cpp | 2 +- src/playlist/playlistbackend.cpp | 58 +++--- src/playlist/playlistdelegates.cpp | 4 +- src/playlist/playlistview.cpp | 11 +- src/playlist/playlistview.h | 6 +- src/smartplaylists/searchtermwidget.cpp | 2 +- src/songinfo/songinfobase.cpp | 2 +- src/songinfo/songkickconcerts.cpp | 48 ++--- src/songinfo/songkickconcertwidget.cpp | 9 +- src/songinfo/ultimatelyricsprovider.cpp | 4 +- src/transcoder/transcodedialog.cpp | 2 +- src/transcoder/transcoder.cpp | 6 +- src/ui/albumcoverchoicecontroller.cpp | 1 + src/ui/edittagdialog.cpp | 13 +- src/ui/flowlayout.cpp | 2 +- src/ui/globalshortcutssettingspage.cpp | 2 +- src/ui/mainwindow.cpp | 1 - src/ui/qtsystemtrayicon.cpp | 12 +- src/widgets/errordialog.cpp | 2 +- src/widgets/fancytabwidget.cpp | 8 +- src/widgets/forcescrollperpixel.cpp | 3 +- src/widgets/groupediconview.cpp | 2 +- src/widgets/groupediconview.h | 2 +- src/widgets/nowplayingwidget.cpp | 4 +- src/widgets/stylehelper.cpp | 8 +- src/widgets/stylehelper.h | 4 +- tests/scopedtransaction_test.cpp | 9 +- tools/ultimate_lyrics_parser/main.cpp | 2 - 71 files changed, 714 insertions(+), 658 deletions(-) diff --git a/ext/libclementine-common/core/logging.cpp b/ext/libclementine-common/core/logging.cpp index acbc0e2f0..b0a3564d8 100644 --- a/ext/libclementine-common/core/logging.cpp +++ b/ext/libclementine-common/core/logging.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -43,7 +44,7 @@ const char* kDefaultLogLevels = "GstEnginePipeline:2,*:3"; static const char* kMessageHandlerMagic = "__logging_message__"; static const int kMessageHandlerMagicLength = strlen(kMessageHandlerMagic); -static QtMsgHandler sOriginalMessageHandler = nullptr; +static QtMessageHandler sOriginalMessageHandler = nullptr; void GLog(const char* domain, int level, const char* message, void* user_data) { switch (level) { @@ -67,9 +68,9 @@ void GLog(const char* domain, int level, const char* message, void* user_data) { } } -static void MessageHandler(QtMsgType type, const char* message) { - if (strncmp(kMessageHandlerMagic, message, kMessageHandlerMagicLength) == 0) { - fprintf(stderr, "%s\n", message + kMessageHandlerMagicLength); +static void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message) { + if (strncmp(kMessageHandlerMagic, message.toLocal8Bit().data(), kMessageHandlerMagicLength) == 0) { + fprintf(stderr, "%s\n", message.toLocal8Bit().data() + kMessageHandlerMagicLength); return; } @@ -88,7 +89,7 @@ static void MessageHandler(QtMsgType type, const char* message) { break; } - for (const QString& line : QString::fromLocal8Bit(message).split('\n')) { + for (const QString& line : message.split('\n')) { CreateLogger(level, "unknown", -1) << line.toLocal8Bit().constData(); } @@ -106,7 +107,7 @@ void Init() { // Catch other messages from Qt if (!sOriginalMessageHandler) { - sOriginalMessageHandler = qInstallMsgHandler(MessageHandler); + sOriginalMessageHandler = qInstallMessageHandler(MessageHandler); } } @@ -204,9 +205,9 @@ QDebug CreateLogger(Level level, const QString& class_name, int line) { QDebug ret(type); ret.nospace() << kMessageHandlerMagic << QDateTime::currentDateTime() .toString("hh:mm:ss.zzz") - .toAscii() + .toLatin1() .constData() << level_name - << function_line.leftJustified(32).toAscii().constData(); + << function_line.leftJustified(32).toLatin1().constData(); return ret.space(); } @@ -214,9 +215,9 @@ QDebug CreateLogger(Level level, const QString& class_name, int line) { QString CXXDemangle(const QString& mangled_function) { int status; char* demangled_function = abi::__cxa_demangle( - mangled_function.toAscii().constData(), nullptr, nullptr, &status); + mangled_function.toLatin1().constData(), nullptr, nullptr, &status); if (status == 0) { - QString ret = QString::fromAscii(demangled_function); + QString ret = QString::fromLatin1(demangled_function); free(demangled_function); return ret; } @@ -257,7 +258,7 @@ void DumpStackTrace() { backtrace_symbols(reinterpret_cast(&callstack), callstack_size); // Start from 1 to skip ourself. for (int i = 1; i < callstack_size; ++i) { - qLog(Debug) << DemangleSymbol(QString::fromAscii(symbols[i])); + qLog(Debug) << DemangleSymbol(QString::fromLatin1(symbols[i])); } free(symbols); #else diff --git a/src/core/database.cpp b/src/core/database.cpp index e351aa32e..908ee7f4b 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -265,13 +265,14 @@ QSqlDatabase Database::Connect() { StaticInit(); { - QSqlQuery set_fts_tokenizer("SELECT fts3_tokenizer(:name, :pointer)", db); + QSqlQuery set_fts_tokenizer(db); + set_fts_tokenizer.prepare("SELECT fts3_tokenizer(:name, :pointer)"); set_fts_tokenizer.bindValue(":name", "unicode"); set_fts_tokenizer.bindValue( ":pointer", QByteArray(reinterpret_cast(&sFTSTokenizer), sizeof(&sFTSTokenizer))); if (!set_fts_tokenizer.exec()) { - qLog(Warning) << "Couldn't register FTS3 tokenizer"; + qLog(Warning) << "Couldn't register FTS3 tokenizer : " << set_fts_tokenizer.lastError(); } // Implicit invocation of ~QSqlQuery() when leaving the scope // to release any remaining database locks! @@ -290,12 +291,13 @@ QSqlDatabase Database::Connect() { if (!injected_database_name_.isNull()) filename = injected_database_name_; // Attach the db - QSqlQuery q("ATTACH DATABASE :filename AS :alias", db); + QSqlQuery q(db); + q.prepare("ATTACH DATABASE :filename AS :alias"); q.bindValue(":filename", filename); q.bindValue(":alias", key); if (!q.exec()) { qFatal("Couldn't attach external database '%s'", - key.toAscii().constData()); + key.toLatin1().constData()); } } @@ -310,10 +312,10 @@ QSqlDatabase Database::Connect() { attached_databases_[key].schema_.isEmpty()) continue; // Find out if there are any tables in this database - QSqlQuery q(QString( + QSqlQuery q(db); + q.prepare(QString( "SELECT ROWID FROM %1.sqlite_master" - " WHERE type='table'").arg(key), - db); + " WHERE type='table'").arg(key)); if (!q.exec() || !q.next()) { q.finish(); ExecSchemaCommandsFromFile(db, attached_databases_[key].schema_, 0); @@ -360,7 +362,8 @@ void Database::RecreateAttachedDb(const QString& database_name) { { QSqlDatabase db(Connect()); - QSqlQuery q("DETACH DATABASE :alias", db); + QSqlQuery q(db); + q.prepare("DETACH DATABASE :alias"); q.bindValue(":alias", database_name); if (!q.exec()) { qLog(Warning) << "Failed to detach database" << database_name; @@ -391,12 +394,13 @@ void Database::AttachDatabaseOnDbConnection(const QString& database_name, AttachDatabase(database_name, database); // Attach the db - QSqlQuery q("ATTACH DATABASE :filename AS :alias", db); + QSqlQuery q(db); + q.prepare("ATTACH DATABASE :filename AS :alias"); q.bindValue(":filename", database.filename_); q.bindValue(":alias", database_name); if (!q.exec()) { qFatal("Couldn't attach external database '%s'", - database_name.toAscii().constData()); + database_name.toLatin1().constData()); } } @@ -405,7 +409,8 @@ void Database::DetachDatabase(const QString& database_name) { { QSqlDatabase db(Connect()); - QSqlQuery q("DETACH DATABASE :alias", db); + QSqlQuery q(db); + q.prepare("DETACH DATABASE :alias"); q.bindValue(":alias", database_name); if (!q.exec()) { qLog(Warning) << "Failed to detach database" << database_name; @@ -448,10 +453,10 @@ void Database::UpdateDatabaseSchema(int version, QSqlDatabase& db) { } void Database::UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db) { - QSqlQuery select(QString("SELECT ROWID, filename FROM %1").arg(table), db); - QSqlQuery update( - QString("UPDATE %1 SET filename=:filename WHERE ROWID=:id").arg(table), - db); + QSqlQuery select(db); + select.prepare(QString("SELECT ROWID, filename FROM %1").arg(table)); + QSqlQuery update(db); + update.prepare(QString("UPDATE %1 SET filename=:filename WHERE ROWID=:id").arg(table)); select.exec(); if (CheckErrors(select)) return; while (select.next()) { @@ -545,12 +550,11 @@ QStringList Database::SongsTables(QSqlDatabase& db, int schema_version) const { // look for the tables in attached dbs for (const QString& key : attached_databases_.keys()) { - QSqlQuery q( - QString( + QSqlQuery q(db); + q.prepare(QString( "SELECT NAME FROM %1.sqlite_master" " WHERE type='table' AND name='songs' OR name LIKE '%songs'") - .arg(key), - db); + .arg(key)); if (q.exec()) { while (q.next()) { QString tab_name = key + "." + q.value(0).toString(); @@ -587,7 +591,7 @@ bool Database::IntegrityCheck(QSqlDatabase db) { bool ok = false; bool error_reported = false; // Ask for 10 error messages at most. - QSqlQuery q(QString("PRAGMA integrity_check(10)"), db); + QSqlQuery q("PRAGMA integrity_check(10)", db); while (q.next()) { QString message = q.value(0).toString(); diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index 56217f6fd..e7f6587f9 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -183,12 +183,14 @@ void MergedProxyModel::SourceModelReset() { // Delete all mappings DeleteAllMappings(); + // Reset the proxy + beginResetModel(); + // Clear the containers p_->mappings_.clear(); merge_points_.clear(); - // Reset the proxy - reset(); + endResetModel(); } void MergedProxyModel::SubModelReset() { @@ -497,7 +499,8 @@ void MergedProxyModel::LayoutChanged() { const int new_row = merge_points_[key].row(); if (old_row != new_row) { - reset(); + beginResetModel(); + endResetModel(); return; } } diff --git a/src/core/metatypes.cpp b/src/core/metatypes.cpp index daf5b71f7..7691e4e32 100644 --- a/src/core/metatypes.cpp +++ b/src/core/metatypes.cpp @@ -29,6 +29,7 @@ #include "covers/albumcoverfetcher.h" #include "engines/enginebase.h" #include "engines/gstengine.h" +#include "engines/gstenginepipeline.h" #include "globalsearch/searchprovider.h" #include "internet/digitally/digitallyimportedclient.h" #include "internet/core/geolocator.h" @@ -53,7 +54,6 @@ class GstEnginePipeline; class QNetworkReply; void RegisterMetaTypes() { - qRegisterMetaType("ColumnAlignmentMap"); qRegisterMetaType("const char*"); qRegisterMetaType("CoverSearchResult"); qRegisterMetaType("CoverSearchResults"); diff --git a/src/core/organiseformat.h b/src/core/organiseformat.h index e24a22461..77005794c 100644 --- a/src/core/organiseformat.h +++ b/src/core/organiseformat.h @@ -22,6 +22,7 @@ #include #include +#include #include "core/song.h" diff --git a/src/core/potranslator.h b/src/core/potranslator.h index eafdccf2f..e92ba3429 100644 --- a/src/core/potranslator.h +++ b/src/core/potranslator.h @@ -29,7 +29,7 @@ class PoTranslator : public QTranslator { public: QString translate(const char* context, const char* source_text, - const char* disambiguation = 0) const { + const char* disambiguation = 0, int n = -1) const { QString ret = QTranslator::translate(context, source_text, disambiguation); if (!ret.isEmpty()) return ret; return QTranslator::translate(nullptr, source_text, disambiguation); diff --git a/src/core/qxtglobalshortcutbackend.cpp b/src/core/qxtglobalshortcutbackend.cpp index f33b3e325..c04e41d4a 100644 --- a/src/core/qxtglobalshortcutbackend.cpp +++ b/src/core/qxtglobalshortcutbackend.cpp @@ -40,7 +40,6 @@ bool QxtGlobalShortcutBackend::DoRegister() { void QxtGlobalShortcutBackend::AddShortcut(QAction* action) { if (action->shortcut().isEmpty()) return; - QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(action->shortcut(), this); connect(shortcut, SIGNAL(activated()), action, SLOT(trigger())); shortcuts_ << shortcut; diff --git a/src/core/qxtglobalshortcutbackend.h b/src/core/qxtglobalshortcutbackend.h index 32361291c..4976241c5 100644 --- a/src/core/qxtglobalshortcutbackend.h +++ b/src/core/qxtglobalshortcutbackend.h @@ -23,6 +23,7 @@ #include "globalshortcutbackend.h" class QxtGlobalShortcut; +class QAction; class QxtGlobalShortcutBackend : public GlobalShortcutBackend { public: diff --git a/src/covers/amazoncoverprovider.cpp b/src/covers/amazoncoverprovider.cpp index 63aead35a..7d991bb0d 100644 --- a/src/covers/amazoncoverprovider.cpp +++ b/src/covers/amazoncoverprovider.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "core/closure.h" #include "core/logging.h" @@ -79,14 +80,14 @@ bool AmazonCoverProvider::StartSearch(const QString& artist, const QByteArray data_to_sign = QString("GET\n%1\n%2\n%3") .arg(url.host(), url.path(), query_items.join("&")) - .toAscii(); + .toLatin1(); const QByteArray signature(Utilities::HmacSha256( QByteArray::fromBase64(kSecretAccessKeyB64), data_to_sign)); // Add the signature to the request - encoded_args << EncodedArg("Signature", - QUrl::toPercentEncoding(signature.toBase64())); - url.setEncodedQueryItems(encoded_args); + QUrlQuery url_query; + url_query.addQueryItem("Signature", QUrl::toPercentEncoding(signature.toBase64())); + url.setQuery(url_query); QNetworkReply* reply = network_->get(QNetworkRequest(url)); NewClosure(reply, SIGNAL(finished()), this, diff --git a/src/covers/musicbrainzcoverprovider.cpp b/src/covers/musicbrainzcoverprovider.cpp index 827bd085c..fffaab179 100644 --- a/src/covers/musicbrainzcoverprovider.cpp +++ b/src/covers/musicbrainzcoverprovider.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "core/closure.h" #include "core/network.h" @@ -46,8 +47,10 @@ bool MusicbrainzCoverProvider::StartSearch(const QString& artist, QString query = QString("release:\"%1\" AND artist:\"%2\"") .arg(album.trimmed().replace('"', "\\\"")) .arg(artist.trimmed().replace('"', "\\\"")); - url.addQueryItem("query", query); - url.addQueryItem("limit", "5"); + QUrlQuery url_query; + url_query.addQueryItem("query", query); + url_query.addQueryItem("limit", "5"); + url.setQuery(url_query); QNetworkRequest request(url); QNetworkReply* reply = network_->get(request); diff --git a/src/dbus/org.mpris.MediaPlayer2.TrackList.xml b/src/dbus/org.mpris.MediaPlayer2.TrackList.xml index 51b4bbc6a..5b609c7b3 100644 --- a/src/dbus/org.mpris.MediaPlayer2.TrackList.xml +++ b/src/dbus/org.mpris.MediaPlayer2.TrackList.xml @@ -5,9 +5,8 @@ - - - + + @@ -25,19 +24,17 @@ - - - + + - - - + + diff --git a/src/devices/devicedatabasebackend.cpp b/src/devices/devicedatabasebackend.cpp index 14f28ed66..308805507 100644 --- a/src/devices/devicedatabasebackend.cpp +++ b/src/devices/devicedatabasebackend.cpp @@ -36,11 +36,10 @@ DeviceDatabaseBackend::DeviceList DeviceDatabaseBackend::GetAllDevices() { DeviceList ret; - QSqlQuery q( - "SELECT ROWID, unique_id, friendly_name, size, icon," + QSqlQuery q(db); + q.prepare("SELECT ROWID, unique_id, friendly_name, size, icon," " transcode_mode, transcode_format" - " FROM devices", - db); + " FROM devices"); q.exec(); if (db_->CheckErrors(q)) return ret; @@ -65,13 +64,12 @@ int DeviceDatabaseBackend::AddDevice(const Device& device) { ScopedTransaction t(&db); // Insert the device into the devices table - QSqlQuery q( - "INSERT INTO devices (" + QSqlQuery q(db); + q.prepare("INSERT INTO devices (" " unique_id, friendly_name, size, icon," " transcode_mode, transcode_format)" " VALUES (:unique_id, :friendly_name, :size, :icon," - " :transcode_mode, :transcode_format)", - db); + " :transcode_mode, :transcode_format)"); q.bindValue(":unique_id", device.unique_id_); q.bindValue(":friendly_name", device.friendly_name_); q.bindValue(":size", device.size_); @@ -103,7 +101,8 @@ void DeviceDatabaseBackend::RemoveDevice(int id) { ScopedTransaction t(&db); // Remove the device from the devices table - QSqlQuery q("DELETE FROM devices WHERE ROWID=:id", db); + QSqlQuery q(db); + q.prepare("DELETE FROM devices WHERE ROWID=:id"); q.bindValue(":id", id); q.exec(); if (db_->CheckErrors(q)) return; @@ -125,14 +124,13 @@ void DeviceDatabaseBackend::SetDeviceOptions(int id, QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q( - "UPDATE devices" + QSqlQuery q(db); + q.prepare("UPDATE devices" " SET friendly_name=:friendly_name," " icon=:icon_name," " transcode_mode=:transcode_mode," " transcode_format=:transcode_format" - " WHERE ROWID=:id", - db); + " WHERE ROWID=:id"); q.bindValue(":friendly_name", friendly_name); q.bindValue(":icon_name", icon_name); q.bindValue(":transcode_mode", mode); diff --git a/src/devices/deviceproperties.cpp b/src/devices/deviceproperties.cpp index c097d409d..1b6cd2f64 100644 --- a/src/devices/deviceproperties.cpp +++ b/src/devices/deviceproperties.cpp @@ -155,7 +155,7 @@ void DeviceProperties::UpdateHardwareInfo() { AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id)); AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id)); for (const QString& key : info.keys()) { - AddHardwareInfo(row++, tr(key.toAscii()), info[key].toString()); + AddHardwareInfo(row++, tr(key.toLatin1()), info[key].toString()); } ui_->hardware_info->sortItems(0); diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index 7f903ff7b..35b9bbfc7 100755 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -709,7 +709,7 @@ GstElement* GstEngine::CreateElement(const QString& factoryName, QString name = factoryName + "-" + QString::number(next_element_id_++); GstElement* element = gst_element_factory_make( - factoryName.toAscii().constData(), name.toAscii().constData()); + factoryName.toLatin1().constData(), name.toLatin1().constData()); if (!element) { emit Error(QString( diff --git a/src/engines/gstenginepipeline.cpp b/src/engines/gstenginepipeline.cpp index 7f48f1fb2..d381f0b04 100644 --- a/src/engines/gstenginepipeline.cpp +++ b/src/engines/gstenginepipeline.cpp @@ -413,7 +413,7 @@ bool GstEnginePipeline::InitFromString(const QString& pipeline) { pipeline_ = gst_pipeline_new("pipeline"); GstElement* new_bin = - CreateDecodeBinFromString(pipeline.toAscii().constData()); + CreateDecodeBinFromString(pipeline.toLatin1().constData()); if (!new_bin) { return false; } diff --git a/src/globalsearch/globalsearchsettingspage.cpp b/src/globalsearch/globalsearchsettingspage.cpp index 460d63a81..3ea953630 100644 --- a/src/globalsearch/globalsearchsettingspage.cpp +++ b/src/globalsearch/globalsearchsettingspage.cpp @@ -28,8 +28,8 @@ GlobalSearchSettingsPage::GlobalSearchSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui::GlobalSearchSettingsPage) { ui_->setupUi(this); - ui_->sources->header()->setResizeMode(0, QHeaderView::Stretch); - ui_->sources->header()->setResizeMode(1, QHeaderView::ResizeToContents); + ui_->sources->header()->setSectionResizeMode(0, QHeaderView::Stretch); + ui_->sources->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); warning_icon_ = IconLoader::Load("dialog-warning"); diff --git a/src/internet/core/geolocator.cpp b/src/internet/core/geolocator.cpp index f527dd81d..990308d0c 100644 --- a/src/internet/core/geolocator.cpp +++ b/src/internet/core/geolocator.cpp @@ -22,9 +22,10 @@ #include #include -#include - #include +#include +#include +#include #include "core/closure.h" #include "core/logging.h" @@ -97,16 +98,15 @@ void Geolocator::RequestFinished(QNetworkReply* reply) { return; } - QJson::Parser parser; - bool ok = false; - QVariant result = parser.parse(reply, &ok); - if (!ok) { + QJsonParseError error; + QJsonDocument json_document = QJsonDocument::fromJson(reply->readAll(), &error); + if (error.error != QJsonParseError::NoError) { emit Finished(LatLng()); return; } - QVariantMap map = result.toMap(); - QString latlng = map["latlng"].toString(); + QJsonObject json_object = json_document.object(); + QString latlng = json_object["latlng"].toString(); LatLng ll(latlng); emit Finished(ll); diff --git a/src/internet/core/internetshowsettingspage.cpp b/src/internet/core/internetshowsettingspage.cpp index 6df377921..639f22ab7 100644 --- a/src/internet/core/internetshowsettingspage.cpp +++ b/src/internet/core/internetshowsettingspage.cpp @@ -29,8 +29,8 @@ InternetShowSettingsPage::InternetShowSettingsPage(SettingsDialog* parent) : SettingsPage(parent), ui_(new Ui::InternetShowSettingsPage) { ui_->setupUi(this); - ui_->sources->header()->setResizeMode(0, QHeaderView::Stretch); - ui_->sources->header()->setResizeMode(1, QHeaderView::ResizeToContents); + ui_->sources->header()->setSectionResizeMode(0, QHeaderView::Stretch); + ui_->sources->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); } void InternetShowSettingsPage::Load() { diff --git a/src/internet/core/oauthenticator.cpp b/src/internet/core/oauthenticator.cpp index 8996da5f4..08f78f947 100644 --- a/src/internet/core/oauthenticator.cpp +++ b/src/internet/core/oauthenticator.cpp @@ -23,8 +23,10 @@ #include #include #include - -#include +#include +#include +#include +#include #include "core/closure.h" #include "core/logging.h" @@ -49,24 +51,29 @@ void OAuthenticator::StartAuthorisation(const QString& oauth_endpoint, server->Listen(); QUrl url = QUrl(oauth_endpoint); - url.addQueryItem("response_type", "code"); - url.addQueryItem("client_id", client_id_); + QUrlQuery url_query; + url_query.addQueryItem("response_type", "code"); + url_query.addQueryItem("client_id", client_id_); QUrl redirect_url; + QUrlQuery redirect_url_query; const QString port = QString::number(server->url().port()); if (redirect_style_ == RedirectStyle::REMOTE) { redirect_url = QUrl(kRemoteURL); - redirect_url.addQueryItem("port", port); + redirect_url_query.addQueryItem("port", port); } else if (redirect_style_ == RedirectStyle::REMOTE_WITH_STATE) { redirect_url = QUrl(kRemoteURL); - url.addQueryItem("state", port); + url_query.addQueryItem("state", port); } else { redirect_url = server->url(); } - url.addQueryItem("redirect_uri", redirect_url.toString()); - url.addQueryItem("scope", scope); + url_query.addQueryItem("redirect_uri", redirect_url.toString()); + url_query.addQueryItem("scope", scope); + + url.setQuery(url_query); + redirect_url.setQuery(redirect_url_query); NewClosure(server, SIGNAL(Finished()), this, &OAuthenticator::RedirectArrived, server, redirect_url); @@ -78,7 +85,7 @@ void OAuthenticator::RedirectArrived(LocalRedirectServer* server, QUrl url) { server->deleteLater(); QUrl request_url = server->request_url(); qLog(Debug) << Q_FUNC_INFO << request_url; - RequestAccessToken(request_url.queryItemValue("code").toUtf8(), url); + RequestAccessToken(QUrlQuery(request_url).queryItemValue("code").toUtf8(), url); } QByteArray OAuthenticator::ParseHttpRequest(const QByteArray& request) const { @@ -126,19 +133,20 @@ void OAuthenticator::FetchAccessTokenFinished(QNetworkReply* reply) { return; } - QJson::Parser parser; - bool ok = false; - QVariantMap result = parser.parse(reply, &ok).toMap(); - if (!ok) { + QJsonParseError error; + QJsonDocument json_document = QJsonDocument::fromJson(reply->readAll(), &error); + + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Failed to parse oauth reply"; return; } - qLog(Debug) << result; + QJsonObject json_result = json_document.object(); + qLog(Debug) << json_result; - access_token_ = result["access_token"].toString(); - refresh_token_ = result["refresh_token"].toString(); - SetExpiryTime(result["expires_in"].toInt()); + access_token_ = json_result["access_token"].toString(); + refresh_token_ = json_result["refresh_token"].toString(); + SetExpiryTime(json_result["expires_in"].toInt()); emit Finished(); } @@ -178,14 +186,13 @@ void OAuthenticator::SetExpiryTime(int expires_in_seconds) { void OAuthenticator::RefreshAccessTokenFinished(QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - bool ok = false; - QVariantMap result = parser.parse(reply, &ok).toMap(); - access_token_ = result["access_token"].toString(); - if (result.contains("refresh_token")) { - refresh_token_ = result["refresh_token"].toString(); + QJsonObject json_result = QJsonDocument::fromJson(reply->readAll()).object(); + + access_token_ = json_result["access_token"].toString(); + if (json_result.contains("refresh_token")) { + refresh_token_ = json_result["refresh_token"].toString(); } - SetExpiryTime(result["expires_in"].toInt()); + SetExpiryTime(json_result["expires_in"].toInt()); emit Finished(); } diff --git a/src/internet/digitally/digitallyimportedclient.cpp b/src/internet/digitally/digitallyimportedclient.cpp index 9609301d6..f72d2ea34 100644 --- a/src/internet/digitally/digitallyimportedclient.cpp +++ b/src/internet/digitally/digitallyimportedclient.cpp @@ -19,10 +19,11 @@ #include "digitallyimportedclient.h" -#include - #include #include +#include +#include +#include #include "core/logging.h" #include "core/network.h" @@ -52,7 +53,7 @@ void DigitallyImportedClient::SetAuthorisationHeader( req->setRawHeader("Authorization", "Basic " + QString("%1:%2") .arg(kApiUsername, kApiPassword) - .toAscii() + .toLatin1() .toBase64()); } @@ -82,32 +83,30 @@ DigitallyImportedClient::AuthReply DigitallyImportedClient::ParseAuthReply( return ret; } - QJson::Parser parser; - QVariantMap data = parser.parse(reply).toMap(); + QJsonObject json_root_object = QJsonDocument::fromJson(reply->readAll()).object(); - if (!data.contains("subscriptions")) { + if (json_root_object["subscriptions"].isUndefined()) { return ret; } - QVariantList subscriptions = - data.value("subscriptions", QVariantList()).toList(); - if (subscriptions.isEmpty() || - subscriptions[0].toMap().value("status").toString() != "active") { + QJsonArray json_subscriptions = json_root_object["subscriptions"].toArray(); + if (json_subscriptions.isEmpty() || + json_subscriptions[0].toObject()["status"].toString() != "active") { ret.error_reason_ = tr("You do not have an active subscription"); return ret; } - if (!data.contains("first_name") || !data.contains("last_name") || - !subscriptions[0].toMap().contains("expires_on") || - !data.contains("listen_key")) + if (json_root_object["first_name"].isUndefined() || json_root_object["last_name"].isUndefined() || + json_subscriptions[0].toObject()["expires_on"].isUndefined() || + json_root_object["listen_key"].isUndefined()) return ret; ret.success_ = true; - ret.first_name_ = data["first_name"].toString(); - ret.last_name_ = data["last_name"].toString(); + ret.first_name_ = json_root_object["first_name"].toString(); + ret.last_name_ = json_root_object["last_name"].toString(); ret.expires_ = QDateTime::fromString( - subscriptions[0].toMap()["expires_on"].toString(), Qt::ISODate); - ret.listen_hash_ = data["listen_key"].toString(); + json_subscriptions[0].toObject()["expires_on"].toString(), Qt::ISODate); + ret.listen_hash_ = json_root_object["listen_key"].toString(); return ret; } @@ -123,30 +122,28 @@ DigitallyImportedClient::ChannelList DigitallyImportedClient::ParseChannelList( QNetworkReply* reply) const { ChannelList ret; - QJson::Parser parser; - QVariantMap data = parser.parse(reply).toMap(); + QJsonObject json_root_object = QJsonDocument::fromJson(reply->readAll()).object(); - if (!data.contains("channel_filters")) return ret; + if (json_root_object["channel_filters"].isUndefined()) return ret; - QVariantList filters = data["channel_filters"].toList(); + QJsonArray json_filters = json_root_object["channel_filters"].toArray(); - for (const QVariant& filter : filters) { + for (const QJsonValue & filter: json_filters) { // Find the filter called "All" - QVariantMap filter_map = filter.toMap(); - if (filter_map.value("name", QString()).toString() != "All") continue; + QJsonObject json_filter = filter.toObject(); + if (json_filter["name"].toString() != "All") continue; // Add all its stations to the result - QVariantList channels = - filter_map.value("channels", QVariantList()).toList(); - for (const QVariant& channel_var : channels) { - QVariantMap channel_map = channel_var.toMap(); + QJsonArray json_channels = json_filter["channels"].toArray(); + for (const QJsonValue& channel_var : json_channels) { + QJsonObject json_channel = channel_var.toObject(); Channel channel; - channel.art_url_ = QUrl(channel_map.value("asset_url").toString()); - channel.description_ = channel_map.value("description").toString(); - channel.director_ = channel_map.value("channel_director").toString(); - channel.key_ = channel_map.value("key").toString(); - channel.name_ = channel_map.value("name").toString(); + channel.art_url_ = QUrl(json_channel["asset_url"].toString()); + channel.description_ = json_channel["description"].toString(); + channel.director_ = json_channel["channel_director"].toString(); + channel.key_ = json_channel["key"].toString(); + channel.name_ = json_channel["name"].toString(); ret << channel; } diff --git a/src/internet/grooveshark/groovesharkservice.cpp b/src/internet/grooveshark/groovesharkservice.cpp index dd9bca060..5c5f8e67a 100644 --- a/src/internet/grooveshark/groovesharkservice.cpp +++ b/src/internet/grooveshark/groovesharkservice.cpp @@ -35,9 +35,11 @@ #include #include #include - -#include -#include +#include +#include +#include +#include +#include #include "qtiocompressor.h" @@ -215,7 +217,7 @@ int GroovesharkService::SimpleSearch(const QString& query) { void GroovesharkService::SimpleSearchFinished(QNetworkReply* reply, int id) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); emit SimpleSearchResults(id, songs); } @@ -238,12 +240,12 @@ int GroovesharkService::SearchAlbums(const QString& query) { void GroovesharkService::SearchAlbumsFinished(QNetworkReply* reply, int id) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); - QVariantList albums = result["albums"].toList(); + QJsonObject result = ExtractResult(reply).object(); + QJsonArray json_albums = result["albums"].toArray(); QList ret; - for (const QVariant& v : albums) { - quint64 album_id = v.toMap()["AlbumID"].toULongLong(); + for (const QJsonValue& v : json_albums) { + quint64 album_id = v.toObject()["AlbumID"].toString().toULongLong(); GetAlbumSongs(album_id); ret << album_id; } @@ -263,7 +265,7 @@ void GroovesharkService::GetAlbumSongs(quint64 album_id) { void GroovesharkService::GetAlbumSongsFinished(QNetworkReply* reply, quint64 album_id) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); emit AlbumSongsLoaded(album_id, songs); @@ -291,7 +293,7 @@ void GroovesharkService::SearchSongsFinished(QNetworkReply* reply) { if (reply != last_search_reply_) return; - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); app_->task_manager()->SetTaskFinished(task_search_id_); task_search_id_ = 0; @@ -311,7 +313,7 @@ void GroovesharkService::InitCountry() { // Get country info QNetworkReply* reply_country = CreateRequest("getCountry", QList()); if (WaitForReply(reply_country)) { - country_ = ExtractResult(reply_country); + country_ = ExtractResult(reply_country).object().toVariantMap(); } reply_country->deleteLater(); } @@ -332,12 +334,12 @@ QUrl GroovesharkService::GetStreamingUrlFromSongId(const QString& song_id, reply->deleteLater(); if (reply_has_timeouted) return QUrl(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); server_id->clear(); server_id->append(result["StreamServerID"].toString()); stream_key->clear(); stream_key->append(result["StreamKey"].toString()); - *length_nanosec = result["uSecs"].toLongLong() * 1000; + *length_nanosec = result["uSecs"].toString().toLongLong() * 1000; // Keep in mind that user has request to listen to this song last_songs_ids_.append(song_id.toInt()); last_artists_ids_.append(artist_id.toInt()); @@ -375,7 +377,7 @@ void GroovesharkService::SessionCreated(QNetworkReply* reply) { return; } - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Error) << "Grooveshark returned an error during session creation"; } @@ -397,7 +399,7 @@ void GroovesharkService::AuthenticateSession() { void GroovesharkService::Authenticated(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); // Check if the user has been authenticated correctly QString error; if (!result["success"].toBool() || result["UserID"].toInt() == 0) { @@ -700,7 +702,7 @@ void GroovesharkService::RetrieveUserPlaylists() { void GroovesharkService::UserPlaylistsRetrieved(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); QList playlists = ExtractPlaylistInfo(result); for (const PlaylistInfo& playlist_info : playlists) { @@ -737,7 +739,7 @@ void GroovesharkService::PlaylistSongsRetrieved(QNetworkReply* reply, : &playlists_[playlist_id]; playlist_info->item_->removeRows(0, playlist_info->item_->rowCount()); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); SortSongsAlphabeticallyIfNeeded(&songs); @@ -778,7 +780,7 @@ void GroovesharkService::UserFavoritesRetrieved(QNetworkReply* reply, favorites_->removeRows(0, favorites_->rowCount()); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); SortSongsAlphabeticallyIfNeeded(&songs); @@ -812,7 +814,7 @@ void GroovesharkService::UserLibrarySongsRetrieved(QNetworkReply* reply, library_->removeRows(0, library_->rowCount()); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); SortSongsAlphabeticallyIfNeeded(&songs); @@ -841,7 +843,7 @@ void GroovesharkService::RetrievePopularSongsMonth() { void GroovesharkService::PopularSongsMonthRetrieved(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); app_->task_manager()->IncreaseTaskProgress(task_popular_id_, 50, 100); @@ -867,7 +869,7 @@ void GroovesharkService::RetrievePopularSongsToday() { void GroovesharkService::PopularSongsTodayRetrieved(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); SongList songs = ExtractSongs(result); app_->task_manager()->IncreaseTaskProgress(task_popular_id_, 50, 100); @@ -893,7 +895,7 @@ void GroovesharkService::RetrieveSubscribedPlaylists() { void GroovesharkService::SubscribedPlaylistsRetrieved(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); QList playlists = ExtractPlaylistInfo(result); for (const PlaylistInfo& playlist_info : playlists) { @@ -924,9 +926,10 @@ void GroovesharkService::RetrieveAutoplayTags() { void GroovesharkService::AutoplayTagsRetrieved(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); - QVariantMap::const_iterator it; + QJsonObject result = ExtractResult(reply).object(); + QJsonObject::const_iterator it; if (!stations_) return; + for (it = result.constBegin(); it != result.constEnd(); ++it) { int id = it.key().toInt(); QString name = it.value().toString().toLower(); @@ -955,9 +958,9 @@ Song GroovesharkService::StartAutoplayTag(int tag_id, reply->deleteLater(); if (reply_has_timeouted) return Song(); - QVariantMap result = ExtractResult(reply); - autoplay_state = result["autoplayState"].toMap(); - return ExtractSong(result["nextSong"].toMap()); + QJsonObject result = ExtractResult(reply).object(); + autoplay_state = result["autoplayState"].toObject().toVariantMap(); + return ExtractSong(result["nextSong"].toObject()); } Song GroovesharkService::StartAutoplay(QVariantMap& autoplay_state) { @@ -978,9 +981,9 @@ Song GroovesharkService::StartAutoplay(QVariantMap& autoplay_state) { reply->deleteLater(); if (reply_has_timeouted) return Song(); - QVariantMap result = ExtractResult(reply); - autoplay_state = result["autoplayState"].toMap(); - return ExtractSong(result["nextSong"].toMap()); + QJsonObject result = ExtractResult(reply).object(); + autoplay_state = result["autoplayState"].toObject().toVariantMap(); + return ExtractSong(result["nextSong"].toObject()); } Song GroovesharkService::GetAutoplaySong(QVariantMap& autoplay_state) { @@ -992,9 +995,9 @@ Song GroovesharkService::GetAutoplaySong(QVariantMap& autoplay_state) { reply->deleteLater(); if (reply_has_timeouted) return Song(); - QVariantMap result = ExtractResult(reply); - autoplay_state = result["autoplayState"].toMap(); - return ExtractSong(result["nextSong"].toMap()); + QJsonObject result = ExtractResult(reply).object(); + autoplay_state = result["autoplayState"].toObject().toVariantMap(); + return ExtractSong(result["nextSong"].toObject()); } void GroovesharkService::MarkStreamKeyOver30Secs(const QString& stream_key, @@ -1010,7 +1013,7 @@ void GroovesharkService::MarkStreamKeyOver30Secs(const QString& stream_key, void GroovesharkService::StreamMarked(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark markStreamKeyOver30Secs failed"; } @@ -1030,7 +1033,7 @@ void GroovesharkService::MarkSongComplete(const QString& song_id, void GroovesharkService::SongMarkedAsComplete(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark markSongComplete failed"; } @@ -1177,8 +1180,8 @@ void GroovesharkService::GetSongUrlToShare(int song_id) { void GroovesharkService::SongUrlToShareReceived(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); - if (!result["url"].isValid()) return; + QJsonObject result = ExtractResult(reply).object(); + if (result["url"].isUndefined()) return; QString url = result["url"].toString(); ShowUrlBox(tr("Grooveshark song's URL"), url); } @@ -1199,8 +1202,8 @@ void GroovesharkService::GetPlaylistUrlToShare(int playlist_id) { void GroovesharkService::PlaylistUrlToShareReceived(QNetworkReply* reply) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); - if (!result["url"].isValid()) return; + QJsonObject result = ExtractResult(reply).object(); + if (result["url"].isUndefined()) return; QString url = result["url"].toString(); ShowUrlBox(tr("Grooveshark playlist's URL"), url); } @@ -1249,7 +1252,7 @@ void GroovesharkService::PlaylistSongsSet(QNetworkReply* reply, int playlist_id, reply->deleteLater(); app_->task_manager()->SetTaskFinished(task_id); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark setPlaylistSongs failed"; return; @@ -1289,8 +1292,8 @@ void GroovesharkService::CreateNewPlaylist() { void GroovesharkService::NewPlaylistCreated(QNetworkReply* reply, const QString& name) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); - if (!result["success"].toBool() || !result["playlistID"].isValid()) { + QJsonObject result = ExtractResult(reply).object(); + if (!result["success"].toBool() || result["playlistID"].isUndefined()) { qLog(Warning) << "Grooveshark createPlaylist failed"; return; } @@ -1336,7 +1339,7 @@ void GroovesharkService::DeletePlaylist(int playlist_id) { void GroovesharkService::PlaylistDeleted(QNetworkReply* reply, int playlist_id) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark deletePlaylist failed"; return; @@ -1384,7 +1387,7 @@ void GroovesharkService::RenamePlaylist(int playlist_id) { void GroovesharkService::PlaylistRenamed(QNetworkReply* reply, int playlist_id, const QString& new_name) { reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark renamePlaylist failed"; return; @@ -1411,7 +1414,7 @@ void GroovesharkService::UserFavoriteSongAdded(QNetworkReply* reply, reply->deleteLater(); app_->task_manager()->SetTaskFinished(task_id); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark addUserFavoriteSong failed"; return; @@ -1447,7 +1450,7 @@ void GroovesharkService::UserLibrarySongAdded(QNetworkReply* reply, reply->deleteLater(); app_->task_manager()->SetTaskFinished(task_id); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark addUserLibrarySongs failed"; return; @@ -1536,7 +1539,7 @@ void GroovesharkService::SongsRemovedFromFavorites(QNetworkReply* reply, app_->task_manager()->SetTaskFinished(task_id); reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark removeUserFavoriteSongs failed"; return; @@ -1595,7 +1598,7 @@ void GroovesharkService::SongsRemovedFromLibrary(QNetworkReply* reply, app_->task_manager()->SetTaskFinished(task_id); reply->deleteLater(); - QVariantMap result = ExtractResult(reply); + QJsonObject result = ExtractResult(reply).object(); if (!result["success"].toBool()) { qLog(Warning) << "Grooveshark removeUserLibrarySongs failed"; return; @@ -1606,11 +1609,12 @@ void GroovesharkService::SongsRemovedFromLibrary(QNetworkReply* reply, QNetworkReply* GroovesharkService::CreateRequest(const QString& method_name, const QList& params, bool use_https) { - QVariantMap request_params; - request_params.insert("method", method_name); + QJsonDocument json_document; + QJsonObject json_request_params; + json_request_params.insert("method", QJsonValue(method_name)); - QVariantMap header; - header.insert("wsKey", kApiKey); + QJsonObject json_header; + json_header.insert("wsKey", QJsonValue(kApiKey)); if (session_id_.isEmpty()) { if (method_name != "startSession") { // It's normal to not have a session_id when calling startSession. @@ -1618,26 +1622,28 @@ QNetworkReply* GroovesharkService::CreateRequest(const QString& method_name, qLog(Warning) << "Session ID is empty: will not be added to query"; } } else { - header.insert("sessionID", session_id_); + json_header.insert("sessionID", QJsonValue(session_id_)); } - request_params.insert("header", header); + json_request_params["header"] = json_header; - QVariantMap parameters; + QJsonObject json_parameters; for (const Param& param : params) { - parameters.insert(param.first, param.second); + json_parameters.insert(param.first, QJsonValue(param.second.toString())); } - request_params.insert("parameters", parameters); + json_request_params["parameters"] = json_parameters; - QJson::Serializer serializer; - QByteArray post_params = serializer.serialize(request_params); + json_document.setObject(json_request_params); + QByteArray post_params = json_document.toBinaryData(); QUrl url(kUrl); if (use_https) { url.setScheme("https"); } - url.setQueryItems( + QUrlQuery url_query; + url_query.setQueryItems( QList>() << QPair( "sig", Utilities::HmacMd5(api_key_, post_params).toHex())); + url.setQuery(url_query); QNetworkRequest req(url); QNetworkReply* reply = network_->post(req, post_params); @@ -1673,20 +1679,24 @@ bool GroovesharkService::WaitForReply(QNetworkReply* reply) { return true; } -QVariantMap GroovesharkService::ExtractResult(QNetworkReply* reply) { - QJson::Parser parser; - bool ok; - QVariantMap result = parser.parse(reply, &ok).toMap(); - if (!ok) { +QJsonDocument GroovesharkService::ExtractResult(QNetworkReply* reply) { + reply->deleteLater(); + + QJsonParseError error; + QJsonDocument json_document = QJsonDocument::fromJson(reply->readAll(), &error); + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Error while parsing Grooveshark result"; } - QVariantList errors = result["errors"].toList(); - QVariantList::iterator it; - for (it = errors.begin(); it != errors.end(); ++it) { - QVariantMap error = (*it).toMap(); - qLog(Error) << "Grooveshark error: (" << error["code"].toInt() << ") " - << error["message"].toString(); - switch (error["code"].toInt()) { + + QJsonObject json_object = json_document.object(); + QJsonArray json_errors = json_object["errors"].toArray(); + + for(const QJsonValue & error : json_errors) { + QJsonObject json_error = error.toObject(); + + qLog(Error) << "Grooveshark error: (" << json_error["code"].toInt() << ") " + << json_error["message"].toString(); + switch (json_error["code"].toInt()) { case 100: // User auth required case 102: // User premium required case 300: // Session required @@ -1697,7 +1707,10 @@ QVariantMap GroovesharkService::ExtractResult(QNetworkReply* reply) { break; } } - return result["result"].toMap(); + + QJsonDocument doc_ret; + doc_ret.setObject(json_object["result"].toObject()); + return doc_ret; } namespace { @@ -1709,24 +1722,26 @@ bool CompareSongs(const QVariant& song1, const QVariant& song2) { if (song1_sort == song2_sort) { // Favorite songs have a "TSFavorited" and (currently) no "Sort" field return song1_map["TSFavorited"].toString() < - song2_map["TSFavorited"].toString(); + song2_map["TSFavorited"].toString(); } return song1_sort < song2_sort; } -} // namespace +} // namespace -SongList GroovesharkService::ExtractSongs(const QVariantMap& result) { - QVariantList result_songs = result["songs"].toList(); +SongList GroovesharkService::ExtractSongs(const QJsonObject& result) { + QVariantList result_songs = result["songs"].toArray().toVariantList(); + // We don't automatically sort QJsonValue because it doesn't implement swap and so I think it simplier like that + // https://bugreports.qt.io/browse/QTBUG-44944 qStableSort(result_songs.begin(), result_songs.end(), CompareSongs); SongList songs; for (int i = 0; i < result_songs.size(); ++i) { QVariantMap result_song = result_songs[i].toMap(); - songs << ExtractSong(result_song); + songs << ExtractSong(QJsonObject::fromVariantMap(result_song)); } return songs; } -Song GroovesharkService::ExtractSong(const QVariantMap& result_song) { +Song GroovesharkService::ExtractSong(const QJsonObject& result_song) { Song song; if (!result_song.isEmpty()) { int song_id = result_song["SongID"].toInt(); @@ -1765,11 +1780,11 @@ Song GroovesharkService::ExtractSong(const QVariantMap& result_song) { return song; } -QList GroovesharkService::ExtractSongsIds(const QVariantMap& result) { - QVariantList result_songs = result["songs"].toList(); +QList GroovesharkService::ExtractSongsIds(const QJsonObject& result) { + QJsonArray result_songs = result["songs"].toArray(); QList songs_ids; for (int i = 0; i < result_songs.size(); ++i) { - QVariantMap result_song = result_songs[i].toMap(); + QJsonObject result_song = result_songs[i].toObject(); int song_id = result_song["SongID"].toInt(); songs_ids << song_id; } @@ -1798,16 +1813,16 @@ int GroovesharkService::ExtractSongId(const QUrl& url) { } QList GroovesharkService::ExtractPlaylistInfo( - const QVariantMap& result) { - QVariantList playlists_qvariant = result["playlists"].toList(); + const QJsonObject result) { + QJsonArray json_playlists = result["playlists"].toArray(); QList playlists; // Get playlists info - for (const QVariant& playlist_qvariant : playlists_qvariant) { - QVariantMap playlist = playlist_qvariant.toMap(); - int playlist_id = playlist["PlaylistID"].toInt(); - QString playlist_name = playlist["PlaylistName"].toString(); + for (const QJsonValue& playlist : json_playlists) { + QJsonObject json_playlist = playlist.toObject(); + int playlist_id = json_playlist["PlaylistID"].toInt(); + QString playlist_name = json_playlist["PlaylistName"].toString(); playlists << PlaylistInfo(playlist_id, playlist_name); } diff --git a/src/internet/grooveshark/groovesharkservice.h b/src/internet/grooveshark/groovesharkservice.h index 17c16c42f..dc946890a 100644 --- a/src/internet/grooveshark/groovesharkservice.h +++ b/src/internet/grooveshark/groovesharkservice.h @@ -106,8 +106,8 @@ class GroovesharkService : public InternetService { void GetPlaylistUrlToShare(int playlist_id); // Start autoplay for the given tag_id, fill the autoplay_state, returns a // first song to play - Song StartAutoplayTag(int tag_id, QVariantMap& autoplay_state); - Song StartAutoplay(QVariantMap& autoplay_state); + Song StartAutoplayTag(int tag_id, QVariantMap &autoplay_state); + Song StartAutoplay(QVariantMap &autoplay_state); // Get another autoplay song. autoplay_state is the autoplay_state received // from StartAutoplayTag Song GetAutoplaySong(QVariantMap& autoplay_state); @@ -232,22 +232,22 @@ class GroovesharkService : public InternetService { // seconds. Returns false if reply has timeouted bool WaitForReply(QNetworkReply* reply); // Convenient function for extracting result from reply - QVariantMap ExtractResult(QNetworkReply* reply); + QJsonDocument ExtractResult(QNetworkReply* reply); // Convenient function for extracting songs from grooveshark result. result // should be the "result" field of most Grooveshark replies - SongList ExtractSongs(const QVariantMap& result); + SongList ExtractSongs(const QJsonObject &result); // Convenient function for extracting song from grooveshark result. // result_song should be the song field ('song', 'nextSong', ...) of the // Grooveshark reply - Song ExtractSong(const QVariantMap& result_song); + Song ExtractSong(const QJsonObject &result_song); // Convenient functions for extracting Grooveshark songs ids - QList ExtractSongsIds(const QVariantMap& result); + QList ExtractSongsIds(const QJsonObject &result); QList ExtractSongsIds(const QList& urls); int ExtractSongId( const QUrl& url); // Returns 0 if url is not a Grooveshark url // Convenient function for extracting basic playlist info (only 'id' and // 'name': QStandardItem still need to be created), and sort them by name - QList ExtractPlaylistInfo(const QVariantMap& result); + QList ExtractPlaylistInfo(const QJsonObject result); void ResetSessionId(); @@ -308,7 +308,7 @@ class GroovesharkService : public InternetService { QString password_; // In fact, password's md5 hash QString user_id_; QString session_id_; - QMap country_; + QVariantMap country_; // The last artists and songs ids th users has listened to. Used for autoplay QList last_artists_ids_; QList last_songs_ids_; diff --git a/src/internet/icecast/icecastbackend.cpp b/src/internet/icecast/icecastbackend.cpp index 35daa3c24..2c9f1bbe7 100644 --- a/src/internet/icecast/icecastbackend.cpp +++ b/src/internet/icecast/icecastbackend.cpp @@ -43,7 +43,8 @@ QStringList IcecastBackend::GetGenresAlphabetical(const QString& filter) { QString sql = QString("SELECT DISTINCT genre FROM %1 %2 ORDER BY genre") .arg(kTableName, where); - QSqlQuery q(sql, db); + QSqlQuery q(db); + q.prepare(sql); if (!filter.isEmpty()) { q.bindValue(":filter", QString("%" + filter + "%")); } @@ -69,7 +70,8 @@ QStringList IcecastBackend::GetGenresByPopularity(const QString& filter) { " %2" " GROUP BY genre" " ORDER BY count DESC").arg(kTableName, where); - QSqlQuery q(sql, db); + QSqlQuery q(db); + q.prepare(sql); if (!filter.isEmpty()) { q.bindValue(":filter", QString("%" + filter + "%")); } @@ -109,7 +111,8 @@ IcecastBackend::StationList IcecastBackend::GetStations(const QString& filter, if (!where_clauses.isEmpty()) { sql += " WHERE " + where_clauses.join(" AND "); } - QSqlQuery q(sql, db); + QSqlQuery q(db); + q.prepare(sql); for (const QString& value : bound_items) { q.addBindValue(value); } @@ -134,7 +137,8 @@ IcecastBackend::StationList IcecastBackend::GetStations(const QString& filter, bool IcecastBackend::IsEmpty() { QMutexLocker l(db_->Mutex()); QSqlDatabase db = db_->Connect(); - QSqlQuery q(QString("SELECT ROWID FROM %1 LIMIT 1").arg(kTableName), db); + QSqlQuery q(db); + q.prepare(QString("SELECT ROWID FROM %1 LIMIT 1").arg(kTableName)); q.exec(); return !q.next(); } @@ -146,17 +150,16 @@ void IcecastBackend::ClearAndAddStations(const StationList& stations) { ScopedTransaction t(&db); // Remove all existing items - QSqlQuery q(QString("DELETE FROM %1").arg(kTableName), db); + QSqlQuery q(db); + q.prepare(QString("DELETE FROM %1").arg(kTableName)); q.exec(); if (db_->CheckErrors(q)) return; - q = QSqlQuery( - QString( + q.prepare(QString( "INSERT INTO %1 (name, url, mime_type, bitrate," " channels, samplerate, genre)" " VALUES (:name, :url, :mime_type, :bitrate," - " :channels, :samplerate, :genre)").arg(kTableName), - db); + " :channels, :samplerate, :genre)").arg(kTableName)); // Add these ones for (const Station& station : stations) { diff --git a/src/internet/icecast/icecastmodel.cpp b/src/internet/icecast/icecastmodel.cpp index 98ef34493..79d4c99fd 100644 --- a/src/internet/icecast/icecastmodel.cpp +++ b/src/internet/icecast/icecastmodel.cpp @@ -46,7 +46,8 @@ void IcecastModel::Reset() { LazyPopulate(root_); - reset(); + beginResetModel(); + endResetModel(); } void IcecastModel::LazyPopulate(IcecastItem* parent) { diff --git a/src/internet/jamendo/jamendodynamicplaylist.cpp b/src/internet/jamendo/jamendodynamicplaylist.cpp index cfcfb16a8..4424a978a 100644 --- a/src/internet/jamendo/jamendodynamicplaylist.cpp +++ b/src/internet/jamendo/jamendodynamicplaylist.cpp @@ -21,9 +21,8 @@ #include "jamendodynamicplaylist.h" #include -#include -#include #include +#include #include "core/logging.h" #include "core/network.h" @@ -119,35 +118,36 @@ QString JamendoDynamicPlaylist::OrderSpec(OrderBy by, OrderDirection dir) { void JamendoDynamicPlaylist::Fetch() { QUrl url(kUrl); - url.addQueryItem("pn", QString::number(current_page_++)); - url.addQueryItem("n", QString::number(kPageSize)); - url.addQueryItem("order", OrderSpec(order_by_, order_direction_)); + QUrlQuery url_query; + url_query.addQueryItem("pn", QString::number(current_page_++)); + url_query.addQueryItem("n", QString::number(kPageSize)); + url_query.addQueryItem("order", OrderSpec(order_by_, order_direction_)); + url.setQuery(url_query); + // TODO // We have to use QHttp here because there's no way to disable Keep-Alive // with QNetworkManager. - QHttpRequestHeader header( - "GET", QString(url.encodedPath() + "?" + url.encodedQuery())); - header.setValue("Host", url.encodedHost()); - - QHttp http(url.host()); - http.request(header); + QNetworkAccessManager network(this); + QNetworkRequest req(url); + QNetworkReply *reply = network.get(req); // Wait for the reply { QEventLoop event_loop; - connect(&http, SIGNAL(requestFinished(int, bool)), &event_loop, - SLOT(quit())); + connect(reply, SIGNAL(finished()), &event_loop, SLOT(quit())); event_loop.exec(); } - if (http.error() != QHttp::NoError) { - qLog(Warning) << "HTTP error returned from Jamendo:" << http.errorString() + reply->deleteLater(); + + if (reply->error() != QNetworkReply::NoError) { + qLog(Warning) << "HTTP error returned from Jamendo:" << reply->errorString() << ", url:" << url.toString(); return; } // The reply will contain one track ID per line - QStringList lines = QString::fromAscii(http.readAll()).split('\n'); + QStringList lines = QString::fromLatin1(reply->readAll()).split('\n'); // Get the songs from the database SongList songs = backend_->GetSongsByForeignId( diff --git a/src/internet/jamendo/jamendoservice.cpp b/src/internet/jamendo/jamendoservice.cpp index d68662e1d..6fba45482 100644 --- a/src/internet/jamendo/jamendoservice.cpp +++ b/src/internet/jamendo/jamendoservice.cpp @@ -289,9 +289,9 @@ void JamendoService::InsertTrackIds(const TrackIdList& ids) const { ScopedTransaction t(&db); - QSqlQuery insert(QString("INSERT INTO %1 (%2) VALUES (:id)") - .arg(kTrackIdsTable, kTrackIdsColumn), - db); + QSqlQuery insert(db); + insert.prepare(QString("INSERT INTO %1 (%2) VALUES (:id)") + .arg(kTrackIdsTable, kTrackIdsColumn)); for (int id : ids) { insert.bindValue(":id", id); diff --git a/src/internet/magnatune/magnatunedownloaddialog.cpp b/src/internet/magnatune/magnatunedownloaddialog.cpp index c502a0682..12957913b 100644 --- a/src/internet/magnatune/magnatunedownloaddialog.cpp +++ b/src/internet/magnatune/magnatunedownloaddialog.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "magnatuneservice.h" #include "internet/core/internetmodel.h" @@ -49,8 +50,8 @@ MagnatuneDownloadDialog::MagnatuneDownloadDialog(MagnatuneService* service, current_reply_(nullptr), next_row_(0) { ui_->setupUi(this); - ui_->albums->header()->setResizeMode(QHeaderView::ResizeToContents); - ui_->albums->header()->setResizeMode(1, QHeaderView::Fixed); + ui_->albums->header()->setSectionResizeMode(QHeaderView::ResizeToContents); + ui_->albums->header()->setSectionResizeMode(1, QHeaderView::Fixed); ui_->albums->header()->resizeSection(1, 150); ui_->albums->setItemDelegateForColumn(1, new ProgressItemDelegate(this)); @@ -126,8 +127,10 @@ void MagnatuneDownloadDialog::DownloadNext() { QUrl url(MagnatuneService::kDownloadUrl); url.setUserName(service_->username()); url.setPassword(service_->password()); - url.addQueryItem("id", MagnatuneService::kPartnerId); - url.addQueryItem("sku", sku); + + QUrlQuery url_query; + url_query.addQueryItem("id", MagnatuneService::kPartnerId); + url_query.addQueryItem("sku", sku); current_reply_ = network_->get(QNetworkRequest(url)); diff --git a/src/internet/magnatune/magnatuneservice.cpp b/src/internet/magnatune/magnatuneservice.cpp index 7206e8808..2c7f1764b 100644 --- a/src/internet/magnatune/magnatuneservice.cpp +++ b/src/internet/magnatune/magnatuneservice.cpp @@ -227,7 +227,7 @@ Song MagnatuneService::ReadTrack(QXmlStreamReader& reader) { if (name == "url") { QUrl url; // Magnatune's URLs are already encoded - url.setEncodedUrl(value.toLocal8Bit()); + url.setUrl(value.toLocal8Bit()); url.setScheme("magnatune"); song.set_url(url); } diff --git a/src/internet/podcasts/itunessearchpage.cpp b/src/internet/podcasts/itunessearchpage.cpp index a17005f95..dccfebded 100644 --- a/src/internet/podcasts/itunessearchpage.cpp +++ b/src/internet/podcasts/itunessearchpage.cpp @@ -19,9 +19,13 @@ #include "itunessearchpage.h" -#include #include #include +#include +#include +#include +#include +#include #include "core/closure.h" #include "core/network.h" @@ -47,7 +51,9 @@ void ITunesSearchPage::SearchClicked() { emit Busy(true); QUrl url(QUrl::fromEncoded(kUrlBase)); - url.addQueryItem("term", ui_->query->text()); + QUrlQuery url_query; + url_query.addQueryItem("term", ui_->query->text()); + url.setQuery(url_query); QNetworkReply* reply = network_->get(QNetworkRequest(url)); NewClosure(reply, SIGNAL(finished()), this, @@ -67,37 +73,38 @@ void ITunesSearchPage::SearchFinished(QNetworkReply* reply) { return; } - QJson::Parser parser; - QVariant data = parser.parse(reply); + QJsonParseError error; + QJsonDocument json_document = QJsonDocument::fromJson(reply->readAll(), &error); - // Was it valid JSON? - if (data.isNull()) { + if (error.error != QJsonParseError::NoError) { QMessageBox::warning( this, tr("Failed to fetch podcasts"), tr("There was a problem parsing the response from the iTunes Store")); return; } + QJsonObject json_data = json_document.object(); + // Was there an error message in the JSON? - if (data.toMap().contains("errorMessage")) { + if (!json_data["errorMessage"].isUndefined()) { QMessageBox::warning(this, tr("Failed to fetch podcasts"), - data.toMap()["errorMessage"].toString()); + json_data["errorMessage"].toString()); return; } - for (const QVariant& result_variant : data.toMap()["results"].toList()) { - QVariantMap result(result_variant.toMap()); - if (result["kind"].toString() != "podcast") { + for (const QJsonValue& result : json_data["results"].toArray()) { + QJsonObject json_result = result.toObject(); + if (json_result["kind"].toString() != "podcast") { continue; } Podcast podcast; - podcast.set_author(result["artistName"].toString()); - podcast.set_title(result["trackName"].toString()); - podcast.set_url(result["feedUrl"].toUrl()); - podcast.set_link(result["trackViewUrl"].toUrl()); - podcast.set_image_url_small(QUrl(result["artworkUrl30"].toString())); - podcast.set_image_url_large(QUrl(result["artworkUrl100"].toString())); + podcast.set_author(json_result["artistName"].toString()); + podcast.set_title(json_result["trackName"].toString()); + podcast.set_url(QUrl(json_result["feedUrl"].toString())); + podcast.set_link(QUrl(json_result["trackViewUrl"].toString())); + podcast.set_image_url_small(QUrl(json_result["artworkUrl30"].toString())); + podcast.set_image_url_large(QUrl(json_result["artworkUrl100"].toString())); model()->appendRow(model()->CreatePodcastItem(podcast)); } diff --git a/src/internet/podcasts/podcastbackend.cpp b/src/internet/podcasts/podcastbackend.cpp index c6657586e..c37bb701c 100644 --- a/src/internet/podcasts/podcastbackend.cpp +++ b/src/internet/podcasts/podcastbackend.cpp @@ -47,11 +47,11 @@ void PodcastBackend::Subscribe(Podcast* podcast) { ScopedTransaction t(&db); // Insert the podcast. - QSqlQuery q("INSERT INTO podcasts (" + Podcast::kColumnSpec + + QSqlQuery q(db); + q.prepare("INSERT INTO podcasts (" + Podcast::kColumnSpec + ")" " VALUES (" + - Podcast::kBindSpec + ")", - db); + Podcast::kBindSpec + ")"); podcast->BindToQuery(&q); q.exec(); @@ -86,13 +86,14 @@ void PodcastBackend::Unsubscribe(const Podcast& podcast) { ScopedTransaction t(&db); // Remove the podcast. - QSqlQuery q("DELETE FROM podcasts WHERE ROWID = :id", db); + QSqlQuery q(db); + q.prepare("DELETE FROM podcasts WHERE ROWID = :id"); q.bindValue(":id", podcast.database_id()); q.exec(); if (db_->CheckErrors(q)) return; // Remove all episodes in the podcast - q = QSqlQuery("DELETE FROM podcast_episodes WHERE podcast_id = :id", db); + q.prepare("DELETE FROM podcast_episodes WHERE podcast_id = :id"); q.bindValue(":id", podcast.database_id()); q.exec(); if (db_->CheckErrors(q)) return; @@ -104,11 +105,11 @@ void PodcastBackend::Unsubscribe(const Podcast& podcast) { void PodcastBackend::AddEpisodes(PodcastEpisodeList* episodes, QSqlDatabase* db) { - QSqlQuery q("INSERT INTO podcast_episodes (" + PodcastEpisode::kColumnSpec + + QSqlQuery q(*db); + q.prepare("INSERT INTO podcast_episodes (" + PodcastEpisode::kColumnSpec + ")" " VALUES (" + - PodcastEpisode::kBindSpec + ")", - *db); + PodcastEpisode::kBindSpec + ")"); for (auto it = episodes->begin(); it != episodes->end(); ++it) { it->BindToQuery(&q); @@ -136,14 +137,13 @@ void PodcastBackend::UpdateEpisodes(const PodcastEpisodeList& episodes) { QSqlDatabase db(db_->Connect()); ScopedTransaction t(&db); - QSqlQuery q( - "UPDATE podcast_episodes" + QSqlQuery q(db); + q.prepare("UPDATE podcast_episodes" " SET listened = :listened," " listened_date = :listened_date," " downloaded = :downloaded," " local_url = :local_url" - " WHERE ROWID = :id", - db); + " WHERE ROWID = :id"); for (const PodcastEpisode& episode : episodes) { q.bindValue(":listened", episode.listened()); @@ -166,7 +166,8 @@ PodcastList PodcastBackend::GetAllSubscriptions() { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + Podcast::kColumnSpec + " FROM podcasts", db); + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + Podcast::kColumnSpec + " FROM podcasts"); q.exec(); if (db_->CheckErrors(q)) return ret; @@ -185,10 +186,10 @@ Podcast PodcastBackend::GetSubscriptionById(int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + Podcast::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + Podcast::kColumnSpec + " FROM podcasts" - " WHERE ROWID = :id", - db); + " WHERE ROWID = :id"); q.bindValue(":id", id); q.exec(); if (!db_->CheckErrors(q) && q.next()) { @@ -204,10 +205,10 @@ Podcast PodcastBackend::GetSubscriptionByUrl(const QUrl& url) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + Podcast::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + Podcast::kColumnSpec + " FROM podcasts" - " WHERE url = :url", - db); + " WHERE url = :url"); q.bindValue(":url", url.toEncoded()); q.exec(); if (!db_->CheckErrors(q) && q.next()) { @@ -223,11 +224,11 @@ PodcastEpisodeList PodcastBackend::GetEpisodes(int podcast_id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + PodcastEpisode::kColumnSpec + " FROM podcast_episodes" " WHERE podcast_id = :id" - " ORDER BY publication_date DESC", - db); + " ORDER BY publication_date DESC"); q.bindValue(":db", podcast_id); q.exec(); if (db_->CheckErrors(q)) return ret; @@ -247,10 +248,10 @@ PodcastEpisode PodcastBackend::GetEpisodeById(int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + PodcastEpisode::kColumnSpec + " FROM podcast_episodes" - " WHERE ROWID = :id", - db); + " WHERE ROWID = :id"); q.bindValue(":db", id); q.exec(); if (!db_->CheckErrors(q) && q.next()) { @@ -266,10 +267,10 @@ PodcastEpisode PodcastBackend::GetEpisodeByUrl(const QUrl& url) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + PodcastEpisode::kColumnSpec + " FROM podcast_episodes" - " WHERE url = :url", - db); + " WHERE url = :url"); q.bindValue(":url", url.toEncoded()); q.exec(); if (!db_->CheckErrors(q) && q.next()) { @@ -285,11 +286,11 @@ PodcastEpisode PodcastBackend::GetEpisodeByUrlOrLocalUrl(const QUrl& url) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + PodcastEpisode::kColumnSpec + " FROM podcast_episodes" " WHERE url = :url" - " OR local_url = :url", - db); + " OR local_url = :url"); q.bindValue(":url", url.toEncoded()); q.exec(); if (!db_->CheckErrors(q) && q.next()) { @@ -306,11 +307,11 @@ PodcastEpisodeList PodcastBackend::GetOldDownloadedEpisodes( QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + PodcastEpisode::kColumnSpec + " FROM podcast_episodes" " WHERE downloaded = 'true'" - " AND listened_date <= :max_listened_date", - db); + " AND listened_date <= :max_listened_date"); q.bindValue(":max_listened_date", max_listened_date.toTime_t()); q.exec(); if (db_->CheckErrors(q)) return ret; @@ -330,12 +331,12 @@ PodcastEpisode PodcastBackend::GetOldestDownloadedListenedEpisode() { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + PodcastEpisode::kColumnSpec + " FROM podcast_episodes" " WHERE downloaded = 'true'" " AND listened = 'true'" - " ORDER BY listened_date ASC", - db); + " ORDER BY listened_date ASC"); q.exec(); if (db_->CheckErrors(q)) return ret; q.next(); @@ -350,11 +351,11 @@ PodcastEpisodeList PodcastBackend::GetNewDownloadedEpisodes() { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec + + QSqlQuery q(db); + q.prepare("SELECT ROWID, " + PodcastEpisode::kColumnSpec + " FROM podcast_episodes" " WHERE downloaded = 'true'" - " AND listened = 'false'", - db); + " AND listened = 'false'"); q.exec(); if (db_->CheckErrors(q)) return ret; diff --git a/src/internet/podcasts/podcastparser.cpp b/src/internet/podcasts/podcastparser.cpp index 0476d5e9b..3e163448e 100644 --- a/src/internet/podcasts/podcastparser.cpp +++ b/src/internet/podcasts/podcastparser.cpp @@ -114,7 +114,7 @@ void PodcastParser::ParseChannel(QXmlStreamReader* reader, Podcast* ret) const { if (name == "title") { ret->set_title(reader->readElementText()); } else if (name == "link" && lower_namespace.isEmpty()) { - ret->set_link(QUrl::fromEncoded(reader->readElementText().toAscii())); + ret->set_link(QUrl::fromEncoded(reader->readElementText().toLatin1())); } else if (name == "description") { ret->set_description(reader->readElementText()); } else if (name == "owner" && lower_namespace == kItunesNamespace) { @@ -126,7 +126,7 @@ void PodcastParser::ParseChannel(QXmlStreamReader* reader, Podcast* ret) const { } else if (name == "link" && lower_namespace == kAtomNamespace && ret->url().isEmpty() && reader->attributes().value("rel") == "self") { - ret->set_url(QUrl::fromEncoded(reader->readElementText().toAscii())); + ret->set_url(QUrl::fromEncoded(reader->readElementText().toLatin1())); } else if (name == "item") { ParseItem(reader, ret); } else { @@ -152,7 +152,7 @@ void PodcastParser::ParseImage(QXmlStreamReader* reader, Podcast* ret) const { const QStringRef name = reader->name(); if (name == "url") { ret->set_image_url_large( - QUrl::fromEncoded(reader->readElementText().toAscii())); + QUrl::fromEncoded(reader->readElementText().toLatin1())); } else { Utilities::ConsumeCurrentElement(reader); } @@ -231,7 +231,7 @@ void PodcastParser::ParseItem(QXmlStreamReader* reader, Podcast* ret) const { const QString type = reader->attributes().value("type").toString(); if (type.startsWith("audio/") || type.startsWith("x-audio/")) { episode.set_url(QUrl::fromEncoded( - reader->attributes().value("url").toString().toAscii())); + reader->attributes().value("url").toString().toLatin1())); } Utilities::ConsumeCurrentElement(reader); } else if (name == "author" && lower_namespace == kItunesNamespace) { @@ -293,9 +293,9 @@ void PodcastParser::ParseOutline(QXmlStreamReader* reader, podcast.set_description(attributes.value("description").toString()); podcast.set_title(attributes.value("text").toString()); podcast.set_image_url_large(QUrl::fromEncoded( - attributes.value("imageHref").toString().toAscii())); + attributes.value("imageHref").toString().toLatin1())); podcast.set_url(QUrl::fromEncoded( - attributes.value("xmlUrl").toString().toAscii())); + attributes.value("xmlUrl").toString().toLatin1())); ret->feeds.append(podcast); // Consume any children and the EndElement. diff --git a/src/internet/podcasts/podcasturlloader.cpp b/src/internet/podcasts/podcasturlloader.cpp index b6509e4ad..c08265fd6 100644 --- a/src/internet/podcasts/podcasturlloader.cpp +++ b/src/internet/podcasts/podcasturlloader.cpp @@ -20,6 +20,7 @@ #include "podcasturlloader.h" #include +#include #include "podcastparser.h" #include "core/closure.h" @@ -73,14 +74,15 @@ QUrl PodcastUrlLoader::FixPodcastUrl(const QString& url_text) { QUrl PodcastUrlLoader::FixPodcastUrl(const QUrl& url_orig) { QUrl url(url_orig); + QUrlQuery url_query(url); // Replace schemes if (url.scheme().isEmpty() || url.scheme() == "feed" || url.scheme() == "itpc" || url.scheme() == "itms") { url.setScheme("http"); } else if (url.scheme() == "zune" && url.host() == "subscribe" && - !url.queryItems().isEmpty()) { - url = QUrl(url.queryItems()[0].second); + !url_query.queryItems().isEmpty()) { + url = QUrl(url_query.queryItems()[0].second); } return url; diff --git a/src/internet/soundcloud/soundcloudservice.cpp b/src/internet/soundcloud/soundcloudservice.cpp index 4883afa96..955f723d1 100644 --- a/src/internet/soundcloud/soundcloudservice.cpp +++ b/src/internet/soundcloud/soundcloudservice.cpp @@ -25,9 +25,11 @@ #include #include #include - -#include -#include +#include +#include +#include +#include +#include #include "internet/core/internetmodel.h" #include "internet/core/oauthenticator.h" @@ -217,7 +219,7 @@ void SoundCloudService::RetrieveUserData() { void SoundCloudService::RetrieveUserTracks() { QList parameters; parameters << Param("oauth_token", access_token_); - QNetworkReply* reply = CreateRequest("me/tracks", parameters); + QNetworkReply* reply = CreateRequest("/me/tracks", parameters); NewClosure(reply, SIGNAL(finished()), this, SLOT(UserTracksRetrieved(QNetworkReply*)), reply); } @@ -225,7 +227,7 @@ void SoundCloudService::RetrieveUserTracks() { void SoundCloudService::UserTracksRetrieved(QNetworkReply* reply) { reply->deleteLater(); - SongList songs = ExtractSongs(ExtractResult(reply)); + SongList songs = ExtractSongs(ExtractResult(reply).array()); // Fill results list for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); @@ -236,7 +238,7 @@ void SoundCloudService::UserTracksRetrieved(QNetworkReply* reply) { void SoundCloudService::RetrieveUserActivities() { QList parameters; parameters << Param("oauth_token", access_token_); - QNetworkReply* reply = CreateRequest("me/activities", parameters); + QNetworkReply* reply = CreateRequest("/me/activities", parameters); NewClosure(reply, SIGNAL(finished()), this, SLOT(UserActivitiesRetrieved(QNetworkReply*)), reply); } @@ -244,7 +246,7 @@ void SoundCloudService::RetrieveUserActivities() { void SoundCloudService::UserActivitiesRetrieved(QNetworkReply* reply) { reply->deleteLater(); - QList activities = ExtractActivities(ExtractResult(reply)); + QList activities = ExtractActivities(ExtractResult(reply).object()); // Fill results list for (QStandardItem* activity : activities) { user_activities_->appendRow(activity); @@ -254,7 +256,7 @@ void SoundCloudService::UserActivitiesRetrieved(QNetworkReply* reply) { void SoundCloudService::RetrieveUserPlaylists() { QList parameters; parameters << Param("oauth_token", access_token_); - QNetworkReply* reply = CreateRequest("me/playlists", parameters); + QNetworkReply* reply = CreateRequest("/me/playlists", parameters); NewClosure(reply, SIGNAL(finished()), this, SLOT(UserPlaylistsRetrieved(QNetworkReply*)), reply); } @@ -262,12 +264,12 @@ void SoundCloudService::RetrieveUserPlaylists() { void SoundCloudService::UserPlaylistsRetrieved(QNetworkReply* reply) { reply->deleteLater(); - QList playlists = ExtractResult(reply).toList(); - for (const QVariant& playlist : playlists) { - QMap playlist_map = playlist.toMap(); + QJsonArray json_playlists = ExtractResult(reply).array(); + for (const QJsonValue& playlist : json_playlists) { + QJsonObject json_playlist = playlist.toObject(); - QStandardItem* playlist_item = CreatePlaylistItem(playlist_map["title"].toString()); - SongList songs = ExtractSongs(playlist_map["tracks"]); + QStandardItem* playlist_item = CreatePlaylistItem(json_playlist["title"].toString()); + SongList songs = ExtractSongs(json_playlist["tracks"].toArray()); for (const Song& song : songs) { playlist_item->appendRow(CreateSongItem(song)); } @@ -299,7 +301,7 @@ void SoundCloudService::DoSearch() { QList parameters; parameters << Param("q", pending_search_); - QNetworkReply* reply = CreateRequest("tracks", parameters); + QNetworkReply* reply = CreateRequest("/tracks", parameters); const int id = next_pending_search_id_++; NewClosure(reply, SIGNAL(finished()), this, SLOT(SearchFinished(QNetworkReply*, int)), reply, id); @@ -308,7 +310,7 @@ void SoundCloudService::DoSearch() { void SoundCloudService::SearchFinished(QNetworkReply* reply, int task_id) { reply->deleteLater(); - SongList songs = ExtractSongs(ExtractResult(reply)); + SongList songs = ExtractSongs(ExtractResult(reply).array()); // Fill results list for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); @@ -328,7 +330,7 @@ void SoundCloudService::ClearSearchResults() { int SoundCloudService::SimpleSearch(const QString& text) { QList parameters; parameters << Param("q", text); - QNetworkReply* reply = CreateRequest("tracks", parameters); + QNetworkReply* reply = CreateRequest("/tracks", parameters); const int id = next_pending_search_id_++; NewClosure(reply, SIGNAL(finished()), this, SLOT(SimpleSearchFinished(QNetworkReply*, int)), reply, id); @@ -338,7 +340,7 @@ int SoundCloudService::SimpleSearch(const QString& text) { void SoundCloudService::SimpleSearchFinished(QNetworkReply* reply, int id) { reply->deleteLater(); - SongList songs = ExtractSongs(ExtractResult(reply)); + SongList songs = ExtractSongs(ExtractResult(reply).array()); emit SimpleSearchResults(id, songs); } @@ -372,12 +374,15 @@ QNetworkReply* SoundCloudService::CreateRequest(const QString& ressource_name, QUrl url(kUrl); url.setPath(ressource_name); + QUrlQuery url_query; - url.addQueryItem("client_id", kApiClientId); + url_query.addQueryItem("client_id", kApiClientId); for (const Param& param : params) { - url.addQueryItem(param.first, param.second); + url_query.addQueryItem(param.first, param.second); } + url.setQuery(url_query); + qLog(Debug) << "Request Url: " << url.toEncoded(); QNetworkRequest req(url); @@ -386,7 +391,7 @@ QNetworkReply* SoundCloudService::CreateRequest(const QString& ressource_name, return reply; } -QVariant SoundCloudService::ExtractResult(QNetworkReply* reply) { +QJsonDocument SoundCloudService::ExtractResult(QNetworkReply* reply) { if (reply->error() != QNetworkReply::NoError) { qLog(Error) << "Error when retrieving SoundCloud results:" << reply->errorString() << QString(" (%1)").arg(reply->error()); @@ -396,16 +401,16 @@ QVariant SoundCloudService::ExtractResult(QNetworkReply* reply) { reply->error() == QNetworkReply::AuthenticationRequiredError) { // In case of access denied errors (invalid token?) logout Logout(); - return QVariant(); + return QJsonDocument(); } } - QJson::Parser parser; - bool ok; - QVariant result = parser.parse(reply, &ok); - if (!ok) { + QJsonParseError error; + QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &error); + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Error while parsing SoundCloud result"; } - return result; + + return document; } void SoundCloudService::RetrievePlaylist(int playlist_id, @@ -416,7 +421,7 @@ void SoundCloudService::RetrievePlaylist(int playlist_id, QList parameters; parameters << Param("oauth_token", access_token_); QNetworkReply* reply = - CreateRequest("playlists/" + QString::number(playlist_id), parameters); + CreateRequest("/playlists/" + QString::number(playlist_id), parameters); NewClosure(reply, SIGNAL(finished()), this, SLOT(PlaylistRetrieved(QNetworkReply*, int)), reply, request_id); } @@ -425,42 +430,41 @@ void SoundCloudService::PlaylistRetrieved(QNetworkReply* reply, int request_id) { if (!pending_playlists_requests_.contains(request_id)) return; PlaylistInfo playlist_info = pending_playlists_requests_.take(request_id); - QVariant res = ExtractResult(reply); - SongList songs = ExtractSongs(res.toMap()["tracks"]); + QJsonDocument res = ExtractResult(reply); + SongList songs = ExtractSongs(res.object()["tracks"].toArray()); for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); playlist_info.item_->appendRow(child); } } -QList SoundCloudService::ExtractActivities(const QVariant& result) { +QList SoundCloudService::ExtractActivities(const QJsonObject& result) { QList activities; - QVariantList q_variant_list = result.toMap()["collection"].toList(); - for (const QVariant& q : q_variant_list) { - QMap activity = q.toMap(); - const QString type = activity["type"].toString(); + QJsonArray q_list = result["collection"].toArray(); + for (const QJsonValue& q : q_list) { + QJsonObject json_activity = q.toObject(); + const QString type = json_activity["type"].toString(); if (type == "track") { - Song song = ExtractSong(activity["origin"].toMap()); + Song song = ExtractSong(json_activity["origin"].toObject()); if (song.is_valid()) { activities << CreateSongItem(song); } } else if (type == "playlist") { - QMap origin_map = activity["origin"].toMap(); + QJsonObject json_origin = json_activity["origin"].toObject(); QStandardItem* playlist_item = - CreatePlaylistItem(origin_map["title"].toString()); + CreatePlaylistItem(json_origin["title"].toString()); activities << playlist_item; - RetrievePlaylist(origin_map["id"].toInt(), playlist_item); + RetrievePlaylist(json_origin["id"].toInt(), playlist_item); } } return activities; } -SongList SoundCloudService::ExtractSongs(const QVariant& result) { +SongList SoundCloudService::ExtractSongs(const QJsonArray & result) { SongList songs; - QVariantList q_variant_list = result.toList(); - for (const QVariant& q : q_variant_list) { - Song song = ExtractSong(q.toMap()); + for (const QJsonValue& q : result) { + Song song = ExtractSong(q.toObject()); if (song.is_valid()) { songs << song; } @@ -468,14 +472,16 @@ SongList SoundCloudService::ExtractSongs(const QVariant& result) { return songs; } -Song SoundCloudService::ExtractSong(const QVariantMap& result_song) { +Song SoundCloudService::ExtractSong(const QJsonObject& result_song) { Song song; if (!result_song.isEmpty() && result_song["streamable"].toBool()) { - QUrl stream_url = result_song["stream_url"].toUrl(); - stream_url.addQueryItem("client_id", kApiClientId); + QUrl stream_url(result_song["stream_url"].toString()); + QUrlQuery stream_url_query; + stream_url_query.addQueryItem("client_id", kApiClientId); + stream_url.setQuery(stream_url_query); song.set_url(stream_url); - QString username = result_song["user"].toMap()["username"].toString(); + QString username = result_song["user"].toObject()["username"].toString(); // We don't have a real artist name, but username is the most similar thing // we have song.set_artist(username); @@ -486,7 +492,7 @@ Song SoundCloudService::ExtractSong(const QVariantMap& result_song) { QString genre = result_song["genre"].toString(); song.set_genre(genre); - float bpm = result_song["bpm"].toFloat(); + float bpm = result_song["bpm"].toDouble(); song.set_bpm(bpm); QVariant cover = result_song["artwork_url"]; diff --git a/src/internet/soundcloud/soundcloudservice.h b/src/internet/soundcloud/soundcloudservice.h index a806204b4..0063a291f 100644 --- a/src/internet/soundcloud/soundcloudservice.h +++ b/src/internet/soundcloud/soundcloudservice.h @@ -26,6 +26,7 @@ class NetworkAccessManager; class OAuthenticator; class SearchBoxWidget; +class QJsonDocument; class QMenu; class QNetworkReply; @@ -101,11 +102,11 @@ class SoundCloudService : public InternetService { QNetworkReply* CreateRequest(const QString& ressource_name, const QList>& params); // Convenient function for extracting result from reply - QVariant ExtractResult(QNetworkReply* reply); + QJsonDocument ExtractResult(QNetworkReply* reply); // Returns items directly, as activities can be playlists or songs - QList ExtractActivities(const QVariant& result); - SongList ExtractSongs(const QVariant& result); - Song ExtractSong(const QVariantMap& result_song); + QList ExtractActivities(const QJsonObject &result); + SongList ExtractSongs(const QJsonArray &result); + Song ExtractSong(const QJsonObject& result_song); QStandardItem* root_; QStandardItem* search_; diff --git a/src/internet/subsonic/subsonicservice.cpp b/src/internet/subsonic/subsonicservice.cpp index 91dc18eae..a55de21ef 100644 --- a/src/internet/subsonic/subsonicservice.cpp +++ b/src/internet/subsonic/subsonicservice.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "core/application.h" #include "core/closure.h" @@ -209,10 +210,12 @@ void SubsonicService::Ping() { QUrl SubsonicService::BuildRequestUrl(const QString& view) const { QUrl url(working_server_ + "/rest/" + view + ".view"); - url.addQueryItem("v", kApiVersion); - url.addQueryItem("c", kApiClientName); - url.addQueryItem("u", username_); - url.addQueryItem("p", QString("enc:" + password_.toUtf8().toHex())); + QUrlQuery url_query; + url_query.addQueryItem("v", kApiVersion); + url_query.addQueryItem("c", kApiClientName); + url_query.addQueryItem("u", username_); + url_query.addQueryItem("p", QString("enc:" + password_.toUtf8().toHex())); + url.setQuery(url_query); return url; } @@ -496,9 +499,11 @@ void SubsonicLibraryScanner::OnGetAlbumFinished(QNetworkReply* reply) { void SubsonicLibraryScanner::GetAlbumList(int offset) { QUrl url = service_->BuildRequestUrl("getAlbumList2"); - url.addQueryItem("type", "alphabeticalByName"); - url.addQueryItem("size", QString::number(kAlbumChunkSize)); - url.addQueryItem("offset", QString::number(offset)); + QUrlQuery url_query; + url_query.addQueryItem("type", "alphabeticalByName"); + url_query.addQueryItem("size", QString::number(kAlbumChunkSize)); + url_query.addQueryItem("offset", QString::number(offset)); + url.setQuery(url_query); QNetworkReply* reply = service_->Send(url); NewClosure(reply, SIGNAL(finished()), this, SLOT(OnGetAlbumListFinished(QNetworkReply*, int)), reply, offset); @@ -506,7 +511,9 @@ void SubsonicLibraryScanner::GetAlbumList(int offset) { void SubsonicLibraryScanner::GetAlbum(const QString& id) { QUrl url = service_->BuildRequestUrl("getAlbum"); - url.addQueryItem("id", id); + QUrlQuery url_query; + url_query.addQueryItem("id", id); + url.setQuery(url_query); QNetworkReply* reply = service_->Send(url); NewClosure(reply, SIGNAL(finished()), this, SLOT(OnGetAlbumFinished(QNetworkReply*)), reply); diff --git a/src/internet/subsonic/subsonicurlhandler.cpp b/src/internet/subsonic/subsonicurlhandler.cpp index d133f291c..a9dcbda4a 100644 --- a/src/internet/subsonic/subsonicurlhandler.cpp +++ b/src/internet/subsonic/subsonicurlhandler.cpp @@ -17,6 +17,8 @@ along with Clementine. If not, see . */ +#include + #include "subsonicservice.h" #include "subsonicurlhandler.h" @@ -29,6 +31,8 @@ UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl& url) { return LoadResult(); QUrl newurl = service_->BuildRequestUrl("stream"); - newurl.addQueryItem("id", url.host()); + QUrlQuery url_query; + url_query.addQueryItem("id", url.host()); + newurl.setQuery(url_query); return LoadResult(url, LoadResult::TrackAvailable, newurl); } diff --git a/src/library/librarybackend.cpp b/src/library/librarybackend.cpp index 7efe0ee9b..0966346a5 100644 --- a/src/library/librarybackend.cpp +++ b/src/library/librarybackend.cpp @@ -111,8 +111,8 @@ void LibraryBackend::ChangeDirPath(int id, const QString& old_path, ScopedTransaction t(&db); // Do the dirs table - QSqlQuery q( - QString("UPDATE %1 SET path=:path WHERE ROWID=:id").arg(dirs_table_), db); + QSqlQuery q(db); + q.prepare(QString("UPDATE %1 SET path=:path WHERE ROWID=:id").arg(dirs_table_)); q.bindValue(":path", new_path); q.bindValue(":id", id); q.exec(); @@ -124,24 +124,24 @@ void LibraryBackend::ChangeDirPath(int id, const QString& old_path, const int path_len = old_url.length(); // Do the subdirs table - q = QSqlQuery(QString( + q = QSqlQuery(db); + q.prepare(QString( "UPDATE %1 SET path=:path || substr(path, %2)" " WHERE directory=:id") .arg(subdirs_table_) - .arg(path_len), - db); + .arg(path_len)); q.bindValue(":path", new_url); q.bindValue(":id", id); q.exec(); if (db_->CheckErrors(q)) return; // Do the songs table - q = QSqlQuery(QString( + q = QSqlQuery(db); + q.prepare(QString( "UPDATE %1 SET filename=:path || substr(filename, %2)" " WHERE directory=:id") .arg(songs_table_) - .arg(path_len), - db); + .arg(path_len)); q.bindValue(":path", new_url); q.bindValue(":id", id); q.exec(); @@ -156,7 +156,8 @@ DirectoryList LibraryBackend::GetAllDirectories() { DirectoryList ret; - QSqlQuery q(QString("SELECT ROWID, path FROM %1").arg(dirs_table_), db); + QSqlQuery q(db); + q.prepare(QString("SELECT ROWID, path FROM %1").arg(dirs_table_)); q.exec(); if (db_->CheckErrors(q)) return ret; @@ -177,10 +178,10 @@ SubdirectoryList LibraryBackend::SubdirsInDirectory(int id) { } SubdirectoryList LibraryBackend::SubdirsInDirectory(int id, QSqlDatabase& db) { - QSqlQuery q(QString( + QSqlQuery q(db); + q.prepare(QString( "SELECT path, mtime FROM %1" - " WHERE directory = :dir").arg(subdirs_table_), - db); + " WHERE directory = :dir").arg(subdirs_table_)); q.bindValue(":dir", id); q.exec(); if (db_->CheckErrors(q)) return SubdirectoryList(); @@ -201,9 +202,9 @@ void LibraryBackend::UpdateTotalSongCount() { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q(QString("SELECT COUNT(*) FROM %1 WHERE unavailable = 0") - .arg(songs_table_), - db); + QSqlQuery q(db); + q.prepare(QString("SELECT COUNT(*) FROM %1 WHERE unavailable = 0") + .arg(songs_table_)); q.exec(); if (db_->CheckErrors(q)) return; if (!q.next()) return; @@ -225,10 +226,10 @@ void LibraryBackend::AddDirectory(const QString& path) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q(QString( + QSqlQuery q(db); + q.prepare(QString( "INSERT INTO %1 (path, subdirs)" - " VALUES (:path, 1)").arg(dirs_table_), - db); + " VALUES (:path, 1)").arg(dirs_table_)); q.bindValue(":path", db_path); q.exec(); if (db_->CheckErrors(q)) return; @@ -250,15 +251,15 @@ void LibraryBackend::RemoveDirectory(const Directory& dir) { ScopedTransaction transaction(&db); // Delete the subdirs that were in this directory - QSqlQuery q( - QString("DELETE FROM %1 WHERE directory = :id").arg(subdirs_table_), db); + QSqlQuery q(db); + q.prepare(QString("DELETE FROM %1 WHERE directory = :id").arg(subdirs_table_)); q.bindValue(":id", dir.id); q.exec(); if (db_->CheckErrors(q)) return; // Now remove the directory itself - q = QSqlQuery(QString("DELETE FROM %1 WHERE ROWID = :id").arg(dirs_table_), - db); + q = QSqlQuery(db); + q.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(dirs_table_)); q.bindValue(":id", dir.id); q.exec(); if (db_->CheckErrors(q)) return; @@ -272,10 +273,10 @@ SongList LibraryBackend::FindSongsInDirectory(int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q( + QSqlQuery q(db); + q.prepare( QString("SELECT ROWID, " + Song::kColumnSpec + - " FROM %1 WHERE directory = :directory").arg(songs_table_), - db); + " FROM %1 WHERE directory = :directory").arg(songs_table_)); q.bindValue(":directory", id); q.exec(); if (db_->CheckErrors(q)) return SongList(); @@ -292,25 +293,22 @@ SongList LibraryBackend::FindSongsInDirectory(int id) { void LibraryBackend::AddOrUpdateSubdirs(const SubdirectoryList& subdirs) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery find_query( - QString( + QSqlQuery find_query(db); + find_query.prepare(QString( "SELECT ROWID FROM %1" - " WHERE directory = :id AND path = :path").arg(subdirs_table_), - db); - QSqlQuery add_query(QString( + " WHERE directory = :id AND path = :path").arg(subdirs_table_)); + QSqlQuery add_query(db); + add_query.prepare(QString( "INSERT INTO %1 (directory, path, mtime)" - " VALUES (:id, :path, :mtime)").arg(subdirs_table_), - db); - QSqlQuery update_query( - QString( + " VALUES (:id, :path, :mtime)").arg(subdirs_table_)); + QSqlQuery update_query(db); + update_query.prepare(QString( "UPDATE %1 SET mtime = :mtime" - " WHERE directory = :id AND path = :path").arg(subdirs_table_), - db); - QSqlQuery delete_query( - QString( + " WHERE directory = :id AND path = :path").arg(subdirs_table_)); + QSqlQuery delete_query(db); + delete_query.prepare(QString( "DELETE FROM %1" - " WHERE directory = :id AND path = :path").arg(subdirs_table_), - db); + " WHERE directory = :id AND path = :path").arg(subdirs_table_)); ScopedTransaction transaction(&db); for (const Subdirectory& subdir : subdirs) { @@ -349,25 +347,24 @@ void LibraryBackend::AddOrUpdateSongs(const SongList& songs) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery check_dir( - QString("SELECT ROWID FROM %1 WHERE ROWID = :id").arg(dirs_table_), db); - QSqlQuery add_song(QString("INSERT INTO %1 (" + Song::kColumnSpec + + QSqlQuery check_dir(db); + check_dir.prepare(QString("SELECT ROWID FROM %1 WHERE ROWID = :id").arg(dirs_table_)); + QSqlQuery add_song(db); + add_song.prepare(QString("INSERT INTO %1 (" + Song::kColumnSpec + ")" " VALUES (" + - Song::kBindSpec + ")").arg(songs_table_), - db); - QSqlQuery update_song(QString("UPDATE %1 SET " + Song::kUpdateSpec + - " WHERE ROWID = :id").arg(songs_table_), - db); - QSqlQuery add_song_fts( - QString("INSERT INTO %1 (ROWID, " + Song::kFtsColumnSpec + + Song::kBindSpec + ")").arg(songs_table_)); + QSqlQuery update_song(db); + update_song.prepare(QString("UPDATE %1 SET " + Song::kUpdateSpec + + " WHERE ROWID = :id").arg(songs_table_)); + QSqlQuery add_song_fts(db); + add_song_fts.prepare(QString("INSERT INTO %1 (ROWID, " + Song::kFtsColumnSpec + ")" " VALUES (:id, " + - Song::kFtsBindSpec + ")").arg(fts_table_), - db); - QSqlQuery update_song_fts(QString("UPDATE %1 SET " + Song::kFtsUpdateSpec + - " WHERE ROWID = :id").arg(fts_table_), - db); + Song::kFtsBindSpec + ")").arg(fts_table_)); + QSqlQuery update_song_fts(db); + update_song_fts.prepare(QString("UPDATE %1 SET " + Song::kFtsUpdateSpec + + " WHERE ROWID = :id").arg(fts_table_)); ScopedTransaction transaction(&db); @@ -440,9 +437,9 @@ void LibraryBackend::UpdateMTimesOnly(const SongList& songs) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q(QString("UPDATE %1 SET mtime = :mtime WHERE ROWID = :id") - .arg(songs_table_), - db); + QSqlQuery q(db); + q.prepare(QString("UPDATE %1 SET mtime = :mtime WHERE ROWID = :id") + .arg(songs_table_)); ScopedTransaction transaction(&db); for (const Song& song : songs) { @@ -458,10 +455,10 @@ void LibraryBackend::DeleteSongs(const SongList& songs) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery remove( - QString("DELETE FROM %1 WHERE ROWID = :id").arg(songs_table_), db); - QSqlQuery remove_fts( - QString("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_), db); + QSqlQuery remove(db); + remove.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(songs_table_)); + QSqlQuery remove_fts(db); + remove_fts.prepare(QString("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_)); ScopedTransaction transaction(&db); for (const Song& song : songs) { @@ -485,10 +482,10 @@ void LibraryBackend::MarkSongsUnavailable(const SongList& songs, QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery remove(QString("UPDATE %1 SET unavailable = %2 WHERE ROWID = :id") + QSqlQuery remove(db); + remove.prepare(QString("UPDATE %1 SET unavailable = %2 WHERE ROWID = :id") .arg(songs_table_) - .arg(int(unavailable)), - db); + .arg(int(unavailable))); ScopedTransaction transaction(&db); for (const Song& song : songs) { @@ -612,14 +609,14 @@ SongList LibraryBackend::GetSongsByForeignId(const QStringList& ids, QString in = ids.join(","); - QSqlQuery q( - QString( + QSqlQuery q(db); + q.prepare( + QString( "SELECT %2.ROWID, " + Song::kColumnSpec + ", %2.%3" " FROM %2, %1" " WHERE %2.%3 IN (%4) AND %1.ROWID = %2.ROWID AND unavailable = 0") - .arg(songs_table_, table, column, in), - db); + .arg(songs_table_, table, column, in)); q.exec(); if (db_->CheckErrors(q)) return SongList(); @@ -644,10 +641,10 @@ SongList LibraryBackend::GetSongsById(const QStringList& ids, QSqlDatabase& db) { QString in = ids.join(","); - QSqlQuery q(QString("SELECT ROWID, " + Song::kColumnSpec + + QSqlQuery q(db); + q.prepare(QString("SELECT ROWID, " + Song::kColumnSpec + " FROM %1" - " WHERE ROWID IN (%2)").arg(songs_table_, in), - db); + " WHERE ROWID IN (%2)").arg(songs_table_, in)); q.exec(); if (db_->CheckErrors(q)) return SongList(); @@ -722,11 +719,11 @@ void LibraryBackend::UpdateCompilations() { // in the same // directory - QSqlQuery q( + QSqlQuery q(db); + q.prepare( QString( "SELECT effective_albumartist, album, filename, sampler " - "FROM %1 WHERE unavailable = 0 ORDER BY album").arg(songs_table_), - db); + "FROM %1 WHERE unavailable = 0 ORDER BY album").arg(songs_table_)); q.exec(); if (db_->CheckErrors(q)) return; @@ -754,21 +751,21 @@ void LibraryBackend::UpdateCompilations() { } // Now mark the songs that we think are in compilations - QSqlQuery update( + QSqlQuery update(db); + update.prepare( QString( "UPDATE %1" " SET sampler = :sampler," " effective_compilation = ((compilation OR :sampler OR " "forced_compilation_on) AND NOT forced_compilation_off) + 0" - " WHERE album = :album AND unavailable = 0").arg(songs_table_), - db); - QSqlQuery find_songs( + " WHERE album = :album AND unavailable = 0").arg(songs_table_)); + QSqlQuery find_songs(db); + find_songs.prepare( QString( "SELECT ROWID, " + Song::kColumnSpec + " FROM %1" " WHERE album = :album AND sampler = :sampler AND unavailable = 0") - .arg(songs_table_), - db); + .arg(songs_table_)); SongList deleted_songs; SongList added_songs; @@ -932,7 +929,8 @@ void LibraryBackend::UpdateManualAlbumArt(const QString& artist, " WHERE album = :album AND unavailable = 0").arg(songs_table_)); if (!artist.isNull()) sql += " AND artist = :artist"; - QSqlQuery q(sql, db); + QSqlQuery q(db); + q.prepare(sql); q.bindValue(":art", art); q.bindValue(":album", album); if (!artist.isNull()) q.bindValue(":artist", artist); @@ -987,7 +985,8 @@ void LibraryBackend::ForceCompilation(const QString& album, " WHERE album = :album AND unavailable = 0").arg(songs_table_)); if (!artist.isEmpty()) sql += " AND artist = :artist"; - QSqlQuery q(sql, db); + QSqlQuery q(db); + q.prepare(sql); q.bindValue(":forced_compilation_on", on ? 1 : 0); q.bindValue(":forced_compilation_off", on ? 0 : 1); q.bindValue(":album", album); @@ -1025,7 +1024,8 @@ SongList LibraryBackend::FindSongs(const smart_playlists::Search& search) { // Run the query SongList ret; - QSqlQuery query(sql, db); + QSqlQuery query(db); + query.prepare(sql); query.exec(); if (db_->CheckErrors(query)) return ret; @@ -1052,13 +1052,13 @@ void LibraryBackend::IncrementPlayCount(int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q(QString( + QSqlQuery q(db); + q.prepare(QString( "UPDATE %1 SET playcount = playcount + 1," " lastplayed = :now," " score = " + QString(kNewScoreSql).arg("1.0") + - " WHERE ROWID = :id").arg(songs_table_), - db); + " WHERE ROWID = :id").arg(songs_table_)); q.bindValue(":now", QDateTime::currentDateTime().toTime_t()); q.bindValue(":id", id); q.exec(); @@ -1075,12 +1075,12 @@ void LibraryBackend::IncrementSkipCount(int id, float progress) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q(QString( + QSqlQuery q(db); + q.prepare(QString( "UPDATE %1 SET skipcount = skipcount + 1," " score = " + QString(kNewScoreSql).arg(progress) + - " WHERE ROWID = :id").arg(songs_table_), - db); + " WHERE ROWID = :id").arg(songs_table_)); q.bindValue(":id", id); q.exec(); if (db_->CheckErrors(q)) return; @@ -1095,11 +1095,11 @@ void LibraryBackend::ResetStatistics(int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q(QString( + QSqlQuery q(db); + q.prepare(QString( "UPDATE %1 SET playcount = 0, skipcount = 0," " lastplayed = -1, score = 0" - " WHERE ROWID = :id").arg(songs_table_), - db); + " WHERE ROWID = :id").arg(songs_table_)); q.bindValue(":id", id); q.exec(); if (db_->CheckErrors(q)) return; @@ -1128,10 +1128,10 @@ void LibraryBackend::UpdateSongsRating(const QList& id_list, id_str_list << QString::number(i); } QString ids = id_str_list.join(","); - QSqlQuery q(QString( + QSqlQuery q(db); + q.prepare(QString( "UPDATE %1 SET rating = :rating" - " WHERE ROWID IN (%2)").arg(songs_table_, ids), - db); + " WHERE ROWID IN (%2)").arg(songs_table_, ids)); q.bindValue(":rating", rating); q.exec(); if (db_->CheckErrors(q)) return; diff --git a/src/library/librarymodel.cpp b/src/library/librarymodel.cpp index 9d5e1e39f..73c92e228 100644 --- a/src/library/librarymodel.cpp +++ b/src/library/librarymodel.cpp @@ -151,7 +151,8 @@ void LibraryModel::Init(bool async) { new LibraryItem(LibraryItem::Type_LoadingIndicator, root_); loading->display_text = tr("Loading..."); loading->lazy_loaded = true; - reset(); + beginResetModel(); + endResetModel(); // Show a loading indicator in the status bar too. init_task_id_ = app_->task_manager()->StartTask(tr("Loading songs")); diff --git a/src/library/libraryquery.cpp b/src/library/libraryquery.cpp index 02177bf42..dd7bdc634 100644 --- a/src/library/libraryquery.cpp +++ b/src/library/libraryquery.cpp @@ -166,7 +166,8 @@ QSqlQuery LibraryQuery::Exec(QSqlDatabase db, const QString& songs_table, sql.replace("%fts_table_noprefix", fts_table.section('.', -1, -1)); sql.replace("%fts_table", fts_table); - query_ = QSqlQuery(sql, db); + query_ = QSqlQuery(db); + query_.prepare(sql); // Bind values for (const QVariant& value : bound_values_) { diff --git a/src/main.cpp b/src/main.cpp index eee7bbef2..4a90b0951 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,14 +69,14 @@ #include "tagreadermessages.pb.h" -#include "qtsingleapplication.h" -#include "qtsinglecoreapplication.h" +#include "singleapplication.h" +#include "singlecoreapplication.h" #include #include #include -#include +#include #ifdef HAVE_SPOTIFY_DOWNLOADER #include @@ -109,28 +109,18 @@ const QDBusArgument& operator>>(const QDBusArgument& arg, QImage& image); // Load sqlite plugin on windows and mac. #include -Q_IMPORT_PLUGIN(qsqlite) +Q_IMPORT_PLUGIN(QSQLiteDriverPlugin) namespace { void LoadTranslation(const QString& prefix, const QString& path, const QString& language) { -#if QT_VERSION < 0x040700 - // QTranslator::load will try to open and read "clementine" if it exists, - // without checking if it's a file first. - // This was fixed in Qt 4.7 - QFileInfo maybe_clementine_directory(path + "/clementine"); - if (maybe_clementine_directory.exists() && - !maybe_clementine_directory.isFile()) - return; -#endif QTranslator* t = new PoTranslator; if (t->load(prefix + "_" + language, path)) QCoreApplication::installTranslator(t); else delete t; - QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); } void IncreaseFDLimit() { @@ -272,10 +262,10 @@ int main(int argc, char* argv[]) { } #endif - QCoreApplication::setApplicationName("Clementine"); + QCoreApplication::setApplicationName("Clementine-qt5"); QCoreApplication::setApplicationVersion(CLEMENTINE_VERSION_DISPLAY); - QCoreApplication::setOrganizationName("Clementine"); - QCoreApplication::setOrganizationDomain("clementine-player.org"); + QCoreApplication::setOrganizationName("Clementine-qt5"); + QCoreApplication::setOrganizationDomain("clementine-player-qt5.org"); // This makes us show up nicely in gnome-volume-control #if !GLIB_CHECK_VERSION(2, 36, 0) @@ -298,7 +288,7 @@ int main(int argc, char* argv[]) { // Clementine running without needing an X server. // This MUST be done before parsing the commandline options so QTextCodec // gets the right system locale for filenames. - QtSingleCoreApplication a(argc, argv); + SingleCoreApplication a(argc, argv); CheckPortable(); crash_reporting.SetApplicationPath(a.applicationFilePath()); @@ -307,16 +297,6 @@ int main(int argc, char* argv[]) { if (!options.Parse()) return 1; logging::SetLevels(options.log_levels()); - if (a.isRunning()) { - if (options.is_empty()) { - qLog(Info) - << "Clementine is already running - activating existing window"; - } - if (a.sendMessage(options.Serialize(), 5000)) { - return 0; - } - // Couldn't send the message so start anyway - } } #ifdef Q_OS_DARWIN @@ -335,7 +315,7 @@ int main(int argc, char* argv[]) { // Output the version, so when people attach log output to bug reports they // don't have to tell us which version they're using. - qLog(Info) << "Clementine" << CLEMENTINE_VERSION_DISPLAY; + qLog(Info) << "Clementine-qt5" << CLEMENTINE_VERSION_DISPLAY; // Seed the random number generators. time_t t = time(nullptr); @@ -344,7 +324,7 @@ int main(int argc, char* argv[]) { IncreaseFDLimit(); - QtSingleApplication a(argc, argv); + SingleApplication a(argc, argv); // A bug in Qt means the wheel_scroll_lines setting gets ignored and replaced // with the default value of 3 in QApplicationPrivate::initialize. @@ -363,11 +343,6 @@ int main(int argc, char* argv[]) { a.setQuitOnLastWindowClosed(false); - // Do this check again because another instance might have started by now - if (a.isRunning() && a.sendMessage(options.Serialize(), 5000)) { - return 0; - } - #ifndef Q_OS_DARWIN // Gnome on Ubuntu has menu icons disabled by default. I think that's a bad // idea, and makes some menus in Clementine look confusing. @@ -491,10 +466,8 @@ int main(int argc, char* argv[]) { #ifdef HAVE_DBUS QObject::connect(&mpris, SIGNAL(RaiseMainWindow()), &w, SLOT(Raise())); #endif - QObject::connect(&a, SIGNAL(messageReceived(QByteArray)), &w, - SLOT(CommandlineOptionsReceived(QByteArray))); - w.CommandlineOptionsReceived(options); + w.CommandlineOptionsReceived(options); int ret = a.exec(); #ifdef Q_OS_LINUX diff --git a/src/musicbrainz/acoustidclient.cpp b/src/musicbrainz/acoustidclient.cpp index ba29dc060..9f92ec8c6 100644 --- a/src/musicbrainz/acoustidclient.cpp +++ b/src/musicbrainz/acoustidclient.cpp @@ -20,8 +20,11 @@ #include #include #include - -#include +#include +#include +#include +#include +#include #include "core/closure.h" #include "core/logging.h" @@ -50,7 +53,9 @@ void AcoustidClient::Start(int id, const QString& fingerprint, << Param("fingerprint", fingerprint); QUrl url(kUrl); - url.setQueryItems(parameters); + QUrlQuery url_query; + url_query.setQueryItems(parameters); + url.setQuery(url_query); QNetworkRequest req(url); QNetworkReply* reply = network_->get(req); @@ -94,15 +99,17 @@ void AcoustidClient::RequestFinished(QNetworkReply* reply, int request_id) { return; } - QJson::Parser parser; - bool ok = false; - QVariantMap result = parser.parse(reply, &ok).toMap(); - if (!ok) { + QJsonParseError error; + QJsonDocument json_document = QJsonDocument::fromJson(reply->readAll(), &error); + + if (error.error != QJsonParseError::NoError) { emit Finished(request_id, QStringList()); return; } - QString status = result["status"].toString(); + QJsonObject json_object = json_document.object(); + + QString status = json_object["status"].toString(); if (status != "ok") { emit Finished(request_id, QStringList()); return; @@ -113,18 +120,18 @@ void AcoustidClient::RequestFinished(QNetworkReply* reply, int request_id) { // -then sort results by number of sources (the results are originally // unsorted but results with more sources are likely to be more accurate) // -keep only the ids, as sources where useful only to sort the results - QVariantList results = result["results"].toList(); + QJsonArray json_results = json_object["results"].toArray(); // List of pairs QList id_source_list; - for (const QVariant& v : results) { - QVariantMap r = v.toMap(); - if (r.contains("recordings")) { - QVariantList recordings = r["recordings"].toList(); - for (const QVariant& recording : recordings) { - QVariantMap o = recording.toMap(); - if (o.contains("id")) { + for (const QJsonValue& v : json_results) { + QJsonObject r = v.toObject(); + if (!r["recordings"].isUndefined()) { + QJsonArray json_recordings = r["recordings"].toArray(); + for (const QJsonValue& recording : json_recordings) { + QJsonObject o = recording.toObject(); + if (!o["id"].isUndefined()) { id_source_list << IdSource(o["id"].toString(), o["sources"].toInt()); } } diff --git a/src/musicbrainz/chromaprinter.cpp b/src/musicbrainz/chromaprinter.cpp index 212075835..dbb3ef0f0 100644 --- a/src/musicbrainz/chromaprinter.cpp +++ b/src/musicbrainz/chromaprinter.cpp @@ -44,7 +44,7 @@ Chromaprinter::~Chromaprinter() {} GstElement* Chromaprinter::CreateElement(const QString& factory_name, GstElement* bin) { GstElement* ret = gst_element_factory_make( - factory_name.toAscii().constData(), factory_name.toAscii().constData()); + factory_name.toLatin1().constData(), factory_name.toLatin1().constData()); if (ret && bin) gst_bin_add(GST_BIN(bin), ret); diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp index 576af44d8..79c056827 100644 --- a/src/musicbrainz/musicbrainzclient.cpp +++ b/src/musicbrainz/musicbrainzclient.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "core/closure.h" #include "core/logging.h" @@ -50,7 +51,9 @@ void MusicBrainzClient::Start(int id, const QStringList& mbid_list) { parameters << Param("inc", "artists+releases+media"); QUrl url(kTrackUrl + mbid); - url.setQueryItems(parameters); + QUrlQuery url_query; + url_query.setQueryItems(parameters); + url.setQuery(url_query); QNetworkRequest req(url); QNetworkReply* reply = network_->get(req); @@ -74,7 +77,9 @@ void MusicBrainzClient::StartDiscIdRequest(const QString& discid) { parameters << Param("inc", "artists+recordings"); QUrl url(kDiscUrl + discid); - url.setQueryItems(parameters); + QUrlQuery url_query; + url_query.setQueryItems(parameters); + url.setQuery(url_query); QNetworkRequest req(url); QNetworkReply* reply = network_->get(req); diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index 55ec7c114..e65e8a529 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -180,7 +180,7 @@ void OutgoingDataCreator::SendClementineInfo() { QString version = QString("%1 %2").arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion()); - info->set_version(version.toAscii()); + info->set_version(version.toLatin1()); SendDataToClients(&msg); } diff --git a/src/playlist/playlistbackend.cpp b/src/playlist/playlistbackend.cpp index d8f3d3fd7..bb5d065a5 100644 --- a/src/playlist/playlistbackend.cpp +++ b/src/playlist/playlistbackend.cpp @@ -78,14 +78,13 @@ PlaylistBackend::PlaylistList PlaylistBackend::GetPlaylists( condition = " WHERE " + condition_list.join(" OR "); } - QSqlQuery q( - "SELECT ROWID, name, last_played, dynamic_playlist_type," + QSqlQuery q(db); + q.prepare("SELECT ROWID, name, last_played, dynamic_playlist_type," " dynamic_playlist_data, dynamic_playlist_backend," " special_type, ui_path, is_favorite" " FROM playlists" " " + - condition + " ORDER BY ui_order", - db); + condition + " ORDER BY ui_order"); q.exec(); if (db_->CheckErrors(q)) return ret; @@ -110,13 +109,12 @@ PlaylistBackend::Playlist PlaylistBackend::GetPlaylist(int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q( - "SELECT ROWID, name, last_played, dynamic_playlist_type," + QSqlQuery q(db); + q.prepare("SELECT ROWID, name, last_played, dynamic_playlist_type," " dynamic_playlist_data, dynamic_playlist_backend," " special_type, ui_path, is_favorite" " FROM playlists" - " WHERE ROWID=:id", - db); + " WHERE ROWID=:id"); q.bindValue(":id", id); q.exec(); if (db_->CheckErrors(q)) return Playlist(); @@ -293,23 +291,22 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items, qLog(Debug) << "Saving playlist" << playlist; - QSqlQuery clear("DELETE FROM playlist_items WHERE playlist = :playlist", db); - QSqlQuery insert( - "INSERT INTO playlist_items" + QSqlQuery clear(db); + clear.prepare("DELETE FROM playlist_items WHERE playlist = :playlist"); + QSqlQuery insert(db); + insert.prepare("INSERT INTO playlist_items" " (playlist, type, library_id, radio_service, " + Song::kColumnSpec + ")" " VALUES (:playlist, :type, :library_id, :radio_service, " + - Song::kBindSpec + ")", - db); - QSqlQuery update( - "UPDATE playlists SET " + Song::kBindSpec + ")"); + QSqlQuery update(db); + update.prepare("UPDATE playlists SET " " last_played=:last_played," " dynamic_playlist_type=:dynamic_type," " dynamic_playlist_data=:dynamic_data," " dynamic_playlist_backend=:dynamic_backend" - " WHERE ROWID=:playlist", - db); + " WHERE ROWID=:playlist"); ScopedTransaction transaction(&db); @@ -350,10 +347,10 @@ int PlaylistBackend::CreatePlaylist(const QString& name, QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q( + QSqlQuery q(db); + q.prepare( "INSERT INTO playlists (name, special_type)" - " VALUES (:name, :special_type)", - db); + " VALUES (:name, :special_type)"); q.bindValue(":name", name); q.bindValue(":special_type", special_type); q.exec(); @@ -365,8 +362,10 @@ int PlaylistBackend::CreatePlaylist(const QString& name, void PlaylistBackend::RemovePlaylist(int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery delete_playlist("DELETE FROM playlists WHERE ROWID=:id", db); - QSqlQuery delete_items("DELETE FROM playlist_items WHERE playlist=:id", db); + QSqlQuery delete_playlist(db); + delete_playlist.prepare("DELETE FROM playlists WHERE ROWID=:id"); + QSqlQuery delete_items(db); + delete_items.prepare("DELETE FROM playlist_items WHERE playlist=:id"); delete_playlist.bindValue(":id", id); delete_items.bindValue(":id", id); @@ -385,7 +384,8 @@ void PlaylistBackend::RemovePlaylist(int id) { void PlaylistBackend::RenamePlaylist(int id, const QString& new_name) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("UPDATE playlists SET name=:name WHERE ROWID=:id", db); + QSqlQuery q(db); + q.prepare("UPDATE playlists SET name=:name WHERE ROWID=:id"); q.bindValue(":name", new_name); q.bindValue(":id", id); @@ -396,8 +396,8 @@ void PlaylistBackend::RenamePlaylist(int id, const QString& new_name) { void PlaylistBackend::FavoritePlaylist(int id, bool is_favorite) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("UPDATE playlists SET is_favorite=:is_favorite WHERE ROWID=:id", - db); + QSqlQuery q(db); + q.prepare("UPDATE playlists SET is_favorite=:is_favorite WHERE ROWID=:id"); q.bindValue(":is_favorite", is_favorite ? 1 : 0); q.bindValue(":id", id); @@ -410,11 +410,12 @@ void PlaylistBackend::SetPlaylistOrder(const QList& ids) { QSqlDatabase db(db_->Connect()); ScopedTransaction transaction(&db); - QSqlQuery q("UPDATE playlists SET ui_order=-1", db); + QSqlQuery q(db); + q.prepare("UPDATE playlists SET ui_order=-1"); q.exec(); if (db_->CheckErrors(q)) return; - q = QSqlQuery("UPDATE playlists SET ui_order=:index WHERE ROWID=:id", db); + q.prepare("UPDATE playlists SET ui_order=:index WHERE ROWID=:id"); for (int i = 0; i < ids.count(); ++i) { q.bindValue(":index", i); q.bindValue(":id", ids[i]); @@ -428,7 +429,8 @@ void PlaylistBackend::SetPlaylistOrder(const QList& ids) { void PlaylistBackend::SetPlaylistUiPath(int id, const QString& path) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - QSqlQuery q("UPDATE playlists SET ui_path=:path WHERE ROWID=:id", db); + QSqlQuery q(db); + q.prepare("UPDATE playlists SET ui_path=:path WHERE ROWID=:id"); ScopedTransaction transaction(&db); diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index 76b15544c..580e78a40 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -220,7 +220,7 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent* event, QAbstractItemView* view, // Special case: we want newlines in the comment tooltip if (index.column() == Playlist::Column_Comment) { - text = Qt::escape(index.data(Qt::ToolTipRole).toString()); + text = index.data(Qt::ToolTipRole).toString().toHtmlEscaped(); text.replace("\\r\\n", "
"); text.replace("\\n", "
"); text.replace("\r\n", "
"); @@ -436,7 +436,7 @@ QString NativeSeparatorsDelegate::displayText(const QVariant& value, if (value.type() == QVariant::Url) { url = value.toUrl(); } else if (string_value.contains("://")) { - url = QUrl::fromEncoded(string_value.toAscii()); + url = QUrl::fromEncoded(string_value.toLatin1()); } else { return QDir::toNativeSeparators(string_value); } diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index fe4ec4562..c1cebc56c 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -27,7 +27,7 @@ #include "covers/currentartloader.h" #include "ui/qt_blurimage.h" -#include +#include #include #include #include @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -60,7 +61,7 @@ const int PlaylistView::kDefaultBlurRadius = 0; const int PlaylistView::kDefaultOpacityLevel = 40; PlaylistProxyStyle::PlaylistProxyStyle(QStyle* base) - : QProxyStyle(base), cleanlooks_(new QCleanlooksStyle) {} + : QProxyStyle(base), common_style_(new QCommonStyle) {} void PlaylistProxyStyle::drawControl(ControlElement element, const QStyleOption* option, @@ -85,7 +86,7 @@ void PlaylistProxyStyle::drawControl(ControlElement element, } if (element == CE_ItemViewItem) - cleanlooks_->drawControl(element, option, painter, widget); + common_style_->drawControl(element, option, painter, widget); else QProxyStyle::drawControl(element, option, painter, widget); } @@ -96,7 +97,7 @@ void PlaylistProxyStyle::drawPrimitive(PrimitiveElement element, const QWidget* widget) const { if (element == QStyle::PE_PanelItemViewRow || element == QStyle::PE_PanelItemViewItem) - cleanlooks_->drawPrimitive(element, option, painter, widget); + common_style_->drawPrimitive(element, option, painter, widget); else QProxyStyle::drawPrimitive(element, option, painter, widget); } @@ -132,7 +133,7 @@ PlaylistView::PlaylistView(QWidget* parent) drag_over_(false), dynamic_controls_(new DynamicPlaylistControls(this)) { setHeader(header_); - header_->setMovable(true); + header_->setSectionsMovable(true); setStyle(style_); setMouseTracking(true); diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index fedc207e0..d72312b8d 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -26,7 +26,7 @@ #include "playlist.h" -class QCleanlooksStyle; +class QCommonStyle; class Application; class DynamicPlaylistControls; @@ -40,7 +40,7 @@ class QTimeLine; // that uses Gtk to paint row backgrounds, ignoring any custom brush or palette // the caller set in the QStyleOption. That breaks our currently playing track // animation, which relies on the background painted by Qt to be transparent. -// This proxy style uses QCleanlooksStyle to paint the affected elements. +// This proxy style uses QCommonStyle to paint the affected elements. // This class is used by the global search view as well. class PlaylistProxyStyle : public QProxyStyle { public: @@ -51,7 +51,7 @@ class PlaylistProxyStyle : public QProxyStyle { QPainter* painter, const QWidget* widget) const; private: - std::unique_ptr cleanlooks_; + std::unique_ptr common_style_; }; class PlaylistView : public QTreeView { diff --git a/src/smartplaylists/searchtermwidget.cpp b/src/smartplaylists/searchtermwidget.cpp index 74bf64b07..9cf989475 100644 --- a/src/smartplaylists/searchtermwidget.cpp +++ b/src/smartplaylists/searchtermwidget.cpp @@ -118,7 +118,7 @@ SearchTermWidget::SearchTermWidget(LibraryBackend* library, QWidget* parent) // Set stylesheet QFile stylesheet_file(":/smartplaylistsearchterm.css"); stylesheet_file.open(QIODevice::ReadOnly); - QString stylesheet = QString::fromAscii(stylesheet_file.readAll()); + QString stylesheet = QString::fromLatin1(stylesheet_file.readAll()); const QColor base(222, 97, 97, 128); stylesheet.replace("%light2", Utilities::ColorToRgba(base.lighter(140))); stylesheet.replace("%light", Utilities::ColorToRgba(base.lighter(120))); diff --git a/src/songinfo/songinfobase.cpp b/src/songinfo/songinfobase.cpp index 35bd0c517..770b8d5a3 100644 --- a/src/songinfo/songinfobase.cpp +++ b/src/songinfo/songinfobase.cpp @@ -59,7 +59,7 @@ SongInfoBase::SongInfoBase(QWidget* parent) // Set stylesheet QFile stylesheet(":/songinfo.css"); stylesheet.open(QIODevice::ReadOnly); - setStyleSheet(QString::fromAscii(stylesheet.readAll())); + setStyleSheet(QString::fromLatin1(stylesheet.readAll())); connect(fetcher_, SIGNAL(ResultReady(int, SongInfoFetcher::Result)), SLOT(ResultReady(int, SongInfoFetcher::Result))); diff --git a/src/songinfo/songkickconcerts.cpp b/src/songinfo/songkickconcerts.cpp index 1b36e420e..0f21633cf 100644 --- a/src/songinfo/songkickconcerts.cpp +++ b/src/songinfo/songkickconcerts.cpp @@ -20,11 +20,12 @@ #include #include #include +#include +#include +#include #include -#include - #include "core/closure.h" #include "core/logging.h" #include "songkickconcertwidget.h" @@ -107,22 +108,23 @@ void SongkickConcerts::FetchSongkickCalendar(const QString& artist_id, int id) { } void SongkickConcerts::CalendarRequestFinished(QNetworkReply* reply, int id) { - QJson::Parser parser; - bool ok = false; - QVariant result = parser.parse(reply, &ok); + reply->deleteLater(); - if (!ok) { + QJsonParseError error; + QJsonDocument json_document = QJsonDocument::fromJson(reply->readAll(), &error); + + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Error parsing Songkick reply"; emit Finished(id); return; } - QVariantMap root = result.toMap(); - QVariantMap results_page = root["resultsPage"].toMap(); - QVariantMap results = results_page["results"].toMap(); - QVariantList events = results["event"].toList(); + QJsonObject json_root = json_document.object(); + QJsonObject json_results_page = json_root["resultsPage"].toObject(); + QJsonObject json_results = json_results_page["results"].toObject(); + QJsonArray json_events = json_results["event"].toArray(); - if (events.isEmpty()) { + if (json_events.isEmpty()) { emit Finished(id); return; } @@ -130,21 +132,21 @@ void SongkickConcerts::CalendarRequestFinished(QNetworkReply* reply, int id) { QWidget* container = new QWidget; QVBoxLayout* layout = new QVBoxLayout(container); - for (const QVariant& v : events) { - QVariantMap event = v.toMap(); - QString display_name = event["displayName"].toString(); - QString start_date = event["start"].toMap()["date"].toString(); - QString city = event["location"].toMap()["city"].toString(); - QString uri = event["uri"].toString(); + for (const QJsonValue& v : json_events) { + QJsonObject json_event = v.toObject(); + QString display_name = json_event["displayName"].toString(); + QString start_date = json_event["start"].toObject()["date"].toString(); + QString city = json_event["location"].toObject()["city"].toString(); + QString uri = json_event["uri"].toString(); // Try to get the lat/lng coordinates of the venue. - QVariantMap venue = event["venue"].toMap(); - const bool valid_latlng = venue["lng"].isValid() && venue["lat"].isValid(); + QJsonObject json_venue = json_event["venue"].toObject(); + const bool valid_latlng = !json_venue["lng"].isUndefined() && !json_venue["lat"].isUndefined(); if (valid_latlng && latlng_.IsValid()) { static const int kFilterDistanceMetres = 250 * 1e3; // 250km - Geolocator::LatLng latlng(venue["lat"].toString(), - venue["lng"].toString()); + Geolocator::LatLng latlng(json_venue["lat"].toString(), + json_venue["lng"].toString()); if (latlng_.IsValid() && latlng.IsValid()) { int distance_metres = latlng_.Distance(latlng); if (distance_metres > kFilterDistanceMetres) { @@ -159,8 +161,8 @@ void SongkickConcerts::CalendarRequestFinished(QNetworkReply* reply, int id) { widget->Init(display_name, uri, start_date, city); if (valid_latlng) { - widget->SetMap(venue["lat"].toString(), venue["lng"].toString(), - venue["displayName"].toString()); + widget->SetMap(json_venue["lat"].toString(), json_venue["lng"].toString(), + json_venue["displayName"].toString()); } layout->addWidget(widget); diff --git a/src/songinfo/songkickconcertwidget.cpp b/src/songinfo/songkickconcertwidget.cpp index 691f9fb02..21655f1f0 100644 --- a/src/songinfo/songkickconcertwidget.cpp +++ b/src/songinfo/songkickconcertwidget.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "songinfotextview.h" #include "ui_songkickconcertwidget.h" @@ -58,7 +59,7 @@ void SongKickConcertWidget::ReloadSettings() { void SongKickConcertWidget::Init(const QString& title, const QString& url, const QString& date, const QString& location) { ui_->title->setText( - QString("%2").arg(Qt::escape(url), Qt::escape(title))); + QString("%2").arg(url.toHtmlEscaped(), title.toHtmlEscaped())); if (!location.isEmpty()) { ui_->location->setText(location); @@ -96,10 +97,12 @@ void SongKickConcertWidget::SetMap(const QString& lat, const QString& lng, ui_->map->show(); map_url_ = QUrl("https://maps.google.com/"); - map_url_.addQueryItem("ll", QString("%1,%2").arg(lat, lng)); + QUrlQuery map_url_query; + map_url_query.addQueryItem("ll", QString("%1,%2").arg(lat, lng)); if (!venue_name.isEmpty()) { - map_url_.addQueryItem("q", venue_name); + map_url_query.addQueryItem("q", venue_name); } + map_url_.setQuery(map_url_query); // Request the static map image const QUrl url(QString(kStaticMapUrl).arg(QString::number(kStaticMapWidth), diff --git a/src/songinfo/ultimatelyricsprovider.cpp b/src/songinfo/ultimatelyricsprovider.cpp index 586e5d239..915d62a00 100644 --- a/src/songinfo/ultimatelyricsprovider.cpp +++ b/src/songinfo/ultimatelyricsprovider.cpp @@ -37,7 +37,7 @@ UltimateLyricsProvider::UltimateLyricsProvider() void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) { // Get the text codec const QTextCodec* codec = - QTextCodec::codecForName(charset_.toAscii().constData()); + QTextCodec::codecForName(charset_.toLatin1().constData()); if (!codec) { qLog(Warning) << "Invalid codec" << charset_; emit Finished(id); @@ -100,7 +100,7 @@ void UltimateLyricsProvider::LyricsFetched() { } const QTextCodec* codec = - QTextCodec::codecForName(charset_.toAscii().constData()); + QTextCodec::codecForName(charset_.toLatin1().constData()); const QString original_content = codec->toUnicode(reply->readAll()); QString lyrics; diff --git a/src/transcoder/transcodedialog.cpp b/src/transcoder/transcodedialog.cpp index 49f2f8ef8..981e3178a 100644 --- a/src/transcoder/transcodedialog.cpp +++ b/src/transcoder/transcodedialog.cpp @@ -54,7 +54,7 @@ TranscodeDialog::TranscodeDialog(QWidget* parent) finished_success_(0), finished_failed_(0) { ui_->setupUi(this); - ui_->files->header()->setResizeMode(QHeaderView::ResizeToContents); + ui_->files->header()->setSectionResizeMode(QHeaderView::ResizeToContents); log_ui_->setupUi(log_dialog_); QPushButton* clear_button = diff --git a/src/transcoder/transcoder.cpp b/src/transcoder/transcoder.cpp index 973a161cc..a51b77bd6 100644 --- a/src/transcoder/transcoder.cpp +++ b/src/transcoder/transcoder.cpp @@ -47,9 +47,9 @@ TranscoderPreset::TranscoderPreset(Song::FileType type, const QString& name, GstElement* Transcoder::CreateElement(const QString& factory_name, GstElement* bin, const QString& name) { GstElement* ret = gst_element_factory_make( - factory_name.toAscii().constData(), - name.isNull() ? factory_name.toAscii().constData() - : name.toAscii().constData()); + factory_name.toLatin1().constData(), + name.isNull() ? factory_name.toLatin1().constData() + : name.toLatin1().constData()); if (ret && bin) gst_bin_add(GST_BIN(bin), ret); diff --git a/src/ui/albumcoverchoicecontroller.cpp b/src/ui/albumcoverchoicecontroller.cpp index 06a40f3c5..0fa6f15e0 100644 --- a/src/ui/albumcoverchoicecontroller.cpp +++ b/src/ui/albumcoverchoicecontroller.cpp @@ -39,6 +39,7 @@ #include #include #include +#include const char* AlbumCoverChoiceController::kLoadImageFileFilter = QT_TR_NOOP( "Images (*.png *.jpg *.jpeg *.bmp *.gif *.xpm *.pbm *.pgm *.ppm *.xbm)"); diff --git a/src/ui/edittagdialog.cpp b/src/ui/edittagdialog.cpp index a69c67fbe..d3075fec2 100644 --- a/src/ui/edittagdialog.cpp +++ b/src/ui/edittagdialog.cpp @@ -461,21 +461,20 @@ void EditTagDialog::UpdateSummaryTab(const Song& song) { app_->album_cover_loader()->LoadImageAsync(cover_options_, song); QString summary = - "" + Qt::escape(song.PrettyTitleWithArtist()) + "
"; + "" + song.PrettyTitleWithArtist().toHtmlEscaped() + "
"; bool art_is_set = true; if (song.has_manually_unset_cover()) { - summary += Qt::escape(tr("Cover art manually unset")); + summary += tr("Cover art manually unset").toHtmlEscaped(); art_is_set = false; } else if (!song.art_manual().isEmpty()) { - summary += Qt::escape(tr("Cover art set from %1").arg(song.art_manual())); + summary += tr("Cover art set from %1").arg(song.art_manual()).toHtmlEscaped(); } else if (song.has_embedded_cover()) { - summary += Qt::escape(tr("Cover art from embedded image")); + summary += tr("Cover art from embedded image"); } else if (!song.art_automatic().isEmpty()) { - summary += Qt::escape( - tr("Cover art loaded automatically from %1").arg(song.art_automatic())); + summary += tr("Cover art loaded automatically from %1").arg(song.art_automatic()).toHtmlEscaped(); } else { - summary += Qt::escape(tr("Cover art not set")); + summary += tr("Cover art not set").toHtmlEscaped(); art_is_set = false; } diff --git a/src/ui/flowlayout.cpp b/src/ui/flowlayout.cpp index cccb1a1c4..582ec92bd 100644 --- a/src/ui/flowlayout.cpp +++ b/src/ui/flowlayout.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include +#include #include "flowlayout.h" //! [1] diff --git a/src/ui/globalshortcutssettingspage.cpp b/src/ui/globalshortcutssettingspage.cpp index 8217594a0..8a25d27ae 100644 --- a/src/ui/globalshortcutssettingspage.cpp +++ b/src/ui/globalshortcutssettingspage.cpp @@ -39,7 +39,7 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog* dialog) grabber_(new GlobalShortcutGrabber) { ui_->setupUi(this); ui_->shortcut_options->setEnabled(false); - ui_->list->header()->setResizeMode(QHeaderView::ResizeToContents); + ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); setWindowIcon(IconLoader::Load("input-keyboard")); settings_.beginGroup(GlobalShortcuts::kSettingsGroup); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 736762b2a..cba1d91d9 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -951,7 +951,6 @@ MainWindow::~MainWindow() { void MainWindow::ReloadSettings() { #ifndef Q_OS_DARWIN bool show_tray = settings_.value("showtray", true).toBool(); - tray_icon_->SetVisible(show_tray); if (!show_tray && !isVisible()) show(); #endif diff --git a/src/ui/qtsystemtrayicon.cpp b/src/ui/qtsystemtrayicon.cpp index 39677bc21..436cdc395 100644 --- a/src/ui/qtsystemtrayicon.cpp +++ b/src/ui/qtsystemtrayicon.cpp @@ -57,7 +57,7 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject* parent) QFile pattern_file(":/now_playing_tooltip.txt"); pattern_file.open(QIODevice::ReadOnly); - pattern_ = QString::fromAscii(pattern_file.readAll()); + pattern_ = QString::fromLatin1(pattern_file.readAll()); connect(tray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(Clicked(QSystemTrayIcon::ActivationReason))); @@ -216,7 +216,7 @@ void QtSystemTrayIcon::SetVisible(bool visible) { tray_->setVisible(visible); } void QtSystemTrayIcon::SetNowPlaying(const Song& song, const QString& image_path) { -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN // Windows doesn't support HTML in tooltips, so just show something basic tray_->setToolTip(song.PrettyTitleWithArtist()); return; @@ -230,14 +230,14 @@ void QtSystemTrayIcon::SetNowPlaying(const Song& song, clone.replace("%appName", QCoreApplication::applicationName()); clone.replace("%titleKey", tr("Title") % ":"); - clone.replace("%titleValue", Qt::escape(song.PrettyTitle())); + clone.replace("%titleValue", song.PrettyTitle().toHtmlEscaped()); clone.replace("%artistKey", tr("Artist") % ":"); - clone.replace("%artistValue", Qt::escape(song.artist())); + clone.replace("%artistValue", song.artist().toHtmlEscaped()); clone.replace("%albumKey", tr("Album") % ":"); - clone.replace("%albumValue", Qt::escape(song.album())); + clone.replace("%albumValue", song.album().toHtmlEscaped()); clone.replace("%lengthKey", tr("Length") % ":"); - clone.replace("%lengthValue", Qt::escape(song.PrettyLength())); + clone.replace("%lengthValue", song.PrettyLength().toHtmlEscaped()); if (columns == 2) { QString final_path = diff --git a/src/widgets/errordialog.cpp b/src/widgets/errordialog.cpp index eb6e0bef8..1086305f3 100644 --- a/src/widgets/errordialog.cpp +++ b/src/widgets/errordialog.cpp @@ -53,7 +53,7 @@ void ErrorDialog::UpdateContent() { QString html; for (const QString& message : current_messages_) { if (!html.isEmpty()) html += "
"; - html += Qt::escape(message); + html += message.toHtmlEscaped(); } ui_->messages->setHtml(html); } diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp index c61d3fe83..9f73584e7 100644 --- a/src/widgets/fancytabwidget.cpp +++ b/src/widgets/fancytabwidget.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include using namespace Core; using namespace Internal; @@ -128,7 +128,7 @@ void FancyTabProxyStyle::drawControl(ControlElement element, p->drawText(text_rect, textFlags, text); p->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor()); -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC if (widget) { const QString fader_key = "tab_" + text + "_fader"; const QString animation_key = "tab_" + text + "_animation"; @@ -253,7 +253,7 @@ void FancyTab::setFader(float value) { FancyTabBar::FancyTabBar(QWidget* parent) : QWidget(parent) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - setStyle(new QWindowsStyle); + setStyle(new QCommonStyle); setMinimumWidth(qMax(2 * m_rounding, 40)); setAttribute(Qt::WA_Hover, true); setFocusPolicy(Qt::NoFocus); @@ -439,7 +439,7 @@ void FancyTabBar::paintTab(QPainter* painter, int tabIndex) const { painter->drawText(tabTextRect, textFlags, tabText); painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor()); -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC if (!selected) { painter->save(); int fader = int(m_tabs[tabIndex]->fader()); diff --git a/src/widgets/forcescrollperpixel.cpp b/src/widgets/forcescrollperpixel.cpp index 065c1e47b..f7aea32c1 100644 --- a/src/widgets/forcescrollperpixel.cpp +++ b/src/widgets/forcescrollperpixel.cpp @@ -29,8 +29,7 @@ ForceScrollPerPixel::ForceScrollPerPixel(QAbstractItemView* item_view, bool ForceScrollPerPixel::eventFilter(QObject* object, QEvent* event) { if (object == item_view_ && event->type() != QEvent::Destroy && - event->type() != QEvent::WinIdChange && - event->type() != QEvent::AccessibilityPrepare) { + event->type() != QEvent::WinIdChange) { item_view_->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); item_view_->verticalScrollBar()->setSingleStep(20); } diff --git a/src/widgets/groupediconview.cpp b/src/widgets/groupediconview.cpp index ba0fef26b..60a53a85b 100644 --- a/src/widgets/groupediconview.cpp +++ b/src/widgets/groupediconview.cpp @@ -108,7 +108,7 @@ void GroupedIconView::rowsInserted(const QModelIndex& parent, int start, } void GroupedIconView::dataChanged(const QModelIndex& topLeft, - const QModelIndex& bottomRight) { + const QModelIndex& bottomRight, const QVector &) { QListView::dataChanged(topLeft, bottomRight); LayoutItems(); } diff --git a/src/widgets/groupediconview.h b/src/widgets/groupediconview.h index 42e08bf1f..025e5584d 100644 --- a/src/widgets/groupediconview.h +++ b/src/widgets/groupediconview.h @@ -72,7 +72,7 @@ class GroupedIconView : public QListView { void resizeEvent(QResizeEvent* e); // QAbstractItemView - void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); + void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector& = QVector()); QModelIndex indexAt(const QPoint& p) const; void rowsInserted(const QModelIndex& parent, int start, int end); void setSelection(const QRect& rect, diff --git a/src/widgets/nowplayingwidget.cpp b/src/widgets/nowplayingwidget.cpp index 10194e18a..588736599 100644 --- a/src/widgets/nowplayingwidget.cpp +++ b/src/widgets/nowplayingwidget.cpp @@ -290,8 +290,8 @@ void NowPlayingWidget::UpdateDetailsText() { // TODO: Make this configurable html += QString("%1
%2
%3").arg( - Qt::escape(metadata_.PrettyTitle()), Qt::escape(metadata_.artist()), - Qt::escape(metadata_.album())); + metadata_.PrettyTitle().toHtmlEscaped(), metadata_.artist().toHtmlEscaped(), + metadata_.album().toHtmlEscaped()); html += "

"; details_->setHtml(html); diff --git a/src/widgets/stylehelper.cpp b/src/widgets/stylehelper.cpp index 23ab4c697..87674af37 100644 --- a/src/widgets/stylehelper.cpp +++ b/src/widgets/stylehelper.cpp @@ -30,12 +30,12 @@ #include "stylehelper.h" #include -#include +#include #include #include -#include +#include #include -#include +#include #include // Clamps float color values within (0, 255) @@ -47,7 +47,7 @@ static int clamp(float x) { namespace Utils { qreal StyleHelper::sidebarFontSize() { -#if defined(Q_WS_MAC) +#if defined(Q_OS_MAC) return 10; #else return 7.5; diff --git a/src/widgets/stylehelper.h b/src/widgets/stylehelper.h index f73f4b442..77c62b9ec 100644 --- a/src/widgets/stylehelper.h +++ b/src/widgets/stylehelper.h @@ -30,8 +30,8 @@ #ifndef STYLEHELPER_H #define STYLEHELPER_H -#include -#include +#include +#include #include "ui/qt_blurimage.h" diff --git a/tests/scopedtransaction_test.cpp b/tests/scopedtransaction_test.cpp index 2a7fa98da..3261574b9 100644 --- a/tests/scopedtransaction_test.cpp +++ b/tests/scopedtransaction_test.cpp @@ -63,13 +63,15 @@ TEST_F(ScopedTransactionTest, RollbackOnDtor) { ScopedTransaction t(&database_); database_.exec("INSERT INTO foo (bar) VALUES (42)"); - QSqlQuery q("SELECT * FROM foo", database_); + QSqlQuery q(database_); + q.prepare("SELECT * FROM foo"); ASSERT_TRUE(q.exec()); ASSERT_TRUE(q.next()); EXPECT_EQ(42, q.value(0).toInt()); } - QSqlQuery q("SELECT * FROM foo", database_); + QSqlQuery q(database_); + q.prepare("SELECT * FROM foo"); ASSERT_TRUE(q.exec()); ASSERT_FALSE(q.next()); } @@ -83,7 +85,8 @@ TEST_F(ScopedTransactionTest, Commit) { t.Commit(); } - QSqlQuery q("SELECT * FROM foo", database_); + QSqlQuery q(database_); + q.prepare("SELECT * FROM foo"); ASSERT_TRUE(q.exec()); ASSERT_TRUE(q.next()); EXPECT_EQ(42, q.value(0).toInt()); diff --git a/tools/ultimate_lyrics_parser/main.cpp b/tools/ultimate_lyrics_parser/main.cpp index 19083ff43..a92d3ad5f 100644 --- a/tools/ultimate_lyrics_parser/main.cpp +++ b/tools/ultimate_lyrics_parser/main.cpp @@ -17,8 +17,6 @@ #include #include -#include -#include #include #include From 42aafd247a3a96f7a6c07d31b3a0881691a8daf2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Apr 2015 18:26:09 +0200 Subject: [PATCH 10/17] Update optional components to qt5 --- CMakeLists.txt | 51 ++++++------ src/CMakeLists.txt | 7 +- src/dbus/org.freedesktop.Avahi.EntryGroup.xml | 4 +- src/dbus/org.freedesktop.Avahi.Server.xml | 2 +- .../org.freedesktop.MediaPlayer.player.xml | 8 +- src/dbus/org.freedesktop.MediaPlayer.root.xml | 2 +- .../org.freedesktop.MediaPlayer.tracklist.xml | 2 +- src/dbus/org.freedesktop.Notifications.xml | 2 +- src/dbus/org.freedesktop.UDisks.Device.xml | 8 +- src/dbus/org.freedesktop.UDisks.xml | 2 +- src/dbus/org.mpris.MediaPlayer2.Player.xml | 2 +- src/dbus/org.mpris.MediaPlayer2.Playlists.xml | 8 +- src/dbus/org.mpris.MediaPlayer2.TrackList.xml | 6 +- src/devices/mtpconnection.cpp | 14 ++-- src/internet/box/boxservice.cpp | 73 +++++++++--------- src/internet/box/boxservice.h | 2 +- src/internet/dropbox/dropboxauthenticator.cpp | 20 ++--- src/internet/dropbox/dropboxservice.cpp | 50 ++++++------ .../googledrive/googledriveclient.cpp | 60 ++++++++------- .../googledrive/googledriveservice.cpp | 7 +- src/internet/lastfm/lastfmcompat.h | 28 +++---- src/internet/lastfm/lastfmservice.cpp | 2 +- src/internet/seafile/seafileservice.cpp | 77 ++++++++++--------- src/internet/skydrive/skydriveservice.cpp | 38 ++++----- src/internet/vk/vkconnection.cpp | 60 +++++++++------ src/internet/vk/vkmusiccache.cpp | 2 +- src/moodbar/moodbarpipeline.cpp | 2 +- src/ui/ripcd.cpp | 6 +- src/widgets/osd_x11.cpp | 2 +- src/wiimotedev/wiimotesettingspage.cpp | 2 +- tests/CMakeLists.txt | 8 +- 31 files changed, 298 insertions(+), 259 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fccae8aa..c108b2974 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,9 +87,9 @@ if (WIN32) find_library(QTSPARKLE_LIBRARIES qtsparkle) endif (WIN32) -find_library(LASTFM_LIBRARIES lastfm) -find_path(LASTFM_INCLUDE_DIRS lastfm/ws.h) -find_path(LASTFM1_INCLUDE_DIRS lastfm/Track.h) +find_library(LASTFM5_LIBRARIES lastfm5) +find_path(LASTFM5_INCLUDE_DIRS lastfm5/ws.h) +find_path(LASTFM51_INCLUDE_DIRS lastfm5/Track.h) find_path(SPARSEHASH_INCLUDE_DIRS google/sparsetable) @@ -115,7 +115,7 @@ else() set(CMAKE_REQUIRED_LIBRARIES) endif() -if(LASTFM_INCLUDE_DIRS AND LASTFM1_INCLUDE_DIRS) +if(LASTFM5_INCLUDE_DIRS AND LASTFM51_INCLUDE_DIRS) set(HAVE_LIBLASTFM1 ON) endif() @@ -192,85 +192,85 @@ endif(WIN32) optional_component(BREAKPAD OFF "Crash reporting") -optional_component(GOOGLE_DRIVE OFF "Google Drive support" +optional_component(GOOGLE_DRIVE ON "Google Drive support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(DROPBOX OFF "Dropbox support" +optional_component(DROPBOX ON "Dropbox support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(SKYDRIVE OFF "Skydrive support" +optional_component(SKYDRIVE ON "Skydrive support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(BOX OFF "Box support" +optional_component(BOX ON "Box support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(VK OFF "Vk.com support") +optional_component(VK ON "Vk.com support") -optional_component(SEAFILE OFF "Seafile support" +optional_component(SEAFILE ON "Seafile support" DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" ) -optional_component(AUDIOCD OFF "Devices: Audio CD support" +optional_component(AUDIOCD ON "Devices: Audio CD support" DEPENDS "libcdio" CDIO_FOUND ) -optional_component(LIBGPOD OFF "Devices: iPod classic support" +optional_component(LIBGPOD ON "Devices: iPod classic support" DEPENDS "libgpod" LIBGPOD_FOUND ) -optional_component(GIO OFF "Devices: GIO device backend" +optional_component(GIO ON "Devices: GIO device backend" DEPENDS "libgio" GIO_FOUND DEPENDS "Linux or Windows" "NOT APPLE" ) -optional_component(LIBMTP OFF "Devices: MTP support" +optional_component(LIBMTP ON "Devices: MTP support" DEPENDS "libmtp" LIBMTP_FOUND ) -optional_component(LIBLASTFM OFF "Last.fm support" - DEPENDS "liblastfm" LASTFM_LIBRARIES LASTFM_INCLUDE_DIRS +optional_component(LIBLASTFM ON "Last.fm support" + DEPENDS "liblastfm" LASTFM5_LIBRARIES LASTFM5_INCLUDE_DIRS ) -optional_component(DBUS OFF "D-Bus support" +optional_component(DBUS ON "D-Bus support" DEPENDS "Linux" LINUX ) -optional_component(WIIMOTEDEV OFF "Wiimote support" +optional_component(WIIMOTEDEV ON "Wiimote support" DEPENDS "D-Bus support" HAVE_DBUS ) -optional_component(DEVICEKIT OFF "Devices: DeviceKit backend" +optional_component(DEVICEKIT ON "Devices: DeviceKit backend" DEPENDS "D-Bus support" HAVE_DBUS ) -optional_component(SPOTIFY_BLOB OFF "Spotify support: non-GPL binary helper" +optional_component(SPOTIFY_BLOB ON "Spotify support: non-GPL binary helper" DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE DEPENDS "libspotify" SPOTIFY_FOUND ) -optional_component(MOODBAR OFF "Moodbar support" +optional_component(MOODBAR ON "Moodbar support" DEPENDS "fftw3" FFTW3_FOUND ) -optional_component(SPARKLE OFF "Sparkle integration" +optional_component(SPARKLE ON "Sparkle integration" DEPENDS "Mac OS X" APPLE DEPENDS "Sparkle" SPARKLE ) -optional_component(LIBPULSE OFF "Pulse audio integration" +optional_component(LIBPULSE ON "Pulse audio integration" DEPENDS "libpulse" LIBPULSE_FOUND ) -optional_component(VISUALISATIONS OFF "Visualisations") +optional_component(VISUALISATIONS ON "Visualisations") if(NOT HAVE_SPOTIFY_BLOB AND NOT QCA_QT5_FOUND) message(FATAL_ERROR "Either QCA-qt5 must be available or the non-GPL Spotify " @@ -282,6 +282,7 @@ endif() # Find DBus if it's enabled if (HAVE_DBUS) find_package(Qt5 COMPONENTS DBus) + get_target_property(QT_DBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp LOCATION) endif () if (HAVE_VK) @@ -291,7 +292,7 @@ if (HAVE_VK) endif(HAVE_VK) # We can include the Qt definitions now -set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Sql Qt5::Network Qt5::Xml Qt5::Widgets Qt5::Concurrent Qt5::X11Extras) +set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Sql Qt5::Network Qt5::Xml Qt5::Widgets Qt5::Concurrent Qt5::X11Extras Qt5::DBus) # Remove GLU and GL from the link line - they're not really required # and don't exist on my mingw toolchain diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b9cc0d438..9d193c850 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,7 +44,7 @@ find_package(OpenGL) include_directories(${OPENGL_INCLUDE_DIR}) if(HAVE_LIBLASTFM) - include_directories(${LASTFM_INCLUDE_DIRS}) + include_directories(${LASTFM5_INCLUDE_DIRS}) endif(HAVE_LIBLASTFM) if(HAVE_BREAKPAD) @@ -1223,9 +1223,6 @@ add_library(clementine_lib STATIC ${OTHER_UIC_SOURCES} ) -add_dependencies(clementine_lib pot) - - target_link_libraries(clementine_lib clementine-spotifyblob-messages libclementine-common @@ -1261,7 +1258,7 @@ if(ENABLE_VISUALISATIONS) endif(ENABLE_VISUALISATIONS) if(HAVE_LIBLASTFM) - target_link_libraries(clementine_lib ${LASTFM_LIBRARIES}) + target_link_libraries(clementine_lib ${LASTFM5_LIBRARIES}) endif(HAVE_LIBLASTFM) if(HAVE_LIBGPOD) diff --git a/src/dbus/org.freedesktop.Avahi.EntryGroup.xml b/src/dbus/org.freedesktop.Avahi.EntryGroup.xml index 2930d7eeb..ec7f13742 100644 --- a/src/dbus/org.freedesktop.Avahi.EntryGroup.xml +++ b/src/dbus/org.freedesktop.Avahi.EntryGroup.xml @@ -51,7 +51,7 @@ -
@@ -73,7 +73,7 @@ - diff --git a/src/dbus/org.freedesktop.Avahi.Server.xml b/src/dbus/org.freedesktop.Avahi.Server.xml index f336f207c..49493b3e0 100644 --- a/src/dbus/org.freedesktop.Avahi.Server.xml +++ b/src/dbus/org.freedesktop.Avahi.Server.xml @@ -132,7 +132,7 @@ - diff --git a/src/dbus/org.freedesktop.MediaPlayer.player.xml b/src/dbus/org.freedesktop.MediaPlayer.player.xml index fc81b98a7..1523ec00d 100644 --- a/src/dbus/org.freedesktop.MediaPlayer.player.xml +++ b/src/dbus/org.freedesktop.MediaPlayer.player.xml @@ -26,7 +26,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -56,12 +56,12 @@ - + - + diff --git a/src/dbus/org.freedesktop.MediaPlayer.root.xml b/src/dbus/org.freedesktop.MediaPlayer.root.xml index 593e99177..6b8976ed0 100644 --- a/src/dbus/org.freedesktop.MediaPlayer.root.xml +++ b/src/dbus/org.freedesktop.MediaPlayer.root.xml @@ -13,7 +13,7 @@ - +
diff --git a/src/dbus/org.freedesktop.MediaPlayer.tracklist.xml b/src/dbus/org.freedesktop.MediaPlayer.tracklist.xml index db8aabdae..d2db72f32 100644 --- a/src/dbus/org.freedesktop.MediaPlayer.tracklist.xml +++ b/src/dbus/org.freedesktop.MediaPlayer.tracklist.xml @@ -7,7 +7,7 @@ - + diff --git a/src/dbus/org.freedesktop.Notifications.xml b/src/dbus/org.freedesktop.Notifications.xml index 41f733009..00e85ea53 100644 --- a/src/dbus/org.freedesktop.Notifications.xml +++ b/src/dbus/org.freedesktop.Notifications.xml @@ -22,7 +22,7 @@ - + diff --git a/src/dbus/org.freedesktop.UDisks.Device.xml b/src/dbus/org.freedesktop.UDisks.Device.xml index 816dd6ffc..99d1c459f 100644 --- a/src/dbus/org.freedesktop.UDisks.Device.xml +++ b/src/dbus/org.freedesktop.UDisks.Device.xml @@ -636,7 +636,7 @@ - + An array of triples (pid, uid, command line for the process @@ -1355,9 +1355,9 @@ - - - + + + diff --git a/src/dbus/org.freedesktop.UDisks.xml b/src/dbus/org.freedesktop.UDisks.xml index 07daea04d..f046d64bf 100644 --- a/src/dbus/org.freedesktop.UDisks.xml +++ b/src/dbus/org.freedesktop.UDisks.xml @@ -1051,7 +1051,7 @@ - + An array of file systems known to the daemon and what features are supported. Each element in the array contains the following members: diff --git a/src/dbus/org.mpris.MediaPlayer2.Player.xml b/src/dbus/org.mpris.MediaPlayer2.Player.xml index 3c11567fa..711a74e47 100644 --- a/src/dbus/org.mpris.MediaPlayer2.Player.xml +++ b/src/dbus/org.mpris.MediaPlayer2.Player.xml @@ -27,7 +27,7 @@ - + diff --git a/src/dbus/org.mpris.MediaPlayer2.Playlists.xml b/src/dbus/org.mpris.MediaPlayer2.Playlists.xml index f94b31f2f..ef4c28a3c 100644 --- a/src/dbus/org.mpris.MediaPlayer2.Playlists.xml +++ b/src/dbus/org.mpris.MediaPlayer2.Playlists.xml @@ -6,7 +6,7 @@ - + @@ -17,12 +17,12 @@ - + - + - + diff --git a/src/dbus/org.mpris.MediaPlayer2.TrackList.xml b/src/dbus/org.mpris.MediaPlayer2.TrackList.xml index 5b609c7b3..a08888cb8 100644 --- a/src/dbus/org.mpris.MediaPlayer2.TrackList.xml +++ b/src/dbus/org.mpris.MediaPlayer2.TrackList.xml @@ -6,7 +6,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/src/devices/mtpconnection.cpp b/src/devices/mtpconnection.cpp index 009aad5eb..0c55d2778 100644 --- a/src/devices/mtpconnection.cpp +++ b/src/devices/mtpconnection.cpp @@ -20,6 +20,7 @@ #include #include +#include MtpConnection::MtpConnection(const QUrl& url) : device_(nullptr) { QString hostname = url.host(); @@ -34,19 +35,20 @@ MtpConnection::MtpConnection(const QUrl& url) : device_(nullptr) { const unsigned int bus_location = host_re.cap(1).toInt(); const unsigned int device_num = host_re.cap(2).toInt(); - if (url.hasQueryItem("vendor")) { + QUrlQuery url_query(url); + if (url_query.hasQueryItem("vendor")) { LIBMTP_raw_device_t* raw_device = (LIBMTP_raw_device_t*)malloc(sizeof(LIBMTP_raw_device_t)); raw_device->device_entry.vendor = - url.queryItemValue("vendor").toAscii().data(); + url_query.queryItemValue("vendor").toLatin1().data(); raw_device->device_entry.product = - url.queryItemValue("product").toAscii().data(); + url_query.queryItemValue("product").toLatin1().data(); raw_device->device_entry.vendor_id = - url.queryItemValue("vendor_id").toUShort(); + url_query.queryItemValue("vendor_id").toUShort(); raw_device->device_entry.product_id = - url.queryItemValue("product_id").toUShort(); + url_query.queryItemValue("product_id").toUShort(); raw_device->device_entry.device_flags = - url.queryItemValue("quirks").toUInt(); + url_query.queryItemValue("quirks").toUInt(); raw_device->bus_location = bus_location; raw_device->devnum = device_num; diff --git a/src/internet/box/boxservice.cpp b/src/internet/box/boxservice.cpp index 3a39caaad..46fdec844 100644 --- a/src/internet/box/boxservice.cpp +++ b/src/internet/box/boxservice.cpp @@ -18,7 +18,10 @@ #include "boxservice.h" -#include +#include +#include +#include +#include #include "core/application.h" #include "core/player.h" @@ -122,10 +125,9 @@ void BoxService::AddAuthorizationHeader(QNetworkRequest* request) const { void BoxService::FetchUserInfoFinished(QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); + QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object(); - QString name = response["name"].toString(); + QString name = json_response["name"].toString(); if (!name.isEmpty()) { QSettings s; s.beginGroup(kSettingsGroup); @@ -160,7 +162,9 @@ void BoxService::UpdateFiles() { void BoxService::InitialiseEventsCursor() { QUrl url(kEvents); - url.addQueryItem("stream_position", "now"); + QUrlQuery url_query; + url_query.addQueryItem("stream_position", "now"); + url.setQuery(url_query); QNetworkRequest request(url); AddAuthorizationHeader(&request); QNetworkReply* reply = network_->get(request); @@ -170,12 +174,11 @@ void BoxService::InitialiseEventsCursor() { void BoxService::InitialiseEventsFinished(QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); - if (response.contains("next_stream_position")) { + QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object(); + if (json_response.contains("next_stream_position")) { QSettings s; s.beginGroup(kSettingsGroup); - s.setValue("cursor", response["next_stream_position"]); + s.setValue("cursor", json_response["next_stream_position"].toString()); } } @@ -189,9 +192,11 @@ void BoxService::FetchRecursiveFolderItems(const int folder_id, << "modified_at" << "name"; QString fields_list = fields.join(","); - url.addQueryItem("fields", fields_list); - url.addQueryItem("limit", "1000"); // Maximum according to API docs. - url.addQueryItem("offset", QString::number(offset)); + QUrlQuery url_query (url); + url_query.addQueryItem("fields", fields_list); + url_query.addQueryItem("limit", "1000"); // Maximum according to API docs. + url_query.addQueryItem("offset", QString::number(offset)); + url.setQuery(url_query); QNetworkRequest request(url); AddAuthorizationHeader(&request); QNetworkReply* reply = network_->get(request); @@ -204,21 +209,18 @@ void BoxService::FetchFolderItemsFinished(QNetworkReply* reply, const int folder_id) { reply->deleteLater(); - QByteArray data = reply->readAll(); + QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object(); - QJson::Parser parser; - QVariantMap response = parser.parse(data).toMap(); - - QVariantList entries = response["entries"].toList(); - const int total_entries = response["total_count"].toInt(); - const int offset = response["offset"].toInt(); + QJsonArray entries = json_response["entries"].toArray(); + const int total_entries = json_response["total_count"].toInt(); + const int offset = json_response["offset"].toInt(); if (entries.size() + offset < total_entries) { // Fetch the next page if necessary. FetchRecursiveFolderItems(folder_id, offset + entries.size()); } - for (const QVariant& e : entries) { - QVariantMap entry = e.toMap(); + for (const QJsonValue& e : entries) { + QJsonObject entry = e.toObject(); if (entry["type"].toString() == "folder") { FetchRecursiveFolderItems(entry["id"].toInt()); } else { @@ -227,16 +229,16 @@ void BoxService::FetchFolderItemsFinished(QNetworkReply* reply, } } -void BoxService::MaybeAddFileEntry(const QVariantMap& entry) { +void BoxService::MaybeAddFileEntry(const QJsonObject &entry) { QString mime_type = GuessMimeTypeForFile(entry["name"].toString()); QUrl url; url.setScheme("box"); - url.setPath(entry["id"].toString()); + url.setPath("/" + entry["id"].toString()); Song song; song.set_url(url); - song.set_ctime(entry["created_at"].toDateTime().toTime_t()); - song.set_mtime(entry["modified_at"].toDateTime().toTime_t()); + song.set_ctime(QDateTime::fromString(entry["created_at"].toString()).toTime_t()); + song.set_mtime(QDateTime::fromString(entry["modified_at"].toString()).toTime_t()); song.set_filesize(entry["size"].toInt()); song.set_title(entry["name"].toString()); @@ -271,8 +273,10 @@ void BoxService::RedirectFollowed(QNetworkReply* reply, const Song& song, void BoxService::UpdateFilesFromCursor(const QString& cursor) { QUrl url(kEvents); - url.addQueryItem("stream_position", cursor); - url.addQueryItem("limit", "5000"); + QUrlQuery url_query; + url_query.addQueryItem("stream_position", cursor); + url_query.addQueryItem("limit", "5000"); + url.setQuery(url_query); QNetworkRequest request(url); AddAuthorizationHeader(&request); QNetworkReply* reply = network_->get(request); @@ -283,18 +287,17 @@ void BoxService::UpdateFilesFromCursor(const QString& cursor) { void BoxService::FetchEventsFinished(QNetworkReply* reply) { // TODO(John Maguire): Page through events. reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); + QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object(); QSettings s; s.beginGroup(kSettingsGroup); - s.setValue("cursor", response["next_stream_position"]); + s.setValue("cursor", json_response["next_stream_position"].toString()); - QVariantList entries = response["entries"].toList(); - for (const QVariant& e : entries) { - QVariantMap event = e.toMap(); + QJsonArray entries = json_response["entries"].toArray(); + for (const QJsonValue& e : entries) { + QJsonObject event = e.toObject(); QString type = event["event_type"].toString(); - QVariantMap source = event["source"].toMap(); + QJsonObject source = event["source"].toObject(); if (source["type"] == "file") { if (type == "ITEM_UPLOAD") { // Add file. @@ -303,7 +306,7 @@ void BoxService::FetchEventsFinished(QNetworkReply* reply) { // Delete file. QUrl url; url.setScheme("box"); - url.setPath(source["id"].toString()); + url.setPath("/" + source["id"].toString()); Song song = library_backend_->GetSongByUrl(url); if (song.is_valid()) { library_backend_->DeleteSongs(SongList() << song); diff --git a/src/internet/box/boxservice.h b/src/internet/box/boxservice.h index 9748f680e..a7fd990aa 100644 --- a/src/internet/box/boxservice.h +++ b/src/internet/box/boxservice.h @@ -64,7 +64,7 @@ class BoxService : public CloudFileService { void UpdateFilesFromCursor(const QString& cursor); QNetworkReply* FetchContentUrlForFile(const QString& file_id); void InitialiseEventsCursor(); - void MaybeAddFileEntry(const QVariantMap& entry); + void MaybeAddFileEntry(const QJsonObject& entry); void EnsureConnected(); QString access_token_; diff --git a/src/internet/dropbox/dropboxauthenticator.cpp b/src/internet/dropbox/dropboxauthenticator.cpp index 22284ff32..3bc67db77 100644 --- a/src/internet/dropbox/dropboxauthenticator.cpp +++ b/src/internet/dropbox/dropboxauthenticator.cpp @@ -20,11 +20,12 @@ #include -#include - #include #include #include +#include +#include +#include #include "core/closure.h" #include "core/logging.h" @@ -98,8 +99,10 @@ void DropboxAuthenticator::Authorise() { SLOT(RedirectArrived(LocalRedirectServer*)), server); QUrl url(kAuthoriseEndpoint); - url.addQueryItem("oauth_token", token_); - url.addQueryItem("oauth_callback", server->url().toString()); + QUrlQuery url_query; + url_query.addQueryItem("oauth_token", token_); + url_query.addQueryItem("oauth_callback", server->url().toString()); + url.setQuery(url_query); QDesktopServices::openUrl(url); } @@ -108,7 +111,7 @@ void DropboxAuthenticator::RedirectArrived(LocalRedirectServer* server) { server->deleteLater(); QUrl request_url = server->request_url(); qLog(Debug) << Q_FUNC_INFO << request_url; - uid_ = request_url.queryItemValue("uid"); + uid_ = QUrlQuery(request_url).queryItemValue("uid"); RequestAccessToken(); } @@ -126,7 +129,7 @@ void DropboxAuthenticator::RequestAccessToken() { void DropboxAuthenticator::RequestAccessTokenFinished(QNetworkReply* reply) { reply->deleteLater(); - QString result = QString::fromAscii(reply->readAll()); + QString result = QString::fromLatin1(reply->readAll()); qLog(Debug) << result; QMap params = ParseParamList(result); access_token_ = params["oauth_token"]; @@ -174,8 +177,7 @@ void DropboxAuthenticator::RequestAccountInformation() { void DropboxAuthenticator::RequestAccountInformationFinished( QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); - name_ = response["display_name"].toString(); + QJsonDocument document = QJsonDocument::fromBinaryData(reply->readAll()); + name_ = document.object()["display_name"].toString(); emit Finished(); } diff --git a/src/internet/dropbox/dropboxservice.cpp b/src/internet/dropbox/dropboxservice.cpp index 666dbc6e7..8bbd4f611 100644 --- a/src/internet/dropbox/dropboxservice.cpp +++ b/src/internet/dropbox/dropboxservice.cpp @@ -21,8 +21,10 @@ #include #include - -#include +#include +#include +#include +#include #include "core/application.h" #include "core/logging.h" @@ -103,9 +105,11 @@ void DropboxService::RequestFileList() { s.beginGroup(kSettingsGroup); QUrl url = QUrl(QString(kDeltaEndpoint)); + QUrlQuery url_query; if (s.contains("cursor")) { - url.addQueryItem("cursor", s.value("cursor").toString()); + url_query.addQueryItem("cursor", s.value("cursor").toString()); } + url.setQuery(url_query); QNetworkRequest request(url); request.setRawHeader("Authorization", GenerateAuthorisationHeader()); @@ -117,21 +121,22 @@ void DropboxService::RequestFileList() { void DropboxService::RequestFileListFinished(QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); - if (response.contains("reset") && response["reset"].toBool()) { + QJsonDocument document = QJsonDocument::fromBinaryData(reply->readAll()); + QJsonObject json_response = document.object(); + + if (json_response.contains("reset") && json_response["reset"].toBool()) { qLog(Debug) << "Resetting Dropbox DB"; library_backend_->DeleteAll(); } QSettings settings; settings.beginGroup(kSettingsGroup); - settings.setValue("cursor", response["cursor"].toString()); + settings.setValue("cursor", json_response["cursor"].toString()); - QVariantList contents = response["entries"].toList(); + QJsonArray contents = json_response["entries"].toArray(); qLog(Debug) << "Delta found:" << contents.size(); - for (const QVariant& c : contents) { - QVariantList item = c.toList(); + for (const QJsonValue& c : contents) { + QJsonArray item = c.toArray(); QString path = item[0].toString(); QUrl url; @@ -148,7 +153,7 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) { continue; } - QVariantMap metadata = item[1].toMap(); + QJsonObject metadata = item[1].toObject(); if (metadata["is_dir"].toBool()) { continue; } @@ -168,7 +173,7 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) { } } - if (response.contains("has_more") && response["has_more"].toBool()) { + if (json_response.contains("has_more") && json_response["has_more"].toBool()) { RequestFileList(); } else { // Long-poll wait for changes. @@ -181,9 +186,11 @@ void DropboxService::LongPollDelta() { s.beginGroup(kSettingsGroup); QUrl request_url = QUrl(QString(kLongPollEndpoint)); + QUrlQuery url_query; if (s.contains("cursor")) { - request_url.addQueryItem("cursor", s.value("cursor").toString()); + url_query.addQueryItem("cursor", s.value("cursor").toString()); } + request_url.setQuery(url_query); QNetworkRequest request(request_url); request.setRawHeader("Authorization", GenerateAuthorisationHeader()); QNetworkReply* reply = network_->get(request); @@ -193,15 +200,14 @@ void DropboxService::LongPollDelta() { void DropboxService::LongPollFinished(QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); - if (response["changes"].toBool()) { + QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object(); + if (json_response["changes"].toBool()) { // New changes, we should request deltas again. qLog(Debug) << "Detected new dropbox changes; fetching..."; RequestFileList(); } else { bool ok = false; - int backoff_secs = response["backoff"].toInt(&ok); + int backoff_secs = json_response["backoff"].toString().toInt(&ok); backoff_secs = ok ? backoff_secs : 0; QTimer::singleShot(backoff_secs * 1000, this, SLOT(LongPollDelta())); @@ -219,8 +225,7 @@ QNetworkReply* DropboxService::FetchContentUrl(const QUrl& url) { void DropboxService::FetchContentUrlFinished(QNetworkReply* reply, const QVariantMap& data) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); + QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object(); QFileInfo info(data["path"].toString()); QUrl url; @@ -236,7 +241,7 @@ void DropboxService::FetchContentUrlFinished(QNetworkReply* reply, song.set_ctime(0); MaybeAddFileToDatabase(song, data["mime_type"].toString(), - QUrl::fromEncoded(response["url"].toByteArray()), + QUrl::fromEncoded(json_response["url"].toString().toLatin1()), QString::null); } @@ -244,7 +249,6 @@ QUrl DropboxService::GetStreamingUrlFromSongId(const QUrl& url) { QNetworkReply* reply = FetchContentUrl(url); WaitForSignal(reply, SIGNAL(finished())); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); - return QUrl::fromEncoded(response["url"].toByteArray()); + QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object(); + return QUrl::fromEncoded(json_response["url"].toString().toLatin1()); } diff --git a/src/internet/googledrive/googledriveclient.cpp b/src/internet/googledrive/googledriveclient.cpp index e93cae44f..66e9a3eba 100644 --- a/src/internet/googledrive/googledriveclient.cpp +++ b/src/internet/googledrive/googledriveclient.cpp @@ -19,7 +19,12 @@ #include "googledriveclient.h" -#include +#include +#include +#include +#include +#include +#include #include "internet/core/oauthenticator.h" #include "core/closure.h" @@ -114,16 +119,15 @@ void Client::FetchUserInfoFinished(ConnectResponse* response, if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 200) { qLog(Warning) << "Failed to get user info" << reply->readAll(); } else { - QJson::Parser parser; - bool ok = false; - QVariantMap result = parser.parse(reply, &ok).toMap(); - if (!ok) { + QJsonParseError error; + QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &error); + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Failed to parse user info reply"; return; } - qLog(Debug) << result; - response->user_email_ = result["email"].toString(); + qLog(Debug) << document; + response->user_email_ = document.object()["email"].toString(); qLog(Debug) << response->user_email_; } emit response->Finished(); @@ -157,16 +161,15 @@ GetFileResponse* Client::GetFile(const QString& file_id) { void Client::GetFileFinished(GetFileResponse* response, QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - bool ok = false; - QVariantMap result = parser.parse(reply, &ok).toMap(); - if (!ok) { + QJsonParseError error; + QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &error); + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Failed to fetch file with ID" << response->file_id_; emit response->Finished(); return; } - response->file_ = File(result); + response->file_ = File(document.object().toVariantMap()); emit response->Finished(); } @@ -179,13 +182,16 @@ ListChangesResponse* Client::ListChanges(const QString& cursor) { void Client::MakeListChangesRequest(ListChangesResponse* response, const QString& page_token) { QUrl url(kGoogleDriveChanges); + QUrlQuery url_query; if (!response->cursor().isEmpty()) { - url.addQueryItem("startChangeId", response->cursor()); + url_query.addQueryItem("startChangeId", response->cursor()); } if (!page_token.isEmpty()) { - url.addQueryItem("pageToken", page_token); + url_query.addQueryItem("pageToken", page_token); } + url.setQuery(url_query); + qLog(Debug) << "Requesting changes at:" << response->cursor() << page_token; QNetworkRequest request(url); @@ -201,33 +207,33 @@ void Client::ListChangesFinished(ListChangesResponse* response, QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - bool ok = false; + QJsonParseError error; + QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &error); // TODO(John Maguire): Put this on a separate thread as the response could be large. - QVariantMap result = parser.parse(reply, &ok).toMap(); - if (!ok) { + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Failed to fetch changes" << response->cursor(); emit response->Finished(); return; } - if (result.contains("largestChangeId")) { - response->next_cursor_ = result["largestChangeId"].toString(); + QJsonObject json_result = document.object(); + if (json_result.contains("largestChangeId")) { + response->next_cursor_ = json_result["largestChangeId"].toString(); } // Emit the FilesFound signal for the files in the response. FileList files; QList files_deleted; - for (const QVariant& v : result["items"].toList()) { - QVariantMap change = v.toMap(); + for (const QJsonValue & v : json_result["items"].toArray()) { + QJsonObject change = v.toObject(); if (change["deleted"].toBool() || - change["file"].toMap()["labels"].toMap()["trashed"].toBool()) { + change["file"].toObject()["labels"].toObject()["trashed"].toBool()) { QUrl url; url.setScheme("googledrive"); - url.setPath(change["fileId"].toString()); + url.setPath("/" + change["fileId"].toString()); files_deleted << url; } else { - files << File(change["file"].toMap()); + files << File(change["file"].toObject().toVariantMap()); } } @@ -235,8 +241,8 @@ void Client::ListChangesFinished(ListChangesResponse* response, emit response->FilesDeleted(files_deleted); // Get the next page of results if there is one. - if (result.contains("nextPageToken")) { - MakeListChangesRequest(response, result["nextPageToken"].toString()); + if (json_result.contains("nextPageToken")) { + MakeListChangesRequest(response, json_result["nextPageToken"].toString()); } else { emit response->Finished(); } diff --git a/src/internet/googledrive/googledriveservice.cpp b/src/internet/googledrive/googledriveservice.cpp index d7b106677..cc1797b25 100644 --- a/src/internet/googledrive/googledriveservice.cpp +++ b/src/internet/googledrive/googledriveservice.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "core/application.h" #include "core/closure.h" @@ -163,7 +164,7 @@ void GoogleDriveService::FilesFound(const QList& files) { QUrl url; url.setScheme("googledrive"); - url.setPath(file.id()); + url.setPath("/" + file.id()); Song song; // Add some extra tags from the Google Drive metadata. @@ -204,7 +205,9 @@ QUrl GoogleDriveService::GetStreamingUrlFromSongId(const QString& id) { loop.exec(); QUrl url(response->file().download_url()); - url.addQueryItem("access_token", client_->access_token()); + QUrlQuery url_query(url); + url_query.addQueryItem("access_token", client_->access_token()); + url.setQuery(url_query); return url; } diff --git a/src/internet/lastfm/lastfmcompat.h b/src/internet/lastfm/lastfmcompat.h index 7ca9acf5d..c0681869f 100644 --- a/src/internet/lastfm/lastfmcompat.h +++ b/src/internet/lastfm/lastfmcompat.h @@ -24,21 +24,21 @@ #include "fixlastfm.h" #ifdef HAVE_LIBLASTFM1 -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif namespace lastfm { diff --git a/src/internet/lastfm/lastfmservice.cpp b/src/internet/lastfm/lastfmservice.cpp index 243e5858d..11d20c905 100644 --- a/src/internet/lastfm/lastfmservice.cpp +++ b/src/internet/lastfm/lastfmservice.cpp @@ -213,7 +213,7 @@ void LastFMService::UpdateSubscriberStatusFinished(QNetworkReply* reply) { QUrl LastFMService::FixupUrl(const QUrl& url) { QUrl ret; - ret.setEncodedUrl(url.toEncoded().replace( + ret.setUrl(url.toEncoded().replace( "USERNAME", QUrl::toPercentEncoding(lastfm::ws::Username))); return ret; } diff --git a/src/internet/seafile/seafileservice.cpp b/src/internet/seafile/seafileservice.cpp index 27a5b4bed..4ce2b802e 100644 --- a/src/internet/seafile/seafileservice.cpp +++ b/src/internet/seafile/seafileservice.cpp @@ -22,8 +22,11 @@ #include -#include #include +#include +#include +#include +#include #include "core/application.h" #include "core/player.h" @@ -80,7 +83,7 @@ bool SeafileService::has_credentials() const { void SeafileService::AddAuthorizationHeader(QNetworkRequest* request) const { request->setRawHeader("Authorization", - QString("Token %1").arg(access_token_).toAscii()); + QString("Token %1").arg(access_token_).toLatin1()); } void SeafileService::ForgetCredentials() { @@ -98,13 +101,15 @@ void SeafileService::ForgetCredentials() { bool SeafileService::GetToken(const QString& mail, const QString& password, const QString& server) { QUrl url(server + kAuthTokenUrl); + QUrlQuery url_query; + + url_query.addQueryItem("username", mail); + url_query.addQueryItem("password", password); + QNetworkRequest request(url); AddAuthorizationHeader(&request); - url.addQueryItem("username", mail); - url.addQueryItem("password", password); - - QNetworkReply* reply = network_->post(request, url.encodedQuery()); + QNetworkReply* reply = network_->post(request, url_query.toString().toLatin1()); WaitForSignal(reply, SIGNAL(finished())); if (!CheckReply(&reply)) { @@ -114,11 +119,10 @@ bool SeafileService::GetToken(const QString& mail, const QString& password, reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply->readAll()).toMap(); + QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object(); // Because the server responds "token" - access_token_ = response["token"].toString().replace("\"", ""); + access_token_ = json_response["token"].toString().replace("\"", ""); if (access_token_.isEmpty()) { return false; @@ -156,11 +160,11 @@ void SeafileService::GetLibrariesFinished(QNetworkReply* reply) { // key : id, value : name QMap libraries; QByteArray data = reply->readAll(); - QJson::Parser parser; - QList repos = parser.parse(data).toList(); - for (int i = 0; i < repos.size(); ++i) { - QVariantMap repo = repos.at(i).toMap(); + QJsonArray json_repos = QJsonDocument::fromJson(data).array(); + + for (const QJsonValue & json_repo: json_repos) { + QJsonObject repo = json_repo.toObject(); QString repo_name = repo["name"].toString(), repo_id = repo["id"].toString(); @@ -246,7 +250,9 @@ void SeafileService::UpdateLibrariesInProgress( QNetworkReply* SeafileService::PrepareFetchFolderItems(const QString& library, const QString& path) { QUrl url(server_ + QString(kFolderItemsUrl).arg(library)); - url.addQueryItem("p", path); + QUrlQuery url_query; + url_query.addQueryItem("p", path); + url.setQuery(url_query); QNetworkRequest request(url); AddAuthorizationHeader(&request); @@ -277,12 +283,11 @@ void SeafileService::FetchAndCheckFolderItemsFinished( QByteArray data = reply->readAll(); - QJson::Parser parser; - QList variant_entries = parser.parse(data).toList(); + QJsonArray json_entries = QJsonDocument::fromJson(data).array(); SeafileTree::Entries entries; - for (const QVariant& e : variant_entries) { - QVariantMap entry = e.toMap(); + for (const QJsonValue& e : json_entries) { + QJsonObject entry = e.toObject(); SeafileTree::Entry::Type entry_type = SeafileTree::Entry::StringToType(entry["type"].toString()); QString entry_name = entry["name"].toString(); @@ -322,14 +327,13 @@ void SeafileService::AddRecursivelyFolderItemsFinished(QNetworkReply* reply, reply->deleteLater(); QByteArray data = reply->readAll(); - QJson::Parser parser; - QList entries = parser.parse(data).toList(); + QJsonArray json_entries = QJsonDocument::fromJson(data).array(); - for (const QVariant& e : entries) { - QVariantMap entry_map = e.toMap(); + for (const QJsonValue& e : json_entries) { + QJsonObject json_entry = e.toObject(); SeafileTree::Entry::Type entry_type = - SeafileTree::Entry::StringToType(entry_map["type"].toString()); - QString entry_name = entry_map["name"].toString(); + SeafileTree::Entry::StringToType(json_entry["type"].toString()); + QString entry_name = json_entry["name"].toString(); // We just want libraries/directories and files which could be songs. if (entry_type == SeafileTree::Entry::NONE) { @@ -339,7 +343,7 @@ void SeafileService::AddRecursivelyFolderItemsFinished(QNetworkReply* reply, continue; } - SeafileTree::Entry entry(entry_name, entry_map["id"].toString(), + SeafileTree::Entry entry(entry_name, json_entry["id"].toString(), entry_type); // If AddEntry was not successful we stop @@ -360,7 +364,9 @@ void SeafileService::AddRecursivelyFolderItemsFinished(QNetworkReply* reply, QNetworkReply* SeafileService::PrepareFetchContentForFile( const QString& library, const QString& filepath) { QUrl content_url(server_ + QString(kFileContentUrl).arg(library)); - content_url.addQueryItem("p", filepath); + QUrlQuery content_url_query; + content_url_query.addQueryItem("p", filepath); + content_url.setQuery(content_url_query); QNetworkRequest request(content_url); AddAuthorizationHeader(&request); @@ -397,23 +403,22 @@ void SeafileService::MaybeAddFileEntryInProgress(QNetworkReply* reply, QByteArray data = reply->readAll(); - QJson::Parser parser; - QVariantMap entry_detail_map = parser.parse(data).toMap(); + QJsonObject json_entry_detail = QJsonDocument::fromJson(data).object(); QUrl url; url.setScheme("seafile"); - url.setPath("/" + library + path + entry_detail_map["name"].toString()); + url.setPath("/" + library + path + json_entry_detail["name"].toString()); Song song; song.set_url(url); song.set_ctime(0); - song.set_mtime(entry_detail_map["mtime"].toInt()); - song.set_filesize(entry_detail_map["size"].toInt()); - song.set_title(entry_detail_map["name"].toString()); + song.set_mtime(json_entry_detail["mtime"].toInt()); + song.set_filesize(json_entry_detail["size"].toInt()); + song.set_title(json_entry_detail["name"].toString()); // Get the download url of the entry reply = PrepareFetchContentUrlForFile( - library, path + entry_detail_map["name"].toString()); + library, path + json_entry_detail["name"].toString()); NewClosure( reply, SIGNAL(finished()), this, SLOT(FetchContentUrlForFileFinished(QNetworkReply*, Song, QString)), @@ -423,7 +428,9 @@ void SeafileService::MaybeAddFileEntryInProgress(QNetworkReply* reply, QNetworkReply* SeafileService::PrepareFetchContentUrlForFile( const QString& library, const QString& filepath) { QUrl content_url(server_ + QString(kFileUrl).arg(library)); - content_url.addQueryItem("p", filepath); + QUrlQuery content_url_query; + content_url_query.addQueryItem("p", filepath); + content_url.setQuery(content_url_query); QNetworkRequest request(content_url); AddAuthorizationHeader(&request); @@ -589,7 +596,7 @@ bool SeafileService::CheckReply(QNetworkReply** reply, int tries) { // Unknown, 404 ... (*reply)->deleteLater(); - qLog(Warning) << "Error for reply : " << status_code_variant.toInt(); + qLog(Warning) << "Error with the reply : " << status_code_variant.toInt(); return false; } diff --git a/src/internet/skydrive/skydriveservice.cpp b/src/internet/skydrive/skydriveservice.cpp index 91bfce90c..c8f001429 100644 --- a/src/internet/skydrive/skydriveservice.cpp +++ b/src/internet/skydrive/skydriveservice.cpp @@ -19,9 +19,12 @@ #include "skydriveservice.h" -#include +#include +#include +#include +#include -#include +#include #include "core/application.h" #include "core/player.h" @@ -107,10 +110,9 @@ void SkydriveService::AddAuthorizationHeader(QNetworkRequest* request) { void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); + QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object(); - QString name = response["name"].toString(); + QString name = json_response["name"].toString(); if (!name.isEmpty()) { QSettings s; s.beginGroup(kSettingsGroup); @@ -124,7 +126,9 @@ void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) { void SkydriveService::ListFiles(const QString& folder) { QUrl url(QString(kSkydriveBase) + folder + "/files"); - url.addQueryItem("filter", "audio,folders"); + QUrlQuery url_query; + url_query.addQueryItem("filter", "audio,folders"); + url.setQuery(url_query); QNetworkRequest request(url); AddAuthorizationHeader(&request); @@ -135,27 +139,26 @@ void SkydriveService::ListFiles(const QString& folder) { void SkydriveService::ListFilesFinished(QNetworkReply* reply) { reply->deleteLater(); - QJson::Parser parser; - QVariantMap response = parser.parse(reply).toMap(); + QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object(); - QVariantList files = response["data"].toList(); - for (const QVariant& f : files) { - QVariantMap file = f.toMap(); + QJsonArray files = json_response["data"].toArray(); + for (const QJsonValue& f : files) { + QJsonObject file = f.toObject(); if (file["type"].toString() == "audio") { QString mime_type = GuessMimeTypeForFile(file["name"].toString()); QUrl url; url.setScheme("skydrive"); - url.setPath(file["id"].toString()); + url.setPath("/" + file["id"].toString()); Song song; song.set_url(url); - song.set_ctime(file["created_time"].toDateTime().toTime_t()); - song.set_mtime(file["updated_time"].toDateTime().toTime_t()); + song.set_ctime(QDateTime::fromString(file["created_time"].toString()).toTime_t()); + song.set_mtime(QDateTime::fromString(file["updated_time"].toString()).toTime_t()); song.set_comment(file["description"].toString()); song.set_filesize(file["size"].toInt()); song.set_title(file["name"].toString()); - QUrl download_url = file["source"].toUrl(); + QUrl download_url(file["source"].toString()); // HTTPS appears to be broken somehow between Qt & Skydrive downloads. // Fortunately, just changing the scheme to HTTP works. download_url.setScheme("http"); @@ -175,9 +178,8 @@ QUrl SkydriveService::GetStreamingUrlFromSongId(const QString& file_id) { std::unique_ptr reply(network_->get(request)); WaitForSignal(reply.get(), SIGNAL(finished())); - QJson::Parser parser; - QVariantMap response = parser.parse(reply.get()).toMap(); - return response["source"].toUrl(); + QJsonObject json_response = QJsonDocument::fromBinaryData(reply.get()->readAll()).object(); + return QUrl(json_response["source"].toString()); } void SkydriveService::EnsureConnected() { diff --git a/src/internet/vk/vkconnection.cpp b/src/internet/vk/vkconnection.cpp index d44a65e65..3fd8353ea 100644 --- a/src/internet/vk/vkconnection.cpp +++ b/src/internet/vk/vkconnection.cpp @@ -21,8 +21,10 @@ #include #include - -#include +#include +#include +#include +#include #include "core/closure.h" #include "core/logging.h" @@ -95,18 +97,22 @@ bool VkConnection::hasAccount() { QNetworkRequest VkConnection::makeRequest(const QString& method, const QVariantMap& args) { QUrl url = kApiUrl; - url.setPath(url.path() % QLatin1Literal("/") % method); + url.setPath(url.path() + "/" + method); + QUrlQuery url_query; for (auto it = args.constBegin(); it != args.constEnd(); ++it) { - url.addEncodedQueryItem(QUrl::toPercentEncoding(it.key()), + url_query.addQueryItem(QUrl::toPercentEncoding(it.key()), QUrl::toPercentEncoding(it.value().toString())); } - url.addEncodedQueryItem("access_token", access_token_); + url_query.addQueryItem("access_token", access_token_); + url.setQuery(url_query); return QNetworkRequest(url); } void VkConnection::decorateRequest(QNetworkRequest& request) { QUrl url = request.url(); - url.addEncodedQueryItem("access_token", access_token_); + QUrlQuery url_query(url); + url_query.addQueryItem("access_token", access_token_); + url.setQuery(url_query); request.setUrl(url); } @@ -115,11 +121,13 @@ void VkConnection::requestAccessToken() { server->Listen(); QUrl url = kVkOAuthEndpoint; - url.addQueryItem("client_id", kAppID); - url.addQueryItem("scope", + QUrlQuery url_query; + url_query.addQueryItem("client_id", kAppID); + url_query.addQueryItem("scope", Vreen::flagsToStrList(kScopes, kScopeNames).join(",")); - url.addQueryItem("redirect_uri", server->url().toString()); - url.addQueryItem("response_type", "code"); + url_query.addQueryItem("redirect_uri", server->url().toString()); + url_query.addQueryItem("response_type", "code"); + url.setQuery(url_query); qLog(Debug) << "Try to login to Vk.com" << url; @@ -130,13 +138,16 @@ void VkConnection::requestAccessToken() { } void VkConnection::codeRecived(LocalRedirectServer* server, QUrl redirect_uri) { - if (server->request_url().hasQueryItem("code")) { - code_ = server->request_url().queryItemValue("code").toUtf8(); + QUrlQuery url_query_server(server->request_url()); + if (url_query_server.hasQueryItem("code")) { + code_ = url_query_server.queryItemValue("code").toUtf8(); QUrl url = kVkOAuthTokenEndpoint; - url.addQueryItem("client_id", kAppID); - url.addQueryItem("client_secret", kAppSecret); - url.addQueryItem("code", QString::fromUtf8(code_)); - url.addQueryItem("redirect_uri", redirect_uri.toString()); + QUrlQuery url_query; + url_query.addQueryItem("client_id", kAppID); + url_query.addQueryItem("client_secret", kAppSecret); + url_query.addQueryItem("code", QString::fromUtf8(code_)); + url_query.addQueryItem("redirect_uri", redirect_uri.toString()); + url.setQuery(url_query); qLog(Debug) << "Getting access token" << url; QNetworkRequest request(url); @@ -159,21 +170,22 @@ void VkConnection::accessTokenRecived(QNetworkReply* reply) { return; } - QJson::Parser parser; - bool ok = false; QByteArray reply_data = reply->readAll(); - QVariantMap result = parser.parse(reply_data, &ok).toMap(); - if (!ok) { + QJsonParseError error; + QJsonDocument document = QJsonDocument::fromJson(reply_data, &error); + if (error.error != QJsonParseError::NoError) { qLog(Error) << "Failed to parse oauth reply" << reply_data; emit setConnectionState(Vreen::Client::StateOffline); clear(); return; } - qLog(Debug) << result; - access_token_ = result["access_token"].toByteArray(); - expires_in_ = result["expires_in"].toUInt(); - uid_ = result["user_id"].toInt(); + QJsonObject json_result = document.object(); + qLog(Debug) << json_result; + + access_token_ = json_result["access_token"].toString().toLatin1(); + expires_in_ = json_result["expires_in"].toString().toUInt(); + uid_ = json_result["user_id"].toInt(); if (expires_in_) { expires_in_ += QDateTime::currentDateTime().toTime_t(); diff --git a/src/internet/vk/vkmusiccache.cpp b/src/internet/vk/vkmusiccache.cpp index 62033948c..c802818e3 100644 --- a/src/internet/vk/vkmusiccache.cpp +++ b/src/internet/vk/vkmusiccache.cpp @@ -130,7 +130,7 @@ void VkMusicCache::DownloadNext() { void VkMusicCache::DownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { if (bytesTotal) { - int progress = qRound(100 * bytesReceived / bytesTotal); + int progress = qRound(100. * bytesReceived / bytesTotal); app_->task_manager()->SetTaskProgress(task_id, progress, 100); } } diff --git a/src/moodbar/moodbarpipeline.cpp b/src/moodbar/moodbarpipeline.cpp index 7163efda1..d5409211d 100644 --- a/src/moodbar/moodbarpipeline.cpp +++ b/src/moodbar/moodbarpipeline.cpp @@ -57,7 +57,7 @@ bool MoodbarPipeline::IsAvailable() { GstElement* MoodbarPipeline::CreateElement(const QString& factory_name) { GstElement* ret = - gst_element_factory_make(factory_name.toAscii().constData(), nullptr); + gst_element_factory_make(factory_name.toLatin1().constData(), nullptr); if (ret) { gst_bin_add(GST_BIN(pipeline_), ret); diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index bf8a329a8..cbcd62670 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -75,11 +75,11 @@ RipCD::RipCD(QWidget* parent) ui_->setupUi(this); // Set column widths in the QTableWidget. - ui_->tableWidget->horizontalHeader()->setResizeMode( + ui_->tableWidget->horizontalHeader()->setSectionResizeMode( kCheckboxColumn, QHeaderView::ResizeToContents); - ui_->tableWidget->horizontalHeader()->setResizeMode( + ui_->tableWidget->horizontalHeader()->setSectionResizeMode( kTrackNumberColumn, QHeaderView::ResizeToContents); - ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn, + ui_->tableWidget->horizontalHeader()->setSectionResizeMode(kTrackTitleColumn, QHeaderView::Stretch); // Add a rip button diff --git a/src/widgets/osd_x11.cpp b/src/widgets/osd_x11.cpp index a79bc841c..d5e10436b 100644 --- a/src/widgets/osd_x11.cpp +++ b/src/widgets/osd_x11.cpp @@ -66,7 +66,7 @@ QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image) { int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3); arg << i.depth() / channels; arg << channels; - arg << QByteArray(reinterpret_cast(i.bits()), i.numBytes()); + arg << QByteArray(reinterpret_cast(i.bits()), i.byteCount()); arg.endStructure(); return arg; } diff --git a/src/wiimotedev/wiimotesettingspage.cpp b/src/wiimotedev/wiimotesettingspage.cpp index 3c9adfcf3..77f780aab 100644 --- a/src/wiimotedev/wiimotesettingspage.cpp +++ b/src/wiimotedev/wiimotesettingspage.cpp @@ -26,7 +26,7 @@ WiimoteSettingsPage::WiimoteSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui_WiimoteSettingsPage) { ui_->setupUi(this); - ui_->list->header()->setResizeMode(QHeaderView::ResizeToContents); + ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); setWindowIcon(QIcon(":/icons/32x32/wiimotedev.png")); text_buttons_.insert(WIIMOTE_BTN_1, "Wiiremote 1"); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7c46c02d2..95c954d00 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -74,14 +74,14 @@ qt5_wrap_cpp(TESTUTILS-SOURCES-MOC ${TESTUTILS-MOC-HEADERS}) add_library(test_utils STATIC EXCLUDE_FROM_ALL ${TESTUTILS-SOURCES} ${TESTUTILS-SOURCES-MOC}) target_link_libraries(test_utils ${GMOCK_LIBRARIES} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY}) -add_custom_target(test - echo "Running tests" +add_custom_target(clementine_test + echo "Running Clementine tests" WORKING_DIRECTORY ${CURRENT_BINARY_DIR} ) add_custom_target(build_tests WORKING_DIRECTORY ${CURRENT_BINARY_DIR} ) -add_dependencies(test build_tests) +add_dependencies(clementine_test build_tests) qt5_add_resources(TEST-RESOURCE-SOURCES data/testdata.qrc) @@ -112,7 +112,7 @@ macro(add_test_file test_source gui_required) set_target_properties(${TEST_NAME} PROPERTIES COMPILE_FLAGS "-Wno-bool-conversions") endif (SUPPORTS_NOBOOL) - add_custom_command(TARGET test POST_BUILD + add_custom_command(TARGET clementine_test POST_BUILD COMMAND ./${TEST_NAME}${CMAKE_EXECUTABLE_SUFFIX}) add_dependencies(build_tests ${TEST_NAME}) endmacro (add_test_file) From 4d0e413fb96b20f8c445c49e03c5e10c3d16f660 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Apr 2015 15:06:00 +0200 Subject: [PATCH 11/17] Finally use of qtsingleapplication adapted to qt5 --- 3rdparty/qtsingleapplication/CMakeLists.txt | 28 + 3rdparty/qtsingleapplication/LICENSE.LGPL | 504 ++++++++++++++++++ 3rdparty/qtsingleapplication/qtlocalpeer.cpp | 200 +++++++ 3rdparty/qtsingleapplication/qtlocalpeer.h | 76 +++ 3rdparty/qtsingleapplication/qtlockedfile.cpp | 192 +++++++ 3rdparty/qtsingleapplication/qtlockedfile.h | 96 ++++ .../qtsingleapplication/qtlockedfile_unix.cpp | 114 ++++ .../qtsingleapplication/qtlockedfile_win.cpp | 214 ++++++++ .../qtsingleapplication.cpp | 331 ++++++++++++ .../qtsingleapplication/qtsingleapplication.h | 101 ++++ .../qtsinglecoreapplication.cpp | 148 +++++ .../qtsinglecoreapplication.h | 70 +++ 3rdparty/singleapplication/CMakeLists.txt | 20 - 3rdparty/singleapplication/LICENSE | 21 - .../singleapplication/singleapplication.cpp | 48 -- .../singleapplication/singleapplication.h | 32 -- .../singlecoreapplication.cpp | 48 -- .../singleapplication/singlecoreapplication.h | 32 -- CMakeLists.txt | 15 +- src/CMakeLists.txt | 7 +- src/main.cpp | 26 +- src/ui/mainwindow.cpp | 4 +- src/ui/mainwindow.h | 2 +- 23 files changed, 2113 insertions(+), 216 deletions(-) create mode 100644 3rdparty/qtsingleapplication/CMakeLists.txt create mode 100644 3rdparty/qtsingleapplication/LICENSE.LGPL create mode 100644 3rdparty/qtsingleapplication/qtlocalpeer.cpp create mode 100644 3rdparty/qtsingleapplication/qtlocalpeer.h create mode 100644 3rdparty/qtsingleapplication/qtlockedfile.cpp create mode 100644 3rdparty/qtsingleapplication/qtlockedfile.h create mode 100644 3rdparty/qtsingleapplication/qtlockedfile_unix.cpp create mode 100644 3rdparty/qtsingleapplication/qtlockedfile_win.cpp create mode 100644 3rdparty/qtsingleapplication/qtsingleapplication.cpp create mode 100644 3rdparty/qtsingleapplication/qtsingleapplication.h create mode 100644 3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp create mode 100644 3rdparty/qtsingleapplication/qtsinglecoreapplication.h delete mode 100644 3rdparty/singleapplication/CMakeLists.txt delete mode 100644 3rdparty/singleapplication/LICENSE delete mode 100644 3rdparty/singleapplication/singleapplication.cpp delete mode 100644 3rdparty/singleapplication/singleapplication.h delete mode 100644 3rdparty/singleapplication/singlecoreapplication.cpp delete mode 100644 3rdparty/singleapplication/singlecoreapplication.h diff --git a/3rdparty/qtsingleapplication/CMakeLists.txt b/3rdparty/qtsingleapplication/CMakeLists.txt new file mode 100644 index 000000000..975881adb --- /dev/null +++ b/3rdparty/qtsingleapplication/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 2.6) + +set(SINGLEAPP-SOURCES + qtlocalpeer.cpp + qtsingleapplication.cpp + qtsinglecoreapplication.cpp +) + +set(SINGLEAPP-MOC-HEADERS + qtlocalpeer.h + qtsingleapplication.h + qtsinglecoreapplication.h +) + +if(WIN32) + set(SINGLEAPP-SOURCES ${SINGLEAPP-SOURCES} qtlockedfile_win.cpp) +elseif(WIN32) + set(SINGLEAPP-SOURCES ${SINGLEAPP-SOURCES} qtlockedfile_unix.cpp) +endif(WIN32) + +QT5_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS}) + +ADD_LIBRARY(qtsingleapplication STATIC + ${SINGLEAPP-SOURCES} + ${SINGLEAPP-SOURCES-MOC} +) + +QT5_USE_MODULES(qtsingleapplication Core Widgets Network) diff --git a/3rdparty/qtsingleapplication/LICENSE.LGPL b/3rdparty/qtsingleapplication/LICENSE.LGPL new file mode 100644 index 000000000..5ab7695ab --- /dev/null +++ b/3rdparty/qtsingleapplication/LICENSE.LGPL @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/3rdparty/qtsingleapplication/qtlocalpeer.cpp b/3rdparty/qtsingleapplication/qtlocalpeer.cpp new file mode 100644 index 000000000..1c89e3c00 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtlocalpeer.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + + +#include "qtlocalpeer.h" +#include +#include +#include + +#if defined(Q_OS_WIN) +#include +#include +typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); +static PProcessIdToSessionId pProcessIdToSessionId = 0; +#endif +#if defined(Q_OS_UNIX) +#include +#endif + +namespace QtLP_Private { +#include "qtlockedfile.cpp" +#if defined(Q_OS_WIN) +#include "qtlockedfile_win.cpp" +#else +#include "qtlockedfile_unix.cpp" +#endif +} + +const char* QtLocalPeer::ack = "ack"; + +QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) + : QObject(parent), id(appId) +{ + QString prefix = id; + if (id.isEmpty()) { + id = QCoreApplication::applicationFilePath(); +#if defined(Q_OS_WIN) + id = id.toLower(); +#endif + prefix = id.section(QLatin1Char('/'), -1); + } + prefix.remove(QRegExp("[^a-zA-Z]")); + prefix.truncate(6); + + QByteArray idc = id.toUtf8(); + quint16 idNum = qChecksum(idc.constData(), idc.size()); + socketName = QLatin1String("qtsingleapp-") + prefix + + QLatin1Char('-') + QString::number(idNum, 16); + +#if defined(Q_OS_WIN) + if (!pProcessIdToSessionId) { + QLibrary lib("kernel32"); + pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); + } + if (pProcessIdToSessionId) { + DWORD sessionId = 0; + pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); + socketName += QLatin1Char('-') + QString::number(sessionId, 16); + } +#else + socketName += QLatin1Char('-') + QString::number(::getuid(), 16); +#endif + + server = new QLocalServer(this); + QString lockName = QDir(QDir::tempPath()).absolutePath() + + QLatin1Char('/') + socketName + + QLatin1String("-lockfile"); + lockFile.setFileName(lockName); + lockFile.open(QIODevice::ReadWrite); +} + + + +bool QtLocalPeer::isClient() +{ + if (lockFile.isLocked()) + return false; + + if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) + return true; + + bool res = server->listen(socketName); +#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) + // ### Workaround + if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { + QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); + res = server->listen(socketName); + } +#endif + if (!res) + qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); + QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); + return false; +} + + +bool QtLocalPeer::sendMessage(const QString &message, int timeout) +{ + if (!isClient()) + return false; + + QLocalSocket socket; + bool connOk = false; + for(int i = 0; i < 2; i++) { + // Try twice, in case the other instance is just starting up + socket.connectToServer(socketName); + connOk = socket.waitForConnected(timeout/2); + if (connOk || i) + break; + int ms = 250; +#if defined(Q_OS_WIN) + Sleep(DWORD(ms)); +#else + struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; + nanosleep(&ts, NULL); +#endif + } + if (!connOk) + return false; + + QByteArray uMsg(message.toUtf8()); + QDataStream ds(&socket); + ds.writeBytes(uMsg.constData(), uMsg.size()); + bool res = socket.waitForBytesWritten(timeout); + if (res) { + res &= socket.waitForReadyRead(timeout); // wait for ack + if (res) + res &= (socket.read(qstrlen(ack)) == ack); + } + return res; +} + + +void QtLocalPeer::receiveConnection() +{ + QLocalSocket* socket = server->nextPendingConnection(); + if (!socket) + return; + + while (socket->bytesAvailable() < (int)sizeof(quint32)) + socket->waitForReadyRead(); + QDataStream ds(socket); + QByteArray uMsg; + quint32 remaining; + ds >> remaining; + uMsg.resize(remaining); + int got = 0; + char* uMsgBuf = uMsg.data(); + do { + got = ds.readRawData(uMsgBuf, remaining); + remaining -= got; + uMsgBuf += got; + } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); + if (got < 0) { + qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); + delete socket; + return; + } + QString message(QString::fromUtf8(uMsg)); + socket->write(ack, qstrlen(ack)); + socket->waitForBytesWritten(1000); + delete socket; + emit messageReceived(message); //### (might take a long time to return) +} diff --git a/3rdparty/qtsingleapplication/qtlocalpeer.h b/3rdparty/qtsingleapplication/qtlocalpeer.h new file mode 100644 index 000000000..7b3fa8159 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtlocalpeer.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + +#ifndef QTLOCALPEER_H +#define QTLOCALPEER_H + +#include +#include +#include + +#include "qtlockedfile.h" + +class QtLocalPeer : public QObject +{ + Q_OBJECT + +public: + QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); + bool isClient(); + bool sendMessage(const QString &message, int timeout); + QString applicationId() const + { return id; } + +Q_SIGNALS: + void messageReceived(const QString &message); + +protected Q_SLOTS: + void receiveConnection(); + +protected: + QString id; + QString socketName; + QLocalServer* server; + QtLP_Private::QtLockedFile lockFile; + +private: + static const char* ack; +}; + +#endif // QTLOCALPEER_H diff --git a/3rdparty/qtsingleapplication/qtlockedfile.cpp b/3rdparty/qtsingleapplication/qtlockedfile.cpp new file mode 100644 index 000000000..3e73ba652 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtlockedfile.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + +#include "qtlockedfile.h" + +/*! + \class QtLockedFile + + \brief The QtLockedFile class extends QFile with advisory locking + functions. + + A file may be locked in read or write mode. Multiple instances of + \e QtLockedFile, created in multiple processes running on the same + machine, may have a file locked in read mode. Exactly one instance + may have it locked in write mode. A read and a write lock cannot + exist simultaneously on the same file. + + The file locks are advisory. This means that nothing prevents + another process from manipulating a locked file using QFile or + file system functions offered by the OS. Serialization is only + guaranteed if all processes that access the file use + QLockedFile. Also, while holding a lock on a file, a process + must not open the same file again (through any API), or locks + can be unexpectedly lost. + + The lock provided by an instance of \e QtLockedFile is released + whenever the program terminates. This is true even when the + program crashes and no destructors are called. +*/ + +/*! \enum QtLockedFile::LockMode + + This enum describes the available lock modes. + + \value ReadLock A read lock. + \value WriteLock A write lock. + \value NoLock Neither a read lock nor a write lock. +*/ + +/*! + Constructs an unlocked \e QtLockedFile object. This constructor + behaves in the same way as \e QFile::QFile(). + + \sa QFile::QFile() +*/ +QtLockedFile::QtLockedFile() + : QFile() +{ +#ifdef Q_OS_WIN + wmutex = 0; + rmutex = 0; +#endif + m_lock_mode = NoLock; +} + +/*! + Constructs an unlocked QtLockedFile object with file \a name. This + constructor behaves in the same way as \e QFile::QFile(const + QString&). + + \sa QFile::QFile() +*/ +QtLockedFile::QtLockedFile(const QString &name) + : QFile(name) +{ +#ifdef Q_OS_WIN + wmutex = 0; + rmutex = 0; +#endif + m_lock_mode = NoLock; +} + +/*! + Opens the file in OpenMode \a mode. + + This is identical to QFile::open(), with the one exception that the + Truncate mode flag is disallowed. Truncation would conflict with the + advisory file locking, since the file would be modified before the + write lock is obtained. If truncation is required, use resize(0) + after obtaining the write lock. + + Returns true if successful; otherwise false. + + \sa QFile::open(), QFile::resize() +*/ +bool QtLockedFile::open(OpenMode mode) +{ + if (mode & QIODevice::Truncate) { + qWarning("QtLockedFile::open(): Truncate mode not allowed."); + return false; + } + return QFile::open(mode); +} + +/*! + Returns \e true if this object has a in read or write lock; + otherwise returns \e false. + + \sa lockMode() +*/ +bool QtLockedFile::isLocked() const +{ + return m_lock_mode != NoLock; +} + +/*! + Returns the type of lock currently held by this object, or \e + QtLockedFile::NoLock. + + \sa isLocked() +*/ +QtLockedFile::LockMode QtLockedFile::lockMode() const +{ + return m_lock_mode; +} + +/*! + \fn bool QtLockedFile::lock(LockMode mode, bool block = true) + + Obtains a lock of type \a mode. The file must be opened before it + can be locked. + + If \a block is true, this function will block until the lock is + aquired. If \a block is false, this function returns \e false + immediately if the lock cannot be aquired. + + If this object already has a lock of type \a mode, this function + returns \e true immediately. If this object has a lock of a + different type than \a mode, the lock is first released and then a + new lock is obtained. + + This function returns \e true if, after it executes, the file is + locked by this object, and \e false otherwise. + + \sa unlock(), isLocked(), lockMode() +*/ + +/*! + \fn bool QtLockedFile::unlock() + + Releases a lock. + + If the object has no lock, this function returns immediately. + + This function returns \e true if, after it executes, the file is + not locked by this object, and \e false otherwise. + + \sa lock(), isLocked(), lockMode() +*/ + +/*! + \fn QtLockedFile::~QtLockedFile() + + Destroys the \e QtLockedFile object. If any locks were held, they + are released. +*/ diff --git a/3rdparty/qtsingleapplication/qtlockedfile.h b/3rdparty/qtsingleapplication/qtlockedfile.h new file mode 100644 index 000000000..2af3e3ea2 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtlockedfile.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + +#ifndef QTLOCKEDFILE_H +#define QTLOCKEDFILE_H + +#include +#ifdef Q_OS_WIN +#include +#endif + +#if defined(Q_WS_WIN) || defined(Q_OS_WIN) +# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) +# define QT_QTLOCKEDFILE_EXPORT +# elif defined(QT_QTLOCKEDFILE_IMPORT) +# if defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# endif +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) +# elif defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTLOCKEDFILE_EXPORT +#endif + +namespace QtLP_Private { + +class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile +{ +public: + enum LockMode { NoLock = 0, ReadLock, WriteLock }; + + QtLockedFile(); + QtLockedFile(const QString &name); + ~QtLockedFile(); + + bool open(OpenMode mode); + + bool lock(LockMode mode, bool block = true); + bool unlock(); + bool isLocked() const; + LockMode lockMode() const; + +private: +#ifdef Q_OS_WIN + Qt::HANDLE wmutex; + Qt::HANDLE rmutex; + QVector rmutexes; + QString mutexname; + + Qt::HANDLE getMutexHandle(int idx, bool doCreate); + bool waitMutex(Qt::HANDLE mutex, bool doBlock); + +#endif + LockMode m_lock_mode; +}; +} +#endif diff --git a/3rdparty/qtsingleapplication/qtlockedfile_unix.cpp b/3rdparty/qtsingleapplication/qtlockedfile_unix.cpp new file mode 100644 index 000000000..715c7d9b1 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtlockedfile_unix.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "qtlockedfile.h" + +bool QtLockedFile::lock(LockMode mode, bool block) +{ + if (!isOpen()) { + qWarning("QtLockedFile::lock(): file is not opened"); + return false; + } + + if (mode == NoLock) + return unlock(); + + if (mode == m_lock_mode) + return true; + + if (m_lock_mode != NoLock) + unlock(); + + struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; + int cmd = block ? F_SETLKW : F_SETLK; + int ret = fcntl(handle(), cmd, &fl); + + if (ret == -1) { + if (errno != EINTR && errno != EAGAIN) + qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); + return false; + } + + + m_lock_mode = mode; + return true; +} + + +bool QtLockedFile::unlock() +{ + if (!isOpen()) { + qWarning("QtLockedFile::unlock(): file is not opened"); + return false; + } + + if (!isLocked()) + return true; + + struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = F_UNLCK; + int ret = fcntl(handle(), F_SETLKW, &fl); + + if (ret == -1) { + qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); + return false; + } + + m_lock_mode = NoLock; + return true; +} + +QtLockedFile::~QtLockedFile() +{ + if (isOpen()) + unlock(); +} + diff --git a/3rdparty/qtsingleapplication/qtlockedfile_win.cpp b/3rdparty/qtsingleapplication/qtlockedfile_win.cpp new file mode 100644 index 000000000..ed2995f3f --- /dev/null +++ b/3rdparty/qtsingleapplication/qtlockedfile_win.cpp @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + +#include "qtlockedfile.h" +#include +#include + +#define MUTEX_PREFIX "QtLockedFile mutex " +// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS +#define MAX_READERS MAXIMUM_WAIT_OBJECTS + +Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) +{ + if (mutexname.isEmpty()) { + QFileInfo fi(*this); + mutexname = QString::fromLatin1(MUTEX_PREFIX) + + fi.absoluteFilePath().toLower(); + } + QString mname(mutexname); + if (idx >= 0) + mname += QString::number(idx); + + Qt::HANDLE mutex; + if (doCreate) { +#if (QT_VERSION < 0x050000) + QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); +#else + mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); +#endif + if (!mutex) { + qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); + return 0; + } + } + else { +#if (QT_VERSION < 0x050000) + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); +#else + mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); +#endif + if (!mutex) { + if (GetLastError() != ERROR_FILE_NOT_FOUND) + qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); + return 0; + } + } + return mutex; +} + +bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) +{ + Q_ASSERT(mutex); + DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); + switch (res) { + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + return true; + break; + case WAIT_TIMEOUT: + break; + default: + qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); + } + return false; +} + + + +bool QtLockedFile::lock(LockMode mode, bool block) +{ + if (!isOpen()) { + qWarning("QtLockedFile::lock(): file is not opened"); + return false; + } + + if (mode == NoLock) + return unlock(); + + if (mode == m_lock_mode) + return true; + + if (m_lock_mode != NoLock) + unlock(); + + if (!wmutex && !(wmutex = getMutexHandle(-1, true))) + return false; + + if (!waitMutex(wmutex, block)) + return false; + + if (mode == ReadLock) { + int idx = 0; + for (; idx < MAX_READERS; idx++) { + rmutex = getMutexHandle(idx, false); + if (!rmutex || waitMutex(rmutex, false)) + break; + CloseHandle(rmutex); + } + bool ok = true; + if (idx >= MAX_READERS) { + qWarning("QtLockedFile::lock(): too many readers"); + rmutex = 0; + ok = false; + } + else if (!rmutex) { + rmutex = getMutexHandle(idx, true); + if (!rmutex || !waitMutex(rmutex, false)) + ok = false; + } + if (!ok && rmutex) { + CloseHandle(rmutex); + rmutex = 0; + } + ReleaseMutex(wmutex); + if (!ok) + return false; + } + else { + Q_ASSERT(rmutexes.isEmpty()); + for (int i = 0; i < MAX_READERS; i++) { + Qt::HANDLE mutex = getMutexHandle(i, false); + if (mutex) + rmutexes.append(mutex); + } + if (rmutexes.size()) { + DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), + TRUE, block ? INFINITE : 0); + if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { + if (res != WAIT_TIMEOUT) + qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); + m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky + unlock(); + return false; + } + } + } + + m_lock_mode = mode; + return true; +} + +bool QtLockedFile::unlock() +{ + if (!isOpen()) { + qWarning("QtLockedFile::unlock(): file is not opened"); + return false; + } + + if (!isLocked()) + return true; + + if (m_lock_mode == ReadLock) { + ReleaseMutex(rmutex); + CloseHandle(rmutex); + rmutex = 0; + } + else { + foreach(Qt::HANDLE mutex, rmutexes) { + ReleaseMutex(mutex); + CloseHandle(mutex); + } + rmutexes.clear(); + ReleaseMutex(wmutex); + } + + m_lock_mode = QtLockedFile::NoLock; + return true; +} + +QtLockedFile::~QtLockedFile() +{ + if (isOpen()) + unlock(); + if (wmutex) + CloseHandle(wmutex); +} diff --git a/3rdparty/qtsingleapplication/qtsingleapplication.cpp b/3rdparty/qtsingleapplication/qtsingleapplication.cpp new file mode 100644 index 000000000..48c2e45f2 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtsingleapplication.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + + +#include "qtsingleapplication.h" +#include "qtlocalpeer.h" +#include + +/*! + \class QtSingleApplication qtsingleapplication.h + \brief The QtSingleApplication class provides an API to detect and + communicate with running instances of an application. + + This class allows you to create applications where only one + instance should be running at a time. I.e., if the user tries to + launch another instance, the already running instance will be + activated instead. Another usecase is a client-server system, + where the first started instance will assume the role of server, + and the later instances will act as clients of that server. + + By default, the full path of the executable file is used to + determine whether two processes are instances of the same + application. You can also provide an explicit identifier string + that will be compared instead. + + The application should create the QtSingleApplication object early + in the startup phase, and call isRunning() to find out if another + instance of this application is already running. If isRunning() + returns false, it means that no other instance is running, and + this instance has assumed the role as the running instance. In + this case, the application should continue with the initialization + of the application user interface before entering the event loop + with exec(), as normal. + + The messageReceived() signal will be emitted when the running + application receives messages from another instance of the same + application. When a message is received it might be helpful to the + user to raise the application so that it becomes visible. To + facilitate this, QtSingleApplication provides the + setActivationWindow() function and the activateWindow() slot. + + If isRunning() returns true, another instance is already + running. It may be alerted to the fact that another instance has + started by using the sendMessage() function. Also data such as + startup parameters (e.g. the name of the file the user wanted this + new instance to open) can be passed to the running instance with + this function. Then, the application should terminate (or enter + client mode). + + If isRunning() returns true, but sendMessage() fails, that is an + indication that the running instance is frozen. + + Here's an example that shows how to convert an existing + application to use QtSingleApplication. It is very simple and does + not make use of all QtSingleApplication's functionality (see the + examples for that). + + \code + // Original + int main(int argc, char **argv) + { + QApplication app(argc, argv); + + MyMainWidget mmw; + mmw.show(); + return app.exec(); + } + + // Single instance + int main(int argc, char **argv) + { + QtSingleApplication app(argc, argv); + + if (app.isRunning()) + return !app.sendMessage(someDataString); + + MyMainWidget mmw; + app.setActivationWindow(&mmw); + mmw.show(); + return app.exec(); + } + \endcode + + Once this QtSingleApplication instance is destroyed (normally when + the process exits or crashes), when the user next attempts to run the + application this instance will not, of course, be encountered. The + next instance to call isRunning() or sendMessage() will assume the + role as the new running instance. + + For console (non-GUI) applications, QtSingleCoreApplication may be + used instead of this class, to avoid the dependency on the QtGui + library. + + \sa QtSingleCoreApplication +*/ + + +void QtSingleApplication::sysInit(const QString &appId) +{ + actWin = 0; + peer = new QtLocalPeer(this, appId); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Creates a QtSingleApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc, \a + argv, and \a GUIenabled are passed on to the QAppliation constructor. + + If you are creating a console application (i.e. setting \a + GUIenabled to false), you may consider using + QtSingleCoreApplication instead. +*/ + +QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled) + : QApplication(argc, argv, GUIenabled) +{ + sysInit(); +} + + +/*! + Creates a QtSingleApplication object with the application + identifier \a appId. \a argc and \a argv are passed on to the + QAppliation constructor. +*/ + +QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv) + : QApplication(argc, argv) +{ + sysInit(appId); +} + + +#if defined(Q_WS_X11) +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be QCoreApplication::applicationFilePath(). \a dpy, \a visual, + and \a cmap are passed on to the QApplication constructor. +*/ +QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, visual, cmap) +{ + sysInit(); +} + +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a + argv, \a visual, and \a cmap are passed on to the QApplication + constructor. +*/ +QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, argc, argv, visual, cmap) +{ + sysInit(); +} + +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be \a appId. \a dpy, \a argc, \a + argv, \a visual, and \a cmap are passed on to the QApplication + constructor. +*/ +QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, argc, argv, visual, cmap) +{ + sysInit(appId); +} +#endif + + +/*! + Returns true if another instance of this application is running; + otherwise false. + + This function does not find instances of this application that are + being run by a different user (on Windows: that are running in + another session). + + \sa sendMessage() +*/ + +bool QtSingleApplication::isRunning() +{ + return peer->isClient(); +} + + +/*! + Tries to send the text \a message to the currently running + instance. The QtSingleApplication object in the running instance + will emit the messageReceived() signal when it receives the + message. + + This function returns true if the message has been sent to, and + processed by, the current instance. If there is no instance + currently running, or if the running instance fails to process the + message within \a timeout milliseconds, this function return false. + + \sa isRunning(), messageReceived() +*/ +bool QtSingleApplication::sendMessage(const QString &message, int timeout) +{ + return peer->sendMessage(message, timeout); +} + + +/*! + Returns the application identifier. Two processes with the same + identifier will be regarded as instances of the same application. +*/ +QString QtSingleApplication::id() const +{ + return peer->applicationId(); +} + + +/*! + Sets the activation window of this application to \a aw. The + activation window is the widget that will be activated by + activateWindow(). This is typically the application's main window. + + If \a activateOnMessage is true (the default), the window will be + activated automatically every time a message is received, just prior + to the messageReceived() signal being emitted. + + \sa activateWindow(), messageReceived() +*/ + +void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) +{ + actWin = aw; + if (activateOnMessage) + connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); + else + disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); +} + + +/*! + Returns the applications activation window if one has been set by + calling setActivationWindow(), otherwise returns 0. + + \sa setActivationWindow() +*/ +QWidget* QtSingleApplication::activationWindow() const +{ + return actWin; +} + + +/*! + De-minimizes, raises, and activates this application's activation window. + This function does nothing if no activation window has been set. + + This is a convenience function to show the user that this + application instance has been activated when he has tried to start + another instance. + + This function should typically be called in response to the + messageReceived() signal. By default, that will happen + automatically, if an activation window has been set. + + \sa setActivationWindow(), messageReceived(), initialize() +*/ +void QtSingleApplication::activateWindow() +{ + if (actWin) { + actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); + actWin->raise(); + actWin->activateWindow(); + } +} + + +/*! + \fn void QtSingleApplication::messageReceived(const QString& message) + + This signal is emitted when the current instance receives a \a + message from another instance of this application. + + \sa sendMessage(), setActivationWindow(), activateWindow() +*/ + + +/*! + \fn void QtSingleApplication::initialize(bool dummy = true) + + \obsolete +*/ diff --git a/3rdparty/qtsingleapplication/qtsingleapplication.h b/3rdparty/qtsingleapplication/qtsingleapplication.h new file mode 100644 index 000000000..42e977281 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtsingleapplication.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + +#ifndef QTSINGLEAPPLICATION_H +#define QTSINGLEAPPLICATION_H + +#include + +class QtLocalPeer; + +#if defined(Q_WS_WIN) || defined(Q_OS_WIN32) +# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) +# define QT_QTSINGLEAPPLICATION_EXPORT +# elif defined(QT_QTSINGLEAPPLICATION_IMPORT) +# if defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# endif +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) +# elif defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTSINGLEAPPLICATION_EXPORT +#endif + +class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication +{ + Q_OBJECT + +public: + QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); + QtSingleApplication(const QString &id, int &argc, char **argv); +#if defined(Q_WS_X11) + QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); + QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); + QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); +#endif + + bool isRunning(); + QString id() const; + + void setActivationWindow(QWidget* aw, bool activateOnMessage = true); + QWidget* activationWindow() const; + + // Obsolete: + void initialize(bool dummy = true) + { isRunning(); Q_UNUSED(dummy) } + +public Q_SLOTS: + bool sendMessage(const QString &message, int timeout = 5000); + void activateWindow(); + + +Q_SIGNALS: + void messageReceived(const QString &message); + + +private: + void sysInit(const QString &appId = QString()); + QtLocalPeer *peer; + QWidget *actWin; +}; + +#endif // QTSINGLEAPPLICATION_H diff --git a/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp b/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp new file mode 100644 index 000000000..cf607710e --- /dev/null +++ b/3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + + +#include "qtsinglecoreapplication.h" +#include "qtlocalpeer.h" + +/*! + \class QtSingleCoreApplication qtsinglecoreapplication.h + \brief A variant of the QtSingleApplication class for non-GUI applications. + + This class is a variant of QtSingleApplication suited for use in + console (non-GUI) applications. It is an extension of + QCoreApplication (instead of QApplication). It does not require + the QtGui library. + + The API and usage is identical to QtSingleApplication, except that + functions relating to the "activation window" are not present, for + obvious reasons. Please refer to the QtSingleApplication + documentation for explanation of the usage. + + A QtSingleCoreApplication instance can communicate to a + QtSingleApplication instance if they share the same application + id. Hence, this class can be used to create a light-weight + command-line tool that sends commands to a GUI application. + + \sa QtSingleApplication +*/ + +/*! + Creates a QtSingleCoreApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc and \a + argv are passed on to the QCoreAppliation constructor. +*/ + +QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer(this); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Creates a QtSingleCoreApplication object with the application + identifier \a appId. \a argc and \a argv are passed on to the + QCoreAppliation constructor. +*/ +QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer(this, appId); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Returns true if another instance of this application is running; + otherwise false. + + This function does not find instances of this application that are + being run by a different user (on Windows: that are running in + another session). + + \sa sendMessage() +*/ + +bool QtSingleCoreApplication::isRunning() +{ + return peer->isClient(); +} + + +/*! + Tries to send the text \a message to the currently running + instance. The QtSingleCoreApplication object in the running instance + will emit the messageReceived() signal when it receives the + message. + + This function returns true if the message has been sent to, and + processed by, the current instance. If there is no instance + currently running, or if the running instance fails to process the + message within \a timeout milliseconds, this function return false. + + \sa isRunning(), messageReceived() +*/ + +bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) +{ + return peer->sendMessage(message, timeout); +} + + +/*! + Returns the application identifier. Two processes with the same + identifier will be regarded as instances of the same application. +*/ + +QString QtSingleCoreApplication::id() const +{ + return peer->applicationId(); +} + + +/*! + \fn void QtSingleCoreApplication::messageReceived(const QString& message) + + This signal is emitted when the current instance receives a \a + message from another instance of this application. + + \sa sendMessage() +*/ diff --git a/3rdparty/qtsingleapplication/qtsinglecoreapplication.h b/3rdparty/qtsingleapplication/qtsinglecoreapplication.h new file mode 100644 index 000000000..549d49f53 --- /dev/null +++ b/3rdparty/qtsingleapplication/qtsinglecoreapplication.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of a Qt Solutions component. +** +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +****************************************************************************/ + +#ifndef QTSINGLECOREAPPLICATION_H +#define QTSINGLECOREAPPLICATION_H + +#include + +class QtLocalPeer; + +class QtSingleCoreApplication : public QCoreApplication +{ + Q_OBJECT + +public: + QtSingleCoreApplication(int &argc, char **argv); + QtSingleCoreApplication(const QString &id, int &argc, char **argv); + + bool isRunning(); + QString id() const; + +public Q_SLOTS: + bool sendMessage(const QString &message, int timeout = 5000); + + +Q_SIGNALS: + void messageReceived(const QString &message); + + +private: + QtLocalPeer* peer; +}; + +#endif // QTSINGLECOREAPPLICATION_H diff --git a/3rdparty/singleapplication/CMakeLists.txt b/3rdparty/singleapplication/CMakeLists.txt deleted file mode 100644 index f4711c0f5..000000000 --- a/3rdparty/singleapplication/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -set(SINGLEAPP-SOURCES - singleapplication.cpp - singlecoreapplication.cpp -) - -set(SINGLEAPP-MOC-HEADERS - singleapplication.h - singlecoreapplication.h -) - -QT5_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS}) - -ADD_LIBRARY(singleapplication STATIC - ${SINGLEAPP-SOURCES} - ${SINGLEAPP-SOURCES-MOC} -) - -QT5_USE_MODULES(singleapplication Core Network Widgets) diff --git a/3rdparty/singleapplication/LICENSE b/3rdparty/singleapplication/LICENSE deleted file mode 100644 index 5c0006b9a..000000000 --- a/3rdparty/singleapplication/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Itay Grudev - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/3rdparty/singleapplication/singleapplication.cpp b/3rdparty/singleapplication/singleapplication.cpp deleted file mode 100644 index 9f71a62cb..000000000 --- a/3rdparty/singleapplication/singleapplication.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "singleapplication.h" -#include - -/** - * @brief Constructor. Checks and fires up LocalServer or closes the program - * if another instance already exists - * @param argc - * @param argv - */ -SingleApplication::SingleApplication(int &argc, char **argv) - : QApplication(argc, argv) -{ - QString serverName = QApplication::organizationName() + QApplication::applicationName(); - serverName.replace(QRegExp("[^\\w\\-. ]"), ""); - - // Attempt to connect to the LocalServer - socket = new QLocalSocket(); - socket->connectToServer(serverName); - if(socket->waitForConnected(1000)){ - socket->close(); - ::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function - } else { - // If the connection is insuccessful, this is the main process - // So we create a Local Server - server = new QLocalServer(); - server->removeServer(serverName); - server->listen(serverName); - QObject::connect(server, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished())); - } -} - -/** - * @brief Destructor - */ -SingleApplication::~SingleApplication() -{ - server->close(); -} - -/** - * @brief Executed when the showUp command is sent to LocalServer - */ -void SingleApplication::slotConnectionEstablished() -{ - server->nextPendingConnection(); - emit showUp(); -} - diff --git a/3rdparty/singleapplication/singleapplication.h b/3rdparty/singleapplication/singleapplication.h deleted file mode 100644 index 3550eace0..000000000 --- a/3rdparty/singleapplication/singleapplication.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef SINGLE_APPLICATION_H -#define SINGLE_APPLICATION_H - -#include -#include -#include - -/** - * @brief The SingleApplication class handles multipe instances of the same Application - * @see QApplication - */ -class SingleApplication : public QApplication -{ - Q_OBJECT -public: - explicit SingleApplication(int &, char **); - ~SingleApplication(); - -signals: - void showUp(); - -private slots: - void slotConnectionEstablished(); - -private: - QLocalSocket *socket; - QLocalServer *server; - -}; - -#endif // SINGLE_APPLICATION_H - diff --git a/3rdparty/singleapplication/singlecoreapplication.cpp b/3rdparty/singleapplication/singlecoreapplication.cpp deleted file mode 100644 index 587b3fa53..000000000 --- a/3rdparty/singleapplication/singlecoreapplication.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "singlecoreapplication.h" -#include - -/** - * @brief Constructor. Checks and fires up LocalServer or closes the program - * if another instance already exists - * @param argc - * @param argv - */ -SingleCoreApplication::SingleCoreApplication(int &argc, char **argv) - : QCoreApplication(argc, argv) -{ - QString serverName = QCoreApplication::organizationName() + QCoreApplication::applicationName(); - serverName.replace(QRegExp("[^\\w\\-. ]"), ""); - - // Attempt to connect to the LocalServer - socket = new QLocalSocket(); - socket->connectToServer(serverName); - if(socket->waitForConnected(1000)){ - socket->close(); - ::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function - } else { - // If the connection is insuccessful, this is the main process - // So we create a Local Server - server = new QLocalServer(); - server->removeServer(serverName); - server->listen(serverName); - QObject::connect(server, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished())); - } -} - -/** - * @brief Destructor - */ -SingleCoreApplication::~SingleCoreApplication() -{ - server->close(); -} - -/** - * @brief Executed when the showUp command is sent to LocalServer - */ -void SingleCoreApplication::slotConnectionEstablished() -{ - server->nextPendingConnection(); - emit showUp(); -} - diff --git a/3rdparty/singleapplication/singlecoreapplication.h b/3rdparty/singleapplication/singlecoreapplication.h deleted file mode 100644 index b3a404d03..000000000 --- a/3rdparty/singleapplication/singlecoreapplication.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef SINGLE_CORE_APPLICATION_H -#define SINGLE_CORE_APPLICATION_H - -#include -#include -#include - -/** - * @brief The SingleCoreApplication class handles multipe instances of the same Application - * @see QApplication - */ -class SingleCoreApplication : public QCoreApplication -{ - Q_OBJECT -public: - explicit SingleCoreApplication(int &, char **); - ~SingleCoreApplication(); - -signals: - void showUp(); - -private slots: - void slotConnectionEstablished(); - -private: - QLocalSocket *socket; - QLocalServer *server; - -}; - -#endif // SINGLE_CORE_APPLICATION_H - diff --git a/CMakeLists.txt b/CMakeLists.txt index c108b2974..9c2323507 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,9 +322,18 @@ endif(ENABLE_VISUALISATIONS) add_subdirectory(3rdparty/qsqlite) include_directories("3rdparty/qsqlite") -add_subdirectory(3rdparty/singleapplication) -set(SINGLEAPPLICATION_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/singleapplication) -set(SINGLEAPPLICATION_LIBRARIES singleapplication) +# When/if upstream accepts our patches then these options can be used to link +# to system installed qtsingleapplication instead. +option(USE_SYSTEM_QTSINGLEAPPLICATION "Don't set this option unless your system QtSingleApplication library has been compiled with the Clementine patches in 3rdparty" OFF) +if(USE_SYSTEM_QTSINGLEAPPLICATION) + find_path(QTSINGLEAPPLICATION_INCLUDE_DIRS qtsingleapplication.h PATH_SUFFIXES QtSolutions) + find_library(QTSINGLEAPPLICATION_LIBRARIES QtSolutions_SingleApplication-2.6) + find_library(QTSINGLECOREAPPLICATION_LIBRARIES QtSolutions_SingleCoreApplication-2.6) +else(USE_SYSTEM_QTSINGLEAPPLICATION) + add_subdirectory(3rdparty/qtsingleapplication) + set(QTSINGLEAPPLICATION_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qtsingleapplication) + set(QTSINGLEAPPLICATION_LIBRARIES qtsingleapplication) +endif(USE_SYSTEM_QTSINGLEAPPLICATION) # QtIoCompressor isn't patched, so we can use a system version if it's # available diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9d193c850..86b4940e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,7 +32,7 @@ include_directories(${GLIB_INCLUDE_DIRS}) include_directories(${LIBXML_INCLUDE_DIRS}) include_directories(${GOBJECT_INCLUDE_DIRS}) include_directories(${LIBPROJECTM_INCLUDE_DIRS}) -include_directories(${SINGLEAPPLICATION_INCLUDE_DIRS}) +include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIRS}) include_directories(${QTIOCOMPRESSOR_INCLUDE_DIRS}) include_directories(${QXT_INCLUDE_DIRS}) include_directories(${ECHONEST5_INCLUDE_DIRS}) @@ -1240,8 +1240,7 @@ target_link_libraries(clementine_lib ${GSTREAMER_LIBRARIES} ${GSTREAMER_APP_LIBRARIES} ${GSTREAMER_TAG_LIBRARIES} - ${SINGLEAPPLICATION_LIBRARIES} - ${QTSINGLECOREAPPLICATION_LIBRARIES} + ${QTSINGLEAPPLICATION_LIBRARIES} ${QTIOCOMPRESSOR_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${SQLITE_LIBRARIES} @@ -1349,7 +1348,7 @@ if (UNIX AND NOT APPLE) endif () endif () -add_dependencies(clementine_lib singleapplication) +add_dependencies(clementine_lib qtsingleapplication) ############################################################################### diff --git a/src/main.cpp b/src/main.cpp index 4a90b0951..2c3fb1c3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,8 +69,8 @@ #include "tagreadermessages.pb.h" -#include "singleapplication.h" -#include "singlecoreapplication.h" +#include "qtsingleapplication.h" +#include "qtsinglecoreapplication.h" #include #include @@ -288,7 +288,7 @@ int main(int argc, char* argv[]) { // Clementine running without needing an X server. // This MUST be done before parsing the commandline options so QTextCodec // gets the right system locale for filenames. - SingleCoreApplication a(argc, argv); + QtSingleCoreApplication a(argc, argv); CheckPortable(); crash_reporting.SetApplicationPath(a.applicationFilePath()); @@ -297,6 +297,16 @@ int main(int argc, char* argv[]) { if (!options.Parse()) return 1; logging::SetLevels(options.log_levels()); + if (a.isRunning()) { + if (options.is_empty()) { + qLog(Info) + << "Clementine is already running - activating existing window"; + } + if (a.sendMessage(options.Serialize(), 5000)) { + return 0; + } + // Couldn't send the message so start anyway + } } #ifdef Q_OS_DARWIN @@ -324,7 +334,7 @@ int main(int argc, char* argv[]) { IncreaseFDLimit(); - SingleApplication a(argc, argv); + QtSingleApplication a(argc, argv); // A bug in Qt means the wheel_scroll_lines setting gets ignored and replaced // with the default value of 3 in QApplicationPrivate::initialize. @@ -342,6 +352,10 @@ int main(int argc, char* argv[]) { #endif a.setQuitOnLastWindowClosed(false); + // Do this check again because another instance might have started by now + if (a.isRunning() && a.sendMessage(options.Serialize(), 5000)) { + return 0; + } #ifndef Q_OS_DARWIN // Gnome on Ubuntu has menu icons disabled by default. I think that's a bad @@ -466,8 +480,10 @@ int main(int argc, char* argv[]) { #ifdef HAVE_DBUS QObject::connect(&mpris, SIGNAL(RaiseMainWindow()), &w, SLOT(Raise())); #endif - + QObject::connect(&a, SIGNAL(messageReceived(QString)), &w, + SLOT(CommandlineOptionsReceived(QString))); w.CommandlineOptionsReceived(options); + int ret = a.exec(); #ifdef Q_OS_LINUX diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index cba1d91d9..626134219 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -1943,14 +1943,14 @@ void MainWindow::PlaylistEditFinished(const QModelIndex& index) { } void MainWindow::CommandlineOptionsReceived( - const QByteArray& serialized_options) { + const QString& serialized_options) { if (serialized_options == "wake up!") { // Old versions of Clementine sent this - just ignore it return; } CommandlineOptions options; - options.Load(serialized_options); + options.Load(serialized_options.toLatin1()); if (options.is_empty()) { show(); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 71e286259..50672ac26 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -222,7 +222,7 @@ signals: void AddCDTracks(); void AddPodcast(); - void CommandlineOptionsReceived(const QByteArray& serialized_options); + void CommandlineOptionsReceived(const QString &serialized_options); void CheckForUpdates(); From 8bafaced14df086e6b0f1446db7a3e02b4ceb9ed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Apr 2015 17:45:23 +0200 Subject: [PATCH 12/17] Fix error message log in metatypes (declared twice) --- src/core/metatypes.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/metatypes.cpp b/src/core/metatypes.cpp index 9c5deb00c..d6196cca3 100644 --- a/src/core/metatypes.cpp +++ b/src/core/metatypes.cpp @@ -56,7 +56,6 @@ class QNetworkReply; void RegisterMetaTypes() { qRegisterMetaType("CollapsibleInfoPane::Data"); - qRegisterMetaType("ColumnAlignmentMap"); qRegisterMetaType("const char*"); qRegisterMetaType("CoverSearchResult"); qRegisterMetaType("CoverSearchResults"); From 32fe732f645e00632cb8b795db35f6ad41018711 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Apr 2015 18:54:42 +0200 Subject: [PATCH 13/17] Adapt clementine tests to qt5 --- CMakeLists.txt | 2 +- tests/CMakeLists.txt | 1 + tests/main.cpp | 2 +- tests/mock_networkaccessmanager.cpp | 6 ++++-- tests/zeroconf_test.cpp | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0b2aa1b8..675143b6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ endif (UNIX AND NOT APPLE) set(QT_MIN_VERSION 5.0.0) -find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core OpenGL Sql Network Xml Widgets Concurrent) +find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core OpenGL Sql Network Xml Widgets Concurrent Test) find_package(X11) if(X11_FOUND) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 95c954d00..617704241 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -100,6 +100,7 @@ macro(add_test_file test_source gui_required) ${test_source} ) target_link_libraries(${TEST_NAME} ${GMOCK_LIBRARIES} clementine_lib test_utils) + qt5_use_modules (${TEST_NAME} Test) set(GUI_REQUIRED ${gui_required}) if (GUI_REQUIRED) target_link_libraries(${TEST_NAME} test_gui_main) diff --git a/tests/main.cpp b/tests/main.cpp index eb058fbc6..036e02111 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -25,7 +25,7 @@ #ifndef Q_WS_X11 # include - Q_IMPORT_PLUGIN(qsqlite) + Q_IMPORT_PLUGIN(QSQLiteDriverPlugin) #endif int main(int argc, char** argv) { diff --git a/tests/mock_networkaccessmanager.cpp b/tests/mock_networkaccessmanager.cpp index 64d6d5f68..bb0224d39 100644 --- a/tests/mock_networkaccessmanager.cpp +++ b/tests/mock_networkaccessmanager.cpp @@ -18,6 +18,7 @@ #include "mock_networkaccessmanager.h" #include +#include #include using std::min; @@ -44,10 +45,11 @@ class RequestForUrlMatcher : public MatcherInterface { return false; } + QUrlQuery url_query(url); for (QMap::const_iterator it = expected_params_.constBegin(); it != expected_params_.constEnd(); ++it) { - if (!url.hasQueryItem(it.key()) || - url.queryItemValue(it.key()) != it.value()) { + if (!url_query.hasQueryItem(it.key()) || + url_query.queryItemValue(it.key()) != it.value()) { return false; } } diff --git a/tests/zeroconf_test.cpp b/tests/zeroconf_test.cpp index 3448f8221..973953e25 100644 --- a/tests/zeroconf_test.cpp +++ b/tests/zeroconf_test.cpp @@ -21,7 +21,7 @@ static const char kLongMultiByteString[] = TEST(ZeroconfTest, TruncatesAscii) { QByteArray truncated = Zeroconf::TruncateName( - QString::fromAscii(k64CharAscii)); + QString::fromLatin1(k64CharAscii)); EXPECT_EQ(63, truncated.size()); EXPECT_TRUE(truncated.endsWith('\0')); } @@ -34,7 +34,7 @@ TEST(ZeroconfTest, DoesNotTruncateShortMultiByteUTF8) { TEST(ZeroconfTest, TruncatesLongMultiByteUTF8) { QByteArray truncated = Zeroconf::TruncateName( - QString::fromAscii(kLongMultiByteString)); + QString::fromLatin1(kLongMultiByteString)); EXPECT_LE(63, truncated.size()); EXPECT_TRUE(truncated.endsWith('\0')); } From 1c6d164219aa700485075d048fa1eb1623282b1a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Apr 2015 20:21:19 +0200 Subject: [PATCH 14/17] Avoid warning message with dbus inialized before a QApplication --- src/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2c3fb1c3e..6b63ea648 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -317,12 +317,6 @@ int main(int argc, char* argv[]) { 1); #endif -#ifdef HAVE_LIBLASTFM - lastfm::ws::ApiKey = LastFMService::kApiKey; - lastfm::ws::SharedSecret = LastFMService::kSecret; - lastfm::setNetworkAccessManager(new NetworkAccessManager); -#endif - // Output the version, so when people attach log output to bug reports they // don't have to tell us which version they're using. qLog(Info) << "Clementine-qt5" << CLEMENTINE_VERSION_DISPLAY; @@ -336,6 +330,12 @@ int main(int argc, char* argv[]) { QtSingleApplication a(argc, argv); +#ifdef HAVE_LIBLASTFM + lastfm::ws::ApiKey = LastFMService::kApiKey; + lastfm::ws::SharedSecret = LastFMService::kSecret; + lastfm::setNetworkAccessManager(new NetworkAccessManager); +#endif + // A bug in Qt means the wheel_scroll_lines setting gets ignored and replaced // with the default value of 3 in QApplicationPrivate::initialize. { From 4a9224c04e7984bc0d5f4bd1ea0cc8021f8430f7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Apr 2015 20:37:31 +0200 Subject: [PATCH 15/17] Remove boring libpng warnings --- data/icons/32x32/internet-services.png | Bin 5196 -> 2562 bytes data/playstore/fr_generic_rgb_wo_45.png | Bin 7115 -> 5980 bytes data/providers/skydrive.png | Bin 3469 -> 1261 bytes data/providers/wikipedia.png | Bin 3203 -> 525 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/data/icons/32x32/internet-services.png b/data/icons/32x32/internet-services.png index 464115e4a54cfb48ab51d625762016d2c9e49f06..c6fe3e20dbaf3da31559cbf66a1a24da3874c082 100644 GIT binary patch delta 2454 zcmV;H32FAsD1sD_B$IjyW`AQzL_t(o!_}92a8%VD$G>;??jw)gWV3l}vYW?lLPB1o zF$y{{4KUV95Ja$`t<<3cj#^(-#E#RM+Nqri79xTr2@p)8A%>TtyaEWQs3ejQNrEK1 zA;~_I-M#y~`?$OJ^bZX_!U%NiAN|hUxo6J({m$=m=l47FI|ulg)qio~_)Xc<*E86@ zeLGgJT!{(0HThq!y}opK_)0ayFeQG!KO+?6Vg&+WOz%W zF1!l>x-VY*>EMk`EdYQ;i|#)+y?Qz(fhN!j|xRgcHq=nvFxSPuZGC@d~ZPgLkt z$*E*|K_Pkm#TVCJ%U&=!&|6H%%+hGK)HR%~S+evtDiYaIl&8xyIvo%B{I0-_0zA9+ z1pvUf#d5*oVt;ZIVx$WTOG>^jEvr~xx3lqY0C1tNe=0z3x*7tS?v0bl?(q9PH3Ryg zmDTsmGXlV_cUo^ag_9a{IROB3?|b0j{=Mzf9gOopqC)YP&%3*8%ZiJBXngqSF#tfz zyKP@LwzaRg>1fx{yZhb)05r9?f6}&Z&$=Ic?CS0X0Drt$U$=h!#@fe!?%fQX&1kZG zQv<1KDUX`16VT@B#{Sy?l<>wjN{TAoY_wRwxR|Fk>U7YX->8*(ydG_Ga!SBt8ZQN4 zx|X9@eSa^)rVju>gv7@lyyedPs_cx!-_Z&hA@#X3?sKzjLlWP+|pEKlV*C`r>>yI9~Xr)8m3NB?*K51N-$OqY#eStoZcI zS$`)b7CkaLY^XeQ;>5&?m8;6t>a6Geevkds+pjVYJpQ!tl|R)a1Vd3!0KEPXf*}rO zn;W5U1dKZXp+JCGsRUB72$dCizkIJVhImGfo-QdZyGNIszhKQXPkoWE&C=g8^Y%1a zEGk^{DyFICki;aNoZ7zq)N!Wh?9V$pfqpGJkne z?CoXw_lrbASnXa6U70}NkOgL&2VED(@U>wA2aff@;|oD5p`l8V!)EuwWc8r3T!&#Z zwML~l|i zjM&C8GREMO^9JZg9SDbc*z7(SEq`uUCVa3?c#)rzf<(C#G%Y}Ck{t4QDXy3p6l7LUz~=N~ z@ z87EjafIMvuDy#13nk@9I%_vD0-&avl0j;hO5srhH7QyXy!{rWui$qbs`z+Fwa@<+2 z!*eUDF>G|gZ1aE?2=RIM7!1{cMaA9cF83=I{?y0GP z5I8yoz-%@)J@xz=T)fx|fq#Gk0YSjeLM*010GMnZFs>jNPZ063QZ)YaLEK%Hj}=QR zFk)hGaQUE>sh^0M;vjLQji zh7$6`L%8 zjQgNSkfKPJ0k4Yz4<25R4|C?+f$sBN9krWk?Na~%VAE@x9IlWJq8JIda1a5P4RLW& z&_V%v`pt-mp<#1)5eh}oueZU+hVYL!KZ4I6f<~2qP&fj=p92U5%Y+*O!ouxzA{q@t zC?PPrt$1P0y05+;^M3~bUv>9fK6UyyC=vx9;Sly)K@koKvKVlYD8?)6M;L?Jv8(vZ87tQD- z6d$ZdFksde0iG-W&_v4F|qL0qf^0EI}DptL}RyDIZgJyVBhgy2ZWna^O}wT$O+ znG(`aYqB=AHSb97?Ce^1>eQ+09~vHc^qUSgZ{GaU$$vR%T*|D<1uyr#w4sCS*xgCG zdW~e@vW*-*d5OHezniq|?;%T8H}YAf4{ih?o%EYOfBsAWXlZM|W~}R8&3+_Fs;0E2 zvU>5ud3m~0MS@($agnIeY%!ke>NsO1;%^@wK=9l5|DXN?^v7`T UMg72`01E&B07*qoM6N<$f_C|#Z~y=R delta 5104 zcmVFOw0}eAZu_2-Y5k*7< z6+wa`28@Oxu_B6vfMCHMkRYJMU=&eNc{8$Bbmir}mzUokXMcTbpS|}zXYYO1x&V;8 z{kgn!SPFnNo`4_Xg z0)Qfk?E(%fNyMfiCh@~U+(f(-030dtD~|t)1)Lm#_)>1^8M%CJVv>Na%hIEp+1fJb z-kj`IjzC}(#AKx~`E0sddRhjPmkYq+oj*%PTwA)R$bZ&mw$|20=Ei1U73#lk{!NK{ zyGXBsKlcox^?kAZm0x;20E}5tZFYRI#qR~6V>1Bq_rKUQ4+0=5>RbE3SNEZb=OsxX z$gndp$L{!k0Z0NWPyi}G1Ly)HU=D16J#Ypdz<(D6f-n#TRsj}B0%?E`vOzxB2#P=n z*a3EfYETOrKoe*ICqM@{4K9Go;5xVgZi5G41dM~{UdP6d+Yd3o?Mr zAqM0Kc|iV92owdyL5UC#5<>aVCa44|hpM4Es0sQWIt5*Tu0n&*J!lk~f_{hI!w5`* zseiCCtPPvM4A=$sgTvsJa3Z`K&Vvi#?Qj)b4_yPPlex4vr&>=Vw!hZ7&wDr6*;uGTJg8GHjVbnL{!c zWyUB7MT6o-VNo_w8Yq`2<5Ub)hw4L3rj}5@qxMs0WMyP6Wy582WNT#4$d1qunl{ac zmP#w5ouJ*Jy_Zv#bCKi7ZIf$}8dZN`iSTS4ifZ`>^=_S-9_DfhxikF;Na$gBn(pL&mTBCGGsZVKESw-1PIYW7`@mn$4Q`weVUDtt72ITD@9x+B(`1+FP_cv?q1s zb$oR4beeS@>XLPxbXV)v>)z7C=rQzC^!DrB(1-P{^po^!^al)J18W1W!G425L$sl- zAyeeqo|%5^b{6q}Sw=sg-G}X@7(112Y*jU$X+U zF0n%DhURoMhax4#6-nF7w1z2sd>bCl5ZDY;1Zn2)S(X@%P z*=IA%pfZ9OrHm`KXj@m?^|q&N-`QE)3G7bT{bp}upJIR1esZbKQqIzbrDG224ortS zhY?4*W1Qnb#}OwrCx50>z0(tC4QIAWs!l zhetO?&#v%Tv3tdMj8#lg%$=1wD|1#}U8T4xb=8?z$yjFW$vAXeMBLH156nPjJ##kR zCw^c249ktRhkx~)?aZ!VPjMVL<(!EGhlKKk$wY_5U5QgkPDzzX(_A-hHTPw*cXDm= zTuNZd;gp5ch}70JTv}Y(DV_{3h1Zj=lAe=3m|>7nlrgf}ZuRcfGkiaOVpAd!m-U>o12Ryiugst zTkN;gZbfb7ZtdS@v2E|RPsQxwYbB;7l_eiaS*6#$G5e-n=E9e!)6|Z;4?!H=SSy{V>ut&IOq{_dlbFb#!9eY1iCsp6B zajj|Hr?hX|zPbJE{X++w546-O*Ot`2Kgd0Jx6Z4sy~-lqcg5k# z>3^$sS5IAITJ{_=u0ch3gRK7Nz-W`3^tt-{+Q?-=iT-$%Tkn9u%z z{ZRE$?_<{|zfTVr(iRr}1p}D#{3Ul5b&(-ye^*IFK~z}7)t7m26m=HIzdh4)WRjU= zGC3xhgk&ZmAs5*g1+AD3SgtEU5WxlAm9G$;|YeJx9;N-jY>7XbIjg5_1v0}ydKA-v_fVbM3b3WLA=*^))V~x#bM=ZtxJOLkzf$&if z076;>iV}hnP@qL(Xmz>BpQ_u^P~Y(Qf2>)v$jOr@Zw#QNr3FiuF2%xyifk*J3PVUki)#=Rc5lthut^U;(@ByuNDsD!s=`J3$82-Rx`4vWMyrtZ#-SQXz?vnG`g)gUzcri zIUn=~+`;PwcxLtU0Dy6;^_tXV;o<-R#!)0s!7@VV(0HbFdfA1+ z;gNKc*?Kt#($Z5OvDhY{&C`wj*bOM*^%Y90I>TbJTEV!Pr?NB|pf|o=C-wTg+LV;k zpxHcL2EcqRp;&VdBIfr2e?Ww!M<2N9_JZo1%%qfPjF0vW+6RoM^zQ<@&#IP;z}cQN zNk3>D##EgaiHamT##4yKqW1uJ5dcvCX7k0CUAxHfPd+6!i&OYrv3%w>0Km)zb(@-Y zbrG*WM7}Ye5JHGy#7Q>p_;^J1t2NaCAWABk1aai#M}OVld5rvbfBO#7wr}6+t7Ryr z={B)cj1h~)sm@fzt_Yf2+mTw^1>fg8)la>&&vBq> z&A2t47K@5jJ@NSJjddF!Ty+0p6qXbh(;~?-MZBUu93^+Sf1S*3^QdWdUUBIkjBG{4 zroS(m&hrEWK>v^(!)7O>ViDZlAj*p~(cNo;Hd_V8!@}ne0~7_ZNIE+!uTVN_=-*;B zn|^z)??R$hn>+F7<4=Y~G`*x{`?i+=Kydr5Gcar%t~_$!pm5Kg_rAPkW>p&-@GF9> zA96*q?AG#vfBQrtA#4sGhAvH@Z^#OZ-HYz?WBAHAfqh5%;Pro(lM5ER7qmc#&-7#1`9TlP^p3&n4TJH7piW7I)!_x}_an+hkfq5)n4@ra zZ7qbr;Yk1%i>dj^=T_nT`CbSF6bJ}{0TyC0e+>e_Z1;k3hroD4NRUa<^zR37S9JlF zEw03fnZcnGgJ|2Yhm#3{@C2uO3>X|8M=%%!MJR;BL1=QdC@w9+)`t3~NdOh)6>Ax{ z3z|$76iG=4vH=8rF2qSh=)GV?^(|VozSjkhH-un_10N$Wj5@)`2;$?UpgN3PclrfG_nu7f+l#e+r7kz(+Ym0ya>DL!vwmTr`F;s~b~uQ&5<% zLLeB1!^MK8DX^gkY)&uiE(V7_8oRV= z6Y>6m4|i)5EmIknLzJb}Xrl5Fw z7oh+tjRPLzdy8%3ZltRcAdvxPs~7Py2>=Sw7(rQ~8h2LZqh^K^9+niD5Z{P585@FSNy*qk|Y%dT9L#;4A#n)g!Qev9im$+n$c zq`TKd1}@sk!Q&UmTYL4Sb#D(@w6ckxQue@l0MaYExpU{v0D#u^jvx1H_8pU?WtG)d z)hv7{KVMg-OjO7@E*djgtfn*F-N(;;(!3Rb@rEX;pD^Z$zdm>Xp|8*XfA&B0$8hh- SxU2yH0000tewvy+uQvuD|R?~!nfWcwZ; z=Xm{IFP`VQulpKz*fR|k5<*%+2!coua78U}4FqpKd|dD~>@9vLxG-75wbUWVhYf-P z-a*jW4Y+PYkcS`y{Wgan$z%wkaz>eTDuZWnEmTz$p_|*!%%=Q!aEHJJZr~0eCLv{!*?4iT5`4 z_LKECCnBny_}p%%U)bz^`%#t_AT$czX9jU%hW~uWB*Idlwux-^U-D)=Xc>3n{&%u^ zB)t>pwO{qm)OY{yUek%`&SMtT8;B56#W=+n!Ws&4x~x%fiy6Q?rELkm5K$uIY<+HR zZS7A+M%G=Zo&U_tjEtT>tz=J5>>8%SeNU0)?)ks{n3fi~w}wXvb~2etUa(Bv%z7{4^VzRZCl&>wZLoaha1( zJtZBTDr&V8vO(Tl{d-n4zSVVOHdX7&3aQ0^)%p6w)zwwg1frv(6PJ{1>*>K~V`GDB zYEm6Opr;?6n)*N|<^(~PS69Oowwe#bT_Et|q4DwH_;?ClUf#_7{7|0fB}?ajcjUd@ z-Q7`#E8>VWU8TS^Nh@i5ns^Ii=1~+$i49KnS!P8vw=cT5>2?_UzNl4-{GRTaK zj5rgX_N=?jHThB{@td^m&epuJw8R1*S<(0dT??wwQ++d33(Xyz`y_}AK$$wUCLqM;VZvV#0-p$)ld(Ft?+$M{vc4i z0s^-7_FRaO!NC|v{6!l!%1TKIXXp3tH#-x2C)=Z;P_65#GRkVP*^eMVpy`+#p~amb z%*puyY=s3%m-a@%J|!k9qZ(b7F);+e{kpok-E$%DLo1ZklP4HQM@I&xrW(%9`<~Lw z%*>5`7orsv6$sRR^94T!dZO3}`FH#|PIHs*KVebPL@4>=M@3Yl=PoV6?dtq*j34Qm zn?yg@RVR5^jxI}_v?rf0H6i>qs3O^sLx8DsSC-wuH) zSgNY34<9~knV+YRj*c#?u2z2fG(2{HVe+`nJVIM%5&Kr3@KAhMfoSTrD^ZbzcYySNxJ+g3X;k=;7f31^oP} zrj{;Ev)UaK3Wv#?n9!@Kskv;AuzgHQV&&o@0F`{=1OorC^o7Y8XLoogJV}2 zlKe_T7#Pqj`0Vg~GpN9o^4e2GBBkHnTzTmm7!XL)j*X4U@h4gKC-O~IzoKJdWqo05 z%duu_W5XgLL9@KP{2?kT7!GTjuCRS!XNQk^R;YvN{PJZH+TYTWRa#mag7)_Ipn%yL zXW6*AJ2z+C*M4)QNIpKk*j}rl;o(5T;*d|DXdtkDi}k()Y5-JWVPSL^oih^;4-tf( z_gY-;OW+ZF^eFhp582lq9?WrYuyokiELcD4wr`F3Ra{+#kbZtbz9){nX3YwUy-Xk;|2 zetA`-rmK6;=4UbnO25hHQCAdQXj@wwhsfQ8ganDaygbc$c5(k}>32av_yOnV=Z&tb zxD*r=1OdIhy~G3rFJc%Ti+lXm$x?H36SlOl*jia>OH90fvcH%Cyb1;4cPEzFQF>4gtxuz4bpkw8k`l`&Q<8i7^8D2#3LXYZiPWBJT59 z=;`S-ylp%hkoxxRTTXPeM(9;#O^vObTmTwu#zs$9_dghUd0t*fis&oy!>>g}b+2Yc zG0hPO0xEvvo-hgytz50)g@x<#!N9^oF3<(;^=bssjItW2$cTt+!(yBN{<{l~iy#0X z=<={%V0&u|j^gF#w*gy09ClKf<)oz0Ax1_=wTl)2kE5)Vm2rs(3E`;b=H?(FS}H0I zG=r39q@&Ry4LNyRW#vOmb9s48#BH1F>gqZ=I_8v=@PnnmQED0*HUMvnZ!ca&Gd%tb z^9Fm)%gGTG5s3#RKr!R;`n8q2y9j8$U#F*UP?VI81E~^07>3%~?G0Z0BVAn~kUsc6 zM)q1iHovS49mW+{@cp}RzSsVOhM4mLQdm`;V{7q;EH3E-d`nBqwY9aSp)7?qEh&o* z{JBPNiX;KEkhC=Vjh~;e0KbD$FaaFf*x1}cZ)IhrGTH)KT3!w`sIbW@FTV@KLJ=Gy zWZn{h0T3(hd%_z~&AJ+Zf#tH)f^kbpZEcu8Zmy+piK!t00Rd_nnyk7y8ay(Fj=wvT z%S%fESqhfg$?v&<$#tD!2Ua*|UH@e;lW#ra$k9Z)ih_u4?R}7%kIyc?*oxkD z`TVf9$oewoJrJ~EBU$8dUw!$J3dXNa-Y}zQi^M87;>kq5z)s9{?#y9K zY@M1o48s?8-%#u5=wRaJCM?J;`kEw`-7Lu`(bZpMQHK;4GJu z&vI@{vD_Xin>OI_TJa-o$|&FI^OLJZ?brGg3Y%4UXZ9O1d*&>YdW>0%UnRzdC;fQ4 zDM49nY;7y5s}tQf2XZSaM4}=i3!ZUO-?_u|hAbi?qVO4K{iS~Hfsdqw#N%Pl=8HY4 zR^PLnEi;C@N)~c?93hG-K@9g6rcl?FCJ0iQPq`YR~-z z52F!BC6x#ceoRXXz9Ky@W1VKlckAKze>Fa9)g**5uGH5q0^agGIXTE_7G(DfF<5a-TWGO2r zXTiLj1NwZYbagYszpLD`yUc6f6dMnZm4yX!zv&+XWY>!U0V4!pk0-C7;Cg;+51QG$ z_plEMRV>B&l|OiUENwQ$*#81g(`~9W zU;Mm>%SS0=+5JbCP`!gxsT)tsgo)!?_ra z{sBoyMwSnV`QmuHomC||7UqXU;#Yb<(oB<7f`Z!roF1%#a_1Bm^W|%1XrM07HZuqU z076H@eMW{7`Hb{UOy&#Khsw#5ja*KbwU5spe`1YE-Pp3s-=?7Jrqb+mMIs;IrHXe` zX{0Up8pVBEvSD{2(=Mw1F7e0GZIJe`rj(|9D&~G(NSekPs5SxxY}IA^(^#;%pdifR zWBbv(I2f>W*w)OwOH1Z_3nX-+v9RnfU+@FW-kz}`MkXfomOhC&GawF^THnbV0$YO^ zX>ARJ^o@*oYV#jeT67Yk)=EqoDrZRW@tJx(`Q1o%XR0EA#$&e#G@r^p3j)SVgpExp z!XLOm7{bKF1W0*2OeKnTJX%FlGlqnO#JJLKnDHU85)1qPVl)%Z)+xM)hk z3cZ5kzi8b=5&jn3XfLPi!GYI3hADxGw3&qr&I9yebfJk$5!3BVdzts5y3yC1sVc1i zj==Q<&Nq0yT;H9pz?+_)20pM0_-6D*iZdp3eKzRtaNxAqOb;z>ZsKupaGai>f2pdf zN=tH@EHSaOvkNFK72xHYWsEBN`gLi0n?PGzTTw{~1CqJ;Ba$lNj+>sIPW{M%GEXz3 zWV{4Ki^Idi+tw&<1d7t$)rITn=~=s2L`O?Y={TWG zAi#c>UeR3!hK229PbZ442 zf)LXyjKc`#s>$v?zQE-3FDZHy_wL<;0^(RzJh@Zj;_l*-&|(M6V<;#nK(8*OpkjU5 zO!aaLOUqy%aO@bF?I}%waI-QqA+18nLD?JW-#a_Z2~U9tGND1vA;OxUnwly>zI@4( znmWTjG&eVg-fP%z16~?9;?7F@Q5S%0(hJ4!+U*b7*l>X7+L|oQ(DO}9Oq{B;r$C`l zv9YlMz!h8m+ncv@a3FsJjF_Oq7$-A@xAL2mNWCBShl19XaNl54}S^JOgYmYK;7RWR; zHFb1!%%{p;fEQL!P*B<1D<8+j=B8KU&G~B}?x=u>c3;4h7(yQ$1cI2_e04JG&-YA4 zG%!7Z?Misi^>-A{@u18gm-nVb6;qgY1nNu{XLGw9Il!s5lJLY`e^)a26IQ;k|B}8a zqrPJGdlZ|Q+pMISp@9d0#?}@-^Axb>lYKSczgvJ^^H1{qo0dSV>A5*IFhO8`1%d!C z7Z)?MH(jAp#v}P9bPC&UmhgCg8plTq^zhI)j)RXu>xmDEO!{}MuJK=-)sNo&)W^ju z6ta@N$7JLFV9u1ZeYT%8>&us;t*MO-8zj0F51J{7eAG=(0vy%*mZ!hES-}E1IXPQ~ zvsIYmd&|sQF^hdR2ht*d<6{EoyE*Na&D1Isv>$*vx>)v%+&q&^OFbyH9kHL zB2yM{;-JU8_U5MdDvz)JEfP(373md|%NTA0tHPoF`4%MKD=R-bRDB+lxo~U{)hjhs zM@5E(dFQ-bB~55)=?WJq(w0c^Mjm-`+dj%2$-qfXN$QJVFcax~%T=m=`dMATzq2C? z1DTuOo>AWpM0DfxqnG-+x=N_VHwP@)+1Yiz|D3uyI?yT3&C3PNE3;<;-G$n51fAl$)Mv(-X;d{IC~S6koVNr2SJ*Zkxit}93{#H6G)%E}>` z(z4g5tbx^b8=#Q5I5@8R3r&F7*#oOTto^v!b^h7cX8~AHz_hUk&}1quE-t+jURYSz zYj<}`EiH1;a|Sv(9VireG>wSz5)m=6m7QGy`T+=5z+{>>`6Nh4NEn0E2u_)dL7H=p z&#ngqGu6PGT5`^B;zcrPfxK(Rf32IlkORM(ewsBkTZgRrB&vs-AAVR*wH6EbA}e&3 zMzFE6A`iG{W@_pgjQnwBqz<>=TIttZE&EUpWo2a)41i>NXGgWpcmQDg2zYf^@7d9& zY~r=w@vsUnH#d1Ym`*WBq#Cow56{h|Y86(RoWJw)zxq3Aprr+(giJm8l%eauE-}9q zvzaZw?YgOj+Ttr-kHzjI%Nm#RQAJv~RgA}B0}4cJILfj+dc1FEwnhLU%*?zT#@QO5 z+14iSw9t4KXIcwJU8$rBmWq%flLON`*I~Y&-o+RpUOr4e(PEBKvr&h6hL^fb@x6k! z0}sX~CRWyZ;|eIA+GOkZZ_llY(~7e4^43tsw;uq4TRJ+hGmwY9tVs!= zISf=)FBbF2clw}r=`IcSL3g#eT}8$2XRTyBi#0+|1@Aimr_033iUmmS&1#g`|NXC7 z)-&^^mcV2Y+W|}aeL!G60|RgWT!Dck8jY3%Dc;oYukP4{%%xJ37Y8%2uBgGCzDIMD;T3#hM`1Y;|eaI>8*e|})MZpTo$T47+y zU~#b036i`KWX_s-RZ$HIlD2#UBaj&I84pF3UHNBYz4xX+uL$P-t&-Z*ypGa3D!TLm+T+Z)Rz1WdHzp+MSknR8-d% zhtIutdZEoQ0#b(FyTAa_dy`&8VVD_UC<6{NG_fI~0ue<-nj%P0#DLLIBvwSR5EN9f z2P6n6F&ITuEN@2Ei>|D^_ww@l3o6c zm;e!*vpE?o5f_L!B}k0Z0NWkO#^@ z9q0f3Xv3lIchAu>dPU)xk0{A5EKc;LJ1HL z5<+>u$9dISw03U@r;Pdb`_%=KWKZEBGfDjQHqKX(I48#TTN1~8;gpaI8ijWGV z0cl0Lkv`-mGK$O~Z&4T&1w}_0qHIx~s8AFOwFb2wRf4KU9Y%GadQmq~W2jlwM>H9& zh}K8jpuNx$=mc~Yx)5D~ZbG-CFQRXwCx6hdF&GRDqm8k`cw!#HrxSaPGJ$91oX|tH2$>oxu&^ zCUFaRDZD1$2Jeq&<8$z(_(ps;{yKgFzd(>CXcO!RA%rBtCPF2lm2i>pfbfz?B!8+A zt%-p|E^#BVl6Z`GnK(v#OOhe!kz7d8Bq3=B=@980=`QIdnM~FqJCdWw0`d-WGx-Af z5&4Y-MZ!qJOM)%2L83;YLt;qcxg=gvQ_@LtwPdbjh2#mz>yk54cquI@7b&LHdZ`+z zlTss6bJ7%PQ)z$cROu4wBhpu-r+;LyGFmcjGHjUwnS(MHWX357MV;b8VNo_y8Yvek z6I2XUo9abPq83xXqYhAKWo2ZS$%e^h%ht%AmK~)bG%cDJErnJ}J5C#>y<4KR#Ayj< z$@V3!ONN%r%Pp02l;g-1$+gMdmU|~pmv@s-mft1cDgRIbrJ$z}sF0Amz>RYg@#RiSFV>VWEknzmY~TE1GF+Cz1MIzv5PyLvhF_J8+x#wgi;89Ete8nzgY z8PSY1jmyXF)a;mc^>(B7bo*HQ1NNg1st!zt z28YLv>W*y3CdWx9U4N$}r=w2KolTti&h5_gE;cUfT+X>7t{$#Mt^;l|ZlP|~Zjap6 z+!Nee+-E&3Jl1-g^F(|4c<%BX@lx_)c{O{@dRuv~^X~N_`2_n^`#kp5^X2 zj2>R4y()XvmDLKXQ&yjjk&I!+oQOrohQ}U>eb4k~HZbSnyy9x(W?3$*y{u`s_YbV#g7oZ-4~tGO?dJd^5@=9B%C4<&y}2~TND#ihok zp5)2!l6k#p%4ykYgX#L|h3TVfY}V{qGt2kkH)TK>t1`L-RMF2=zfecGML3pepIMXn zCMzuKM7DG`FS|cSFK2tsWUhPew`);rS!;XpRP#3Fjeo6kT35dwS|7K*XM_5Nf(;WJ zJvJWRMA($P>8E^?{IdL4o5MGE7bq2MEEwP7v8AO@qL5!WvekBL-8R%V?zVyL=G&{b ze=K4bT`e{#t|)$A!YaA?jp;X)-+bB;zhj`(vULAW%ue3U;av{94wp%n<(7@__S@Z2 zPA@Mie}AQwPOQFN<6P5Lt600ec77jw-_U-? z{jGIMb;Wh>4sZ|LsrRVwXwYh?IEXozdGJYNSYzL}jBlHp6q<^gJ{;m58a*6zxVPD= zx%r6Vkr^j5!`X2{BzCX?yfA&kpFYhM` zo{*nZOsY&aPnk`fns%SQ@pR?WiD&807FT8pf0h2V_PNgUAAWQEt$#LRcH#y9#i!p( zUdq2b^lI6wp1FXzN3T;~FU%Lck$-deE#qz9yYP3D3t8{6?<+s(e(3(_^YOu_)K8!O z1p}D#{E@&~+mRtJkzy2o5e!L0K~#9!?VJgik5%8thwLOfk&-2neXQ9+hU~isQ9?xu zkwS}?Y{`>^^2TJ3$MV``Y-1R+7{l0=v1Ki5$X0!y`*W`M{I7fd{-cqt#{919cg=m@ z|8phZO6uCRt72keoN3m79M0ei1VPiMPuD{aJ>*>VOX5V# z{rdF-2s<3kRX?qD70UTD58l2nf()k3AOW{;XNEs&nVgYS*rv(xy%8xz7Cs3Ka01 zXULF2Pe1*%InI$Ihk37UhcWg1^UoW@Dt-F&o^N*F52s6imrf;0lu*^GRrTC+L# z>U#L$hi~X_jT$x7vu95gE?n50V|#JzZc9HNfBbQCoHuXYc*o~XG5x)I^=gdYi4!Ld zF&Ot61Pd1~1clnYd$;+!di840Z>T40qs*H(Pv_2^(~m#?Xxd@r=E{}J9G^USQpb)R zGsle@H8Smg>(;Gn&VTypC!IfkUcdbEivbM3efi~==C|U-i<|QoUUhWy==5|Ni?bRjQP^UbbvmbG>21hI-Rl({}};zaG=zh4nvi zrHVO!XH|as>8GCSOy-CYBg`>U5@Myl`|i8uH+MgfI2SHlh$C^_Z2Lw#&XE*I86*h6 zaDxEAuUogy93MS;)L8KxH)+zuJi~(dPI0D8ndHp>K0vUKlY0$<@bGZYK*Ox$%a<=J zS+Zmb4i5Gp-$AMwfH`yKcm}~v-b*jNWW*+afLgqGv0i@pWi#QZ3;SHeH-zXNHf)$y zty*Oy&A4&nj2ORi<%&lVaGiU?!otjZY0tCQuU~Jjj~X?~fX&^HX3d(J=g*iiLz5>@ z*3_v}Z%|KmRkO-b8C=VrJ-aSmyl5uawwpbBwg&`A99(vnOJ^29q5}Z~Z_g3Uj(uW( zCXm6JG-;B#o-$=hefZ&rI&$QQ8Hl!R+Zz21p(a>`h*>5QF^d{-zlRAyYB1qneDQ^m z5&(zEXV95cUm##54jnpF8#it=l8NiXhY#1jefxZZVA`~43JeVNJm0&&UAlD9&Ye3= zTfjxX`2GeB8hF|ObPIxrhzMEw{rBI0Rl9cWJ3a^Z9R!GJ3j#zbE11FOJSr;6=+VrX zGpj|57M^>!zI^#|qXw>Dzi!k8*R6ZYbqG~r@0l`Xihlj|S98oNwK}(V@7|^@(#Pt1 zw>tRfqmMiWoRvB~di2ou-+v#cAFsUf3InNBsZ#muCx%}8_U%3A6DCa1sZ*zajKn*0 z=8Q)r!lzH4HqykZgYMnCtA73Z1_ah%OjIC1EJGn7A!el>K781SNPc6*pue$RA&f!* z0M)8h%cEy~STspGbPz^`4qX7vAt4I4~b3oz^iYk&d>0BOA<&fj_G9nbe1 zI&>)Ufq+%aAiVwd+r}Pn2di-X>_8&U2M!!)M7cE(vt-F)R){ZG41VUBXN;lu@y8!~ z+)5aO5~IxRGFqTn|>mFWyzgJlXHc2fg^>izW~RfBWsXCZR+$FDNKT_3G8T?*m3ai`)fq z1BmjwyZJucTd`(xFhM!)4p+V2Jj3fV*qQ};rF|Lk4fZEg;N%-K|bZpJEAS{SYhvsS6%oYkuQ zf2&n=W{AqnS*t0>W@y9ZK+QQbT^qGRyA`Uyh>BT=V{6csL3R(MRf8f`dBGZ0S-e(NmIkZFieQyo7^(_OL$vVJG-vWB zDd@sfgTC#+|LO=;4i44YU#99OO>m^a9L1cPq-$f}k>(7O zz8k73JsT-oru6YnB&!x85p=5{VDiWidS7QHKxFtVSRerB-FE!=@#Z%s-d%O%7Uv{| zAPQEzZ32=>oUE?Kf9PQ6`1nd};5SDu@H z$wZRxx6*(NB}65XcUx)|A?gya^eG(S*j*-uok7tGWYgRh1k~rTDj};XkT#*Ap{7`c zGBRJ^PaQ*iE0)?sYa=o7zH9thpW-faJAgIQH3sl9#xyrRno_fh@0(9{@lLO0_X42KGKq&(qTs` zIF4nj+C^^o0IG1HnKNg`+es#YR4WFZt@s@=SJ%KzV|h-dle;1exv2up+g5VfD~N# zs-2@FOybg|OYQzSldC7s55?zyG9vaM_EXyGV!Kkk*;W;^qKE*RB76s&Zc$2Aj~l2K z1gtE;1=)(IgfJkuS%C=E%9PrDUbRe&Q)s{b65FvS$l& zZw&-Fva8Xa2(>uA%S?K+{gG;MaFbdbj?%vlMye(NIJ8N-%5~Q1!p*dQr)&!yC|g_C z7C94eeYA9RuqKaa;J7~V+XT3Lwgj8{JYTMp1&1}7u=3Hx7CgS(G3pWR#9BZsTC~XL zH&}34_tUO=yaDbeG|kp5-b|(36a;C1b7oibgHdX8Zm(J%*{oK_qV=y6(Q0=xN&z~k_CIdcR{tJ4 zlD~tt*6gg=wr94e!}%?$ z??`}-hocoly-AM!^HZ5V9b1z`RWx}_P&jrOugzymTbyhz*+g1!? z9Fj@2^^X9KDrww6Vi<3|^_I^Z3B>yWK1Lv_50&HgmMA&1VPjOAHKLJ@Oe|7@$)-ND zbm`J@-a%O%L>}fZM-0UcFqO&tk;&}Dy&)|MHn=*RnLZ{4A~ zT5pKLo^7utx$@ms_>vXGpxWdNmO2weaEFdiFNpqiM-4IT*bIW6L^9AGkHOa_5X391 zj35jCG%la7{g)V_>~}z?+VXISJqos(naRZ{B{0N<+KS}9eft_i4IuFSs3l((IqCo# z0zHnAhiV{y0E7s4ODk-G(W6Jl*~NrJ0Q@W#o&yN!i+3{1+7NC4-#Q3#=TOHBJM_8^ zsmmYR)Y6dvU1GOsX~}U?Os!pm&X_5uslzeHE%Or1GVRS2=V@U^M)kFQdQ01$fr zPW_jE5bs@5cWRfn-9W?6CK62v1_8TLZ6L-Iq{*L0U35x=&R$ore~d;yGD!I{=Sx(R z?`8}z2+Q49<`G}qy^H8}i$#2ejBl5*tB9#!8zuB#4dCKBfQjg2aERhGmD8uL@7=y8YN0c%#_S>^HowzOr&<*8Oeklz}VeAq_ zvL^l&-@mnm11O5QcJ10W$A>(K3xO}0#Q$7AdGh3e3l}bs`QjfJ4kZ8Op7Z|#jqw*} TtukJ}00000NkvXXu0mjfPt@3v diff --git a/data/providers/skydrive.png b/data/providers/skydrive.png index 5e8f45a27f61cc08fedf8b7ddf5abf90d7a44d02..ebb6f016e82171108f823ef6c40e9df99244d5fe 100644 GIT binary patch literal 1261 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-s3dtTpz6=aiY77hwEes65fIO>_%)p?h48n{ROYO^m3Ql;s zIEHu}Pfn0vbrv>AV)r?tvnJ<_%nTt5lLDjS!p|Q*eH32l=n&vh!N}3k(IvRpF(!#o z#>2}~_=9m9O*S{O&~^ z;}-kz^gOOfm{ms}?fp1x2O=Ze=iE(U!5I(R#(Tdw$aW zzgX2uT@`rsCK)vTVq3`i!*Q`;I-!2>rq zKRZnqN#uQcm#4>eufR5y{cMT6VYLT3Ub8Qs#%d?5rY3wPz?5@}iHusaW$>OU99c80 zc<20BcK(IQTfe!H$;RCczwX_9cVcOq$>TQ*EPq^Ce*UP&^k<>x`!^kBoTV+?IJ0`e f>!v^leFlb0!fbIXR23D05zXM~>gTe~DWM4fR8ZoZ literal 3469 zcmV;84RZ2{P)|D^_ww@lRz|vCuzLs)$;-`! zo*{AqUjza0dRV*yaMRE;fKCVhpQKsoe1Yhg01=zBIT!& zC1$=TK@rP|Ibo3vKKm@PqnO#LJhq6%Ij6Hz*<$V$@wQAMN5qJ)hzm2hoGcOF60t^# zFqJFfH{#e-4l@G)6iI9sa9D{VHW4w29}?su;^hF~NC{tY+*d5%WDCTXa!E_i;d2ub z1#}&jF5T4HnnCyEWTkKf0>c0%E1Ah>(_PY1)0w;+02c53Su*0<(nUqKG_|(0G&D0Z z{i;y^b@OjZ+}lNZ8Th$p5Uu}MTtq^NHl z*T1?CO*}7&0ztZsv2j*bmJyf3G7=Z`5B*PvzoDiKdLpOAxi2$L0#SX*@cY_n(^h55xYX z#km%V()bZjV~l{*bt*u9?FT3d5g^g~#a;iSZ@&02Abxq_DwB(I|L-^bXThc7C4-yr zInE_0gw7K3GZ**7&k~>k0Z0NWkO#^@9q0fwx1%qjZ=)yBuQ3=5 z4Wo^*!gyjLF-e%Um=erBOdIALW)L%unZshS@>qSW9o8Sq#0s#5*edK%>{;v(b^`kb zN5rY%%y90wC>#%$kE_5P!JWYk;U;klcqzOl-UjcFXXA75rT9jCH~u<)0>40zCTJ7v z2qAyk54cquI@7b&LHdZ`+zlTss6bJ7%PQ)z$cROu4wBhpu-r)01)S~6}jY?%U? zgEALn#wiFzo#H}aQ8rT=DHkadR18&{>P1bW7E`~Y4p3)hWn`DhhRJ5j*2tcg9i<^O zEt(fCg;q*CP8+7ZTcWhYX$fb^_9d-LhL+6BEtPYWVlfK zTBusSTASKKb%HuWJzl+By+?gkLq)?+BTu761jmyXF)a;mc z^>(B7bo*HQ1NNg1st!zt28YLv>W*y3CdWx9U8f|cqfXDAO`Q48?auQqHZJR2&bcD4 z9Ip>EY~kKEPV6Wm+eXFV)D)_R=tM0@&p?(!V*Qu1PXHG9o^TY0bZ?)4%0 z1p8F`JoeS|<@=<@RE7GY07EYX@lwd>4oW|Yi!o+Su@M`;WuSK8LKk71XR(_ zRKHM1xJ5XYX`fk>`6eqY>qNG6HZQwBM=xi4&Sb88?zd}EYguc1@>KIS<&CX#T35dw zS|7K*XM_5Nf(;WJJvJWRMA($P>8E^?{IdL4o5MGE7bq2MEEwP7v8AO@qL5!WvekBL z-8R%V?zVyL=G&{be=K4bT`e{#t|)$A!YaA?jp;X)-+bB;zhj`(vULAW%ue3U;av{9 z4wp%n<(7@__S@Z2PA@Mif3+uO&y|X06?J#o zSi8M;ejj_^(0<4Lt#wLu#dYrva1Y$6_o(k^&}yhSh&h;f@JVA>W8b%oZ=0JGnu?n~ z9O4}sJsfnnx7n(>`H13?(iXTy*fM=I`sj`CT)*pTHEgYKqqP+u1IL8No_-(u{qS+0 z<2@%BCt82d{Gqm;(q7a7b>wu+b|!X?c13m#p7cK1({0<`{-e>4hfb-UsyQuty7Ua; zOu?B?XLHZaol8GAb3Wnxcu!2v{R_`T4=x`(GvqLI{-*2AOSimkUAw*F_TX^n z@STz9kDQ$NC=!KfXWC z8h`dn#xL(D3Z9UkR7|Q&Hcy#Notk!^zVUSB(}`#4&lYA1f0h2V_PNgUAAWQEt$#LR zcH#y9#i!p(Udq2b^lI6wp1FXzN3T;~FU%Lck$-deE#qz9yYP3D3t8{6?<+s(e(3(_ z^YOu_)K8!O1p}D#{Jgc%9RL6TAY({UO#lFTB>(_`g8%^e{{R4h=>PzAFaQARU;qF* zm;eA5Z<1fdMgRZ+32;bRa{vG?BLDy{BLR4&KXw2B0?tW9K~!ko?U-3e6=4*|Zxodf zm9(#7Xi!8FLD2HlrKClXpoMS&LyYi63-Y1W!U`(zsSwd#gdn0&>!qLtDsTgXb}S+y zh$vdfR;T}o|HMsZ`|h2&Gtu|(d%5?1bIpcO2Rn!rrZ zW)rj(Z@>;PED8cs!F7e;O@1(~(jqV)RDlzq0n~!!U?gZvB6yQ;pdd(r**r-;Sp4~C zaGOEc1^5Mgb&==>lY$Uf0QwYnbP(JEN5B@a8svjg-l=Cc>&pEWmQcy3Mbc@mlfXF8?(t$$pqBBW-2_g9-T;F)sc;e~ z_IQ!Yl$EM_Hw{52ve!;vvd7eU&e{-X|6`;Xx$_&ifqx0qu`hSKzyXlKLB$A>YwXYd z2(+@qJ1zRiypM+*yh#^F*53k!;GWBZ7cBc#5fKm$ffZ&h?emcTvpD`mMLj^n{N%tI?-c;WLnD1|LIKaFPA$aM2*ZA>XXdcUZ2M3eR vfazi@Q(}dAKnrLAEuaOoK$!dj`B`}^S)|f600000NkvXXu0mjfTIPl5 diff --git a/data/providers/wikipedia.png b/data/providers/wikipedia.png index 4a84436fa43d5a911d8600e97b28e8c4b9d17d0a..cd501b2aaaf3f86aa0f25596ca940835c86d021b 100644 GIT binary patch delta 510 zcmVfP?@5`Tzg`fam}Kbua(` z>RI+y?e7jT@qQ9J+u00Lr5M??VshmXv^00009a7bBm000XU000XU0RWnu7ytkP zg-Jv~R7l6IRa{m5g3A|2owgJ51pJl z*GZGAmk-ZIy47R%bN~RhjJ!7@TcqH0cXEy?tzHuCh7lG19>)z?kPcv5mi`X}55SxG z;~58hU&N09zSQUoKz6JN`FTbT+zG1q%E*CEkmtmSUPfznB$3oeQ<_Ym9k5t z#)M#$HL@Xt!G9ycPKjTunXqe~r+I}N)+&9VcHc}e%DHBj&NvVp6oF%{N(XuXW@^Gc zJ)KGq1bc-Q!9Wmda>6@;qe}4RIEH{CXINmpeq3DVf}mfB*DWyFs{3Cdh^&m5Q7jYG z__F#UMV0V7!C6el z#_Y+dTDd}y#cOB%ooHeGaD||gyU+TMbNTW%f-K&!*i(NiL8?T(UT554WA#mZ0^k*H z0QgI<|0?Z|UN>CqeZ`Gsi+$0nzDIF$1N; A-2eap literal 3203 zcmV-}41Dv6P)|D^_ww@lRz|vCuzLs)$;-`! zo*{AqUjza0dRV*yaMRE;fKCVhpQKsoe1Yhg01=zBIT!& zC1$=TK@rP|Ibo3vKKm@PqnO#LJhq6%Ij6Hz*<$V$@wQAMN5qJ)hzm2hoGcOF60t^# zFqJFfH{#e-4l@G)6iI9sa9D{VHW4w29}?su;^hF~NC{tY+*d5%WDCTXa!E_i;d2ub z1#}&jF5T4HnnCyEWTkKf0>c0%E1Ah>(_PY1)0w;+02c53Su*0<(nUqKG_|(0G&D0Z z{i;y^b@OjZ+}lNZ8Th$p5Uu}MTtq^NHl z*T1?CO*}7&0ztZsv2j*bmJyf3G7=Z`5B*PvzoDiKdLpOAxi2$L0#SX*@cY_n(^h55xYX z#km%V()bZjV~l{*bt*u9?FT3d5g^g~#a;iSZ@&02Abxq_DwB(I|L-^bXThc7C4-yr zInE_0gw7K3GZ**7&k~>k0Z0NWkO#^@9q0fwx1%qjZ=)yBuQ3=5 z4Wo^*!gyjLF-e%Um=erBOdIALW)L%unZshS@>qSW9o8Sq#0s#5*edK%>{;v(b^`kb zN5rY%%y90wC>#%$kE_5P!JWYk;U;klcqzOl-UjcFXXA75rT9jCH~u<)0>40zCTJ7v z2qAyk54cquI@7b&LHdZ`+zlTss6bJ7%PQ)z$cROu4wBhpu-r)01)S~6}jY?%U? zgEALn#wiFzo#H}aQ8rT=DHkadR18&{>P1bW7E`~Y4p3)hWn`DhhRJ5j*2tcg9i<^O zEt(fCg;q*CP8+7ZTcWhYX$fb^_9d-LhL+6BEtPYWVlfK zTBusSTASKKb%HuWJzl+By+?gkLq)?+BTu761jmyXF)a;mc z^>(B7bo*HQ1NNg1st!zt28YLv>W*y3CdWx9U8f|cqfXDAO`Q48?auQqHZJR2&bcD4 z9Ip>EY~kKEPV6Wm+eXFV)D)_R=tM0@&p?(!V*Qu1PXHG9o^TY0bZ?)4%0 z1p8F`JoeS|<@=<@RE7GY07EYX@lwd>4oW|Yi!o+Su@M`;WuSK8LKk71XR(_ zRKHM1xJ5XYX`fk>`6eqY>qNG6HZQwBM=xi4&Sb88?zd}EYguc1@>KIS<&CX#T35dw zS|7K*XM_5Nf(;WJJvJWRMA($P>8E^?{IdL4o5MGE7bq2MEEwP7v8AO@qL5!WvekBL z-8R%V?zVyL=G&{be=K4bT`e{#t|)$A!YaA?jp;X)-+bB;zhj`(vULAW%ue3U;av{9 z4wp%n<(7@__S@Z2PA@Mif3+uO&y|X06?J#o zSi8M;ejj_^(0<4Lt#wLu#dYrva1Y$6_o(k^&}yhSh&h;f@JVA>W8b%oZ=0JGnu?n~ z9O4}sJsfnnx7n(>`H13?(iXTy*fM=I`sj`CT)*pTHEgYKqqP+u1IL8No_-(u{qS+0 z<2@%BCt82d{Gqm;(q7a7b>wu+b|!X?c13m#p7cK1({0<`{-e>4hfb-UsyQuty7Ua; zOu?B?XLHZaol8GAb3Wnxcu!2v{R_`T4=x`(GvqLI{-*2AOSimkUAw*F_TX^n z@STz9kDQ$NC=!KfXWC z8h`dn#xL(D3Z9UkR7|Q&Hcy#Notk!^zVUSB(}`#4&lYA1f0h2V_PNgUAAWQEt$#LR zcH#y9#i!p(Udq2b^lI6wp1FXzN3T;~FU%Lck$-deE#qz9yYP3D3t8{6?<+s(e(3(_ z^YOu_)K8!O1p}D#{Fkv~6#xJLAY({UO#lFTB>(_`g8%^e{{R4h=>PzAFaQARU;qF* zm;eA5Z<1fdMgRZ+32;bRa{vGf6951U69E94oEQKA0mMl}K~z}7?N@EFgfI+50uqpb z1SB8<2}q~|Bp?9^NI(J-kkGs3UEVAuDIfRl`sZb)GdGu}*=)K2vg~Evd-q(6|GXiG z%h;ZOO#b^eapkGZWnZG*Y)9r3+dqI6fOF1V^E~^$?{E3Xaa@-byDZBOfUfI&Q4}7c z;MFwEx@i~&UzX*@m*=@}+xFLARn^9a*lC*9h2I>DT*$d=0UuJ=^^Pw5$KZB!zLF!U z6&uEF0Dvy80@bmBZp$yRQdwxIT01j~RjD1ubh00DNTL~9g#GCIp$eDobodKz*Pk&?^`0OY|Weql$uyq5uJl9cK#me~I%?*lA3^g7f%4<=#6 znhUo8u;et|^Z2$#_*(!%$!X)6S+d6NTd!n7tyP_{bVho&0K^`td>Ju2KK4>7?{P7Z pSE?5P$v;feewro!I8FU|{s0N@lHtW*&NKi3002ovPDHLkV1kBu3kLuI From 7bfe32c7df6af9d9c281d54a2070902ee5b488b8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Apr 2015 23:22:53 +0200 Subject: [PATCH 16/17] Avoid warning message when the level exceeds the threshold --- ext/libclementine-common/core/logging.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/libclementine-common/core/logging.cpp b/ext/libclementine-common/core/logging.cpp index b0a3564d8..3b1fdb72b 100644 --- a/ext/libclementine-common/core/logging.cpp +++ b/ext/libclementine-common/core/logging.cpp @@ -104,6 +104,7 @@ void Init() { sClassLevels = new QMap(); sNullDevice = new NullDevice; + sNullDevice->open(QIODevice::ReadWrite); // Catch other messages from Qt if (!sOriginalMessageHandler) { From 0938e81711f4439614467eeeca2debc3874f0abc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Apr 2015 10:38:38 +0200 Subject: [PATCH 17/17] Avoid "QFSFileEngine::open: No file name specified" messages if we know that the filename is empty --- src/covers/albumcoverloader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/covers/albumcoverloader.cpp b/src/covers/albumcoverloader.cpp index 8ebf51cce..a1a4582ef 100644 --- a/src/covers/albumcoverloader.cpp +++ b/src/covers/albumcoverloader.cpp @@ -196,6 +196,9 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage( QMetaObject::invokeMethod(spotify, "LoadImage", Qt::QueuedConnection, Q_ARG(QString, id)); return TryLoadResult(true, false, QImage()); + } else if (filename.isEmpty()) { + // Avoid "QFSFileEngine::open: No file name specified" messages if we know that the filename is empty + return TryLoadResult(false, false, task.options.default_output_image_); } QImage image(filename);