diff options
1055 files changed, 22038 insertions, 5923 deletions
diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..8e36231c21 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,16 @@ +Checks: "\ + performance-faster-string-find,\ + performance-for-range-copy,\ + performance-implicit-conversion-in-loop,\ + performance-inefficient-algorithm,\ + performance-inefficient-vector-operation,\ + performance-move-const-arg,\ + performance-move-constructor-init,\ + performance-no-automatic-move,\ + performance-noexcept-move-constructor,\ + performance-trivially-destructible,\ + performance-type-promotion-in-math-fn,\ + performance-unnecessary-copy-initialization,\ + performance-unnecessary-value-param,\ +" +HeaderFilterRegex: '(^|/)(tools|xbmc)/' diff --git a/.github/workflows/gh-action-weblate-upload.yml b/.github/workflows/gh-action-weblate-upload.yml new file mode 100644 index 0000000000..34493398f7 --- /dev/null +++ b/.github/workflows/gh-action-weblate-upload.yml @@ -0,0 +1,28 @@ +# This GitHub action updates the translation (msgmrge) based on the changed source language file + +name: Update Weblate translations + +on: + push: + branches: + - master + paths: + - "addons/resource.language.en_gb/resources/strings.po" + - ".github/workflows/gh-action-weblate-upload.yml" +jobs: + weblate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.2 + with: + fetch-depth: 0 + - name: Update Weblate + env: + TOKEN: "${{ secrets.WEBLATE_TOKEN }}" + run: | + curl \ + --form file=@addons/resource.language.en_gb/resources/strings.po \ + --form method=source \ + -H "Authorization: Token $TOKEN" \ + https://kodi.weblate.cloud/api/translations/kodi-core/kodi-main/en_gb/file/ diff --git a/.gitignore b/.gitignore index 0d9778728d..19c200efe5 100644 --- a/.gitignore +++ b/.gitignore @@ -99,6 +99,7 @@ cmake_install.cmake /kodi.bin /kodi-test /kodi-xrandr +/*.diff /*.patch /kodi-build*/ /gtestresults.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ff1a7dd63..348bef4048 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,6 +225,7 @@ add_custom_command(OUTPUT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp ${ADDON_XML_OUTPUTS} COMMAND ${CMAKE_COMMAND} -DCORE_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} + -DCORE_PLATFORM_NAME_LC="${CORE_PLATFORM_NAME_LC}" -DCORE_BUILD_DIR=${CORE_BUILD_DIR} -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} -DARCH_DEFINES="${ARCH_DEFINES}" @@ -308,9 +309,12 @@ set_target_properties(lib${APP_NAME_LC} PROPERTIES PREFIX "") set(OTHER_FILES cmake/README.md) # Subdirs +foreach(CORE_PLATFORM_LC ${CORE_PLATFORM_NAME_LC}) + core_add_subdirs_from_filelist(${CMAKE_SOURCE_DIR}/cmake/treedata/common/${CORE_PLATFORM_LC}/*.txt + ${CMAKE_SOURCE_DIR}/cmake/treedata/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_LC}/*.txt) +endforeach() + core_add_subdirs_from_filelist(${CMAKE_SOURCE_DIR}/cmake/treedata/common/*.txt - ${CMAKE_SOURCE_DIR}/cmake/treedata/common/${CORE_PLATFORM_NAME_LC}/*.txt - ${CMAKE_SOURCE_DIR}/cmake/treedata/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}/*.txt ${CMAKE_SOURCE_DIR}/cmake/treedata/${CORE_SYSTEM_NAME}/*.txt) core_add_optional_subdirs_from_filelist(${CMAKE_SOURCE_DIR}/cmake/treedata/optional/common/*.txt ${CMAKE_SOURCE_DIR}/cmake/treedata/optional/${CORE_SYSTEM_NAME}/*.txt) diff --git a/addons/metadata.themoviedb.org.python/LICENSE.txt b/addons/metadata.themoviedb.org.python/LICENSE.txt new file mode 100644 index 0000000000..a814663c2b --- /dev/null +++ b/addons/metadata.themoviedb.org.python/LICENSE.txt @@ -0,0 +1,328 @@ +Valid-License-Identifier: GPL-2.0-or-later +SPDX-URL:https://spdx.org/licenses/GPL-2.0-or-later.html +Usage-Guide: + To use the GNU General Public License v2.0 or later put the following SPDX + tag/value pair into a comment according to the placement guidelines in + the licensing rules documentation: + SPDX-License-Identifier: GPL-2.0-or-later +License-Text: + +GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. + +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software +is covered by the GNU Lesser General Public License instead.) You can apply +it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you +wish), that you receive source code or can get it if you want it, that you +can change the software or use pieces of it in new free programs; and that +you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or +for a fee, you must give the recipients all the rights that you have. You +must make sure that they, too, receive or can get the source code. And you +must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If +the software is modified by someone else and passed on, we want its recipients +to know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will individually +obtain patent licenses, in effect making the program proprietary. To prevent +this, we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms +of this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or translated +into another language. (Hereinafter, translation is included without limitation +in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running the Program +is not restricted, and the output from the Program is covered only if its +contents constitute a work based on the Program (independent of having been +made by running the Program). Whether that is true depends on what the Program +does. + +1. You may copy and distribute verbatim copies of the Program's source code +as you receive it, in any medium, provided that you conspicuously and appropriately +publish on each copy an appropriate copyright notice and disclaimer of warranty; +keep intact all the notices that refer to this License and to the absence +of any warranty; and give any other recipients of the Program a copy of this +License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, +thus forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + +a) You must cause the modified files to carry prominent notices stating that +you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or +in part contains or is derived from the Program or any part thereof, to be +licensed as a whole at no charge to all third parties under the terms of this +License. + +c) If the modified program normally reads commands interactively when run, +you must cause it, when started running for such interactive use in the most +ordinary way, to print or display an announcement including an appropriate +copyright notice and a notice that there is no warranty (or else, saying that +you provide a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this License. +(Exception: if the Program itself is interactive but does not normally print +such an announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Program, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Program. + +In addition, mere aggregation of another work not based on the Program with +the Program (or with a work based on the Program) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under Section +2) in object code or executable form under the terms of Sections 1 and 2 above +provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, +which must be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give +any third party, for a charge no more than your cost of physically performing +source distribution, a complete machine-readable copy of the corresponding +source code, to be distributed under the terms of Sections 1 and 2 above on +a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for noncommercial +distribution and only if you received the program in object code or executable +form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy the +source code from the same place counts as distribution of the source code, +even though third parties are not compelled to copy the source along with +the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except +as expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses terminated +so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Program or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Program +(or any work based on the Program), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor +to copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of +the rights granted herein. You are not responsible for enforcing compliance +by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed +on you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of +this License. If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Program at all. For example, if a +patent license would not permit royalty-free redistribution of the Program +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system, which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Program under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of +the General Public License from time to time. Such new versions will be similar +in spirit to the present version, but may differ in detail to address new +problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Program does not specify a version number of this License, you may choose +any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing and reuse +of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE +OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES +OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + +<one line to give the program's name and an idea of what it does.> + +Copyright (C) <yyyy> <name of author> + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301 , USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when +it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author Gnomovision comes +with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, +and you are welcome to redistribute it under certain conditions; type `show +c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than `show w' and `show c'; they could even be mouse-clicks +or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' +(which makes passes at compilers) written by James Hacker. + +< signature of Ty Coon > , 1 April 1989 Ty Coon, President of Vice This General +Public License does not permit incorporating your program into proprietary +programs. If your program is a subroutine library, you may consider it more +useful to permit linking proprietary applications with the library. If this +is what you want to do, use the GNU Lesser General Public License instead +of this License. diff --git a/addons/metadata.themoviedb.org.python/README.md b/addons/metadata.themoviedb.org.python/README.md new file mode 100644 index 0000000000..be0fc744d0 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/README.md @@ -0,0 +1,14 @@ +## The Movie Database Python scraper for Kodi + +This is early work on a Python movie scraper for Kodi. + +### Manual search by IMDB / TMDB ID +When manually searching you can enter an IMDB or TMDB ID to pull up an exact movie result. +To search by TMDB enter "tmdb/" then the ID, like "tmdb/11". To search by IMDB ID enter it directly. + +## Development info + +### How to run unit tests + +`python -m unittest discover -v` from the main **metadata.themoviedb.org.python** directory. +Python 3 only. diff --git a/addons/metadata.themoviedb.org.python/addon.xml b/addons/metadata.themoviedb.org.python/addon.xml new file mode 100644 index 0000000000..93fcb2f8a7 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/addon.xml @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<addon id="metadata.themoviedb.org.python" + name="The Movie Database Python" + version="1.3.0+matrix.1" + provider-name="Team Kodi"> + <requires> + <import addon="xbmc.metadata" version="2.1.0"/> + <import addon="xbmc.python" version="3.0.0"/> + </requires> + <extension point="xbmc.metadata.scraper.movies" + library="python/scraper.py"/> + <extension point="xbmc.addon.metadata"> + <reuselanguageinvoker>true</reuselanguageinvoker> + <news>v1.3.0 (2020-10-04) +- Change: removed dependencies on requests, tmdbsimple, and trakt modules +- Change: images now returned with initial API call instead of during fallback +- Change: settings language for TMDb now use culture name (i.e. en-US) - required for direct API call + +v1.2.1 (2020-08-08) +- Fix: Prefer movies that exactly match search title and year +- Fix: Change 'landscape from TMDb' option disabled behavior to keep titled fanart +</news> + <summary lang="af_ZA">TMDB Fliek Skraper</summary> + <summary lang="be_BY">TMDB Movie Scraper</summary> + <summary lang="bg_BG">Сваля инф. за филми от TMDB</summary> + <summary lang="ca_ES">Arreplegador de pel·lícules TMDB</summary> + <summary lang="cs_CZ">Zdroj zisku dat k filmům TMDB</summary> + <summary lang="cy_GB">Crafwr Ffilmiau TMDB</summary> + <summary lang="da_DK">TMDB Scraper til Film</summary> + <summary lang="de_DE">TMDB Filmscraper</summary> + <summary lang="el_GR">Scraper Ταινιών του TMDb</summary> + <summary lang="en_GB">Python TMDB Movie Scraper</summary> + <summary lang="en_NZ">Python TMDB Movie Scraper</summary> + <summary lang="en_US">Python TMDB Movie Scraper</summary> + <summary lang="es_ES">Scraper de películas de TheMovieDB</summary> + <summary lang="es_AR">Scraper de Películas de TheMovieDB</summary> + <summary lang="es_MX">Scraper de Películas TMDb</summary> + <summary lang="et_EE">TMDB Filmi kaabits</summary> + <summary lang="fi_FI">TMDB elokuvatietojen lataaja</summary> + <summary lang="fr_FR">Collecteur de Films TMDB</summary> + <summary lang="fr_CA">Extracteur de films TMDB</summary> + <summary lang="gl_ES">Scraper de Filme de TMDB</summary> + <summary lang="he_IL">TMDB סקרייפר סרטים</summary> + <summary lang="hr_HR">TMDB filmski sakupljač informacija</summary> + <summary lang="hu_HU">TMDB filmadat leolvasó</summary> + <summary lang="id_ID">Pengais Film TMDB</summary> + <summary lang="is_IS">TMDB Skafa fyrir Kvikmyndir</summary> + <summary lang="it_IT">Ricercatore per TMDB Movie</summary> + <summary lang="ja_JP">TMDB映画のスクレーパー</summary> + <summary lang="ko_KR">TMDB 영화 정보수집기</summary> + <summary lang="lt_LT">TMDB filmų skreperis</summary> + <summary lang="mk_MK">TMDB инфо за филмови</summary> + <summary lang="ml_IN">മൂവി ഡി ബി, വിവരശേഖരം</summary> + <summary lang="ms_MY">Pengikis Cakera TMDB</summary> + <summary lang="my_MM">TMDB Movie Scraper</summary> + <summary lang="nl_NL">TMDb-filmscraper</summary> + <summary lang="nb_NO">TMDB-skraper</summary> + <summary lang="pl_PL">Ekstraktor filmowy TMDB</summary> + <summary lang="pt_PT">Colector de filmes TMDb</summary> + <summary lang="pt_BR">Scraper de Filmes TMDb</summary> + <summary lang="ro_RO">Scraper de filme TMDb</summary> + <summary lang="ru_RU">Инфоресурс на базе TMDB</summary> + <summary lang="se">Skrapa för TMDb</summary> + <summary lang="sk_SK">TheMovieDB filmový sťahovač</summary> + <summary lang="sl_SI">Ponudnik informacij o filmih TMDB</summary> + <summary lang="sv_SE">TMDB Filmskrapa</summary> + <summary lang="ta_IN">LastFM நிகழ்படம் சுரண்டி</summary> + <summary lang="th_TH">ตัวรับข้อมูลภาพยนต์ TMDB</summary> + <summary lang="tr_TR">TMDB Film Scraper</summary> + <summary lang="uk_UA">TMDB — джерело інформації про фільми</summary> + <summary lang="vi_VN">Trình lấy dữ liệu Phim từ TMDB</summary> + <summary lang="zh_CN">TMDB 电影刮削器</summary> + <summary lang="zh_TW">TMDB 電影搜括器</summary> + <description lang="af_ZA">themoviedb.org is 'n verniet en oop fliek databasis. Dit is totaal gebruiker gedryf deur mense soos jy. TMDB word huidiglik deur miljoene mense elke maand gebruik, en met hulle kragtige API word dit ook deur baie gewilde media sentrums soos Kodi gebruik om Fliek Metadata, Plakkate en Ondersteunerkuns te onttrek om die gebruiker se ondervinding te verryk.</description> + <description lang="be_BY">themoviedb.org is a free and open movie database. It's completely user driven by people like you. TMDb is currently used by millions of people every month and with their powerful API, it is also used by many popular media centers like Kodi to retrieve Movie Metadata, Posters and Fanart to enrich the user's experience.</description> + <description lang="bg_BG">themoviedb.org е безплатна и отворена филмова база данни. Задвижва се изцяло от потребителите си, от хора като вас. Милиони хора по света всеки месец ползват TMDb. Благодарение на многофункционално API може да се ползва от най-различни и популярни медийни центрове като Kodi, които извличат метаданни, постери и фанарт за филми с цел за красивото оформяне на интерфейса.</description> + <description lang="ca_ES">themoviedb.org és una base de dades oberta i lliure. Es manté completament per usuaris, per gent com tu. TMDb s'utilitza actualment per milions de persones cada mes i amb la seva potent API també és utilitzada per molts centre media populas com l'Kodi per obtenir les meta-dades de pel·lícules, pósters i fanart per enriquir l'experiència d'usuari.</description> + <description lang="cs_CZ">themoviedb.org je otevřená a svobodná databáze filmů. Je řízena uživateli, tedy lidmi jako vy. TMDB je každý měsíc používána milióny lidí a se svým výborným API je také používano mnoha populárními mediálními centry jako je Kodi, k získávání metadat, plagátů a fanartu filmů pro obohacení uživatelského zážitku.</description> + <description lang="cy_GB">Mae themoviedb.org yn gronfa ddata ffilmiau rhydd ac agored. Mae'n cael ei yrru gan ddefnyddwyr fel chi. Mae TMDb yn cael ei ddefnyddio gan filiynau o bobl bob mis a gyda'i API pwerus, mae'n cael ei ddefnyddio gan lawer o'r canolfannau cyfrwng fel Kodi i estyn metadata ffilmiau, posteri a chelf er mwyn cyfoethogi profiad defnyddwyr.</description> + <description lang="da_DK">themoviedb.org er en fri og åben filmdatabase. Den er helt og aldeles brugerdrevet af folk som dig. TMDb bruges i dag af millioner af mennesker hver måned, og med deres kraftfulde API er den også brugt af mange populære mediecentre såsom Kodi til at hente metadata, plakater og fankunst til film, for at berige brugerens oplevelse.</description> + <description lang="de_DE">TheMovieDB.org ist eine freie und offene Filmdatenbank. Sie wird von Benutzern wie dir angetrieben. TheMovieDB wird zur Zeit von millionen Nutzern jeden Monat genutzt und dank ihrer mächtigen API ist sie auch von vielen Media-Center, wie z.B. Kodi, implementiert, um Film-Metadaten, -Poster und -Fanarts zu beziehen, die das Benutzererlebnis verbessern.</description> + <description lang="el_GR">Το themoviedb.org είναι μία δωρεάν και ανοικτή βάση δεδομένων ταινιών. Διαχειρίζεται πλήρως από ανθρώπους σαν και εσάς. Το TMDb χρησιμοποιείται από εκατομμύρια ανθρώπους κάθε μήνα, και με το πανίσχυρο API τους, χρησιμοποιείται και από πολλά δημοφιλή κέντρα πολυμέσων όπως το Kodi για να λαμβάνουν μετα-δεδομένα Ταινιών, Αφίσες και Fanart για εμπλουτισμό της εμπειρίας του χρήστη.</description> + <description lang="en_GB">themoviedb.org is a free and open movie database. It's completely user driven by people like you. TMDb is currently used by millions of people every month and with their powerful API, it is also used by many popular media centers like Kodi to retrieve Movie Metadata, Posters and Fanart to enrich the user's experience.</description> + <description lang="en_NZ">themoviedb.org is a free and open movie database. It's completely user driven by people like you. TMDb is currently used by millions of people every month and with their powerful API, it is also used by many popular media centers like Kodi to retrieve Movie Metadata, Posters and Fanart to enrich the user's experience.</description> + <description lang="en_US">themoviedb.org is a free and open movie database. It's completely user driven by people like you. TMDb is currently used by millions of people every month and with their powerful API, it is also used by many popular media centers like Kodi to retrieve Movie Metadata, Posters and Fanart to enrich the user's experience.</description> + <description lang="es_ES">themovieDB.org es una base de datos de películas gratuita y abierta. Es una página web que se basa en contenido subido por los usuarios. TMDb es usada diariamente por mucha gente gracias a su API, que es usada por más programas aparte de Kodi para descargar información de películas así como Posters o Fanart (Fondos de escritorio basados en películas usados en distintos skins) para enriquecer la experiencia de usar Kodi.</description> + <description lang="es_AR">themovieDB.org es una base de datos de películas gratuita y abierta. Está formada con contenido subido por usuarios como vos. TMDb es actualmente utilizada por millones de personas cada mes y, gracias a su poderosa API, es usada por muchos programas populares como Kodi para descargar Información de Películas, Posters y Fanart para enriquecer la experiencia de usar Kodi.</description> + <description lang="es_MX">themoviedb.org es una base de datos de películas gratis y abierta. Es completamente manejada por usuarios y personas como tu. Actualmente TMDb es usada por millones de personas cada mes, y dado a su poderosa API, es usada también por varios media centers populares como Kodi para obtener Metada de Películas, Posters y Fanarts, enriqueciendo de esta manera la experiencia del usuario.</description> + <description lang="et_EE">themoviedb.org on tasuta ja vaba juurdepääsuga filmide andmebaas.See on täielikult koostatud sinu sarnaste inimeste poolt. TMDb on hetkel igapäevaselt kasutuses miljonite inimeste poolt ja seda kasutavad paljud populaarsed meediakeskused, nagu ka Kodi, filmiandmete, fännikunsti ja posterite leidmiseks.</description> + <description lang="fi_FI">themoviedb.org on vapaa ja avoin elokuvatietokanta. Se on täysin käyttäjien ylläpitämä. TMDb:a käyttää miljoonat ihmiset joka kuukausi, sitä käytetään käyttäjäkokemuksen rikastuttamiseen monissa muissakin suosituissa Kodi:n kaltaisissa ohjelmissa lataamalla elokuvien tietoja, julisteita ja fanitaidetta.</description> + <description lang="fr_FR">themoviedb.org est une base de données gratuite et libre d'accès de films. Elle est totalement gérée par les utilisateurs. TMDb est actuellement utilisée par des millions de personnes chaque mois et, grâce à ses puissantes fonctions et routines, elle est également utilisée par de nombreux Media Centers populaires comme Kodi aux fins de récupération des Métadonnées, Posters et Fanarts des films en vue d'améliorer l'expérience de l'utilisateur.</description> + <description lang="fr_CA">themoviedb.org est une base de données libre et ouverte. Elle est complètement gérée par des gens comme vous. TMDb est actuellement utilisée par des millions de personnes chaque mois et avec son API puissante, elle est également utilisée par de nombreux centres multimédias populaires comme Kodi pour récupérer les métadonnées des films, les affiches et le fanart afin d'enrichir l'expérience de l'utilisateur.</description> + <description lang="gl_ES">themoviedb.org é una base de datos sobre filmes libre e aberta, impulsada por xente coma ti. Na actualidade TMDb é usada por millóns de persoas todos os meses, e grazas ó seu potente API, usado por algúns dos centros multimedia máis populares como Kodi para obter a información dos filmes, Posters e Fanart e así mellorar a experiencia do usuario.</description> + <description lang="he_IL">themoviedb.org is a free and open movie database. It's completely user driven by people like you. TMDb is currently used by millions of people every month and with their powerful API, it is also used by many popular media centers like Kodi to retrieve Movie Metadata, Posters and Fanart to enrich the user's experience.</description> + <description lang="hr_HR">themoviedb.org je besplatna i otvorena baza filmskih podataka. TMDb trenutno koriste milijuni ljudi svaki mjesec uz pomoću njegovog snažnog API-ja, isto tako se koristi u mnogim popularnim medijskim centrima poput Kodi-a, kako bi mogli sakupljati informacije o filmovima, filmske postere, omote filmova i na kraju obogatili korisničko iskustvo.</description> + <description lang="hu_HU">A themoviedb.org egy ingyenes és nyílt filmadatbázis. Teljes egészében olyan felhasználók töltik fel, mint például Te. A TMDb-t havonta emberek milliói használják és a hatékony API-n keresztül számos népszerű média center is, mint például az Kodi a filmadatok, poszterek, fanartképek letöltésére.</description> + <description lang="id_ID">themoviedb.org adalah database film yang gratis dan terbuka. Ini benar-benar digerakkan oleh orang-orang seperti Anda. TMDb saat ini digunakan oleh jutaan orang setiap bulannya dan dengan APInya yang digdaya, juga digunakan oleh beberapa pusat media seperti Kodi untuk mengambil Metadata Film, Poster dan Fanart untuk menperkaya pengalaman penggunanya.</description> + <description lang="is_IS">themoviedb.org er frír og opinn gagnagrunnur. Hann er algjörlega rekinn af fólki eins og þér. TMBd er notaður af milljónum manna í hverjum mánuði og með öflugum forritaskilum þeirra (API), er hann líka notaður af mörgum vinsælum heimabíókerfum eins og Kodi til að ná í Ítarupplýsingar yfir Kvikmyndir, Veggspjöld og Fanart til að lífga upplifun notandans.</description> + <description lang="it_IT">themoviedb.org è un database libero e aperto. E' gestito da utenti e persone come te. Viene usato correntemente da millioni di persone ogni mese e con le sue potenti API, è anche utilizzato da molti popolari media centers come Kodi per ottenere Metadati, Posters e Fanart di film per arricchire la loro esperienza utente.</description> + <description lang="ja_JP">themoviedb.org は自由でオープンな映画データベースです。その運営は、完全にユーザ主導で行われています。TMDb は現在毎月何百万人もの人に利用されているほか、Kodi のようなメディアセンターも、TMDb のパワフルな API を介して映画メタデータ、ポスター、ファンアートを取得し、使い勝手を向上させるなどして使っています。</description> + <description lang="ko_KR">themoviedb.org 는 전적으로 여러분 같은 이용자가 주도하는 무료 공개 영화 데이터베이스입니다. TMDb 는 현재 매월 수백만의 사람들이 강력한 API와 함께 사용하고 있을 뿐만 아니라 Kodi 같은 많은 미디어 센터가 영화 정보, 포스터, 팬아트를 가져와 풍성한 사용자 경험을 제공하는데 이용되고 있습니다.</description> + <description lang="lt_LT">themoviedb.org yra nemokama ir atvira filmų duomenų bazė. Ji palaikoma tokių pat vartotojų kaip ir jūs. TMDb šiuo metu naudojama milijonų žmonių kiekvieną mėnesį ir turi galingą API, o taip pat naudojama daugelio populiarių media centrų, tokių kaip Kodi, kad gautų filmų metaduomenis, plakatus ir Fanart, siekiant praturtinti vartotojo patirtį.</description> + <description lang="mk_MK">themoviedb.org is a free and open movie database. It's completely user driven by people like you. TMDb is currently used by millions of people every month and with their powerful API, it is also used by many popular media centers like Kodi to retrieve Movie Metadata, Posters and Fanart to enrich the user's experience.</description> + <description lang="ml_IN">മൂവി ഡി ബി, എല്ലാവർക്കും കൈവക്കാവുന്ന ഒരു സൗജന്യ വിവരശേഖരമാണ്. ഇതുമൂലം ലോകം മുഴുവനും സിനിമാ പോസ്റ്ററുകൾ എല്ലവരും കാണുന്നു</description> + <description lang="ms_MY">themoviedb.org adalah pangkalan data cakera terbuka. Ia sepenuhnya dipacu oleh individu seperti anda. TMDb buat masa ini diguna oleh berjuta-juta individu setiap bulan dan dengan API hebat mereka, ia juga digunakan oleh banyak pusat media popular seperti Kodi untuk mendapatkan Data Meta, Poster, Seni Peminat Cereka untuk memperkayakan pengalaman pengguna.</description> + <description lang="nl_NL">Themoviedb.org is een vrije en open filmdatabank. Gebruikers zoals jij vormen de motor van deze site. Op dit moment gebruiken elke maand miljoenen mensen TMDb. De krachtige API van de site laat mediacenters zoals Kodi toe om metadata, posters en fanart op te halen en zo de gebruikerservaring te verrijken.</description> + <description lang="nb_NO">themoviedb.org er en fir og åpen filmdatabase. Den drives helt og fullt av mennesker som deg. TMDB brukes av millioner av mennesker hver måned og med sitt gode API, brukes den også av mange popluære mediasenterløsninger som Kodi for å hente metadata for filmer, plakater og fanart for å gi en bedre brukeropplevelse.</description> + <description lang="pl_PL">themoviedb.org jest wolną i otwartą filmową bazą danych, zarządzaną przez osoby takie jak Ty. Obecnie odwiedzają ją miliony osób miesięcznie, a dzięki dostępności interfejsu programistycznego jest używana przez wiele centrów multimedialnych takich jak Kodi, jako źródło informacji o filmach, plakatów i tapet.</description> + <description lang="pt_PT">O themoviedb.org é uma base de dados de filmes livre e aberta. É actualizado inteiramente por pessoas como você e usado por milhões todos os meses. Com o poderoso motor de busca disponível, também se tornou no favorito para muitos programas de centro de média, como o popular Kodi, para obter informação, posters e fanart que enriquecem a experiência do utilizador.</description> + <description lang="pt_BR">O themoviedb.org é um banco de dados aberto e gratuito. É completamente operado por pessoas como você. O TMDb é atualmente usado por milhares de pessoas a cada mês e com sua poderosa API, é usado por muitas centrais de mídia populares como o Kodi para buscar metadados, cartazes e fanart de filmes para enriquecer a experiência do usuário.</description> + <description lang="ro_RO">themoviedb.org este o bază de date de filme gratuită și deschisă. Este actualizată de oameni ca și tine. TMDb este curent folosită de milioane de oameni în fiecare lună și datorită API-ului puternic, este de asemena folosită de multe centre media populare ca Kodi pentru a obține informații despre filme, afișe și imagini produse de fani (Fanart) care îmbogățesc experiența utilizatorului.</description> + <description lang="ru_RU">themoviedb.org — это бесплатная и открытая база данных фильмов. Она полностью поддерживается обычными людьми. В данный момент сайт TMDb используют миллионы людей каждый месяц, и благодаря мощному API его могут использовать различные популярные медиацентры, такие как Kodi, чтобы получать метаданные, постеры и фанарт для фильмов с целью красивого оформления интерфейса.</description> + <description lang="se">themoviedb.org är en fri och öppen filmdatabas. Det drivs helt av människor som dig. TMDb används av miljontals människor varje månad och med deras kraftfulla API, är det också använt av många populära mediacenter som Kodi för att hämta filmmetadata, omslag och fanart för att förgylla användarens upplevelse.</description> + <description lang="sk_SK">themoviedb.org je voľná a otvorená databáza filmov. Je výlučne vedená užívateľmi ako si ty. TMDb je každý mesiac používaná miliónmi ľudí, a vďaka svojmu výkonnému API je veľmi populárna medzi 'media centrami' ako Kodi pre sťahovanie filmových metadát, plagátov a fanartov pre obohatenie zážitkov.</description> + <description lang="sl_SI">themoviedb.org je brezplačna in prosta baza filmov. Je v celoti ustvarjena s strani uporabnikov kot ste vi. TMDB uporablja miljone ljudi in z njihovo močno API, jo lahko uporabljate tudi v multimedijskih centrih kot Kodi, s tem prenesete informacije o filmih, plakate in ozadja ter s tem popestrite uporabniško izkušnjo.</description> + <description lang="sv_SE">themoviedb.org är en gratis och öppen filmdatabas. Den drivs helt av människor som du. TMDb används för närvarande av miljoner människor varje månad och med deras kraftfulla API används den även av många populära mediacenter som t.ex. Kodi för att hämta metadata om filmer, affischer och fanart för att berika användarens upplevelse.</description> + <description lang="ta_IN">themoviedb.org ஒரு இலவச மற்றும் திறந்த திரைப்பட தரவுத்தளம் ஆகும். இந்த தரவுத்தளம் முற்றிலும் பயனர் மக்களால் இயக்கப்படுகிறது. TMDb அவர்களது சக்திவாய்ந்த API இனால் தற்போது பல இலட்சக்கணக்கான மக்களால் ஒவ்வொரு மாதமும் பயன்படுத்தப்படுகிறது, இது Kodi போன்ற பல பிரபல ஊடக மையங்களில் பயனர் அனுபவத்தை மேம்படுத்த பயன்படுத்தப்படுகிறது.</description> + <description lang="th_TH">themoviedb.org เป็นฐานข้อมูลภาพยนตร์ที่ฟรีและเปิดกว้าง. มันถูกขับเคลื่อนจากผู้ใช้ โดยคนเช่นคุณ. TMDb ปัจจุบันมีการใช้โดยคนนับล้านในแต่ละเดือน และมีประสิทธิภาพด้วย API ของพวกเขา , มันยังถูกใช้โดยหลายศูนย์สื่อที่นิยมเช่น Kodi เพื่อดึง อธิบายข้อมูลภาพยนตร์, โปสเตอร์และ แฟนอาร์ต เพื่อเพิ่มประสบการณ์ของผู้ใช้</description> + <description lang="tr_TR">themoviedb.org ücretsiz ve herkese açık bir film veri tabanıdır. Tamamen kullanıcılar tarafından oluşturulmakta ve yönetilmektedir. TMDb her ay milyonlarca kullanıcı tarafından kullanılmakta ve güçlü API'si sayesinde Kodi gibi bir çok popüler medya merkezi tarafından Film Veritabanı, Poster ve Fanart bilgilerini kullanarak kullanıcı deneyimini zenginleştirmektedir.</description> + <description lang="uk_UA">themoviedb.org - це безкоштовна і відкрита база даних фільмів. Вона повністю підтримується звичайними людьми. В даний момент сайт TMDb використовують мільйони людей кожен місяць, і завдяки потужному API, його можуть використовувати різні популярні медіацентри, такі як Kodi, щоб отримувати метадані, постери і фанарт для фільмів з метою оформлення інтерфейсу.</description> + <description lang="vi_VN">themoviedb.org là cơ sở dữ liệu về phim ảnh mở và miễn phí. Nó hoàn toàn được kiểm soát bởi những người như bạn. TMDb hiện tại đang được sử dụng bởi hàng triệu người dùng hàng tháng và với sự hỗ trợ của bộ API mạnh mẽ nó cũng được sử dụng bởi những thiết bị giải trí cá nhân như Kodi cho việc lấy dữ liệu về Phim ảnh, Poster và Fanart để làm tăng trải nghiệm của người sử dụng</description> + <description lang="zh_CN">themoviedb.org 是一个开放和自由的电影数据库。它完全由象你一样的用户来掌控。TMDb 每月为上百万用户提供服务,并通过强大的 API 界面为许多流行的媒体中心系统如 Kodi 提供电影资料、封面海报和同人画以丰富用户的体验。</description> + <description lang="zh_TW">themoviedb.org是一個免費和開放的電影資料庫。它是完全由與您一樣的廣大使用者來更新資訊。 TMDb目前擁有數以百萬計的使用人次並且有著強大的API,許多受歡迎的媒體中心平台像Kodi藉由TMDb獲取電影的數據資料庫,海報和影片資訊,以豐富使用者體驗。</description> + <platform>all</platform> + <license>GPL-2.0-or-later</license> + <forum>https://forum.kodi.tv/showthread.php?tid=344580</forum> + <website>https://www.themoviedb.org</website> + <source>https://github.com/xbmc/metadata.themoviedb.org.python</source> + <assets> + <icon>resources/icon.png</icon> + </assets> + </extension> +</addon> diff --git a/addons/metadata.themoviedb.org.python/python/lib/__init__.py b/addons/metadata.themoviedb.org.python/python/lib/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/__init__.py diff --git a/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/__init__.py b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/__init__.py new file mode 100644 index 0000000000..f10f26379a --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/__init__.py @@ -0,0 +1,17 @@ + +def get_imdb_id(uniqueids): + imdb_id = uniqueids.get('imdb') + if not imdb_id or not imdb_id.startswith('tt'): + return None + return imdb_id + +# example format for scraper results +_ScraperResults = { + 'info', + 'ratings', + 'uniqueids', + 'cast', + 'available_art', + 'error', + 'warning' # not handled +} diff --git a/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/api_utils.py b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/api_utils.py new file mode 100644 index 0000000000..26f5028581 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/api_utils.py @@ -0,0 +1,77 @@ +# coding: utf-8 +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +"""Functions to interact with various web site APIs.""" + +from __future__ import absolute_import, unicode_literals + +import json, xbmc +# from pprint import pformat +try: #PY2 / PY3 + from urllib2 import Request, urlopen + from urllib2 import URLError + from urllib import urlencode +except ImportError: + from urllib.request import Request, urlopen + from urllib.error import URLError + from urllib.parse import urlencode +try: + from typing import Text, Optional, Union, List, Dict, Any # pylint: disable=unused-import + InfoType = Dict[Text, Any] # pylint: disable=invalid-name +except ImportError: + pass + +HEADERS = {} + + +def set_headers(headers): + HEADERS.update(headers) + + +def load_info(url, params=None, default=None, resp_type = 'json'): + # type: (Text, Optional[Dict[Text, Union[Text, List[Text]]]]) -> Union[dict, list] + """ + Load info from external api + + :param url: API endpoint URL + :param params: URL query params + :default: object to return if there is an error + :resp_type: what to return to the calling function + :return: API response or default on error + """ + theerror = '' + if params: + url = url + '?' + urlencode(params) + xbmc.log('Calling URL "{}"'.format(url), xbmc.LOGDEBUG) + req = Request(url, headers=HEADERS) + try: + response = urlopen(req) + except URLError as e: + if hasattr(e, 'reason'): + theerror = {'error': 'failed to reach the remote site\nReason: {}'.format(e.reason)} + elif hasattr(e, 'code'): + theerror = {'error': 'remote site unable to fulfill the request\nError code: {}'.format(e.code)} + if default is not None: + return default + else: + return theerror + if resp_type.lower() == 'json': + resp = json.loads(response.read().decode('utf-8')) + else: + resp = response.read().decode('utf-8') + # xbmc.log('the api response:\n{}'.format(pformat(resp)), xbmc.LOGDEBUG) + return resp diff --git a/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/fanarttv.py b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/fanarttv.py new file mode 100644 index 0000000000..f19cb1cb66 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/fanarttv.py @@ -0,0 +1,87 @@ +from . import api_utils +try: + from urllib import quote +except ImportError: # py2 / py3 + from urllib.parse import quote + +API_KEY = '384afe262ee0962545a752ff340e3ce4' +API_URL = 'https://webservice.fanart.tv/v3/movies/{}' + +ARTMAP = { + 'movielogo': 'clearlogo', + 'hdmovielogo': 'clearlogo', + 'hdmovieclearart': 'clearart', + 'movieart': 'clearart', + 'moviedisc': 'discart', + 'moviebanner': 'banner', + 'moviethumb': 'landscape', + 'moviebackground': 'fanart', + 'movieposter': 'poster' +} + +def get_details(uniqueids, clientkey, language, set_tmdbid): + media_id = _get_mediaid(uniqueids) + if not media_id: + return {} + + movie_data = _get_data(media_id, clientkey) + movieset_data = _get_data(set_tmdbid, clientkey) + if not movie_data and not movieset_data: + return {} + + movie_art = {} + movieset_art = {} + if movie_data: + movie_art = _parse_data(movie_data, language) + if movieset_data: + movieset_art = _parse_data(movieset_data, language) + movieset_art = {'set.' + key: value for key, value in movieset_art.items()} + + available_art = movie_art + available_art.update(movieset_art) + + return {'available_art': available_art} + +def _get_mediaid(uniqueids): + for source in ('tmdb', 'imdb', 'unknown'): + if source in uniqueids: + return uniqueids[source] + +def _get_data(media_id, clientkey): + headers = {'api-key': API_KEY} + if clientkey: + headers['client-key'] = clientkey + api_utils.set_headers(headers) + fanarttv_url = API_URL.format(media_id) + return api_utils.load_info(fanarttv_url, default={}) + +def _parse_data(data, language): + result = {} + for arttype, artlist in data.items(): + if arttype not in ARTMAP: + continue + for image in artlist: + image_lang = _get_imagelanguage(arttype, image) + if image_lang and image_lang != language: + continue + + generaltype = ARTMAP[arttype] + if generaltype == 'poster' and not image_lang: + generaltype = 'keyart' + if artlist and generaltype not in result: + result[generaltype] = [] + + url = quote(image['url'], safe="%/:=&?~#+!$,;'@()*[]") + resultimage = {'url': url, 'preview': url.replace('.fanart.tv/fanart/', '.fanart.tv/preview/')} + result[generaltype].append(resultimage) + + return result + +def _get_imagelanguage(arttype, image): + if 'lang' not in image or arttype == 'moviebackground': + return None + if arttype in ('movielogo', 'hdmovielogo', 'hdmovieclearart', 'movieart', 'moviebanner', + 'moviethumb', 'moviedisc'): + return image['lang'] if image['lang'] not in ('', '00') else 'en' + # movieposter may or may not have a title and thus need a language + return image['lang'] if image['lang'] not in ('', '00') else None diff --git a/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/imdbratings.py b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/imdbratings.py new file mode 100644 index 0000000000..eba96b131b --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/imdbratings.py @@ -0,0 +1,72 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# IMDb ratings based on code in metadata.themoviedb.org.python by Team Kodi +# pylint: disable=missing-docstring + +import re +from . import api_utils +from . import get_imdb_id + +IMDB_RATINGS_URL = 'https://www.imdb.com/title/{}/' +IMDB_RATING_REGEX = re.compile(r'itemprop="ratingValue".*?>.*?([\d.]+).*?<') +IMDB_VOTES_REGEX = re.compile(r'itemprop="ratingCount".*?>.*?([\d,]+).*?<') +IMDB_TOP250_REGEX = re.compile(r'Top Rated Movies #(\d+)') + +def get_details(uniqueids): + imdb_id = get_imdb_id(uniqueids) + if not imdb_id: + return {} + votes, rating, top250 = _get_ratinginfo(imdb_id) + return _assemble_imdb_result(votes, rating, top250) + +def _get_ratinginfo(imdb_id): + response = api_utils.load_info(IMDB_RATINGS_URL.format(imdb_id), default = '', resp_type='text') + return _parse_imdb_result(response) + +def _assemble_imdb_result(votes, rating, top250): + result = {} + if top250: + result['info'] = {'top250': top250} + if votes and rating: + result['ratings'] = {'imdb': {'votes': votes, 'rating': rating}} + return result + +def _parse_imdb_result(input_html): + rating = _parse_imdb_rating(input_html) + votes = _parse_imdb_votes(input_html) + top250 = _parse_imdb_top250(input_html) + + return votes, rating, top250 + +def _parse_imdb_rating(input_html): + match = re.search(IMDB_RATING_REGEX, input_html) + if (match): + return float(match.group(1)) + return None + +def _parse_imdb_votes(input_html): + match = re.search(IMDB_VOTES_REGEX, input_html) + if (match): + return int(match.group(1).replace(',', '')) + return None + +def _parse_imdb_top250(input_html): + match = re.search(IMDB_TOP250_REGEX, input_html) + if (match): + return int(match.group(1)) + return None diff --git a/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdb.py b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdb.py new file mode 100644 index 0000000000..7ce9422daf --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdb.py @@ -0,0 +1,241 @@ +from datetime import datetime, timedelta +from . import tmdbapi + + +class TMDBMovieScraper(object): + def __init__(self, url_settings, language, certification_country): + self.url_settings = url_settings + self.language = language + self.certification_country = certification_country + self._urls = None + + @property + def urls(self): + if not self._urls: + self._urls = _load_base_urls(self.url_settings) + return self._urls + + def search(self, title, year=None): + search_media_id = _parse_media_id(title) + if search_media_id: + if search_media_id['type'] == 'tmdb': + result = _get_movie(search_media_id['id'], self.language, True) + result = [result] + else: + response = tmdbapi.find_movie_by_external_id(search_media_id['id'], language=self.language) + theerror = response.get('error') + if theerror: + return 'error: {}'.format(theerror) + result = response.get('movie_results') + if 'error' in result: + return result + else: + response = tmdbapi.search_movie(query=title, year=year, language=self.language) + theerror = response.get('error') + if theerror: + return 'error: {}'.format(theerror) + result = response['results'] + urls = self.urls + + def is_best(item): + return item['title'].lower() == title and ( + not year or item.get('release_date', '').startswith(year)) + if result and not is_best(result[0]): + best_first = next((item for item in result if is_best(item)), None) + if best_first: + result = [best_first] + [item for item in result if item is not best_first] + + for item in result: + if item.get('poster_path'): + item['poster_path'] = urls['preview'] + item['poster_path'] + if item.get('backdrop_path'): + item['backdrop_path'] = urls['preview'] + item['backdrop_path'] + return result + + def get_details(self, uniqueids): + media_id = uniqueids.get('tmdb') or uniqueids.get('imdb') + details = self._gather_details(media_id) + if not details: + return None + if details.get('error'): + return details + return self._assemble_details(**details) + + def _gather_details(self, media_id): + movie = _get_movie(media_id, self.language) + if not movie or movie.get('error'): + return movie + + # don't specify language to get English text for fallback + movie_fallback = _get_movie(media_id) + + collection = _get_moviecollection(movie['belongs_to_collection'].get('id'), self.language) if \ + movie['belongs_to_collection'] else None + collection_fallback = _get_moviecollection(movie['belongs_to_collection'].get('id')) if \ + movie['belongs_to_collection'] else None + + return {'movie': movie, 'movie_fallback': movie_fallback, 'collection': collection, + 'collection_fallback': collection_fallback} + + def _assemble_details(self, movie, movie_fallback, collection, collection_fallback): + info = { + 'title': movie['title'], + 'originaltitle': movie['original_title'], + 'plot': movie.get('overview') or movie_fallback.get('overview'), + 'tagline': movie.get('tagline') or movie_fallback.get('tagline'), + 'studio': _get_names(movie['production_companies']), + 'genre': _get_names(movie['genres']), + 'country': _get_names(movie['production_countries']), + 'credits': _get_cast_members(movie['casts'], 'crew', 'Writing', ['Screenplay', 'Writer', 'Author']), + 'director': _get_cast_members(movie['casts'], 'crew', 'Directing', ['Director']), + 'premiered': movie['release_date'], + 'tag': _get_names(movie['keywords']['keywords']) + } + + if 'countries' in movie['releases']: + certcountry = self.certification_country.upper() + for country in movie['releases']['countries']: + if country['iso_3166_1'] == certcountry and country['certification']: + info['mpaa'] = country['certification'] + break + + trailer = _parse_trailer(movie.get('trailers', {}), movie_fallback.get('trailers', {})) + if trailer: + info['trailer'] = trailer + if collection: + info['set'] = collection.get('name') or collection_fallback.get('name') + info['setoverview'] = collection.get('overview') or collection_fallback.get('overview') + if movie.get('runtime'): + info['duration'] = movie['runtime'] * 60 + + ratings = {'themoviedb': {'rating': float(movie['vote_average']), 'votes': int(movie['vote_count'])}} + uniqueids = {'tmdb': movie['id'], 'imdb': movie['imdb_id']} + cast = [{ + 'name': actor['name'], + 'role': actor['character'], + 'thumbnail': self.urls['original'] + actor['profile_path'] + if actor['profile_path'] else "", + 'order': actor['order'] + } + for actor in movie['casts'].get('cast', []) + ] + available_art = _parse_artwork(movie, collection, self.urls, self.language) + + _info = {'set_tmdbid': movie['belongs_to_collection'].get('id') + if movie['belongs_to_collection'] else None} + + return {'info': info, 'ratings': ratings, 'uniqueids': uniqueids, 'cast': cast, + 'available_art': available_art, '_info': _info} + +def _parse_media_id(title): + if title.startswith('tt') and title[2:].isdigit(): + return {'type': 'imdb', 'id':title} # IMDB ID works alone because it is clear + title = title.lower() + if title.startswith('tmdb/') and title[5:].isdigit(): # TMDB ID + return {'type': 'tmdb', 'id':title[5:]} + elif title.startswith('imdb/tt') and title[7:].isdigit(): # IMDB ID with prefix to match + return {'type': 'imdb', 'id':title[5:]} + return None + +def _get_movie(mid, language=None, search=False): + details = None if search else \ + 'trailers,images,releases,casts,keywords' if language is not None else \ + 'trailers' + response = tmdbapi.get_movie(mid, language=language, append_to_response=details) + theerror = response.get('error') + if theerror: + return 'error: {}'.format(theerror) + else: + return response + +def _get_moviecollection(collection_id, language=None): + if not collection_id: + return None + details = 'images' + response = tmdbapi.get_collection(collection_id, language=language, append_to_response=details) + theerror = response.get('error') + if theerror: + return 'error: {}'.format(theerror) + else: + return response + +def _parse_artwork(movie, collection, urlbases, language): + posters = [] + landscape = [] + fanart = [] + if 'images' in movie: + posters = _get_images_with_fallback(movie['images']['posters'], urlbases, language) + landscape = _get_images(movie['images']['backdrops'], urlbases, language) + fanart = _get_images(movie['images']['backdrops'], urlbases, None) + + setposters = [] + setlandscape = [] + setfanart = [] + if collection and 'images' in collection: + setposters = _get_images_with_fallback(collection['images']['posters'], urlbases, language) + setlandscape = _get_images(collection['images']['backdrops'], urlbases, language) + setfanart = _get_images(collection['images']['backdrops'], urlbases, None) + + return {'poster': posters, 'landscape': landscape, 'fanart': fanart, + 'set.poster': setposters, 'set.landscape': setlandscape, 'set.fanart': setfanart} + +def _get_images_with_fallback(imagelist, urlbases, language, language_fallback='en'): + images = _get_images(imagelist, urlbases, language) + + # Add backup images + if language != language_fallback: + images.extend(_get_images(imagelist, urlbases, language_fallback)) + + # Add any images if nothing set so far + if not images: + images = _get_images(imagelist, urlbases) + + return images + +def _get_images(imagelist, urlbases, language='_any'): + result = [] + for img in imagelist: + if language != '_any' and img['iso_639_1'] != language: + continue + result.append({ + 'url': urlbases['original'] + img['file_path'], + 'preview': urlbases['preview'] + img['file_path'], + }) + return result + +def _get_date_numeric(datetime_): + return (datetime_ - datetime(1970, 1, 1)).total_seconds() + +def _load_base_urls(url_settings): + urls = {} + urls['original'] = url_settings.getSettingString('originalUrl') + urls['preview'] = url_settings.getSettingString('previewUrl') + last_updated = url_settings.getSettingString('lastUpdated') + if not urls['original'] or not urls['preview'] or not last_updated or \ + float(last_updated) < _get_date_numeric(datetime.now() - timedelta(days=30)): + conf = tmdbapi.get_configuration() + if conf: + urls['original'] = conf['images']['secure_base_url'] + 'original' + urls['preview'] = conf['images']['secure_base_url'] + 'w780' + url_settings.setSetting('originalUrl', urls['original']) + url_settings.setSetting('previewUrl', urls['preview']) + url_settings.setSetting('lastUpdated', str(_get_date_numeric(datetime.now()))) + return urls + +def _parse_trailer(trailers, fallback): + if trailers.get('youtube'): + return 'plugin://plugin.video.youtube/?action=play_video&videoid='+trailers['youtube'][0]['source'] + if fallback.get('youtube'): + return 'plugin://plugin.video.youtube/?action=play_video&videoid='+fallback['youtube'][0]['source'] + return None + +def _get_names(items): + return [item['name'] for item in items] if items else [] + +def _get_cast_members(casts, casttype, department, jobs): + result = [] + if casttype in casts: + for cast in casts[casttype]: + if cast['department'] == department and cast['job'] in jobs and cast['name'] not in result: + result.append(cast['name']) + return result diff --git a/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdbapi.py b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdbapi.py new file mode 100644 index 0000000000..47674643db --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/tmdbapi.py @@ -0,0 +1,132 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring + +"""Functions to interact with TMDb API.""" + +from . import api_utils +import xbmc +try: + from typing import Optional, Text, Dict, List, Any # pylint: disable=unused-import + InfoType = Dict[Text, Any] # pylint: disable=invalid-name +except ImportError: + pass + + +HEADERS = ( + ('User-Agent', 'Kodi Movie scraper by Team Kodi'), + ('Accept', 'application/json'), +) +api_utils.set_headers(dict(HEADERS)) + +TMDB_PARAMS = {'api_key': 'f090bb54758cabf231fb605d3e3e0468'} +BASE_URL = 'https://api.themoviedb.org/3/{}' +SEARCH_URL = BASE_URL.format('search/movie') +FIND_URL = BASE_URL.format('find/{}') +MOVIE_URL = BASE_URL.format('movie/{}') +COLLECTION_URL = BASE_URL.format('collection/{}') +CONFIG_URL = BASE_URL.format('configuration') + + +def search_movie(query, year=None, language=None): + # type: (Text) -> List[InfoType] + """ + Search for a movie + + :param title: movie title to search + :param year: the year to search (optional) + :param language: the language filter for TMDb (optional) + :return: a list with found movies + """ + xbmc.log('using title of %s to find movie' % query, xbmc.LOGDEBUG) + theurl = SEARCH_URL + params = _set_params(None, language) + params['query'] = query + if year is not None: + params['year'] = str(year) + return api_utils.load_info(theurl, params=params) + + +def find_movie_by_external_id(external_id, language=None): + # type: (Text) -> List[InfoType] + """ + Find movie based on external ID + + :param mid: external ID + :param language: the language filter for TMDb (optional) + :return: the movie or error + """ + xbmc.log('using external id of %s to find movie' % external_id, xbmc.LOGDEBUG) + theurl = FIND_URL.format(external_id) + params = _set_params(None, language) + params['external_source'] = 'imdb_id' + return api_utils.load_info(theurl, params=params) + + + +def get_movie(mid, language=None, append_to_response=None): + # type: (Text) -> List[InfoType] + """ + Get movie details + + :param mid: TMDb movie ID + :param language: the language filter for TMDb (optional) + :append_to_response: the additional data to get from TMDb (optional) + :return: the movie or error + """ + xbmc.log('using movie id of %s to get movie details' % mid, xbmc.LOGDEBUG) + theurl = MOVIE_URL.format(mid) + return api_utils.load_info(theurl, params=_set_params(append_to_response, language)) + + +def get_collection(collection_id, language=None, append_to_response=None): + # type: (Text) -> List[InfoType] + """ + Get movie collection information + + :param collection_id: TMDb collection ID + :param language: the language filter for TMDb (optional) + :append_to_response: the additional data to get from TMDb (optional) + :return: the movie or error + """ + xbmc.log('using collection id of %s to get collection details' % collection_id, xbmc.LOGDEBUG) + theurl = COLLECTION_URL.format(collection_id) + return api_utils.load_info(theurl, params=_set_params(append_to_response, language)) + + +def get_configuration(): + # type: (Text) -> List[InfoType] + """ + Get configuration information + + :return: configuration details or error + """ + xbmc.log('getting configuration details', xbmc.LOGDEBUG) + return api_utils.load_info(CONFIG_URL, params=TMDB_PARAMS.copy()) + + +def _set_params(append_to_response, language): + params = TMDB_PARAMS.copy() + img_lang = 'en,null' + if language is not None: + params['language'] = language + img_lang = '%s,en,null' % language[0:2] + if append_to_response is not None: + params['append_to_response'] = append_to_response + if 'images' in append_to_response: + params['include_image_language'] = img_lang + return params diff --git a/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/traktratings.py b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/traktratings.py new file mode 100644 index 0000000000..7e24d5ea2c --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/lib/tmdbscraper/traktratings.py @@ -0,0 +1,55 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring + +"""Functions to interact with Trakt API.""" + +from __future__ import absolute_import, unicode_literals + +from . import api_utils +from . import get_imdb_id +try: + from typing import Optional, Text, Dict, List, Any # pylint: disable=unused-import + InfoType = Dict[Text, Any] # pylint: disable=invalid-name +except ImportError: + pass + + +HEADERS = ( + ('User-Agent', 'Kodi Movie scraper by Team Kodi'), + ('Accept', 'application/json'), + ('trakt-api-key', '5f2dc73b6b11c2ac212f5d8b4ec8f3dc4b727bb3f026cd254d89eda997fe64ae'), + ('trakt-api-version', '2'), + ('Content-Type', 'application/json'), +) +api_utils.set_headers(dict(HEADERS)) + +MOVIE_URL = 'https://api.trakt.tv/movies/{}' + + +def get_trakt_ratinginfo(uniqueids): + imdb_id = get_imdb_id(uniqueids) + result = {} + url = MOVIE_URL.format(imdb_id) + params = {'extended': 'full'} + movie_info = api_utils.load_info(url, params=params, default={}) + if(movie_info): + if 'votes' in movie_info and 'rating' in movie_info: + result['ratings'] = {'trakt': {'votes': int(movie_info['votes']), 'rating': float(movie_info['rating'])}} + elif 'rating' in movie_info: + result['ratings'] = {'trakt': {'rating': float(movie_info['rating'])}} + return result diff --git a/addons/metadata.themoviedb.org.python/python/scraper.py b/addons/metadata.themoviedb.org.python/python/scraper.py new file mode 100644 index 0000000000..8561d6d357 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/scraper.py @@ -0,0 +1,170 @@ +import json +import sys +import xbmc +import xbmcaddon +import xbmcgui +import xbmcplugin + +from lib.tmdbscraper.tmdb import TMDBMovieScraper +from lib.tmdbscraper.fanarttv import get_details as get_fanarttv_artwork +from lib.tmdbscraper.imdbratings import get_details as get_imdb_details +from lib.tmdbscraper.traktratings import get_trakt_ratinginfo +from scraper_datahelper import combine_scraped_details_info_and_ratings, \ + combine_scraped_details_available_artwork, find_uniqueids_in_text, get_params +from scraper_config import configure_scraped_details, PathSpecificSettings, \ + configure_fanarttv_artwork, configure_tmdb_artwork, is_fanarttv_configured + +ADDON_SETTINGS = xbmcaddon.Addon() +ID = ADDON_SETTINGS.getAddonInfo('id') + +def log(msg, level=xbmc.LOGDEBUG): + xbmc.log(msg='[{addon}]: {msg}'.format(addon=ID, msg=msg), level=level) + +def get_tmdb_scraper(settings): + language = settings.getSettingString('language') + certcountry = settings.getSettingString('tmdbcertcountry') + return TMDBMovieScraper(ADDON_SETTINGS, language, certcountry) + +def search_for_movie(title, year, handle, settings): + log("Find movie with title '{title}' from year '{year}'".format(title=title, year=year), xbmc.LOGINFO) + title = _strip_trailing_article(title) + search_results = get_tmdb_scraper(settings).search(title, year) + if not search_results: + return + if 'error' in search_results: + header = "The Movie Database Python error searching with web service TMDB" + xbmcgui.Dialog().notification(header, search_results['error'], xbmcgui.NOTIFICATION_WARNING) + log(header + ': ' + search_results['error'], xbmc.LOGWARNING) + return + + for movie in search_results: + listitem = _searchresult_to_listitem(movie) + uniqueids = {'tmdb': str(movie['id'])} + xbmcplugin.addDirectoryItem(handle=handle, url=build_lookup_string(uniqueids), + listitem=listitem, isFolder=True) + +_articles = [prefix + article for prefix in (', ', ' ') for article in ("the", "a", "an")] +def _strip_trailing_article(title): + title = title.lower() + for article in _articles: + if title.endswith(article): + return title[:-len(article)] + return title + +def _searchresult_to_listitem(movie): + movie_info = {'title': movie['title']} + movie_label = movie['title'] + + movie_year = movie['release_date'].split('-')[0] if movie.get('release_date') else None + if movie_year: + movie_label += ' ({})'.format(movie_year) + movie_info['year'] = movie_year + + listitem = xbmcgui.ListItem(movie_label, offscreen=True) + + listitem.setInfo('video', movie_info) + if movie['poster_path']: + listitem.setArt({'thumb': movie['poster_path']}) + + return listitem + +# Low limit because a big list of artwork can cause trouble in some cases +# (a column can be too large for the MySQL integration), +# and how useful is a big list anyway? Not exactly rhetorical, this is an experiment. +IMAGE_LIMIT = 10 + +def add_artworks(listitem, artworks): + for arttype, artlist in artworks.items(): + if arttype == 'fanart': + continue + for image in artlist[:IMAGE_LIMIT]: + listitem.addAvailableArtwork(image['url'], arttype) + + fanart_to_set = [{'image': image['url'], 'preview': image['preview']} + for image in artworks['fanart'][:IMAGE_LIMIT]] + listitem.setAvailableFanart(fanart_to_set) + +def get_details(input_uniqueids, handle, settings): + details = get_tmdb_scraper(settings).get_details(input_uniqueids) + if not details: + return False + if 'error' in details: + header = "The Movie Database Python error with web service TMDB" + xbmcgui.Dialog().notification(header, details['error'], xbmcgui.NOTIFICATION_WARNING) + log(header + ': ' + details['error'], xbmc.LOGWARNING) + return False + + details = configure_tmdb_artwork(details, settings) + + if settings.getSettingString('RatingS') == 'IMDb' or settings.getSettingBool('imdbanyway'): + imdbinfo = get_imdb_details(details['uniqueids']) + if 'error' in imdbinfo: + header = "The Movie Database Python error with website IMDB" + log(header + ': ' + imdbinfo['error'], xbmc.LOGWARNING) + else: + details = combine_scraped_details_info_and_ratings(details, imdbinfo) + + if settings.getSettingString('RatingS') == 'Trakt' or settings.getSettingBool('traktanyway'): + traktinfo = get_trakt_ratinginfo(details['uniqueids']) + details = combine_scraped_details_info_and_ratings(details, traktinfo) + + if is_fanarttv_configured(settings): + fanarttv_info = get_fanarttv_artwork(details['uniqueids'], + settings.getSettingString('fanarttv_clientkey'), + settings.getSettingString('fanarttv_language'), + details['_info']['set_tmdbid']) + fanarttv_info = configure_fanarttv_artwork(fanarttv_info, settings) + details = combine_scraped_details_available_artwork(details, fanarttv_info) + + details = configure_scraped_details(details, settings) + + listitem = xbmcgui.ListItem(details['info']['title'], offscreen=True) + listitem.setInfo('video', details['info']) + listitem.setCast(details['cast']) + listitem.setUniqueIDs(details['uniqueids'], 'tmdb') + add_artworks(listitem, details['available_art']) + + for rating_type, value in details['ratings'].items(): + if 'votes' in value: + listitem.setRating(rating_type, value['rating'], value['votes'], value['default']) + else: + listitem.setRating(rating_type, value['rating'], defaultt=value['default']) + + xbmcplugin.setResolvedUrl(handle=handle, succeeded=True, listitem=listitem) + return True + +def find_uniqueids_in_nfo(nfo, handle): + uniqueids = find_uniqueids_in_text(nfo) + if uniqueids: + listitem = xbmcgui.ListItem(offscreen=True) + xbmcplugin.addDirectoryItem( + handle=handle, url=build_lookup_string(uniqueids), listitem=listitem, isFolder=True) + +def build_lookup_string(uniqueids): + return json.dumps(uniqueids) + +def parse_lookup_string(uniqueids): + return json.loads(uniqueids) + +def run(): + params = get_params(sys.argv[1:]) + enddir = True + if 'action' in params: + settings = ADDON_SETTINGS if not params.get('pathSettings') else \ + PathSpecificSettings(json.loads(params['pathSettings']), lambda msg: log(msg, xbmc.LOGWARNING)) + action = params["action"] + if action == 'find' and 'title' in params: + search_for_movie(params["title"], params.get("year"), params['handle'], settings) + elif action == 'getdetails' and 'url' in params: + enddir = not get_details(parse_lookup_string(params["url"]), params['handle'], settings) + elif action == 'NfoUrl' and 'nfo' in params: + find_uniqueids_in_nfo(params["nfo"], params['handle']) + else: + log("unhandled action: " + action, xbmc.LOGWARNING) + else: + log("No action in 'params' to act on", xbmc.LOGWARNING) + if enddir: + xbmcplugin.endOfDirectory(params['handle']) + +if __name__ == '__main__': + run() diff --git a/addons/metadata.themoviedb.org.python/python/scraper_config.py b/addons/metadata.themoviedb.org.python/python/scraper_config.py new file mode 100644 index 0000000000..c39d4c9e64 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/scraper_config.py @@ -0,0 +1,126 @@ +def configure_scraped_details(details, settings): + details = _configure_rating_prefix(details, settings) + details = _configure_keeporiginaltitle(details, settings) + details = _configure_trailer(details, settings) + details = _configure_multiple_studios(details, settings) + details = _configure_default_rating(details, settings) + details = _configure_tags(details, settings) + return details + +def configure_tmdb_artwork(details, settings): + if 'available_art' not in details: + return details + + art = details['available_art'] + fanart_enabled = settings.getSettingBool('fanart') + if not fanart_enabled: + if 'fanart' in art: + del art['fanart'] + if 'set.fanart' in art: + del art['set.fanart'] + if not settings.getSettingBool('landscape'): + if 'landscape' in art: + if fanart_enabled: + art['fanart'] = art.get('fanart', []) + art['landscape'] + del art['landscape'] + if 'set.landscape' in art: + if fanart_enabled: + art['set.fanart'] = art.get('set.fanart', []) + art['set.landscape'] + del art['set.landscape'] + + return details + +_fanarttv_arttypes = ['fanart', 'poster', 'clearlogo', 'clearart', 'discart', 'banner', 'landscape', 'keyart'] +_fanarttv_arttypes += ['set.' + t for t in _fanarttv_arttypes] +def configure_fanarttv_artwork(details, settings): + if 'available_art' not in details: + return details + art = details['available_art'] + for arttype in _fanarttv_arttypes: + if arttype in art and not settings.getSettingBool('enable_fanarttv_' + arttype): + del art[arttype] + + return details + +def is_fanarttv_configured(settings): + for arttype in _fanarttv_arttypes: + if settings.getSettingBool('enable_fanarttv_' + arttype): + return True + return False + +def _configure_rating_prefix(details, settings): + if details['info'].get('mpaa'): + details['info']['mpaa'] = settings.getSettingString('certprefix') + details['info']['mpaa'] + return details + +def _configure_keeporiginaltitle(details, settings): + if settings.getSettingBool('keeporiginaltitle'): + details['info']['title'] = details['info']['originaltitle'] + return details + +def _configure_trailer(details, settings): + if details['info'].get('trailer') and not settings.getSettingBool('trailer'): + del details['info']['trailer'] + return details + +def _configure_multiple_studios(details, settings): + if not settings.getSettingBool('multiple_studios'): + details['info']['studio'] = details['info']['studio'][:1] + return details + +def _configure_default_rating(details, settings): + imdb_default = bool(details['ratings'].get('imdb')) and settings.getSettingString('RatingS') == 'IMDb' + trakt_default = bool(details['ratings'].get('trakt')) and settings.getSettingString('RatingS') == 'Trakt' + default_rating = 'themoviedb' + if imdb_default: + default_rating = 'imdb' + elif trakt_default: + default_rating = 'trakt' + if default_rating not in details['ratings']: + default_rating = list(details['ratings'].keys())[0] if details['ratings'] else None + for rating_type in details['ratings'].keys(): + details['ratings'][rating_type]['default'] = rating_type == default_rating + return details + +def _configure_tags(details, settings): + if not settings.getSettingBool('add_tags'): + del details['info']['tag'] + return details + +# pylint: disable=invalid-name +try: + basestring +except NameError: # py2 / py3 + basestring = str + +#pylint: disable=redefined-builtin +class PathSpecificSettings(object): + # read-only shim for typed `xbmcaddon.Addon().getSetting*` methods + def __init__(self, settings_dict, log_fn): + self.data = settings_dict + self.log = log_fn + + def getSettingBool(self, id): + return self._inner_get_setting(id, bool, False) + + def getSettingInt(self, id): + return self._inner_get_setting(id, int, 0) + + def getSettingNumber(self, id): + return self._inner_get_setting(id, float, 0.0) + + def getSettingString(self, id): + return self._inner_get_setting(id, basestring, '') + + def _inner_get_setting(self, setting_id, setting_type, default): + value = self.data.get(setting_id) + if isinstance(value, setting_type): + return value + self._log_bad_value(value, setting_id) + return default + + def _log_bad_value(self, value, setting_id): + if value is None: + self.log("requested setting ({0}) was not found.".format(setting_id)) + else: + self.log('failed to load value "{0}" for setting {1}'.format(value, setting_id)) diff --git a/addons/metadata.themoviedb.org.python/python/scraper_datahelper.py b/addons/metadata.themoviedb.org.python/python/scraper_datahelper.py new file mode 100644 index 0000000000..23504e092c --- /dev/null +++ b/addons/metadata.themoviedb.org.python/python/scraper_datahelper.py @@ -0,0 +1,54 @@ +import re +try: + from urlparse import parse_qsl +except ImportError: # py2 / py3 + from urllib.parse import parse_qsl + +# get addon params from the plugin path querystring +def get_params(argv): + result = {'handle': int(argv[0])} + if len(argv) < 2 or not argv[1]: + return result + + result.update(parse_qsl(argv[1].lstrip('?'))) + return result + +def combine_scraped_details_info_and_ratings(original_details, additional_details): + def update_or_set(details, key, value): + if key in details: + details[key].update(value) + else: + details[key] = value + + if additional_details: + if additional_details.get('info'): + update_or_set(original_details, 'info', additional_details['info']) + if additional_details.get('ratings'): + update_or_set(original_details, 'ratings', additional_details['ratings']) + return original_details + +def combine_scraped_details_available_artwork(original_details, additional_details): + if additional_details and additional_details.get('available_art'): + available_art = additional_details['available_art'] + if not original_details.get('available_art'): + original_details['available_art'] = available_art + else: + for arttype, artlist in available_art.items(): + original_details['available_art'][arttype] = \ + artlist + original_details['available_art'].get(arttype, []) + + return original_details + +def find_uniqueids_in_text(input_text): + result = {} + res = re.search(r'(themoviedb.org/movie/)([0-9]+)', input_text) + if (res): + result['tmdb'] = res.group(2) + res = re.search(r'imdb....?/title/tt([0-9]+)', input_text) + if (res): + result['imdb'] = 'tt' + res.group(1) + else: + res = re.search(r'imdb....?/Title\?t{0,2}([0-9]+)', input_text) + if (res): + result['imdb'] = 'tt' + res.group(1) + return result diff --git a/addons/metadata.themoviedb.org.python/resources/icon.png b/addons/metadata.themoviedb.org.python/resources/icon.png Binary files differnew file mode 100644 index 0000000000..1aa8275b50 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/icon.png diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.af_za/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.af_za/strings.po new file mode 100644 index 0000000000..fe8286afcb --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.af_za/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Afrikaans (http://www.transifex.com/projects/p/xbmc-addons/language/af/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: af\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Stel Ondersteunerkuns in staat" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Verkies Voorskou van HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Verkose Taal" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Kry Gradering vanaf" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Stel Voorskou in staat (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Hou Oorspronklike Titel" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Verkose Sertifiserings Land" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.am_et/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.am_et/strings.po new file mode 100644 index 0000000000..6e99ca8331 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.am_et/strings.po @@ -0,0 +1,33 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Amharic (http://www.transifex.com/projects/p/xbmc-addons/language/am/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: am\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "የተመረጠው ቋንቋ" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "ደረጃ ያግኙ ከ " + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "ዋናውን አርእስት ጠብቅ " + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "የተመረጠው የምስክር ወረቀት አገር " diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.be_by/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.be_by/strings.po new file mode 100644 index 0000000000..d5e25aac03 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.be_by/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Belarusian (http://www.transifex.com/projects/p/xbmc-addons/language/be/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: be\n" +"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Enable Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Prefer Trailer from HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Пераважная мова" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Get Rating from" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Enable Trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Keep Original Title" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Preferred Certification Country" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.bg_bg/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.bg_bg/strings.po new file mode 100644 index 0000000000..eefd4542d3 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.bg_bg/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Bulgarian (http://www.transifex.com/projects/p/xbmc-addons/language/bg/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: bg\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Ползвай фанарт" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Предпочитай трейлърите от HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Предпочитан език" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Получавай рейтинга от" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Включи трейлърите от YouTube" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Запазвай оригиналното заглавие" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Категоризирай според стандарта в" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ca_es/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ca_es/strings.po new file mode 100644 index 0000000000..a4c02084e3 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ca_es/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Catalan (http://www.transifex.com/projects/p/xbmc-addons/language/ca/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ca\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Habilita el fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Prefereix trailers de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Idioma perferit" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obté qualificació de" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Habilita el tràiler (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Manté el títol original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Païs de certificació preferit" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.cs_cz/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.cs_cz/strings.po new file mode 100644 index 0000000000..d303eb2d48 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.cs_cz/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Czech (http://www.transifex.com/projects/p/xbmc-addons/language/cs/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: cs\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Povolit Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Upřednostňovat upoutávku z HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Upřednostňovaný jazyk" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Získat hodnocení z" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Povolit upoutávku (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Ponechat původní název" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Upřednostňovaný stát poskytující certifikaci" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.cy_gb/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.cy_gb/strings.po new file mode 100644 index 0000000000..6c3ef8a5ca --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.cy_gb/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Welsh (http://www.transifex.com/projects/p/xbmc-addons/language/cy/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: cy\n" +"Plural-Forms: nplurals=4; plural=(n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Galluogi Celf" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Dewis Cyflwyniadau o HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Dewis Iaith" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Graddio gan" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Galluogi Cyflwyniadau (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Cadw'r Teitl Gwreiddiol" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Gwlad Tysytysgrifo Dewisol" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.da_dk/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.da_dk/strings.po new file mode 100644 index 0000000000..94268451e5 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.da_dk/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Danish (http://www.transifex.com/projects/p/xbmc-addons/language/da/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: da\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Aktiver Fankunst" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Foretræk Trailer fra HD-trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Foretrukket Sprog" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Hent bedømmelse fra" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Aktivér Trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Behold original titel" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Foretrukket land til aldersvejledninger" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.de_de/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.de_de/strings.po new file mode 100644 index 0000000000..81f334947e --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.de_de/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: German (http://www.transifex.com/projects/p/xbmc-addons/language/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Aktiviere Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Bevorzuge Trailer von HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Bevorzugte Sprache" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Lade die Bewertung von" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Aktiviere Trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Verwende Original-Titel" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Bevorzugtes Land für die Altersbewertung" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.el_gr/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.el_gr/strings.po new file mode 100644 index 0000000000..7a0926f994 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.el_gr/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Greek (http://www.transifex.com/projects/p/xbmc-addons/language/el/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: el\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Ενεργοποίηση Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Προτίμηση διαφημιστικών από HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Προτιμώμενη Γλώσσα" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Αξιολόγηση από" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Διαφημιστικά από YouTube" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Διατήρηση Πρωτότυπου Τίτλου" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Προτιμώμενη Χώρα για δείκτη Καταλληλότητας" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_gb/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_gb/strings.po new file mode 100644 index 0000000000..f977ba8507 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_gb/strings.po @@ -0,0 +1,141 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable fanart from TMDb" +msgstr "" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "" + +msgctxt "#30003" +msgid "Default Rating from" +msgstr "" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "" + +msgctxt "#30007" +msgid "Add also IMDb ratings" +msgstr "" + +msgctxt "#30008" +msgid "Certification Prefix" +msgstr "" + +msgctxt "#30009" +msgid "Add multiple studios" +msgstr "" + +msgctxt "#30010" +msgid "Add also Trakt.tv ratings" +msgstr "" + +msgctxt "#30011" +msgid "Add keywords as tags" +msgstr "" + +msgctxt "#30012" +msgid "Separate TMDb fanart with title to landscape" +msgstr "" + +msgctxt "#30100" +msgid "Language for Fanart.tv artwork" +msgstr "" + +msgctxt "#30101" +msgid "Fanart.tv personal API key (optional)" +msgstr "" + +msgctxt "#30102" +msgid "Enable fanart from Fanart.tv" +msgstr "" + +msgctxt "#30103" +msgid "Enable poster from Fanart.tv" +msgstr "" + +msgctxt "#30104" +msgid "Enable clearlogo from Fanart.tv" +msgstr "" + +msgctxt "#30105" +msgid "Enable clearart from Fanart.tv" +msgstr "" + +msgctxt "#30106" +msgid "Enable discart from Fanart.tv" +msgstr "" + +msgctxt "#30107" +msgid "Enable banner from Fanart.tv" +msgstr "" + +msgctxt "#30108" +msgid "Enable landscape from Fanart.tv" +msgstr "" + +msgctxt "#30109" +msgid "Enable set fanart from Fanart.tv" +msgstr "" + +msgctxt "#30110" +msgid "Enable set poster from Fanart.tv" +msgstr "" + +msgctxt "#30111" +msgid "Enable set clearlogo from Fanart.tv" +msgstr "" + +msgctxt "#30112" +msgid "Enable set clearart from Fanart.tv" +msgstr "" + +msgctxt "#30113" +msgid "Enable set discart from Fanart.tv" +msgstr "" + +msgctxt "#30114" +msgid "Enable set banner from Fanart.tv" +msgstr "" + +msgctxt "#30115" +msgid "Enable set landscape from Fanart.tv" +msgstr "" + +msgctxt "#30116" +msgid "Enable keyart from Fanart.tv" +msgstr "" + +msgctxt "#30117" +msgid "Enable set keyart from Fanart.tv" +msgstr "" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_nz/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_nz/strings.po new file mode 100644 index 0000000000..f977ba8507 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_nz/strings.po @@ -0,0 +1,141 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable fanart from TMDb" +msgstr "" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "" + +msgctxt "#30003" +msgid "Default Rating from" +msgstr "" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "" + +msgctxt "#30007" +msgid "Add also IMDb ratings" +msgstr "" + +msgctxt "#30008" +msgid "Certification Prefix" +msgstr "" + +msgctxt "#30009" +msgid "Add multiple studios" +msgstr "" + +msgctxt "#30010" +msgid "Add also Trakt.tv ratings" +msgstr "" + +msgctxt "#30011" +msgid "Add keywords as tags" +msgstr "" + +msgctxt "#30012" +msgid "Separate TMDb fanart with title to landscape" +msgstr "" + +msgctxt "#30100" +msgid "Language for Fanart.tv artwork" +msgstr "" + +msgctxt "#30101" +msgid "Fanart.tv personal API key (optional)" +msgstr "" + +msgctxt "#30102" +msgid "Enable fanart from Fanart.tv" +msgstr "" + +msgctxt "#30103" +msgid "Enable poster from Fanart.tv" +msgstr "" + +msgctxt "#30104" +msgid "Enable clearlogo from Fanart.tv" +msgstr "" + +msgctxt "#30105" +msgid "Enable clearart from Fanart.tv" +msgstr "" + +msgctxt "#30106" +msgid "Enable discart from Fanart.tv" +msgstr "" + +msgctxt "#30107" +msgid "Enable banner from Fanart.tv" +msgstr "" + +msgctxt "#30108" +msgid "Enable landscape from Fanart.tv" +msgstr "" + +msgctxt "#30109" +msgid "Enable set fanart from Fanart.tv" +msgstr "" + +msgctxt "#30110" +msgid "Enable set poster from Fanart.tv" +msgstr "" + +msgctxt "#30111" +msgid "Enable set clearlogo from Fanart.tv" +msgstr "" + +msgctxt "#30112" +msgid "Enable set clearart from Fanart.tv" +msgstr "" + +msgctxt "#30113" +msgid "Enable set discart from Fanart.tv" +msgstr "" + +msgctxt "#30114" +msgid "Enable set banner from Fanart.tv" +msgstr "" + +msgctxt "#30115" +msgid "Enable set landscape from Fanart.tv" +msgstr "" + +msgctxt "#30116" +msgid "Enable keyart from Fanart.tv" +msgstr "" + +msgctxt "#30117" +msgid "Enable set keyart from Fanart.tv" +msgstr "" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_us/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_us/strings.po new file mode 100644 index 0000000000..f977ba8507 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.en_us/strings.po @@ -0,0 +1,141 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable fanart from TMDb" +msgstr "" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "" + +msgctxt "#30003" +msgid "Default Rating from" +msgstr "" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "" + +msgctxt "#30007" +msgid "Add also IMDb ratings" +msgstr "" + +msgctxt "#30008" +msgid "Certification Prefix" +msgstr "" + +msgctxt "#30009" +msgid "Add multiple studios" +msgstr "" + +msgctxt "#30010" +msgid "Add also Trakt.tv ratings" +msgstr "" + +msgctxt "#30011" +msgid "Add keywords as tags" +msgstr "" + +msgctxt "#30012" +msgid "Separate TMDb fanart with title to landscape" +msgstr "" + +msgctxt "#30100" +msgid "Language for Fanart.tv artwork" +msgstr "" + +msgctxt "#30101" +msgid "Fanart.tv personal API key (optional)" +msgstr "" + +msgctxt "#30102" +msgid "Enable fanart from Fanart.tv" +msgstr "" + +msgctxt "#30103" +msgid "Enable poster from Fanart.tv" +msgstr "" + +msgctxt "#30104" +msgid "Enable clearlogo from Fanart.tv" +msgstr "" + +msgctxt "#30105" +msgid "Enable clearart from Fanart.tv" +msgstr "" + +msgctxt "#30106" +msgid "Enable discart from Fanart.tv" +msgstr "" + +msgctxt "#30107" +msgid "Enable banner from Fanart.tv" +msgstr "" + +msgctxt "#30108" +msgid "Enable landscape from Fanart.tv" +msgstr "" + +msgctxt "#30109" +msgid "Enable set fanart from Fanart.tv" +msgstr "" + +msgctxt "#30110" +msgid "Enable set poster from Fanart.tv" +msgstr "" + +msgctxt "#30111" +msgid "Enable set clearlogo from Fanart.tv" +msgstr "" + +msgctxt "#30112" +msgid "Enable set clearart from Fanart.tv" +msgstr "" + +msgctxt "#30113" +msgid "Enable set discart from Fanart.tv" +msgstr "" + +msgctxt "#30114" +msgid "Enable set banner from Fanart.tv" +msgstr "" + +msgctxt "#30115" +msgid "Enable set landscape from Fanart.tv" +msgstr "" + +msgctxt "#30116" +msgid "Enable keyart from Fanart.tv" +msgstr "" + +msgctxt "#30117" +msgid "Enable set keyart from Fanart.tv" +msgstr "" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_ar/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_ar/strings.po new file mode 100644 index 0000000000..8bab5780ca --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_ar/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Spanish (Argentina) (http://www.transifex.com/projects/p/xbmc-addons/language/es_AR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: es_AR\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Descargar Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Activar Trailers de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Idioma Preferido" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obtener Puntuación de" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Activar Trailer (Youtube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Mantener Título Original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "País de Certificación Preferido" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_es/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_es/strings.po new file mode 100644 index 0000000000..f772231c8a --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_es/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Spanish (http://www.transifex.com/projects/p/xbmc-addons/language/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Descargar Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Activar Trailers de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Idioma preferido" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obtener puntuación de" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Activar trailer (Youtube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Mantener título original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Clasificación por edades" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_mx/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_mx/strings.po new file mode 100644 index 0000000000..a8b21d995a --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.es_mx/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Spanish (Mexico) (http://www.transifex.com/projects/p/xbmc-addons/language/es_MX/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: es_MX\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Activar Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Preferir Trailers de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Lenguaje Preferido" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obtener Rating de" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Habilitar Trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Mantener Título Original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "País de Certificación Preferido" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.et_ee/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.et_ee/strings.po new file mode 100644 index 0000000000..74e34c8468 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.et_ee/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Estonian (http://www.transifex.com/projects/p/xbmc-addons/language/et/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: et\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Võimalda fännikunst" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Eelista HD-Trailers.net treilerit" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Eelistatud keel" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Hangi hinnang" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Võimalda treilerit (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Säilita originaalne pealkiri" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Eelistatud kinnitatud riik" diff --git a/addons/service.xbmc.versioncheck/resources/language/Asturian/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.eu_es/strings.po index 0c00a68df0..1b7c8b2bed 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Asturian/strings.po +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.eu_es/strings.po @@ -1,7 +1,7 @@ # Kodi Media Center language file -# Addon Name: Version Check -# Addon id: service.xbmc.versioncheck -# Addon Provider: Team Kodi +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation msgid "" msgstr "" "Project-Id-Version: XBMC Addons\n" @@ -9,13 +9,13 @@ msgstr "" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Kodi Translation Team\n" -"Language-Team: Asturian (http://www.transifex.com/projects/p/xbmc-addons/language/ast/)\n" +"Language-Team: Basque (http://www.transifex.com/projects/p/xbmc-addons/language/eu/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ast\n" +"Language: eu\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -msgctxt "#32020" -msgid "General" -msgstr "Xeneral" +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Gaitu Fanarta" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.fi_fi/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.fi_fi/strings.po new file mode 100644 index 0000000000..172b2f5d3e --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.fi_fi/strings.po @@ -0,0 +1,21 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Finnish (http://www.transifex.com/projects/p/xbmc-addons/language/fi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: fi\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Fanitaide käytössä" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.fr_ca/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.fr_ca/strings.po new file mode 100644 index 0000000000..e55becb3ba --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.fr_ca/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: French (Canada) (http://www.transifex.com/projects/p/xbmc-addons/language/fr_CA/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: fr_CA\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Activer le fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Préférer les bandes-annonces de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Langue préférée" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obtenir les évaluations sur" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Activer les bandes-annonces (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Conserver le titre original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Pays de certification préféré" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.fr_fr/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.fr_fr/strings.po new file mode 100644 index 0000000000..7b05a75ebe --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.fr_fr/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: French (http://www.transifex.com/projects/p/xbmc-addons/language/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Activer les Fanarts" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Préférer les bandes-annonces de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Langue préférée" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obtenir la note à partir de" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Activer les bandes-annonces (You Tube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Garder le titre original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Pays favori de certification" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.gl_es/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.gl_es/strings.po new file mode 100644 index 0000000000..e2d3ca53bb --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.gl_es/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Galician (http://www.transifex.com/projects/p/xbmc-addons/language/gl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: gl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Habilitar Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Preferir os Avances de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Idioma Preferido" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obter a puntuación dende" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Habilitar Avance (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Manter o Título Orixinal" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "País de Certificación Preferido" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.he_il/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.he_il/strings.po new file mode 100644 index 0000000000..72fd1f1f1b --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.he_il/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Hebrew (http://www.transifex.com/projects/p/xbmc-addons/language/he/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: he\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "אפשר עטיפות דיסק" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "העדף קדימון מ-HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "שפה מועדפת" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "השג דירוג מ-" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "הפעל קדימון (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "שמור על כותרת מקורית" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "אישור מדינה מועדף" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.hi_in/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.hi_in/strings.po new file mode 100644 index 0000000000..f612ccb4c9 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.hi_in/strings.po @@ -0,0 +1,21 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Hindi (Devanagiri) (http://www.transifex.com/projects/p/xbmc-addons/language/hi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: hi\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "फ़ानर्ट को एनेबल करे" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.hr_hr/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.hr_hr/strings.po new file mode 100644 index 0000000000..b458538d87 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.hr_hr/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Croatian (http://www.transifex.com/projects/p/xbmc-addons/language/hr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: hr\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Omogući omote" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Preferiraj najave filmova s HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Željeni jezik" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Nabavi ocijene s" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Omogući najave filmova (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Zadrži izvorni naslov" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Željena država ovjere" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.hu_hu/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.hu_hu/strings.po new file mode 100644 index 0000000000..2441c2a572 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.hu_hu/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Hungarian (http://www.transifex.com/projects/p/xbmc-addons/language/hu/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: hu\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Fanartképek engedélyezése" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Filmelőzetesek inkább a HD-Trailers.net-ről" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Preferált nyelv" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Értékelés letöltése innen" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Filmelőzetesek engedélyezése (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Eredeti filmcím megtartása" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Preferált korhatár-besorolás innen" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.id_id/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.id_id/strings.po new file mode 100644 index 0000000000..0cbacdc7c9 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.id_id/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Indonesian (http://www.transifex.com/projects/p/xbmc-addons/language/id/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: id\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Aktifkan Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Utamakan Trailer dari HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Bahasa terutama" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Ambil Rating dari" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Aktifkan Trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Pertahankan Judul Aslinya" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Negara pemberi sertifikasi yang diutamakan" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.is_is/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.is_is/strings.po new file mode 100644 index 0000000000..afc82d015d --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.is_is/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Icelandic (http://www.transifex.com/projects/p/xbmc-addons/language/is/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: is\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Virkja Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Æskilegt að fá Kynningarmyndbönd frá HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Æskilegt tungumál" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Fá Einkunnagjöf frá" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Virkja Kynningarmyndbönd (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Halda Upphaflegum Titli" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Æskilegt Land Aldursvottunar" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.it_it/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.it_it/strings.po new file mode 100644 index 0000000000..7c141857fe --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.it_it/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Italian (http://www.transifex.com/projects/p/xbmc-addons/language/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Abilita Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Preferire i Trailers provenienti da HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Linguaggio preferito" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Prendere Valutazioni da" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Abilita Trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Mantieni Titolo Originale" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Paese di Certificazione Preferito" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ja_jp/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ja_jp/strings.po new file mode 100644 index 0000000000..c786a33767 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ja_jp/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Japanese (http://www.transifex.com/projects/p/xbmc-addons/language/ja/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ja\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "ファンアートを有効に" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "HD-Trailers.net からの予告編を優先" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "優先する言語" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "評価の取得先" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "予告編を有効にする (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "オリジナルタイトルを保持" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "優先する証明書の国" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ko_kr/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ko_kr/strings.po new file mode 100644 index 0000000000..76d50ab82d --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ko_kr/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Korean (http://www.transifex.com/projects/p/xbmc-addons/language/ko/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ko\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "팬아트 사용" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "HD-Trailers.net 에서 예고편 가져오기" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "선호 언어" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "평점 가져오기" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "예고편 사용 (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "원 제목 유지" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "등급 기준 국가" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.lt_lt/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.lt_lt/strings.po new file mode 100644 index 0000000000..6cffbae32b --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.lt_lt/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Lithuanian (http://www.transifex.com/projects/p/xbmc-addons/language/lt/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: lt\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Įjungti Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Pirmenybė filmo anonsui iš HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Pageidaujama kalba" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Gauti įvertinimą iš" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Įjungti filmų anonsus (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Išlaikyti originalų pavadinimą" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Pageidaujama sertifikavimo šalis" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.mk_mk/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.mk_mk/strings.po new file mode 100644 index 0000000000..04fc28a2bd --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.mk_mk/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Macedonian (http://www.transifex.com/projects/p/xbmc-addons/language/mk/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: mk\n" +"Plural-Forms: nplurals=2; plural=(n % 10 == 1 && n % 100 != 11) ? 0 : 1;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Овозможи сликички" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Активирај најава од HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Посакуван јазик" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Користи вреднување од IMDb" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Овозможи најава (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Задржи оригинален назив" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Преферирана цертификациона држава" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ml_in/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ml_in/strings.po new file mode 100644 index 0000000000..d95329b4c1 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ml_in/strings.po @@ -0,0 +1,25 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Malayalam (http://www.transifex.com/projects/p/xbmc-addons/language/ml/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ml\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "ഇഷ്ടപ്പെട്ട ഭാഷ" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "യഥാർത്ത പേര് നിലനിർത്തുക" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ms_my/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ms_my/strings.po new file mode 100644 index 0000000000..3a35a60eef --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ms_my/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Malay (http://www.transifex.com/projects/p/xbmc-addons/language/ms/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ms\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Benarkan Seni Peminat" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Utamakan Treler dari " + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Bahasa Digemari" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Dapatkan Penarafan dari" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Benarkan Treler (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Kekalkan Tajuk Asal" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Negara Persijilan Dikehendaki" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.my_mm/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.my_mm/strings.po new file mode 100644 index 0000000000..d67a7c7c45 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.my_mm/strings.po @@ -0,0 +1,37 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Burmese (http://www.transifex.com/projects/p/xbmc-addons/language/my/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: my\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Fanart ကို လုပ်ဆောင်ခွင့်" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "HD-Trailers.net မှသင့်လျှော်သော ကြော်ငြာ" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "သင့်လျှော်သော ဘာသာစကား" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "ကြော်ငြာများရယူမည်(You Tube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "မူလခေါင်းစဉ်အတိုင်းထားမည်" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.nb_no/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.nb_no/strings.po new file mode 100644 index 0000000000..9f46d620fc --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.nb_no/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Norwegian (http://www.transifex.com/projects/p/xbmc-addons/language/no/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: no\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Hent fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Foretrekk trailer fra HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Foretrukket språk" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Hent rangering fra" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Hent trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Bruk originaltittel" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Foretrukket land for aldersgrenser" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.nl_nl/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.nl_nl/strings.po new file mode 100644 index 0000000000..af2b35c439 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.nl_nl/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Dutch (http://www.transifex.com/projects/p/xbmc-addons/language/nl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Fanart inschakelen" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Trailers van HD-Trailers.net inschakelen" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Voorkeurstaal" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Haal score bij" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Gebruik trailers (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Behoud originele titel" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Voorkeur voor certificeringsland" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.pl_pl/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.pl_pl/strings.po new file mode 100644 index 0000000000..c762be3a3f --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.pl_pl/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Polish (http://www.transifex.com/projects/p/xbmc-addons/language/pl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: pl\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Używaj tapet" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Preferuj zwiastuny z serwisu HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Preferowany język" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Pobieraj ocenę z" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Aktywuj zwiastuny (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Zachowuj tytuł oryginalny" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Preferowany kraj kategorii wiekowej" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.pt_br/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.pt_br/strings.po new file mode 100644 index 0000000000..0893d76579 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.pt_br/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/projects/p/xbmc-addons/language/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Habilitar Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Preferir trailer de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Idioma preferido" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obter classificação de" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Ativar trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Manter o título original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Preferir país de certificação" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.pt_pt/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.pt_pt/strings.po new file mode 100644 index 0000000000..a73a8b65f0 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.pt_pt/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Portuguese (http://www.transifex.com/projects/p/xbmc-addons/language/pt/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: pt\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Activar Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Activar trailers de HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Idioma preferido" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Obter Classificação de" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Activar Trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Manter Título Original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "País Preferido para Certificação" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ro_ro/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ro_ro/strings.po new file mode 100644 index 0000000000..77ca7e7cb6 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ro_ro/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Romanian (http://www.transifex.com/projects/p/xbmc-addons/language/ro/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ro\n" +"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Activează Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Activează trailere de la HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Limbă preferată" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Ia rating de la " + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Activează trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Păstrează titlul original" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Ţară certificare preferată" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ru_ru/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ru_ru/strings.po new file mode 100644 index 0000000000..fb198e517a --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ru_ru/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Russian (http://www.transifex.com/projects/p/xbmc-addons/language/ru/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ru\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Использовать фанарт" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Использовать трейлеры с HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Предпочтительный язык" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Сайт рейтинга" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Включить трейлеры (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Использовать оригинальные названия" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Страна сертификации" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.sk_sk/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sk_sk/strings.po new file mode 100644 index 0000000000..7d4b358576 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sk_sk/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Slovak (http://www.transifex.com/projects/p/xbmc-addons/language/sk/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: sk\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Povoliť umeleckú grafiku" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Uprednostniť upútavky zo stránky HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Uprednostňovaný jazyk" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Hodnotenie získaj z " + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Povoliť upútavky (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Ponechať pôvodný názov" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Uprednostňovaný pôvod hodnotenia prístupnosti pre mládež" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.sl_si/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sl_si/strings.po new file mode 100644 index 0000000000..73ad4f71ff --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sl_si/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Slovenian (http://www.transifex.com/projects/p/xbmc-addons/language/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Vključi grafike" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Napovedniki s HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Privzet jezik" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Prenesi ocene z" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Vključi napovednike (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Ohrani naslov izvirnika" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Država za ocene o omejitvi predvajanja" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.sq_al/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sq_al/strings.po new file mode 100644 index 0000000000..aac1a670bd --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sq_al/strings.po @@ -0,0 +1,21 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Albanian (http://www.transifex.com/projects/p/xbmc-addons/language/sq/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: sq\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Aktivo \"Fanart'in\"" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.sv_se/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sv_se/strings.po new file mode 100644 index 0000000000..a3efcebd35 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.sv_se/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Swedish (http://www.transifex.com/projects/p/xbmc-addons/language/sv/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: sv\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Aktivera fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Aktivera trailers från HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Föredraget språk" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Hämta betyg från" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Aktivera trailer (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Behåll orginaltitel" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Önskat certifieringsland" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.ta_in/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ta_in/strings.po new file mode 100644 index 0000000000..a793f117e7 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.ta_in/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Tamil (India) (http://www.transifex.com/projects/p/xbmc-addons/language/ta_IN/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ta_IN\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "விசிறிபடத்தை காண்பி" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "HD-Trailers.net இருந்து வரும் டிரெய்லர்களை விரும்பு" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "விரும்பிய மொழி" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "தரத்தை கைப்பற்று" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "டிரெய்லர் செயல்படுத்த (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "அசல் தலைப்பை வைக்க" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "விருப்பமான சான்றிதழ் நாடு" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.th_th/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.th_th/strings.po new file mode 100644 index 0000000000..91664ebac2 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.th_th/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Thai (http://www.transifex.com/projects/p/xbmc-addons/language/th/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: th\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "เปิดใช้ แฟนอาร์ต" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "เรียกใฃ้ ตัวอย่างภาพยนตร์ จาก HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "ภาษา ที่ต้องการ" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "รับการจัดอันดับ จาก" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "เปิดใช้ ตัวอย่างภาพยนตร์ (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "คงไว้ซึ่ง ชื่อต้นฉบับ" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "การรับรองจากประเทศ ที่ต้องการ" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.tr_tr/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.tr_tr/strings.po new file mode 100644 index 0000000000..9c8a3d9400 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.tr_tr/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Turkish (http://www.transifex.com/projects/p/xbmc-addons/language/tr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: tr\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Fanart Etkinleştir" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Fragmanlar için HD-Trailers.net'i tercih et" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Tercih Edilen Dil" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Değerlendirmeyi şuradan al" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Fragmanı Etkinleştir (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Özgün Başlığı Koru" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Tercih Edilen Sertifika Ülkesi" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.uk_ua/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.uk_ua/strings.po new file mode 100644 index 0000000000..ecb1a23eb8 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.uk_ua/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Ukrainian (http://www.transifex.com/projects/p/xbmc-addons/language/uk/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: uk\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Завантажувати фанарт" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Віддавати перевагу трейлерам з HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Бажана мова" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Отримати рейтинг з" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Увімкнути трейлери (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Зберігати оригінальну назву" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Бажана країна сертифікації" diff --git a/addons/service.xbmc.versioncheck/resources/language/Georgian/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.uz_uz/strings.po index 89e4e828b1..1cd650f4c3 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Georgian/strings.po +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.uz_uz/strings.po @@ -1,7 +1,7 @@ # Kodi Media Center language file -# Addon Name: Version Check -# Addon id: service.xbmc.versioncheck -# Addon Provider: Team Kodi +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation msgid "" msgstr "" "Project-Id-Version: XBMC Addons\n" @@ -9,13 +9,13 @@ msgstr "" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Kodi Translation Team\n" -"Language-Team: Georgian (http://www.transifex.com/projects/p/xbmc-addons/language/ka/)\n" +"Language-Team: Uzbek (http://www.transifex.com/projects/p/xbmc-addons/language/uz/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ka\n" +"Language: uz\n" "Plural-Forms: nplurals=1; plural=0;\n" -msgctxt "#32020" -msgid "General" -msgstr "მთავარი" +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Afzal til" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.vi_vn/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.vi_vn/strings.po new file mode 100644 index 0000000000..194c3b320d --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.vi_vn/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Vietnamese (http://www.transifex.com/projects/p/xbmc-addons/language/vi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: vi\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "Sử dụng Fanart" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "Ưu tiên Phim giới thiệu từ HD-Trailers.net" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "Ưu tiên ngôn ngữ" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "Lấy Đánh giá từ" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "Sử dụng Phim giới thiệu (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "Giữ nguyên tên phim gốc" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "Ưu tiên chứng chỉ của quốc gia" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.zh_cn/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.zh_cn/strings.po new file mode 100644 index 0000000000..90fe0a5526 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.zh_cn/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Chinese (Simple) (http://www.transifex.com/projects/p/xbmc-addons/language/zh/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: zh\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "启用同人画" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "备选 HD-Trailers.net 预告片" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "首选语言" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "获取评分于" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "启用预告片(YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "使用未翻译片名" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "首选电影分级国别" diff --git a/addons/metadata.themoviedb.org.python/resources/language/resource.language.zh_tw/strings.po b/addons/metadata.themoviedb.org.python/resources/language/resource.language.zh_tw/strings.po new file mode 100644 index 0000000000..3764b46adb --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/language/resource.language.zh_tw/strings.po @@ -0,0 +1,45 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: Chinese (Traditional) (http://www.transifex.com/projects/p/xbmc-addons/language/zh_TW/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: zh_TW\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgctxt "#30000" +msgid "Enable Fanart" +msgstr "啟用專輯資訊" + +msgctxt "#30001" +msgid "Prefer Trailer from HD-Trailers.net" +msgstr "偏好從HD-Trailers.net取得預告片" + +msgctxt "#30002" +msgid "Preferred Language" +msgstr "偏好的語言" + +msgctxt "#30003" +msgid "Get Rating from" +msgstr "從...取得評價" + +msgctxt "#30004" +msgid "Enable Trailer (YouTube)" +msgstr "啟用預告片 (YouTube)" + +msgctxt "#30005" +msgid "Keep Original Title" +msgstr "保留原始標題" + +msgctxt "#30006" +msgid "Preferred Certification Country" +msgstr "偏好的認證國家" diff --git a/addons/metadata.themoviedb.org.python/resources/settings.xml b/addons/metadata.themoviedb.org.python/resources/settings.xml new file mode 100644 index 0000000000..b63ae0c789 --- /dev/null +++ b/addons/metadata.themoviedb.org.python/resources/settings.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<settings> + <category label="$LOCALIZE[128]"> + <setting label="30005" type="bool" id="keeporiginaltitle" default="false"/> + <setting label="30000" type="bool" id="fanart" default="true"/> + <setting label="30012" type="bool" id="landscape" default="true"/> + <setting label="30004" type="bool" id="trailer" default="true"/> + <setting label="30002" type="select" values="ar-AE|ar-SA|be-BY|bg-BG|bn-BD|ca-ES|ch-GU|cs-CZ|da-DK|de-DE|el-GR|en-US|eo-EO|es-ES|es-MX|et-EE|eu-ES|fa-IR|fi-FI|fr-CA|fr-FR|gl-ES|he-IL|hi-IN|hr-HR|hu-HU|id-ID|it-IT|ja-JP|ka-GE|ko-KR|lt-LT|lv-LV|ml-IN|nb-NO|nl-NL|no-NO|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sk-SK|sl-SI|sr-RS|sv-SE|ta-IN|th-TH|tr-TR|uk-UA|vi-VN|zh-CN|zh-HK|zh-TW" id="language" default="en-US"/> + <setting label="30006" type="select" values="au|bg|br|by|ca|cz|ge|de|dk|ee|es|fi|fr|gb|gr|hr|hu|id|il|in|it|ir|jp|kr|lt|lv|mx|nl|no|pl|pt|ru|si|sv|th|tr|ua|us|vn|zh" id="tmdbcertcountry" default="us"/> + <setting label="30008" type="text" id="certprefix" default="Rated " /> + <setting label="30003" type="labelenum" values="TMDb|IMDb|Trakt" id="RatingS" default="TMDb"/> + <setting label="30007" type="bool" id="imdbanyway" visible="!eq(-1,1)" default="false"/> + <setting label="30010" type="bool" id="traktanyway" visible="!eq(-2,2)" default="false"/> + <setting label="30009" type="bool" id="multiple_studios" default="false" /> + <setting label="30011" type="bool" id="add_tags" default="true" /> + <!-- For add-on inner workings --> + <setting id="lastUpdated" type="text" default="0" visible="false" /> + <setting id="originalUrl" type="text" default="" visible="false" /> + <setting id="previewUrl" type="text" default="" visible="false" /> + </category> + <category label="Fanart.tv"> + <setting id="fanarttv_language" label="30100" type="select" default="en" values="en|fr|de|ja|zh|es|it|pt|sv|ru|nl|ar|ko|no|hu|da|hi|is|pl|he|bg|fi|ml" /> + <setting label="30102" type="bool" id="enable_fanarttv_fanart" default="false"/> + <setting label="30103" type="bool" id="enable_fanarttv_poster" default="false"/> + <setting label="30116" type="bool" id="enable_fanarttv_keyart" default="false"/> + <setting label="30104" type="bool" id="enable_fanarttv_clearlogo" default="false"/> + <setting label="30105" type="bool" id="enable_fanarttv_clearart" default="false"/> + <setting label="30106" type="bool" id="enable_fanarttv_discart" default="false"/> + <setting label="30107" type="bool" id="enable_fanarttv_banner" default="false"/> + <setting label="30108" type="bool" id="enable_fanarttv_landscape" default="false"/> + <setting label="30109" type="bool" id="enable_fanarttv_set.fanart" default="false"/> + <setting label="30110" type="bool" id="enable_fanarttv_set.poster" default="false"/> + <setting label="30117" type="bool" id="enable_fanarttv_set.keyart" default="false"/> + <setting label="30111" type="bool" id="enable_fanarttv_set.clearlogo" default="false"/> + <setting label="30112" type="bool" id="enable_fanarttv_set.clearart" default="false"/> + <setting label="30113" type="bool" id="enable_fanarttv_set.discart" default="false"/> + <setting label="30114" type="bool" id="enable_fanarttv_set.banner" default="false"/> + <setting label="30115" type="bool" id="enable_fanarttv_set.landscape" default="false"/> + <setting label="30101" type="text" id="fanarttv_clientkey" default="" /> + </category> +</settings> diff --git a/addons/metadata.tvshows.themoviedb.org.python/LICENSE.txt b/addons/metadata.tvshows.themoviedb.org.python/LICENSE.txt new file mode 100644 index 0000000000..f288702d2f --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>. diff --git a/addons/metadata.tvshows.themoviedb.org.python/addon.xml b/addons/metadata.tvshows.themoviedb.org.python/addon.xml new file mode 100644 index 0000000000..10e4edd33f --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/addon.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<addon id="metadata.tvshows.themoviedb.org.python" + name="TMDb TV Shows" + version="1.3.0" + provider-name="Team Kodi"> + <requires> + <import addon="xbmc.python" version="3.0.0"/> + <import addon="xbmc.metadata" version="2.1.0"/> + </requires> + <extension point="xbmc.metadata.scraper.tvshows" library="main.py"/> + <extension point="xbmc.addon.metadata"> + <news>1.3.0 +scraper now returns URL references for all possible art so Kodi can decide what to display based on system settings + +1.2.3 +fix for crash if show had no network listed on TMDb + +1.2.2 +change so that scraper returns English data for a show if data is missing in selected language +fixed order of certification preferences in setting + </news> + <summary lang="en_GB">Fetch TV Show metadata from themoviedb.org</summary> + <description lang="en_GB">The Movie Database (TMDb) is a community built movie and TV database. Every piece of data has been added by our amazing community dating back to 2008. TMDb's strong international focus and breadth of data is largely unmatched and something we're incredibly proud of. Put simply, we live and breathe community and that's precisely what makes us different.</description> + <platform>all</platform> + <license>GPL-3.0-or-later</license> + <assets> + <icon>resources/icon.png</icon> + </assets> + <forum>https://forum.kodi.tv/showthread.php?tid=357232</forum> + <website>https://www.themoviedb.org</website> + <source>https://github.com/xbmc/metadata.tvshows.themoviedb.org.python</source> + </extension> +</addon> + diff --git a/addons/metadata.tvshows.themoviedb.org.python/changelog.txt b/addons/metadata.tvshows.themoviedb.org.python/changelog.txt new file mode 100644 index 0000000000..184f7861c8 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/changelog.txt @@ -0,0 +1,52 @@ +1.3.0 +scraper now returns URL references for all possible art so Kodi can decide what to display based on system settings + +1.2.3 +fix for crash if show had no network listed on TMDb + +1.2.2 +change so that scraper returns English data for a show if data is missing in selected language +fixed order of certification preferences in setting + +1.2.1 +pull configuration for TMDb API from the API server and cache it +provide preview image for art lists (provides faster loading of small images) +delete expired cache files periodically +first version available via the Kodi repo + + +1.2.0 +removed external module dependencies +version number change to reflect that Leia and Matrix code are no longer in sync (Leia will remain on 1.1.x, Matrix will be 1.2.x and higher) + + +1.1.13 +added back Trakt ratings (different method to avoid crashes) +changed how images are retrieved to ensure something is returned in most cases (see post below for more details) + + +1.1.12 +fix for crash if scraping an episode with an nfo file that doesn't have the TMDb ID in it + + +1.1.11 +fix for source settings being ignored + + +1.1.10 +removed Trakt support due to periodic crashes + + +1.1.9 +added option to get ratings from Trakt and IMDb +added option to disable the text prepended to the content rating +re-arranged settings +since the code is shared between the two releases, synced version numbers + + +1.1.8 +fix for crash if scraping a show with lots of artwork + + +1.1.7 +added support for fanarttv client key
\ No newline at end of file diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/__init__.py b/addons/metadata.tvshows.themoviedb.org.python/libs/__init__.py new file mode 100644 index 0000000000..2cbe995660 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/__init__.py @@ -0,0 +1,2 @@ +# coding: utf-8 +# Author:Team Kodi diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/actions.py b/addons/metadata.tvshows.themoviedb.org.python/libs/actions.py new file mode 100644 index 0000000000..30409036f2 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/actions.py @@ -0,0 +1,200 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring +# +# This is based on the metadata.tvmaze scrapper by Roman Miroshnychenko aka Roman V.M. + +"""Plugin route actions""" + +from __future__ import absolute_import, unicode_literals + +import sys, urllib.parse +import xbmcgui, xbmcplugin +from . import tmdb, data_utils +from .utils import logger, safe_get +try: + from typing import Optional, Text, Union, ByteString # pylint: disable=unused-import +except ImportError: + pass + +HANDLE = int(sys.argv[1]) # type: int + + +def find_show(title, year=None): + # type: (Union[Text, bytes], Optional[Text]) -> None + """Find a show by title""" + if not isinstance(title, str): + title = title.decode('utf-8') + logger.debug('Searching for TV show {} ({})'.format(title, year)) + search_results = tmdb.search_show(title, year) + for search_result in search_results: + show_name = search_result['name'] + if safe_get(search_result, 'first_air_date') is not None: + show_name += ' ({})'.format(search_result['first_air_date'][:4]) + list_item = xbmcgui.ListItem(show_name, offscreen=True) + show_info = search_result + list_item = data_utils.add_main_show_info(list_item, show_info, full_info=False) + # Below "url" is some unique ID string (may be an actual URL to a show page) + # that is used to get information about a specific TV show. + xbmcplugin.addDirectoryItem( + HANDLE, + url=str(search_result['id']), + listitem=list_item, + isFolder=True + ) + + +def get_show_id_from_nfo(nfo): + # type: (Text) -> None + """ + Get show ID by NFO file contents + + This function is called first instead of find_show + if a NFO file is found in a TV show folder. + + :param nfo: the contents of a NFO file + """ + if isinstance(nfo, bytes): + nfo = nfo.decode('utf-8', 'replace') + logger.debug('Parsing NFO file:\n{}'.format(nfo)) + parse_result = data_utils.parse_nfo_url(nfo) + if parse_result: + if parse_result.provider == 'themoviedb': + show_info = tmdb.load_show_info(parse_result.show_id, ep_grouping=parse_result.ep_grouping) + else: + show_info = None + if show_info is not None: + list_item = xbmcgui.ListItem(show_info['name'], offscreen=True) + # "url" is some string that unique identifies a show. + # It may be an actual URL of a TV show page. + xbmcplugin.addDirectoryItem( + HANDLE, + url=str(show_info['id']), + listitem=list_item, + isFolder=True + ) + + +def get_details(show_id): + # type: (Text) -> None + """Get details about a specific show""" + logger.debug('Getting details for show id {}'.format(show_id)) + show_info = tmdb.load_show_info(show_id) + if show_info is not None: + list_item = xbmcgui.ListItem(show_info['name'], offscreen=True) + list_item = data_utils.add_main_show_info(list_item, show_info, full_info=True) + xbmcplugin.setResolvedUrl(HANDLE, True, list_item) + else: + xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem(offscreen=True)) + + +def get_episode_list(show_id): # pylint: disable=missing-docstring + # type: (Text) -> None + logger.debug('Getting episode list for show id {}'.format(show_id)) + if not show_id.isdigit(): + # Kodi has a bug: when a show directory contains an XML NFO file with + # episodeguide URL, that URL is always passed here regardless of + # the actual parsing result in get_show_from_nfo() + parse_result = data_utils.parse_nfo_url(show_id) + if not parse_result: + return + if parse_result.provider == 'themoviedb': + show_info = tmdb.load_show_info(parse_result.show_id) + else: + return + else: + show_info = tmdb.load_show_info(show_id) + if show_info is not None: + theindex = 0 + for episode in show_info['episodes']: + list_item = xbmcgui.ListItem(episode['name'], offscreen=True) + list_item = data_utils.add_episode_info(list_item, episode, full_info=False) + encoded_ids = urllib.parse.urlencode( + {'show_id': str(show_info['id']), 'episode_id': str(theindex)} + ) + theindex = theindex + 1 + # Below "url" is some unique ID string (may be an actual URL to an episode page) + # that allows to retrieve information about a specific episode. + url = urllib.parse.quote(encoded_ids) + xbmcplugin.addDirectoryItem( + HANDLE, + url=url, + listitem=list_item, + isFolder=True + ) + + +def get_episode_details(encoded_ids): # pylint: disable=missing-docstring + # type: (Text) -> None + encoded_ids = urllib.parse.unquote(encoded_ids) + decoded_ids = dict(urllib.parse.parse_qsl(encoded_ids)) + logger.debug('Getting episode details for {}'.format(decoded_ids)) + episode_info = tmdb.load_episode_info( + decoded_ids['show_id'], decoded_ids['episode_id'] + ) + if episode_info: + list_item = xbmcgui.ListItem(episode_info['name'], offscreen=True) + list_item = data_utils.add_episode_info(list_item, episode_info, full_info=True) + xbmcplugin.setResolvedUrl(HANDLE, True, list_item) + else: + xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem(offscreen=True)) + + +def get_artwork(show_id): + # type: (Text) -> None + """ + Get available artwork for a show + + :param show_id: default unique ID set by setUniqueIDs() method + """ + if not show_id: + return + logger.debug('Getting artwork for show ID {}'.format(show_id)) + show_info = tmdb.load_show_info(show_id) + if show_info is not None: + list_item = xbmcgui.ListItem(show_info['name'], offscreen=True) + list_item = data_utils.set_show_artwork(show_info, list_item) + xbmcplugin.setResolvedUrl(HANDLE, True, list_item) + else: + xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem(offscreen=True)) + + +def router(paramstring): + # type: (Text) -> None + """ + Route addon calls + + :param paramstring: url-encoded query string + :raises RuntimeError: on unknown call action + """ + params = dict(urllib.parse.parse_qsl(paramstring)) + logger.debug('Called addon with params: {}'.format(sys.argv)) + if params['action'] == 'find': + find_show(params['title'], params.get('year')) + elif params['action'].lower() == 'nfourl': + get_show_id_from_nfo(params['nfo']) + elif params['action'] == 'getdetails': + get_details(params['url']) + elif params['action'] == 'getepisodelist': + get_episode_list(params['url']) + elif params['action'] == 'getepisodedetails': + get_episode_details(params['url']) + elif params['action'] == 'getartwork': + get_artwork(params.get('id')) + else: + raise RuntimeError('Invalid addon call: {}'.format(sys.argv)) + xbmcplugin.endOfDirectory(HANDLE) diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/api_utils.py b/addons/metadata.tvshows.themoviedb.org.python/libs/api_utils.py new file mode 100644 index 0000000000..71ad98732f --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/api_utils.py @@ -0,0 +1,72 @@ +# coding: utf-8 +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +"""Functions to interact with various web site APIs""" + +from __future__ import absolute_import, unicode_literals + +import json +from urllib.request import Request, urlopen +from urllib.error import URLError +from urllib.parse import urlencode +from pprint import pformat +from .utils import logger +try: + from typing import Text, Optional, Union, List, Dict, Any # pylint: disable=unused-import + InfoType = Dict[Text, Any] # pylint: disable=invalid-name +except ImportError: + pass + +HEADERS = {} + + +def set_headers(headers): + HEADERS.update(headers) + + +def load_info(url, params=None, default=None, resp_type = 'json', verboselog=False): + # type: (Text, Optional[Dict[Text, Union[Text, List[Text]]]]) -> Union[dict, list] + """ + Load info from external api + + :param url: API endpoint URL + :param params: URL query params + :default: object to return if there is an error + :resp_type: what to return to the calling function + :return: API response or default on error + """ + if params: + url = url + '?' + urlencode(params) + logger.debug('Calling URL "{}"'.format(url)) + req = Request(url, headers=HEADERS) + try: + response = urlopen(req) + except URLError as e: + if hasattr(e, 'reason'): + logger.debug('failed to reach the remote site\nReason: {}'.format(e.reason)) + elif hasattr(e, 'code'): + logger.debug('remote site unable to fulfill the request\nError code: {}'.format(e.code)) + response = None + if response is None: + resp = default + elif resp_type.lower() == 'json': + resp = json.loads(response.read().decode('utf-8')) + else: + resp = response.read().decode('utf-8') + if verboselog: + logger.debug('the api response:\n{}'.format(pformat(resp))) + return resp diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/cache.py b/addons/metadata.tvshows.themoviedb.org.python/libs/cache.py new file mode 100644 index 0000000000..aec026b38e --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/cache.py @@ -0,0 +1,97 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring +# +# This is based on the metadata.tvmaze scrapper by Roman Miroshnychenko aka Roman V.M. + +"""Cache-related functionality""" + +from __future__ import absolute_import, unicode_literals + +import os, pickle +from datetime import datetime, timedelta +import xbmc, xbmcvfs + +from .utils import ADDON, logger + +try: + from typing import Optional, Text, Dict, Any # pylint: disable=unused-import +except ImportError: + pass + + +CACHING_DURATION = timedelta(hours=3) # type: timedelta + + +def _get_cache_directory(): # pylint: disable=missing-docstring + # type: () -> Text + profile_dir = xbmcvfs.translatePath(ADDON.getAddonInfo('profile')) + cache_dir = os.path.join(profile_dir, 'cache') + if not xbmcvfs.exists(cache_dir): + xbmcvfs.mkdir(cache_dir) + return cache_dir + + +CACHE_DIR = _get_cache_directory() # type: Text + + +def clean_cache(): + """ + delete cache items that have expired + """ + dirs, files = xbmcvfs.listdir(CACHE_DIR) + for filename in files: + filepath = os.path.join(CACHE_DIR, filename) + lastmod = datetime.fromtimestamp(xbmcvfs.Stat(filepath).st_mtime()) + if datetime.now() - lastmod > CACHING_DURATION: + xbmcvfs.delete(filepath) + + +def cache_show_info(show_info): + # type: (Dict[Text, Any]) -> None + """ + Save show_info dict to cache + """ + file_name = str(show_info['id']) + '.pickle' + cache = { + 'show_info': show_info, + 'timestamp': datetime.now(), + } + with open(os.path.join(CACHE_DIR, file_name), 'wb') as fo: + pickle.dump(cache, fo, protocol=2) + + +def load_show_info_from_cache(show_id): + # type: (Text) -> Optional[Dict[Text, Any]] + """ + Load show info from a local cache + + :param show_id: show ID on TVmaze + :return: show_info dict or None + """ + file_name = str(show_id) + '.pickle' + try: + with open(os.path.join(CACHE_DIR, file_name), 'rb') as fo: + load_kwargs = {} + load_kwargs['encoding'] = 'bytes' + cache = pickle.load(fo, **load_kwargs) + if datetime.now() - cache['timestamp'] > CACHING_DURATION: + return None + return cache['show_info'] + except (IOError, pickle.PickleError) as exc: + logger.debug('Cache message: {} {}'.format(type(exc), exc)) + return None diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/data_utils.py b/addons/metadata.tvshows.themoviedb.org.python/libs/data_utils.py new file mode 100644 index 0000000000..9708bc364a --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/data_utils.py @@ -0,0 +1,332 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring +# +# This is based on the metadata.tvmaze scrapper by Roman Miroshnychenko aka Roman V.M. + +"""Functions to process data""" + +from __future__ import absolute_import, unicode_literals + +import re, json +from collections import OrderedDict, namedtuple +from .utils import safe_get, logger +from . import settings + +try: + from typing import Optional, Text, Dict, List, Any # pylint: disable=unused-import + from xbmcgui import ListItem # pylint: disable=unused-import + InfoType = Dict[Text, Any] # pylint: disable=invalid-name +except ImportError: + pass + +TAG_RE = re.compile(r'<[^>]+>') +SHOW_ID_REGEXPS = ( + r'(tvmaze)\.com/shows/(\d+)/[\w\-]', + r'(thetvdb)\.com/.*?series/(\d+)', + r'(thetvdb)\.com[\w=&\?/]+id=(\d+)', + r'(imdb)\.com/[\w/\-]+/(tt\d+)', + r'(themoviedb)\.org/tv/(\d+).*/episode_group/(.*)', + r'(themoviedb)\.org/tv/(\d+)' +) +SUPPORTED_ARTWORK_TYPES = {'poster', 'banner'} +IMAGE_SIZES = ('large', 'original', 'medium') +CLEAN_PLOT_REPLACEMENTS = ( + ('<b>', '[B]'), + ('</b>', '[/B]'), + ('<i>', '[I]'), + ('</i>', '[/I]'), + ('</p><p>', '[CR]'), +) +VALIDEXTIDS = ['tmdb_id', 'imdb_id', 'tvdb_id'] + +UrlParseResult = namedtuple('UrlParseResult', ['provider', 'show_id', 'ep_grouping']) + + + +def _clean_plot(plot): + # type: (Text) -> Text + """Replace HTML tags with Kodi skin tags""" + for repl in CLEAN_PLOT_REPLACEMENTS: + plot = plot.replace(repl[0], repl[1]) + plot = TAG_RE.sub('', plot) + return plot + + +def _set_cast(cast_info, list_item): + # type: (InfoType, ListItem) -> ListItem + """Save cast info to list item""" + cast = [] + for item in cast_info: + data = { + 'name': item['name'], + 'role': item['character'], + 'order': item['order'], + } + thumb = None + if safe_get(item, 'profile_path') is not None: + thumb = settings.IMAGEROOTURL + item['profile_path'] + if thumb: + data['thumbnail'] = thumb + cast.append(data) + list_item.setCast(cast) + return list_item + + +def _get_credits(show_info): + # type: (InfoType) -> List[Text] + """Extract show creator(s) and writer(s) from show info""" + credits_ = [] + for item in show_info.get('created_by', []): + credits_.append(item['name']) + for item in show_info.get('credits', {}).get('crew', []): + if item.get('job') == 'Writer' and item.get('name') not in credits_: + credits_.append(item['name']) + return credits_ + + +def _get_directors(episode_info): + # type: (InfoType) -> List[Text] + """Extract episode writer(s) from episode info""" + directors_ = [] + for item in episode_info.get('credits', {}).get('crew', []): + if item.get('job') == 'Director': + directors_.append(item['name']) + return directors_ + + +def _set_unique_ids(ext_ids, list_item): + # type: (InfoType, ListItem) -> ListItem + """Extract unique ID in various online databases""" + unique_ids = {} + for key, value in ext_ids.items(): + if key in VALIDEXTIDS and value: + key = key[:-3] + unique_ids[key] = str(value) + list_item.setUniqueIDs(unique_ids, 'tmdb') + return list_item + + +def _set_rating(the_info, list_item, episode=False): + # type: (InfoType, ListItem) -> ListItem + """Set show/episode rating""" + first = True + for rating_type in settings.RATING_TYPES: + logger.debug('adding rating type of %s' % rating_type) + rating = float(the_info.get('ratings', {}).get(rating_type, {}).get('rating', '0')) + votes = int(the_info.get('ratings', {}).get(rating_type, {}).get('votes', '0')) + logger.debug("adding rating of %s and votes of %s" % (str(rating), str(votes))) + if rating > 0: + list_item.setRating(rating_type, rating, votes=votes, defaultt=first) + first = False + return list_item + + +def _add_season_info(show_info, list_item): + # type: (InfoType, ListItem) -> ListItem + """Add info for show seasons""" + for season in show_info['seasons']: + list_item.addSeason(season['season_number'], safe_get(season, 'name', '')) +# image = season.get('poster_path', '') +# if image: +# url = settings.IMAGEROOTURL + image +# list_item.addAvailableArtwork(url, 'poster', season=season['season_number']) + for image_type, image_list in season.get('images', {}).items(): + if image_type == 'posters': + destination = 'poster' + else: + destination = image_type + for image in image_list: + if image.get('type') == 'fanarttv': + theurl = image['file_path'] + previewurl = theurl.replace('.fanart.tv/fanart/', '.fanart.tv/preview/') + else: + theurl = settings.IMAGEROOTURL + image['file_path'] + previewurl = settings.PREVIEWROOTURL + image['file_path'] + list_item.addAvailableArtwork(theurl, art_type=destination, preview=previewurl, season=season['season_number']) + return list_item + + +def set_show_artwork(show_info, list_item): + # type: (InfoType, ListItem) -> ListItem + """Set available images for a show""" + for image_type, image_list in show_info.get('images', {}).items(): + if image_type == 'backdrops': + fanart_list = [] + for image in image_list: + if image.get('type') == 'fanarttv': + theurl = image['file_path'] + else: + theurl = settings.IMAGEROOTURL + image['file_path'] + fanart_list.append({'image': theurl}) + if fanart_list: + list_item.setAvailableFanart(fanart_list) + else: + if image_type == 'posters': + destination = 'poster' + else: + destination = image_type + for image in image_list: + if image.get('type') == 'fanarttv': + theurl = image['file_path'] + previewurl = theurl.replace('.fanart.tv/fanart/', '.fanart.tv/preview/') + else: + theurl = settings.IMAGEROOTURL + image['file_path'] + previewurl = settings.PREVIEWROOTURL + image['file_path'] + list_item.addAvailableArtwork(theurl, art_type=destination, preview=previewurl) + return list_item + + +def add_main_show_info(list_item, show_info, full_info=True): + # type: (ListItem, InfoType, bool) -> ListItem + """Add main show info to a list item""" + plot = _clean_plot(safe_get(show_info, 'overview', '')) + original_name = show_info.get('original_name') + if settings.KEEPTITLE and original_name: + showname = original_name + else: + showname = show_info['name'] + video = { + 'plot': plot, + 'plotoutline': plot, + 'title': showname, + 'tvshowtitle': showname, + 'mediatype': 'tvshow', + # This property is passed as "url" parameter to getepisodelist call + 'episodeguide': str(show_info['id']), + } + if show_info.get('first_air_date'): + video['year'] = int(show_info['first_air_date'][:4]) + video['premiered'] = show_info['first_air_date'] + if full_info: + video['status'] = safe_get(show_info, 'status', '') + genre_list = safe_get(show_info, 'genres', {}) + genres = [] + for genre in genre_list: + genres.append(genre['name']) + video['genre'] = genres + networks = show_info.get('networks', []) + if networks: + network = networks[0] + country = network.get('origin_country', '') + else: + network = None + country = None + if network and country: + video['studio'] = '{0} ({1})'.format(network['name'], country) + video['country'] = country + content_ratings = show_info.get('content_ratings', {}).get('results', {}) + if content_ratings: + mpaa = '' + mpaa_backup = '' + for content_rating in content_ratings: + iso = content_rating.get('iso_3166_1', '').lower() + if iso == 'us': + mpaa_backup = content_rating.get('rating') + if iso == settings.CERT_COUNTRY.lower(): + mpaa = content_rating.get('rating', '') + if not mpaa: + mpaa = mpaa_backup + if mpaa: + video['Mpaa'] = settings.CERT_PREFIX + mpaa + video['credits'] = video['writer'] = _get_credits(show_info) + list_item = set_show_artwork(show_info, list_item) + list_item = _add_season_info(show_info, list_item) + list_item = _set_cast(show_info['credits']['cast'], list_item) + list_item = _set_rating(show_info, list_item) + ext_ids = {'tmdb_id': show_info['id']} + ext_ids.update(show_info.get('external_ids', {})) + list_item = _set_unique_ids(ext_ids, list_item) + else: + image = safe_get(show_info, 'poster_path', '') + if image: + theurl = settings.IMAGEROOTURL + image + previewurl = settings.PREVIEWROOTURL + image + list_item.addAvailableArtwork(theurl, art_type='poster', preview=previewurl) + list_item.setInfo('video', video) + # This is needed for getting artwork + list_item = _set_unique_ids(show_info, list_item) + return list_item + + +def add_episode_info(list_item, episode_info, full_info=True): + # type: (ListItem, InfoType, bool) -> ListItem + """Add episode info to a list item""" + video = { + 'title': episode_info['name'], + 'season': episode_info['season_number'], + 'episode': episode_info['episode_number'], + 'mediatype': 'episode', + } + if safe_get(episode_info, 'air_date') is not None: + video['aired'] = episode_info['air_date'] + if full_info: + summary = safe_get(episode_info, 'overview') + if summary is not None: + video['plot'] = video['plotoutline'] = _clean_plot(summary) + if safe_get(episode_info, 'air_date') is not None: + video['premiered'] = episode_info['air_date'] + list_item = _set_cast(episode_info['credits']['guest_stars'], list_item) + ext_ids = {'tmdb_id': episode_info['id']} + ext_ids.update(episode_info.get('external_ids', {})) + list_item = _set_unique_ids(ext_ids, list_item) + list_item = _set_rating(episode_info, list_item, episode=True) + for image in episode_info.get('images', {}).get('stills', []): + img_path = image.get('file_path') + if img_path: + theurl = settings.IMAGEROOTURL + img_path + previewurl = settings.PREVIEWROOTURL + img_path + list_item.addAvailableArtwork(theurl, art_type='thumb', preview=previewurl) + video['credits'] = video['writer'] = _get_credits(episode_info) + video['director'] = _get_directors(episode_info) + list_item.setInfo('video', video) + return list_item + + +def parse_nfo_url(nfo): + # type: (Text) -> Optional[UrlParseResult] + """Extract show ID from NFO file contents""" + for regexp in SHOW_ID_REGEXPS: + logger.debug('trying regex to match service from parsing nfo:') + logger.debug(regexp) + show_id_match = re.search(regexp, nfo, re.I) + if show_id_match: + logger.debug('match group 1: ' + show_id_match.group(1)) + logger.debug('match group 2: ' + show_id_match.group(2)) + try: + ep_grouping = show_id_match.group(3) + except IndexError: + ep_grouping = None + if ep_grouping is not None: + logger.debug('match group 3: ' + ep_grouping) + else: + logger.debug('match group 3: None') + return UrlParseResult(show_id_match.group(1), show_id_match.group(2), ep_grouping) + return None + + +def parse_media_id(title): + title = title.lower() + if title.startswith('tt') and title[2:].isdigit(): + return {'type': 'imdb_id', 'title': title} # IMDB ID works alone because it is clear + elif title.startswith('imdb/tt') and title[7:].isdigit(): # IMDB ID with prefix to match + return {'type': 'imdb_id', 'title': title[5:]} # IMDB ID works alone because it is clear + elif title.startswith('tmdb/') and title[5:].isdigit(): # TVDB ID + return {'type': 'tmdb_id', 'title': title[5:]} + elif title.startswith('tvdb/') and title[5:].isdigit(): # TVDB ID + return {'type': 'tvdb_id', 'title': title[5:]} + return None diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/debugger.py b/addons/metadata.tvshows.themoviedb.org.python/libs/debugger.py new file mode 100644 index 0000000000..fd63eff084 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/debugger.py @@ -0,0 +1,111 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring +# +# This is based on the metadata.tvmaze scrapper by Roman Miroshnychenko aka Roman V.M. + +""" +Provides a context manager that writes extended debugging info +in the Kodi log on unhandled exceptions +""" +from __future__ import absolute_import, unicode_literals + +import inspect +from contextlib import contextmanager +from platform import uname +from pprint import pformat + +import xbmc + +from .utils import logger + +try: + from typing import Text, Generator, Callable, Dict, Any # pylint: disable=unused-import +except ImportError: + pass + + +def _format_vars(variables): + # type: (Dict[Text, Any]) -> Text + """ + Format variables dictionary + + :param variables: variables dict + :type variables: dict + :return: formatted string with sorted ``var = val`` pairs + :rtype: str + """ + var_list = [(var, val) for var, val in variables.items() + if not (var.startswith('__') or var.endswith('__'))] + var_list.sort(key=lambda i: i[0]) + lines = [] + for var, val in var_list: + lines.append('{0} = {1}'.format(var, pformat(val))) + return '\n'.join(lines) + + +@contextmanager +def debug_exception(logger_func=logger.error): + # type: (Callable[[Text], None]) -> Generator[None] + """ + Diagnostic helper context manager + + It controls execution within its context and writes extended + diagnostic info to the Kodi log if an unhandled exception + happens within the context. The info includes the following items: + + - System info + - Kodi version + - Module path. + - Code fragment where the exception has happened. + - Global variables. + - Local variables. + + After logging the diagnostic info the exception is re-raised. + + Example:: + + with debug_exception(): + # Some risky code + raise RuntimeError('Fatal error!') + + :param logger_func: logger function which must accept a single argument + which is a log message. + """ + try: + yield + except Exception as exc: + frame_info = inspect.trace(5)[-1] + logger_func('*** Unhandled exception detected: {} {} ***'.format(type(exc), exc)) + logger_func('*** Start diagnostic info ***') + logger_func('System info: {0}'.format(uname())) + logger_func('OS info: {0}'.format(xbmc.getInfoLabel('System.OSVersionInfo'))) + logger_func('Kodi version: {0}'.format( + xbmc.getInfoLabel('System.BuildVersion'))) + logger_func('File: {0}'.format(frame_info[1])) + context = '' + if frame_info[4] is not None: + for i, line in enumerate(frame_info[4], frame_info[2] - frame_info[5]): + if i == frame_info[2]: + context += '{0}:>{1}'.format(str(i).rjust(5), line) + else: + context += '{0}: {1}'.format(str(i).rjust(5), line) + logger_func('Code context:\n' + context) + logger_func('Global variables:\n' + _format_vars(frame_info[0].f_globals)) + logger_func('Local variables:\n' + _format_vars(frame_info[0].f_locals)) + logger_func('**** End diagnostic info ****') + raise exc diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/imdbratings.py b/addons/metadata.tvshows.themoviedb.org.python/libs/imdbratings.py new file mode 100644 index 0000000000..331e55bae1 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/imdbratings.py @@ -0,0 +1,62 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# IMDb ratings based on code in metadata.themoviedb.org.python by Team Kodi +# pylint: disable=missing-docstring + + +import re +from . import api_utils +from . import settings + +IMDB_RATINGS_URL = 'https://www.imdb.com/title/{}/' +IMDB_RATING_REGEX = re.compile(r'itemprop="ratingValue".*?>.*?([\d.]+).*?<') +IMDB_VOTES_REGEX = re.compile(r'itemprop="ratingCount".*?>.*?([\d,]+).*?<') + + +def get_details(imdb_id): + if not imdb_id: + return {} + votes, rating = _get_ratinginfo(imdb_id) + return _assemble_imdb_result(votes, rating) + +def _get_ratinginfo(imdb_id): + response = api_utils.load_info(IMDB_RATINGS_URL.format(imdb_id), default = '', resp_type='text', verboselog=settings.VERBOSELOG) + return _parse_imdb_result(response) + +def _assemble_imdb_result(votes, rating): + result = {} + if votes and rating: + result['ratings'] = {'imdb': {'votes': votes, 'rating': rating}} + return result + +def _parse_imdb_result(input_html): + rating = _parse_imdb_rating(input_html) + votes = _parse_imdb_votes(input_html) + return votes, rating + +def _parse_imdb_rating(input_html): + match = re.search(IMDB_RATING_REGEX, input_html) + if (match): + return float(match.group(1)) + return None + +def _parse_imdb_votes(input_html): + match = re.search(IMDB_VOTES_REGEX, input_html) + if (match): + return int(match.group(1).replace(',', '')) + return None diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/settings.py b/addons/metadata.tvshows.themoviedb.org.python/libs/settings.py new file mode 100644 index 0000000000..e6bba54a90 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/settings.py @@ -0,0 +1,98 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring + +import json, sys, urllib.parse +from .utils import logger +from . import api_utils, cache +from pprint import pformat +from xbmcaddon import Addon +from datetime import datetime, timedelta + + +def _get_date_numeric(datetime_): + return (datetime_ - datetime(1970, 1, 1)).total_seconds() + + +def _get_configuration(): + logger.debug('getting configuration details') + return api_utils.load_info('https://api.themoviedb.org/3/configuration', params={'api_key': TMDB_CLOWNCAR}, verboselog=VERBOSELOG) + + +def _load_base_urls(): + image_root_url = ADDON.getSettingString('originalUrl') + preview_root_url = ADDON.getSettingString('previewUrl') + last_updated = ADDON.getSettingString('lastUpdated') + if not image_root_url or not preview_root_url or not last_updated or \ + float(last_updated) < _get_date_numeric(datetime.now() - timedelta(days=30)): + cache.clean_cache() + conf = _get_configuration() + if conf: + image_root_url = conf['images']['secure_base_url'] + 'original' + preview_root_url = conf['images']['secure_base_url'] + 'w780' + ADDON.setSetting('originalUrl', image_root_url) + ADDON.setSetting('previewUrl', preview_root_url) + ADDON.setSetting('lastUpdated', str(_get_date_numeric(datetime.now()))) + return image_root_url, preview_root_url + + +ADDON = Addon() +TMDB_CLOWNCAR = 'af3a53eb387d57fc935e9128468b1899' +FANARTTV_CLOWNCAR = 'b018086af0e1478479adfc55634db97d' +TRAKT_CLOWNCAR = '90901c6be3b2de5a4fa0edf9ab5c75e9a5a0fef2b4ee7373d8b63dcf61f95697' +MAXIMAGES = 350 +FANARTTV_MAPPING = { 'showbackground': 'backdrops', + 'tvposter': 'posters', + 'tvbanner': 'banner', + 'hdtvlogo': 'clearlogo', + 'clearlogo': 'clearlogo', + 'hdclearart': 'clearart', + 'clearart': 'clearart', + 'tvthumb': 'landscape', + 'characterart': 'characterart', + 'seasonposter':'seasonposters', + 'seasonbanner':'seasonbanner', + 'seasonthumb': 'seasonlandscape' + } + +try: + source_params = dict(urllib.parse.parse_qsl(sys.argv[2])) +except IndexError: + source_params = {} +source_settings = json.loads(source_params.get('pathSettings', {})) +logger.debug('the source settings are:\n{}'.format(pformat(source_settings))) + +KEEPTITLE =source_settings.get('keeporiginaltitle', ADDON.getSettingBool('keeporiginaltitle')) +VERBOSELOG = source_settings.get('verboselog', ADDON.getSettingBool('verboselog')) +LANG = source_settings.get('language', ADDON.getSettingString('language')) +CERT_COUNTRY = source_settings.get('tmdbcertcountry', ADDON.getSettingString('tmdbcertcountry')).lower() +IMAGEROOTURL, PREVIEWROOTURL = _load_base_urls() + +if source_settings.get('usecertprefix', ADDON.getSettingBool('usecertprefix')): + CERT_PREFIX = source_settings.get('certprefix', ADDON.getSettingString('certprefix')) +else: + CERT_PREFIX = '' +primary_rating = source_settings.get('ratings', ADDON.getSettingString('ratings')).lower() +RATING_TYPES = [primary_rating] +if source_settings.get('imdbanyway', ADDON.getSettingBool('imdbanyway')) and primary_rating != 'imdb': + RATING_TYPES.append('imdb') +if source_settings.get('traktanyway', ADDON.getSettingBool('traktanyway')) and primary_rating != 'trakt': + RATING_TYPES.append('trakt') +if source_settings.get('tmdbanyway', ADDON.getSettingBool('tmdbanyway')) and primary_rating != 'tmdb': + RATING_TYPES.append('tmdb') +FANARTTV_ENABLE = source_settings.get('enable_fanarttv', ADDON.getSettingBool('enable_fanarttv')) +FANARTTV_CLIENTKEY = source_settings.get('fanarttv_clientkey', ADDON.getSettingString('fanarttv_clientkey')) diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/tmdb.py b/addons/metadata.tvshows.themoviedb.org.python/libs/tmdb.py new file mode 100644 index 0000000000..8f4a136927 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/tmdb.py @@ -0,0 +1,388 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring + +"""Functions to interact with TMDb API""" + +from __future__ import absolute_import, unicode_literals + +from math import floor +from pprint import pformat +from . import cache, data_utils, api_utils, settings, imdbratings, traktratings +from .utils import logger +try: + from typing import Text, Optional, Union, List, Dict, Any # pylint: disable=unused-import + InfoType = Dict[Text, Any] # pylint: disable=invalid-name +except ImportError: + pass + +HEADERS = ( + ('User-Agent', 'Kodi TV Show scraper by Team Kodi; contact pkscout@kodi.tv'), + ('Accept', 'application/json'), +) +api_utils.set_headers(dict(HEADERS)) + +TMDB_PARAMS = {'api_key': settings.TMDB_CLOWNCAR, 'language': settings.LANG} +BASE_URL = 'https://api.themoviedb.org/3/{}' +EPISODE_GROUP_URL = BASE_URL.format('tv/episode_group/{}') +SEARCH_URL = BASE_URL.format('search/tv') +FIND_URL = BASE_URL.format('find/{}') +SHOW_URL = BASE_URL.format('tv/{}') +SEASON_URL = BASE_URL.format('tv/{}/season/{}') +EPISODE_URL = BASE_URL.format('tv/{}/season/{}/episode/{}') +FANARTTV_URL = 'https://webservice.fanart.tv/v3/tv/{}' +FANARTTV_PARAMS = {'api_key': settings.FANARTTV_CLOWNCAR} +if settings.FANARTTV_CLIENTKEY: + FANARTTV_PARAMS['client_key'] = settings.FANARTTV_CLIENTKEY + + +def search_show(title, year=None): + # type: (Text) -> List[InfoType] + """ + Search for a single TV show + + :param title: TV show title to search + : param year: the year to search (optional) + :return: a list with found TV shows + """ + params = TMDB_PARAMS.copy() + results = [] + ext_media_id = data_utils.parse_media_id(title) + if ext_media_id: + logger.debug('using %s of %s to find show' % (ext_media_id['type'], ext_media_id['title'])) + if ext_media_id['type'] == 'tmdb_id': + search_url = SHOW_URL.format(ext_media_id['title']) + else: + search_url = FIND_URL.format(ext_media_id['title']) + params['external_source'] = ext_media_id['type'] + else: + logger.debug('using title of %s to find show' % title) + search_url = SEARCH_URL + params['query'] = title + if year: + params['first_air_date_year'] = str(year) + resp = api_utils.load_info(search_url, params=params, verboselog=settings.VERBOSELOG) + if resp is not None: + if ext_media_id: + if ext_media_id['type'] == 'tmdb_id': + if resp.get('success') == 'false': + results = [] + else: + results = [resp] + else: + results = resp.get('tv_results', []) + else: + results = resp.get('results', []) + return results + + +def load_episode_list(show_info, season_map, ep_grouping): + # type: (Text) -> List[InfoType] + """Load episode list from themoviedb.org API""" + episode_list = [] + if ep_grouping is not None: + logger.debug('Getting episodes with episode grouping of ' + ep_grouping) + episode_group_url = EPISODE_GROUP_URL.format(ep_grouping) + custom_order = api_utils.load_info(episode_group_url, params=TMDB_PARAMS, verboselog=settings.VERBOSELOG) + if custom_order is not None: + show_info['seasons'] = [] + season_num = 1 + for custom_season in custom_order.get('groups', []): + ep_num = 1 + season_episodes = [] + current_season = season_map.get(str(custom_season['episodes'][0]['season_number']), {}).copy() + current_season['name'] = custom_season['name'] + current_season['season_number'] = season_num + for episode in custom_season['episodes']: + episode['org_seasonnum'] = episode['season_number'] + episode['org_epnum'] = episode['episode_number'] + episode['season_number'] = season_num + episode['episode_number'] = ep_num + season_episodes.append(episode) + episode_list.append(episode) + ep_num = ep_num + 1 + current_season['episodes'] = season_episodes + show_info['seasons'].append(current_season) + season_num = season_num + 1 + else: + logger.debug('Getting episodes from standard season list') + show_info['seasons'] = [] + for key, value in season_map.items(): + show_info['seasons'].append(value) + for season in show_info.get('seasons', []): + for episode in season.get('episodes', []): + episode['org_seasonnum'] = episode['season_number'] + episode['org_epnum'] = episode['episode_number'] + episode_list.append(episode) + show_info['episodes'] = episode_list + return show_info + + +def load_show_info(show_id, ep_grouping=None): + # type: (Text) -> Optional[InfoType] + """ + Get full info for a single show + + :param show_id: themoviedb.org show ID + :return: show info or None + """ + show_info = cache.load_show_info_from_cache(show_id) + if show_info is None: + logger.debug('no cache file found, loading from scratch') + show_url = SHOW_URL.format(show_id) + params = TMDB_PARAMS.copy() + params['append_to_response'] = 'credits,content_ratings,external_ids,images' + params['include_image_language'] = '%s,en,null' % settings.LANG[0:2] + show_info = api_utils.load_info(show_url, params=params, verboselog=settings.VERBOSELOG) + if show_info['overview'] == '' and settings.LANG != 'en-US': + params['language'] = 'en-US' + del params['append_to_response'] + show_info_backup = api_utils.load_info(show_url, params=params, verboselog=settings.VERBOSELOG) + params['language'] = settings.LANG + show_info['overview'] = show_info_backup['overview'] + if show_info is None: + return None + season_map = {} + params['append_to_response'] = 'credits,images' + for season in show_info.get('seasons', []): + season_url = SEASON_URL.format(show_id, season['season_number']) + season_info = api_utils.load_info(season_url, params=params, default={}, verboselog=settings.VERBOSELOG) + if (season_info['overview'] == '' or season_info['name'].lower().startswith('season')) and settings.LANG != 'en-US': + params['language'] = 'en-US' + season_info_backup = api_utils.load_info(season_url, params=params, default={}, verboselog=settings.VERBOSELOG) + params['language'] = settings.LANG + if season_info['overview'] == '': + season_info['overview'] = season_info_backup['overview'] + if season_info['name'].lower().startswith('season'): + season_info['name'] = season_info_backup['name'] + season_info['images'] = _sort_image_types(season_info.get('images', {})) + season_map[str(season['season_number'])] = season_info + show_info = load_episode_list(show_info, season_map, ep_grouping) + show_info['ratings'] = load_ratings(show_info) + show_info = load_fanarttv_art(show_info) + show_info['images'] = _sort_image_types(show_info.get('images', {})) + show_info = trim_artwork(show_info) + cast_check = [] + cast = [] + for season in reversed(show_info.get('seasons', [])): + for cast_member in season.get('credits', {}).get('cast', []): + if cast_member['name'] not in cast_check: + cast.append(cast_member) + cast_check.append(cast_member['name']) + show_info['credits']['cast'] = cast + logger.debug('saving show info to the cache') + if settings.VERBOSELOG: + logger.debug(format(pformat(show_info))) + cache.cache_show_info(show_info) + else: + logger.debug('using cached show info') + return show_info + + +def load_episode_info(show_id, episode_id): + # type: (Text, Text) -> Optional[InfoType] + """ + Load episode info + + :param show_id: + :param episode_id: + :return: episode info or None + """ + show_info = load_show_info(show_id) + if show_info is not None: + try: + episode_info = show_info['episodes'][int(episode_id)] + except KeyError: + return None + # this ensures we are using the season/ep from the episode grouping if provided + ep_url = EPISODE_URL.format(show_info['id'], episode_info['org_seasonnum'], episode_info['org_epnum']) + params = TMDB_PARAMS.copy() + params['append_to_response'] = 'credits,external_ids,images' + params['include_image_language'] = '%s,en,null' % settings.LANG[0:2] + ep_return = api_utils.load_info(ep_url, params=params, verboselog=settings.VERBOSELOG) + if (ep_return['overview'] == '' or ep_return['name'].lower().startswith('episode')) and settings.LANG != 'en-US': + params['language'] = 'en-US' + del params['append_to_response'] + ep_return_backup = api_utils.load_info(ep_url, params=params, verboselog=settings.VERBOSELOG) + if ep_return['overview'] == '': + ep_return['overview'] = ep_return_backup['overview'] + if ep_return['name'].lower().startswith('episode'): + ep_return['name'] = ep_return_backup['name'] + if ep_return is None: + return None + ep_return['images'] = _sort_image_types(ep_return.get('images', {})) + ep_return['season_number'] = episode_info['season_number'] + ep_return['episode_number'] = episode_info['episode_number'] + ep_return['org_seasonnum'] = episode_info['org_seasonnum'] + ep_return['org_epnum'] = episode_info['org_epnum'] + ep_return['ratings'] = load_ratings(ep_return, show_imdb_id=show_info.get('external_ids', {}).get('imdb_id')) + show_info['episodes'][int(episode_id)] = ep_return + cache.cache_show_info(show_info) + return ep_return + return None + + +def load_ratings(the_info, show_imdb_id=''): + ratings = {} + imdb_id = the_info.get('external_ids', {}).get('imdb_id') + for rating_type in settings.RATING_TYPES: + logger.debug('setting rating using %s' % rating_type) + if rating_type == 'tmdb': + ratings['tmdb'] = {'votes': the_info['vote_count'], 'rating': the_info['vote_average']} + elif rating_type == 'imdb' and imdb_id: + imdb_rating = imdbratings.get_details(imdb_id).get('ratings') + if imdb_rating: + ratings.update(imdb_rating) + elif rating_type == 'trakt': + if show_imdb_id: + season = the_info['org_seasonnum'] + episode = the_info['org_epnum'] + resp = traktratings.get_details(show_imdb_id, season=season, episode=episode) + else: + resp = traktratings.get_details(imdb_id) + trakt_rating = resp.get('ratings') + if trakt_rating: + ratings.update(trakt_rating) + + logger.debug('returning ratings of\n{}'.format(pformat(ratings))) + return ratings + +def load_fanarttv_art(show_info): + # type: (Text) -> Optional[InfoType] + """ + Add fanart.tv images for a show + + :param show_info: the current show info + :return: show info + """ + tvdb_id = show_info.get('external_ids', {}).get('tvdb_id') + if tvdb_id and settings.FANARTTV_ENABLE: + fanarttv_url = FANARTTV_URL.format(tvdb_id) + artwork = api_utils.load_info(fanarttv_url, params=FANARTTV_PARAMS, verboselog=settings.VERBOSELOG) + if artwork is None: + return show_info + for fanarttv_type, tmdb_type in settings.FANARTTV_MAPPING.items(): + if not show_info['images'].get(tmdb_type) and not tmdb_type.startswith('season'): + show_info['images'][tmdb_type] = [] + for item in artwork.get(fanarttv_type, []): + lang = item.get('lang') + if lang == '' or lang == '00': + lang = None + filepath = '' + if lang is None or lang == settings.LANG[0:2] or lang == 'en': + filepath = item.get('url') + if filepath: + if tmdb_type.startswith('season'): + image_type = tmdb_type[6:] + for s in range(len(show_info.get('seasons', []))): + season_num = show_info['seasons'][s]['season_number'] + artseason = item.get('season', '') + if not show_info['seasons'][s].get('images'): + show_info['seasons'][s]['images'] = {} + if not show_info['seasons'][s]['images'].get(image_type): + show_info['seasons'][s]['images'][image_type] = [] + if artseason == '' or artseason == str(season_num): + show_info['seasons'][s]['images'][image_type].append({'file_path':filepath, 'type':'fanarttv', 'iso_639_1': lang}) + else: + show_info['images'][tmdb_type].append({'file_path':filepath, 'type':'fanarttv', 'iso_639_1': lang}) + return show_info + + +def trim_artwork(show_info): + # type: (Text) -> Optional[InfoType] + """ + Trim artwork to keep the text blob below 65K characters + + :param show_info: the current show info + :return: show info + """ + image_counts = {} + image_total = 0 + backdrops_total = 0 + for image_type, image_list in show_info.get('images', {}).items(): + total = len(image_list) + if image_type == 'backdrops': + backdrops_total = backdrops_total + total + else: + image_counts[image_type] = {'total':total} + image_total = image_total + total + for season in show_info.get('seasons', []): + for image_type, image_list in season.get('images', {}).items(): + total = len(image_list) + thetype = '%s_%s' % (str(season['season_number']), image_type) + image_counts[thetype] = {'total':total} + image_total = image_total + total + if image_total <= settings.MAXIMAGES and backdrops_total <= settings.MAXIMAGES: + return show_info + if backdrops_total > settings.MAXIMAGES: + logger.error('there are %s fanart images' % str(backdrops_total)) + logger.error('that is more than the max of %s, image results will be trimmed to the max' % str(settings.MAXIMAGES)) + reduce = -1 * (backdrops_total - settings.MAXIMAGES ) + del show_info['images']['backdrops'][reduce:] + if image_total > settings.MAXIMAGES: + reduction = (image_total - settings.MAXIMAGES)/image_total + logger.error('there are %s non-fanart images' % str(image_total)) + logger.error('that is more than the max of %s, image results will be trimmed by %s' % (str(settings.MAXIMAGES), str(reduction))) + for key, value in image_counts.items(): + total = value['total'] + reduce = int(floor(total * reduction)) + target = total - reduce + if target < 5: + reduce = 0 + else: + reduce = -1 * reduce + image_counts[key]['reduce'] = reduce + logger.debug('%s: %s' % (key, pformat(image_counts[key]))) + for image_type, image_list in show_info.get('images', {}).items(): + if image_type == 'backdrops': + continue # already handled backdrops above + reduce = image_counts[image_type]['reduce'] + if reduce != 0: + del show_info['images'][image_type][reduce:] + for s in range(len(show_info.get('seasons', []))): + for image_type, image_list in show_info['seasons'][s].get('images', {}).items(): + thetype = '%s_%s' % (str(show_info['seasons'][s]['season_number']), image_type) + reduce = image_counts[thetype]['reduce'] + if reduce != 0: + del show_info['seasons'][s]['images'][image_type][reduce:] + return show_info + + +def _sort_image_types(imagelist): + for image_type, images in imagelist.items(): + imagelist[image_type] = _image_sort(images) + return imagelist + + +def _image_sort(images): + lang_pref = [] + lang_null = [] + lang_en = [] + firstimage = True + for image in images: + image_lang = image.get('iso_639_1') + if image_lang == settings.LANG[0:2]: + lang_pref.append(image) + elif image_lang == 'en': + lang_en.append(image) + else: + if firstimage: + lang_pref.append(image) + else: + lang_null.append(image) + firstimage = False + return lang_pref + lang_null + lang_en diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/traktratings.py b/addons/metadata.tvshows.themoviedb.org.python/libs/traktratings.py new file mode 100644 index 0000000000..e442b56455 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/traktratings.py @@ -0,0 +1,58 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring + +"""Functions to interact with Trakt API""" + +from __future__ import absolute_import, unicode_literals + +from . import api_utils, settings +from .utils import logger +try: + from typing import Text, Optional, Union, List, Dict, Any # pylint: disable=unused-import + InfoType = Dict[Text, Any] # pylint: disable=invalid-name +except ImportError: + pass + + +HEADERS = ( + ('User-Agent', 'Kodi TV Show scraper by Team Kodi; contact pkscout@kodi.tv'), + ('Accept', 'application/json'), + ('trakt-api-key', settings.TRAKT_CLOWNCAR), + ('trakt-api-version', '2'), + ('Content-Type', 'application/json'), +) +api_utils.set_headers(dict(HEADERS)) + +SHOW_URL = 'https://api.trakt.tv/shows/{}' +EP_URL = SHOW_URL + '/seasons/{}/episodes/{}/ratings' + + +def get_details(imdb_id, season=None, episode=None): + result = {} + if season and episode: + url = EP_URL.format(imdb_id, season, episode) + params = None + else: + url = SHOW_URL.format(imdb_id) + params = {'extended': 'full'} + resp = api_utils.load_info(url, params=params, default={}, verboselog=settings.VERBOSELOG) + rating =resp.get('rating') + votes = resp.get('votes') + if votes and rating: + result['ratings'] = {'trakt': {'votes': votes, 'rating': rating}} + return result diff --git a/addons/metadata.tvshows.themoviedb.org.python/libs/utils.py b/addons/metadata.tvshows.themoviedb.org.python/libs/utils.py new file mode 100644 index 0000000000..48961b47c5 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/libs/utils.py @@ -0,0 +1,71 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# pylint: disable=missing-docstring + +"""Misc utils""" + +from __future__ import absolute_import, unicode_literals + +import xbmc +from xbmcaddon import Addon + +try: + from typing import Text, Optional, Any, Dict # pylint: disable=unused-import +except ImportError: + pass + +ADDON_ID = 'metadata.tvshows.themoviedb.org.python' +ADDON = Addon() + + +class logger: + log_message_prefix = '[{} ({})]: '.format(ADDON_ID, ADDON.getAddonInfo('version')) + + @staticmethod + def log(message, level=xbmc.LOGDEBUG): + # type: (Text, int) -> None + if isinstance(message, bytes): + message = message.decode('utf-8') + message = logger.log_message_prefix + message + xbmc.log(message, level) + + @staticmethod + def info(message): + # type: (Text) -> None + logger.log(message, xbmc.LOGINFO) + + @staticmethod + def error(message): + # type: (Text) -> None + logger.log(message, xbmc.LOGERROR) + + @staticmethod + def debug(message): + # type: (Text) -> None + logger.log(message, xbmc.LOGDEBUG) + + +def safe_get(dct, key, default=None): + # type: (Dict[Text, Any], Text, Any) -> Any + """ + Get a key from dict + + Returns the respective value or default if key is missing or the value is None. + """ + if key in dct and dct[key] is not None: + return dct[key] + return default diff --git a/addons/metadata.tvshows.themoviedb.org.python/main.py b/addons/metadata.tvshows.themoviedb.org.python/main.py new file mode 100644 index 0000000000..a81c519393 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/main.py @@ -0,0 +1,32 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2020, Team Kodi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# Code attribution: +# core based on metadata.tvmaze scrapper by Roman Miroshnychenko aka Roman V.M. +# IMDb ratings based on code in metadata.themoviedb.org.python by Team Kodi +# pylint: disable=missing-docstring + +from __future__ import absolute_import + +import sys + +from libs.actions import router +from libs.debugger import debug_exception + +if __name__ == '__main__': + with debug_exception(): + router(sys.argv[2][1:]) diff --git a/addons/metadata.tvshows.themoviedb.org.python/resources/icon.png b/addons/metadata.tvshows.themoviedb.org.python/resources/icon.png Binary files differnew file mode 100644 index 0000000000..1aa8275b50 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/resources/icon.png diff --git a/addons/metadata.tvshows.themoviedb.org.python/resources/language/resource.language.en_gb/strings.po b/addons/metadata.tvshows.themoviedb.org.python/resources/language/resource.language.en_gb/strings.po new file mode 100644 index 0000000000..e28ec38903 --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/resources/language/resource.language.en_gb/strings.po @@ -0,0 +1,126 @@ +# Kodi Media Center language file +# Addon Name: The Movie Database +# Addon id: metadata.themoviedb.org +# Addon Provider: XBMC Foundation +msgid "" +msgstr "" +"Project-Id-Version: XBMC Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kodi Translation Team\n" +"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Preferred language" +msgstr "" + +msgctxt "#30001" +msgid "Preferred certification country" +msgstr "" + +msgctxt "#30002" +msgid "Include certification prefix" +msgstr "" + +msgctxt "#30003" +msgid "Prefix" +msgstr "" + +msgctxt "#30004" +msgid "Keep original title" +msgstr "" + +# empty strings from 30007 to 30099 + +msgctxt "#30100" +msgid "Fanart.tv" +msgstr "" + +msgctxt "#30101" +msgid "Client key (optional)" +msgstr "" + +msgctxt "#30102" +msgid "Enable fanart" +msgstr "" + +msgctxt "#30103" +msgid "Enable poster" +msgstr "" + +msgctxt "#30104" +msgid "Enable banner" +msgstr "" + +msgctxt "#30105" +msgid "Enable clearlogo" +msgstr "" + +msgctxt "#30106" +msgid "Enable clearart" +msgstr "" + +msgctxt "#30107" +msgid "Enable landscape" +msgstr "" + +msgctxt "#30108" +msgid "Enable character art" +msgstr "" + +msgctxt "#30109" +msgid "Include art from fanart.tv" +msgstr "" + +# empty strings from 30110 to 30149 + +msgctxt "#30150" +msgid "Enable season poster" +msgstr "" + +msgctxt "#30151" +msgid "Enable season banner" +msgstr "" + +msgctxt "#30152" +msgid "Enable season landscape" +msgstr "" + +# empty strings from 30153 to 30200 + +msgctxt "#30200" +msgid "Advanced" +msgstr "" + +msgctxt "#30201" +msgid "Verbose debug logging" +msgstr "" + +# emptry strings from 30202 to 30299 + +msgctxt "#30300" +msgid "Ratings" +msgstr "" + +msgctxt "#30301" +msgid "Default rating from" +msgstr "" + +msgctxt "#30302" +msgid "Also add IMDb ratings" +msgstr "" + +msgctxt "#30303" +msgid "Also add Trakt.tv ratings" +msgstr "" + +msgctxt "#30304" +msgid "Also add TMDb ratings" +msgstr "" + diff --git a/addons/metadata.tvshows.themoviedb.org.python/resources/settings.xml b/addons/metadata.tvshows.themoviedb.org.python/resources/settings.xml new file mode 100644 index 0000000000..b18667d97a --- /dev/null +++ b/addons/metadata.tvshows.themoviedb.org.python/resources/settings.xml @@ -0,0 +1,268 @@ +<?xml version="1.0" ?> +<settings version="1"> + <section id="metadata.tvshows.themoviedb.org.python"> + <category id="general" label="128" help=""> + <group id="1"> + <setting id="language" type="string" label="30000" help=""> + <level>0</level> + <default>en-US</default> + <constraints> + <options> + <option>ar-AE</option> + <option>ar-SA</option> + <option>be-BY</option> + <option>bg-BG</option> + <option>bn-BD</option> + <option>ca-ES</option> + <option>ch-GU</option> + <option>cs-CZ</option> + <option>da-DK</option> + <option>de-DE</option> + <option>el-GR</option> + <option>en-US</option> + <option>eo-EO</option> + <option>es-ES</option> + <option>es-MX</option> + <option>et-EE</option> + <option>eu-ES</option> + <option>fa-IR</option> + <option>fi-FI</option> + <option>fr-CA</option> + <option>fr-FR</option> + <option>gl-ES</option> + <option>he-IL</option> + <option>hi-IN</option> + <option>hr-HR</option> + <option>hu-HU</option> + <option>id-ID</option> + <option>it-IT</option> + <option>ja-JP</option> + <option>ka-GE</option> + <option>ko-KR</option> + <option>lt-LT</option> + <option>lv-LV</option> + <option>ml-IN</option> + <option>nb-NO</option> + <option>nl-NL</option> + <option>no-NO</option> + <option>pl-PL</option> + <option>pt-BR</option> + <option>pt-PT</option> + <option>ro-RO</option> + <option>ru-RU</option> + <option>sk-SK</option> + <option>sl-SI</option> + <option>sr-RS</option> + <option>sv-SE</option> + <option>ta-IN</option> + <option>th-TH</option> + <option>tr-TR</option> + <option>uk-UA</option> + <option>vi-VN</option> + <option>zh-CN</option> + <option>zh-HK</option> + <option>zh-TW</option> + </options> + </constraints> + <control type="list" format="string"> + <heading>30000</heading> + </control> + </setting> + <setting id="tmdbcertcountry" type="string" label="30001" help=""> + <level>0</level> + <default>us</default> + <constraints> + <options> + <option>au</option> + <option>bg</option> + <option>br</option> + <option>by</option> + <option>ca</option> + <option>cz</option> + <option>de</option> + <option>dk</option> + <option>ee</option> + <option>es</option> + <option>fi</option> + <option>fr</option> + <option>gb</option> + <option>ge</option> + <option>gr</option> + <option>hr</option> + <option>hu</option> + <option>id</option> + <option>il</option> + <option>in</option> + <option>it</option> + <option>ir</option> + <option>jp</option> + <option>kr</option> + <option>lt</option> + <option>lv</option> + <option>mx</option> + <option>nl</option> + <option>no</option> + <option>pl</option> + <option>pt</option> + <option>ru</option> + <option>si</option> + <option>sv</option> + <option>th</option> + <option>tr</option> + <option>ua</option> + <option>us</option> + <option>vn</option> + <option>zh</option> + </options> + </constraints> + <control type="list" format="string"> + <heading>30001</heading> + </control> + </setting> + <setting id="usecertprefix" type="boolean" label="30002" help=""> + <level>0</level> + <default>true</default> + <control type="toggle"/> + </setting> + <setting id="certprefix" type="string" label="30003" help=""> + <level>0</level> + <default>Rated </default> + <dependencies> + <dependency type="enable"> + <condition operator="is" setting="usecertprefix">true</condition> + </dependency> + </dependencies> + <control type="edit" format="string"> + <heading>30003</heading> + </control> + </setting> + <setting id="keeporiginaltitle" type="boolean" label="30004" help=""> + <level>0</level> + <default>false</default> + <control type="toggle"/> + </setting> + </group> + </category> + <category id="ratings" label="30300" help=""> + <group id="1"> + <setting id="ratings" type="string" label="30301" help=""> + <level>0</level> + <default>TMDb</default> + <constraints> + <options> + <option label="TMDb">TMDb</option> + <option label="IMDb">IMDb</option> + <option label="Trakt">Trakt</option> + </options> + </constraints> + <control type="spinner" format="string"/> + </setting> + <setting id="imdbanyway" type="boolean" label="30302" help=""> + <level>0</level> + <default>false</default> + <dependencies> + <dependency type="enable"> + <condition operator="!is" setting="ratings">IMDb</condition> + </dependency> + </dependencies> + <control type="toggle"/> + </setting> + <setting id="traktanyway" type="boolean" label="30303" help=""> + <level>0</level> + <default>false</default> + <dependencies> + <dependency type="enable"> + <condition operator="!is" setting="ratings">Trakt</condition> + </dependency> + </dependencies> + <control type="toggle"/> + </setting> + <setting id="tmdbanyway" type="boolean" label="30304" help=""> + <level>0</level> + <default>true</default> + <dependencies> + <dependency type="enable"> + <condition operator="!is" setting="ratings">TMDb</condition> + </dependency> + </dependencies> + <control type="toggle"/> + </setting> + </group> + </category> + <category id="fanart.tv" label="30100" help=""> + <group id="1"> + <setting id="enable_fanarttv" type="boolean" label="30109" help=""> + <level>0</level> + <default>true</default> + <control type="toggle"/> + </setting> + <setting id="fanarttv_clientkey" type="string" label="30101" help=""> + <level>0</level> + <default/> + <dependencies> + <dependency type="enable"> + <condition operator="is" setting="enable_fanarttv">true</condition> + </dependency> + </dependencies> + <constraints> + <allowempty>true</allowempty> + </constraints> + <control type="edit" format="string"> + <heading>30101</heading> + </control> + </setting> + </group> + </category> + <category id="advanced" label="30200" help=""> + <group id="1"> + <setting id="verboselog" type="boolean" label="30201" help=""> + <level>0</level> + <default>false</default> + <control type="toggle"/> + </setting> + <setting id="lastUpdated" type="string" help=""> + <level>0</level> + <default>0</default> + <dependencies> + <dependency type="visible"> + <condition on="property" name="InfoBool">false</condition> + </dependency> + </dependencies> + <control type="edit" format="string"> + <heading/> + </control> + </setting> + <setting id="originalUrl" type="string" help=""> + <level>0</level> + <default/> + <constraints> + <allowempty>true</allowempty> + </constraints> + <dependencies> + <dependency type="visible"> + <condition on="property" name="InfoBool">false</condition> + </dependency> + </dependencies> + <control type="edit" format="string"> + <heading/> + </control> + </setting> + <setting id="previewUrl" type="string" help=""> + <level>0</level> + <default/> + <constraints> + <allowempty>true</allowempty> + </constraints> + <dependencies> + <dependency type="visible"> + <condition on="property" name="InfoBool">false</condition> + </dependency> + </dependencies> + <control type="edit" format="string"> + <heading/> + </control> + </setting> + </group> + </category> + </section> +</settings> diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index c20342083a..7241d0cc9f 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -7856,10 +7856,7 @@ msgctxt "#14084" msgid "Queue songs on selection" msgstr "" -#: system/settings/settings.xml -msgctxt "#14085" -msgid "Whitelist" -msgstr "" +#empty string with id 14085 #: system/settings/settings.xml msgctxt "#14086" @@ -8077,7 +8074,22 @@ msgctxt "#14125" msgid "Input" msgstr "" -#empty strings from id 14126 to 14199 +#: system/settings/settings.xml +msgctxt "#14126" +msgid "Whitelist" +msgstr "" + +#: system/settings/settings.xml +msgctxt "#14127" +msgid "Allow 3:2 pulldown refresh rates" +msgstr "" + +#: system/settings/settings.xml +msgctxt "#14128" +msgid "Allow double refresh rates" +msgstr "" + +#empty strings from id 14129 to 14199 #: system/settings/settings.xml msgctxt "#14200" @@ -11123,7 +11135,31 @@ msgctxt "#19329" msgid "Allow backend channel numbers with more than one PVR add-on" msgstr "" -#empty strings from id 19330 to 19498 +#. pvr settings "switch to channel on reminder auto-close" setting label +#: system/settings/settings.xml +msgctxt "#19330" +msgid "Switch to channel when auto-closing the reminder popup" +msgstr "" + +#. additional text for reminder announcement dialog, used if a recording can be scheduled +#: xbmc/pvr/timers/PVRGUIActions.cpp +msgctxt "#19331" +msgid "(Auto-close of this reminder will switch to channel...)" +msgstr "" + +#. text for event log entry for logging auto channel switch for auto-closed reminders +#: xbmc/pvr/timers/PVRGUIActions.cpp +msgctxt "#19332" +msgid "Switched to channel for auto-closed PVR reminder for '{0:s}' on channel '{1:s}' at '{2:s}'" +msgstr "" + +#. text for event log entry for logging auto scheduled recordings for auto-closed reminders +#: xbmc/pvr/timers/PVRGUIActions.cpp +msgctxt "#19333" +msgid "Switched to channel for auto-closed PVR reminder for channel '{0:s}' at '{1:s}'" +msgstr "" + +#empty strings from id 19334 to 19498 #. label for epg genre value #: xbmc/pvr/epg/Epg.cpp @@ -19720,11 +19756,7 @@ msgctxt "#36355" msgid "In a multi-screen configuration, the screens not displaying this application are blacked out." msgstr "" -#. Description of setting with label #14085 "Whitelist" -#: system/settings/settings.xml -msgctxt "#36356" -msgid "Whitelisted modes are allowed to be switched to when changing resolution and refresh rate" -msgstr "" +#empty string with id 36356 #. Description of setting with label #214 "Video calibration..." #: system/settings/settings.xml @@ -20173,7 +20205,12 @@ msgctxt "#36433" msgid "When enabled, VAAPI render method is preferred and the CPU has less load. If you experience hangs, disable this option." msgstr "" -#empty strings from id 36434 to 36435 +#: system/settings/settings.xml +msgctxt "#36434" +msgid "If enabled, switch to the channel with the programme to remind when auto-closing the reminder popup." +msgstr "" + +#empty strings from id 36435 to 36435 #. Description for setting #310: "Keyboard layouts" #: system/settings/settings.xml @@ -20201,7 +20238,25 @@ msgctxt "#36442" msgid "Set the number of volume control steps." msgstr "" -#empty strings from id 36443 to 36459 +#. Description of setting with label #14126 "Whitelist" +#: system/settings/settings.xml +msgctxt "#36443" +msgid "Whitelisted modes give the user the control to choose which display modes are allowed or not allowed to be used" +msgstr "" + +#. Description of setting with label #14127 "Whitelist" +#: system/settings/settings.xml +msgctxt "#36444" +msgid "Select this option to allow using 3:2 pulldown refresh rates (playing 23.976 FPS video on a 59.94 Hz monitor or playing 24 FPS video on a 60 Hz monitor). You may want to use this option if your monitor doesn't have a 23.976 Hz or 24 Hz mode." +msgstr "" + +#. Description of setting with label #14128 "Whitelist" +#: system/settings/settings.xml +msgctxt "#36445" +msgid "Select this option to allow using double refresh rates (playing 29.97 FPS video on a 59.94 Hz monitor or playing 30 FPS video on a 60 Hz monitor). You may want to use this option if your monitor doesn't have a 29.97 Hz or 30 Hz mode." +msgstr "" + +#empty strings from id 36446 to 36459 #. Description of settings with label #14112 "Enable event logging" #: system/settings/settings.xml @@ -22272,6 +22327,7 @@ msgstr "" #: system/settings/settings.xml msgctxt "#39142" msgid "Custom" +msgstr "" #: system/settings/settings.xml msgctxt "#39143" @@ -22326,3 +22382,8 @@ msgstr "" msgctxt "#39152" msgid "Integer scaling (IS) is a Nearest-Neighbor(NN) upscaling technique using Display Engine" msgstr "" + +#: xbmc/windows/GUIWindowSystemInfo.cpp +msgctxt "#39153" +msgid "Windowing system:" +msgstr "" diff --git a/addons/service.xbmc.versioncheck/LICENSES/Apache-2.0.txt b/addons/service.xbmc.versioncheck/LICENSES/Apache-2.0.txt new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/addons/service.xbmc.versioncheck/LICENSES/Apache-2.0.txt @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + 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 are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/addons/service.xbmc.versioncheck/LICENSE.txt b/addons/service.xbmc.versioncheck/LICENSES/GPL-2.0-or-later.txt index ab123ffca1..ab123ffca1 100644 --- a/addons/service.xbmc.versioncheck/LICENSE.txt +++ b/addons/service.xbmc.versioncheck/LICENSES/GPL-2.0-or-later.txt diff --git a/addons/service.xbmc.versioncheck/LICENSES/GPL-3.0-or-later.txt b/addons/service.xbmc.versioncheck/LICENSES/GPL-3.0-or-later.txt new file mode 100644 index 0000000000..f288702d2f --- /dev/null +++ b/addons/service.xbmc.versioncheck/LICENSES/GPL-3.0-or-later.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>. diff --git a/addons/service.xbmc.versioncheck/README.md b/addons/service.xbmc.versioncheck/README.md deleted file mode 100644 index fb153e0292..0000000000 --- a/addons/service.xbmc.versioncheck/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Kodi Version Check service addon -========================= - -This service checks the installed Kodi/XBMC version against the next available one and notifies you if there is a new version available. -When a new version comes out the versions.txt should be updated to reflect the latest version available. -When updating the version.txt always put latest release at the top since the list is read in chronological order. diff --git a/addons/service.xbmc.versioncheck/addon.xml b/addons/service.xbmc.versioncheck/addon.xml index 85f7081bdd..9d4114f153 100644 --- a/addons/service.xbmc.versioncheck/addon.xml +++ b/addons/service.xbmc.versioncheck/addon.xml @@ -1,119 +1,122 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<addon id="service.xbmc.versioncheck" - name="Version Check" - version="0.4.6" - provider-name="Team Kodi"> +<addon id="service.xbmc.versioncheck" name="Version Check" version="0.5.9+matrix.1" provider-name="Team Kodi"> <requires> - <import addon="xbmc.python" version="2.1.0"/> + <import addon="xbmc.python" version="3.0.0"/> </requires> - <extension point="xbmc.service" library="service.py" start="login"/> + <extension point="xbmc.service" library="resources/lib/runner.py"/> <extension point="xbmc.addon.metadata"> - <summary lang="be">Kodi Version Check checks if you are running latest released version.</summary> - <summary lang="bg">Проверява дали ползвате най-новата версия на Kodi.</summary> - <summary lang="ca">Kodi Version Check comprova si està utilitzant la última versió publicada.</summary> - <summary lang="cs">Kontrola verze Kodi, zkontroluje, zda používáte nejnovější vydanou verzi.</summary> - <summary lang="da">Kodi undersøger om du benytter den nyeste version.</summary> - <summary lang="de">Kodi Versionsprüfung prüft, ob die neuste Version von Kodi installiert ist.</summary> - <summary lang="el">Ο Έλεγχος Έκδοσης Kodi εξετάζει αν έχετε την πιο πρόσφατη έκδοση του προγράμματος.</summary> - <summary lang="en">Kodi Version Check checks if you are running latest released version.</summary> + <news> +- add Kodi 18.9 release +- fixup Kodi 19 pre alpha2 translatePath + </news> + <assets> + <icon>icon.png</icon> + </assets> + <summary lang="be_BY">Kodi Version Check checks if you are running latest released version.</summary> + <summary lang="bg_BG">Проверява дали ползвате най-новата версия на Kodi.</summary> + <summary lang="ca_ES">Kodi Version Check comprova si està utilitzant la última versió publicada.</summary> + <summary lang="cs_CZ">Kontrola verze Kodi, zkontroluje, zda používáte nejnovější vydanou verzi.</summary> + <summary lang="da_DK">Kodi undersøger om du benytter den nyeste version.</summary> + <summary lang="de_DE">Kodi Versionsprüfung prüft, ob die neuste Version von Kodi installiert ist.</summary> + <summary lang="el_GR">Ο Έλεγχος Έκδοσης Kodi εξετάζει αν έχετε την πιο πρόσφατη έκδοση του προγράμματος.</summary> + <summary lang="en_GB">Kodi Version Check checks if you are running latest released version.</summary> <summary lang="en_NZ">Kodi Version Check checks if you are running latest released version.</summary> <summary lang="en_US">Kodi Version Check checks if you are running latest released version.</summary> - <summary lang="es">Kodi Version Check comprueba si está ejecutando la última versión de Kodi.</summary> - <summary lang="es_MX">Comprobador de Version de Kodi comprueba si se esta ejecutando ultima version publicada.</summary> - <summary lang="fi">Kodi Version Check tarkistaa onko käyttämäsi uusin versio.</summary> - <summary lang="fr">Le contrôle de version de Kodi vérifie si la dernière version sortie est utilisée.</summary> + <summary lang="es_ES">Kodi Version Check comprueba si está ejecutando la última versión de Kodi.</summary> + <summary lang="es_MX">Comprobador de Version de Kodi comprueba si se esta ejecutando ultima version publicada.</summary> + <summary lang="fi_FI">Kodi Version Check tarkistaa onko käyttämäsi uusin versio.</summary> + <summary lang="fr_FR">Le contrôle de version de Kodi vérifie si la dernière version sortie est utilisée.</summary> <summary lang="fr_CA">Le contrôleur de version Kodi vérifie si vous utilisez la dernière version parue.</summary> - <summary lang="gl">Kodi Version Check verifica se está a executar a última versión.</summary> - <summary lang="he">בודק גרסת Kodi מוודא אם אתה מריץ את הגרסה הרשמית האחרונה.</summary> - <summary lang="hr">Kodi provjeritelj inačice provjerava imate li posljednju inačicu izdanja.</summary> - <summary lang="hu">Az Kodi verzió ellenőrző megvizsgálja, hogy a legújabb kiadást futtatja-e.</summary> - <summary lang="id">Kodi Version Check mengecek apakah Anda menggunakan versi rilis terbaru.</summary> - <summary lang="is">Kodi Version Check athugar hvort þú sért að keyra nýjustu viðurkennda útgáfu.</summary> - <summary lang="it">Kodi Version Check verifica se hai l'ultima versione rilasciata</summary> - <summary lang="ko">Kodi Version Checks는 최신 정식 릴리즈 버전을 사용중인지 검사해줍니다.</summary> - <summary lang="lt">Kodi Version Check patikrina ar naudojate naujausią versiją.</summary> - <summary lang="nl">Kodi versie-check controleert of je de laatst beschikbare versie hebt.</summary> - <summary lang="no">Kodi Versjonsettersyn sjekker om du kjører den sist utgitte versjonen.</summary> - <summary lang="pl">Dodatek Version Check sprawdza czy używasz najnowszej wersji Kodi.</summary> - <summary lang="pt">O Kodi Version Check verifica se a sua versão de lançamento do Kodi está actualizada.</summary> + <summary lang="gl_ES">Kodi Version Check verifica se está a executar a última versión.</summary> + <summary lang="he_IL">בודק גרסת Kodi מוודא אם אתה מריץ את הגרסה הרשמית האחרונה.</summary> + <summary lang="hr_HR">Kodi provjeritelj inačice provjerava imate li posljednju inačicu izdanja.</summary> + <summary lang="hu_HU">Az Kodi verzió ellenőrző megvizsgálja, hogy a legújabb kiadást futtatja-e.</summary> + <summary lang="id_ID">Kodi Version Check mengecek apakah Anda menggunakan versi rilis terbaru.</summary> + <summary lang="is_IS">Kodi Version Check athugar hvort þú sért að keyra nýjustu viðurkennda útgáfu.</summary> + <summary lang="it_IT">Kodi Version Check verifica se hai l'ultima versione rilasciata</summary> + <summary lang="ko_KR">Kodi Version Checks는 최신 정식 릴리즈 버전을 사용중인지 검사해줍니다.</summary> + <summary lang="lt_LT">Kodi Version Check patikrina ar naudojate naujausią versiją.</summary> + <summary lang="nl_NL">Kodi versie-check controleert of je de laatst beschikbare versie hebt.</summary> + <summary lang="nb_NO">Kodi Versjonsettersyn sjekker om du kjører den sist utgitte versjonen.</summary> + <summary lang="pl_PL">Dodatek Version Check sprawdza czy używasz najnowszej wersji Kodi.</summary> + <summary lang="pt_PT">O Kodi Version Check verifica se a sua versão de lançamento do Kodi está actualizada.</summary> <summary lang="pt_BR">Kodi Version Check verifica se você está executando a versão mais recente.</summary> - <summary lang="ro">Verificare versiune Kodi verifică dacă folosiți ultima versiune lansată.</summary> - <summary lang="ru">Kodi Version Check проверяет если вы используете последнюю версию</summary> - <summary lang="sk">Kodi Kontrola verzií overuje, či používate najnovšiu vydanú verziu.</summary> - <summary lang="sl">Preverjanje različice Kodi preveri, če imate nameščeno nazadnje izdano različico.</summary> - <summary lang="sv">Kodi Version Check kontrollerar om du använder den senaste versionen.</summary> - <summary lang="tr">Kodi Sürüm Kontrol yayınlanmış son sürümü kullanıp kullanmadığınızı kontrol eder.</summary> - <summary lang="zh">Kodi 版本检查检查你使用的是否为最新发布的版本。</summary> - <description lang="be">Kodi Version Check only supports a number of platforms/distros as releases may differ between them. For more information visit the kodi.tv website.</description> - <description lang="bg">Kodi Version Check поддържа няколко платформи/дистрибуции. За повече информация посетете страницата www.kodi.tv</description> - <description lang="ca">Kodi Version Check només és compatible amb una sèrie de plataformes / distribucions ja que les ultimes versions poden ser diferents entre elles. Per obtenir més informació, visiteu el lloc web kodi.tv.</description> - <description lang="cs">Kontrola verze Kodi podporuje pouze několik platforem/distribucí a verze mezi nimi se můžou lišit. Pro více informací navštivte webové stránky kodi.tv.</description> - <description lang="da">Kodi kan kun undersøge for opdateringer for visse platforme/udgaver, da der kan være forskel. For mere information, besøg kodi.tv.</description> - <description lang="de">Kodi Versionsprüfung unterstützt nur ein paar Plattformen/Distributionen, da sich die jeweiligen Veröffentlichungen unterscheiden können. Für weitere Informationen besuchen Sie die kodi.tv-Webseite.</description> - <description lang="el">Ο Έλεγχος Έκδοσης Kodi υποστηρίζει μόνο ορισμένα λειτουργικά συστήματα/διανομές, καθώς οι εκδόσεις διαφέρουν για το καθένα. Για περισσότερες πληροφορίες επισκεφθείτε το kodi.tv</description> - <description lang="en">Kodi Version Check only supports a number of platforms/distros as releases may differ between them. For more information visit the kodi.tv website.</description> + <summary lang="ro_RO">Verificare versiune Kodi verifică dacă folosiți ultima versiune lansată.</summary> + <summary lang="ru_RU">Kodi Version Check проверяет если вы используете последнюю версию</summary> + <summary lang="sk_SK">Kodi Kontrola verzií overuje, či používate najnovšiu vydanú verziu.</summary> + <summary lang="sl_SI">Preverjanje različice Kodi preveri, če imate nameščeno nazadnje izdano različico.</summary> + <summary lang="sv_SE">Kodi Version Check kontrollerar om du använder den senaste versionen.</summary> + <summary lang="tr_TR">Kodi Sürüm Kontrol yayınlanmış son sürümü kullanıp kullanmadığınızı kontrol eder.</summary> + <summary lang="zh_CN">Kodi 版本检查检查你使用的是否为最新发布的版本。</summary> + <description lang="be_BY">Kodi Version Check only supports a number of platforms/distros as releases may differ between them. For more information visit the kodi.tv website.</description> + <description lang="bg_BG">Kodi Version Check поддържа няколко платформи/дистрибуции. За повече информация посетете страницата www.kodi.tv</description> + <description lang="ca_ES">Kodi Version Check només és compatible amb una sèrie de plataformes / distribucions ja que les ultimes versions poden ser diferents entre elles. Per obtenir més informació, visiteu el lloc web kodi.tv.</description> + <description lang="cs_CZ">Kontrola verze Kodi podporuje pouze několik platforem/distribucí a verze mezi nimi se můžou lišit. Pro více informací navštivte webové stránky kodi.tv.</description> + <description lang="da_DK">Kodi kan kun undersøge for opdateringer for visse platforme/udgaver, da der kan være forskel. For mere information, besøg kodi.tv.</description> + <description lang="de_DE">Kodi Versionsprüfung unterstützt nur ein paar Plattformen/Distributionen, da sich die jeweiligen Veröffentlichungen unterscheiden können. Für weitere Informationen besuchen Sie die kodi.tv-Webseite.</description> + <description lang="el_GR">Ο Έλεγχος Έκδοσης Kodi υποστηρίζει μόνο ορισμένα λειτουργικά συστήματα/διανομές, καθώς οι εκδόσεις διαφέρουν για το καθένα. Για περισσότερες πληροφορίες επισκεφθείτε το kodi.tv</description> + <description lang="en_GB">Kodi Version Check only supports a number of platforms/distros as releases may differ between them. For more information visit the kodi.tv website.</description> <description lang="en_NZ">Kodi Version Check only supports a number of platforms/distros as releases may differ between them. For more information visit the kodi.tv website.</description> <description lang="en_US">Kodi Version Check only supports a number of platforms/distros as releases may differ between them. For more information visit the kodi.tv website.</description> - <description lang="es">Kodi Version Check solo soporta un número limitado de plataformas/distribuciones, ya que los lanzamientos pueden diferir entre ellos. Para más información, visite la web de kodi.tv.</description> - <description lang="fi">Kodi Version Check tukee vain joitain alustoja/distroja koska julkaisut saattavat poiketa toisistaan. Saadaksesi lisätietoa, vieraile kodi.tv:ssä.</description> - <description lang="fr">Le contrôle de version de Kodi ne prend en charge qu'un certain nombre de plate-formes/distributions car les versions peuvent varier entre elles. Pour plus d'informations, consulter le site Web kodi.tv.</description> + <description lang="es_ES">Kodi Version Check solo soporta un número limitado de plataformas/distribuciones, ya que los lanzamientos pueden diferir entre ellos. Para más información, visite la web de kodi.tv.</description> + <description lang="fi_FI">Kodi Version Check tukee vain joitain alustoja/distroja koska julkaisut saattavat poiketa toisistaan. Saadaksesi lisätietoa, vieraile kodi.tv:ssä.</description> + <description lang="fr_FR">Le contrôle de version de Kodi ne prend en charge qu'un certain nombre de plate-formes/distributions car les versions peuvent varier entre elles. Pour plus d'informations, consulter le site Web kodi.tv.</description> <description lang="fr_CA">Le contrôleur de version Kodi ne prend en charge qu'un certain nombre de plate-formes/distributions car les versions peuvent varier entre elles. Pour plus d'informations, visitez le site Web kodi.tv.</description> - <description lang="gl">Kodi Version Check só soporta un número limitado de plataformas/distribucións, xa que os lanzamentos poden diferir entre eles. Para máis información visitar o sitio web de kodi.tv.</description> - <description lang="he">בודק גרסת Kodi תומך רק במספר פלטפורמות/הפצות מאחר שסימון הגרסאות שונה בין אחת לשניה. למידע נוסף בקר באתר kodi.tv.</description> - <description lang="hr">Kodi provjeritelj inačice samo podržava broj platformi/distribucija koliko to dopuštaju pojedina izdanja. Za više informacija posjetite kodi.tv web stranicu.</description> - <description lang="hu">Az Kodi verzió-ellenőrző csak néhány platformot / disztribúciót támogat, mert a kiadások között különbségek lehetnek. További információkért keresse fel az kodi.tv oldalt.</description> - <description lang="id">Kodi Version Check hanya mendukung beberapa platform/distro karena rilisnya mungkin berbeda-beda. Untuk informasi lebih lanjut kunjungi situs kodi.tv.</description> - <description lang="it">Kodi Version Check supporta un numero di piattaforme e distribuzioni diverse tra loro. Per più informazioni visita il sito kodi.tv</description> - <description lang="ko">Kodi Versio Check는 일부 플랫폼/배포본만을 지원합니다. 자세한 정보는 kodi.tv 웹사이트에서 확인하세요</description> - <description lang="lt">Kodi Version Check palaiko tik kelias platformas/distribucijas, nes leidimai tarp jų gali skirtis. Norėdami gauti daugiau informacijos, apsilankykite Kodi.tv puslapyje.</description> - <description lang="nl">Kodi versie check ondersteunt alleen een aantal platforms/distro`s omdat uitgaven verschillen tussen hen. Voor meer informatie bezoek de kodi.tv website.</description> - <description lang="no">Kodi Versjonsettersyn støtter kun noen plattformer/distribusjoner fordi utgivelser kan være forskjellige mellom dem. Besøk kodi.tv for mer informasjon.</description> - <description lang="pl">Dodatek Version Check wspiera tylko część platform i dystrybucji. Więcej informacji na stronie kodi.tv</description> - <description lang="pt">O Kodi Version Check suporta apenas algumas plataformas/distribuições, porque os lançamentos podem não ser sempre idênticos. Para mais informação, visite o site kodi.tv.</description> + <description lang="gl_ES">Kodi Version Check só soporta un número limitado de plataformas/distribucións, xa que os lanzamentos poden diferir entre eles. Para máis información visitar o sitio web de kodi.tv.</description> + <description lang="he_IL">בודק גרסת Kodi תומך רק במספר פלטפורמות/הפצות מאחר שסימון הגרסאות שונה בין אחת לשניה. למידע נוסף בקר באתר kodi.tv.</description> + <description lang="hr_HR">Kodi provjeritelj inačice samo podržava broj platformi/distribucija koliko to dopuštaju pojedina izdanja. Za više informacija posjetite kodi.tv web stranicu.</description> + <description lang="hu_HU">Az Kodi verzió-ellenőrző csak néhány platformot / disztribúciót támogat, mert a kiadások között különbségek lehetnek. További információkért keresse fel az kodi.tv oldalt.</description> + <description lang="id_ID">Kodi Version Check hanya mendukung beberapa platform/distro karena rilisnya mungkin berbeda-beda. Untuk informasi lebih lanjut kunjungi situs kodi.tv.</description> + <description lang="it_IT">Kodi Version Check supporta un numero di piattaforme e distribuzioni diverse tra loro. Per più informazioni visita il sito kodi.tv</description> + <description lang="ko_KR">Kodi Versio Check는 일부 플랫폼/배포본만을 지원합니다. 자세한 정보는 kodi.tv 웹사이트에서 확인하세요</description> + <description lang="lt_LT">Kodi Version Check palaiko tik kelias platformas/distribucijas, nes leidimai tarp jų gali skirtis. Norėdami gauti daugiau informacijos, apsilankykite Kodi.tv puslapyje.</description> + <description lang="nl_NL">Kodi versie check ondersteunt alleen een aantal platforms/distro`s omdat uitgaven verschillen tussen hen. Voor meer informatie bezoek de kodi.tv website.</description> + <description lang="nb_NO">Kodi Versjonsettersyn støtter kun noen plattformer/distribusjoner fordi utgivelser kan være forskjellige mellom dem. Besøk kodi.tv for mer informasjon.</description> + <description lang="pl_PL">Dodatek Version Check wspiera tylko część platform i dystrybucji. Więcej informacji na stronie kodi.tv</description> + <description lang="pt_PT">O Kodi Version Check suporta apenas algumas plataformas/distribuições, porque os lançamentos podem não ser sempre idênticos. Para mais informação, visite o site kodi.tv.</description> <description lang="pt_BR">Verificador de versões do Kodi somente suporta algumas plataformas/distros em que os lançamentos podem diferenciar entre si. Para maiores informações visite o website kodi.tv.</description> - <description lang="ru">Проверка новых версий Kodi поддерживается только на ряде платформ/дистрибутивов и они могут различаться между собой. Для получения доп. информации посетите сайт kodi.tv</description> - <description lang="sl">Preverjanje različice Kodi podpira le nekatere platforme/distribucije, saj se izdaje med njimi lahko zelo razlikujejo. Za več informacij obiščite spletišče kodi.tv</description> - <description lang="sv">Kodi Version Check stöder endeast ett antal plattformar/distributioner eftersom utgivningar kan skilja mellan dessa. För mer information besök kodi.tv webplatsen.</description> - <description lang="tr">Kodi Sürüm Kontrol sürümler arasında değişiklik olduğu için sadece birkaç platform/dağıtım destekler. Daha fazla bilgi için kodi.tv web sitesini ziyaret edin.</description> - <description lang="zh">Kodi 版本检查只支持部分平台/发行版,它们之间的版本可能会有所不同。欲了解更多信息,请访问 kodi.tv 网站。</description> - <disclaimer lang="be">Feel free to use this script. For information visit kodi.tv</disclaimer> - <disclaimer lang="bg">Ползвайте скрипта свободно. За повече информация посетете www.kodi.tv</disclaimer> - <disclaimer lang="ca">Sigues lliure d'utilitzar aquest script. Per més informació visita kodi.tv</disclaimer> - <disclaimer lang="cs">Neváhejte použít tento skript. Pro více informací navštivte kodi.tv</disclaimer> - <disclaimer lang="da">Du er velkommen til at bruge dette script. For information, besøg kodi.tv</disclaimer> - <disclaimer lang="de">Zögern Sie nicht, dieses Skript zu verwenden. Für Informationen besuchen Sie kodi.tv</disclaimer> - <disclaimer lang="el">Χρησιμοποιήστε αυτό το script ελεύθερα. Για πληροφορίες επισκεφθείτε το kodi.tv</disclaimer> - <disclaimer lang="en">Feel free to use this script. For information visit kodi.tv</disclaimer> + <description lang="ru_RU">Проверка новых версий Kodi поддерживается только на ряде платформ/дистрибутивов и они могут различаться между собой. Для получения доп. информации посетите сайт kodi.tv</description> + <description lang="sl_SI">Preverjanje različice Kodi podpira le nekatere platforme/distribucije, saj se izdaje med njimi lahko zelo razlikujejo. Za več informacij obiščite spletišče kodi.tv</description> + <description lang="sv_SE">Kodi Version Check stöder endeast ett antal plattformar/distributioner eftersom utgivningar kan skilja mellan dessa. För mer information besök kodi.tv webplatsen.</description> + <description lang="tr_TR">Kodi Sürüm Kontrol sürümler arasında değişiklik olduğu için sadece birkaç platform/dağıtım destekler. Daha fazla bilgi için kodi.tv web sitesini ziyaret edin.</description> + <description lang="zh_CN">Kodi 版本检查只支持部分平台/发行版,它们之间的版本可能会有所不同。欲了解更多信息,请访问 kodi.tv 网站。</description> + <disclaimer lang="be_BY">Feel free to use this script. For information visit kodi.tv</disclaimer> + <disclaimer lang="bg_BG">Ползвайте скрипта свободно. За повече информация посетете www.kodi.tv</disclaimer> + <disclaimer lang="ca_ES">Sigues lliure d'utilitzar aquest script. Per més informació visita kodi.tv</disclaimer> + <disclaimer lang="cs_CZ">Neváhejte použít tento skript. Pro více informací navštivte kodi.tv</disclaimer> + <disclaimer lang="da_DK">Du er velkommen til at bruge dette script. For information, besøg kodi.tv</disclaimer> + <disclaimer lang="de_DE">Zögern Sie nicht, dieses Skript zu verwenden. Für Informationen besuchen Sie kodi.tv</disclaimer> + <disclaimer lang="el_GR">Χρησιμοποιήστε αυτό το script ελεύθερα. Για πληροφορίες επισκεφθείτε το kodi.tv</disclaimer> + <disclaimer lang="en_GB">Feel free to use this script. For information visit kodi.tv</disclaimer> <disclaimer lang="en_NZ">Feel free to use this script. For information visit kodi.tv</disclaimer> <disclaimer lang="en_US">Feel free to use this script. For information visit kodi.tv</disclaimer> - <disclaimer lang="es">Puede usar libremente este programa. Para más información, visite kodi.tv</disclaimer> + <disclaimer lang="es_ES">Puede usar libremente este programa. Para más información, visite kodi.tv</disclaimer> <disclaimer lang="es_MX">Sientase libre de utilizar este script. Para mas información visita kodi.tv</disclaimer> - <disclaimer lang="fr">Utiliser ce script si désiré. Pour plus d'informations, consulter le site kodi.tv</disclaimer> + <disclaimer lang="fr_FR">Utiliser ce script si désiré. Pour plus d'informations, consulter le site kodi.tv</disclaimer> <disclaimer lang="fr_CA">N'hésitez pas à utiliser ce script. Pour plus d'informations visitez kodi.tv</disclaimer> - <disclaimer lang="gl">Síntase libre de usar este script, para máis información visitar kodi.tv.</disclaimer> - <disclaimer lang="he">תרגיש חופשי להשתמש בסקריפט זה. למידע נוסף בקר ב-kodi.tv</disclaimer> - <disclaimer lang="hr">Slobodno koristite ovu skriptu. Za više informacija posjetite kodi.tv</disclaimer> - <disclaimer lang="hu">Használja bátran ezt a szkriptet! Információkért keresse fel az kodi.tv oldalt!</disclaimer> - <disclaimer lang="id">Jangan sungkan menggunakan script ini. Untuk informasi hubungi kodi.tv</disclaimer> - <disclaimer lang="it">Usa liberamente lo script. Per informazioni visita kodi.tv</disclaimer> - <disclaimer lang="ko">이 스크립트를 자유롭게 사용하세요. 관련 정보는 kodi.tv를 방문하세요.</disclaimer> - <disclaimer lang="lt">Galite laisvai naudoti šį scenarijų. Apsilankykite kodi.tv, norėdami gauti daugiau informacijos.</disclaimer> - <disclaimer lang="nl">Gebruik dit script vrijblijvend. Voor meer informatie bezoek kodi.tv</disclaimer> - <disclaimer lang="no">Du har fri tillatelse til å benytte dette skriptet. Besøk kodi.tv for informasjon</disclaimer> - <disclaimer lang="pl">Zapraszamy do używania tego dodatku. Więcej informacji na stronie kodi.tv</disclaimer> - <disclaimer lang="pt">Esteja à vontade para usar este script. Para mais informação, visite kodi.tv.</disclaimer> + <disclaimer lang="gl_ES">Síntase libre de usar este script, para máis información visitar kodi.tv.</disclaimer> + <disclaimer lang="he_IL">תרגיש חופשי להשתמש בסקריפט זה. למידע נוסף בקר ב-kodi.tv</disclaimer> + <disclaimer lang="hr_HR">Slobodno koristite ovu skriptu. Za više informacija posjetite kodi.tv</disclaimer> + <disclaimer lang="hu_HU">Használja bátran ezt a szkriptet! Információkért keresse fel az kodi.tv oldalt!</disclaimer> + <disclaimer lang="id_ID">Jangan sungkan menggunakan script ini. Untuk informasi hubungi kodi.tv</disclaimer> + <disclaimer lang="it_IT">Usa liberamente lo script. Per informazioni visita kodi.tv</disclaimer> + <disclaimer lang="ko_KR">이 스크립트를 자유롭게 사용하세요. 관련 정보는 kodi.tv를 방문하세요.</disclaimer> + <disclaimer lang="lt_LT">Galite laisvai naudoti šį scenarijų. Apsilankykite kodi.tv, norėdami gauti daugiau informacijos.</disclaimer> + <disclaimer lang="nl_NL">Gebruik dit script vrijblijvend. Voor meer informatie bezoek kodi.tv</disclaimer> + <disclaimer lang="nb_NO">Du har fri tillatelse til å benytte dette skriptet. Besøk kodi.tv for informasjon</disclaimer> + <disclaimer lang="pl_PL">Zapraszamy do używania tego dodatku. Więcej informacji na stronie kodi.tv</disclaimer> + <disclaimer lang="pt_PT">Esteja à vontade para usar este script. Para mais informação, visite kodi.tv.</disclaimer> <disclaimer lang="pt_BR">Sinta-se livre para usar este script. Para maiores informações visite kodi.tv</disclaimer> - <disclaimer lang="ro">Simțiți-vă liberi să folosiți acest script. Pentru informații vizitați kodi.tv</disclaimer> - <disclaimer lang="ru">Используйте этот скрипт на свое усмотрение. Для информации посетите kodi.tv</disclaimer> - <disclaimer lang="sl">Izvolite uporabiti ta skript. Za dodatne informacije obiščite kodi.tv</disclaimer> - <disclaimer lang="sv">Använd gärna detta skript. För information, besök kodi.tv</disclaimer> - <disclaimer lang="tr">Bu betiği kullanmaktan çekinmeyin. Daha fazla bilgi için kodi.tv adresini ziyaret edin</disclaimer> - <disclaimer lang="zh">可放心使用此脚本,更多信息访问 kodi.tv</disclaimer> + <disclaimer lang="ro_RO">Simțiți-vă liberi să folosiți acest script. Pentru informații vizitați kodi.tv</disclaimer> + <disclaimer lang="ru_RU">Используйте этот скрипт на свое усмотрение. Для информации посетите kodi.tv</disclaimer> + <disclaimer lang="sl_SI">Izvolite uporabiti ta skript. Za dodatne informacije obiščite kodi.tv</disclaimer> + <disclaimer lang="sv_SE">Använd gärna detta skript. För information, besök kodi.tv</disclaimer> + <disclaimer lang="tr_TR">Bu betiği kullanmaktan çekinmeyin. Daha fazla bilgi için kodi.tv adresini ziyaret edin</disclaimer> + <disclaimer lang="zh_CN">可放心使用此脚本,更多信息访问 kodi.tv</disclaimer> <platform>all</platform> - <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license> - <forum>http://forum.xbmc.org/showthread.php?tid=160228</forum> - <website>http://xbmc.org</website> - <email></email> + <license>GPL-2.0-or-later, GPL-3.0-or-later, Apache-2.0</license> + <forum>https://forum.kodi.tv/showthread.php?tid=160228</forum> + <website>https://kodi.tv</website> <source>https://github.com/XBMC-Addons/service.xbmc.versioncheck</source> </extension> -</addon> +</addon>
\ No newline at end of file diff --git a/addons/service.xbmc.versioncheck/changelog.txt b/addons/service.xbmc.versioncheck/changelog.txt deleted file mode 100644 index eefbdcfd43..0000000000 --- a/addons/service.xbmc.versioncheck/changelog.txt +++ /dev/null @@ -1,150 +0,0 @@ -v0.3.26 to v0.4.5 -- Update version list - -v0.3.25 -- fix issue with the older python2.6 - -v0.3.5 to v0.3.24 -- Update version list - -v0.3.14 -- Updated language files from Transifex -- Cosmetics -- Update version list - -v0.3.12 to 0.3.4 -- Update version list - -v0.3.3 -- Updated language files from Transifex -- Update version list - -v0.3.2 -- Don't notify on newer unreleased builds - -v0.3.1 -- Don't notify on newer unreleased builds - -v0.3.0 -- Update with 14.0 Helix - -v0.2.7 -- Fix popup on Kodi 15.0 builds - -v0.2.6 -- Update with 14.0 Helix rc 3 - -v0.2.5 -- Update with 14.0 Helix rc 2 - -v0.2.4 -- Fix error or unicode - -v0.2.3 -- Updated language files from Transifex -- Update with 14.0 Helix rc 1 - -v0.2.2 -- New Kodi logo as icon -- Update with 14.0 Helix beta 4 -- Update with 14.0 Helix beta 5 - -v0.2.1 -- Updated language files from Transifex -- Don't exclude OpenELEC any more for version check -- Update with 14.0 Helix beta 3 - -v0.2.0 -- Only notify when the available version of Kodi changes, not when add-on is updated -- Update with 14.0 Helix alpha3 -- Update with 14.0 Helix alpha4 -- Update with 14.0 Helix beta 1 -- Update with 14.0 Helix beta 2 - -v0.1.24 -- Reworked notification logic -- Updated with recent builds - -v0.1.23 -- Update with 13.2 Gotham -- Update with 13.2 Gotham rc1 -- Update with 13.2 Gotham beta3 -- Update with 13.2 Gotham beta2 -- Update with 13.2 Gotham beta1 -- Update with 14.0 Helix alpha2 - -v0.1.22 -- Updated language files from Transifex -- Update with 13.1 Gotham rc1 -- Update with 13.1 Gotham beta2 -- Update with 13.1 Gotham beta1 -- Update with 13.0 Gotham - -v0.1.21 -- Update with 13.0 Gotham rc1 -- Update with 13.0 Gotham beta4 - -v0.1.20 -- Fix missing apt option for Linux -- Update with 13.0 Gotham beta3 -- Update with 13.0 Gotham beta2 -- Update with 13.0 Gotham beta1 - -v0.1.19 -- Added Gotham alpha user notice - -v0.1.17 -- Update with 13.0 Gotham alpha11 - -v0.1.16 -- Update with 12.3 Frodo stable - -v0.1.15 -- Add option for linux to disable check through "apt" - -v0.1.14 -- Update with 13.0 Gotham alpha10 - -v0.1.13 -- Update with 13.0 Gotham alpha9 - -v0.1.12 -- Fix encoding text encoding error for some languages -- Update language files - -v0.1.11 -- Updated language files from Transifex -- Fix problems with python2.7.5 -- Update with 13.0 Gotham alpha8 - -v0.1.11 -- Update with 13.0 Gotham alpha7 - -v0.1.9 -- Update with 13.0 Gotham alpha6 -- Updated language files from Transifex - -v0.1.7 -- Update with 13.0 Gotham alpha5 - -v0.1.7 -- Update with 13.0 Gotham alpha4 - -v0.1.6 -- Update with 12.2 Frodo stable -- Added Linux full system upgrade - -v0.1.5 -- Update with 13.0 Gotham alpha3 - -v0.1.4 -- We can now upgrade xbmc on Linux. This works either via polkit or shell wrapper as fallback - -v0.1.3 -- Update with 13.0 Gotham alpha2 - -v0.1.2 -- Add notification for Ubuntu users checking through apt command - -v0.1.1 -- Initial version diff --git a/addons/service.xbmc.versioncheck/lib/__init__.py b/addons/service.xbmc.versioncheck/lib/__init__.py deleted file mode 100644 index 55e5f844b4..0000000000 --- a/addons/service.xbmc.versioncheck/lib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .common import * diff --git a/addons/service.xbmc.versioncheck/lib/aptdaemonhandler.py b/addons/service.xbmc.versioncheck/lib/aptdaemonhandler.py deleted file mode 100644 index 1e09b56100..0000000000 --- a/addons/service.xbmc.versioncheck/lib/aptdaemonhandler.py +++ /dev/null @@ -1,109 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Team-XBMC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -import xbmc -from .common import * - -try: - #import apt - import apt - from aptdaemon import client - from aptdaemon import errors -except: - log('python apt import error') - -class AptdaemonHandler: - - def __init__(self): - self.aptclient = client.AptClient() - - def _check_versions(self, package): - if not self._update_cache(): - return False, False - try: - trans = self.aptclient.upgrade_packages([package]) - #trans = self.aptclient.upgrade_packages("bla") - trans.simulate(reply_handler=self._apttransstarted, error_handler=self._apterrorhandler) - pkg = trans.packages[4][0] - if pkg == package: - cache=apt.Cache() - cache.open(None) - cache.upgrade() - if cache[pkg].installed: - return cache[pkg].installed.version, cache[pkg].candidate.version - - return False, False - - except Exception as error: - log("Exception while checking versions: %s" %error) - return False, False - - def _update_cache(self): - try: - if self.aptclient.update_cache(wait=True) == "exit-success": - return True - else: - return False - except errors.NotAuthorizedError: - log("You are not allowed to update the cache") - return False - - def check_upgrade_available(self, package): - '''returns True if newer package is available in the repositories''' - installed, candidate = self._check_versions(package) - if installed and candidate: - if installed != candidate: - log("Version installed %s" %installed) - log("Version available %s" %candidate) - return True - else: - log("Already on newest version") - elif not installed: - log("No installed package found") - return False - else: - return False - - def upgrade_package(self, package): - try: - log("Installing new version") - if self.aptclient.upgrade_packages([package], wait=True) == "exit-success": - log("Upgrade successful") - return True - except Exception as error: - log("Exception during upgrade: %s" %error) - return False - - def upgrade_system(self): - try: - log("Upgrading system") - if self.aptclient.upgrade_system(wait=True) == "exit-success": - return True - except Exception as error: - log("Exception during system upgrade: %s" %error) - return False - - def _getpassword(self): - if len(self._pwd) == 0: - self._pwd = get_password_from_user() - return self._pwd - - def _apttransstarted(self): - pass - - def _apterrorhandler(self, error): - log("Apt Error %s" %error)
\ No newline at end of file diff --git a/addons/service.xbmc.versioncheck/lib/common.py b/addons/service.xbmc.versioncheck/lib/common.py deleted file mode 100644 index 97f4a6442a..0000000000 --- a/addons/service.xbmc.versioncheck/lib/common.py +++ /dev/null @@ -1,205 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Team-XBMC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -import sys - -import os -import xbmc -import xbmcaddon -import xbmcgui -import xbmcvfs - -ADDON = xbmcaddon.Addon() -ADDONVERSION = ADDON.getAddonInfo('version') -ADDONNAME = ADDON.getAddonInfo('name') -if sys.version_info[0] >= 3: - ADDONPATH = ADDON.getAddonInfo('path') - ADDONPROFILE = xbmc.translatePath( ADDON.getAddonInfo('profile') ) -else: - ADDONPATH = ADDON.getAddonInfo('path').decode('utf-8') - ADDONPROFILE = xbmc.translatePath( ADDON.getAddonInfo('profile') ).decode('utf-8') -ICON = ADDON.getAddonInfo('icon') -KODI_VERSION_MAJOR = int(xbmc.getInfoLabel('System.BuildVersion')[0:2]) - -monitor = xbmc.Monitor() - -# Fixes unicode problems -def string_unicode(text, encoding='utf-8'): - try: - if sys.version_info[0] >= 3: - text = str( text ) - else: - text = unicode( text, encoding ) - except: - pass - return text - -def normalize_string(text): - try: - text = unicodedata.normalize('NFKD', string_unicode(text)).encode('ascii', 'ignore') - except: - pass - return text - -def localise(id): - string = normalize_string(ADDON.getLocalizedString(id)) - return string - -def log(txt): - if sys.version_info[0] >= 3: - message = '%s: %s' % ("Version Check", txt.encode('utf-8')) - else: - if isinstance (txt,str): - txt = txt.decode("utf-8") - message = (u'%s: %s' % ("Version Check", txt)).encode("utf-8") - xbmc.log(msg=message, level=xbmc.LOGDEBUG) - -def get_password_from_user(): - keyboard = xbmc.Keyboard("", ADDONNAME + "," +localise(32022), True) - keyboard.doModal() - if (keyboard.isConfirmed()): - pwd = keyboard.getText() - return pwd - -def message_upgrade_success(): - xbmc.executebuiltin("Notification(%s, %s, %d, %s)" %(ADDONNAME, - localise(32013), - 15000, - ICON)) - -def message_restart(): - if dialog_yesno(32014): - xbmc.executebuiltin("RestartApp") - -def dialog_yesno(line1 = 0, line2 = 0): - return xbmcgui.Dialog().yesno(ADDONNAME, - localise(line1), - localise(line2)) - -def upgrade_message(msg, oldversion, upgrade, msg_current, msg_available): - wait_for_end_of_video() - - if ADDON.getSetting("lastnotified_version") < ADDONVERSION: - xbmcgui.Dialog().ok(ADDONNAME, - localise(msg), - localise(32001), - localise(32002)) - #ADDON.setSetting("lastnotified_version", ADDONVERSION) - else: - log("Already notified one time for upgrading.") - -def upgrade_message2( version_installed, version_available, version_stable, oldversion, upgrade,): - # shorten releasecandidate to rc - if version_installed['tag'] == 'releasecandidate': - version_installed['tag'] = 'rc' - if version_available['tag'] == 'releasecandidate': - version_available['tag'] = 'rc' - # convert json-rpc result to strings for usage - msg_current = '%i.%i %s%s' %(version_installed['major'], - version_installed['minor'], - version_installed['tag'], - version_installed.get('tagversion','')) - msg_available = version_available['major'] + '.' + version_available['minor'] + ' ' + version_available['tag'] + version_available.get('tagversion','') - msg_stable = version_stable['major'] + '.' + version_stable['minor'] + ' ' + version_stable['tag'] + version_stable.get('tagversion','') - msg = localise(32034) %(msg_current, msg_available) - - wait_for_end_of_video() - - # hack: convert current version number to stable string - # so users don't get notified again. remove in future - if ADDON.getSetting("lastnotified_version") == '0.1.24': - ADDON.setSetting("lastnotified_stable", msg_stable) - - # Show different dialogs depending if there's a newer stable available. - # Also split them between xbmc and kodi notifications to reduce possible confusion. - # People will find out once they visit the website. - # For stable only notify once and when there's a newer stable available. - # Ignore any add-on updates as those only count for != stable - if oldversion == 'stable' and ADDON.getSetting("lastnotified_stable") != msg_stable: - if xbmcaddon.Addon('xbmc.addon').getAddonInfo('version') < "13.9.0": - xbmcgui.Dialog().ok(ADDONNAME, - msg, - localise(32030), - localise(32031)) - else: - xbmcgui.Dialog().ok(ADDONNAME, - msg, - localise(32032), - localise(32033)) - ADDON.setSetting("lastnotified_stable", msg_stable) - - elif oldversion != 'stable' and ADDON.getSetting("lastnotified_version") != msg_available: - if xbmcaddon.Addon('xbmc.addon').getAddonInfo('version') < "13.9.0": - # point them to xbmc.org - xbmcgui.Dialog().ok(ADDONNAME, - msg, - localise(32035), - localise(32031)) - else: - #use kodi.tv - xbmcgui.Dialog().ok(ADDONNAME, - msg, - localise(32035), - localise(32033)) - - # older skins don't support a text field in the OK dialog. - # let's use split lines for now. see code above. - ''' - msg = localise(32034) %(msg_current, msg_available) - if oldversion == 'stable': - msg = msg + ' ' + localise(32030) - else: - msg = msg + ' ' + localise(32035) - msg = msg + ' ' + localise(32031) - xbmcgui.Dialog().ok(ADDONNAME, msg) - #ADDON.setSetting("lastnotified_version", ADDONVERSION) - ''' - ADDON.setSetting("lastnotified_version", msg_available) - - else: - log("Already notified one time for upgrading.") - - -def abortRequested(): - if KODI_VERSION_MAJOR > 13: - return monitor.abortRequested() - else: - return xbmc.abortRequested - - -def waitForAbort(seconds): - if KODI_VERSION_MAJOR > 13: - return monitor.waitForAbort(seconds) - else: - for _ in range(0, seconds*1000/200): - if xbmc.abortRequested: - return True - xbmc.sleep(200) - - -def wait_for_end_of_video(): - # Don't show notify while watching a video - while xbmc.Player().isPlayingVideo() and not abortRequested(): - if waitForAbort(1): - # Abort was requested while waiting. We should exit - break - i = 0 - while i < 10 and not abortRequested(): - if waitForAbort(1): - # Abort was requested while waiting. We should exit - break - i += 1 diff --git a/addons/service.xbmc.versioncheck/lib/jsoninterface.py b/addons/service.xbmc.versioncheck/lib/jsoninterface.py deleted file mode 100644 index 6f0f7acb91..0000000000 --- a/addons/service.xbmc.versioncheck/lib/jsoninterface.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Team-XBMC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -import os -import sys -import xbmc -import xbmcaddon -import xbmcvfs -import lib.common -from lib.common import log - -ADDONPATH = lib.common.ADDONPATH - -import json as jsoninterface - -def get_installedversion(): - # retrieve current installed version - json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Application.GetProperties", "params": {"properties": ["version", "name"]}, "id": 1 }') - if sys.version_info[0] >= 3: - json_query = str(json_query) - else: - json_query = unicode(json_query, 'utf-8', errors='ignore') - json_query = jsoninterface.loads(json_query) - version_installed = [] - if 'result' in json_query and 'version' in json_query['result']: - version_installed = json_query['result']['version'] - return version_installed - -def get_versionfilelist(): - # retrieve versionlists from supplied version file - version_file = os.path.join(ADDONPATH, 'resources/versions.txt') - # Eden didn't have xbmcvfs.File() - if xbmcaddon.Addon('xbmc.addon').getAddonInfo('version') < "11.9.3": - file = open(version_file, 'r') - else: - file = xbmcvfs.File(version_file) - data = file.read() - file.close() - if sys.version_info[0] >= 3: - version_query = str(data) - else: - version_query = unicode(data, 'utf-8', errors='ignore') - version_query = jsoninterface.loads(version_query) - return version_query diff --git a/addons/service.xbmc.versioncheck/lib/shellhandlerapt.py b/addons/service.xbmc.versioncheck/lib/shellhandlerapt.py deleted file mode 100644 index 9fbb0b5e5b..0000000000 --- a/addons/service.xbmc.versioncheck/lib/shellhandlerapt.py +++ /dev/null @@ -1,125 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Team-XBMC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -import xbmc -from .common import * - -try: - from subprocess import check_output - from subprocess import call -except: - log('subprocess import error') - - -class ShellHandlerApt: - - _pwd = "" - - def __init__(self, usesudo=False): - self.sudo = usesudo - installed, candidate = self._check_versions("xbmc", False) - if not installed: - # there is no package installed via repo, so we exit here - log("No installed package found, exiting") - import sys - sys.exit(0) - - def _check_versions(self, package, update=True): - _cmd = "apt-cache policy " + package - - if update and not self._update_cache(): - return False, False - - try: - result = check_output([_cmd], shell=True).split("\n") - except Exception as error: - log("ShellHandlerApt: exception while executing shell command %s: %s" %(_cmd, error)) - return False, False - - if result[0].replace(":", "") == package: - installed = result[1].split()[1] - candidate = result[2].split()[1] - if installed == "(none)": - installed = False - if candidate == "(none)": - candidate = False - return installed, candidate - else: - log("ShellHandlerApt: error during version check") - return False, False - - def _update_cache(self): - _cmd = 'apt-get update' - try: - if self.sudo: - x = check_output('echo \'%s\' | sudo -S %s' %(self._getpassword(), _cmd), shell=True) - else: - x = check_output(_cmd.split()) - except Exception as error: - log("Exception while executing shell command %s: %s" %(_cmd, error)) - return False - - return True - - def check_upgrade_available(self, package): - '''returns True if newer package is available in the repositories''' - installed, candidate = self._check_versions(package) - if installed and candidate: - if installed != candidate: - log("Version installed %s" %installed) - log("Version available %s" %candidate) - return True - else: - log("Already on newest version") - elif not installed: - log("No installed package found") - return False - else: - return False - - def upgrade_package(self, package): - _cmd = "apt-get install -y " + package - try: - if self.sudo: - x = check_output('echo \'%s\' | sudo -S %s' %(self._getpassword(), _cmd), shell=True) - else: - x = check_output(_cmd.split()) - log("Upgrade successful") - except Exception as error: - log("Exception while executing shell command %s: %s" %(_cmd, error)) - return False - - return True - - def upgrade_system(self): - _cmd = "apt-get upgrade -y" - try: - log("Upgrading system") - if self.sudo: - x = check_output('echo \'%s\' | sudo -S %s' %(self._getpassword(), _cmd), shell=True) - else: - x = check_output(_cmd.split()) - except Exception as error: - log("Exception while executing shell command %s: %s" %(_cmd, error)) - return False - - return True - - def _getpassword(self): - if len(self._pwd) == 0: - self._pwd = get_password_from_user() - return self._pwd diff --git a/addons/service.xbmc.versioncheck/lib/versions.py b/addons/service.xbmc.versioncheck/lib/versions.py deleted file mode 100644 index 514136e5fe..0000000000 --- a/addons/service.xbmc.versioncheck/lib/versions.py +++ /dev/null @@ -1,127 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Team-XBMC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -from lib.common import log - -def compare_version(version_installed, versionlist): - # Create separate version lists - versionlist_stable = versionlist['releases']['stable'] - versionlist_rc = versionlist['releases']['releasecandidate'] - versionlist_beta = versionlist['releases']['beta'] - versionlist_alpha = versionlist['releases']['alpha'] - versionlist_prealpha = versionlist['releases']['prealpha'] - log('Version installed %s' %version_installed) - ### Check to upgrade to newest available stable version - # check on smaller major version. Smaller version than available always notify - oldversion = False - version_available = '' - # check if installed major version is smaller than available major stable - # here we don't care if running non stable - if version_installed['major'] < int(versionlist_stable[0]['major']): - version_available = versionlist_stable[0] - oldversion = 'stable' - log('Version available %s' %versionlist_stable[0]) - log('You are running an older version') - - - # check if installed major version is equal than available major stable - # however also check on minor version and still don't care about non stable - elif version_installed['major'] == int(versionlist_stable[0]['major']): - if version_installed['minor'] < int(versionlist_stable[0]['minor']): - version_available = versionlist_stable[0] - oldversion = 'stable' - log('Version available %s' %versionlist_stable[0]) - log('You are running an older minor version') - # check for <= minor !stable - elif version_installed['tag'] != 'stable' and version_installed['minor'] <= int(versionlist_stable[0]['minor']): - version_available = versionlist_stable[0] - oldversion = True - log('Version available %s' %versionlist_stable[0]) - log('You are running an older non stable minor version') - else: - log('Version available %s' %versionlist_stable[0]) - log('There is no newer stable available') - - # Already skipped a possible newer stable build. Let's continue with non stable builds. - # Check also 'oldversion' hasn't been set to 'stable' or true by previous checks because if so, - # those part need to be skipped - - #check for RC builds - if not oldversion and version_installed['tag'] in ['releasecandidate']: - # check if you are using a RC build lower than current available RC - # then check if you are using a beta/alpha lower than current available RC - # 14.0rc3 is newer than: 14.0rc1, 14.0b9, 14.0a15 - if version_installed['major'] <= int(versionlist_rc[0]['major']): - if version_installed['minor'] <= int(versionlist_rc[0]['minor']): - if version_installed.get('tagversion','') < versionlist_rc[0]['tagversion']: - version_available = versionlist_rc[0] - oldversion = True - log('Version available %s' %versionlist_rc[0]) - log('You are running an older RC version') - # now check if installed !=rc - elif not oldversion and version_installed['tag'] in ['beta','alpha','prealpha']: - if version_installed['major'] <= int(versionlist_rc[0]['major']): - if version_installed['minor'] <= int(versionlist_beta[0]['minor']): - version_available = versionlist_rc[0] - oldversion = True - log('Version available %s' %versionlist_rc[0]) - log('You are running an older non RC version') - - #check for beta builds - if not oldversion and version_installed['tag'] == 'beta': - # check if you are using a RC build lower than current available RC - # then check if you are using a beta/alpha lower than current available RC - # 14.0b3 is newer than: 14.0b1, 14.0a15 - if version_installed['major'] <= int(versionlist_beta[0]['major']): - if version_installed['minor'] <= int(versionlist_beta[0]['minor']): - if version_installed.get('tagversion','') < versionlist_beta[0]['tagversion']: - version_available = versionlist_beta[0] - oldversion = True - log('Version available %s' %versionlist_beta[0]) - log('You are running an older beta version') - # now check if installed !=beta - elif not oldversion and version_installed['tag'] in ['alpha','prealpha']: - if version_installed['major'] <= int(versionlist_beta[0]['major']): - if version_installed['minor'] <= int(versionlist_beta[0]['minor']): - version_available = versionlist_beta[0] - oldversion = True - log('Version available %s' %versionlist_beta[0]) - log('You are running an older non beta version') - - #check for alpha builds and older - if not oldversion and version_installed['tag'] == 'alpha': - # check if you are using a RC build lower than current available RC - # then check if you are using a beta/alpha lower than current available RC - # 14.0a3 is newer than: 14.0a1 or pre-alpha - if version_installed['major'] <= int(versionlist_alpha[0]['major']): - if version_installed['minor'] <= int(versionlist_alpha[0]['minor']): - if version_installed.get('tagversion','') < versionlist_alpha[0]['tagversion']: - version_available = versionlist_alpha[0] - oldversion = True - log('Version available %s' %versionlist_alpha[0]) - log('You are running an older alpha version') - # now check if installed !=alpha - elif not oldversion and version_installed['tag'] in ['prealpha']: - if version_installed['major'] <= int(versionlist_alpha[0]['major']): - if version_installed['minor'] <= int(versionlist_alpha[0]['minor']): - version_available = versionlist_alpha[0] - oldversion = True - log('Version available %s' %versionlist_alpha[0]) - log('You are running an older non alpha version') - version_stable = versionlist_stable[0] - return oldversion, version_installed, version_available, version_stable
\ No newline at end of file diff --git a/addons/service.xbmc.versioncheck/lib/viewer.py b/addons/service.xbmc.versioncheck/lib/viewer.py deleted file mode 100644 index 4a43156a33..0000000000 --- a/addons/service.xbmc.versioncheck/lib/viewer.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -# -# Copyright (C) 2011-2013 Martijn Kaijser -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -#import modules -import os -import sys -import xbmc -import xbmcgui -import xbmcaddon - -### get addon info -ADDON = xbmcaddon.Addon('service.xbmc.versioncheck') -ADDONVERSION = ADDON.getAddonInfo('version') -ADDONNAME = ADDON.getAddonInfo('name') -if sys.version_info[0] >= 3: - ADDONPATH = ADDON.getAddonInfo('path') - ADDONPROFILE = xbmc.translatePath( ADDON.getAddonInfo('profile') ) -else: - ADDONPATH = ADDON.getAddonInfo('path').decode('utf-8') - ADDONPROFILE = xbmc.translatePath( ADDON.getAddonInfo('profile') ).decode('utf-8') -ICON = ADDON.getAddonInfo('icon') - -class Viewer: - # constants - WINDOW = 10147 - CONTROL_LABEL = 1 - CONTROL_TEXTBOX = 5 - - def __init__(self, *args, **kwargs): - # activate the text viewer window - xbmc.executebuiltin("ActivateWindow(%d)" % (self.WINDOW,)) - # get window - self.window = xbmcgui.Window(self.WINDOW) - # give window time to initialize - xbmc.sleep(100) - # set controls - self.setControls() - - def setControls(self): - #get header, text - heading, text = self.getText() - # set heading - self.window.getControl(self.CONTROL_LABEL).setLabel("%s : %s" % (ADDONNAME, heading, )) - # set text - self.window.getControl(self.CONTROL_TEXTBOX).setText(text) - xbmc.sleep(2000) - - def getText(self): - try: - if sys.argv[ 1 ] == "gotham-alpha_notice": - return "Call to Gotham alpha users", self.readFile(os.path.join(ADDONPATH , "resources/gotham-alpha_notice.txt")) - except Exception as e: - xbmc.log(ADDONNAME + ': ' + str(e), xbmc.LOGERROR) - return "", "" - - def readFile(self, filename): - return open(filename).read() - -class WebBrowser: - """ Display url using the default browser. """ - - def __init__(self, *args, **kwargs): - try: - url = sys.argv[2] - # notify user - notification(ADDONNAME, url) - xbmc.sleep(100) - # launch url - self.launchUrl(url) - except Exception as e: - xbmc.log(ADDONNAME + ': ' + str(e), xbmc.LOGERROR) - - def launchUrl(self, url): - import webbrowser - webbrowser.open(url) - -def Main(): - try: - if sys.argv[ 1 ] == "webbrowser": - WebBrowser() - else: - Viewer() - except Exception as e: - xbmc.log(ADDONNAME + ': ' + str(e), xbmc.LOGERROR) - -if (__name__ == "__main__"): - Main() diff --git a/addons/service.xbmc.versioncheck/resources/gotham-alpha_notice.txt b/addons/service.xbmc.versioncheck/resources/gotham-alpha_notice.txt deleted file mode 100644 index b905baaae4..0000000000 --- a/addons/service.xbmc.versioncheck/resources/gotham-alpha_notice.txt +++ /dev/null @@ -1,7 +0,0 @@ -[B]Call to Gotham alpha users[/B] -[I]For more information visit http://xbmc.org [/I] - -In the last blog post which you can read at http://xbmc.org we already told you we are working hard towards a Beta release. There are still some things that need to be improved before we are confident on releasing a Beta. We will of course keep you posted when that time comes. Work continues by the developers to iron out the know remaining issues as much as possible. Thanks to the users who install our latest development builds, the remaining problems become known and we try to address these. Do note we may not be able to address all issues reported, as time and available developers are limited. We all try our best but we hope all of you will understand this and we need to accept that some issues will remain. -If you are a developer and you are confident enough to dive into our source code and fix it, we would appreciate it very much if you would create a so called pull-request on our github page for code review so it might be included. - -As it stands now it’s highly unlikely there will be another monthly release before Beta release as there isn’t a merge window any more like we had in the previous months. The monthly builds were done at the end of the month to mark the most stable Gotham version. However now we only do bug fixing, each build we create daily should become better and better. This also means you can download and install the most recent nightly build quite safely to have the most up to date version running. Because of this we would like to ask if possible to upgrade to the last available “nightly build” (the links can be found at the end). As I just mentioned these builds should be considered more stable than any previous monthly Gotham release. There should be no reason to keep using any older monthly build. This would also help to identify any remaining issues left and helps us make the upcoming Gotham release a great one.
\ No newline at end of file diff --git a/addons/service.xbmc.versioncheck/resources/language/Afrikaans/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.af_za/strings.po index 95f99d4405..95f99d4405 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Afrikaans/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.af_za/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Amharic/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.am_et/strings.po index 192cddf5df..192cddf5df 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Amharic/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.am_et/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Arabic/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ar_sa/strings.po index ad8cf641d3..ad8cf641d3 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Arabic/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ar_sa/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Belarusian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.be_by/strings.po index 8fae033bca..8fae033bca 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Belarusian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.be_by/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Bulgarian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.bg_bg/strings.po index 13ae10ddc2..13ae10ddc2 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Bulgarian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.bg_bg/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Bosnian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.bs_ba/strings.po index a3e9d425a1..a3e9d425a1 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Bosnian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.bs_ba/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Catalan/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ca_es/strings.po index ddae20e81d..ddae20e81d 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Catalan/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ca_es/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Czech/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.cs_cz/strings.po index 3486f1414e..3486f1414e 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Czech/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.cs_cz/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Welsh/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.cy_gb/strings.po index a7ba85f209..a7ba85f209 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Welsh/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.cy_gb/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Danish/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.da_dk/strings.po index ed58344e6d..ed58344e6d 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Danish/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.da_dk/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/German/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.de_de/strings.po index dfff922145..dfff922145 100644 --- a/addons/service.xbmc.versioncheck/resources/language/German/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.de_de/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Greek/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.el_gr/strings.po index 0b90fc5dbf..0b90fc5dbf 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Greek/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.el_gr/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/English (Australia)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_au/strings.po index f5c64dae14..f5c64dae14 100644 --- a/addons/service.xbmc.versioncheck/resources/language/English (Australia)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_au/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/English/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_gb/strings.po index 6746418c5c..7aab68ec9a 100644 --- a/addons/service.xbmc.versioncheck/resources/language/English/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_gb/strings.po @@ -24,7 +24,7 @@ msgctxt "#32002" msgid "Visit Kodi.tv for more information." msgstr "" -#empty strings from id 32003 to 32008 +# empty strings from id 32003 to 32008 msgctxt "#32009" msgid "Would you like to remove this reminder?" @@ -58,7 +58,7 @@ msgctxt "#32016" msgid "There is a newer stable Kodi version available." msgstr "" -#empty strings from id 32017 to 32019 +# empty strings from id 32017 to 32019 msgctxt "#32020" msgid "General" @@ -80,7 +80,7 @@ msgctxt "#32024" msgid "Linux: Upgrade using apt" msgstr "" -#empty strings from id 32025 to 32029 +# empty strings from id 32025 to 32029 #. Used in OK dialog msgctxt "#32030" @@ -112,7 +112,7 @@ msgctxt "#32035" msgid "It is recommended that you to upgrade to a newer version." msgstr "" -#empty strings from id 32036 to 32039 +# empty strings from id 32036 to 32039 msgctxt "#32040" msgid "Your version %s of the Python cryptography module is too old. You need at least version 1.7." diff --git a/addons/service.xbmc.versioncheck/resources/language/English (New Zealand)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_nz/strings.po index f5eedbc97c..f5eedbc97c 100644 --- a/addons/service.xbmc.versioncheck/resources/language/English (New Zealand)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_nz/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/English (US)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_us/strings.po index 63f4a600d9..63f4a600d9 100644 --- a/addons/service.xbmc.versioncheck/resources/language/English (US)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.en_us/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Esperanto/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.eo/strings.po index aa40076f7c..aa40076f7c 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Esperanto/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.eo/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Spanish (Argentina)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.es_ar/strings.po index c0d26db1d5..c0d26db1d5 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Spanish (Argentina)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.es_ar/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Spanish/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.es_es/strings.po index 596578e9a0..596578e9a0 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Spanish/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.es_es/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Spanish (Mexico)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.es_mx/strings.po index a737594b58..a737594b58 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Spanish (Mexico)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.es_mx/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Estonian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.et_ee/strings.po index fc6ef2c854..fc6ef2c854 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Estonian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.et_ee/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Basque/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.eu_es/strings.po index b38edba1fb..b38edba1fb 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Basque/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.eu_es/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Persian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.fa_af/strings.po index eed149539d..eed149539d 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Persian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.fa_af/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Persian (Iran)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.fa_ir/strings.po index 31075a0c5a..31075a0c5a 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Persian (Iran)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.fa_ir/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Finnish/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.fi_fi/strings.po index b44b2db916..b44b2db916 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Finnish/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.fi_fi/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Faroese/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.fo_fo/strings.po index 04d7e9c4c5..04d7e9c4c5 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Faroese/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.fo_fo/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/French (Canada)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.fr_ca/strings.po index cd676c4c62..cd676c4c62 100644 --- a/addons/service.xbmc.versioncheck/resources/language/French (Canada)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.fr_ca/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/French/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.fr_fr/strings.po index 51c48d4662..51c48d4662 100644 --- a/addons/service.xbmc.versioncheck/resources/language/French/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.fr_fr/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Galician/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.gl_es/strings.po index 4a47329e07..4a47329e07 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Galician/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.gl_es/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Hebrew/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.he_il/strings.po index 704289a898..704289a898 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Hebrew/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.he_il/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Hindi (Devanagiri)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.hi_in/strings.po index 8b3a6e1114..8b3a6e1114 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Hindi (Devanagiri)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.hi_in/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Croatian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.hr_hr/strings.po index d169766f2f..d169766f2f 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Croatian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.hr_hr/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Hungarian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.hu_hu/strings.po index 66ee97bb44..66ee97bb44 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Hungarian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.hu_hu/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Armenian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.hy_am/strings.po index 178f62f063..178f62f063 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Armenian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.hy_am/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Indonesian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.id_id/strings.po index 8f8292c346..8f8292c346 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Indonesian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.id_id/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Icelandic/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.is_is/strings.po index fa9388742d..fa9388742d 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Icelandic/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.is_is/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Italian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.it_it/strings.po index ea87a62e22..ea87a62e22 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Italian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.it_it/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Japanese/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ja_jp/strings.po index e2f6770021..e2f6770021 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Japanese/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ja_jp/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Korean/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ko_kr/strings.po index 6fb8be9140..6fb8be9140 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Korean/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ko_kr/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Lithuanian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.lt_lt/strings.po index 7fa3579d43..7fa3579d43 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Lithuanian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.lt_lt/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Latvian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.lv_lv/strings.po index ca52f51807..ca52f51807 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Latvian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.lv_lv/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Macedonian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.mk_mk/strings.po index 439a433149..439a433149 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Macedonian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.mk_mk/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Malayalam/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ml_in/strings.po index cc00a0289c..cc00a0289c 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Malayalam/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ml_in/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Mongolian (Mongolia)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.mn_mn/strings.po index 51c68ec3d6..51c68ec3d6 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Mongolian (Mongolia)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.mn_mn/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Malay/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ms_my/strings.po index 0ea4776616..0ea4776616 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Malay/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ms_my/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Maltese/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.mt_mt/strings.po index d4cdc60f4e..d4cdc60f4e 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Maltese/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.mt_mt/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Burmese/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.my_mm/strings.po index b2d650117d..b2d650117d 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Burmese/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.my_mm/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Norwegian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.nb_no/strings.po index cefb39d652..cefb39d652 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Norwegian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.nb_no/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Dutch/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.nl_nl/strings.po index 2d7cd506f0..2d7cd506f0 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Dutch/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.nl_nl/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Polish/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.pl_pl/strings.po index 3fc994317f..3fc994317f 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Polish/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.pl_pl/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Portuguese (Brazil)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.pt_br/strings.po index 296ee05939..296ee05939 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Portuguese (Brazil)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.pt_br/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Portuguese/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.pt_pt/strings.po index b9a2a4b890..b9a2a4b890 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Portuguese/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.pt_pt/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Romanian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ro_ro/strings.po index d7363d30a5..d7363d30a5 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Romanian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ro_ro/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Russian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ru_ru/strings.po index efc608edf2..efc608edf2 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Russian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ru_ru/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Slovak/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.sk_sk/strings.po index b4f7825ff9..b4f7825ff9 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Slovak/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.sk_sk/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Slovenian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.sl_si/strings.po index 051b85fe35..051b85fe35 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Slovenian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.sl_si/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Albanian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.sq_al/strings.po index 08f3c9cdf1..08f3c9cdf1 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Albanian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.sq_al/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Serbian (Cyrillic)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.sr_rs/strings.po index de861fec96..de861fec96 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Serbian (Cyrillic)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.sr_rs/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Serbian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.sr_rs@latin/strings.po index 922d46f94d..922d46f94d 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Serbian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.sr_rs@latin/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Swedish/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.sv_se/strings.po index 3e52d1c1bc..3e52d1c1bc 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Swedish/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.sv_se/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Tamil (India)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.ta_in/strings.po index 8a7007685c..8a7007685c 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Tamil (India)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.ta_in/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Thai/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.th_th/strings.po index c76bc3bdc7..c76bc3bdc7 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Thai/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.th_th/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Turkish/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.tr_tr/strings.po index a6ee608f32..a6ee608f32 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Turkish/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.tr_tr/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Ukrainian/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.uk_ua/strings.po index 7031ed8949..7031ed8949 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Ukrainian/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.uk_ua/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Uzbek/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.uz_uz/strings.po index ef286dc13d..ef286dc13d 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Uzbek/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.uz_uz/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Vietnamese/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.vi_vn/strings.po index 03a22cfcd9..03a22cfcd9 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Vietnamese/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.vi_vn/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Chinese (Simple)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.zh_cn/strings.po index 29109b4bbe..29109b4bbe 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Chinese (Simple)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.zh_cn/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/language/Chinese (Traditional)/strings.po b/addons/service.xbmc.versioncheck/resources/language/resource.language.zh_tw/strings.po index 1094ebda6f..1094ebda6f 100644 --- a/addons/service.xbmc.versioncheck/resources/language/Chinese (Traditional)/strings.po +++ b/addons/service.xbmc.versioncheck/resources/language/resource.language.zh_tw/strings.po diff --git a/addons/service.xbmc.versioncheck/resources/lib/__init__.py b/addons/service.xbmc.versioncheck/resources/lib/__init__.py new file mode 100644 index 0000000000..978a8fe75f --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/__init__.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +__all__ = ['runner', 'version_check'] diff --git a/addons/service.xbmc.versioncheck/resources/lib/runner.py b/addons/service.xbmc.versioncheck/resources/lib/runner.py new file mode 100644 index 0000000000..21e8e8a181 --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/runner.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +from version_check import service # pylint: disable=import-error + +service.run() diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/__init__.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/__init__.py new file mode 100644 index 0000000000..72aa8c7c5f --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/__init__.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +__all__ = ['apt_daemon_handler', 'common', 'handler', 'json_interface', 'service', + 'shell_handler_apt', 'versions', 'viewer'] diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/apt_daemon_handler.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/apt_daemon_handler.py new file mode 100644 index 0000000000..93a6e6243f --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/apt_daemon_handler.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +from .common import log +from .handler import Handler + +try: + import apt + from aptdaemon import client + from aptdaemon import errors +except ImportError: + apt = None + client = None + errors = None + log('ImportError: apt, aptdaemon') + + +class AptDaemonHandler(Handler): + """ Apt daemon handler + """ + + def __init__(self): + Handler.__init__(self) + self.apt_client = client.AptClient() + + def _check_versions(self, package): + """ Check apt package versions + + :param package: package to check + :type package: str + :return: installed version, candidate version + :rtype: str, str / False, False + """ + if self.update and not self._update_cache(): + return False, False + try: + trans = self.apt_client.upgrade_packages([package]) + # trans = self.apt_client.upgrade_packages('bla') + trans.simulate(reply_handler=self._apt_trans_started, + error_handler=self._apt_error_handler) + pkg = trans.packages[4][0] + if pkg == package: + cache = apt.Cache() + cache.open(None) + cache.upgrade() + if cache[pkg].installed: + return cache[pkg].installed.version, cache[pkg].candidate.version + + return False, False + + except Exception as error: # pylint: disable=broad-except + log('Exception while checking versions: %s' % error) + return False, False + + def _update_cache(self): + """ Update apt client cache + + :return: success of updating apt cache + :rtype: bool + """ + try: + return self.apt_client.update_cache(wait=True) == 'exit-success' + except errors.NotAuthorizedError: + log('You are not allowed to update the cache') + return False + + def upgrade_package(self, package): + """ Upgrade apt package + + :param package: package to upgrade + :type package: str + :return: success of apt package upgrade + :rtype: bool + """ + try: + log('Installing new version') + if self.apt_client.upgrade_packages([package], wait=True) == 'exit-success': + log('Upgrade successful') + return True + except Exception as error: # pylint: disable=broad-except + log('Exception during upgrade: %s' % error) + return False + + def upgrade_system(self): + """ Upgrade system + + :return: success of system upgrade + :rtype: bool + """ + try: + log('Upgrading system') + if self.apt_client.upgrade_system(wait=True) == 'exit-success': + return True + except Exception as error: # pylint: disable=broad-except + log('Exception during system upgrade: %s' % error) + return False + + def _apt_trans_started(self): + """ Apt transfer reply handler + """ + + @staticmethod + def _apt_error_handler(error): + """ Apt transfer error handler + + :param error: apt error message + :type error: str + """ + log('Apt Error %s' % error) diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/common.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/common.py new file mode 100644 index 0000000000..74bb0f42b1 --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/common.py @@ -0,0 +1,288 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +import sys + +import xbmc # pylint: disable=import-error +import xbmcaddon # pylint: disable=import-error +import xbmcgui # pylint: disable=import-error +import xbmcvfs # pylint: disable=import-error + +try: + xbmc.translatePath = xbmcvfs.translatePath +except AttributeError: + pass + +ADDON = xbmcaddon.Addon('service.xbmc.versioncheck') +ADDON_VERSION = ADDON.getAddonInfo('version') +ADDON_NAME = ADDON.getAddonInfo('name') +if sys.version_info[0] >= 3: + ADDON_PATH = ADDON.getAddonInfo('path') + ADDON_PROFILE = xbmc.translatePath(ADDON.getAddonInfo('profile')) +else: + ADDON_PATH = ADDON.getAddonInfo('path').decode('utf-8') + ADDON_PROFILE = xbmc.translatePath(ADDON.getAddonInfo('profile')).decode('utf-8') +ICON = ADDON.getAddonInfo('icon') +KODI_VERSION_MAJOR = int(xbmc.getInfoLabel('System.BuildVersion')[0:2]) + +MONITOR = xbmc.Monitor() + + +# Fixes unicode problems +def string_unicode(text, encoding='utf-8'): + """ Python 2/3 -> unicode/str + + :param text: text to convert + :type text: unicode (py2) / str (py3) / bytes (py3) + :param encoding: text encoding + :type encoding: str + :return: converted text + :rtype: unicode (py2) / str (py3) + """ + try: + if sys.version_info[0] >= 3: + text = str(text) + else: + text = unicode(text, encoding) # pylint: disable=undefined-variable + except: # pylint: disable=bare-except + pass + return text + + +def normalize_string(text): + """ Normalize string + + :param text: text to normalize + :type text: unicode (py2) / str (py3) / bytes (py3) + :return: normalized text + :rtype: unicode (py2) / str (py3) + """ + try: + text = unicodedata.normalize('NFKD', string_unicode(text)).encode('ascii', 'ignore') # pylint: disable=undefined-variable + except: # pylint: disable=bare-except + pass + return text + + +def localise(string_id): + """ Localise string id + + :param string_id: id of the string to localise + :type string_id: int + :return: localised string + :rtype: unicode (py2) / str (py3) + """ + string = normalize_string(ADDON.getLocalizedString(string_id)) + return string + + +def log(txt): + """ Log text at xbmc.LOGDEBUG level + + :param txt: text to log + :type txt: str / unicode / bytes (py3) + """ + if sys.version_info[0] >= 3: + if isinstance(txt, bytes): + txt = txt.decode('utf-8') + message = '%s: %s' % (ADDON_NAME, txt) + else: + if isinstance(txt, str): + txt = txt.decode('utf-8') + message = (u'%s: %s' % (ADDON_NAME, txt)).encode('utf-8') + xbmc.log(msg=message, level=xbmc.LOGDEBUG) + + +def notification(heading, message, icon=None, time=15000, sound=True): + """ Create a notification + + :param heading: notification heading + :type heading: str + :param message: notification message + :type message: str + :param icon: path and filename for the notification icon + :type icon: str + :param time: time to display notification + :type time: int + :param sound: is notification audible + :type sound: bool + """ + if not icon: + icon = ICON + xbmcgui.Dialog().notification(heading, message, icon, time, sound) + + +def get_password_from_user(): + """ Prompt user to input password + + :return: password + :rtype: str + """ + pwd = '' + keyboard = xbmc.Keyboard('', ADDON_NAME + ': ' + localise(32022), True) + keyboard.doModal() + if keyboard.isConfirmed(): + pwd = keyboard.getText() + return pwd + + +def message_upgrade_success(): + """ Upgrade success notification + """ + notification(ADDON_NAME, localise(32013)) + + +def message_restart(): + """ Prompt user to restart Kodi + """ + if dialog_yes_no(32014): + xbmc.executebuiltin('RestartApp') + + +def dialog_yes_no(line1=0, line2=0): + """ Prompt user with yes/no dialog + + :param line1: string id for the first line of the dialog + :type line1: int + :param line2: string id for the second line of the dialog + :type line2: int + :return: users selection (yes / no) + :rtype: bool + """ + return xbmcgui.Dialog().yesno(ADDON_NAME, '[CR]'.join([localise(line1), localise(line2)])) + + +def upgrade_message(msg): + """ Prompt user with upgrade suggestion message + + :param msg: string id for prompt message + :type msg: int + """ + wait_for_end_of_video() + + if ADDON.getSetting('lastnotified_version') < ADDON_VERSION: + xbmcgui.Dialog().ok( + ADDON_NAME, + '[CR]'.join([localise(msg), localise(32001), localise(32002)]) + ) + else: + log('Already notified one time for upgrading.') + + +def upgrade_message2(version_installed, version_available, version_stable, old_version): + """ Prompt user with upgrade suggestion message + + :param version_installed: currently installed version + :type version_installed: dict + :param version_available: available version + :type version_available: dict + :param version_stable: latest stable version + :type version_stable: dict + :param old_version: whether using an old version + :type old_version: bool / 'stable' + """ + # shorten releasecandidate to rc + if version_installed['tag'] == 'releasecandidate': + version_installed['tag'] = 'rc' + if version_available['tag'] == 'releasecandidate': + version_available['tag'] = 'rc' + # convert json-rpc result to strings for usage + msg_current = '%i.%i %s%s' % (version_installed['major'], + version_installed['minor'], + version_installed['tag'], + version_installed.get('tagversion', '')) + msg_available = version_available['major'] + '.' + version_available['minor'] + ' ' + \ + version_available['tag'] + version_available.get('tagversion', '') + msg_stable = version_stable['major'] + '.' + version_stable['minor'] + ' ' + \ + version_stable['tag'] + version_stable.get('tagversion', '') + msg = localise(32034) % (msg_current, msg_available) + + wait_for_end_of_video() + + # hack: convert current version number to stable string + # so users don't get notified again. remove in future + if ADDON.getSetting('lastnotified_version') == '0.1.24': + ADDON.setSetting('lastnotified_stable', msg_stable) + + # Show different dialogs depending if there's a newer stable available. + # Also split them between xbmc and kodi notifications to reduce possible confusion. + # People will find out once they visit the website. + # For stable only notify once and when there's a newer stable available. + # Ignore any add-on updates as those only count for != stable + if old_version == 'stable' and ADDON.getSetting('lastnotified_stable') != msg_stable: + if xbmcaddon.Addon('xbmc.addon').getAddonInfo('version') < '13.9.0': + xbmcgui.Dialog().ok(ADDON_NAME, '[CR]'.join([msg, localise(32030), localise(32031)])) + else: + xbmcgui.Dialog().ok(ADDON_NAME, '[CR]'.join([msg, localise(32032), localise(32033)])) + ADDON.setSetting('lastnotified_stable', msg_stable) + + elif old_version != 'stable' and ADDON.getSetting('lastnotified_version') != msg_available: + if xbmcaddon.Addon('xbmc.addon').getAddonInfo('version') < '13.9.0': + # point them to xbmc.org + xbmcgui.Dialog().ok(ADDON_NAME, '[CR]'.join([msg, localise(32035), localise(32031)])) + else: + # use kodi.tv + xbmcgui.Dialog().ok(ADDON_NAME, '[CR]'.join([msg, localise(32035), localise(32033)])) + + ADDON.setSetting('lastnotified_version', msg_available) + + else: + log('Already notified one time for upgrading.') + + +def abort_requested(): + """ Kodi 13+ compatible xbmc.Monitor().abortRequested() + + :return: whether abort requested + :rtype: bool + """ + if KODI_VERSION_MAJOR > 13: + return MONITOR.abortRequested() + + return xbmc.abortRequested + + +def wait_for_abort(seconds): + """ Kodi 13+ compatible xbmc.Monitor().waitForAbort() + + :param seconds: seconds to wait for abort + :type seconds: int / float + :return: whether abort was requested + :rtype: bool + """ + if KODI_VERSION_MAJOR > 13: + return MONITOR.waitForAbort(seconds) + + for _ in range(0, seconds * 1000 / 200): + if xbmc.abortRequested: + return True + xbmc.sleep(200) + + return False + + +def wait_for_end_of_video(): + """ Wait for video playback to end + """ + # Don't show notify while watching a video + while xbmc.Player().isPlayingVideo() and not abort_requested(): + if wait_for_abort(1): + # Abort was requested while waiting. We should exit + break + i = 0 + while i < 10 and not abort_requested(): + if wait_for_abort(1): + # Abort was requested while waiting. We should exit + break + i += 1 diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/distro/__init__.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/distro/__init__.py new file mode 100644 index 0000000000..e08322aacc --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/distro/__init__.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- + +""" + + SPDX-License-Identifier: Apache-2.0 + See LICENSES/Apache-2.0.txt for more information. + +""" + +__all__ = ['distro'] diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/distro/distro.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/distro/distro.py new file mode 100644 index 0000000000..33061633ef --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/distro/distro.py @@ -0,0 +1,1216 @@ +# Copyright 2015,2016,2017 Nir Cohen +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +The ``distro`` package (``distro`` stands for Linux Distribution) provides +information about the Linux distribution it runs on, such as a reliable +machine-readable distro ID, or version information. + +It is the recommended replacement for Python's original +:py:func:`platform.linux_distribution` function, but it provides much more +functionality. An alternative implementation became necessary because Python +3.5 deprecated this function, and Python 3.8 will remove it altogether. +Its predecessor function :py:func:`platform.dist` was already +deprecated since Python 2.6 and will also be removed in Python 3.8. +Still, there are many cases in which access to OS distribution information +is needed. See `Python issue 1322 <https://bugs.python.org/issue1322>`_ for +more information. +""" + +import os +import re +import sys +import json +import shlex +import logging +import argparse +import subprocess + + +_UNIXCONFDIR = os.environ.get('UNIXCONFDIR', '/etc') +_OS_RELEASE_BASENAME = 'os-release' + +#: Translation table for normalizing the "ID" attribute defined in os-release +#: files, for use by the :func:`distro.id` method. +#: +#: * Key: Value as defined in the os-release file, translated to lower case, +#: with blanks translated to underscores. +#: +#: * Value: Normalized value. +NORMALIZED_OS_ID = { + 'ol': 'oracle', # Oracle Enterprise Linux +} + +#: Translation table for normalizing the "Distributor ID" attribute returned by +#: the lsb_release command, for use by the :func:`distro.id` method. +#: +#: * Key: Value as returned by the lsb_release command, translated to lower +#: case, with blanks translated to underscores. +#: +#: * Value: Normalized value. +NORMALIZED_LSB_ID = { + 'enterpriseenterprise': 'oracle', # Oracle Enterprise Linux + 'redhatenterpriseworkstation': 'rhel', # RHEL 6, 7 Workstation + 'redhatenterpriseserver': 'rhel', # RHEL 6, 7 Server +} + +#: Translation table for normalizing the distro ID derived from the file name +#: of distro release files, for use by the :func:`distro.id` method. +#: +#: * Key: Value as derived from the file name of a distro release file, +#: translated to lower case, with blanks translated to underscores. +#: +#: * Value: Normalized value. +NORMALIZED_DISTRO_ID = { + 'redhat': 'rhel', # RHEL 6.x, 7.x +} + +# Pattern for content of distro release file (reversed) +_DISTRO_RELEASE_CONTENT_REVERSED_PATTERN = re.compile( + r'(?:[^)]*\)(.*)\()? *(?:STL )?([\d.+\-a-z]*\d) *(?:esaeler *)?(.+)') + +# Pattern for base file name of distro release file +_DISTRO_RELEASE_BASENAME_PATTERN = re.compile( + r'(\w+)[-_](release|version)$') + +# Base file names to be ignored when searching for distro release file +_DISTRO_RELEASE_IGNORE_BASENAMES = ( + 'debian_version', + 'lsb-release', + 'oem-release', + _OS_RELEASE_BASENAME, + 'system-release' +) + + +def linux_distribution(full_distribution_name=True): + """ + Return information about the current OS distribution as a tuple + ``(id_name, version, codename)`` with items as follows: + + * ``id_name``: If *full_distribution_name* is false, the result of + :func:`distro.id`. Otherwise, the result of :func:`distro.name`. + + * ``version``: The result of :func:`distro.version`. + + * ``codename``: The result of :func:`distro.codename`. + + The interface of this function is compatible with the original + :py:func:`platform.linux_distribution` function, supporting a subset of + its parameters. + + The data it returns may not exactly be the same, because it uses more data + sources than the original function, and that may lead to different data if + the OS distribution is not consistent across multiple data sources it + provides (there are indeed such distributions ...). + + Another reason for differences is the fact that the :func:`distro.id` + method normalizes the distro ID string to a reliable machine-readable value + for a number of popular OS distributions. + """ + return _distro.linux_distribution(full_distribution_name) + + +def id(): + """ + Return the distro ID of the current distribution, as a + machine-readable string. + + For a number of OS distributions, the returned distro ID value is + *reliable*, in the sense that it is documented and that it does not change + across releases of the distribution. + + This package maintains the following reliable distro ID values: + + ============== ========================================= + Distro ID Distribution + ============== ========================================= + "ubuntu" Ubuntu + "debian" Debian + "rhel" RedHat Enterprise Linux + "centos" CentOS + "fedora" Fedora + "sles" SUSE Linux Enterprise Server + "opensuse" openSUSE + "amazon" Amazon Linux + "arch" Arch Linux + "cloudlinux" CloudLinux OS + "exherbo" Exherbo Linux + "gentoo" GenToo Linux + "ibm_powerkvm" IBM PowerKVM + "kvmibm" KVM for IBM z Systems + "linuxmint" Linux Mint + "mageia" Mageia + "mandriva" Mandriva Linux + "parallels" Parallels + "pidora" Pidora + "raspbian" Raspbian + "oracle" Oracle Linux (and Oracle Enterprise Linux) + "scientific" Scientific Linux + "slackware" Slackware + "xenserver" XenServer + "openbsd" OpenBSD + "netbsd" NetBSD + "freebsd" FreeBSD + ============== ========================================= + + If you have a need to get distros for reliable IDs added into this set, + or if you find that the :func:`distro.id` function returns a different + distro ID for one of the listed distros, please create an issue in the + `distro issue tracker`_. + + **Lookup hierarchy and transformations:** + + First, the ID is obtained from the following sources, in the specified + order. The first available and non-empty value is used: + + * the value of the "ID" attribute of the os-release file, + + * the value of the "Distributor ID" attribute returned by the lsb_release + command, + + * the first part of the file name of the distro release file, + + The so determined ID value then passes the following transformations, + before it is returned by this method: + + * it is translated to lower case, + + * blanks (which should not be there anyway) are translated to underscores, + + * a normalization of the ID is performed, based upon + `normalization tables`_. The purpose of this normalization is to ensure + that the ID is as reliable as possible, even across incompatible changes + in the OS distributions. A common reason for an incompatible change is + the addition of an os-release file, or the addition of the lsb_release + command, with ID values that differ from what was previously determined + from the distro release file name. + """ + return _distro.id() + + +def name(pretty=False): + """ + Return the name of the current OS distribution, as a human-readable + string. + + If *pretty* is false, the name is returned without version or codename. + (e.g. "CentOS Linux") + + If *pretty* is true, the version and codename are appended. + (e.g. "CentOS Linux 7.1.1503 (Core)") + + **Lookup hierarchy:** + + The name is obtained from the following sources, in the specified order. + The first available and non-empty value is used: + + * If *pretty* is false: + + - the value of the "NAME" attribute of the os-release file, + + - the value of the "Distributor ID" attribute returned by the lsb_release + command, + + - the value of the "<name>" field of the distro release file. + + * If *pretty* is true: + + - the value of the "PRETTY_NAME" attribute of the os-release file, + + - the value of the "Description" attribute returned by the lsb_release + command, + + - the value of the "<name>" field of the distro release file, appended + with the value of the pretty version ("<version_id>" and "<codename>" + fields) of the distro release file, if available. + """ + return _distro.name(pretty) + + +def version(pretty=False, best=False): + """ + Return the version of the current OS distribution, as a human-readable + string. + + If *pretty* is false, the version is returned without codename (e.g. + "7.0"). + + If *pretty* is true, the codename in parenthesis is appended, if the + codename is non-empty (e.g. "7.0 (Maipo)"). + + Some distributions provide version numbers with different precisions in + the different sources of distribution information. Examining the different + sources in a fixed priority order does not always yield the most precise + version (e.g. for Debian 8.2, or CentOS 7.1). + + The *best* parameter can be used to control the approach for the returned + version: + + If *best* is false, the first non-empty version number in priority order of + the examined sources is returned. + + If *best* is true, the most precise version number out of all examined + sources is returned. + + **Lookup hierarchy:** + + In all cases, the version number is obtained from the following sources. + If *best* is false, this order represents the priority order: + + * the value of the "VERSION_ID" attribute of the os-release file, + * the value of the "Release" attribute returned by the lsb_release + command, + * the version number parsed from the "<version_id>" field of the first line + of the distro release file, + * the version number parsed from the "PRETTY_NAME" attribute of the + os-release file, if it follows the format of the distro release files. + * the version number parsed from the "Description" attribute returned by + the lsb_release command, if it follows the format of the distro release + files. + """ + return _distro.version(pretty, best) + + +def version_parts(best=False): + """ + Return the version of the current OS distribution as a tuple + ``(major, minor, build_number)`` with items as follows: + + * ``major``: The result of :func:`distro.major_version`. + + * ``minor``: The result of :func:`distro.minor_version`. + + * ``build_number``: The result of :func:`distro.build_number`. + + For a description of the *best* parameter, see the :func:`distro.version` + method. + """ + return _distro.version_parts(best) + + +def major_version(best=False): + """ + Return the major version of the current OS distribution, as a string, + if provided. + Otherwise, the empty string is returned. The major version is the first + part of the dot-separated version string. + + For a description of the *best* parameter, see the :func:`distro.version` + method. + """ + return _distro.major_version(best) + + +def minor_version(best=False): + """ + Return the minor version of the current OS distribution, as a string, + if provided. + Otherwise, the empty string is returned. The minor version is the second + part of the dot-separated version string. + + For a description of the *best* parameter, see the :func:`distro.version` + method. + """ + return _distro.minor_version(best) + + +def build_number(best=False): + """ + Return the build number of the current OS distribution, as a string, + if provided. + Otherwise, the empty string is returned. The build number is the third part + of the dot-separated version string. + + For a description of the *best* parameter, see the :func:`distro.version` + method. + """ + return _distro.build_number(best) + + +def like(): + """ + Return a space-separated list of distro IDs of distributions that are + closely related to the current OS distribution in regards to packaging + and programming interfaces, for example distributions the current + distribution is a derivative from. + + **Lookup hierarchy:** + + This information item is only provided by the os-release file. + For details, see the description of the "ID_LIKE" attribute in the + `os-release man page + <http://www.freedesktop.org/software/systemd/man/os-release.html>`_. + """ + return _distro.like() + + +def codename(): + """ + Return the codename for the release of the current OS distribution, + as a string. + + If the distribution does not have a codename, an empty string is returned. + + Note that the returned codename is not always really a codename. For + example, openSUSE returns "x86_64". This function does not handle such + cases in any special way and just returns the string it finds, if any. + + **Lookup hierarchy:** + + * the codename within the "VERSION" attribute of the os-release file, if + provided, + + * the value of the "Codename" attribute returned by the lsb_release + command, + + * the value of the "<codename>" field of the distro release file. + """ + return _distro.codename() + + +def info(pretty=False, best=False): + """ + Return certain machine-readable information items about the current OS + distribution in a dictionary, as shown in the following example: + + .. sourcecode:: python + + { + 'id': 'rhel', + 'version': '7.0', + 'version_parts': { + 'major': '7', + 'minor': '0', + 'build_number': '' + }, + 'like': 'fedora', + 'codename': 'Maipo' + } + + The dictionary structure and keys are always the same, regardless of which + information items are available in the underlying data sources. The values + for the various keys are as follows: + + * ``id``: The result of :func:`distro.id`. + + * ``version``: The result of :func:`distro.version`. + + * ``version_parts -> major``: The result of :func:`distro.major_version`. + + * ``version_parts -> minor``: The result of :func:`distro.minor_version`. + + * ``version_parts -> build_number``: The result of + :func:`distro.build_number`. + + * ``like``: The result of :func:`distro.like`. + + * ``codename``: The result of :func:`distro.codename`. + + For a description of the *pretty* and *best* parameters, see the + :func:`distro.version` method. + """ + return _distro.info(pretty, best) + + +def os_release_info(): + """ + Return a dictionary containing key-value pairs for the information items + from the os-release file data source of the current OS distribution. + + See `os-release file`_ for details about these information items. + """ + return _distro.os_release_info() + + +def lsb_release_info(): + """ + Return a dictionary containing key-value pairs for the information items + from the lsb_release command data source of the current OS distribution. + + See `lsb_release command output`_ for details about these information + items. + """ + return _distro.lsb_release_info() + + +def distro_release_info(): + """ + Return a dictionary containing key-value pairs for the information items + from the distro release file data source of the current OS distribution. + + See `distro release file`_ for details about these information items. + """ + return _distro.distro_release_info() + + +def uname_info(): + """ + Return a dictionary containing key-value pairs for the information items + from the distro release file data source of the current OS distribution. + """ + return _distro.uname_info() + + +def os_release_attr(attribute): + """ + Return a single named information item from the os-release file data source + of the current OS distribution. + + Parameters: + + * ``attribute`` (string): Key of the information item. + + Returns: + + * (string): Value of the information item, if the item exists. + The empty string, if the item does not exist. + + See `os-release file`_ for details about these information items. + """ + return _distro.os_release_attr(attribute) + + +def lsb_release_attr(attribute): + """ + Return a single named information item from the lsb_release command output + data source of the current OS distribution. + + Parameters: + + * ``attribute`` (string): Key of the information item. + + Returns: + + * (string): Value of the information item, if the item exists. + The empty string, if the item does not exist. + + See `lsb_release command output`_ for details about these information + items. + """ + return _distro.lsb_release_attr(attribute) + + +def distro_release_attr(attribute): + """ + Return a single named information item from the distro release file + data source of the current OS distribution. + + Parameters: + + * ``attribute`` (string): Key of the information item. + + Returns: + + * (string): Value of the information item, if the item exists. + The empty string, if the item does not exist. + + See `distro release file`_ for details about these information items. + """ + return _distro.distro_release_attr(attribute) + + +def uname_attr(attribute): + """ + Return a single named information item from the distro release file + data source of the current OS distribution. + + Parameters: + + * ``attribute`` (string): Key of the information item. + + Returns: + + * (string): Value of the information item, if the item exists. + The empty string, if the item does not exist. + """ + return _distro.uname_attr(attribute) + + +class cached_property(object): + """A version of @property which caches the value. On access, it calls the + underlying function and sets the value in `__dict__` so future accesses + will not re-call the property. + """ + def __init__(self, f): + self._fname = f.__name__ + self._f = f + + def __get__(self, obj, owner): + assert obj is not None, 'call {} on an instance'.format(self._fname) + ret = obj.__dict__[self._fname] = self._f(obj) + return ret + + +class LinuxDistribution(object): + """ + Provides information about a OS distribution. + + This package creates a private module-global instance of this class with + default initialization arguments, that is used by the + `consolidated accessor functions`_ and `single source accessor functions`_. + By using default initialization arguments, that module-global instance + returns data about the current OS distribution (i.e. the distro this + package runs on). + + Normally, it is not necessary to create additional instances of this class. + However, in situations where control is needed over the exact data sources + that are used, instances of this class can be created with a specific + distro release file, or a specific os-release file, or without invoking the + lsb_release command. + """ + + def __init__(self, + include_lsb=True, + os_release_file='', + distro_release_file='', + include_uname=True): + """ + The initialization method of this class gathers information from the + available data sources, and stores that in private instance attributes. + Subsequent access to the information items uses these private instance + attributes, so that the data sources are read only once. + + Parameters: + + * ``include_lsb`` (bool): Controls whether the + `lsb_release command output`_ is included as a data source. + + If the lsb_release command is not available in the program execution + path, the data source for the lsb_release command will be empty. + + * ``os_release_file`` (string): The path name of the + `os-release file`_ that is to be used as a data source. + + An empty string (the default) will cause the default path name to + be used (see `os-release file`_ for details). + + If the specified or defaulted os-release file does not exist, the + data source for the os-release file will be empty. + + * ``distro_release_file`` (string): The path name of the + `distro release file`_ that is to be used as a data source. + + An empty string (the default) will cause a default search algorithm + to be used (see `distro release file`_ for details). + + If the specified distro release file does not exist, or if no default + distro release file can be found, the data source for the distro + release file will be empty. + + * ``include_name`` (bool): Controls whether uname command output is + included as a data source. If the uname command is not available in + the program execution path the data source for the uname command will + be empty. + + Public instance attributes: + + * ``os_release_file`` (string): The path name of the + `os-release file`_ that is actually used as a data source. The + empty string if no distro release file is used as a data source. + + * ``distro_release_file`` (string): The path name of the + `distro release file`_ that is actually used as a data source. The + empty string if no distro release file is used as a data source. + + * ``include_lsb`` (bool): The result of the ``include_lsb`` parameter. + This controls whether the lsb information will be loaded. + + * ``include_uname`` (bool): The result of the ``include_uname`` + parameter. This controls whether the uname information will + be loaded. + + Raises: + + * :py:exc:`IOError`: Some I/O issue with an os-release file or distro + release file. + + * :py:exc:`subprocess.CalledProcessError`: The lsb_release command had + some issue (other than not being available in the program execution + path). + + * :py:exc:`UnicodeError`: A data source has unexpected characters or + uses an unexpected encoding. + """ + self.os_release_file = os_release_file or \ + os.path.join(_UNIXCONFDIR, _OS_RELEASE_BASENAME) + self.distro_release_file = distro_release_file or '' # updated later + self.include_lsb = include_lsb + self.include_uname = include_uname + + def __repr__(self): + """Return repr of all info + """ + return \ + "LinuxDistribution(" \ + "os_release_file={self.os_release_file!r}, " \ + "distro_release_file={self.distro_release_file!r}, " \ + "include_lsb={self.include_lsb!r}, " \ + "include_uname={self.include_uname!r}, " \ + "_os_release_info={self._os_release_info!r}, " \ + "_lsb_release_info={self._lsb_release_info!r}, " \ + "_distro_release_info={self._distro_release_info!r}, " \ + "_uname_info={self._uname_info!r})".format( + self=self) + + def linux_distribution(self, full_distribution_name=True): + """ + Return information about the OS distribution that is compatible + with Python's :func:`platform.linux_distribution`, supporting a subset + of its parameters. + + For details, see :func:`distro.linux_distribution`. + """ + return ( + self.name() if full_distribution_name else self.id(), + self.version(), + self.codename() + ) + + def id(self): + """Return the distro ID of the OS distribution, as a string. + + For details, see :func:`distro.id`. + """ + def normalize(distro_id, table): + distro_id = distro_id.lower().replace(' ', '_') + return table.get(distro_id, distro_id) + + distro_id = self.os_release_attr('id') + if distro_id: + return normalize(distro_id, NORMALIZED_OS_ID) + + distro_id = self.lsb_release_attr('distributor_id') + if distro_id: + return normalize(distro_id, NORMALIZED_LSB_ID) + + distro_id = self.distro_release_attr('id') + if distro_id: + return normalize(distro_id, NORMALIZED_DISTRO_ID) + + distro_id = self.uname_attr('id') + if distro_id: + return normalize(distro_id, NORMALIZED_DISTRO_ID) + + return '' + + def name(self, pretty=False): + """ + Return the name of the OS distribution, as a string. + + For details, see :func:`distro.name`. + """ + name = self.os_release_attr('name') \ + or self.lsb_release_attr('distributor_id') \ + or self.distro_release_attr('name') \ + or self.uname_attr('name') + if pretty: + name = self.os_release_attr('pretty_name') \ + or self.lsb_release_attr('description') + if not name: + name = self.distro_release_attr('name') \ + or self.uname_attr('name') + version = self.version(pretty=True) + if version: + name = name + ' ' + version + return name or '' + + def version(self, pretty=False, best=False): + """ + Return the version of the OS distribution, as a string. + + For details, see :func:`distro.version`. + """ + versions = [ + self.os_release_attr('version_id'), + self.lsb_release_attr('release'), + self.distro_release_attr('version_id'), + self._parse_distro_release_content( + self.os_release_attr('pretty_name')).get('version_id', ''), + self._parse_distro_release_content( + self.lsb_release_attr('description')).get('version_id', ''), + self.uname_attr('release') + ] + version = '' + if best: + # This algorithm uses the last version in priority order that has + # the best precision. If the versions are not in conflict, that + # does not matter; otherwise, using the last one instead of the + # first one might be considered a surprise. + for v in versions: + if v.count(".") > version.count(".") or version == '': + version = v + else: + for v in versions: + if v != '': + version = v + break + if pretty and version and self.codename(): + version = u'{0} ({1})'.format(version, self.codename()) + return version + + def version_parts(self, best=False): + """ + Return the version of the OS distribution, as a tuple of version + numbers. + + For details, see :func:`distro.version_parts`. + """ + version_str = self.version(best=best) + if version_str: + version_regex = re.compile(r'(\d+)\.?(\d+)?\.?(\d+)?') + matches = version_regex.match(version_str) + if matches: + major, minor, build_number = matches.groups() + return major, minor or '', build_number or '' + return '', '', '' + + def major_version(self, best=False): + """ + Return the major version number of the current distribution. + + For details, see :func:`distro.major_version`. + """ + return self.version_parts(best)[0] + + def minor_version(self, best=False): + """ + Return the minor version number of the current distribution. + + For details, see :func:`distro.minor_version`. + """ + return self.version_parts(best)[1] + + def build_number(self, best=False): + """ + Return the build number of the current distribution. + + For details, see :func:`distro.build_number`. + """ + return self.version_parts(best)[2] + + def like(self): + """ + Return the IDs of distributions that are like the OS distribution. + + For details, see :func:`distro.like`. + """ + return self.os_release_attr('id_like') or '' + + def codename(self): + """ + Return the codename of the OS distribution. + + For details, see :func:`distro.codename`. + """ + try: + # Handle os_release specially since distros might purposefully set + # this to empty string to have no codename + return self._os_release_info['codename'] + except KeyError: + return self.lsb_release_attr('codename') \ + or self.distro_release_attr('codename') \ + or '' + + def info(self, pretty=False, best=False): + """ + Return certain machine-readable information about the OS + distribution. + + For details, see :func:`distro.info`. + """ + return dict( + id=self.id(), + version=self.version(pretty, best), + version_parts=dict( + major=self.major_version(best), + minor=self.minor_version(best), + build_number=self.build_number(best) + ), + like=self.like(), + codename=self.codename(), + ) + + def os_release_info(self): + """ + Return a dictionary containing key-value pairs for the information + items from the os-release file data source of the OS distribution. + + For details, see :func:`distro.os_release_info`. + """ + return self._os_release_info + + def lsb_release_info(self): + """ + Return a dictionary containing key-value pairs for the information + items from the lsb_release command data source of the OS + distribution. + + For details, see :func:`distro.lsb_release_info`. + """ + return self._lsb_release_info + + def distro_release_info(self): + """ + Return a dictionary containing key-value pairs for the information + items from the distro release file data source of the OS + distribution. + + For details, see :func:`distro.distro_release_info`. + """ + return self._distro_release_info + + def uname_info(self): + """ + Return a dictionary containing key-value pairs for the information + items from the uname command data source of the OS distribution. + + For details, see :func:`distro.uname_info`. + """ + return self._uname_info + + def os_release_attr(self, attribute): + """ + Return a single named information item from the os-release file data + source of the OS distribution. + + For details, see :func:`distro.os_release_attr`. + """ + return self._os_release_info.get(attribute, '') + + def lsb_release_attr(self, attribute): + """ + Return a single named information item from the lsb_release command + output data source of the OS distribution. + + For details, see :func:`distro.lsb_release_attr`. + """ + return self._lsb_release_info.get(attribute, '') + + def distro_release_attr(self, attribute): + """ + Return a single named information item from the distro release file + data source of the OS distribution. + + For details, see :func:`distro.distro_release_attr`. + """ + return self._distro_release_info.get(attribute, '') + + def uname_attr(self, attribute): + """ + Return a single named information item from the uname command + output data source of the OS distribution. + + For details, see :func:`distro.uname_release_attr`. + """ + return self._uname_info.get(attribute, '') + + @cached_property + def _os_release_info(self): + """ + Get the information items from the specified os-release file. + + Returns: + A dictionary containing all information items. + """ + if os.path.isfile(self.os_release_file): + with open(self.os_release_file) as release_file: + return self._parse_os_release_content(release_file) + return {} + + @staticmethod + def _parse_os_release_content(lines): + """ + Parse the lines of an os-release file. + + Parameters: + + * lines: Iterable through the lines in the os-release file. + Each line must be a unicode string or a UTF-8 encoded byte + string. + + Returns: + A dictionary containing all information items. + """ + props = {} + lexer = shlex.shlex(lines, posix=True) + lexer.whitespace_split = True + + # The shlex module defines its `wordchars` variable using literals, + # making it dependent on the encoding of the Python source file. + # In Python 2.6 and 2.7, the shlex source file is encoded in + # 'iso-8859-1', and the `wordchars` variable is defined as a byte + # string. This causes a UnicodeDecodeError to be raised when the + # parsed content is a unicode object. The following fix resolves that + # (... but it should be fixed in shlex...): + if sys.version_info[0] == 2 and isinstance(lexer.wordchars, bytes): + lexer.wordchars = lexer.wordchars.decode('iso-8859-1') + + tokens = list(lexer) + for token in tokens: + # At this point, all shell-like parsing has been done (i.e. + # comments processed, quotes and backslash escape sequences + # processed, multi-line values assembled, trailing newlines + # stripped, etc.), so the tokens are now either: + # * variable assignments: var=value + # * commands or their arguments (not allowed in os-release) + if '=' in token: + k, v = token.split('=', 1) + if isinstance(v, bytes): + v = v.decode('utf-8') + props[k.lower()] = v + else: + # Ignore any tokens that are not variable assignments + pass + + if 'version_codename' in props: + # os-release added a version_codename field. Use that in + # preference to anything else Note that some distros purposefully + # do not have code names. They should be setting + # version_codename="" + props['codename'] = props['version_codename'] + elif 'ubuntu_codename' in props: + # Same as above but a non-standard field name used on older Ubuntus + props['codename'] = props['ubuntu_codename'] + elif 'version' in props: + # If there is no version_codename, parse it from the version + codename = re.search(r'(\(\D+\))|,(\s+)?\D+', props['version']) + if codename: + codename = codename.group() + codename = codename.strip('()') + codename = codename.strip(',') + codename = codename.strip() + # codename appears within paranthese. + props['codename'] = codename + + return props + + @cached_property + def _lsb_release_info(self): + """ + Get the information items from the lsb_release command output. + + Returns: + A dictionary containing all information items. + """ + if not self.include_lsb: + return {} + with open(os.devnull, 'w') as devnull: + try: + cmd = ('lsb_release', '-a') + stdout = subprocess.check_output(cmd, stderr=devnull) + except OSError: # Command not found + return {} + content = stdout.decode(sys.getfilesystemencoding()).splitlines() + return self._parse_lsb_release_content(content) + + @staticmethod + def _parse_lsb_release_content(lines): + """ + Parse the output of the lsb_release command. + + Parameters: + + * lines: Iterable through the lines of the lsb_release output. + Each line must be a unicode string or a UTF-8 encoded byte + string. + + Returns: + A dictionary containing all information items. + """ + props = {} + for line in lines: + kv = line.strip('\n').split(':', 1) + if len(kv) != 2: + # Ignore lines without colon. + continue + k, v = kv + props.update({k.replace(' ', '_').lower(): v.strip()}) + return props + + @cached_property + def _uname_info(self): + with open(os.devnull, 'w') as devnull: + try: + cmd = ('uname', '-rs') + stdout = subprocess.check_output(cmd, stderr=devnull) + except OSError: + return {} + content = stdout.decode(sys.getfilesystemencoding()).splitlines() + return self._parse_uname_content(content) + + @staticmethod + def _parse_uname_content(lines): + props = {} + match = re.search(r'^([^\s]+)\s+([\d\.]+)', lines[0].strip()) + if match: + name, version = match.groups() + + # This is to prevent the Linux kernel version from + # appearing as the 'best' version on otherwise + # identifiable distributions. + if name == 'Linux': + return {} + props['id'] = name.lower() + props['name'] = name + props['release'] = version + return props + + @cached_property + def _distro_release_info(self): + """ + Get the information items from the specified distro release file. + + Returns: + A dictionary containing all information items. + """ + if self.distro_release_file: + # If it was specified, we use it and parse what we can, even if + # its file name or content does not match the expected pattern. + distro_info = self._parse_distro_release_file( + self.distro_release_file) + basename = os.path.basename(self.distro_release_file) + # The file name pattern for user-specified distro release files + # is somewhat more tolerant (compared to when searching for the + # file), because we want to use what was specified as best as + # possible. + match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename) + if 'name' in distro_info \ + and 'cloudlinux' in distro_info['name'].lower(): + distro_info['id'] = 'cloudlinux' + elif match: + distro_info['id'] = match.group(1) + return distro_info + else: + try: + basenames = os.listdir(_UNIXCONFDIR) + # We sort for repeatability in cases where there are multiple + # distro specific files; e.g. CentOS, Oracle, Enterprise all + # containing `redhat-release` on top of their own. + basenames.sort() + except OSError: + # This may occur when /etc is not readable but we can't be + # sure about the *-release files. Check common entries of + # /etc for information. If they turn out to not be there the + # error is handled in `_parse_distro_release_file()`. + basenames = ['SuSE-release', + 'arch-release', + 'base-release', + 'centos-release', + 'fedora-release', + 'gentoo-release', + 'mageia-release', + 'mandrake-release', + 'mandriva-release', + 'mandrivalinux-release', + 'manjaro-release', + 'oracle-release', + 'redhat-release', + 'sl-release', + 'slackware-version'] + for basename in basenames: + if basename in _DISTRO_RELEASE_IGNORE_BASENAMES: + continue + match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename) + if match: + filepath = os.path.join(_UNIXCONFDIR, basename) + distro_info = self._parse_distro_release_file(filepath) + if 'name' in distro_info: + # The name is always present if the pattern matches + self.distro_release_file = filepath + distro_info['id'] = match.group(1) + if 'cloudlinux' in distro_info['name'].lower(): + distro_info['id'] = 'cloudlinux' + return distro_info + return {} + + def _parse_distro_release_file(self, filepath): + """ + Parse a distro release file. + + Parameters: + + * filepath: Path name of the distro release file. + + Returns: + A dictionary containing all information items. + """ + try: + with open(filepath) as fp: + # Only parse the first line. For instance, on SLES there + # are multiple lines. We don't want them... + return self._parse_distro_release_content(fp.readline()) + except (OSError, IOError): + # Ignore not being able to read a specific, seemingly version + # related file. + # See https://github.com/nir0s/distro/issues/162 + return {} + + @staticmethod + def _parse_distro_release_content(line): + """ + Parse a line from a distro release file. + + Parameters: + * line: Line from the distro release file. Must be a unicode string + or a UTF-8 encoded byte string. + + Returns: + A dictionary containing all information items. + """ + if isinstance(line, bytes): + line = line.decode('utf-8') + matches = _DISTRO_RELEASE_CONTENT_REVERSED_PATTERN.match( + line.strip()[::-1]) + distro_info = {} + if matches: + # regexp ensures non-None + distro_info['name'] = matches.group(3)[::-1] + if matches.group(2): + distro_info['version_id'] = matches.group(2)[::-1] + if matches.group(1): + distro_info['codename'] = matches.group(1)[::-1] + elif line: + distro_info['name'] = line.strip() + return distro_info + + +_distro = LinuxDistribution() + + +def main(): + logger = logging.getLogger(__name__) + logger.setLevel(logging.DEBUG) + logger.addHandler(logging.StreamHandler(sys.stdout)) + + parser = argparse.ArgumentParser(description="OS distro info tool") + parser.add_argument( + '--json', + '-j', + help="Output in machine readable format", + action="store_true") + args = parser.parse_args() + + if args.json: + logger.info(json.dumps(info(), indent=4, sort_keys=True)) + else: + logger.info('Name: %s', name(pretty=True)) + distribution_version = version(pretty=True) + logger.info('Version: %s', distribution_version) + distribution_codename = codename() + logger.info('Codename: %s', distribution_codename) + + +if __name__ == '__main__': + main() diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/handler.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/handler.py new file mode 100644 index 0000000000..b2ce3a4dcd --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/handler.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +from .common import get_password_from_user +from .common import log + + +class Handler: + """ Base handler class for apt_daemon_handler, and shell_handler_apt + """ + + def __init__(self): + self._pwd = '' + self._update = True + + @property + def pwd(self): + """ password property + + :return: password + :rtype: str + """ + return self._pwd + + @pwd.setter + def pwd(self, value): + """ password setter + + :param value: password + :type value: str + """ + self._pwd = value + + @property + def update(self): + """ update apt-cache property + + :return: whether to update apt-cache or not when checking for upgrades + :rtype: bool + """ + return self._update + + @update.setter + def update(self, value): + """ update apt-cache setter + + :param value: whether to update apt-cache or not when checking for upgrades + :type value: bool + """ + self._update = value + + def _check_versions(self, package): + raise NotImplementedError + + def check_upgrade_available(self, package): + """ Check if package upgrade is available + + :param package: package to check for upgrade availability + :type package: str + :return: whether an upgrade exists for the provided package + :rtype: bool + """ + installed, candidate = self._check_versions(package) + if installed and candidate: + if installed != candidate: + log('Version installed %s' % installed) + log('Version available %s' % candidate) + return True + log('Already on newest version') + return False + + if not installed: + log('No installed package found') + + return False + + def _get_password(self): + """ Get password, ask user for password if not known + + :return: password + :rtype: str + """ + if not self.pwd: + self.pwd = get_password_from_user() + return self.pwd diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/json_interface.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/json_interface.py new file mode 100644 index 0000000000..e09618f900 --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/json_interface.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +from contextlib import closing +import json +import os +import sys + +import xbmc # pylint: disable=import-error +import xbmcvfs # pylint: disable=import-error + +from .common import ADDON_PATH + + +def get_installed_version(): + """ Retrieve the currently installed version + + :return: currently installed version + :rtype: dict + """ + query = { + "jsonrpc": "2.0", + "method": "Application.GetProperties", + "params": { + "properties": ["version", "name"] + }, + "id": 1 + } + json_query = xbmc.executeJSONRPC(json.dumps(query)) + if sys.version_info[0] >= 3: + json_query = str(json_query) + else: + json_query = unicode(json_query, 'utf-8', errors='ignore') # pylint: disable=undefined-variable + json_query = json.loads(json_query) + version_installed = [] + if 'result' in json_query and 'version' in json_query['result']: + version_installed = json_query['result']['version'] + return version_installed + + +def get_version_file_list(): + """ Retrieve version lists from supplied version file (resources/versions.txt) + + :return: all provided versions + :rtype: dict + """ + version_file = os.path.join(ADDON_PATH, 'resources/versions.txt') + with closing(xbmcvfs.File(version_file)) as open_file: + data = open_file.read() + + if sys.version_info[0] >= 3: + version_query = str(data) + else: + version_query = unicode(data, 'utf-8', errors='ignore') # pylint: disable=undefined-variable + version_query = json.loads(version_query) + return version_query diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/service.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/service.py new file mode 100644 index 0000000000..32b7322258 --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/service.py @@ -0,0 +1,162 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +import platform +import sys + +import xbmc # pylint: disable=import-error +import xbmcgui # pylint: disable=import-error + +from .common import ADDON +from .common import ADDON_NAME +from .common import ADDON_VERSION +from .common import dialog_yes_no +from .common import localise +from .common import log +from .common import wait_for_abort +from .common import message_restart +from .common import message_upgrade_success +from .common import upgrade_message +from .common import upgrade_message2 +from .json_interface import get_version_file_list +from .json_interface import get_installed_version +from .versions import compare_version + +if sys.version_info[0] == 3 and sys.version_info[1] >= 8: + try: + from .distro import distro + + DISTRIBUTION = distro.linux_distribution(full_distribution_name=False)[0].lower() + + except (AttributeError, ImportError): + DISTRIBUTION = '' + +else: + DISTRIBUTION = platform.linux_distribution(full_distribution_name=0)[0].lower() # pylint: disable=deprecated-method + +if not DISTRIBUTION: + DISTRIBUTION = platform.uname()[0].lower() + + +def _version_check(): + """ Check versions (non-linux) + + :return: old, current, available, and stable versions + :rtype: bool / 'stable', dict, dict, dict + """ + # retrieve version_lists from supplied version file + version_list = get_version_file_list() + # retrieve version installed + version_installed = get_installed_version() + # compare installed and available + old_version, version_installed, version_available, version_stable = \ + compare_version(version_installed, version_list) + return old_version, version_installed, version_available, version_stable + + +def _version_check_linux(packages): + """ Check package version on linux + + :param packages: list of packages to check + :type packages: list of str + """ + if DISTRIBUTION in ['ubuntu', 'debian', 'linuxmint']: + try: + # try aptdaemon first + # pylint: disable=import-outside-toplevel + from .apt_daemon_handler import AptDaemonHandler + handler = AptDaemonHandler() + except: # pylint: disable=bare-except + # fallback to shell + # since we need the user password, ask to check for new version first + # pylint: disable=import-outside-toplevel + from .shell_handler_apt import ShellHandlerApt + handler = ShellHandlerApt(use_sudo=True) + if dialog_yes_no(32015): + pass + elif dialog_yes_no(32009, 32010): + log('disabling addon by user request') + ADDON.setSetting('versioncheck_enable', 'false') + return + + if handler: + if handler.check_upgrade_available(packages[0]): + if upgrade_message(32012): + if ADDON.getSetting('upgrade_system') == 'false': + result = handler.upgrade_package(packages[0]) + else: + result = handler.upgrade_system() + if result: + message_upgrade_success() + message_restart() + else: + log('Error during upgrade') + return + + log('No upgrade available') + return + + log('Error: no handler found') + return + + log('Unsupported platform %s' % DISTRIBUTION) + sys.exit(0) + + +def _check_cryptography(): + """ Check for cryptography package, and version + + Python cryptography < 1.7 (still shipped with Ubuntu 16.04) has issues with + pyOpenSSL integration, leading to all sorts of weird bugs - check here to save + on some troubleshooting. This check may be removed in the future (when switching + to Python3?) + See https://github.com/pyca/pyopenssl/issues/542 + """ + try: + import cryptography # pylint: disable=import-outside-toplevel + ver = cryptography.__version__ + except ImportError: + # If the module is not found - no problem + return + + ver_parts = list(map(int, ver.split('.'))) + if len(ver_parts) < 2 or ver_parts[0] < 1 or (ver_parts[0] == 1 and ver_parts[1] < 7): + log('Python cryptography module version %s is too old, at least version 1.7 needed' % ver) + xbmcgui.Dialog().ok( + ADDON_NAME, + '[CR]'.join([localise(32040) % ver, localise(32041), localise(32042)]) + ) + + +def run(): + """ Service entry-point + """ + _check_cryptography() + + if ADDON.getSetting('versioncheck_enable') == 'false': + log('Disabled') + else: + log('Version %s started' % ADDON_VERSION) + + if wait_for_abort(5): + sys.exit(0) + + if (xbmc.getCondVisibility('System.Platform.Linux') and + ADDON.getSetting('upgrade_apt') == 'true'): + _version_check_linux(['kodi']) + else: + old_version, version_installed, version_available, version_stable = _version_check() + if old_version: + upgrade_message2(version_installed, version_available, version_stable, old_version) diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/shell_handler_apt.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/shell_handler_apt.py new file mode 100644 index 0000000000..1f7307c3e7 --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/shell_handler_apt.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +import sys + +from .common import log +from .handler import Handler + +try: + from subprocess import check_output +except ImportError: + check_output = None + log('ImportError: subprocess') + + +class ShellHandlerApt(Handler): + """ Apt shell handler + """ + + def __init__(self, use_sudo=False): + Handler.__init__(self) + self.sudo = use_sudo + self._update = False + installed, _ = self._check_versions('kodi') + if not installed: + # there is no package installed via repo, so we exit here + log('No installed package found, exiting') + sys.exit(0) + self._update = True + + def _check_versions(self, package): + """ Check apt package versions + + :param package: package to check + :type package: str + :return: installed version, candidate version + :rtype: str, str / False, False + """ + _cmd = 'apt-cache policy ' + package + + if self.update and not self._update_cache(): + return False, False + + try: + result = check_output([_cmd], shell=True).split('\n') + except Exception as error: # pylint: disable=broad-except + log('ShellHandlerApt: exception while executing shell command %s: %s' % (_cmd, error)) + return False, False + + if result[0].replace(':', '') == package: + installed = result[1].split()[1] + candidate = result[2].split()[1] + if installed == '(none)': + installed = False + if candidate == '(none)': + candidate = False + return installed, candidate + + log('ShellHandlerApt: error during version check') + return False, False + + def _update_cache(self): + """ Update apt cache + + :return: success of updating apt cache + :rtype: bool + """ + _cmd = 'apt-get update' + try: + if self.sudo: + _ = check_output('echo \'%s\' | sudo -S %s' % + (self._get_password(), _cmd), shell=True) + else: + _ = check_output(_cmd.split()) + except Exception as error: # pylint: disable=broad-except + log('Exception while executing shell command %s: %s' % (_cmd, error)) + return False + + return True + + def upgrade_package(self, package): + """ Upgrade apt package + + :param package: package to upgrade + :type package: str + :return: success of apt package upgrade + :rtype: bool + """ + _cmd = 'apt-get install -y ' + package + try: + if self.sudo: + _ = check_output('echo \'%s\' | sudo -S %s' % + (self._get_password(), _cmd), shell=True) + else: + _ = check_output(_cmd.split()) + log('Upgrade successful') + except Exception as error: # pylint: disable=broad-except + log('Exception while executing shell command %s: %s' % (_cmd, error)) + return False + + return True + + def upgrade_system(self): + """ Upgrade system + + :return: success of system upgrade + :rtype: bool + """ + _cmd = 'apt-get upgrade -y' + try: + log('Upgrading system') + if self.sudo: + _ = check_output('echo \'%s\' | sudo -S %s' % + (self._get_password(), _cmd), shell=True) + else: + _ = check_output(_cmd.split()) + except Exception as error: # pylint: disable=broad-except + log('Exception while executing shell command %s: %s' % (_cmd, error)) + return False + + return True diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/versions.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/versions.py new file mode 100644 index 0000000000..1bd9ba4f96 --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/versions.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +from .common import log + + +def compare_version(version_installed, version_list): + """ Compare the installed version against the provided version list + + :param version_installed: currently installed version + :type version_installed: dict + :param version_list: provided versions to compare against + :type version_list: dict + :return: old, current, available, and stable versions + :rtype: bool / 'stable', dict, dict, dict + """ + # Create separate version lists + version_list_stable = version_list['releases']['stable'] + version_list_rc = version_list['releases']['releasecandidate'] + version_list_beta = version_list['releases']['beta'] + version_list_alpha = version_list['releases']['alpha'] + # version_list_prealpha = version_list['releases']['prealpha'] + + stable_version = version_list_stable[0] + rc_version = version_list_rc[0] + beta_version = version_list_beta[0] + alpha_version = version_list_alpha[0] + + log('Version installed %s' % version_installed) + + # Check to upgrade to newest available stable version + # check on smaller major version. Smaller version than available always notify + + # check for stable versions + old_version, version_available = _check_for_stable_version(version_installed, stable_version) + + if not old_version: + # Already skipped a possible newer stable build. Let's continue with non stable builds. + # Check also 'old version' hasn't been set to 'stable' or true by previous checks because + # if so, those part need to be skipped + old_version, version_available = _check_for_rc_version(version_installed, + rc_version, beta_version) + + if not old_version: + # check for beta builds + old_version, version_available = _check_for_beta_version(version_installed, beta_version) + + if not old_version: + # check for alpha builds + old_version, version_available = _check_for_alpha_version(version_installed, alpha_version) + + return old_version, version_installed, version_available, stable_version + + +def _check_for_stable_version(version_installed, stable_version): + """ Compare the installed version against the latest stable version + + :param version_installed: currently installed version + :type version_installed: dict + :param stable_version: latest stable version + :type stable_version: dict + :return: whether using an old version, and available version if newer stable version available + :rtype: bool / 'stable', dict + """ + # check if installed major version is smaller than available major stable + # here we don't care if running non stable + old_version = False + version_available = {} + + if version_installed['major'] < int(stable_version['major']): + version_available = stable_version + old_version = 'stable' + log('Version available %s' % stable_version) + log('You are running an older version') + + # check if installed major version is equal than available major stable + # however also check on minor version and still don't care about non stable + elif version_installed['major'] == int(stable_version['major']): + if version_installed['minor'] < int(stable_version['minor']): + version_available = stable_version + old_version = 'stable' + log('Version available %s' % stable_version) + log('You are running an older minor version') + # check for <= minor !stable + elif version_installed['tag'] != 'stable' and \ + version_installed['minor'] <= int(stable_version['minor']): + version_available = stable_version + old_version = True + log('Version available %s' % stable_version) + log('You are running an older non stable minor version') + else: + log('Version available %s' % stable_version) + log('There is no newer stable available') + + return old_version, version_available + + +def _check_for_rc_version(version_installed, rc_version, beta_version): + """ Compare the installed version against the latest RC version + + :param version_installed: currently installed version + :type version_installed: dict + :param rc_version: latest rc version + :type rc_version: dict + :param beta_version: latest beta version + :type beta_version: dict + :return: whether using an old version, and available version if newer rc version available + :rtype: bool, dict + """ + old_version = False + version_available = {} + # check for RC builds + if version_installed['tag'] in ['releasecandidate']: + # check if you are using a RC build lower than current available RC + # then check if you are using a beta/alpha lower than current available RC + # 14.0rc3 is newer than: 14.0rc1, 14.0b9, 14.0a15 + if version_installed['major'] <= int(rc_version['major']): + if version_installed['minor'] <= int(rc_version['minor']): + if version_installed.get('tagversion', '') < rc_version['tagversion']: + version_available = rc_version + old_version = True + log('Version available %s' % rc_version) + log('You are running an older RC version') + # now check if installed !=rc + elif version_installed['tag'] in ['beta', 'alpha', 'prealpha']: + if version_installed['major'] <= int(rc_version['major']): + if version_installed['minor'] <= int(beta_version['minor']): + version_available = rc_version + old_version = True + log('Version available %s' % rc_version) + log('You are running an older non RC version') + + return old_version, version_available + + +def _check_for_beta_version(version_installed, beta_version): + """ Compare the installed version against the latest beta version + + :param version_installed: currently installed version + :type version_installed: dict + :param beta_version: latest beta version + :type beta_version: dict + :return: whether using an old version, and available version if newer beta version available + :rtype: bool, dict + """ + old_version = False + version_available = {} + # check for beta builds + if not old_version and version_installed['tag'] == 'beta': + # check if you are using a RC build lower than current available RC + # then check if you are using a beta/alpha lower than current available RC + # 14.0b3 is newer than: 14.0b1, 14.0a15 + if version_installed['major'] <= int(beta_version['major']): + if version_installed['minor'] <= int(beta_version['minor']): + if version_installed.get('tagversion', '') < beta_version['tagversion']: + version_available = beta_version + old_version = True + log('Version available %s' % beta_version) + log('You are running an older beta version') + # now check if installed !=beta + elif not old_version and version_installed['tag'] in ['alpha', 'prealpha']: + if version_installed['major'] <= int(beta_version['major']): + if version_installed['minor'] <= int(beta_version['minor']): + version_available = beta_version + old_version = True + log('Version available %s' % beta_version) + log('You are running an older non beta version') + + return old_version, version_available + + +def _check_for_alpha_version(version_installed, alpha_version): + """ Compare the installed version against the latest alpha version + + :param version_installed: currently installed version + :type version_installed: dict + :param alpha_version: latest alpha version + :type alpha_version: dict + :return: whether using an old version, and available version if newer alpha version available + :rtype: bool, dict + """ + old_version = False + version_available = {} + # check for alpha builds and older + if version_installed['tag'] == 'alpha': + # check if you are using a RC build lower than current available RC + # then check if you are using a beta/alpha lower than current available RC + # 14.0a3 is newer than: 14.0a1 or pre-alpha + if version_installed['major'] <= int(alpha_version['major']): + if version_installed['minor'] <= int(alpha_version['minor']): + if version_installed.get('tagversion', '') < alpha_version['tagversion']: + version_available = alpha_version + old_version = True + log('Version available %s' % alpha_version) + log('You are running an older alpha version') + # now check if installed !=alpha + elif version_installed['tag'] in ['prealpha']: + if version_installed['major'] <= int(alpha_version['major']): + if version_installed['minor'] <= int(alpha_version['minor']): + version_available = alpha_version + old_version = True + log('Version available %s' % alpha_version) + log('You are running an older non alpha version') + + return old_version, version_available diff --git a/addons/service.xbmc.versioncheck/resources/lib/version_check/viewer.py b/addons/service.xbmc.versioncheck/resources/lib/version_check/viewer.py new file mode 100644 index 0000000000..9f2b00a34f --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/lib/version_check/viewer.py @@ -0,0 +1,159 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" + + Copyright (C) 2011-2013 Martijn Kaijser + Copyright (C) 2013-2014 Team-XBMC + Copyright (C) 2014-2019 Team Kodi + + This file is part of service.xbmc.versioncheck + + SPDX-License-Identifier: GPL-3.0-or-later + See LICENSES/GPL-3.0-or-later.txt for more information. + +""" + +from contextlib import closing +import os +import sys + +import xbmc # pylint: disable=import-error +import xbmcaddon # pylint: disable=import-error +import xbmcgui # pylint: disable=import-error +import xbmcvfs # pylint: disable=import-error + +_ADDON = xbmcaddon.Addon('service.xbmc.versioncheck') +_ADDON_NAME = _ADDON.getAddonInfo('name') +if sys.version_info[0] >= 3: + _ADDON_PATH = _ADDON.getAddonInfo('path') +else: + _ADDON_PATH = _ADDON.getAddonInfo('path').decode('utf-8') +_ICON = _ADDON.getAddonInfo('icon') + + +class Viewer: + """ Show user a text viewer (WINDOW_DIALOG_TEXT_VIEWER) + Include the text file for the viewers body in the resources/ directory + + usage: + script_path = os.path.join(_ADDON_PATH, 'resources', 'lib', 'version_check', 'viewer.py') + xbmc.executebuiltin('RunScript(%s,%s,%s)' % (script_path, 'Heading', 'notice.txt')) + + :param heading: text viewer heading + :type heading: str + :param filename: filename to use for text viewers body + :type filename: str + """ + WINDOW = 10147 + CONTROL_LABEL = 1 + CONTROL_TEXTBOX = 5 + + def __init__(self, heading, filename): + self.heading = heading + self.filename = filename + # activate the text viewer window + xbmc.executebuiltin('ActivateWindow(%d)' % (self.WINDOW,)) + # get window + self.window = xbmcgui.Window(self.WINDOW) + # give window time to initialize + xbmc.sleep(100) + # set controls + self.set_controls() + + def set_controls(self): + """ Set the window controls + """ + # get text viewer body text + text = self.get_text() + # set heading + self.window.getControl(self.CONTROL_LABEL).setLabel('%s : %s' % (_ADDON_NAME, + self.heading,)) + # set text + self.window.getControl(self.CONTROL_TEXTBOX).setText(text) + xbmc.sleep(2000) + + def get_text(self): + """ Get the text viewers body text from self.filename + + :return: contents of self.filename + :rtype: str + """ + try: + return self.read_file(self.filename) + except Exception as error: # pylint: disable=broad-except + xbmc.log(_ADDON_NAME + ': ' + str(error), xbmc.LOGERROR) + return '' + + @staticmethod + def read_file(filename): + """ Read the contents of the provided file, from + os.path.join(_ADDON_PATH, 'resources', filename) + + :param filename: name of file to read + :type filename: str + :return: contents of the provided file + :rtype: str + """ + filename = os.path.join(_ADDON_PATH, 'resources', filename) + with closing(xbmcvfs.File(filename)) as open_file: + contents = open_file.read() + return contents + + +class WebBrowser: + """ Display url using the default browser + + usage: + script_path = os.path.join(_ADDON_PATH, 'resources', 'lib', 'version_check', 'viewer.py') + xbmc.executebuiltin('RunScript(%s,%s,%s)' % (script_path, 'webbrowser', 'https://kodi.tv/')) + + :param url: url to open + :type url: str + """ + + def __init__(self, url): + self.url = url + try: + # notify user + self.notification(_ADDON_NAME, self.url) + xbmc.sleep(100) + # launch url + self.launch_url() + except Exception as error: # pylint: disable=broad-except + xbmc.log(_ADDON_NAME + ': ' + str(error), xbmc.LOGERROR) + + @staticmethod + def notification(heading, message, icon=None, time=15000, sound=True): + """ Create a notification + + :param heading: notification heading + :type heading: str + :param message: notification message + :type message: str + :param icon: path and filename for the notification icon + :type icon: str + :param time: time to display notification + :type time: int + :param sound: is notification audible + :type sound: bool + """ + if not icon: + icon = _ICON + xbmcgui.Dialog().notification(heading, message, icon, time, sound) + + def launch_url(self): + """ Open self.url in the default web browser + """ + import webbrowser # pylint: disable=import-outside-toplevel + webbrowser.open(self.url) + + +if __name__ == '__main__': + try: + if sys.argv[1] == 'webbrowser': + WebBrowser(sys.argv[2]) + else: + Viewer(sys.argv[1], sys.argv[2]) + except Exception as err: # pylint: disable=broad-except + xbmc.log(_ADDON_NAME + ': ' + str(err), xbmc.LOGERROR) diff --git a/addons/service.xbmc.versioncheck/resources/polkit/10-allow-update.pkla b/addons/service.xbmc.versioncheck/resources/polkit/10-allow-update.pkla index a5135348ef..2316dffc00 100644 --- a/addons/service.xbmc.versioncheck/resources/polkit/10-allow-update.pkla +++ b/addons/service.xbmc.versioncheck/resources/polkit/10-allow-update.pkla @@ -1,5 +1,5 @@ [Untrusted Upgrade] -Identity=unix-user:xbmc +Identity=unix-user:kodi Action=org.debian.apt.upgrade-packages;org.debian.apt.update-cache ResultAny=no ResultInactive=yes diff --git a/addons/service.xbmc.versioncheck/resources/polkit/README b/addons/service.xbmc.versioncheck/resources/polkit/README index c3a1a45134..77920c0d69 100644 --- a/addons/service.xbmc.versioncheck/resources/polkit/README +++ b/addons/service.xbmc.versioncheck/resources/polkit/README @@ -1,10 +1,11 @@ -If you run xbmc standalone and/or do want to have password less upgrades, copy the file 10-allow-update.conf to /etc/polkit-1/localauthority/50-local.d/ +If you run Kodi/XBMC standalone and/or do want to have password less upgrades, copy the file +10-allow-update.conf to /etc/polkit-1/localauthority/50-local.d/ -Make sure to adjust the username if it is different from "xbmc" +Make sure to adjust the username if it is different from "kodi" -For this to work, you must have python-apt and python-aptdaemon installed: +For this to work, you must have python-apt and python-aptdaemon installed: sudo apt-get install python-apt python-aptdaemon -If those packages are not installed, this script will fallback to calling apt directly and ask you for your password. - +If those packages are not installed, this script will fallback to calling apt directly and ask you +for your password. diff --git a/addons/service.xbmc.versioncheck/resources/settings.xml b/addons/service.xbmc.versioncheck/resources/settings.xml index ad7824ccfb..e6f36dc3cc 100644 --- a/addons/service.xbmc.versioncheck/resources/settings.xml +++ b/addons/service.xbmc.versioncheck/resources/settings.xml @@ -1,8 +1,24 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<settings> - <category label="32020"> - <setting label="32021" type="bool" id="versioncheck_enable" default="true"/> - <setting label="32023" type="bool" id="upgrade_system" default="false"/> - <setting label="32024" type="bool" id="upgrade_apt" default="false"/> - </category> +<?xml version="1.0" ?> +<settings version="1"> + <section id="service.xbmc.versioncheck"> + <category help="" id="general" label="32020"> + <group id="1"> + <setting help="" id="versioncheck_enable" label="32021" type="boolean"> + <level>0</level> + <default>true</default> + <control type="toggle"/> + </setting> + <setting help="" id="upgrade_system" label="32023" type="boolean"> + <level>0</level> + <default>false</default> + <control type="toggle"/> + </setting> + <setting help="" id="upgrade_apt" label="32024" type="boolean"> + <level>0</level> + <default>false</default> + <control type="toggle"/> + </setting> + </group> + </category> + </section> </settings> diff --git a/addons/service.xbmc.versioncheck/resources/versions.schema.txt b/addons/service.xbmc.versioncheck/resources/versions.schema.txt new file mode 100644 index 0000000000..dcfdfd03bc --- /dev/null +++ b/addons/service.xbmc.versioncheck/resources/versions.schema.txt @@ -0,0 +1,214 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "releases": { + "type": "object", + "properties": { + "stable": { + "type": "array", + "items": { + "type": "object", + "properties": { + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "tagversion": { + "type": "string" + }, + "revision": { + "type": "string" + }, + "extrainfo": { + "type": "string" + }, + "addon_support": { + "type": "string" + } + }, + "required": [ + "addon_support", + "extrainfo", + "major", + "minor", + "revision", + "tag", + "tagversion" + ] + } + }, + "releasecandidate": { + "type": "array", + "items": { + "type": "object", + "properties": { + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "tagversion": { + "type": "string" + }, + "revision": { + "type": "string" + }, + "extrainfo": { + "type": "string" + }, + "addon_support": { + "type": "string" + } + }, + "required": [ + "addon_support", + "extrainfo", + "major", + "minor", + "revision", + "tag", + "tagversion" + ] + } + }, + "beta": { + "type": "array", + "items": { + "type": "object", + "properties": { + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "tagversion": { + "type": "string" + }, + "revision": { + "type": "string" + }, + "addon_support": { + "type": "string" + }, + "extrainfo": { + "type": "string" + } + }, + "required": [ + "addon_support", + "extrainfo", + "major", + "minor", + "revision", + "tag", + "tagversion" + ] + } + }, + "alpha": { + "type": "array", + "items": { + "type": "object", + "properties": { + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "tagversion": { + "type": "string" + }, + "revision": { + "type": "string" + }, + "addon_support": { + "type": "string" + }, + "extrainfo": { + "type": "string" + } + }, + "required": [ + "addon_support", + "extrainfo", + "major", + "minor", + "revision", + "tag", + "tagversion" + ] + } + }, + "prealpha": { + "type": "array", + "items": { + "type": "object", + "properties": { + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "tagversion": { + "type": "string" + }, + "revision": { + "type": "string" + }, + "extrainfo": { + "type": "string" + }, + "addon_support": { + "type": "string" + } + }, + "required": [ + "addon_support", + "extrainfo", + "major", + "minor", + "revision", + "tag", + "tagversion" + ] + } + } + }, + "required": [ + "alpha", + "beta", + "releasecandidate", + "stable" + ] + } + }, + "required": [ + "jsonrpc", + "releases" + ] +} diff --git a/addons/service.xbmc.versioncheck/resources/versions.txt b/addons/service.xbmc.versioncheck/resources/versions.txt index cf38def2e8..2d6e2d9f1e 100644 --- a/addons/service.xbmc.versioncheck/resources/versions.txt +++ b/addons/service.xbmc.versioncheck/resources/versions.txt @@ -3,6 +3,96 @@ "releases": { "stable": [ { + "major": "18", + "minor": "9", + "tag": "stable", + "tagversion":"", + "revision": "20201023-0655c2c718", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "8", + "tag": "stable", + "tagversion":"", + "revision": "20200727-45686bddb1", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "7", + "tag": "stable", + "tagversion":"", + "revision": "20200520-f14f7a8", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "6", + "tag": "stable", + "tagversion":"", + "revision": "20200229-8e967df", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "5", + "tag": "stable", + "tagversion":"", + "revision": "20191116-37f51f6", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "4", + "tag": "stable", + "tagversion":"", + "revision": "20190831-3ade758", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "3", + "tag": "stable", + "tagversion":"", + "revision": "20190619-89472b7", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "2", + "tag": "stable", + "tagversion":"", + "revision": "20190422-f264356", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "1", + "tag": "stable", + "tagversion":"", + "revision": "20190217-8cfdc89", + "extrainfo": "final", + "addon_support": "yes" + }, + { + "major": "18", + "minor": "0", + "tag": "stable", + "tagversion":"", + "revision": "20190128-d81c34c", + "extrainfo": "final", + "addon_support": "yes" + }, + { "major": "17", "minor": "6", "tag": "stable", @@ -444,6 +534,7 @@ "tag": "beta", "tagversion":"5", "revision": "20181103-920e823249", + "extrainfo": "beta5", "addon_support": "yes" }, { @@ -452,6 +543,7 @@ "tag": "beta", "tagversion":"4", "revision": "20181023-c77874c5bf", + "extrainfo": "beta4", "addon_support": "yes" }, { @@ -460,6 +552,7 @@ "tag": "beta", "tagversion":"3", "revision": "20181002-c2e1b316f5", + "extrainfo": "beta3", "addon_support": "yes" }, { @@ -468,6 +561,7 @@ "tag": "beta", "tagversion":"2", "revision": "20180909-7868a27c6a", + "extrainfo": "beta2", "addon_support": "yes" }, { @@ -476,6 +570,7 @@ "tag": "beta", "tagversion":"1", "revision": "20180826-f21b477993", + "extrainfo": "beta1", "addon_support": "yes" }, { @@ -484,6 +579,7 @@ "tag": "beta", "tagversion":"6", "revision": "20161130-654f1b7", + "extrainfo": "beta6", "addon_support": "yes" }, { @@ -492,6 +588,7 @@ "tag": "beta", "tagversion":"5", "revision": "20160110-9d9a153", + "extrainfo": "beta5", "addon_support": "yes" }, { @@ -500,6 +597,7 @@ "tag": "beta", "tagversion":"4", "revision": "20151213-a724f29", + "extrainfo": "beta4", "addon_support": "yes" }, { @@ -508,6 +606,7 @@ "tag": "beta", "tagversion":"3", "revision": "20151205-85a0a13", + "extrainfo": "beta3", "addon_support": "yes" }, { @@ -516,6 +615,7 @@ "tag": "beta", "tagversion":"2", "revision": "20151121-98e0275", + "extrainfo": "beta2", "addon_support": "yes" }, { @@ -524,6 +624,7 @@ "tag": "beta", "tagversion":"1", "revision": "20151113-9c7322e", + "extrainfo": "beta1", "addon_support": "yes" }, { @@ -532,6 +633,7 @@ "tag": "beta", "tagversion":"2", "revision": "20150614-daedd5f", + "extrainfo": "beta2", "addon_support": "yes" }, { @@ -540,6 +642,7 @@ "tag": "beta", "tagversion":"1", "revision": "20150501-d1a2c33", + "extrainfo": "beta1", "addon_support": "yes" }, { @@ -548,6 +651,7 @@ "tag": "beta", "tagversion":"5", "revision": "20141125-4465fbf", + "extrainfo": "beta5", "addon_support": "yes" }, { @@ -556,6 +660,7 @@ "tag": "beta", "tagversion":"4", "revision": "20141124-ec361ca", + "extrainfo": "beta4", "addon_support": "yes" }, { @@ -564,6 +669,7 @@ "tag": "beta", "tagversion":"3", "revision": "20141116-88a9a44", + "extrainfo": "beta3", "addon_support": "yes" }, { @@ -572,6 +678,7 @@ "tag": "beta", "tagversion":"2", "revision": "20141108-2d88a9a", + "extrainfo": "beta2", "addon_support": "yes" }, { @@ -580,6 +687,7 @@ "tag": "beta", "tagversion":"1", "revision": "20141103-d6947be", + "extrainfo": "beta1", "addon_support": "yes" }, { @@ -729,11 +837,30 @@ ], "alpha": [ { + "major": "19", + "minor": "0", + "tag": "alpha", + "tagversion":"2", + "revision": "20201005-54be31bc5c", + "extrainfo": "alpha2", + "addon_support": "yes" + }, + { + "major": "19", + "minor": "0", + "tag": "alpha", + "tagversion":"1", + "revision": "20200726-db40b2ade4", + "extrainfo": "alpha1", + "addon_support": "yes" + }, + { "major": "17", "minor": "0", "tag": "alpha", "tagversion":"2", "revision": "", + "extrainfo": "alpha2", "addon_support": "yes" }, { @@ -742,6 +869,7 @@ "tag": "alpha", "tagversion":"1", "revision": "", + "extrainfo": "alpha1", "addon_support": "yes" }, { @@ -750,6 +878,7 @@ "tag": "alpha", "tagversion":"3", "revision": "20151001-ca8d08c", + "extrainfo": "alpha3", "addon_support": "yes" }, { @@ -758,6 +887,7 @@ "tag": "alpha", "tagversion":"2", "revision": "20150831-b4afc20", + "extrainfo": "alpha2", "addon_support": "yes" }, { @@ -766,6 +896,7 @@ "tag": "alpha", "tagversion":"1", "revision": "20150801-c5f806e", + "extrainfo": "alpha1", "addon_support": "yes" }, { @@ -774,6 +905,7 @@ "tag": "alpha", "tagversion":"2", "revision": "20150331-32c1f53", + "extrainfo": "alpha2", "addon_support": "yes" }, { @@ -782,6 +914,7 @@ "tag": "alpha", "tagversion":"1", "revision": "20150228-5dc1a55", + "extrainfo": "alpha1", "addon_support": "yes" }, { @@ -790,6 +923,7 @@ "tag": "alpha", "tagversion":"5", "revision": "20141002-d2a4ee9", + "extrainfo": "alpha5", "addon_support": "yes" }, { diff --git a/addons/service.xbmc.versioncheck/service.py b/addons/service.xbmc.versioncheck/service.py deleted file mode 100644 index 038589f7a8..0000000000 --- a/addons/service.xbmc.versioncheck/service.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Team-XBMC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -import platform -import xbmc -import xbmcgui -import lib.common -from lib.common import log, dialog_yesno, localise, waitForAbort -from lib.common import upgrade_message as _upgrademessage -from lib.common import upgrade_message2 as _upgrademessage2 - -ADDON = lib.common.ADDON -ADDONVERSION = lib.common.ADDONVERSION -ADDONNAME = lib.common.ADDONNAME -ADDONPATH = lib.common.ADDONPATH -ICON = lib.common.ICON -oldversion = False - -monitor = xbmc.Monitor() - -class Main: - def __init__(self): - linux = False - packages = [] - - if waitForAbort(5): - sys.exit(0) - - if xbmc.getCondVisibility('System.Platform.Linux') and ADDON.getSetting("upgrade_apt") == 'true': - packages = ['kodi'] - _versionchecklinux(packages) - else: - oldversion, version_installed, version_available, version_stable = _versioncheck() - if oldversion: - _upgrademessage2( version_installed, version_available, version_stable, oldversion, False) - -def _versioncheck(): - # initial vars - from lib.jsoninterface import get_installedversion, get_versionfilelist - from lib.versions import compare_version - # retrieve versionlists from supplied version file - versionlist = get_versionfilelist() - # retrieve version installed - version_installed = get_installedversion() - # compare installed and available - oldversion, version_installed, version_available, version_stable = compare_version(version_installed, versionlist) - return oldversion, version_installed, version_available, version_stable - - -def _versionchecklinux(packages): - if platform.dist()[0].lower() in ['ubuntu', 'debian', 'linuxmint']: - handler = False - result = False - try: - # try aptdaemon first - from lib.aptdaemonhandler import AptdaemonHandler - handler = AptdaemonHandler() - except: - # fallback to shell - # since we need the user password, ask to check for new version first - from lib.shellhandlerapt import ShellHandlerApt - sudo = True - handler = ShellHandlerApt(sudo) - if dialog_yesno(32015): - pass - elif dialog_yesno(32009, 32010): - log("disabling addon by user request") - ADDON.setSetting("versioncheck_enable", 'false') - return - - if handler: - if handler.check_upgrade_available(packages[0]): - if _upgrademessage(32012, oldversion, True): - if ADDON.getSetting("upgrade_system") == "false": - result = handler.upgrade_package(packages[0]) - else: - result = handler.upgrade_system() - if result: - from lib.common import message_upgrade_success, message_restart - message_upgrade_success() - message_restart() - else: - log("Error during upgrade") - else: - log("Error: no handler found") - else: - log("Unsupported platform %s" %platform.dist()[0]) - sys.exit(0) - -# Python cryptography < 1.7 (still shipped with Ubuntu 16.04) has issues with -# pyOpenSSL integration, leading to all sorts of weird bugs - check here to save -# on some troubleshooting. This check may be removed in the future (when switching -# to Python3?) -# See https://github.com/pyca/pyopenssl/issues/542 -def _checkcryptography(): - ver = None - try: - import cryptography - ver = cryptography.__version__ - except: - # If the module is not found - no problem - return - - ver_parts = list(map(int, ver.split('.'))) - if len(ver_parts) < 2 or ver_parts[0] < 1 or (ver_parts[0] == 1 and ver_parts[1] < 7): - log('Python cryptography module version %s is too old, at least version 1.7 needed' % ver) - xbmcgui.Dialog().ok(ADDONNAME, localise(32040) % ver, localise(32041), localise(32042)) - -if (__name__ == "__main__"): - _checkcryptography() - if ADDON.getSetting("versioncheck_enable") == "false": - log("Disabled") - else: - log('Version %s started' % ADDONVERSION) - Main() diff --git a/addons/skin.estuary/xml/Custom_1109_TopBarOverlay.xml b/addons/skin.estuary/xml/Custom_1109_TopBarOverlay.xml index 4b9bcfc3be..3dabea46da 100644 --- a/addons/skin.estuary/xml/Custom_1109_TopBarOverlay.xml +++ b/addons/skin.estuary/xml/Custom_1109_TopBarOverlay.xml @@ -7,7 +7,7 @@ <zorder>0</zorder> <controls> <control type="group"> - <visible>![Player.ShowInfo | Window.IsActive(fullscreeninfo) | Player.ShowTime | Window.IsActive(videoosd) | Window.IsActive(musicosd) | Window.IsActive(playerprocessinfo) | !String.IsEmpty(Player.SeekNumeric) | !String.IsEmpty(PVR.ChannelNumberInput) | Window.IsActive(pvrosdchannels) | Window.IsActive(pvrchannelguide)] + [Player.Seeking | Player.DisplayAfterSeek | Player.Forwarding | Player.Rewinding | Player.Paused + !Window.IsActive(visualisation)]</visible> + <visible>![Player.ShowInfo | Window.IsActive(fullscreeninfo) | Player.ShowTime | Window.IsActive(videoosd) | Window.IsActive(musicosd) | Window.IsActive(playerprocessinfo) | !String.IsEmpty(PVR.ChannelNumberInput) | Window.IsActive(pvrosdchannels) | Window.IsActive(pvrchannelguide)] + [!String.IsEmpty(Player.SeekNumeric) | Player.Seeking | Player.DisplayAfterSeek | Player.Forwarding | Player.Rewinding | Player.Paused]</visible> <animation effect="fade" start="0" end="100" time="300">VisibleChange</animation> <animation effect="slide" start="0,0" end="0,-80" time="300" condition="Player.Paused + System.IdleTime(5)">Conditional</animation> <control type="image"> @@ -148,7 +148,7 @@ <control type="group"> <animation effect="slide" end="0,-90" time="300" tween="sine" easing="inout" condition="$EXP[infodialog_active]">conditional</animation> <animation effect="slide" start="0,-200" end="0,0" time="300" tween="cubic" easing="out">VisibleChange</animation> - <visible>Player.ShowInfo | Window.IsActive(fullscreeninfo) | Player.ShowTime | Window.IsActive(videoosd) | Window.IsActive(musicosd) | Window.IsActive(playerprocessinfo) | !String.IsEmpty(Player.SeekNumeric) | !String.IsEmpty(PVR.ChannelNumberInput) | Window.IsActive(pvrosdchannels) | Window.IsActive(pvrchannelguide) | ![Player.Seeking | Player.DisplayAfterSeek | Player.Forwarding | Player.Rewinding | Player.Paused + !Window.IsActive(visualisation)]</visible> + <visible>Player.ShowInfo | Window.IsActive(fullscreeninfo) | Player.ShowTime | Window.IsActive(videoosd) | Window.IsActive(musicosd) | Window.IsActive(playerprocessinfo) | !String.IsEmpty(PVR.ChannelNumberInput) | Window.IsActive(pvrosdchannels) | Window.IsActive(pvrchannelguide) + ![Player.Seeking | Player.DisplayAfterSeek | Player.Forwarding | Player.Rewinding | Player.Paused]</visible> <depth>DepthBars</depth> <control type="image"> <left>0</left> diff --git a/addons/skin.estuary/xml/DialogSeekBar.xml b/addons/skin.estuary/xml/DialogSeekBar.xml index 213317987b..eb96b586e8 100644 --- a/addons/skin.estuary/xml/DialogSeekBar.xml +++ b/addons/skin.estuary/xml/DialogSeekBar.xml @@ -10,7 +10,7 @@ <include>PVRChannelNumberInput</include> <control type="group"> <animation effect="slide" start="0,200" end="0,0" time="300" tween="cubic" easing="out">VisibleChange</animation> - <visible>Player.ShowInfo | Window.IsActive(fullscreeninfo) | Player.ShowTime | Window.IsActive(videoosd) | Window.IsActive(musicosd) | Window.IsActive(playerprocessinfo) | !String.IsEmpty(Player.SeekNumeric) | !String.IsEmpty(PVR.ChannelNumberInput) | Window.IsActive(pvrosdchannels) | Window.IsActive(pvrchannelguide) | ![Player.Seeking | Player.DisplayAfterSeek | Player.Forwarding | Player.Rewinding | Player.Paused + !Window.IsActive(visualisation)]</visible> + <visible>Player.ShowInfo | Window.IsActive(fullscreeninfo) | Player.ShowTime | Window.IsActive(videoosd) | Window.IsActive(musicosd) | Window.IsActive(playerprocessinfo) | !String.IsEmpty(PVR.ChannelNumberInput) | Window.IsActive(pvrosdchannels) | Window.IsActive(pvrchannelguide) | ![!String.IsEmpty(Player.SeekNumeric) | Player.Seeking | Player.DisplayAfterSeek | Player.Forwarding | Player.Rewinding | Player.Paused]</visible> <visible>!Player.HasGame</visible> <bottom>0</bottom> <height>190</height> @@ -351,8 +351,9 @@ <control type="label"> <left>240</left> <top>180</top> + <right>20</right> <height>25</height> - <label>[COLOR button_focus]$LOCALIZE[19031]:[/COLOR] $INFO[VideoPlayer.NextStartTime] - $INFO[VideoPlayer.NextEndTime]: $INFO[VideoPlayer.NextTitle]</label> + <label>$VAR[OSDNextLabelVar]</label> <visible>VideoPlayer.HasEpg + !RDS.HasRadioText</visible> </control> <control type="label"> @@ -405,7 +406,7 @@ </control> <control type="label"> <height>50</height> - <label>[COLOR button_focus]$LOCALIZE[19031]: [/COLOR]$INFO[VideoPlayer.offset(1).TVShowtitle, , - ]$INFO[VideoPlayer.offset(1).Season,S,]$INFO[VideoPlayer.offset(1).Episode,E, - ]$INFO[VideoPlayer.offset(1).Title]</label> + <label>$VAR[OSDNextLabelVar]</label> <visible>Integer.IsGreater(Playlist.Length(video),1)</visible> </control> </control> diff --git a/addons/skin.estuary/xml/Includes.xml b/addons/skin.estuary/xml/Includes.xml index 2414db4180..cf87b34c5f 100644 --- a/addons/skin.estuary/xml/Includes.xml +++ b/addons/skin.estuary/xml/Includes.xml @@ -860,7 +860,7 @@ </control> <control type="label" id="7700"> <label>$VAR[NowPlayingSublabelVar]</label> - <left>-45</left> + <left>-44</left> <top>44</top> <font>font12</font> <textcolor>grey</textcolor> @@ -868,6 +868,7 @@ <height>25</height> <width>630</width> <align>right</align> + <scroll>true</scroll> </control> </control> <control type="group"> diff --git a/addons/skin.estuary/xml/Includes_Home.xml b/addons/skin.estuary/xml/Includes_Home.xml index 8abe7844a2..4164bcf100 100644 --- a/addons/skin.estuary/xml/Includes_Home.xml +++ b/addons/skin.estuary/xml/Includes_Home.xml @@ -21,7 +21,7 @@ <label>$PARAM[label]</label> <shadowcolor>text_shadow</shadowcolor> <visible>$PARAM[visible]</visible> - <visible>Integer.IsGreater(Container($PARAM[list_id]).NumItems,$PARAM[item_treshold]) | Container($PARAM[list_id]).IsUpdating</visible> + <visible>Integer.IsGreater(Container($PARAM[list_id]).NumItems,$PARAM[item_treshold]) | [Container($PARAM[list_id]).IsUpdating + Integer.IsEqual(Container($PARAM[list_id]).NumItems,0)]</visible> </control> </definition> </include> @@ -453,7 +453,6 @@ <include content="BusyListSpinner"> <param name="list_id" value="$PARAM[list_id]"/> <param name="posy" value="200"/> - <param name="item_treshold" value="$PARAM[item_treshold]"/> </include> <control type="panel" id="$PARAM[list_id]"> <left>0</left> @@ -463,7 +462,7 @@ <include content="WidgetListCommon"> <param name="list_id" value="$PARAM[list_id]"/> </include> - <visible>Integer.IsGreater(Container($PARAM[list_id]).NumItems,$PARAM[item_treshold]) | Container($PARAM[list_id]).IsUpdating</visible> + <visible>Integer.IsGreater(Container($PARAM[list_id]).NumItems,$PARAM[item_treshold]) | [Container($PARAM[list_id]).IsUpdating + Integer.IsEqual(Container($PARAM[list_id]).NumItems,0)]</visible> <itemlayout width="310" height="500"> <control type="group"> <left>70</left> @@ -944,12 +943,11 @@ <include name="BusyListSpinner"> <param name="posy">160</param> <param name="visible">true</param> - <param name="item_treshold">0</param> <definition> <control type="group" id="$PARAM[list_id]599"> <height>160</height> <left>180</left> - <visible>Container($PARAM[list_id]).IsUpdating + !Integer.IsGreater(Container($PARAM[list_id]).NumItems,$PARAM[item_treshold])</visible> + <visible>Container($PARAM[list_id]).IsUpdating + !Integer.IsGreater(Container($PARAM[list_id]).NumItems,0)</visible> <visible>$PARAM[visible]</visible> <control type="image"> <top>$PARAM[posy]</top> diff --git a/addons/skin.estuary/xml/Includes_MusicInfo.xml b/addons/skin.estuary/xml/Includes_MusicInfo.xml index 1b893d064c..5616dd23f2 100644 --- a/addons/skin.estuary/xml/Includes_MusicInfo.xml +++ b/addons/skin.estuary/xml/Includes_MusicInfo.xml @@ -196,6 +196,11 @@ <visible>!String.IsEmpty(ListItem.TrackNumber)</visible> </item> <item> + <label>$LOCALIZE[427]:</label> + <label2>$INFO[ListItem.DiscNumber]$INFO[ListItem.DiscTitle, - ]</label2> + <visible>Integer.IsGreater(ListItem.TotalDiscs,1)</visible> + </item> + <item> <label>$LOCALIZE[38080]:</label> <label2>$INFO[ListItem.Bpm]</label2> <visible>!String.IsEmpty(ListItem.Bpm)</visible> diff --git a/addons/skin.estuary/xml/MusicVisualisation.xml b/addons/skin.estuary/xml/MusicVisualisation.xml index 6f31bc9d76..e19dc3d48f 100644 --- a/addons/skin.estuary/xml/MusicVisualisation.xml +++ b/addons/skin.estuary/xml/MusicVisualisation.xml @@ -138,9 +138,10 @@ <width>1450</width> <height>40</height> <aligny>center</aligny> - <label>$INFO[MusicPlayer.offset(1).Title,[COLOR button_focus]$LOCALIZE[19031]:[/COLOR] ]$INFO[MusicPlayer.offset(1).Artist, - ]</label> + <label>$VAR[OSDNextLabelVar]</label> <shadowcolor>black</shadowcolor> <scroll>true</scroll> + <visible>Integer.IsGreater(Playlist.Length(music),1)</visible> </control> </control> </control> diff --git a/addons/skin.estuary/xml/Variables.xml b/addons/skin.estuary/xml/Variables.xml index 49f4c9e916..a52382ec48 100644 --- a/addons/skin.estuary/xml/Variables.xml +++ b/addons/skin.estuary/xml/Variables.xml @@ -22,10 +22,11 @@ <value condition="String.IsEqual(ListItem.DbType,artist)">$INFO[ListItem.Property(Artist_Description),[COLOR=white],[/COLOR]]</value> </variable> <variable name="NowPlayingSublabelVar"> + <value condition="VideoPlayer.Content(musicvideos)">$INFO[VideoPlayer.Artist]$INFO[VideoPlayer.Album, - ]</value> <value condition="VideoPlayer.Content(episodes)">$INFO[VideoPlayer.TvShowTitle]</value> <value condition="VideoPlayer.Content(movies)">$INFO[VideoPlayer.Year]$INFO[VideoPlayer.Genre, - ]</value> <value condition="VideoPlayer.Content(livetv)">$INFO[VideoPlayer.ChannelName]</value> - <value condition="Player.HasAudio">$INFO[MusicPlayer.Artist]</value> + <value condition="Player.HasAudio">$INFO[MusicPlayer.Artist]$INFO[MusicPlayer.Album, - ]</value> </variable> <variable name="NowPlayingIconVar"> <value condition="Player.Paused">icons/now-playing/pause.png</value> @@ -79,6 +80,10 @@ <value condition="Window.IsActive(musicplaylist) | Window.IsActive(videoplaylist)">$INFO[ListItem.Duration]</value> <value>$INFO[ListItem.Label2]</value> </variable> + <variable name="PlotTextBoxVar"> + <value condition="!String.IsEmpty(ListItem.PlotOutline)">$INFO[ListItem.PlotOutline]</value> + <value>$INFO[ListItem.Plot]</value> + </variable> <variable name="ShiftLeftTextBoxVar"> <value condition="Window.IsActive(pictures)">$INFO[ListItem.Property(description),,[CR]]$INFO[ListItem.PictureDatetime,[COLOR button_focus]$LOCALIZE[552]: [/COLOR],[CR]]$INFO[ListItem.PictureResolution,[COLOR button_focus]$LOCALIZE[169]: [/COLOR],[CR]]$INFO[ListItem.PictureCamMake,[COLOR button_focus]$LOCALIZE[31041]: [/COLOR],[CR]]$INFO[ListItem.PictureCamModel,[COLOR button_focus]$LOCALIZE[21823]: [/COLOR],[CR]]</value> <value condition="String.IsEqual(listitem.dbtype,artist)">$INFO[ListItem.Genre,[COLOR button_focus]$LOCALIZE[515]: [/COLOR],[CR]]$INFO[ListItem.Property(Artist_YearsActive),[COLOR button_focus]$LOCALIZE[21898]: [/COLOR],[CR]]$INFO[ListItem.Property(Artist_Style),[COLOR button_focus]$LOCALIZE[736]: [/COLOR],[CR]]</value> @@ -90,6 +95,7 @@ <value condition="Window.IsActive(pictures)">$INFO[ListItem.Size,[COLOR button_focus]$LOCALIZE[289]: [/COLOR],[CR]]$INFO[ListItem.PictureAperture,[COLOR button_focus]$LOCALIZE[21826]: [/COLOR],[CR]]$INFO[ListItem.PictureFocalLen,[COLOR button_focus]$LOCALIZE[21827]: [/COLOR],[CR]]$INFO[ListItem.PictureExpTime,[COLOR button_focus]$LOCALIZE[21830]: [/COLOR],[CR]]$INFO[ListItem.Date,[COLOR button_focus]$LOCALIZE[552]: [/COLOR],[CR]]</value> <value condition="String.IsEqual(listitem.dbtype,artist)">$INFO[ListItem.Property(artist_description)]</value> <value condition="String.IsEqual(listitem.dbtype,album)">$INFO[ListItem.Property(album_description)]</value> + <value condition="!String.IsEmpty(ListItem.PlotOutline)">$INFO[ListItem.PlotOutline]</value> <value>$INFO[ListItem.Plot]</value> </variable> <variable name="SelectLabel"> @@ -116,19 +122,24 @@ <value condition="String.IsEqual(listitem.dbtype,album)">$INFO[ListItem.Property(album_description)]</value> <value condition="String.IsEqual(listitem.dbtype,musicvideo) | String.IsEqual(listitem.dbtype,video)">$INFO[ListItem.Genre,[COLOR button_focus]$LOCALIZE[515]: [/COLOR],[CR]]$INFO[ListItem.Plot]</value> <value condition="String.IsEqual(listitem.dbtype,artist)">$INFO[ListItem.Property(artist_description)]</value> + <value condition="!String.IsEmpty(ListItem.PlotOutline)">$INFO[ListItem.PlotOutline]</value> <value condition="!String.IsEmpty(ListItem.Plot)">$INFO[ListItem.Plot]</value> - <value condition="String.IsEqual(ListItem.DBType,song)">$VAR[MusicTrackInfo,[COLOR button_focus]$LOCALIZE[554]: [/COLOR],[CR]]$INFO[ListItem.Artist,[COLOR button_focus]$LOCALIZE[557]: [/COLOR],[CR]]$INFO[listitem.Album,[COLOR button_focus]$LOCALIZE[558]: [/COLOR],[CR]]$INFO[ListItem.DiscNumber,[COLOR button_focus]$LOCALIZE[427]: [/COLOR],[CR]]$INFO[ListItem.Year,[COLOR button_focus]$LOCALIZE[345]: [/COLOR],[CR]]$INFO[ListItem.Genre,[COLOR button_focus]$LOCALIZE[515]: [/COLOR],[CR]]$INFO[ListItem.Duration,[COLOR button_focus]$LOCALIZE[180]: [/COLOR],[CR]]$INFO[ListItem.Playcount,[COLOR button_focus]$LOCALIZE[567]: [/COLOR],[CR]]$INFO[ListItem.LastPlayed,[COLOR button_focus]$LOCALIZE[568]: [/COLOR],]</value> + <value condition="String.IsEqual(ListItem.DBType,song)">$VAR[MusicTrackInfo,[COLOR button_focus]$LOCALIZE[554]: [/COLOR],[CR]]$INFO[ListItem.Artist,[COLOR button_focus]$LOCALIZE[557]: [/COLOR],[CR]]$INFO[listitem.Album,[COLOR button_focus]$LOCALIZE[558]: [/COLOR],[CR]]$VAR[InfoDiscVar,[COLOR button_focus]$LOCALIZE[427]: [/COLOR],[CR]]$INFO[ListItem.Year,[COLOR button_focus]$LOCALIZE[345]: [/COLOR],[CR]]$INFO[ListItem.Genre,[COLOR button_focus]$LOCALIZE[515]: [/COLOR],[CR]]$INFO[ListItem.Duration,[COLOR button_focus]$LOCALIZE[180]: [/COLOR],[CR]]$INFO[ListItem.Playcount,[COLOR button_focus]$LOCALIZE[567]: [/COLOR],[CR]]$INFO[ListItem.LastPlayed,[COLOR button_focus]$LOCALIZE[568]: [/COLOR],]</value> <value>$INFO[ListItem.Genre,[COLOR button_focus]$LOCALIZE[515]: [/COLOR],[CR]]</value> </variable> <variable name="NowPlayingInfoVar"> - <value>$INFO[MusicPlayer.Title,[COLOR button_focus]$LOCALIZE[554]: [/COLOR],[CR]]$INFO[MusicPlayer.Artist,[COLOR button_focus]$LOCALIZE[557]: [/COLOR],[CR]]$INFO[MusicPlayer.Album,[COLOR button_focus]$LOCALIZE[558]: [/COLOR],[CR]]$INFO[MusicPlayer.DiscNumber,[COLOR button_focus]$LOCALIZE[427]: [/COLOR],[CR]]$INFO[MusicPlayer.Year,[COLOR button_focus]$LOCALIZE[345]: [/COLOR],[CR]]$INFO[MusicPlayer.Genre,[COLOR button_focus]$LOCALIZE[515]: [/COLOR],[CR]]$INFO[MusicPlayer.Time,[COLOR button_focus]$LOCALIZE[180]: [/COLOR],/]$INFO[MusicPlayer.Duration,,[CR]]</value> + <value>$INFO[MusicPlayer.Title,[COLOR button_focus]$LOCALIZE[554]: [/COLOR],[CR]]$INFO[MusicPlayer.Artist,[COLOR button_focus]$LOCALIZE[557]: [/COLOR],[CR]]$INFO[MusicPlayer.Album,[COLOR button_focus]$LOCALIZE[558]: [/COLOR],[CR]]$VAR[MultiDiscVar,[COLOR button_focus]$LOCALIZE[427]: [/COLOR],[CR]]$INFO[MusicPlayer.Year,[COLOR button_focus]$LOCALIZE[345]: [/COLOR],[CR]]$INFO[MusicPlayer.Genre,[COLOR button_focus]$LOCALIZE[515]: [/COLOR],[CR]]$INFO[MusicPlayer.Time,[COLOR button_focus]$LOCALIZE[180]: [/COLOR],/]$INFO[MusicPlayer.Duration,,[CR]]</value> </variable> <variable name="MusicTrackInfo"> <value condition="String.IsEmpty(listitem.Title)">$INFO[listitem.TrackNumber]</value> <value>$INFO[listitem.TrackNumber,,.]$INFO[listitem.Title, ]</value> </variable> + <variable name="InfoDiscVar"> + <value condition="Integer.IsGreater(ListItem.TotalDiscs,1)">$INFO[ListItem.DiscNumber]$INFO[ListItem.DiscTitle, - ]</value> + </variable> <variable name="MultiDiscVar"> - <value condition="MusicPlayer.IsMultiDisc">$INFO[MusicPlayer.DiscNumber, - [$LOCALIZE[427] ,] ]$INFO[MusicPlayer.DiscTitle]</value> + <value condition="MusicPlayer.IsMultiDisc + Window.IsActive(visualisation)">$INFO[MusicPlayer.DiscNumber, - [$LOCALIZE[427] ,] ]$INFO[MusicPlayer.DiscTitle]</value> + <value condition="MusicPlayer.IsMultiDisc">$INFO[MusicPlayer.DiscNumber]$INFO[MusicPlayer.DiscTitle, - ]</value> </variable> <variable name="WidgetGenreIconVar"> <value condition="System.AddonIsEnabled(resource.images.moviegenreicons.transparent)">$INFO[ListItem.Label,resource://resource.images.moviegenreicons.transparent/,.png]</value> @@ -320,13 +331,20 @@ </variable> <variable name="OSDSubLabelVar"> <value condition="Window.IsActive(visualisation) + Integer.IsGreater(Playlist.Length(music),1) + Integer.IsGreater(Playlist.Position(music),0)">$LOCALIZE[554] $INFO[Playlist.Position] / $INFO[Playlist.Length]</value> - <value condition="VideoPlayer.Content(musicvideos)">$INFO[VideoPlayer.Artist]$INFO[VideoPlayer.Album, - ]</value> + <value condition="VideoPlayer.Content(musicvideos)">$VAR[NowPlayingSublabelVar,,[CR]]$INFO[player.chapter,[COLOR button_focus]$LOCALIZE[21396]: [/COLOR]]$INFO[Player.ChapterCount,/]$INFO[Player.ChapterName, - ]</value> <value condition="VideoPlayer.Content(episodes) + !player.chaptercount">$INFO[VideoPlayer.Season,[COLOR button_focus][CAPITALIZE]$LOCALIZE[36906][/CAPITALIZE]:[/COLOR] S]$INFO[VideoPlayer.Episode,E,: ]$INFO[VideoPlayer.Title]</value> <value condition="VideoPlayer.Content(episodes) + player.chaptercount">$INFO[VideoPlayer.Season,[COLOR button_focus][CAPITALIZE]$LOCALIZE[36906][/CAPITALIZE]:[/COLOR] S]$INFO[VideoPlayer.Episode,E, - ]$INFO[VideoPlayer.Title,,[CR]]$INFO[player.chapter,[COLOR button_focus]$LOCALIZE[21396]:[/COLOR] ]$INFO[Player.ChapterCount,/]$INFO[Player.ChapterName, - ]</value> <value condition="VideoPlayer.Content(LiveTV) | PVR.IsPlayingRecording | PVR.IsPlayingEpgTag">$INFO[VideoPlayer.ChannelNumberLabel,([COLOR button_focus],[/COLOR]) ]$INFO[VideoPlayer.ChannelName] $INFO[VideoPlayer.EpisodeName, - ]</value> <value condition="player.chaptercount + [!VideoPlayer.Content(episodes) + !VideoPlayer.Content(LiveTV)]">$INFO[player.chapter,[COLOR button_focus]$LOCALIZE[21396]:[/COLOR] ]$INFO[Player.ChapterCount,/]$INFO[Player.ChapterName, - ]</value> <value>$INFO[VideoPlayer.Genre]</value> </variable> + <variable name="OSDNextLabelVar"> + <value condition="Window.IsActive(visualisation)">$INFO[MusicPlayer.offset(1).Title,[COLOR button_focus]$LOCALIZE[19031]: [/COLOR]]$INFO[MusicPlayer.offset(1).Artist, - ]$INFO[MusicPlayer.offset(1).Album, - ]$INFO[MusicPlayer.offset(1).Year, (,)]</value> + <value condition="VideoPlayer.Content(musicvideos)">$INFO[VideoPlayer.offset(1).Title,[COLOR button_focus]$LOCALIZE[19031]: [/COLOR]]$INFO[VideoPlayer.offset(1).Artist, - ]$INFO[VideoPlayer.offset(1).Album, - ]$INFO[VideoPlayer.offset(1).Year, (,)]</value> + <value condition="VideoPlayer.Content(livetv)">$INFO[VideoPlayer.NextStartTime,[COLOR button_focus]$LOCALIZE[19031]: [/COLOR]]$INFO[VideoPlayer.NextEndTime, - ]$INFO[VideoPlayer.NextTitle,: ]</value> + <value condition="VideoPlayer.Content(episodes) + Window.IsActive(fullscreenvideo)">$INFO[VideoPlayer.offset(1).TVShowtitle,[COLOR button_focus]$LOCALIZE[19031]: [/COLOR]]$INFO[VideoPlayer.offset(1).Season, - S,]$INFO[VideoPlayer.offset(1).Episode,E]$INFO[VideoPlayer.offset(1).Title, - ]</value> + <value>$INFO[VideoPlayer.offset(1).Title,[COLOR button_focus]$LOCALIZE[19031]: [/COLOR]]$INFO[VideoPlayer.offset(1).Year, (,)]</value> + </variable> <variable name="PlayerClearLogoVar"> <value condition="!String.IsEmpty(Player.Art(tvshow.clearlogo))">$INFO[Player.Art(tvshow.clearlogo)]</value> <value condition="!String.IsEmpty(Player.Art(clearlogo))">$INFO[Player.Art(clearlogo)]</value> diff --git a/addons/skin.estuary/xml/View_502_FanArt.xml b/addons/skin.estuary/xml/View_502_FanArt.xml index 90710c2e33..ceee70eb94 100644 --- a/addons/skin.estuary/xml/View_502_FanArt.xml +++ b/addons/skin.estuary/xml/View_502_FanArt.xml @@ -45,7 +45,7 @@ <right>50</right> <top>769</top> <bottom>105</bottom> - <label>$INFO[ListItem.Plot]</label> + <label>$VAR[PlotTextBoxVar]</label> <autoscroll time="3000" delay="7000" repeat="5000">!System.HasActiveModalDialog + Skin.HasSetting(AutoScroll)</autoscroll> </control> <control type="scrollbar" id="502600"> @@ -61,7 +61,7 @@ <control type="group"> <left>40</left> <top>770</top> - <visible>ListItem.IsCollection + String.IsEmpty(ListItem.Plot)</visible> + <visible>ListItem.IsCollection + String.IsEmpty(ListItem.PlotOutline) + String.IsEmpty(ListItem.Plot)</visible> <include content="InfoList"> <param name="bottom" value="108" /> <param name="width" value="1000" /> diff --git a/addons/skin.estuary/xml/View_51_Poster.xml b/addons/skin.estuary/xml/View_51_Poster.xml index 53a7a82f8d..1d0f6cf062 100644 --- a/addons/skin.estuary/xml/View_51_Poster.xml +++ b/addons/skin.estuary/xml/View_51_Poster.xml @@ -80,7 +80,7 @@ <left>635</left> <top>480</top> <height>245</height> - <visible>ListItem.IsCollection + String.IsEmpty(ListItem.Plot)</visible> + <visible>ListItem.IsCollection + String.IsEmpty(ListItem.PlotOutline) + String.IsEmpty(ListItem.Plot)</visible> <include content="InfoList"> <param name="bottom" value="0" /> <param name="sortby" value="year" /> @@ -110,9 +110,9 @@ <height>250</height> <right>115</right> <autoscroll time="3000" delay="7000" repeat="5000">!System.HasActiveModalDialog + Skin.HasSetting(AutoScroll)</autoscroll> - <label>$INFO[ListItem.Plot]</label> + <label>$VAR[PlotTextBoxVar]</label> <shadowcolor>text_shadow</shadowcolor> - <visible>![ListItem.IsCollection + String.IsEmpty(ListItem.Plot)]</visible> + <visible>![ListItem.IsCollection + String.IsEmpty(ListItem.PlotOutline) + String.IsEmpty(ListItem.Plot)]</visible> </control> </control> </control> diff --git a/cmake/installdata/common/addons.txt b/cmake/installdata/common/addons.txt index 897420faa7..5a9aef2db0 100644 --- a/cmake/installdata/common/addons.txt +++ b/cmake/installdata/common/addons.txt @@ -42,5 +42,7 @@ addons/metadata.common.themoviedb.org/* addons/metadata.generic.albums/* addons/metadata.generic.artists/* addons/metadata.themoviedb.org/* +addons/metadata.themoviedb.org.python/* addons/metadata.tvshows.themoviedb.org/* +addons/metadata.tvshows.themoviedb.org.python/* addons/kodi.vfs/* diff --git a/cmake/modules/FindPulseAudio.cmake b/cmake/modules/FindPulseAudio.cmake index 2ef79107f1..829a2d8189 100644 --- a/cmake/modules/FindPulseAudio.cmake +++ b/cmake/modules/FindPulseAudio.cmake @@ -14,14 +14,10 @@ # # PulseAudio::PulseAudio - The PulseAudio library -if(NOT PulseAudio_FIND_VERSION) - set(PulseAudio_FIND_VERSION 2.0.0) -endif() - if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_PULSEAUDIO libpulse>=${PulseAudio_FIND_VERSION} QUIET) - pkg_check_modules(PC_PULSEAUDIO_MAINLOOP libpulse-mainloop-glib QUIET) - pkg_check_modules(PC_PULSEAUDIO_SIMPLE libpulse-simple QUIET) + pkg_check_modules(PC_PULSEAUDIO libpulse>=11.0.0 QUIET) + pkg_check_modules(PC_PULSEAUDIO_MAINLOOP libpulse-mainloop-glib>=11.0.0 QUIET) + pkg_check_modules(PC_PULSEAUDIO_SIMPLE libpulse-simple>=11.0.0 QUIET) endif() find_path(PULSEAUDIO_INCLUDE_DIR NAMES pulse/pulseaudio.h pulse/simple.h diff --git a/cmake/modules/FindVAAPI.cmake b/cmake/modules/FindVAAPI.cmake index 2111e4f13b..f0a5d0599f 100644 --- a/cmake/modules/FindVAAPI.cmake +++ b/cmake/modules/FindVAAPI.cmake @@ -24,14 +24,14 @@ find_path(VAAPI_libva-drm_INCLUDE_DIR va/va_drm.h PATHS ${PC_VAAPI_libva-drm_INCLUDEDIR}) find_library(VAAPI_libva-drm_LIBRARY NAMES va-drm PATHS ${PC_VAAPI_libva-drm_LIBDIR}) -if(CORE_PLATFORM_NAME_LC STREQUAL "wayland") +if("wayland" IN_LIST CORE_PLATFORM_NAME_LC) find_path(VAAPI_libva-wayland_INCLUDE_DIR va/va_wayland.h PATHS ${PC_VAAPI_libva-wayland_INCLUDEDIR}) find_library(VAAPI_libva-wayland_LIBRARY NAMES va-wayland PATHS ${PC_VAAPI_libva-wayland_LIBDIR}) list(APPEND REQUIRED_VARS "VAAPI_libva-wayland_INCLUDE_DIR" "VAAPI_libva-wayland_LIBRARY") endif() -if(CORE_PLATFORM_NAME_LC STREQUAL "x11") +if("x11" IN_LIST CORE_PLATFORM_NAME_LC) find_path(VAAPI_libva-x11_INCLUDE_DIR va/va_x11.h PATHS ${PC_VAAPI_libva-x11_INCLUDEDIR}) find_library(VAAPI_libva-x11_LIBRARY NAMES va-x11 diff --git a/cmake/platform/freebsd/x11.cmake b/cmake/platform/freebsd/x11.cmake index 09cebde3db..307dac37de 100644 --- a/cmake/platform/freebsd/x11.cmake +++ b/cmake/platform/freebsd/x11.cmake @@ -1,3 +1,2 @@ -set(PLATFORM_REQUIRED_DEPS OpenGl EGL X XRandR LibDRM) -set(PLATFORM_OPTIONAL_DEPS VAAPI VDPAU GLX) -set(APP_RENDER_SYSTEM gl) +list(APPEND PLATFORM_REQUIRED_DEPS OpenGl EGL X XRandR LibDRM) +list(APPEND PLATFORM_OPTIONAL_DEPS VAAPI VDPAU GLX) diff --git a/cmake/platform/linux/gbm.cmake b/cmake/platform/linux/gbm.cmake index fa24fe400d..8f17ef672d 100644 --- a/cmake/platform/linux/gbm.cmake +++ b/cmake/platform/linux/gbm.cmake @@ -1,16 +1,8 @@ -set(PLATFORM_REQUIRED_DEPS EGL GBM LibDRM LibInput Xkbcommon) -set(PLATFORM_OPTIONAL_DEPS VAAPI) +list(APPEND PLATFORM_REQUIRED_DEPS EGL GBM LibDRM LibInput Xkbcommon) +list(APPEND PLATFORM_OPTIONAL_DEPS VAAPI) -set(GBM_RENDER_SYSTEM "" CACHE STRING "Render system to use with GBM: \"gl\" or \"gles\"") - -if(GBM_RENDER_SYSTEM STREQUAL "gl") +if(APP_RENDER_SYSTEM STREQUAL "gl") list(APPEND PLATFORM_REQUIRED_DEPS OpenGl) - set(APP_RENDER_SYSTEM gl) -elseif(GBM_RENDER_SYSTEM STREQUAL "gles") +elseif(APP_RENDER_SYSTEM STREQUAL "gles") list(APPEND PLATFORM_REQUIRED_DEPS OpenGLES) - set(APP_RENDER_SYSTEM gles) -else() - message(SEND_ERROR "You need to decide whether you want to use GL- or GLES-based rendering in combination with the GBM windowing system. Please set GBM_RENDER_SYSTEM to either \"gl\" or \"gles\". For normal desktop systems, you will usually want to use \"gl\".") endif() - -list(APPEND PLATFORM_DEFINES -DPLATFORM_SETTINGS_FILE=gbm.xml) diff --git a/cmake/platform/linux/wayland.cmake b/cmake/platform/linux/wayland.cmake index 7137c93ce7..1adcd8fe77 100644 --- a/cmake/platform/linux/wayland.cmake +++ b/cmake/platform/linux/wayland.cmake @@ -1,20 +1,14 @@ -set(PLATFORM_REQUIRED_DEPS WaylandProtocols>=1.7 Waylandpp>=0.2.2 LibDRM Xkbcommon>=0.4.1) -set(PLATFORM_OPTIONAL_DEPS VAAPI) +list(APPEND PLATFORM_REQUIRED_DEPS WaylandProtocols>=1.7 Waylandpp>=0.2.2 LibDRM Xkbcommon>=0.4.1) +list(APPEND PLATFORM_OPTIONAL_DEPS VAAPI) -set(WAYLAND_RENDER_SYSTEM "" CACHE STRING "Render system to use with Wayland: \"gl\" or \"gles\"") - -if(WAYLAND_RENDER_SYSTEM STREQUAL "gl") +if(APP_RENDER_SYSTEM STREQUAL "gl") list(APPEND PLATFORM_REQUIRED_DEPS OpenGl EGL) - set(APP_RENDER_SYSTEM gl) -elseif(WAYLAND_RENDER_SYSTEM STREQUAL "gles") +elseif(APP_RENDER_SYSTEM STREQUAL "gles") list(APPEND PLATFORM_REQUIRED_DEPS OpenGLES EGL) - set(APP_RENDER_SYSTEM gles) -else() - message(SEND_ERROR "You need to decide whether you want to use GL- or GLES-based rendering in combination with the Wayland windowing system. Please set WAYLAND_RENDER_SYSTEM to either \"gl\" or \"gles\". For normal desktop systems, you will usually want to use \"gl\".") endif() set(PLATFORM_GLOBAL_TARGET_DEPS generate-wayland-extra-protocols) set(WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}") -list(APPEND PLATFORM_DEFINES -DPLATFORM_SETTINGS_FILE=wayland.xml) + # for wayland-extra-protocols.hpp include_directories("${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}") diff --git a/cmake/platform/linux/x11.cmake b/cmake/platform/linux/x11.cmake index e3e6042596..5f5b8c2f99 100644 --- a/cmake/platform/linux/x11.cmake +++ b/cmake/platform/linux/x11.cmake @@ -1,17 +1,9 @@ -set(PLATFORM_REQUIRED_DEPS EGL X XRandR LibDRM) -set(PLATFORM_OPTIONAL_DEPS VAAPI) +list(APPEND PLATFORM_REQUIRED_DEPS EGL X XRandR LibDRM) +list(APPEND PLATFORM_OPTIONAL_DEPS VAAPI) -set(X11_RENDER_SYSTEM "" CACHE STRING "Render system to use with X11: \"gl\" or \"gles\"") - -if(X11_RENDER_SYSTEM STREQUAL "gl") +if(APP_RENDER_SYSTEM STREQUAL "gl") list(APPEND PLATFORM_REQUIRED_DEPS OpenGl) list(APPEND PLATFORM_OPTIONAL_DEPS GLX VDPAU) - set(APP_RENDER_SYSTEM gl) -elseif(X11_RENDER_SYSTEM STREQUAL "gles") +elseif(APP_RENDER_SYSTEM STREQUAL "gles") list(APPEND PLATFORM_REQUIRED_DEPS OpenGLES) - set(APP_RENDER_SYSTEM gles) -else() - message(SEND_ERROR "You need to decide whether you want to use GL- or GLES-based rendering in combination with the X11 windowing system. Please set X11_RENDER_SYSTEM to either \"gl\" or \"gles\". For normal desktop systems, you will usually want to use \"gl\".") endif() - -list(APPEND PLATFORM_DEFINES -DPLATFORM_SETTINGS_FILE=x11.xml) diff --git a/cmake/scripts/common/Platform.cmake b/cmake/scripts/common/Platform.cmake index 5ac233a54d..397d8d46e8 100644 --- a/cmake/scripts/common/Platform.cmake +++ b/cmake/scripts/common/Platform.cmake @@ -3,10 +3,13 @@ if(NOT CORE_SYSTEM_NAME) endif() if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) - # Set default CORE_PLATFORM_NAME to X11 + # Set default CORE_PLATFORM_NAME to X11 WAYLAND GBM # This is overridden by user setting -DCORE_PLATFORM_NAME=<platform> - set(_DEFAULT_PLATFORM X11) - option(ENABLE_APP_AUTONAME "Enable renaming the binary according to windowing?" ON) + set(_DEFAULT_PLATFORM X11 WAYLAND GBM) + + if(NOT APP_RENDER_SYSTEM) + message(SEND_ERROR "You need to decide whether you want to use GL- or GLES-based rendering. Please set APP_RENDER_SYSTEM to either \"gl\" or \"gles\". For normal desktop systems, you will usually want to use \"gl\".") + endif() else() string(TOLOWER ${CORE_SYSTEM_NAME} _DEFAULT_PLATFORM) endif() @@ -18,20 +21,37 @@ set(APP_BINARY_SUFFIX ".bin") # use the normalized to lower case CORE_PLATFORM_NAME_LC (see below) instead # if(NOT CORE_PLATFORM_NAME) - set(CORE_PLATFORM_NAME ${_DEFAULT_PLATFORM} CACHE STRING "Platform port to build") + set(CORE_PLATFORM_NAME ${_DEFAULT_PLATFORM}) endif() +set(CORE_PLATFORM_NAME ${CORE_PLATFORM_NAME} CACHE STRING "Platform port to build" FORCE) unset(_DEFAULT_PLATFORM) -string(TOLOWER ${CORE_PLATFORM_NAME} CORE_PLATFORM_NAME_LC) -list(APPEND final_message "Platform: ${CORE_PLATFORM_NAME}") -if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake) - if(ENABLE_APP_AUTONAME) - set(APP_BINARY_SUFFIX "-${CORE_PLATFORM_NAME_LC}") +string(REPLACE " " ";" CORE_PLATFORM_NAME "${CORE_PLATFORM_NAME}") +foreach(platform IN LISTS CORE_PLATFORM_NAME) + string(TOLOWER ${platform} platform) + list(APPEND CORE_PLATFORM_NAME_LC ${platform}) +endforeach() + +string(REPLACE ";" " " CORE_PLATFORM_STRING "${CORE_PLATFORM_NAME_LC}") +list(APPEND final_message "Platforms: ${CORE_PLATFORM_STRING}") + +if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) + list(LENGTH CORE_PLATFORM_NAME_LC PLATFORM_COUNT) + if(PLATFORM_COUNT EQUAL 1) + option(ENABLE_APP_AUTONAME "Enable renaming the binary according to windowing?" ON) + if(ENABLE_APP_AUTONAME) + set(APP_BINARY_SUFFIX "-${CORE_PLATFORM_NAME_LC}") + endif() endif() -else() - file(GLOB _platformnames RELATIVE ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/ - ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/*.cmake) - string(REPLACE ".cmake" " " _platformnames ${_platformnames}) - message(FATAL_ERROR "invalid CORE_PLATFORM_NAME: ${CORE_PLATFORM_NAME_LC}\nValid platforms: ${_platformnames}") endif() + +foreach(CORE_PLATFORM_LC IN LISTS CORE_PLATFORM_NAME_LC) + if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_LC}.cmake) + include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_LC}.cmake) + else() + file(GLOB _platformnames RELATIVE ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/ + ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/*.cmake) + string(REPLACE ".cmake" " " _platformnames ${_platformnames}) + message(FATAL_ERROR "invalid CORE_PLATFORM_NAME: ${CORE_PLATFORM_NAME_LC}\nValid platforms: ${_platformnames}") + endif() +endforeach() diff --git a/cmake/scripts/linux/ExtraTargets.cmake b/cmake/scripts/linux/ExtraTargets.cmake index 37d196af1a..61c76a8207 100644 --- a/cmake/scripts/linux/ExtraTargets.cmake +++ b/cmake/scripts/linux/ExtraTargets.cmake @@ -14,7 +14,7 @@ if(ENABLE_EVENTCLIENTS AND BLUETOOTH_FOUND) endif() endif() -if(CORE_PLATFORM_NAME_LC STREQUAL "wayland") +if("wayland" IN_LIST CORE_PLATFORM_NAME_LC) # This cannot go into wayland.cmake since it requires the Wayland dependencies # to already be resolved set(PROTOCOL_XMLS "${WAYLANDPP_PROTOCOLS_DIR}/presentation-time.xml" diff --git a/cmake/treedata/common/subdirs.txt b/cmake/treedata/common/subdirs.txt index 1988d5b5dc..ac1ee12698 100644 --- a/cmake/treedata/common/subdirs.txt +++ b/cmake/treedata/common/subdirs.txt @@ -9,10 +9,12 @@ xbmc/addons/interfaces/gui/controls addons_interfaces_gui_controls xbmc/addons/interfaces/gui/dialogs addons_interfaces_gui_dialogs xbmc/addons/kodi-dev-kit/include/kodi addons_kodi-dev-kit_include_kodi xbmc/addons/kodi-dev-kit/include/kodi/addon-instance addons_kodi-dev-kit_include_kodi_addon-instance +xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream addons_kodi-dev-kit_include_kodi_addon-instance_inputstream xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral addons_kodi-dev-kit_include_kodi_addon-instance_peripheral xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr addons_kodi-dev-kit_include_kodi_addon-instance_pvr xbmc/addons/kodi-dev-kit/include/kodi/c-api addons_kodi-dev-kit_include_kodi_c-api xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance addons_kodi-dev-kit_include_kodi_c-api_addon-instance +xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream addons_kodi-dev-kit_include_kodi_c-api_addon-instance_inputstream xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr addons_kodi-dev-kit_include_kodi_c-api_addon-instance_pvr xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui addons_kodi-dev-kit_include_kodi_c-api_gui xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls addons_kodi-dev-kit_include_kodi_c-api_gui_controls diff --git a/docs/README.Android.md b/docs/README.Android.md index 1f8cb47073..4a77d7b9dd 100644 --- a/docs/README.Android.md +++ b/docs/README.Android.md @@ -73,12 +73,12 @@ Building Kodi for Android requires Android NDK revision 20. For the SDK just use ### 3.1. Extract Android SDK and NDK Create needed directories: ``` -mkdir -p $HOME/android-tools/android-sdk-linux +mkdir -p $HOME/android-tools/android-sdk-linux/cmdline-tools ``` Extract Android SDK: ``` -unzip $HOME/Downloads/sdk-tools-linux-4333796.zip -d $HOME/android-tools/android-sdk-linux +unzip $HOME/Downloads/commandlinetools-linux-6200805_latest.zip -d $HOME/android-tools/android-sdk-linux/cmdline-tools ``` **NOTE:** Since we're using the latest SDK available, filename can change over time. Adapt the `unzip` command accordingly. @@ -91,7 +91,7 @@ unzip $HOME/Downloads/android-ndk-r20-linux-x86_64.zip -d $HOME/android-tools ### 3.2. Configure Android SDK Before Android SDK can be used, you need to accept the licenses and configure it: ``` -cd $HOME/android-tools/android-sdk-linux/tools/bin +cd $HOME/android-tools/android-sdk-linux/cmdline-tools/tools/bin ./sdkmanager --licenses ./sdkmanager platform-tools ./sdkmanager "platforms;android-28" diff --git a/docs/README.Linux.md b/docs/README.Linux.md index e7cdf8dd5c..86d1bd628b 100644 --- a/docs/README.Linux.md +++ b/docs/README.Linux.md @@ -141,25 +141,33 @@ cd $HOME/kodi-build Configure build for X11: ``` -cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DX11_RENDER_SYSTEM=gl +cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=x11 -DAPP_RENDER_SYSTEM=gl ``` **NOTE:** You can use `gles` instead of `gl` if you want to build with `GLES`. Or configure build for Wayland: ``` -cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=wayland -DWAYLAND_RENDER_SYSTEM=gl +cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=wayland -DAPP_RENDER_SYSTEM=gl ``` **NOTE:** You can use `gles` instead of `gl` if you want to build with `GLES`. Or configure build for GBM: ``` -cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=gbm -DGBM_RENDER_SYSTEM=gles +cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=gbm -DAPP_RENDER_SYSTEM=gles ``` **NOTE:** You can use `gl` instead of `gles` if you want to build with `GL`. +Or configure build with any combination of the three (default is "x11 wayland gbm"): +``` +cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME="x11 wayland gbm" -DAPP_RENDER_SYSTEM=gl +``` + +**NOTE:** You can use `gles` instead of `gl` if you want to build with `GLES`. + + ### 4.2. Build ``` cmake --build . -- VERBOSE=1 -j$(getconf _NPROCESSORS_ONLN) diff --git a/system/addon-manifest.xml b/system/addon-manifest.xml index 40732c8d18..d31205dfb7 100644 --- a/system/addon-manifest.xml +++ b/system/addon-manifest.xml @@ -34,7 +34,9 @@ <addon>metadata.generic.artists</addon> <addon>metadata.local</addon> <addon>metadata.themoviedb.org</addon> + <addon>metadata.themoviedb.org.python</addon> <addon>metadata.tvshows.themoviedb.org</addon> + <addon>metadata.tvshows.themoviedb.org.python</addon> <addon>repository.xbmc.org</addon> <addon>resource.images.weathericons.default</addon> <addon>resource.language.en_gb</addon> diff --git a/system/settings/gbm.xml b/system/settings/gbm.xml deleted file mode 100644 index 02b819fe05..0000000000 --- a/system/settings/gbm.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<settings version="1"> - <section id="player"> - <category id="videoplayer"> - <group id="2"> - <setting id="videoplayer.usedisplayasclock"> - <visible>false</visible> - <default>false</default> - </setting> - </group> - <group id="3"> - <setting id="videoplayer.useprimedecoder" type="boolean" label="13430" help="36172"> - <visible>false</visible> - <level>2</level> - <default>true</default> - <control type="toggle" /> - </setting> - <setting id="videoplayer.useprimedecoderforhw" type="boolean" parent="videoplayer.useprimedecoder" label="13438" help="36172"> - <visible>true</visible> - <dependencies> - <dependency type="enable"> - <condition setting="videoplayer.useprimedecoder" operator="is">true</condition> - </dependency> - </dependencies> - <level>3</level> - <default>true</default> - <control type="toggle" /> - </setting> - <setting id="videoplayer.useprimerenderer" type="integer" label="13462" help="13463"> - <visible>false</visible> - <level>2</level> - <default>0</default> - <constraints> - <options> - <option label="13464">0</option> <!-- DIRECT --> - <option label="13465">1</option> <!-- GLES --> - </options> - </constraints> - <control type="spinner" format="string" /> - </setting> - </group> - </category> - </section> - <section id="system"> - <category id="display"> - <group id="1"> - <setting id="videoscreen.screen"> - <visible>false</visible> - </setting> - <setting id="videoscreen.hwscalingfilter" type="boolean" label="39151" help="39152"> - <visible>false</visible> - <level>3</level> - <default>true</default> - <control type="toggle" /> - </setting> - <setting id="videoscreen.limitguisize" type="integer" label="37021" help="36548"> - <visible>false</visible> - <level>3</level> - <default>0</default> - <constraints> - <options> - <option label="37030">0</option> <!-- Unlimited --> - <option label="37028">1</option> <!-- 720 --> - <option label="13466">2</option> <!-- 1080 / 720 (>30Hz) --> - <option label="37046">3</option> <!-- 1080 --> - <option label="13467">4</option> <!-- Unlimited / 1080 (>30Hz) --> - </options> - </constraints> - <control type="list" format="string" /> - </setting> - <setting id="videoscreen.limitedrange" type="boolean" label="36042" help="36359"> - <level>3</level> - <default>false</default> - <control type="toggle" /> - </setting> - </group> - </category> - <category id="input"> - <group id="4" label="35150"> - <setting id="input.libinputkeyboardlayout" type="string" label="310" help="36436"> - <level>0</level> - <default>us</default> - <visible>true</visible> - <constraints> - <options>libinputkeyboardlayout</options> - </constraints> - <control type="list" format="string"> - <multiselect>false</multiselect> - </control> - </setting> - </group> - </category> - </section> -</settings> diff --git a/system/settings/linux.xml b/system/settings/linux.xml index 801be4848c..6d1fb9cd49 100644 --- a/system/settings/linux.xml +++ b/system/settings/linux.xml @@ -149,6 +149,38 @@ <default>true</default> <control type="toggle" /> </setting> + <setting id="videoplayer.useprimedecoder" type="boolean" label="13430" help="36172"> + <requirement>HAS_GLES</requirement> + <visible>false</visible> + <level>2</level> + <default>false</default> + <control type="toggle" /> + </setting> + <setting id="videoplayer.useprimedecoderforhw" type="boolean" parent="videoplayer.useprimedecoder" label="13438" help="36172"> + <requirement>HAS_GLES</requirement> + <visible>false</visible> + <dependencies> + <dependency type="enable"> + <condition setting="videoplayer.useprimedecoder" operator="is">true</condition> + </dependency> + </dependencies> + <level>3</level> + <default>true</default> + <control type="toggle" /> + </setting> + <setting id="videoplayer.useprimerenderer" type="integer" label="13462" help="13463"> + <requirement>HAS_GLES</requirement> + <visible>false</visible> + <level>2</level> + <default>1</default> + <constraints> + <options> + <option label="13464">0</option> <!-- DIRECT --> + <option label="13465">1</option> <!-- GLES --> + </options> + </constraints> + <control type="spinner" format="string" /> + </setting> </group> </category> </section> @@ -158,6 +190,47 @@ <setting id="videoscreen.fakefullscreen"> <visible>false</visible> </setting> + <setting id="videoscreen.hwscalingfilter" type="boolean" label="39151" help="39152"> + <visible>false</visible> + <level>3</level> + <default>true</default> + <control type="toggle" /> + </setting> + <setting id="videoscreen.limitguisize" type="integer" label="37021" help="36548"> + <visible>false</visible> + <level>3</level> + <default>0</default> + <constraints> + <options> + <option label="37030">0</option> <!-- Unlimited --> + <option label="37028">1</option> <!-- 720 --> + <option label="13466">2</option> <!-- 1080 / 720 (>30Hz) --> + <option label="37046">3</option> <!-- 1080 --> + <option label="13467">4</option> <!-- Unlimited / 1080 (>30Hz) --> + </options> + </constraints> + <control type="list" format="string" /> + </setting> + <setting id="videoscreen.limitedrange" type="boolean" label="36042" help="36359"> + <level>3</level> + <default>false</default> + <control type="toggle" /> + </setting> + </group> + </category> + <category id="input"> + <group id="4" label="35150"> + <setting id="input.libinputkeyboardlayout" type="string" label="310" help="36436"> + <level>0</level> + <default>us</default> + <visible>false</visible> + <constraints> + <options>libinputkeyboardlayout</options> + </constraints> + <control type="list" format="string"> + <multiselect>false</multiselect> + </control> + </setting> </group> </category> </section> diff --git a/system/settings/settings.xml b/system/settings/settings.xml index fbab7b4a4a..ad46926425 100755 --- a/system/settings/settings.xml +++ b/system/settings/settings.xml @@ -1405,14 +1405,14 @@ <group id="1"> <setting id="scrapers.moviesdefault" type="addon" label="21413" help="36198"> <level>4</level> - <default>metadata.themoviedb.org</default> + <default>metadata.themoviedb.org.python</default> <constraints> <addontype>xbmc.metadata.scraper.movies</addontype> </constraints> </setting> <setting id="scrapers.tvshowsdefault" type="addon" label="21414" help="36199"> <level>4</level> - <default>metadata.tvshows.themoviedb.org</default> + <default>metadata.tvshows.themoviedb.org.python</default> <constraints> <addontype>xbmc.metadata.scraper.tvshows</addontype> </constraints> @@ -1784,6 +1784,11 @@ <default>true</default> <control type="toggle" /> </setting> + <setting id="pvrreminders.autoswitch" type="boolean" label="19330" help="36434"> + <level>1</level> + <default>false</default> + <control type="toggle" /> + </setting> </group> </category> <category id="pvrpowermanagement" label="14095" help="36240"> @@ -2353,18 +2358,6 @@ </dependencies> <control type="spinner" format="string" delayed="true" /> </setting> - <setting id="videoscreen.whitelist" type="list[string]" parent="videoscreen.screen" label="14085" help="36356"> - <level>3</level> - <constraints> - <options>modes</options> - <default></default> - <delimiter>,</delimiter> - <minimumitems>0</minimumitems> - </constraints> - <control type="list" format="string"> - <multiselect>true</multiselect> - </control> - </setting> <setting id="videoscreen.resolution" type="integer" parent="videoscreen.screen" label="169" help="36352"> <level>0</level> <default>16</default> <!-- RES_DESKTOP --> @@ -2625,7 +2618,37 @@ <control type="spinner" format="integer" /> </setting> </group> - <group id="2" label="14232"> + <group id="2" label="14126"> + <setting id="videoscreen.whitelist" type="list[string]" parent="videoscreen.screen" label="14126" help="36443"> + <level>3</level> + <constraints> + <options>modes</options> + <default></default> + <delimiter>,</delimiter> + <minimumitems>0</minimumitems> + </constraints> + <control type="list" format="string"> + <multiselect>true</multiselect> + </control> + </setting> + <setting id="videoscreen.whitelistpulldown" type="boolean" parent="videoscreen.whitelist" label="14127" help="36444"> + <level>3</level> + <default>false</default> + <dependencies> + <dependency type="enable" setting="videoscreen.whitelist" operator="!is"></dependency> + </dependencies> + <control type="toggle" /> + </setting> + <setting id="videoscreen.whitelistdoublerefreshrate" type="boolean" parent="videoscreen.whitelist" label="14128" help="36445"> + <level>3</level> + <default>false</default> + <dependencies> + <dependency type="enable" setting="videoscreen.whitelist" operator="!is"></dependency> + </dependencies> + <control type="toggle" /> + </setting> + </group> + <group id="3" label="14232"> <setting id="videoscreen.stereoscopicmode" type="integer" label="36500" help="36539"> <level>2</level> <default>0</default> @@ -2646,7 +2669,7 @@ <control type="list" format="integer"/> </setting> </group> - <group id="3" label="496"> + <group id="4" label="496"> <setting id="videoscreen.noofbuffers" type="integer" label="36043" help="36552"> <level>2</level> <default>3</default> <!-- triple buffers --> diff --git a/system/settings/wayland.xml b/system/settings/wayland.xml deleted file mode 100644 index 6fcc42ad48..0000000000 --- a/system/settings/wayland.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<settings version="1"> - <section id="player"> - <category id="videoplayer"> - <group id="3"> - <setting id="videoplayer.useprimedecoder" type="boolean" label="13430" help="36172"> - <requirement>HAS_GLES</requirement> - <visible>false</visible> - <level>2</level> - <default>false</default> - <control type="toggle" /> - </setting> - <setting id="videoplayer.useprimedecoderforhw" type="boolean" parent="videoplayer.useprimedecoder" label="13438" help="36172"> - <requirement>HAS_GLES</requirement> - <visible>true</visible> - <dependencies> - <dependency type="enable"> - <condition setting="videoplayer.useprimedecoder" operator="is">true</condition> - </dependency> - </dependencies> - <level>3</level> - <default>true</default> - <control type="toggle" /> - </setting> - <setting id="videoplayer.useprimerenderer" type="integer" label="13462" help="13463"> - <requirement>HAS_GLES</requirement> - <visible>false</visible> - <level>2</level> - <default>1</default> - <constraints> - <options> - <option label="13464">0</option> <!-- DIRECT --> - <option label="13465">1</option> <!-- GLES --> - </options> - </constraints> - <control type="spinner" format="string" /> - </setting> - </group> - </category> - </section> - <section id="system"> - <category id="display"> - <group id="1"> - <setting id="videoscreen.limitedrange" type="boolean" label="36042" help="36359"> - <level>3</level> - <default>false</default> - <control type="toggle" /> - </setting> - </group> - </category> - </section> -</settings> diff --git a/system/settings/x11.xml b/system/settings/x11.xml deleted file mode 100644 index ae0c493047..0000000000 --- a/system/settings/x11.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<settings version="1"> - <section id="system"> - <category id="display"> - <group id="1"> - <setting id="videoscreen.limitedrange" type="boolean" label="36042" help="36359"> - <level>3</level> - <default>false</default> - <updates> - <update type="rename">videoplayer.vdpaustudiolevel</update> - </updates> - <control type="toggle" /> - </setting> - </group> - </category> - </section> -</settings> diff --git a/tools/Linux/kodi.sh.in b/tools/Linux/kodi.sh.in index 73d8c9be81..6899a47c1e 100644 --- a/tools/Linux/kodi.sh.in +++ b/tools/Linux/kodi.sh.in @@ -44,39 +44,13 @@ do LIBDIR="$2" shift; shift ;; - --windowing) - WINDOWING="$2" - echo "$SAVED_ARGS" | sed "s/--windowing[ ]*$2//g" - shift; shift - ;; *) shift ;; esac done -# Note: by default only one of those binaries exists -# To be able to select a different one, if has to be compiled specifically -# Your distribution might provide extra packages for those -if [ "$WINDOWING" = "auto" ]; then - # Wayland - if [ -n "$WAYLAND_DISPLAY" ] && [ -x $LIBDIR/${bin_name}/${bin_name}-wayland ]; then - KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-wayland - # X11 - elif echo $DISPLAY | grep -qE ":[0-9]+" && [ -x $LIBDIR/${bin_name}/${bin_name}-x11 ]; then - KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-x11 - # GBM/DRM - elif [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ -x $LIBDIR/${bin_name}/${bin_name}-gbm ]; then - KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-gbm - # Default kodi.bin - else - KODI_BINARY=${APP_BINARY} - fi -elif [ -n "$WINDOWING" ]; then - KODI_BINARY=$LIBDIR/${bin_name}/${bin_name}-${WINDOWING} -else - KODI_BINARY=${APP_BINARY} -fi +KODI_BINARY=${APP_BINARY} if [ ! -x ${KODI_BINARY} ]; then echo "Error: ${KODI_BINARY} not found" diff --git a/tools/Linux/packaging/package-kodi-launchpad.sh b/tools/Linux/packaging/package-kodi-launchpad.sh new file mode 100755 index 0000000000..46586c83c6 --- /dev/null +++ b/tools/Linux/packaging/package-kodi-launchpad.sh @@ -0,0 +1,75 @@ +#/bin/bash + +releaseversion=${VERSION:-"19.0"} +epoch=${EPOCH:-"2"} +gitrev=${GITREV:-"$(git log -1 --pretty=format:"%h")"} +tag=${TAG:-${gitrev}} +tagrev=${tagrev:-"0"} +dists=${DISTS:-"groovy focal bionic"} +#debuildopts="--no-lintian -d" +gpgkey=${GPG_KEY:-"jenkins (jenkins build bot) <jenkins@kodi.tv>"} +ppa=${PPA:-"nightly"} +debianrepo="${DEBIAN:-"https://github.com/wsnipex/xbmc-packaging"}" + +version="${releaseversion}+git$(date '+%Y%m%d.%H%M')-${tag}" +debversion="${epoch}:${version}" +origtarball="kodi_${version}.orig.tar.gz" + +declare -A PPAS=( + ["nightly"]='ppa:team-xbmc/xbmc-nightly' + ["unstable"]='ppa:team-xbmc/unstable' + ["stable"]='ppa:team-xbmc/ppa' + ["wsnipex-nightly"]='ppa:wsnipex/kodi-git' + ["wsnipex-stable"]='ppa:wsnipex/kodi-stable' +) + +[ -d debian ] && rm -rf debian + +# set build info +date '+%Y%m%d' > BUILDDATE +echo $gitrev > VERSION + +# download packaging files +wget -O - ${debianrepo}/archive/master.tar.gz | tar xzv --strip-components=1 --exclude=".git*" -f - +[ -d debian ] || { echo "ERROR: directory debian does not exist"; exit 3; } + +# add tarballs for internal ffmpeg, libdvd +tools/depends/target/ffmpeg/autobuild.sh -d || { echo "Error downloading ffmpeg"; exit 2; } +make -C tools/depends/target/libdvdnav download GITREV="" || { echo "Error downloading libdvdnav"; exit 2; } +make -C tools/depends/target/libdvdread download GITREV="" || { echo "Error downloading libdvdread"; exit 2; } +make -C tools/depends/target/libdvdcss download GITREV="" || { echo "Error downloading libdvdcss"; exit 2; } +make -C tools/depends/target/dav1d download || { echo "Error downloading dav1d"; exit 2; } + +# create orig tarball if needed +if grep -q quilt debian/source/format; then + echo "origtarball: ${origtarball}" + git archive -o ../${origtarball} ${gitrev} +fi + + +# build source packages +for dist in ${dists//,/ }; do + echo "### Building for ${dist} ###" + sed \ + -e "s/#PACKAGEVERSION#/${debversion}/" \ + -e "s/#TAGREV#/${tagrev}/" \ + -e "s/#DIST#/${dist}/g" \ + debian/changelog.in > debian/changelog + + echo "Changelog:" + cat debian/changelog + echo + + debuild -d -S -k"${gpgkey}" + echo "### DONE ###" +done + +# upload to PPA +echo "### Uploading to PPA ${PPAS[${ppa}]} ###" +dput ${PPAS[${ppa}]} ../kodi_${version}*.changes +if [ $? -eq 0 ]; then + echo "### Successfully pushed ${version} to launchpad ###" +else + echo "### ERROR could not upload package ###" +fi + diff --git a/tools/buildsteps/defaultenv b/tools/buildsteps/defaultenv index 66f0777fb0..0108ac2fff 100644 --- a/tools/buildsteps/defaultenv +++ b/tools/buildsteps/defaultenv @@ -9,6 +9,7 @@ PATH_CHANGE_REV_FILENAME=".last_success_revision" FAILED_BUILD_FILENAME=".last_failed_revision" #TARBALLS ENV-VAR is only used by android scripts atm TARBALLS=${TARBALLS:-"/opt/xbmc-tarballs"} +RENDER_SYSTEM=${RENDER_SYSTEM:-"Default"} BINARY_ADDONS_ROOT=tools/depends/target BINARY_ADDONS="binary-addons" @@ -25,10 +26,10 @@ case $XBMC_PLATFORM_DIR in ;; tvos) - DEFAULT_SDK_VERSION=12.2 + DEFAULT_SDK_VERSION=13.2 DEFAULT_XBMC_DEPENDS_ROOT=$WORKSPACE/tools/depends/xbmc-depends DEFAULT_CONFIGURATION="Debug" - DEFAULT_XCODE_APP="Xcode10.2.app" + DEFAULT_XCODE_APP="Xcode11.3.1.app" ;; osx64) @@ -48,6 +49,7 @@ case $XBMC_PLATFORM_DIR in linux*) DEFAULT_XBMC_DEPENDS_ROOT=$WORKSPACE/tools/depends/xbmc-depends DEFAULT_CONFIGURATION="Debug" + DEFAULT_RENDER_SYSTEM="gl" ;; freebsd) @@ -93,6 +95,11 @@ then DEBUG_SWITCH='--disable-debug' fi +if [ "$RENDER_SYSTEM" == "Default" ] +then + RENDER_SYSTEM=$DEFAULT_RENDER_SYSTEM +fi + #helper functions #hash a dir based on the git revision, Configuration, SDK_PATH, NDK_PATH, NDK_VERSION, SDK_VERSION, TOOLCHAIN and XBMC_DEPENDS_ROOT diff --git a/tools/buildsteps/freebsd/configure-xbmc b/tools/buildsteps/freebsd/configure-xbmc index 0fe6f3b986..cf5f9bcf0b 100644 --- a/tools/buildsteps/freebsd/configure-xbmc +++ b/tools/buildsteps/freebsd/configure-xbmc @@ -5,4 +5,4 @@ XBMC_PLATFORM_DIR=freebsd mkdir -p $WORKSPACE/build cd $WORKSPACE/build -cmake -DCMAKE_BUILD_TYPE=$Configuration -DENABLE_INTERNAL_SPDLOG=ON .. +cmake -DCMAKE_BUILD_TYPE=$Configuration -DENABLE_INTERNAL_SPDLOG=ON -DAPP_RENDER_SYSTEM=gl .. diff --git a/tools/buildsteps/linux-aarch64-gbm/configure-depends b/tools/buildsteps/linux-aarch64-gbm/configure-depends index 2f3532faee..846e0a6be8 100644 --- a/tools/buildsteps/linux-aarch64-gbm/configure-depends +++ b/tools/buildsteps/linux-aarch64-gbm/configure-depends @@ -5,5 +5,5 @@ XBMC_PLATFORM_DIR=linux-aarch64-gbm if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] then cd $WORKSPACE/tools/depends;./configure \ - --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=aarch64-linux-gnu --with-platform=gbm --with-rendersystem=gles --with-tarballs=$TARBALLS $DEBUG_SWITCH + --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=aarch64-linux-gnu --with-rendersystem=$RENDER_SYSTEM --with-tarballs=$TARBALLS $DEBUG_SWITCH fi diff --git a/tools/buildsteps/linux-arm-gbm/configure-depends b/tools/buildsteps/linux-arm-gbm/configure-depends index 394a1fb6d6..ac6b24ec81 100644 --- a/tools/buildsteps/linux-arm-gbm/configure-depends +++ b/tools/buildsteps/linux-arm-gbm/configure-depends @@ -5,5 +5,5 @@ XBMC_PLATFORM_DIR=linux-arm-gbm if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] then cd $WORKSPACE/tools/depends;./configure \ - --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=arm-linux-gnueabihf --with-platform=gbm --with-rendersystem=gles --with-tarballs=$TARBALLS $DEBUG_SWITCH + --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=arm-linux-gnueabihf --with-rendersystem=$RENDER_SYSTEM --with-tarballs=$TARBALLS $DEBUG_SWITCH fi diff --git a/tools/buildsteps/linux64-gbm/configure-depends b/tools/buildsteps/linux64-gbm/configure-depends deleted file mode 100644 index eae90fb12c..0000000000 --- a/tools/buildsteps/linux64-gbm/configure-depends +++ /dev/null @@ -1,9 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] -then - cd $WORKSPACE/tools/depends;./configure \ - --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=x86_64-linux-gnu --with-platform=gbm --with-rendersystem=gles --with-tarballs=$TARBALLS $DEBUG_SWITCH -fi diff --git a/tools/buildsteps/linux64-gbm/configure-xbmc b/tools/buildsteps/linux64-gbm/configure-xbmc deleted file mode 100644 index b5ccaf8e8d..0000000000 --- a/tools/buildsteps/linux64-gbm/configure-xbmc +++ /dev/null @@ -1,5 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -make -C $WORKSPACE/tools/depends/target/cmakebuildsys diff --git a/tools/buildsteps/linux64-gbm/make-binary-addons b/tools/buildsteps/linux64-gbm/make-binary-addons deleted file mode 100644 index ea4e4e3315..0000000000 --- a/tools/buildsteps/linux64-gbm/make-binary-addons +++ /dev/null @@ -1,28 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -. $WORKSPACE/tools/buildsteps/$XBMC_PLATFORM_DIR/make-native-depends - -#clear the build failed file -rm -f $WORKSPACE/cmake/$FAILED_BUILD_FILENAME - -ALL_BINARY_ADDONS_BUILT="1" -#only build binary addons when requested by env/jenkins -if [ "$BUILD_BINARY_ADDONS" == "true" ] -then - for addon in $BINARY_ADDONS - do - echo "building $addon" - git clean -xffd $WORKSPACE/$BINARY_ADDONS_ROOT/$addon - cd $WORKSPACE/$BINARY_ADDONS_ROOT/$addon;make -j $BUILDTHREADS V=99 VERBOSE=1 || ALL_BINARY_ADDONS_BUILT="0" - done -fi - -if [ "$ALL_BINARY_ADDONS_BUILT" == "1" ] -then - tagSuccessFulBuild $WORKSPACE/cmake -else - #mark the build failure in the filesystem but leave jenkins running - tagFailedBuild $WORKSPACE/cmake -fi diff --git a/tools/buildsteps/linux64-gbm/make-depends b/tools/buildsteps/linux64-gbm/make-depends deleted file mode 100644 index ebcf446c1d..0000000000 --- a/tools/buildsteps/linux64-gbm/make-depends +++ /dev/null @@ -1,8 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] -then - cd $WORKSPACE/tools/depends;make -j $BUILDTHREADS || make && tagSuccessFulBuild $WORKSPACE/tools/depends -fi diff --git a/tools/buildsteps/linux64-gbm/make-native-depends b/tools/buildsteps/linux64-gbm/make-native-depends deleted file mode 100644 index 804751e293..0000000000 --- a/tools/buildsteps/linux64-gbm/make-native-depends +++ /dev/null @@ -1,9 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] && [ "$BINARY_ADDONS_CLEAN_NATIVETOOLS" != "0" ] -then - git clean -xffd $WORKSPACE/tools/depends/native - cd $WORKSPACE/tools/depends/native;make -j $BUILDTHREADS && tagSuccessFulBuild $WORKSPACE/tools/depends -fi diff --git a/tools/buildsteps/linux64-gbm/make-xbmc b/tools/buildsteps/linux64-gbm/make-xbmc deleted file mode 100644 index 025988db1a..0000000000 --- a/tools/buildsteps/linux64-gbm/make-xbmc +++ /dev/null @@ -1,5 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -cd $WORKSPACE/build;make -j$BUILDTHREADS || make diff --git a/tools/buildsteps/linux64-gbm/package b/tools/buildsteps/linux64-gbm/package deleted file mode 100644 index 052caea54b..0000000000 --- a/tools/buildsteps/linux64-gbm/package +++ /dev/null @@ -1,5 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -#nothing for linux atm diff --git a/tools/buildsteps/linux64-gbm/prepare-depends b/tools/buildsteps/linux64-gbm/prepare-depends deleted file mode 100644 index 1f4d0d5e48..0000000000 --- a/tools/buildsteps/linux64-gbm/prepare-depends +++ /dev/null @@ -1,15 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -#clean without depends for skipping depends build if possible -#also skip binary addons (pvr, audioencoder) as long as they are deployed in tree -cd $WORKSPACE;git clean -xfd -e "cmake/.last_success_revision" -e "tools/depends" ${DEPLOYED_BINARY_ADDONS} - -# if depends path has changed - cleanout everything and do a full rebuild -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] -then - #clean up the rest too - cd $WORKSPACE;git clean -xffd - cd $WORKSPACE/tools/depends/;./bootstrap -fi diff --git a/tools/buildsteps/linux64-gbm/prepare-xbmc b/tools/buildsteps/linux64-gbm/prepare-xbmc deleted file mode 100644 index 4c17247ec3..0000000000 --- a/tools/buildsteps/linux64-gbm/prepare-xbmc +++ /dev/null @@ -1,9 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -#build binary addons before building xbmc... -#make sure that binary_addons don't clean the native tools -#here -BINARY_ADDONS_CLEAN_NATIVETOOLS="0" -. $WORKSPACE/tools/buildsteps/$XBMC_PLATFORM_DIR/make-binary-addons diff --git a/tools/buildsteps/linux64-gbm/run-tests b/tools/buildsteps/linux64-gbm/run-tests deleted file mode 100644 index bab7e75331..0000000000 --- a/tools/buildsteps/linux64-gbm/run-tests +++ /dev/null @@ -1,14 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-gbm -. $WORKSPACE/tools/buildsteps/defaultenv - -cd $WORKSPACE/build;make -j$BUILDTHREADS kodi-test -if [ "$Configuration" != "Coverage" ]; then - cd $WORKSPACE;build/kodi-test --gtest_output=xml:gtestresults.xml -else - cd $WORKSPACE/build;GTEST_OUTPUT="xml:$WORKSPACE/gtestresults.xml" make coverage -fi - -awk '{ if ($1 == "<testcase" && match($0, "notrun")) print substr($0,0,length($0)-2) "><skipped/></testcase>"; else print $0;}' gtestresults.xml > gtestresults-skipped.xml -rm gtestresults.xml -mv gtestresults-skipped.xml gtestresults.xml diff --git a/tools/buildsteps/linux64-wayland/configure-depends b/tools/buildsteps/linux64-wayland/configure-depends deleted file mode 100755 index 0210592449..0000000000 --- a/tools/buildsteps/linux64-wayland/configure-depends +++ /dev/null @@ -1,9 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] -then - cd $WORKSPACE/tools/depends;./configure \ - --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=x86_64-linux-gnu --with-platform=wayland --with-rendersystem=gl --with-tarballs=$TARBALLS $DEBUG_SWITCH -fi diff --git a/tools/buildsteps/linux64-wayland/configure-xbmc b/tools/buildsteps/linux64-wayland/configure-xbmc deleted file mode 100755 index 52479a2209..0000000000 --- a/tools/buildsteps/linux64-wayland/configure-xbmc +++ /dev/null @@ -1,5 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -make -C $WORKSPACE/tools/depends/target/cmakebuildsys diff --git a/tools/buildsteps/linux64-wayland/make-binary-addons b/tools/buildsteps/linux64-wayland/make-binary-addons deleted file mode 100755 index 0886919146..0000000000 --- a/tools/buildsteps/linux64-wayland/make-binary-addons +++ /dev/null @@ -1,28 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -. $WORKSPACE/tools/buildsteps/$XBMC_PLATFORM_DIR/make-native-depends - -#clear the build failed file -rm -f $WORKSPACE/cmake/$FAILED_BUILD_FILENAME - -ALL_BINARY_ADDONS_BUILT="1" -#only build binary addons when requested by env/jenkins -if [ "$BUILD_BINARY_ADDONS" == "true" ] -then - for addon in $BINARY_ADDONS - do - echo "building $addon" - git clean -xffd $WORKSPACE/$BINARY_ADDONS_ROOT/$addon - cd $WORKSPACE/$BINARY_ADDONS_ROOT/$addon;make -j $BUILDTHREADS V=99 VERBOSE=1 || ALL_BINARY_ADDONS_BUILT="0" - done -fi - -if [ "$ALL_BINARY_ADDONS_BUILT" == "1" ] -then - tagSuccessFulBuild $WORKSPACE/cmake -else - #mark the build failure in the filesystem but leave jenkins running - tagFailedBuild $WORKSPACE/cmake -fi diff --git a/tools/buildsteps/linux64-wayland/make-depends b/tools/buildsteps/linux64-wayland/make-depends deleted file mode 100755 index 5953efd23f..0000000000 --- a/tools/buildsteps/linux64-wayland/make-depends +++ /dev/null @@ -1,9 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] -then - cd $WORKSPACE/tools/depends;make -j $BUILDTHREADS || make && tagSuccessFulBuild $WORKSPACE/tools/depends -fi - diff --git a/tools/buildsteps/linux64-wayland/make-native-depends b/tools/buildsteps/linux64-wayland/make-native-depends deleted file mode 100755 index 77295b96a1..0000000000 --- a/tools/buildsteps/linux64-wayland/make-native-depends +++ /dev/null @@ -1,9 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] && [ "$BINARY_ADDONS_CLEAN_NATIVETOOLS" != "0" ] -then - git clean -xffd $WORKSPACE/tools/depends/native - cd $WORKSPACE/tools/depends/native;make -j $BUILDTHREADS && tagSuccessFulBuild $WORKSPACE/tools/depends -fi
\ No newline at end of file diff --git a/tools/buildsteps/linux64-wayland/make-xbmc b/tools/buildsteps/linux64-wayland/make-xbmc deleted file mode 100755 index 1a5d7e087f..0000000000 --- a/tools/buildsteps/linux64-wayland/make-xbmc +++ /dev/null @@ -1,5 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -cd $WORKSPACE/build;make -j$BUILDTHREADS || make diff --git a/tools/buildsteps/linux64-wayland/package b/tools/buildsteps/linux64-wayland/package deleted file mode 100755 index 0f0abf8f9c..0000000000 --- a/tools/buildsteps/linux64-wayland/package +++ /dev/null @@ -1,5 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -#nothing for linux atm diff --git a/tools/buildsteps/linux64-wayland/prepare-depends b/tools/buildsteps/linux64-wayland/prepare-depends deleted file mode 100755 index d72507053c..0000000000 --- a/tools/buildsteps/linux64-wayland/prepare-depends +++ /dev/null @@ -1,15 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -#clean without depends for skipping depends build if possible -#also skip binary addons (pvr, audioencoder) as long as they are deployed in tree -cd $WORKSPACE;git clean -xfd -e "cmake/.last_success_revision" -e "tools/depends" ${DEPLOYED_BINARY_ADDONS} - -# if depends path has changed - cleanout everything and do a full rebuild -if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] -then - #clean up the rest too - cd $WORKSPACE;git clean -xffd - cd $WORKSPACE/tools/depends/;./bootstrap -fi diff --git a/tools/buildsteps/linux64-wayland/prepare-xbmc b/tools/buildsteps/linux64-wayland/prepare-xbmc deleted file mode 100755 index db0e084696..0000000000 --- a/tools/buildsteps/linux64-wayland/prepare-xbmc +++ /dev/null @@ -1,9 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -#build binary addons before building xbmc... -#make sure that binary_addons don't clean the native tools -#here -BINARY_ADDONS_CLEAN_NATIVETOOLS="0" -. $WORKSPACE/tools/buildsteps/$XBMC_PLATFORM_DIR/make-binary-addons diff --git a/tools/buildsteps/linux64-wayland/run-tests b/tools/buildsteps/linux64-wayland/run-tests deleted file mode 100755 index 42fa9137b7..0000000000 --- a/tools/buildsteps/linux64-wayland/run-tests +++ /dev/null @@ -1,14 +0,0 @@ -WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )} -XBMC_PLATFORM_DIR=linux64-wayland -. $WORKSPACE/tools/buildsteps/defaultenv - -cd $WORKSPACE/build;make -j$BUILDTHREADS kodi-test -if [ "$Configuration" != "Coverage" ]; then - cd $WORKSPACE;build/kodi-test --gtest_output=xml:gtestresults.xml -else - cd $WORKSPACE/build;GTEST_OUTPUT="xml:$WORKSPACE/gtestresults.xml" make coverage -fi - -awk '{ if ($1 == "<testcase" && match($0, "notrun")) print substr($0,0,length($0)-2) "><skipped/></testcase>"; else print $0;}' gtestresults.xml > gtestresults-skipped.xml -rm gtestresults.xml -mv gtestresults-skipped.xml gtestresults.xml diff --git a/tools/buildsteps/linux64/configure-depends b/tools/buildsteps/linux64/configure-depends index 8d22408516..f6446b128b 100755 --- a/tools/buildsteps/linux64/configure-depends +++ b/tools/buildsteps/linux64/configure-depends @@ -5,5 +5,5 @@ XBMC_PLATFORM_DIR=linux64 if [ "$(pathChanged $WORKSPACE/tools/depends)" == "1" ] then cd $WORKSPACE/tools/depends;./configure \ - --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=x86_64-linux-gnu --with-platform=x11 --with-rendersystem=gl --with-tarballs=$TARBALLS $DEBUG_SWITCH + --with-toolchain=/usr --prefix=$XBMC_DEPENDS_ROOT --host=x86_64-linux-gnu --with-rendersystem=$RENDER_SYSTEM --with-tarballs=$TARBALLS $DEBUG_SWITCH fi diff --git a/tools/depends/configure.ac b/tools/depends/configure.ac index cbc57e56c7..2111632a64 100644 --- a/tools/depends/configure.ac +++ b/tools/depends/configure.ac @@ -313,6 +313,7 @@ case $host in platform_cxxflags="$platform_cflags" platform_os="linux" meson_system="linux" + target_platform="wayland gbm" ;; *i686*-linux-gnu*|i*86*-*-linux-uclibc*|x86_64*-linux-gnu*|x86_64-*-linux-uclibc*) case $host in @@ -331,6 +332,7 @@ case $host in platform_os="linux" meson_system="linux" ffmpeg_options_default="--enable-vaapi --enable-vdpau --cpu=$use_cpu" + target_platform="x11 wayland gbm" ;; *darwin*) # darwin builds are always cross @@ -432,12 +434,6 @@ case $host in esac case $use_platform in - gbm|wayland|x11) - if test "$platform_os" != "linux"; then - AC_MSG_ERROR([$use_platform is only supported on the Linux platform]) - fi - target_platform=$use_platform - ;; tvos) platform_cflags+=" -fembed-bitcode" platform_cxxflags+=" -fembed-bitcode" diff --git a/tools/depends/native/TexturePacker/src/TexturePacker.cpp b/tools/depends/native/TexturePacker/src/TexturePacker.cpp index f977e56756..94c421acb7 100644 --- a/tools/depends/native/TexturePacker/src/TexturePacker.cpp +++ b/tools/depends/native/TexturePacker/src/TexturePacker.cpp @@ -49,7 +49,7 @@ #define FLAGS_USE_LZO 1 -#define DIR_SEPARATOR "/" +#define DIR_SEPARATOR '/' const char *GetFormatString(unsigned int format) { @@ -72,7 +72,9 @@ const char *GetFormatString(unsigned int format) } } -void CreateSkeletonHeaderImpl(CXBTFWriter& xbtfWriter, std::string fullPath, std::string relativePath) +void CreateSkeletonHeaderImpl(CXBTFWriter& xbtfWriter, + const std::string& fullPath, + const std::string& relativePath) { struct dirent* dp; struct stat stat_p; @@ -129,7 +131,7 @@ void CreateSkeletonHeaderImpl(CXBTFWriter& xbtfWriter, std::string fullPath, std } } -void CreateSkeletonHeader(CXBTFWriter& xbtfWriter, std::string fullPath) +void CreateSkeletonHeader(CXBTFWriter& xbtfWriter, const std::string& fullPath) { std::string temp; CreateSkeletonHeaderImpl(xbtfWriter, fullPath, temp); diff --git a/tools/depends/target/Toolchain.cmake.in b/tools/depends/target/Toolchain.cmake.in index 8786f52f7e..d30b754f21 100644 --- a/tools/depends/target/Toolchain.cmake.in +++ b/tools/depends/target/Toolchain.cmake.in @@ -11,15 +11,7 @@ if(OS STREQUAL linux) set(CMAKE_SYSTEM_NAME Linux) set(CORE_SYSTEM_NAME linux) set(CORE_PLATFORM_NAME @target_platform@) - if(NOT "@app_rendersystem@" STREQUAL "") - set(X11_RENDER_SYSTEM @app_rendersystem@ CACHE STRING "Render system to use with X11: \"gl\" or \"gles\"") - set(WAYLAND_RENDER_SYSTEM @app_rendersystem@ CACHE STRING "Render system to use with Wayland: \"gl\" or \"gles\"") - set(GBM_RENDER_SYSTEM @app_rendersystem@ CACHE STRING "Render system to use with GBM: \"gl\" or \"gles\"") - else() - set(X11_RENDER_SYSTEM gl CACHE STRING "Render system to use with X11: \"gl\" or \"gles\"") - set(WAYLAND_RENDER_SYSTEM gl CACHE STRING "Render system to use with Wayland: \"gl\" or \"gles\"") - set(GBM_RENDER_SYSTEM gles CACHE STRING "Render system to use with GBM: \"gl\" or \"gles\"") - endif() + set(APP_RENDER_SYSTEM @app_rendersystem@ CACHE STRING "Render system to use: \"gl\" or \"gles\"") elseif(OS STREQUAL android) set(CMAKE_SYSTEM_NAME Android) set(CORE_SYSTEM_NAME android) diff --git a/xbmc/AppParamParser.cpp b/xbmc/AppParamParser.cpp index f8fd7b8e96..6a96313ccc 100644 --- a/xbmc/AppParamParser.cpp +++ b/xbmc/AppParamParser.cpp @@ -16,7 +16,17 @@ #include "utils/SystemInfo.h" #include "utils/log.h" +#include <iostream> #include <stdlib.h> +#include <string> +#include <vector> + +#if defined(TARGET_LINUX) +namespace +{ +std::vector<std::string> availableWindowSystems = CCompileInfo::GetAvailableWindowSystems(); +} // namespace +#endif CAppParamParser::CAppParamParser() : m_logLevel(LOG_LEVEL_NORMAL), @@ -63,6 +73,13 @@ void CAppParamParser::DisplayHelp() printf(" --test\t\tEnable test mode. [FILE] required.\n"); printf(" --settings=<filename>\t\tLoads specified file after advancedsettings.xml replacing any settings specified\n"); printf(" \t\t\t\tspecified file must exist in special://xbmc/system/\n"); +#if defined(TARGET_LINUX) + printf(" --windowing=<system>\tSelect which windowing method to use.\n"); + printf(" \t\t\t\tAvailable window systems are:"); + for (const auto& windowSystem : availableWindowSystems) + printf(" %s", windowSystem.c_str()); + printf("\n"); +#endif exit(0); } @@ -84,6 +101,23 @@ void CAppParamParser::ParseArg(const std::string &arg) m_testmode = true; else if (arg.substr(0, 11) == "--settings=") m_settingsFile = arg.substr(11); +#if defined(TARGET_LINUX) + else if (arg.substr(0, 12) == "--windowing=") + { + if (std::find(availableWindowSystems.begin(), availableWindowSystems.end(), arg.substr(12)) != + availableWindowSystems.end()) + m_windowing = arg.substr(12); + else + { + std::cout << "Selected window system not available: " << arg << std::endl; + std::cout << " Available window systems:"; + for (const auto& windowSystem : availableWindowSystems) + std::cout << " " << windowSystem; + std::cout << std::endl; + exit(0); + } + } +#endif else if (arg.length() != 0 && arg[0] != '-') { const CFileItemPtr item = std::make_shared<CFileItem>(arg); diff --git a/xbmc/AppParamParser.h b/xbmc/AppParamParser.h index a0823364e5..5cfede7f7a 100644 --- a/xbmc/AppParamParser.h +++ b/xbmc/AppParamParser.h @@ -30,6 +30,7 @@ public: bool m_platformDirectories = true; bool m_testmode = false; bool m_standAlone = false; + std::string m_windowing; private: void ParseArg(const std::string &arg); diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 7293bcf12c..f14d1c3627 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -91,6 +91,7 @@ #include "utils/XTimeUtils.h" #include "utils/log.h" #include "windowing/WinSystem.h" +#include "windowing/WindowSystemFactory.h" #ifdef HAS_UPNP #include "network/upnp/UPnP.h" @@ -317,26 +318,6 @@ extern "C" void __stdcall init_emu_environ(); extern "C" void __stdcall update_emu_environ(); extern "C" void __stdcall cleanup_emu_environ(); -// -// Utility function used to copy files from the application bundle -// over to the user data directory in Application Support/Kodi. -// -static void CopyUserDataIfNeeded(const std::string &strPath, const std::string &file, const std::string &destname = "") -{ - std::string destPath; - if (destname == "") - destPath = URIUtils::AddFileToFolder(strPath, file); - else - destPath = URIUtils::AddFileToFolder(strPath, destname); - - if (!CFile::Exists(destPath)) - { - // need to copy it across - std::string srcPath = URIUtils::AddFileToFolder("special://xbmc/userdata/", file); - CFile::Copy(srcPath, destPath); - } -} - void CApplication::Preflight() { #ifdef HAS_DBUS @@ -364,6 +345,7 @@ bool CApplication::Create(const CAppParamParser ¶ms) m_bPlatformDirectories = params.m_platformDirectories; m_bTestMode = params.m_testmode; m_bStandalone = params.m_standAlone; + m_windowing = params.m_windowing; CServiceBroker::CreateLogging(); @@ -392,39 +374,12 @@ bool CApplication::Create(const CAppParamParser ¶ms) CApplicationMessenger::GetInstance().RegisterReceiver(&CServiceBroker::GetPlaylistPlayer()); CApplicationMessenger::GetInstance().SetGUIThread(m_threadID); - //! @todo - move to CPlatformXXX -#ifdef TARGET_POSIX - tzset(); // Initialize timezone information variables -#endif - - - //! @todo - move to CPlatformXXX - #if defined(TARGET_POSIX) - // set special://envhome - if (getenv("HOME")) - { - CSpecialProtocol::SetEnvHomePath(getenv("HOME")); - } - else - { - fprintf(stderr, "The HOME environment variable is not set!\n"); - /* Cleanup. Leaving this out would lead to another crash */ - m_ServiceManager->DeinitStageOne(); - return false; - } - #endif - // copy required files - CopyUserDataIfNeeded("special://masterprofile/", "RssFeeds.xml"); - CopyUserDataIfNeeded("special://masterprofile/", "favourites.xml"); - CopyUserDataIfNeeded("special://masterprofile/", "Lircmap.xml"); + CUtil::CopyUserDataIfNeeded("special://masterprofile/", "RssFeeds.xml"); + CUtil::CopyUserDataIfNeeded("special://masterprofile/", "favourites.xml"); + CUtil::CopyUserDataIfNeeded("special://masterprofile/", "Lircmap.xml"); - //! @todo - move to CPlatformXXX - #ifdef TARGET_DARWIN_IOS - CopyUserDataIfNeeded("special://masterprofile/", "iOS/sources.xml", "sources.xml"); - #endif - - CServiceBroker::GetLogging().Initialize(CSpecialProtocol::TranslatePath("special://logpath")); + CServiceBroker::GetLogging().Initialize(CSpecialProtocol::TranslatePath("special://logpath")); #ifdef TARGET_POSIX //! @todo Win32 has no special://home/ mapping by default, so we //! must create these here. Ideally this should be using special://home/ and @@ -537,16 +492,6 @@ bool CApplication::Create(const CAppParamParser ¶ms) std::string strExecutablePath = CUtil::GetHomePath(); - // for python scripts that check the OS - //! @todo - move to CPlatformXXX -#if defined(TARGET_DARWIN) - setenv("OS","OS X",true); -#elif defined(TARGET_POSIX) - setenv("OS","Linux",true); -#elif defined(TARGET_WINDOWS) - CEnvironment::setenv("OS", "win32"); -#endif - // initialize network protocols avformat_network_init(); // set avutil callback @@ -568,18 +513,10 @@ bool CApplication::Create(const CAppParamParser ¶ms) update_emu_environ();//apply the GUI settings - //! @todo - move to CPlatformXXX -#ifdef TARGET_WINDOWS - CWIN32Util::SetThreadLocalLocale(true); // enable independent locale for each thread, see https://connect.microsoft.com/VisualStudio/feedback/details/794122 -#endif // TARGET_WINDOWS - // application inbound service m_pAppPort = std::make_shared<CAppInboundProtocol>(*this); CServiceBroker::RegisterAppPort(m_pAppPort); - m_pWinSystem = CWinSystemBase::CreateWinSystem(); - CServiceBroker::RegisterWinSystem(m_pWinSystem.get()); - if (!m_ServiceManager->InitStageTwo(params, m_pSettingsComponent->GetProfileManager()->GetProfileUserDataFolder())) { return false; @@ -606,12 +543,6 @@ bool CApplication::Create(const CAppParamParser ¶ms) return false; } - //! @todo - move to CPlatformXXX -#if defined(TARGET_DARWIN_OSX) - // Configure and possible manually start the helper. - XBMCHelper::GetInstance().Configure(); -#endif - CUtil::InitRandomSeed(); m_lastRenderTime = XbmcThreads::SystemClockMillis(); @@ -624,9 +555,46 @@ bool CApplication::CreateGUI() m_renderGUI = true; - if (!CServiceBroker::GetWinSystem()->InitWindowSystem()) + auto windowSystems = KODI::WINDOWING::CWindowSystemFactory::GetWindowSystems(); + + if (!m_windowing.empty()) + windowSystems = {m_windowing}; + + for (auto& windowSystem : windowSystems) { - CLog::Log(LOGFATAL, "CApplication::Create: Unable to init windowing system"); + CLog::Log(LOGDEBUG, "CApplication::{} - trying to init {} windowing system", __FUNCTION__, + windowSystem); + m_pWinSystem = KODI::WINDOWING::CWindowSystemFactory::CreateWindowSystem(windowSystem); + + if (!m_pWinSystem) + continue; + + if (!m_windowing.empty() && m_windowing != windowSystem) + continue; + + CServiceBroker::RegisterWinSystem(m_pWinSystem.get()); + + if (!m_pWinSystem->InitWindowSystem()) + { + CLog::Log(LOGDEBUG, "CApplication::{} - unable to init {} windowing system", __FUNCTION__, + windowSystem); + m_pWinSystem->DestroyWindowSystem(); + m_pWinSystem.reset(); + CServiceBroker::UnregisterWinSystem(); + continue; + } + else + { + CLog::Log(LOGINFO, "CApplication::{} - using the {} windowing system", __FUNCTION__, + windowSystem); + break; + } + } + + if (!m_pWinSystem) + { + CLog::Log(LOGFATAL, "CApplication::{} - unable to init windowing system", __FUNCTION__); + CServiceBroker::UnregisterWinSystem(); return false; } @@ -644,7 +612,7 @@ bool CApplication::CreateGUI() } // update the window resolution - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); + const std::shared_ptr<CSettings> settings = m_pSettingsComponent->GetSettings(); CServiceBroker::GetWinSystem()->SetWindowResolution(settings->GetInt(CSettings::SETTING_WINDOW_WIDTH), settings->GetInt(CSettings::SETTING_WINDOW_HEIGHT)); if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_startFullScreen && CDisplaySettings::GetInstance().GetCurrentResolution() == RES_WINDOW) @@ -987,7 +955,7 @@ void CApplication::StopServices() #endif } -void CApplication::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CApplication::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -1085,7 +1053,7 @@ void CApplication::OnSettingChanged(std::shared_ptr<const CSetting> setting) m_replayGainSettings.bAvoidClipping = std::static_pointer_cast<const CSettingBool>(setting)->GetValue(); } -void CApplication::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CApplication::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -1123,7 +1091,9 @@ void CApplication::OnSettingAction(std::shared_ptr<const CSetting> setting) CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_PICTURES); } -bool CApplication::OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +bool CApplication::OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) { if (setting == NULL) return false; @@ -1964,7 +1934,7 @@ bool CApplication::OnAction(const CAction &action) if (!player.empty()) { item.m_lStartOffset = CUtil::ConvertSecsToMilliSecs(GetTime()); - PlayFile(std::move(item), player, true); + PlayFile(item, player, true); } } else diff --git a/xbmc/Application.h b/xbmc/Application.h index 923a630a2b..050f11afc0 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -360,9 +360,11 @@ protected: bool OnSettingsSaving() const override; bool Load(const TiXmlNode *settings) override; bool Save(TiXmlNode *settings) const override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; - bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; + bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) override; bool LoadSkin(const std::string& skinID); @@ -486,6 +488,7 @@ private: CApplicationPlayer m_appPlayer; CEvent m_playerEvent; CApplicationStackHelper m_stackHelper; + std::string m_windowing; }; XBMC_GLOBAL_REF(CApplication,g_application); diff --git a/xbmc/ApplicationStackHelper.cpp b/xbmc/ApplicationStackHelper.cpp index 5ac45e937e..cdb69648c4 100644 --- a/xbmc/ApplicationStackHelper.cpp +++ b/xbmc/ApplicationStackHelper.cpp @@ -17,6 +17,8 @@ #include "utils/log.h" #include "video/VideoDatabase.h" +#include <utility> + using namespace XFILE; CApplicationStackHelper::CApplicationStackHelper(void) @@ -237,7 +239,7 @@ bool CApplicationStackHelper::HasRegisteredStack(const CFileItem & item) void CApplicationStackHelper::SetRegisteredStack(const CFileItem& item, CFileItemPtr stackItem) { - GetStackPartInformation(item.GetPath())->m_pStack = stackItem; + GetStackPartInformation(item.GetPath())->m_pStack = std::move(stackItem); } int CApplicationStackHelper::GetRegisteredStackPartNumber(const CFileItem& item) @@ -270,7 +272,8 @@ void CApplicationStackHelper::SetRegisteredStackTotalTimeMs(const CFileItem& ite GetStackPartInformation(item.GetPath())->m_lStackTotalTimeMs = totalTime; } -CApplicationStackHelper::StackPartInformationPtr CApplicationStackHelper::GetStackPartInformation(std::string key) +CApplicationStackHelper::StackPartInformationPtr CApplicationStackHelper::GetStackPartInformation( + const std::string& key) { if (m_stackmap.count(key) == 0) { diff --git a/xbmc/ApplicationStackHelper.h b/xbmc/ApplicationStackHelper.h index 6f17465b52..edc9f97f61 100644 --- a/xbmc/ApplicationStackHelper.h +++ b/xbmc/ApplicationStackHelper.h @@ -189,7 +189,7 @@ protected: typedef std::shared_ptr<StackPartInformation> StackPartInformationPtr; typedef std::map<std::string, StackPartInformationPtr> Stackmap; Stackmap m_stackmap; - StackPartInformationPtr GetStackPartInformation(std::string key); + StackPartInformationPtr GetStackPartInformation(const std::string& key); std::unique_ptr<CFileItemList> m_currentStack; int m_currentStackPosition = 0; diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp index da081ac75d..b5745adde2 100644 --- a/xbmc/Autorun.cpp +++ b/xbmc/Autorun.cpp @@ -521,7 +521,10 @@ bool CAutorun::CanResumePlayDVD(const std::string& path) return false; } -void CAutorun::SettingOptionAudioCdActionsFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CAutorun::SettingOptionAudioCdActionsFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(16018), AUTOCD_NONE); list.emplace_back(g_localizeStrings.Get(14098), AUTOCD_PLAY); diff --git a/xbmc/Autorun.h b/xbmc/Autorun.h index a263f5c8a5..396410ab5e 100644 --- a/xbmc/Autorun.h +++ b/xbmc/Autorun.h @@ -55,7 +55,10 @@ public: void HandleAutorun(); static void ExecuteAutorun(const std::string& path = "", bool bypassSettings = false, bool ignoreplaying = true, bool startFromBeginning = false); - static void SettingOptionAudioCdActionsFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); + static void SettingOptionAudioCdActionsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); protected: static bool RunDisc(XFILE::IDirectory* pDir, const std::string& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings, bool startFromBeginning); diff --git a/xbmc/CompileInfo.cpp.in b/xbmc/CompileInfo.cpp.in index 0acf125308..f81fe77902 100644 --- a/xbmc/CompileInfo.cpp.in +++ b/xbmc/CompileInfo.cpp.in @@ -100,3 +100,8 @@ std::vector<ADDON::RepoInfo> CCompileInfo::LoadOfficialRepoInfos() return officialRepoInfos; } + +std::vector<std::string> CCompileInfo::GetAvailableWindowSystems() +{ + return StringUtils::Split("@CORE_PLATFORM_NAME_LC@", ' '); +} diff --git a/xbmc/CompileInfo.h b/xbmc/CompileInfo.h index ad128f0da0..553a0194ee 100644 --- a/xbmc/CompileInfo.h +++ b/xbmc/CompileInfo.h @@ -30,5 +30,6 @@ public: static const char* GetCopyrightYears(); static std::string GetBuildDate(); static const char* GetVersionCode(); + static std::vector<std::string> GetAvailableWindowSystems(); static std::vector<ADDON::RepoInfo> LoadOfficialRepoInfos(); }; diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index e9898d6050..3266a8abfa 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -2990,7 +2990,7 @@ bool CFileItemList::Save(int windowID) // name when list cached) can not be accurately derived from item path. StringUtils::Replace(cachefile, "special://temp/archive_cache/", ""); StringUtils::Replace(cachefile, ".fi", ""); - for (auto item : m_items) + for (const auto& item : m_items) item->SetProperty("cachefilename", cachefile); CArchive ar(&file, CArchive::store); @@ -3101,7 +3101,7 @@ std::string CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */, b std::string folderThumb(GetFolderThumb(strFileName)); if (CFile::Exists(folderThumb)) // folder.jpg return folderThumb; - size_t period = strFileName.find_last_of("."); + size_t period = strFileName.find_last_of('.'); if (period != std::string::npos) { std::string ext; diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 10181e10a6..01c21894cf 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -4497,6 +4497,14 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// @skinning_v19 **[New Boolean Condition]** \link ListItem_Property_AddonIsUpdate `ListItem.Property(Addon.IsUpdate)`\endlink /// <p> /// } +/// \table_row3{ <b>`ListItem.Property(Addon.ValidUpdateOrigin)`</b>, +/// \anchor ListItem_Property_ValidUpdateOrigin +/// _string_, +/// @return The origin string of a valid update for the addon. Empty string if there is no valid update available. +/// <p><hr> +/// @skinning_v19 **[New Infolabel]** \link ListItem_Property_ValidUpdateOrigin `ListItem.Property(Addon.ValidUpdateOrigin)`\endlink +/// <p> +/// } /// \table_row3{ <b>`ListItem.Property(Addon.ValidUpdateVersion)`</b>, /// \anchor ListItem_Property_ValidUpdateVersion /// _string_, diff --git a/xbmc/GUIPassword.cpp b/xbmc/GUIPassword.cpp index b41d0b6ab2..5c0b0d273d 100644 --- a/xbmc/GUIPassword.cpp +++ b/xbmc/GUIPassword.cpp @@ -126,7 +126,7 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const std::string& strType) bool CGUIPassword::IsItemUnlocked(CMediaSource* pItem, const std::string& strType) { const std::string strLabel = pItem->strName; - std::string strHeading = g_localizeStrings.Get(12325); // "Locked! Enter code..." + const std::string& strHeading = g_localizeStrings.Get(12325); // "Locked! Enter code..." return IsItemUnlocked<CMediaSource*>(pItem, strType, strLabel, strHeading); } @@ -136,7 +136,7 @@ bool CGUIPassword::CheckStartUpLock() // prompt user for mastercode if the mastercode was set b4 or by xml int iVerifyPasswordResult = -1; - std::string strHeader = g_localizeStrings.Get(20075); // "Enter master lock code" + const std::string& strHeader = g_localizeStrings.Get(20075); // "Enter master lock code" if (iMasterLockRetriesLeft == -1) iMasterLockRetriesLeft = CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_MASTERLOCK_MAXRETRIES); @@ -279,7 +279,7 @@ bool CGUIPassword::IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled) } // no, unlock since we are allowed to prompt - std::string strHeading = g_localizeStrings.Get(20075); + const std::string& strHeading = g_localizeStrings.Get(20075); std::string strPassword = profileManager->GetMasterProfile().getLockCode(); int iVerifyPasswordResult = VerifyPassword(profileManager->GetMasterProfile().getLockMode(), strPassword, strHeading); @@ -352,7 +352,7 @@ bool CGUIPassword::CheckLock(LockType btnType, const std::string& strPassword, i return true; } - std::string strHeading = g_localizeStrings.Get(iHeading); + const std::string& strHeading = g_localizeStrings.Get(iHeading); int iVerifyPasswordResult = VerifyPassword(btnType, strPassword, strHeading); if (iVerifyPasswordResult == -1) @@ -570,7 +570,7 @@ bool CGUIPassword::IsMediaPathUnlocked(const std::shared_ptr<CProfileManager>& p return true; } -void CGUIPassword::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIPassword::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/GUIPassword.h b/xbmc/GUIPassword.h index 36736482d7..1e315be4d8 100644 --- a/xbmc/GUIPassword.h +++ b/xbmc/GUIPassword.h @@ -71,7 +71,7 @@ public: m_strMediaSourcePath = strMediaSourcePath; } - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; bool bMasterUser; int iMasterLockRetriesLeft; diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp index c6a430afd1..b5e507fd78 100644 --- a/xbmc/LangInfo.cpp +++ b/xbmc/LangInfo.cpp @@ -314,7 +314,7 @@ CLangInfo::CLangInfo() CLangInfo::~CLangInfo() = default; -void CLangInfo::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CLangInfo::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -1093,7 +1093,7 @@ std::set<std::string> CLangInfo::GetSortTokens() const bool CLangInfo::DetermineUse24HourClockFromTimeFormat(const std::string& timeFormat) { // if the time format contains a "h" it's 12-hour and otherwise 24-hour clock format - return timeFormat.find("h") == std::string::npos; + return timeFormat.find('h') == std::string::npos; } bool CLangInfo::DetermineUseMeridiemFromTimeFormat(const std::string& timeFormat) @@ -1122,7 +1122,10 @@ std::string CLangInfo::PrepareTimeFormat(const std::string& timeFormat, bool use return preparedTimeFormat; } -void CLangInfo::SettingOptionsLanguageNamesFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsLanguageNamesFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { // find languages... ADDON::VECADDONS addons; @@ -1135,7 +1138,10 @@ void CLangInfo::SettingOptionsLanguageNamesFiller(SettingConstPtr setting, std:: sort(list.begin(), list.end(), SortLanguage()); } -void CLangInfo::SettingOptionsISO6391LanguagesFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsISO6391LanguagesFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { // get a list of language names std::vector<std::string> languages = g_LangCodeExpander.GetLanguageNames(CLangCodeExpander::ISO_639_1, true); @@ -1144,7 +1150,10 @@ void CLangInfo::SettingOptionsISO6391LanguagesFiller(SettingConstPtr setting, st list.emplace_back(language, language); } -void CLangInfo::SettingOptionsAudioStreamLanguagesFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsAudioStreamLanguagesFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { list.emplace_back(g_localizeStrings.Get(307), "mediadefault"); list.emplace_back(g_localizeStrings.Get(308), "original"); @@ -1153,7 +1162,10 @@ void CLangInfo::SettingOptionsAudioStreamLanguagesFiller(SettingConstPtr setting AddLanguages(list); } -void CLangInfo::SettingOptionsSubtitleStreamLanguagesFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsSubtitleStreamLanguagesFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { list.emplace_back(g_localizeStrings.Get(231), "none"); list.emplace_back(g_localizeStrings.Get(13207), "forced_only"); @@ -1163,7 +1175,11 @@ void CLangInfo::SettingOptionsSubtitleStreamLanguagesFiller(SettingConstPtr sett AddLanguages(list); } -void CLangInfo::SettingOptionsSubtitleDownloadlanguagesFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsSubtitleDownloadlanguagesFiller( + const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { list.emplace_back(g_localizeStrings.Get(308), "original"); list.emplace_back(g_localizeStrings.Get(309), "default"); @@ -1171,7 +1187,10 @@ void CLangInfo::SettingOptionsSubtitleDownloadlanguagesFiller(SettingConstPtr se AddLanguages(list); } -void CLangInfo::SettingOptionsRegionsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsRegionsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { std::vector<std::string> regions; g_langInfo.GetRegionNames(regions); @@ -1194,7 +1213,10 @@ void CLangInfo::SettingOptionsRegionsFiller(SettingConstPtr setting, std::vector current = regions[0]; } -void CLangInfo::SettingOptionsShortDateFormatsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsShortDateFormatsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { bool match = false; const std::string& shortDateFormatSetting = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); @@ -1226,7 +1248,10 @@ void CLangInfo::SettingOptionsShortDateFormatsFiller(SettingConstPtr setting, st current = list[0].value; } -void CLangInfo::SettingOptionsLongDateFormatsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsLongDateFormatsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { bool match = false; const std::string& longDateFormatSetting = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); @@ -1258,7 +1283,10 @@ void CLangInfo::SettingOptionsLongDateFormatsFiller(SettingConstPtr setting, std current = list[0].value; } -void CLangInfo::SettingOptionsTimeFormatsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsTimeFormatsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { bool match = false; const std::string& timeFormatSetting = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); @@ -1329,7 +1357,10 @@ void CLangInfo::SettingOptionsTimeFormatsFiller(SettingConstPtr setting, std::ve current = list[0].value; } -void CLangInfo::SettingOptions24HourClockFormatsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptions24HourClockFormatsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { bool match = false; const std::string& clock24HourFormatSetting = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); @@ -1363,7 +1394,10 @@ void CLangInfo::SettingOptions24HourClockFormatsFiller(SettingConstPtr setting, current = list[0].value; } -void CLangInfo::SettingOptionsTemperatureUnitsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsTemperatureUnitsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { bool match = false; const std::string& temperatureUnitSetting = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); @@ -1392,7 +1426,10 @@ void CLangInfo::SettingOptionsTemperatureUnitsFiller(SettingConstPtr setting, st current = list[0].value; } -void CLangInfo::SettingOptionsSpeedUnitsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLangInfo::SettingOptionsSpeedUnitsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { bool match = false; const std::string& speedUnitSetting = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); diff --git a/xbmc/LangInfo.h b/xbmc/LangInfo.h index be9cf93ac2..295adc5755 100644 --- a/xbmc/LangInfo.h +++ b/xbmc/LangInfo.h @@ -54,7 +54,7 @@ public: ~CLangInfo() override; // implementation of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; // implementation of ISettingsHandler void OnSettingsLoaded() override; @@ -165,18 +165,57 @@ public: static void LoadTokens(const TiXmlNode* pTokens, std::set<std::string>& vecTokens); - static void SettingOptionsLanguageNamesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsAudioStreamLanguagesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsSubtitleStreamLanguagesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsSubtitleDownloadlanguagesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsISO6391LanguagesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsRegionsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsShortDateFormatsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsLongDateFormatsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsTimeFormatsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptions24HourClockFormatsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsTemperatureUnitsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsSpeedUnitsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); + static void SettingOptionsLanguageNamesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsAudioStreamLanguagesFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsSubtitleStreamLanguagesFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsSubtitleDownloadlanguagesFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsISO6391LanguagesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsRegionsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsShortDateFormatsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsLongDateFormatsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsTimeFormatsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptions24HourClockFormatsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsTemperatureUnitsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsSpeedUnitsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); protected: void SetDefaults(); diff --git a/xbmc/NfoFile.cpp b/xbmc/NfoFile.cpp index 78a692d07e..61c714527a 100644 --- a/xbmc/NfoFile.cpp +++ b/xbmc/NfoFile.cpp @@ -149,8 +149,7 @@ void CNfoFile::Close() m_scurl.Clear(); } -std::vector<ScraperPtr> CNfoFile::GetScrapers(TYPE type, - ScraperPtr selectedScraper) +std::vector<ScraperPtr> CNfoFile::GetScrapers(TYPE type, const ScraperPtr& selectedScraper) { AddonPtr addon; ScraperPtr defaultScraper; diff --git a/xbmc/NfoFile.h b/xbmc/NfoFile.h index 4f6727f958..8db080f5d0 100644 --- a/xbmc/NfoFile.h +++ b/xbmc/NfoFile.h @@ -16,6 +16,7 @@ #include "addons/Scraper.h" #include <string> +#include <utility> class CNfoFile { @@ -40,7 +41,7 @@ public: } void Close(); - void SetScraperInfo(ADDON::ScraperPtr info) { m_info = info; } + void SetScraperInfo(ADDON::ScraperPtr info) { m_info = std::move(info); } ADDON::ScraperPtr GetScraperInfo() { return m_info; } const CScraperUrl &ScraperUrl() const { return m_scurl; } @@ -48,7 +49,7 @@ public: const std::string& content); static std::vector<ADDON::ScraperPtr> GetScrapers(ADDON::TYPE type, - ADDON::ScraperPtr selectedScraper); + const ADDON::ScraperPtr& selectedScraper); private: std::string m_doc; diff --git a/xbmc/PlayListPlayer.cpp b/xbmc/PlayListPlayer.cpp index 4a0d640693..10d5083d5e 100644 --- a/xbmc/PlayListPlayer.cpp +++ b/xbmc/PlayListPlayer.cpp @@ -255,7 +255,7 @@ bool CPlayListPlayer::PlaySongId(int songId) return Play(); } -bool CPlayListPlayer::Play(const CFileItemPtr &pItem, std::string player) +bool CPlayListPlayer::Play(const CFileItemPtr& pItem, const std::string& player) { int playlist; if (pItem->IsAudio()) @@ -276,7 +276,10 @@ bool CPlayListPlayer::Play(const CFileItemPtr &pItem, std::string player) return Play(0, player); } -bool CPlayListPlayer::Play(int iSong, std::string player, bool bAutoPlay /* = false */, bool bPlayPrevious /* = false */) +bool CPlayListPlayer::Play(int iSong, + const std::string& player, + bool bAutoPlay /* = false */, + bool bPlayPrevious /* = false */) { if (m_iCurrentPlayList == PLAYLIST_NONE) return false; diff --git a/xbmc/PlayListPlayer.h b/xbmc/PlayListPlayer.h index 654a51ee46..4ab2de7753 100644 --- a/xbmc/PlayListPlayer.h +++ b/xbmc/PlayListPlayer.h @@ -63,14 +63,17 @@ public: /*! \brief Creates a new playlist for an item and starts playing it \param pItem The item to play. */ - bool Play(const CFileItemPtr &pItem, std::string player); + bool Play(const CFileItemPtr& pItem, const std::string& player); /*! \brief Start playing a particular entry in the current playlist \param index the index of the item to play. This value is modified to ensure it lies within the current playlist. \param replace whether this item should replace the currently playing item. See CApplication::PlayFile (defaults to false). \param playPreviousOnFail whether to go back to the previous item if playback fails (default to false) */ - bool Play(int index, std::string player, bool replace = false, bool playPreviousOnFail = false); + bool Play(int index, + const std::string& player, + bool replace = false, + bool playPreviousOnFail = false); /*! \brief Returns the index of the current item in active playlist. \return Current item in the active playlist. diff --git a/xbmc/SeekHandler.cpp b/xbmc/SeekHandler.cpp index c34ac37f0b..e2f0e1028c 100644 --- a/xbmc/SeekHandler.cpp +++ b/xbmc/SeekHandler.cpp @@ -227,7 +227,10 @@ void CSeekHandler::FrameMove() } } -void CSeekHandler::SettingOptionsSeekStepsFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CSeekHandler::SettingOptionsSeekStepsFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { std::string label; for (int seconds : CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_seekSteps) @@ -242,7 +245,7 @@ void CSeekHandler::SettingOptionsSeekStepsFiller(SettingConstPtr setting, std::v } } -void CSeekHandler::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CSeekHandler::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/SeekHandler.h b/xbmc/SeekHandler.h index aea92450a0..048b625e77 100644 --- a/xbmc/SeekHandler.h +++ b/xbmc/SeekHandler.h @@ -32,9 +32,12 @@ public: CSeekHandler() = default; ~CSeekHandler() override; - static void SettingOptionsSeekStepsFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); + static void SettingOptionsSeekStepsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; bool OnAction(const CAction &action) override; void Seek(bool forward, float amount, float duration = 0, bool analogSeek = false, SeekType type = SEEK_TYPE_VIDEO); diff --git a/xbmc/ServiceBroker.cpp b/xbmc/ServiceBroker.cpp index 4a17340d68..582de0d34c 100644 --- a/xbmc/ServiceBroker.cpp +++ b/xbmc/ServiceBroker.cpp @@ -14,6 +14,8 @@ #include "utils/log.h" #include "windowing/WinSystem.h" +#include <utility> + using namespace KODI; @@ -47,7 +49,7 @@ std::shared_ptr<ANNOUNCEMENT::CAnnouncementManager> CServiceBroker::GetAnnouncem } void CServiceBroker::RegisterAnnouncementManager(std::shared_ptr<ANNOUNCEMENT::CAnnouncementManager> port) { - g_serviceBroker.m_pAnnouncementManager = port; + g_serviceBroker.m_pAnnouncementManager = std::move(port); } void CServiceBroker::UnregisterAnnouncementManager() @@ -268,7 +270,7 @@ std::shared_ptr<CAppInboundProtocol> CServiceBroker::GetAppPort() } void CServiceBroker::RegisterAppPort(std::shared_ptr<CAppInboundProtocol> port) { - g_serviceBroker.m_pAppPort = port; + g_serviceBroker.m_pAppPort = std::move(port); } void CServiceBroker::UnregisterAppPort() { @@ -292,7 +294,7 @@ std::shared_ptr<CCPUInfo> CServiceBroker::GetCPUInfo() void CServiceBroker::RegisterCPUInfo(std::shared_ptr<CCPUInfo> cpuInfo) { - g_serviceBroker.m_cpuInfo = cpuInfo; + g_serviceBroker.m_cpuInfo = std::move(cpuInfo); } void CServiceBroker::UnregisterCPUInfo() diff --git a/xbmc/ServiceManager.cpp b/xbmc/ServiceManager.cpp index 5fae97bea3..6721acf1d8 100644 --- a/xbmc/ServiceManager.cpp +++ b/xbmc/ServiceManager.cpp @@ -81,7 +81,8 @@ void CServiceManager::DeinitTesting() bool CServiceManager::InitStageOne() { m_Platform.reset(CPlatform::CreateInstance()); - m_Platform->Init(); + if (!m_Platform->Init()) + return false; #ifdef HAS_PYTHON m_XBPython.reset(new XBPython()); diff --git a/xbmc/URL.cpp b/xbmc/URL.cpp index 80a0d45c83..44ee36d663 100644 --- a/xbmc/URL.cpp +++ b/xbmc/URL.cpp @@ -189,7 +189,7 @@ void CURL::Parse(const std::string& strURL1) if (iOptions != std::string::npos) { // we keep the initial char as it can be any of the above - size_t iProto = strURL.find_first_of("|",iOptions); + size_t iProto = strURL.find_first_of('|', iOptions); if (iProto != std::string::npos) { SetProtocolOptions(strURL.substr(iProto+1)); @@ -201,13 +201,13 @@ void CURL::Parse(const std::string& strURL1) } } - size_t iSlash = strURL.find("/", iPos); + size_t iSlash = strURL.find('/', iPos); if(iSlash >= iEnd) iSlash = std::string::npos; // was an invalid slash as it was contained in options // also skip parsing username:password@ for udp/rtp as it not valid // and conflicts with the following example: rtp://sourceip@multicastip - size_t iAlphaSign = strURL.find("@", iPos); + size_t iAlphaSign = strURL.find('@', iPos); if (iAlphaSign != std::string::npos && iAlphaSign < iEnd && (iAlphaSign < iSlash || iSlash == std::string::npos) && !IsProtocol("udp") && !IsProtocol("rtp")) @@ -218,7 +218,7 @@ void CURL::Parse(const std::string& strURL1) // first extract domain, if protocol is smb if (IsProtocol("smb")) { - size_t iSemiColon = strUserNamePassword.find(";"); + size_t iSemiColon = strUserNamePassword.find(';'); if (iSemiColon != std::string::npos) { @@ -228,7 +228,7 @@ void CURL::Parse(const std::string& strURL1) } // username:password - size_t iColon = strUserNamePassword.find(":"); + size_t iColon = strUserNamePassword.find(':'); if (iColon != std::string::npos) { m_strUserName = strUserNamePassword.substr(0, iColon); @@ -241,7 +241,7 @@ void CURL::Parse(const std::string& strURL1) } iPos = iAlphaSign + 1; - iSlash = strURL.find("/", iAlphaSign); + iSlash = strURL.find('/', iAlphaSign); if (iSlash >= iEnd) iSlash = std::string::npos; @@ -251,16 +251,16 @@ void CURL::Parse(const std::string& strURL1) // check for IPv6 numerical representation inside []. // if [] found, let's store string inside as hostname // and remove that parsed part from strHostNameAndPort - size_t iBrk = strHostNameAndPort.rfind("]"); - if (iBrk != std::string::npos && strHostNameAndPort.find("[") == 0) + size_t iBrk = strHostNameAndPort.rfind(']'); + if (iBrk != std::string::npos && strHostNameAndPort.find('[') == 0) { m_strHostName = strHostNameAndPort.substr(1, iBrk-1); strHostNameAndPort.erase(0, iBrk+1); } // detect hostname:port/ or just :port/ if previous step found [IPv6] format - size_t iColon = strHostNameAndPort.rfind(":"); - if (iColon != std::string::npos && iColon == strHostNameAndPort.find(":")) + size_t iColon = strHostNameAndPort.rfind(':'); + if (iColon != std::string::npos && iColon == strHostNameAndPort.find(':')) { if (m_strHostName.empty()) m_strHostName = strHostNameAndPort.substr(0, iColon); @@ -405,8 +405,7 @@ const std::string CURL::GetFileNameWithoutPath() const inline void protectIPv6(std::string &hn) { - if (!hn.empty() && hn.find(":") != hn.rfind(":") - && hn.find(":") != std::string::npos) + if (!hn.empty() && hn.find(':') != hn.rfind(':') && hn.find(':') != std::string::npos) { hn = '[' + hn + ']'; } diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 2886a20446..727dbb09a0 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -310,8 +310,6 @@ std::string CUtil::GetTitleFromPath(const CURL& url, bool bIsFolder /* = false * URIUtils::RemoveSlashAtEnd(path); std::string strFilename = URIUtils::GetFileName(path); - std::string strHostname = url.GetHostName(); - #ifdef HAS_UPNP // UPNP if (url.IsProtocol("upnp")) @@ -501,7 +499,7 @@ void CUtil::RunShortcut(const char* szShortcutPath) { } -std::string CUtil::GetHomePath(std::string strTarget) +std::string CUtil::GetHomePath(const std::string& strTarget) { auto strPath = CEnvironment::getenv(strTarget); @@ -1032,8 +1030,8 @@ void CUtil::SplitExecFunction(const std::string &execString, std::string &functi { std::string paramString; - size_t iPos = execString.find("("); - size_t iPos2 = execString.rfind(")"); + size_t iPos = execString.find('('); + size_t iPos2 = execString.rfind(')'); if (iPos != std::string::npos && iPos2 != std::string::npos) { paramString = execString.substr(iPos + 1, iPos2 - iPos - 1); @@ -1965,7 +1963,7 @@ int CUtil::ScanArchiveForAssociatedItems(const std::string& strArchivePath, StringUtils::StartsWithNoCase(URIUtils::GetFileName(strPathInRar), CURL::Decode(videoNameNoExt)))) continue; - for (auto ext : item_exts) + for (const auto& ext : item_exts) { if (StringUtils::EqualsNoCase(strExt, ext)) { @@ -2394,3 +2392,20 @@ int CUtil::GetRandomNumber() #endif } +void CUtil::CopyUserDataIfNeeded(const std::string& strPath, + const std::string& file, + const std::string& destname) +{ + std::string destPath; + if (destname.empty()) + destPath = URIUtils::AddFileToFolder(strPath, file); + else + destPath = URIUtils::AddFileToFolder(strPath, destname); + + if (!CFile::Exists(destPath)) + { + // need to copy it across + std::string srcPath = URIUtils::AddFileToFolder("special://xbmc/userdata/", file); + CFile::Copy(srcPath, destPath); + } +} diff --git a/xbmc/Util.h b/xbmc/Util.h index d814150f1c..97986424ed 100644 --- a/xbmc/Util.h +++ b/xbmc/Util.h @@ -48,7 +48,8 @@ public: static std::string GetTitleFromPath(const std::string& strFileNameAndPath, bool bIsFolder = false); static void GetQualifiedFilename(const std::string &strBasePath, std::string &strFilename); static void RunShortcut(const char* szPath); - static std::string GetHomePath(std::string strTarget = "KODI_HOME"); // default target is "KODI_HOME" + static std::string GetHomePath( + const std::string& strTarget = "KODI_HOME"); // default target is "KODI_HOME" static bool ExcludeFileOrFolder(const std::string& strFileOrFolder, const std::vector<std::string>& regexps); static void GetFileAndProtocol(const std::string& strURL, std::string& strDir); static int GetDVDIfoTitle(const std::string& strPathFile); @@ -195,6 +196,12 @@ public: static int64_t ConvertMilliSecsToSecsInt(int64_t offset) { return offset / 1000; } static int64_t ConvertMilliSecsToSecsIntRounded(int64_t offset) { return ConvertMilliSecsToSecsInt(offset + 499); } + /** \brief Copy files from the application bundle over to the user data directory in Application Support/Kodi. + */ + static void CopyUserDataIfNeeded(const std::string& strPath, + const std::string& file, + const std::string& destname = ""); + #if !defined(TARGET_WINDOWS) private: static unsigned int s_randomSeed; diff --git a/xbmc/XBDateTime.cpp b/xbmc/XBDateTime.cpp index 89f4897f47..c5bd507893 100644 --- a/xbmc/XBDateTime.cpp +++ b/xbmc/XBDateTime.cpp @@ -703,7 +703,7 @@ bool CDateTime::SetFromDateString(const std::string &date) if (strMonth.empty()) return false; - size_t iPos2 = date.find(","); + size_t iPos2 = date.find(','); std::string strDay = (date.size() >= iPos) ? date.substr(iPos, iPos2-iPos) : ""; std::string strYear = date.substr(date.find(' ', iPos2) + 1); while (months[j] && StringUtils::CompareNoCase(strMonth, months[j]) != 0) @@ -922,7 +922,7 @@ bool CDateTime::SetFromW3CDate(const std::string &dateTime) { std::string date; - size_t posT = dateTime.find("T"); + size_t posT = dateTime.find('T'); if(posT != std::string::npos) date = dateTime.substr(0, posT); else @@ -950,7 +950,7 @@ bool CDateTime::SetFromW3CDateTime(const std::string &dateTime, bool ignoreTimez { std::string date, time, zone; - size_t posT = dateTime.find("T"); + size_t posT = dateTime.find('T'); if(posT != std::string::npos) { date = dateTime.substr(0, posT); diff --git a/xbmc/addons/Addon.h b/xbmc/addons/Addon.h index 6b72ca62c2..06ba3d3e46 100644 --- a/xbmc/addons/Addon.h +++ b/xbmc/addons/Addon.h @@ -107,6 +107,7 @@ public: CDateTime LastUpdated() const override { return m_addonInfo->LastUpdated(); } CDateTime LastUsed() const override { return m_addonInfo->LastUsed(); } std::string Origin() const override { return m_addonInfo->Origin(); } + std::string OriginName() const override { return m_addonInfo->OriginName(); } uint64_t PackageSize() const override { return m_addonInfo->PackageSize(); } const InfoMap& ExtraInfo() const override { return m_addonInfo->ExtraInfo(); } const std::vector<DependencyInfo>& GetDependencies() const override { return m_addonInfo->GetDependencies(); } diff --git a/xbmc/addons/AddonBindings.cmake b/xbmc/addons/AddonBindings.cmake index 11cf190d3f..b89478e6c7 100644 --- a/xbmc/addons/AddonBindings.cmake +++ b/xbmc/addons/AddonBindings.cmake @@ -8,5 +8,4 @@ set(CORE_ADDON_BINDINGS_FILES set(CORE_ADDON_BINDINGS_DIRS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-dev-kit/include/kodi/ - ${CORE_SOURCE_DIR}/xbmc/cores/VideoPlayer/Interface/Addon ) diff --git a/xbmc/addons/AddonDatabase.h b/xbmc/addons/AddonDatabase.h index b30203e859..db06243f40 100644 --- a/xbmc/addons/AddonDatabase.h +++ b/xbmc/addons/AddonDatabase.h @@ -96,9 +96,9 @@ public: RepoUpdateData() = default; - RepoUpdateData(CDateTime lastCheckedAt, - ADDON::AddonVersion lastCheckedVersion, - CDateTime nextCheckAt) + RepoUpdateData(const CDateTime& lastCheckedAt, + const ADDON::AddonVersion& lastCheckedVersion, + const CDateTime& nextCheckAt) : lastCheckedAt{lastCheckedAt}, lastCheckedVersion{lastCheckedVersion}, nextCheckAt{nextCheckAt} diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index 6fde91fd0a..4a68eab7c0 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -212,7 +212,7 @@ bool CAddonMgr::ReloadSettings(const std::string &id) std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetAvailableUpdates() const { std::vector<std::shared_ptr<IAddon>> availableUpdates = - GetAvailableUpdatesOrOutdatedAddons(false); + GetAvailableUpdatesOrOutdatedAddons(AddonCheckType::AVAILABLE_UPDATES); std::lock_guard<std::mutex> lock(m_lastAvailableUpdatesCountMutex); m_lastAvailableUpdatesCountAsString = std::to_string(availableUpdates.size()); @@ -228,11 +228,11 @@ const std::string& CAddonMgr::GetLastAvailableUpdatesCountAsString() const std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetOutdatedAddons() const { - return GetAvailableUpdatesOrOutdatedAddons(true); + return GetAvailableUpdatesOrOutdatedAddons(AddonCheckType::OUTDATED_ADDONS); } std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetAvailableUpdatesOrOutdatedAddons( - bool returnOutdatedAddons) const + AddonCheckType addonCheckType) const { CSingleLock lock(m_critSection); auto start = XbmcThreads::SystemClockMillis(); @@ -245,14 +245,7 @@ std::vector<std::shared_ptr<IAddon>> CAddonMgr::GetAvailableUpdatesOrOutdatedAdd GetAddonsForUpdate(installed); - if (returnOutdatedAddons) - { - addonRepos.BuildOutdatedList(installed, result); - } - else - { - addonRepos.BuildUpdateList(installed, result); - } + addonRepos.BuildUpdateOrOutdatedList(installed, result, addonCheckType); CLog::Log(LOGDEBUG, "CAddonMgr::GetAvailableUpdatesOrOutdatedAddons took %i ms", XbmcThreads::SystemClockMillis() - start); @@ -390,16 +383,17 @@ bool CAddonMgr::FindInstallableById(const std::string& addonId, AddonPtr& result if (GetAddon(addonId, addonToUpdate, ADDON_UNKNOWN, false)) { - return addonRepos.DoAddonUpdateCheck(addonToUpdate, result); + if (addonRepos.DoAddonUpdateCheck(addonToUpdate, result)) + return true; } // get the latest version from all repos if the - // addon is not installed yet (e.g. for addon select dialog) + // addon is up-to-date or not installed yet - CLog::Log( - LOGDEBUG, - "CAddonMgr::{}: addon {} is not installed. falling back to get latest version from ALL repos", - __FUNCTION__, addonId); + CLog::Log(LOGDEBUG, + "CAddonMgr::{}: addon {} is up-to-date or not installed. falling back to get latest " + "version from all repos", + __FUNCTION__, addonId); return addonRepos.GetLatestAddonVersionFromAllRepos(addonId, result); } @@ -550,7 +544,7 @@ void CAddonMgr::SortByDependencies(VECADDONS& updates) const // add to the end of sorted list of addons if (addToSortedList) { - sorted.emplace_back(std::move(addon)); + sorted.emplace_back(addon); it = updates.erase(it); } else @@ -898,7 +892,19 @@ bool CAddonMgr::IsAddonInstalled(const std::string& ID) bool CAddonMgr::IsAddonInstalled(const std::string& ID, const std::string& origin) const { AddonPtr tmp; - return (GetAddon(ID, tmp, ADDON_UNKNOWN, false) && tmp && tmp->Origin() == origin); + + if (GetAddon(ID, tmp, ADDON_UNKNOWN, false) && tmp) + { + if (tmp->Origin() == ORIGIN_SYSTEM) + { + return CAddonRepos::IsOfficialRepo(origin); + } + else + { + return tmp->Origin() == origin; + } + } + return false; } bool CAddonMgr::IsAddonInstalled(const std::string& ID, @@ -906,8 +912,19 @@ bool CAddonMgr::IsAddonInstalled(const std::string& ID, const AddonVersion& version) { AddonPtr tmp; - return (GetAddon(ID, tmp, ADDON_UNKNOWN, false) && tmp && tmp->Origin() == origin && - tmp->Version() == version); + + if (GetAddon(ID, tmp, ADDON_UNKNOWN, false) && tmp) + { + if (tmp->Origin() == ORIGIN_SYSTEM) + { + return CAddonRepos::IsOfficialRepo(origin) && tmp->Version() == version; + } + else + { + return tmp->Origin() == origin && tmp->Version() == version; + } + } + return false; } bool CAddonMgr::CanAddonBeInstalled(const AddonPtr& addon) diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h index 126ed3730a..dfce76af4a 100644 --- a/xbmc/addons/AddonManager.h +++ b/xbmc/addons/AddonManager.h @@ -26,6 +26,12 @@ namespace ADDON const std::string ADDON_PYTHON_EXT = "*.py"; + enum class AddonCheckType + { + OUTDATED_ADDONS, + AVAILABLE_UPDATES + }; + struct CAddonWithUpdate; /** @@ -242,6 +248,8 @@ namespace ADDON /* \brief Checks whether an addon is installed from a * particular origin repo + * \note if checked for an origin defined as official (i.e. repository.xbmc.org) + * this function will return true even if the addon is a shipped system add-on * \param ID id of the addon * \param origin origin repository id */ @@ -249,6 +257,8 @@ namespace ADDON /* \brief Checks whether an addon is installed from a * particular origin repo and version + * \note if checked for an origin defined as official (i.e. repository.xbmc.org) + * this function will return true even if the addon is a shipped system add-on * \param ID id of the addon * \param origin origin repository id * \param version the version of the addon @@ -507,7 +517,7 @@ namespace ADDON * \return vector filled with either available updates or outdated addons */ std::vector<std::shared_ptr<IAddon>> GetAvailableUpdatesOrOutdatedAddons( - bool returnOutdatedAddons) const; + AddonCheckType addonCheckType) const; bool GetAddonsInternal(const TYPE& type, VECADDONS& addons, diff --git a/xbmc/addons/AddonRepos.cpp b/xbmc/addons/AddonRepos.cpp index e7066b50a4..f73613c6a2 100644 --- a/xbmc/addons/AddonRepos.cpp +++ b/xbmc/addons/AddonRepos.cpp @@ -50,6 +50,14 @@ bool CAddonRepos::IsFromOfficialRepo(const std::shared_ptr<IAddon>& addon, std::any_of(officialRepoInfos.begin(), officialRepoInfos.end(), comparator); } +bool CAddonRepos::IsOfficialRepo(const std::string& repoId) +{ + return repoId == ORIGIN_SYSTEM || std::any_of(officialRepoInfos.begin(), officialRepoInfos.end(), + [&repoId](const RepoInfo& officialRepo) { + return repoId == officialRepo.m_repoId; + }); +} + bool CAddonRepos::LoadAddonsFromDatabase(const CAddonDatabase& database) { return LoadAddonsFromDatabase(database, "", nullptr); @@ -175,32 +183,20 @@ void CAddonRepos::AddAddonIfLatest( } } -void CAddonRepos::BuildUpdateList(const std::vector<std::shared_ptr<IAddon>>& installed, - std::vector<std::shared_ptr<IAddon>>& updates) const -{ - BuildUpdateOrOutdatedList(installed, updates, false); -} - -void CAddonRepos::BuildOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed, - std::vector<std::shared_ptr<IAddon>>& outdated) const -{ - BuildUpdateOrOutdatedList(installed, outdated, true); -} - void CAddonRepos::BuildUpdateOrOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed, std::vector<std::shared_ptr<IAddon>>& result, - bool returnOutdatedAddons) const + AddonCheckType addonCheckType) const { std::shared_ptr<IAddon> update; CLog::Log(LOGDEBUG, "CAddonRepos::{}: Building {} list from installed add-ons", __func__, - returnOutdatedAddons ? "outdated" : "update"); + addonCheckType == AddonCheckType::OUTDATED_ADDONS ? "outdated" : "update"); for (const auto& addon : installed) { if (DoAddonUpdateCheck(addon, update)) { - result.emplace_back(returnOutdatedAddons ? addon : update); + result.emplace_back(addonCheckType == AddonCheckType::OUTDATED_ADDONS ? addon : update); } } } @@ -227,8 +223,8 @@ void CAddonRepos::BuildAddonsWithUpdateList( bool CAddonRepos::DoAddonUpdateCheck(const std::shared_ptr<IAddon>& addon, std::shared_ptr<IAddon>& update) const { - CLog::Log(LOGDEBUG, "ADDONS: update check: addonID = {} / Origin = {}", addon->ID(), - addon->Origin()); + CLog::Log(LOGDEBUG, "ADDONS: update check: addonID = {} / Origin = {} / Version = {}", + addon->ID(), addon->Origin(), addon->Version().asString()); update.reset(); diff --git a/xbmc/addons/AddonRepos.h b/xbmc/addons/AddonRepos.h index 4073744a57..3e241d9a9f 100644 --- a/xbmc/addons/AddonRepos.h +++ b/xbmc/addons/AddonRepos.h @@ -21,6 +21,7 @@ class CAddonDatabase; class CAddonMgr; class CRepository; class IAddon; +enum class AddonCheckType; enum class CheckAddonPath { @@ -75,22 +76,17 @@ public: /*! * \brief Build the list of addons to be updated depending on defined rules + * or the list of outdated addons * \param installed vector of all addons installed on the system that are * checked for an update - * \param[out] updates list of addon versions that are going to be installed + * \param[in] addonCheckType build list of OUTDATED or UPDATES + * \param[out] result list of addon versions that are going to be installed + * or are outdated */ - void BuildUpdateList(const std::vector<std::shared_ptr<IAddon>>& installed, - std::vector<std::shared_ptr<IAddon>>& updates) const; + void BuildUpdateOrOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed, + std::vector<std::shared_ptr<IAddon>>& result, + AddonCheckType addonCheckType) const; - /*! - * \brief Build the list of addons that are outdated and have an update - * available depending on defined rules - * \param installed vector of all addons installed on the system that are - * checked for an update - * \param[out] outdated list of addon versions that have an update available - */ - void BuildOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed, - std::vector<std::shared_ptr<IAddon>>& outdated) const; /*! * \brief Build the list of outdated addons and their available updates. @@ -117,6 +113,14 @@ public: CheckAddonPath checkAddonPath); /*! + * \brief Checks if the passed in repository is defined as official repo + * which includes ORIGIN_SYSTEM + * \param repoId repository id to check + * \return true if the repository id is defined as official, false otherwise + */ + static bool IsOfficialRepo(const std::string& repoId); + + /*! * \brief Check if an update is available for a single addon * \param addon that is checked for an update * \param[out] update pointer to the found update @@ -188,14 +192,6 @@ public: private: /*! - * \brief Executor for BuildUpdateList() and BuildOutdatedList() - * \sa BuildUpdateList() BuildOutdatedList() - */ - void BuildUpdateOrOutdatedList(const std::vector<std::shared_ptr<IAddon>>& installed, - std::vector<std::shared_ptr<IAddon>>& result, - bool returnOutdatedAddons) const; - - /*! * \brief Load the map of addons * \note this function should only by called from publicly exposed wrappers * \return true on success, false otherwise diff --git a/xbmc/addons/AddonStatusHandler.cpp b/xbmc/addons/AddonStatusHandler.cpp index bae06e89fb..1184690a8f 100644 --- a/xbmc/addons/AddonStatusHandler.cpp +++ b/xbmc/addons/AddonStatusHandler.cpp @@ -21,6 +21,8 @@ #include "utils/Variant.h" #include "utils/log.h" +#include <utility> + using namespace KODI::MESSAGING; namespace ADDON @@ -48,7 +50,7 @@ CAddonStatusHandler::CAddonStatusHandler(const std::string &addonID, ADDON_STATU CLog::Log(LOGINFO, "Called Add-on status handler for '%u' of clientName:%s, clientID:%s (same Thread=%s)", status, m_addon->Name().c_str(), m_addon->ID().c_str(), sameThread ? "yes" : "no"); m_status = status; - m_message = message; + m_message = std::move(message); if (sameThread) { diff --git a/xbmc/addons/AddonSystemSettings.cpp b/xbmc/addons/AddonSystemSettings.cpp index cd9f4b1654..ca15b941ff 100644 --- a/xbmc/addons/AddonSystemSettings.cpp +++ b/xbmc/addons/AddonSystemSettings.cpp @@ -45,7 +45,7 @@ CAddonSystemSettings& CAddonSystemSettings::GetInstance() return inst; } -void CAddonSystemSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CAddonSystemSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting->GetId() == CSettings::SETTING_ADDONS_MANAGE_DEPENDENCIES) { @@ -59,7 +59,7 @@ void CAddonSystemSettings::OnSettingAction(std::shared_ptr<const CSetting> setti } } -void CAddonSystemSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CAddonSystemSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { using namespace KODI::MESSAGING::HELPERS; diff --git a/xbmc/addons/AddonSystemSettings.h b/xbmc/addons/AddonSystemSettings.h index 6f7f6e4744..dfa619aa9e 100644 --- a/xbmc/addons/AddonSystemSettings.h +++ b/xbmc/addons/AddonSystemSettings.h @@ -31,8 +31,8 @@ class CAddonSystemSettings : public ISettingCallback { public: static CAddonSystemSettings& GetInstance(); - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; bool GetActive(const TYPE& type, AddonPtr& addon); bool SetActive(const TYPE& type, const std::string& addonID); diff --git a/xbmc/addons/AddonVersion.cpp b/xbmc/addons/AddonVersion.cpp index f87f6aaece..844d21313d 100644 --- a/xbmc/addons/AddonVersion.cpp +++ b/xbmc/addons/AddonVersion.cpp @@ -166,7 +166,7 @@ namespace ADDON bool AddonVersion::SplitFileName(std::string& ID, std::string& version, const std::string& filename) { - size_t dpos = filename.rfind("-"); + size_t dpos = filename.rfind('-'); if (dpos == std::string::npos) return false; ID = filename.substr(0, dpos); diff --git a/xbmc/addons/IAddon.h b/xbmc/addons/IAddon.h index 743ba9393f..ae69e67902 100644 --- a/xbmc/addons/IAddon.h +++ b/xbmc/addons/IAddon.h @@ -60,6 +60,7 @@ namespace ADDON virtual CDateTime LastUpdated() const =0; virtual CDateTime LastUsed() const =0; virtual std::string Origin() const =0; + virtual std::string OriginName() const = 0; virtual uint64_t PackageSize() const =0; virtual const InfoMap &ExtraInfo() const =0; virtual bool HasSettings() =0; diff --git a/xbmc/addons/LanguageResource.cpp b/xbmc/addons/LanguageResource.cpp index 41c301ffc8..ccc5e29b70 100644 --- a/xbmc/addons/LanguageResource.cpp +++ b/xbmc/addons/LanguageResource.cpp @@ -67,7 +67,7 @@ CLanguageResource::CLanguageResource(const AddonInfoPtr& addonInfo) * <token>Le</token> * ... */ - for (auto values : sorttokensElement->GetValues()) + for (const auto& values : sorttokensElement->GetValues()) { /* Second loop goes around the row parts, e.g. * separators = "'" diff --git a/xbmc/addons/PluginSource.cpp b/xbmc/addons/PluginSource.cpp index 16fdfbb19e..c8cdf5f8a5 100644 --- a/xbmc/addons/PluginSource.cpp +++ b/xbmc/addons/PluginSource.cpp @@ -22,7 +22,7 @@ CPluginSource::CPluginSource(const AddonInfoPtr& addonInfo, TYPE addonType) : CA { std::string provides = addonInfo->Type(addonType)->GetValue("provides").asString(); - for (auto values : addonInfo->Type(addonType)->GetValues()) + for (const auto& values : addonInfo->Type(addonType)->GetValues()) { if (values.first != "medialibraryscanpath") continue; diff --git a/xbmc/addons/Repository.cpp b/xbmc/addons/Repository.cpp index 76764c59dc..c1fcf19607 100644 --- a/xbmc/addons/Repository.cpp +++ b/xbmc/addons/Repository.cpp @@ -108,7 +108,7 @@ CRepository::CRepository(const AddonInfoPtr& addonInfo) if (addonver) version = addonver->Version(); - for (auto element : Type(ADDON_REPOSITORY)->GetElements("dir")) + for (const auto& element : Type(ADDON_REPOSITORY)->GetElements("dir")) { DirInfo dir = ParseDirConfiguration(element.second); if ((dir.minversion.empty() || version >= dir.minversion) && diff --git a/xbmc/addons/RepositoryUpdater.cpp b/xbmc/addons/RepositoryUpdater.cpp index a197562d35..9bac6bd6ad 100644 --- a/xbmc/addons/RepositoryUpdater.cpp +++ b/xbmc/addons/RepositoryUpdater.cpp @@ -173,7 +173,7 @@ void CRepositoryUpdater::OnTimeout() CheckForUpdates(); } -void CRepositoryUpdater::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CRepositoryUpdater::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting->GetId() == CSettings::SETTING_ADDONS_AUTOUPDATES) ScheduleUpdate(); diff --git a/xbmc/addons/RepositoryUpdater.h b/xbmc/addons/RepositoryUpdater.h index 92a57446fa..c99ad929b2 100644 --- a/xbmc/addons/RepositoryUpdater.h +++ b/xbmc/addons/RepositoryUpdater.h @@ -57,7 +57,7 @@ public: CDateTime LastUpdated() const; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; struct RepositoryUpdated { }; diff --git a/xbmc/addons/Scraper.cpp b/xbmc/addons/Scraper.cpp index e24b02e155..c9b9bb732f 100644 --- a/xbmc/addons/Scraper.cpp +++ b/xbmc/addons/Scraper.cpp @@ -337,7 +337,7 @@ std::string CScraper::GetPathSettingsAsJSON() return EmptyPathSettings; CSettingsValueFlatJsonSerializer jsonSerializer; - const auto json = jsonSerializer.SerializeValues(GetSettings()->GetSettingsManager()); + auto json = jsonSerializer.SerializeValues(GetSettings()->GetSettingsManager()); if (json.empty()) return EmptyPathSettings; @@ -609,7 +609,7 @@ template<> CMusicAlbumInfo FromFileItem<CMusicAlbumInfo>(const CFileItem &item) { CMusicAlbumInfo info; - std::string sTitle = item.GetLabel(); + const std::string& sTitle = item.GetLabel(); std::string sArtist = item.GetProperty("album.artist").asString(); std::string sAlbumName; if (!sArtist.empty()) @@ -641,7 +641,7 @@ template<> CMusicArtistInfo FromFileItem<CMusicArtistInfo>(const CFileItem &item) { CMusicArtistInfo info; - std::string sTitle = item.GetLabel(); + const std::string& sTitle = item.GetLabel(); CScraperUrl url; url.AppendUrl(CScraperUrl::SUrlEntry(item.GetDynPath())); @@ -675,7 +675,7 @@ static std::vector<T> PythonFind(const std::string &ID, if (XFILE::CDirectory::GetDirectory(str.str(), items, "", DIR_FLAG_DEFAULTS)) { - for (auto it : items) + for (const auto& it : items) result.emplace_back(std::move(FromFileItem<T>(*it))); } @@ -836,7 +836,7 @@ template<> void DetailsFromFileItem<CVideoInfoTag>(const CFileItem &item, CVideoInfoTag &tag) { if (item.HasVideoInfoTag()) - tag = std::move(*item.GetVideoInfoTag()); + tag = *item.GetVideoInfoTag(); } template<class T> @@ -1276,7 +1276,7 @@ EPISODELIST CScraper::GetEpisodeList(XFILE::CCurlFile &fcurl, const CScraperUrl XMLUtils::GetString(pxeMovie, "epnum", strEpNum) && !strEpNum.empty()) { CScraperUrl &scurlEp(ep.cScraperUrl); - size_t dot = strEpNum.find("."); + size_t dot = strEpNum.find('.'); ep.iEpisode = atoi(strEpNum.c_str()); ep.iSubepisode = (dot != std::string::npos) ? atoi(strEpNum.substr(dot + 1).c_str()) : 0; std::string title; diff --git a/xbmc/addons/Service.cpp b/xbmc/addons/Service.cpp index 3f409c4ab3..144c059ece 100644 --- a/xbmc/addons/Service.cpp +++ b/xbmc/addons/Service.cpp @@ -110,7 +110,7 @@ void CServiceAddonManager::Stop(const std::string& addonId) } } -void CServiceAddonManager::Stop(std::map<std::string, int>::value_type service) +void CServiceAddonManager::Stop(const std::map<std::string, int>::value_type& service) { CLog::Log(LOGDEBUG, "CServiceAddonManager: stopping %s.", service.first.c_str()); if (!CScriptInvocationManager::GetInstance().Stop(service.second)) diff --git a/xbmc/addons/Service.h b/xbmc/addons/Service.h index bd67ce34cd..c997ef01b3 100644 --- a/xbmc/addons/Service.h +++ b/xbmc/addons/Service.h @@ -50,7 +50,7 @@ namespace ADDON private: void OnEvent(const AddonEvent& event); - void Stop(std::map<std::string, int>::value_type service); + void Stop(const std::map<std::string, int>::value_type& service); CAddonMgr& m_addonMgr; CCriticalSection m_criticalSection; diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp index 2ffb02885d..4de5e4638c 100644 --- a/xbmc/addons/Skin.cpp +++ b/xbmc/addons/Skin.cpp @@ -156,7 +156,7 @@ CSkinInfo::CSkinInfo( CSkinInfo::CSkinInfo(const AddonInfoPtr& addonInfo) : CAddon(addonInfo, ADDON_SKIN) { - for (auto values : Type(ADDON_SKIN)->GetValues()) + for (const auto& values : Type(ADDON_SKIN)->GetValues()) { if (values.first != "res") continue; @@ -392,7 +392,10 @@ void CSkinInfo::OnPostInstall(bool update, bool modal) } } -void CSkinInfo::SettingOptionsSkinColorsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CSkinInfo::SettingOptionsSkinColorsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { if (!g_SkinInfo) return; @@ -436,7 +439,10 @@ void CSkinInfo::SettingOptionsSkinColorsFiller(SettingConstPtr setting, std::vec } } -void CSkinInfo::SettingOptionsSkinFontsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CSkinInfo::SettingOptionsSkinFontsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { if (!g_SkinInfo) return; @@ -488,7 +494,10 @@ void CSkinInfo::SettingOptionsSkinFontsFiller(SettingConstPtr setting, std::vect current = list[0].value; } -void CSkinInfo::SettingOptionsSkinThemesFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CSkinInfo::SettingOptionsSkinThemesFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { // get the chosen theme and remove the extension from the current theme (backward compat) std::string settingValue = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); @@ -517,7 +526,10 @@ void CSkinInfo::SettingOptionsSkinThemesFiller(SettingConstPtr setting, std::vec } } -void CSkinInfo::SettingOptionsStartupWindowsFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CSkinInfo::SettingOptionsStartupWindowsFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { if (!g_SkinInfo) return; diff --git a/xbmc/addons/Skin.h b/xbmc/addons/Skin.h index 9a44decb23..399c83b91b 100644 --- a/xbmc/addons/Skin.h +++ b/xbmc/addons/Skin.h @@ -169,10 +169,22 @@ public: void ToggleDebug(); const INFO::CSkinVariableString* CreateSkinVariable(const std::string& name, int context); - static void SettingOptionsSkinColorsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsSkinFontsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsSkinThemesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsStartupWindowsFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); + static void SettingOptionsSkinColorsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsSkinFontsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsSkinThemesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsStartupWindowsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); /*! \brief Don't handle skin settings like normal addon settings */ diff --git a/xbmc/addons/VFSEntry.cpp b/xbmc/addons/VFSEntry.cpp index 8ed59f8015..ae6764fc8b 100644 --- a/xbmc/addons/VFSEntry.cpp +++ b/xbmc/addons/VFSEntry.cpp @@ -14,6 +14,8 @@ #include "utils/StringUtils.h" #include "utils/log.h" +#include <utility> + #if defined(TARGET_WINDOWS) #ifndef S_IFLNK #define S_IFLNK 0120000 @@ -563,8 +565,8 @@ bool CVFSEntry::ContainsFiles(const CURL& url, CFileItemList& items) return true; } -CVFSEntryIFileWrapper::CVFSEntryIFileWrapper(VFSEntryPtr ptr) : - m_context(nullptr), m_addon(ptr) +CVFSEntryIFileWrapper::CVFSEntryIFileWrapper(VFSEntryPtr ptr) + : m_context(nullptr), m_addon(std::move(ptr)) { } @@ -675,8 +677,7 @@ bool CVFSEntryIFileWrapper::Rename(const CURL& url, const CURL& url2) return m_addon->Rename(url, url2); } -CVFSEntryIDirectoryWrapper::CVFSEntryIDirectoryWrapper(VFSEntryPtr ptr) : - m_addon(ptr) +CVFSEntryIDirectoryWrapper::CVFSEntryIDirectoryWrapper(VFSEntryPtr ptr) : m_addon(std::move(ptr)) { } diff --git a/xbmc/addons/VFSEntry.h b/xbmc/addons/VFSEntry.h index 7fbe30fa38..a16bfc9fb2 100644 --- a/xbmc/addons/VFSEntry.h +++ b/xbmc/addons/VFSEntry.h @@ -13,6 +13,8 @@ #include "filesystem/IFile.h" #include "filesystem/IFileDirectory.h" +#include <utility> + namespace ADDON { @@ -256,7 +258,10 @@ namespace ADDON public: //! \brief The constructor initializes the reference to the wrapped CVFSEntry. //! \param ptr The CVFSEntry to wrap. - explicit CVFSEntryIFileDirectoryWrapper(VFSEntryPtr ptr) : CVFSEntryIDirectoryWrapper(ptr) {} + explicit CVFSEntryIFileDirectoryWrapper(VFSEntryPtr ptr) + : CVFSEntryIDirectoryWrapper(std::move(ptr)) + { + } //! \brief Empty destructor. ~CVFSEntryIFileDirectoryWrapper() override = default; diff --git a/xbmc/addons/addoninfo/AddonExtensions.cpp b/xbmc/addons/addoninfo/AddonExtensions.cpp index f380e4a7a2..61df9289e0 100644 --- a/xbmc/addons/addoninfo/AddonExtensions.cpp +++ b/xbmc/addons/addoninfo/AddonExtensions.cpp @@ -12,9 +12,9 @@ using namespace ADDON; const SExtValue CAddonExtensions::GetValue(const std::string& id) const { - for (auto values : m_values) + for (const auto& values : m_values) { - for (auto value : values.second) + for (const auto& value : values.second) { if (value.first == id) return value.second; @@ -45,7 +45,7 @@ const EXT_ELEMENTS CAddonExtensions::GetElements(const std::string& id) const return m_children; EXT_ELEMENTS children; - for (auto child : m_children) + for (const auto& child : m_children) { if (child.first == id) children.push_back(std::make_pair(child.first, child.second)); diff --git a/xbmc/addons/addoninfo/AddonExtensions.h b/xbmc/addons/addoninfo/AddonExtensions.h index 694a9dd6e8..0a0c3aa8fd 100644 --- a/xbmc/addons/addoninfo/AddonExtensions.h +++ b/xbmc/addons/addoninfo/AddonExtensions.h @@ -44,7 +44,7 @@ public: const SExtValue GetValue(const std::string& id) const { - for (auto value : *this) + for (const auto& value : *this) { if (value.first == id) return value.second; diff --git a/xbmc/addons/addoninfo/AddonInfo.cpp b/xbmc/addons/addoninfo/AddonInfo.cpp index 33ff2198ef..c32bbc9fc3 100644 --- a/xbmc/addons/addoninfo/AddonInfo.cpp +++ b/xbmc/addons/addoninfo/AddonInfo.cpp @@ -9,6 +9,9 @@ #include "AddonInfo.h" #include "LangInfo.h" +#include "ServiceBroker.h" +#include "addons/AddonManager.h" +#include "addons/IAddon.h" #include "guilib/LocalizeStrings.h" #include <algorithm> @@ -70,6 +73,19 @@ static const TypeMapping types[] = }; // clang-format on +const std::string& CAddonInfo::OriginName() const +{ + if (!m_originName) + { + ADDON::AddonPtr origin; + if (CServiceBroker::GetAddonMgr().GetAddon(m_origin, origin, ADDON::ADDON_UNKNOWN, false)) + m_originName = std::make_unique<std::string>(origin->Name()); + else + m_originName = std::make_unique<std::string>(); // remember we tried to fetch the name + } + return *m_originName; +} + /** * static public helper functions * diff --git a/xbmc/addons/addoninfo/AddonInfo.h b/xbmc/addons/addoninfo/AddonInfo.h index 56fa86d0d9..31dc2adcd5 100644 --- a/xbmc/addons/addoninfo/AddonInfo.h +++ b/xbmc/addons/addoninfo/AddonInfo.h @@ -16,6 +16,7 @@ #include <memory> #include <string> #include <unordered_map> +#include <utility> #include <vector> namespace ADDON @@ -78,11 +79,14 @@ struct DependencyInfo std::string id; AddonVersion versionMin, version; bool optional; - DependencyInfo(std::string id, AddonVersion versionMin, AddonVersion version, bool optional) - : id(id) - , versionMin(versionMin.empty() ? version : versionMin) - , version(version) - , optional(optional) + DependencyInfo(std::string id, + const AddonVersion& versionMin, + const AddonVersion& version, + bool optional) + : id(std::move(id)), + versionMin(versionMin.empty() ? version : versionMin), + version(version), + optional(optional) { } @@ -196,6 +200,8 @@ public: return GetTranslatedText(m_lifecycleStateDescription); } const std::string& Origin() const { return m_origin; } + const std::string& OriginName() const; + const InfoMap& ExtraInfo() const { return m_extrainfo; } bool MeetsVersion(const AddonVersion& versionMin, const AddonVersion& version) const; @@ -246,6 +252,7 @@ private: CDateTime m_lastUpdated; CDateTime m_lastUsed; std::string m_origin; + mutable std::unique_ptr<std::string> m_originName; // @todo use std::optional once we use c++17 uint64_t m_packageSize = 0; std::string m_libname; InfoMap m_extrainfo; diff --git a/xbmc/addons/addoninfo/AddonInfoBuilder.cpp b/xbmc/addons/addoninfo/AddonInfoBuilder.cpp index 75b61105f6..1b6a9b5533 100644 --- a/xbmc/addons/addoninfo/AddonInfoBuilder.cpp +++ b/xbmc/addons/addoninfo/AddonInfoBuilder.cpp @@ -46,7 +46,7 @@ AddonInfoPtr CAddonInfoBuilder::Generate(const std::string& id, TYPE type) } AddonInfoPtr addon = std::make_shared<CAddonInfo>(); - addon->m_id = std::move(id); + addon->m_id = id; addon->m_mainType = type; return addon; } @@ -418,7 +418,9 @@ bool CAddonInfoBuilder::ParseXML(const AddonInfoPtr& addon, const TiXmlElement* return true; } -bool CAddonInfoBuilder::ParseXMLTypes(CAddonType& addonType, AddonInfoPtr info, const TiXmlElement* child) +bool CAddonInfoBuilder::ParseXMLTypes(CAddonType& addonType, + const AddonInfoPtr& info, + const TiXmlElement* child) { if (child) { diff --git a/xbmc/addons/addoninfo/AddonInfoBuilder.h b/xbmc/addons/addoninfo/AddonInfoBuilder.h index 2fe4c3e974..e29471ac5f 100644 --- a/xbmc/addons/addoninfo/AddonInfoBuilder.h +++ b/xbmc/addons/addoninfo/AddonInfoBuilder.h @@ -11,6 +11,8 @@ #include "addons/Repository.h" #include "addons/addoninfo/AddonInfo.h" +#include <utility> + class TiXmlElement; namespace ADDON @@ -40,7 +42,10 @@ public: void SetForum(std::string forum) { m_addonInfo->m_forum = std::move(forum); } void SetEMail(std::string email) { m_addonInfo->m_email = std::move(email); } void SetIcon(std::string icon) { m_addonInfo->m_icon = std::move(icon); } - void SetArt(std::string type, std::string value) { m_addonInfo->m_art[type] = value; } + void SetArt(const std::string& type, std::string value) + { + m_addonInfo->m_art[type] = std::move(value); + } void SetArt(std::map<std::string, std::string> art) { m_addonInfo->m_art = std::move(art); } void SetScreenshots(std::vector<std::string> screenshots) { m_addonInfo->m_screenshots = std::move(screenshots); } void SetChangelog(std::string changelog) { m_addonInfo->m_changelog.insert(std::pair<std::string, std::string>("unk", std::move(changelog))); } @@ -51,8 +56,8 @@ public: } void SetPath(std::string path) { m_addonInfo->m_path = std::move(path); } void SetLibName(std::string libname) { m_addonInfo->m_libname = std::move(libname); } - void SetVersion(AddonVersion version) { m_addonInfo->m_version = std::move(version); } - void SetMinVersion(AddonVersion minversion) { m_addonInfo->m_minversion = std::move(minversion); } + void SetVersion(const AddonVersion& version) { m_addonInfo->m_version = version; } + void SetMinVersion(const AddonVersion& minversion) { m_addonInfo->m_minversion = minversion; } void SetDependencies(std::vector<DependencyInfo> dependencies) { m_addonInfo->m_dependencies = std::move(dependencies); } void SetExtrainfo(InfoMap extrainfo) { @@ -87,7 +92,9 @@ public: private: static bool ParseXML(const AddonInfoPtr& addon, const TiXmlElement* element, const std::string& addonPath, const CRepository::DirInfo& repo = {}); - static bool ParseXMLTypes(CAddonType& addonType, AddonInfoPtr info, const TiXmlElement* child); + static bool ParseXMLTypes(CAddonType& addonType, + const AddonInfoPtr& info, + const TiXmlElement* child); static bool ParseXMLExtension(CAddonExtensions& addonExt, const TiXmlElement* element); static bool GetTextList(const TiXmlElement* element, const std::string& tag, std::unordered_map<std::string, std::string>& translatedValues); static const char* GetPlatformLibraryName(const TiXmlElement* element); diff --git a/xbmc/addons/addoninfo/AddonType.cpp b/xbmc/addons/addoninfo/AddonType.cpp index e17d82ed88..0df7dda4f0 100644 --- a/xbmc/addons/addoninfo/AddonType.cpp +++ b/xbmc/addons/addoninfo/AddonType.cpp @@ -43,7 +43,7 @@ void CAddonType::SetProvides(const std::string& content) if (GetValue("provides").empty()) Insert("provides", content); - for (auto provide : StringUtils::Split(content, ' ')) + for (const auto& provide : StringUtils::Split(content, ' ')) { TYPE content = CAddonInfo::TranslateSubContent(provide); if (content != ADDON_UNKNOWN) diff --git a/xbmc/addons/binary-addons/AddonDll.cpp b/xbmc/addons/binary-addons/AddonDll.cpp index 707ad85abd..d61a60d8a2 100644 --- a/xbmc/addons/binary-addons/AddonDll.cpp +++ b/xbmc/addons/binary-addons/AddonDll.cpp @@ -11,6 +11,7 @@ #include "ServiceBroker.h" #include "addons/AddonStatusHandler.h" #include "addons/binary-addons/BinaryAddonBase.h" +#include "addons/binary-addons/BinaryAddonManager.h" #include "addons/settings/AddonSettings.h" #include "events/EventLog.h" #include "events/NotificationEvent.h" @@ -21,17 +22,21 @@ #include "utils/Variant.h" #include "utils/log.h" +#include <utility> + using namespace KODI::MESSAGING; namespace ADDON { CAddonDll::CAddonDll(const AddonInfoPtr& addonInfo, BinaryAddonBasePtr addonBase) - : CAddon(addonInfo, addonInfo->MainType()), m_binaryAddonBase(addonBase) + : CAddon(addonInfo, addonInfo->MainType()), m_binaryAddonBase(std::move(addonBase)) { } -CAddonDll::CAddonDll(const AddonInfoPtr& addonInfo, TYPE addonType) : CAddon(addonInfo, addonType) +CAddonDll::CAddonDll(const AddonInfoPtr& addonInfo, TYPE addonType) + : CAddon(addonInfo, addonType), + m_binaryAddonBase(CServiceBroker::GetBinaryAddonManager().GetRunningAddonBase(addonInfo->ID())) { } @@ -206,7 +211,8 @@ void CAddonDll::Destroy() /* Unload library file */ if (m_pDll) { - m_pDll->Destroy(); + if (m_interface.toAddon->destroy) + m_interface.toAddon->destroy(); m_pDll->Unload(); } @@ -326,11 +332,6 @@ AddonVersion CAddonDll::GetTypeMinVersionDll(int type) const return AddonVersion(m_pDll ? m_pDll->GetAddonTypeMinVersion(type) : nullptr); } -ADDON_STATUS CAddonDll::GetStatus() -{ - return m_pDll->GetStatus(); -} - void CAddonDll::SaveSettings() { // must save first, as TransferSettings() reloads saved settings! @@ -341,6 +342,9 @@ void CAddonDll::SaveSettings() ADDON_STATUS CAddonDll::TransferSettings() { + if (!m_interface.toAddon->set_setting) + return ADDON_STATUS_NOT_IMPLEMENTED; + bool restart = false; ADDON_STATUS reportStatus = ADDON_STATUS_OK; @@ -351,13 +355,13 @@ ADDON_STATUS CAddonDll::TransferSettings() auto settings = GetSettings(); if (settings != nullptr) { - for (auto section : settings->GetSections()) + for (const auto& section : settings->GetSections()) { - for (auto category : section->GetCategories()) + for (const auto& category : section->GetCategories()) { - for (auto group : category->GetGroups()) + for (const auto& group : category->GetGroups()) { - for (auto setting : group->GetSettings()) + for (const auto& setting : group->GetSettings()) { ADDON_STATUS status = ADDON_STATUS_OK; const char* id = setting->GetId().c_str(); @@ -366,32 +370,33 @@ ADDON_STATUS CAddonDll::TransferSettings() case SettingType::Boolean: { bool tmp = std::static_pointer_cast<CSettingBool>(setting)->GetValue(); - status = m_pDll->SetSetting(id, &tmp); + status = m_interface.toAddon->set_setting(id, &tmp); break; } case SettingType::Integer: { int tmp = std::static_pointer_cast<CSettingInt>(setting)->GetValue(); - status = m_pDll->SetSetting(id, &tmp); + status = m_interface.toAddon->set_setting(id, &tmp); break; } case SettingType::Number: { float tmpf = static_cast<float>(std::static_pointer_cast<CSettingNumber>(setting)->GetValue()); - status = m_pDll->SetSetting(id, &tmpf); + status = m_interface.toAddon->set_setting(id, &tmpf); break; } case SettingType::String: - status = m_pDll->SetSetting(id, std::static_pointer_cast<CSettingString>(setting)->GetValue().c_str()); + status = m_interface.toAddon->set_setting( + id, std::static_pointer_cast<CSettingString>(setting)->GetValue().c_str()); break; default: // log unknowns as an error, but go ahead and transfer the string CLog::Log(LOGERROR, "Unknown setting type of '%s' for %s", id, Name().c_str()); - status = m_pDll->SetSetting(id, setting->ToString().c_str()); + status = m_interface.toAddon->set_setting(id, setting->ToString().c_str()); break; } diff --git a/xbmc/addons/binary-addons/AddonDll.h b/xbmc/addons/binary-addons/AddonDll.h index 474b271097..1bb8810dd2 100644 --- a/xbmc/addons/binary-addons/AddonDll.h +++ b/xbmc/addons/binary-addons/AddonDll.h @@ -46,11 +46,9 @@ class CAddonDll : public CAddon { public: CAddonDll(const AddonInfoPtr& addonInfo, BinaryAddonBasePtr addonBase); - explicit CAddonDll(const AddonInfoPtr& addonInfo, TYPE addonType); + CAddonDll(const AddonInfoPtr& addonInfo, TYPE addonType); ~CAddonDll() override; - virtual ADDON_STATUS GetStatus(); - // Implementation of IAddon via CAddon std::string LibPath() const override; diff --git a/xbmc/addons/binary-addons/BinaryAddonManager.cpp b/xbmc/addons/binary-addons/BinaryAddonManager.cpp index 7c8caca427..8678239d72 100644 --- a/xbmc/addons/binary-addons/BinaryAddonManager.cpp +++ b/xbmc/addons/binary-addons/BinaryAddonManager.cpp @@ -62,13 +62,24 @@ void CBinaryAddonManager::ReleaseAddonBase(const BinaryAddonBasePtr& addonBase, m_runningAddons.erase(addon); } +BinaryAddonBasePtr CBinaryAddonManager::GetRunningAddonBase(const std::string& addonId) const +{ + CSingleLock lock(m_critSection); + + const auto& addonInstances = m_runningAddons.find(addonId); + if (addonInstances != m_runningAddons.end()) + return addonInstances->second; + + return nullptr; +} + AddonPtr CBinaryAddonManager::GetRunningAddon(const std::string& addonId) const { CSingleLock lock(m_critSection); - auto addon = m_runningAddons.find(addonId); - if (addon != m_runningAddons.end()) - return addon->second->GetActiveAddon(); + const BinaryAddonBasePtr base = GetRunningAddonBase(addonId); + if (base) + return base->GetActiveAddon(); return nullptr; } diff --git a/xbmc/addons/binary-addons/BinaryAddonManager.h b/xbmc/addons/binary-addons/BinaryAddonManager.h index 65d5ce4f90..a6328e1758 100644 --- a/xbmc/addons/binary-addons/BinaryAddonManager.h +++ b/xbmc/addons/binary-addons/BinaryAddonManager.h @@ -62,6 +62,15 @@ namespace ADDON void ReleaseAddonBase(const BinaryAddonBasePtr& addonBase, IAddonInstanceHandler* handler); /*! + * @brief Get running addon base class for a given addon id. + * + * @param[in] addonId the addon id + * @return running addon base class if found, nullptr otherwise. + * + */ + BinaryAddonBasePtr GetRunningAddonBase(const std::string& addonId) const; + + /*! * @brief Used from other addon manager to get active addon over a from him * created CAddonDll. * diff --git a/xbmc/addons/binary-addons/DllAddon.h b/xbmc/addons/binary-addons/DllAddon.h index f8d90c890d..d5b5e48fd0 100644 --- a/xbmc/addons/binary-addons/DllAddon.h +++ b/xbmc/addons/binary-addons/DllAddon.h @@ -15,11 +15,7 @@ class DllAddonInterface { public: virtual ~DllAddonInterface() = default; - virtual void GetAddon(void* pAddon) =0; virtual ADDON_STATUS Create(void* cb, const char* globalApiVersion, void* info) = 0; - virtual void Destroy() =0; - virtual ADDON_STATUS GetStatus() =0; - virtual ADDON_STATUS SetSetting(const char *settingName, const void *settingValue) =0; virtual const char* GetAddonTypeVersion(int type)=0; virtual const char* GetAddonTypeMinVersion(int type) = 0; }; @@ -29,19 +25,11 @@ class DllAddon : public DllDynamic, public DllAddonInterface public: DECLARE_DLL_WRAPPER_TEMPLATE(DllAddon) DEFINE_METHOD3(ADDON_STATUS, Create, (void* p1, const char* p2, void* p3)) - DEFINE_METHOD0(void, Destroy) - DEFINE_METHOD0(ADDON_STATUS, GetStatus) - DEFINE_METHOD2(ADDON_STATUS, SetSetting, (const char *p1, const void *p2)) - DEFINE_METHOD1(void, GetAddon, (void* p1)) DEFINE_METHOD1(const char*, GetAddonTypeVersion, (int p1)) DEFINE_METHOD1(const char*, GetAddonTypeMinVersion, (int p1)) bool GetAddonTypeMinVersion_available() { return m_GetAddonTypeMinVersion != nullptr; } BEGIN_METHOD_RESOLVE() - RESOLVE_METHOD_RENAME_OPTIONAL(get_addon, GetAddon) RESOLVE_METHOD_RENAME(ADDON_Create, Create) - RESOLVE_METHOD_RENAME(ADDON_Destroy, Destroy) - RESOLVE_METHOD_RENAME(ADDON_GetStatus, GetStatus) - RESOLVE_METHOD_RENAME(ADDON_SetSetting, SetSetting) RESOLVE_METHOD_RENAME(ADDON_GetTypeVersion, GetAddonTypeVersion) RESOLVE_METHOD_RENAME_OPTIONAL(ADDON_GetTypeMinVersion, GetAddonTypeMinVersion) END_METHOD_RESOLVE() diff --git a/xbmc/addons/gui/GUIDialogAddonInfo.cpp b/xbmc/addons/gui/GUIDialogAddonInfo.cpp index ed979b8a71..a51947d060 100644 --- a/xbmc/addons/gui/GUIDialogAddonInfo.cpp +++ b/xbmc/addons/gui/GUIDialogAddonInfo.cpp @@ -304,13 +304,9 @@ int CGUIDialogAddonInfo::AskForVersion(std::vector<std::pair<AddonVersion, std:: void CGUIDialogAddonInfo::OnUpdate() { - // prompt user to be sure - if (!CGUIDialogYesNo::ShowAndGetInput(CVariant{24138}, CVariant{750})) - return; - const auto& itemAddonInfo = m_item->GetAddonInfo(); - const std::string& origin = itemAddonInfo->Origin(); const std::string& addonId = itemAddonInfo->ID(); + const std::string& origin = m_item->GetProperty("Addon.ValidUpdateOrigin").asString(); const AddonVersion& version = static_cast<AddonVersion>(m_item->GetProperty("Addon.ValidUpdateVersion").asString()); @@ -345,6 +341,7 @@ void CGUIDialogAddonInfo::OnSelectVersion() // get all compatible versions of an addon-id regardless of their origin CServiceBroker::GetAddonMgr().GetCompatibleVersions(processAddonId, compatibleVersions); + versions.reserve(compatibleVersions.size()); for (const auto& compatibleVersion : compatibleVersions) versions.emplace_back( std::make_pair(compatibleVersion->Version(), compatibleVersion->Origin())); @@ -437,23 +434,25 @@ void CGUIDialogAddonInfo::OnInstall() const auto& itemAddonInfo = m_item->GetAddonInfo(); const std::string& origin = itemAddonInfo->Origin(); - if (m_localAddon && (m_localAddon->Origin() != origin) && - (CAddonSystemSettings::GetInstance().GetAddonRepoUpdateMode() != - AddonRepoUpdateMode::ANY_REPOSITORY)) + if (m_localAddon && CAddonSystemSettings::GetInstance().GetAddonRepoUpdateMode() != + AddonRepoUpdateMode::ANY_REPOSITORY) { - const std::string& header = g_localizeStrings.Get(19098); // Warning! - const std::string text = - StringUtils::Format(g_localizeStrings.Get(39028), m_localAddon->ID(), - m_localAddon->Origin(), m_localAddon->Version().asString()); - - if (CGUIDialogYesNo::ShowAndGetInput(header, text)) - { - m_silentUninstall = true; - OnUninstall(); - } - else + if (m_localAddon->Origin() != origin && m_localAddon->Origin() != ORIGIN_SYSTEM) { - return; + const std::string& header = g_localizeStrings.Get(19098); // Warning! + const std::string text = + StringUtils::Format(g_localizeStrings.Get(39028), m_localAddon->ID(), + m_localAddon->Origin(), m_localAddon->Version().asString()); + + if (CGUIDialogYesNo::ShowAndGetInput(header, text)) + { + m_silentUninstall = true; + OnUninstall(); + } + else + { + return; + } } } diff --git a/xbmc/addons/gui/GUIDialogAddonSettings.cpp b/xbmc/addons/gui/GUIDialogAddonSettings.cpp index 5e5be83695..7ff32b45a7 100644 --- a/xbmc/addons/gui/GUIDialogAddonSettings.cpp +++ b/xbmc/addons/gui/GUIDialogAddonSettings.cpp @@ -50,8 +50,8 @@ bool CGUIDialogAddonSettings::OnMessage(CGUIMessage& message) case GUI_MSG_SETTING_UPDATED: { - std::string settingId = message.GetStringParam(0); - std::string settingValue = message.GetStringParam(1); + const std::string& settingId = message.GetStringParam(0); + const std::string& settingValue = message.GetStringParam(1); std::shared_ptr<CSetting> setting = GetSettingsManager()->GetSetting(settingId); if (setting != nullptr) @@ -218,7 +218,7 @@ std::string CGUIDialogAddonSettings::GetLocalizedString(uint32_t labelId) const return CGUIDialogSettingsManagerBase::GetLocalizedString(labelId); } -std::string CGUIDialogAddonSettings::GetSettingsLabel(std::shared_ptr<ISetting> setting) +std::string CGUIDialogAddonSettings::GetSettingsLabel(const std::shared_ptr<ISetting>& setting) { if (setting == nullptr) return ""; @@ -261,7 +261,7 @@ CSettingsManager* CGUIDialogAddonSettings::GetSettingsManager() const return m_addon->GetSettings()->GetSettingsManager(); } -void CGUIDialogAddonSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogAddonSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (m_addon == nullptr || m_addon->GetSettings() == nullptr) return; diff --git a/xbmc/addons/gui/GUIDialogAddonSettings.h b/xbmc/addons/gui/GUIDialogAddonSettings.h index c28fa46ae3..42c8c5ca67 100644 --- a/xbmc/addons/gui/GUIDialogAddonSettings.h +++ b/xbmc/addons/gui/GUIDialogAddonSettings.h @@ -30,7 +30,7 @@ protected: // implementation of CGUIDialogSettingsBase void SetupView() override; std::string GetLocalizedString(uint32_t labelId) const override; - std::string GetSettingsLabel(std::shared_ptr<ISetting> setting) override; + std::string GetSettingsLabel(const std::shared_ptr<ISetting>& setting) override; int GetSettingLevel() const override; std::shared_ptr<CSettingSection> GetSection() override; @@ -40,7 +40,7 @@ protected: CSettingsManager* GetSettingsManager() const override; // implementation of ISettingCallback - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; private: ADDON::AddonPtr m_addon; diff --git a/xbmc/addons/kodi-dev-kit/doxygen/Doxyfile b/xbmc/addons/kodi-dev-kit/doxygen/Doxyfile index 339249e5d6..87307e571b 100644 --- a/xbmc/addons/kodi-dev-kit/doxygen/Doxyfile +++ b/xbmc/addons/kodi-dev-kit/doxygen/Doxyfile @@ -830,9 +830,6 @@ INPUT = main.txt \ Modules/modules_python.dox \ Skin/skin.dox \ ../../../../cmake/scripts/common/AddonHelpers.dox \ - ../../../cores/VideoPlayer/Interface/Addon/DemuxPacket.h \ - ../../../cores/VideoPlayer/Interface/Addon/InputStreamConstants.h \ - ../../../cores/VideoPlayer/Interface/Addon/TimingConstants.h \ ../../../guilib/GUIRenderingControl.dox \ ../../../guilib/GUIButtonControl.dox \ ../../../guilib/GUIEditControl.dox \ diff --git a/xbmc/addons/kodi-dev-kit/doxygen/Modules/modules_cpp.dox b/xbmc/addons/kodi-dev-kit/doxygen/Modules/modules_cpp.dox index acc670ed31..0967bddb49 100644 --- a/xbmc/addons/kodi-dev-kit/doxygen/Modules/modules_cpp.dox +++ b/xbmc/addons/kodi-dev-kit/doxygen/Modules/modules_cpp.dox @@ -93,6 +93,8 @@ Here is a table of the types currently possible: */ /*! \defgroup cpp_kodi_addon_instances Addon type instances + \brief **Group of possible processing instances which can be made available by an add-on**\n + Kodi enables numerous different ways in which the necessary documentation is included in this group. \ingroup cpp_kodi_addon */ /*! diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h b/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h index 6ab4159b7e..06b22d5193 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h @@ -32,7 +32,7 @@ namespace kodi namespace gui { struct IRenderHelper; -} // namespace gui +} /* namespace gui */ //============================================================================== /// @ingroup cpp_kodi_Defs @@ -65,7 +65,8 @@ using HardwareContext = ADDON_HARDWARE_CONTEXT; //============================================================================== /// @ingroup cpp_kodi_addon_addonbase_Defs /// @defgroup cpp_kodi_addon_addonbase_Defs_CSettingValue class CSettingValue -/// @brief Inside addon main instance used helper class to give settings value. +/// @brief **Setting value handler**\n +/// Inside addon main instance used helper class to give settings value. /// /// This is used on @ref addon::CAddonBase::SetSetting() to inform addon about /// settings change by used. This becomes then used to give the related value @@ -311,23 +312,55 @@ private: bool m_owner = false; }; -/// Add-on main instance class. +//============================================================================ +/// @addtogroup cpp_kodi_addon_addonbase +/// @brief **Add-on main instance class**\n +/// This is the addon main class, similar to an <b>`int main()`</b> in executable and +/// carries out initial work and later management of it. +/// class ATTRIBUTE_HIDDEN CAddonBase { public: + //============================================================================ + /// @ingroup cpp_kodi_addon_addonbase + /// @brief Addon base class constructor. + /// CAddonBase() { m_interface->toAddon->destroy = ADDONBASE_Destroy; - m_interface->toAddon->get_status = ADDONBASE_GetStatus; m_interface->toAddon->create_instance = ADDONBASE_CreateInstance; m_interface->toAddon->destroy_instance = ADDONBASE_DestroyInstance; m_interface->toAddon->set_setting = ADDONBASE_SetSetting; } + //---------------------------------------------------------------------------- + //============================================================================ + /// @ingroup cpp_kodi_addon_addonbase + /// @brief Destructor. + /// virtual ~CAddonBase() = default; + //---------------------------------------------------------------------------- + //============================================================================ + /// @ingroup cpp_kodi_addon_addonbase + /// @brief Main addon creation function + /// + /// With this function addon can carry out necessary work which is required + /// at later points or start necessary processes. + /// + /// This function is optional and necessary work can also be carried out + /// using @ref CreateInstance (if it concerns any instance types). + /// + /// @return @ref ADDON_STATUS_OK if correct, for possible errors see + /// @ref ADDON_STATUS + /// + /// @note Terminating the add-on must be carried out using the class destructor + /// given by child. + /// virtual ADDON_STATUS Create() { return ADDON_STATUS_OK; } + //---------------------------------------------------------------------------- + // obsolete virtual ADDON_STATUS GetStatus() { return ADDON_STATUS_OK; } //============================================================================ @@ -391,7 +424,7 @@ public: /// @ingroup cpp_kodi_addon_addonbase /// @brief Instance created /// - /// @param[in] instanceType The requested type of required instance, see \ref ADDON_TYPE. + /// @param[in] instanceType The requested type of required instance, see @ref ADDON_TYPE. /// @param[in] instanceID An individual identification key string given by Kodi. /// @param[in] instance The instance handler used by Kodi must be passed to /// the classes created here. See in the example. @@ -401,8 +434,8 @@ public: /// that it can handle differences. /// @param[out] addonInstance The pointer to instance class created in addon. /// Needed to be able to identify them on calls. - /// @return \ref ADDON_STATUS_OK if correct, for possible errors - /// see \ref ADDON_STATUS + /// @return @ref ADDON_STATUS_OK if correct, for possible errors + /// see @ref ADDON_STATUS /// /// /// -------------------------------------------------------------------------- @@ -414,8 +447,8 @@ public: /// /// ... /// - /// /* If you use only one instance in your add-on, can be instanceType and - /// * instanceID ignored */ + /// // If you use only one instance in your add-on, can be instanceType and + /// // instanceID ignored /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, /// const std::string& instanceID, /// KODI_HANDLE instance, @@ -462,7 +495,7 @@ public: /// This function is optional and intended to notify addon that the instance /// is terminating. /// - /// @param[in] instanceType The requested type of required instance, see \ref ADDON_TYPE. + /// @param[in] instanceType The requested type of required instance, see @ref ADDON_TYPE. /// @param[in] instanceID An individual identification key string given by Kodi. /// @param[in] addonInstance The pointer to instance class created in addon. /// @@ -483,25 +516,19 @@ public: static AddonGlobalInterface* m_interface; // Interface function table to hold addresses on add-on and from kodi - /*private:*/ /* Needed public as long the old call functions becomes used! */ +private: static inline void ADDONBASE_Destroy() { delete static_cast<CAddonBase*>(m_interface->addonBase); m_interface->addonBase = nullptr; } - static inline ADDON_STATUS ADDONBASE_GetStatus() - { - return static_cast<CAddonBase*>(m_interface->addonBase)->GetStatus(); - } - static inline ADDON_STATUS ADDONBASE_SetSetting(const char* settingName, const void* settingValue) { return static_cast<CAddonBase*>(m_interface->addonBase) ->SetSetting(settingName, CSettingValue(settingValue)); } -private: static inline ADDON_STATUS ADDONBASE_CreateInstance(int instanceType, const char* instanceID, KODI_HANDLE instance, @@ -591,7 +618,7 @@ private: } /* namespace addon */ //============================================================================== -/// @ingroup cpp_kodi_addon +/// @ingroup cpp_kodi /// @brief To get used version inside Kodi itself about asked type. /// /// This thought to allow a addon a handling of newer addon versions within @@ -613,6 +640,11 @@ inline std::string ATTRIBUTE_HIDDEN GetKodiTypeVersion(int type) //------------------------------------------------------------------------------ //============================================================================== +/// @ingroup cpp_kodi +/// @brief To get the addon system installation folder. +/// +/// @param[in] append [optional] Path to append to given string +/// @return Path where addon is installed /// inline std::string ATTRIBUTE_HIDDEN GetAddonPath(const std::string& append = "") { @@ -637,6 +669,14 @@ inline std::string ATTRIBUTE_HIDDEN GetAddonPath(const std::string& append = "") //------------------------------------------------------------------------------ //============================================================================== +/// @ingroup cpp_kodi +/// @brief To get the user-related folder of the addon. +/// +/// @note This folder is not created automatically and has to be created by the +/// addon the first time. +/// +/// @param[in] append [optional] Path to append to given string +/// @return User path of addon /// inline std::string ATTRIBUTE_HIDDEN GetBaseUserPath(const std::string& append = "") { @@ -661,6 +701,19 @@ inline std::string ATTRIBUTE_HIDDEN GetBaseUserPath(const std::string& append = //------------------------------------------------------------------------------ //============================================================================== +/// @ingroup cpp_kodi +/// @brief This function gives OS associated executable binary path of the addon. +/// +/// With some systems this can differ from the addon path at @ref GetAddonPath. +/// +/// As an example on Linux: +/// - Addon path is at `/usr/share/kodi/addons/YOUR_ADDON_ID` +/// - Library path is at `/usr/lib/kodi/addons/YOUR_ADDON_ID` +/// +/// @note In addition, in this function, for a given folder, the add-on path +/// itself, but its parent. +/// +/// @return Kodi's sytem library path where related addons are installed. /// inline std::string ATTRIBUTE_HIDDEN GetLibPath() { @@ -1223,6 +1276,11 @@ inline void ATTRIBUTE_HIDDEN SetSettingEnum(const std::string& settingName, enum /*!@}*/ //============================================================================ +/// @ingroup cpp_kodi +/// @brief Get to related @ref ADDON_STATUS a human readable text. +/// +/// @param[in] status Status value to get name for +/// @return Wanted name, as "Unknown" if status not known /// inline std::string ATTRIBUTE_HIDDEN TranslateAddonStatus(ADDON_STATUS status) { @@ -1279,16 +1337,102 @@ inline void* GetInterface(const std::string& name, const std::string& version) } /* namespace kodi */ -/*! addon creation macro - * @todo cleanup this stupid big macro - * This macro includes now all for add-on's needed functions. This becomes a bigger - * rework after everything is done on Kodi itself, currently is this way needed - * to have compatibility with not reworked interfaces. - * - * Becomes really cleaned up soon :D - */ +//============================================================================== +/// @ingroup cpp_kodi_addon_addonbase_Defs +/// @defgroup cpp_kodi_addon_addonbase_Defs_ADDONCREATORAddonClass macro ADDONCREATOR(AddonClass) +/// @brief **Addon creation macro**\n +/// This export the three mandatory "C" functions to have available for Kodi. +/// +/// @note Only this macro can be used on a C++ addon, everything else is done +/// automatically. +/// +/// @param[in] AddonClass Used addon class to be exported with CAddonBase as +/// parent. +/// +/// +/// ---------------------------------------------------------------------------- +/// +/// **Example:** +/// ~~~~~~~~~~~~~{.cpp} +/// +/// #include <kodi/AddonBash.h> +/// +/// class CMyAddon : public kodi::addon::CAddonBase +/// { +/// public: +/// CMyAddon() = default; +/// ADDON_STATUS Create() override; +/// }; +/// +/// ADDON_STATUS CMyAddon::Create() +/// { +/// // Some work +/// +/// return ADDON_STATUS_OK; +/// } +/// +/// ADDONCREATOR(CMyAddon) +/// ~~~~~~~~~~~~~ +/// +/// ---------------------------------------------------------------------------- +/// +/// As information, the following functions are exported using this macro: +/// \table_start +/// \table_h3{ Function, Use, Description } +/// \table_row3{ <b>`ADDON_Create(KODI_HANDLE addonInterface\, const char* globalApiVersion\, void* unused)`</b>, +/// \anchor ADDON_Create +/// _required_, +/// <b>Addon creation call.</b> +/// <br> +/// Like an `int main()` is this the first on addon called place on his start +/// and create within C++ API related class inside addon. +/// <br> +/// @param[in] addonInterface Handle pointer to get Kodi's given table. +/// There have addon needed values and functions +/// to Kodi and addon must set his functions there +/// for Kodi. +/// @param[in] globalApiVersion This give the main version @ref ADDON_GLOBAL_VERSION_MAIN +/// where currently on Kodi's side.<br> +/// This is unsued on addon as there also other +/// special callback functions for.<br> +/// Only thought for future use if needed earlier. +/// @param[in] unused This is a not used value\, only there to have in case of +/// need no Major API version increase where break current. +/// @return @ref ADDON_STATUS_OK if correct\, for possible errors see +/// @ref ADDON_STATUS. +/// <p> +/// } +/// \table_row3{ <b>`const char* ADDON_GetTypeVersion(int type)`</b>, +/// \anchor ADDON_GetTypeVersion +/// _required_, +/// <b>Ask addon about version of given type.</b> +/// <br> +/// This is used to query its associated version in the addon before work +/// is carried out in it and the Kodi can adapt to it. +/// <br> +/// @param[in] type With @ref ADDON_TYPE defined type to ask. +/// @return Version as string of asked type. +/// <p> +/// } +/// \table_row3{ <b>`const char* ADDON_GetTypeMinVersion(int type)`</b>, +/// \anchor ADDON_GetTypeMinVersion +/// _optional_, +/// <b>Ask addon about minimal version of given type.</b> +/// <br> +/// This is used to query its associated min version in the addon before work +/// is carried out in it and the Kodi can adapt to it. +/// <br> +/// @note The minimum version is optional\, if it were not available\, the +/// major version is used instead. +/// <br> +/// @param[in] type With @ref ADDON_TYPE defined type to ask. +/// @return Min version as string of asked type. +/// <p> +/// } +/// \table_end +/// #define ADDONCREATOR(AddonClass) \ - extern "C" __declspec(dllexport) ADDON_STATUS ADDON_Create( \ + extern "C" ATTRIBUTE_DLL_EXPORT ADDON_STATUS ADDON_Create( \ KODI_HANDLE addonInterface, const char* /*globalApiVersion*/, void* /*unused*/) \ { \ kodi::addon::CAddonBase::m_interface = static_cast<AddonGlobalInterface*>(addonInterface); \ @@ -1296,27 +1440,15 @@ inline void* GetInterface(const std::string& name, const std::string& version) return static_cast<kodi::addon::CAddonBase*>(kodi::addon::CAddonBase::m_interface->addonBase) \ ->Create(); \ } \ - extern "C" __declspec(dllexport) void ADDON_Destroy() \ - { \ - kodi::addon::CAddonBase::ADDONBASE_Destroy(); \ - } \ - extern "C" __declspec(dllexport) ADDON_STATUS ADDON_GetStatus() \ - { \ - return kodi::addon::CAddonBase::ADDONBASE_GetStatus(); \ - } \ - extern "C" __declspec(dllexport) ADDON_STATUS ADDON_SetSetting(const char* settingName, \ - const void* settingValue) \ - { \ - return kodi::addon::CAddonBase::ADDONBASE_SetSetting(settingName, settingValue); \ - } \ - extern "C" __declspec(dllexport) const char* ADDON_GetTypeVersion(int type) \ + extern "C" ATTRIBUTE_DLL_EXPORT const char* ADDON_GetTypeVersion(int type) \ { \ return kodi::addon::GetTypeVersion(type); \ } \ - extern "C" __declspec(dllexport) const char* ADDON_GetTypeMinVersion(int type) \ + extern "C" ATTRIBUTE_DLL_EXPORT const char* ADDON_GetTypeMinVersion(int type) \ { \ return kodi::addon::GetTypeMinVersion(type); \ } \ AddonGlobalInterface* kodi::addon::CAddonBase::m_interface = nullptr; +//------------------------------------------------------------------------------ #endif /* __cplusplus */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h b/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h index 36d1dd122a..c6f8c4fdfc 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h @@ -68,7 +68,7 @@ namespace audioengine /// /// ------------------------------------------------------------------------ /// -/// It has the header \ref AudioEngine.h "#include <kodi/AudioEngine.h>" be included +/// It has the header @ref AudioEngine.h "#include <kodi/AudioEngine.h>" be included /// to enjoy it. /// //------------------------------------------------------------------------------ @@ -262,8 +262,8 @@ public: /// @brief Contructs new class to an Kodi IAEStream in the format specified. /// /// @param[in] format The data format the incoming audio will be in - /// (e.g. \ref AUDIOENGINE_FMT_S16LE) - /// @param[in] options [opt] A bit field of stream options (see: enum \ref AudioEngineStreamOptions) + /// (e.g. @ref AUDIOENGINE_FMT_S16LE) + /// @param[in] options [opt] A bit field of stream options (see: enum @ref AudioEngineStreamOptions) /// /// /// ------------------------------------------------------------------------ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt index d37078ac6f..298b5de1ce 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt @@ -3,8 +3,6 @@ set(HEADERS AddonBase.h Filesystem.h General.h Network.h - StreamCodec.h - StreamCrypto.h versions.h) if(CORE_SYSTEM_NAME STREQUAL android) diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h index 1cf05fe295..9e0598353b 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h @@ -91,7 +91,7 @@ namespace vfs /// @brief **File information status**\n /// Used on kodi::vfs::StatFile() to get detailed information about a file. /// -//@{ +///@{ class ATTRIBUTE_HIDDEN FileStatus : public kodi::addon::CStructHdl<FileStatus, STAT_STRUCTURE> { public: @@ -102,7 +102,7 @@ public: FileStatus(STAT_STRUCTURE* channel) : CStructHdl(channel) {} /*! \endcond */ - /// @defgroup cpp_kodi_vfs_Defs_FileStatus_Help *Value Help* + /// @defgroup cpp_kodi_vfs_Defs_FileStatus_Help Value Help /// @ingroup cpp_kodi_vfs_Defs_FileStatus /// ---------------------------------------------------------------------------- /// @@ -126,7 +126,7 @@ public: /// @addtogroup cpp_kodi_vfs_Defs_FileStatus /// @copydetails cpp_kodi_vfs_Defs_FileStatus_Help - //@{ + ///@{ /// @brief Set ID of device containing file. void SetDeviceId(uint32_t deviceId) { m_cStructure->deviceId = deviceId; } @@ -208,9 +208,9 @@ public: /// @brief Get stat url is a regular. bool GetIsSocket() const { return m_cStructure->isSocket; } - //@} + ///@} }; -//@} +///@} //------------------------------------------------------------------------------ //============================================================================== @@ -220,7 +220,7 @@ public: /// Used on kodi::vfs::CFile::IoControlGetCacheStatus() to get running cache /// status of proccessed stream. /// -//@{ +///@{ class ATTRIBUTE_HIDDEN CacheStatus : public kodi::addon::CStructHdl<CacheStatus, VFS_CACHE_STATUS_DATA> { @@ -232,7 +232,7 @@ public: CacheStatus(VFS_CACHE_STATUS_DATA* channel) : CStructHdl(channel) {} /*! \endcond */ - /// @defgroup cpp_kodi_vfs_Defs_CacheStatus_Help *Value Help* + /// @defgroup cpp_kodi_vfs_Defs_CacheStatus_Help Value Help /// @ingroup cpp_kodi_vfs_Defs_CacheStatus /// ---------------------------------------------------------------------------- /// @@ -247,7 +247,7 @@ public: /// @addtogroup cpp_kodi_vfs_Defs_CacheStatus /// @copydetails cpp_kodi_vfs_Defs_CacheStatus_Help - //@{ + ///@{ /// @brief Set number of bytes cached forward of current position. void SetForward(uint64_t forward) { m_cStructure->forward = forward; } @@ -273,9 +273,9 @@ public: /// @brief Get cache low speed condition detected. bool GetLowspeed() { return m_cStructure->lowspeed; } - //@} + ///@} }; -//@} +///@} //------------------------------------------------------------------------------ //============================================================================== @@ -318,7 +318,7 @@ public: } //-------------------------------------------------------------------------- - /// @defgroup cpp_kodi_vfs_Defs_HttpHeader_Help *Value Help* + /// @defgroup cpp_kodi_vfs_Defs_HttpHeader_Help Value Help /// @ingroup cpp_kodi_vfs_Defs_HttpHeader /// /// <b>The following table contains values that can be get with @ref cpp_kodi_vfs_Defs_HttpHeader :</b> @@ -382,6 +382,7 @@ public: if (res) { std::vector<std::string> vecReturn; + vecReturn.reserve(numValues); for (int i = 0; i < numValues; ++i) { vecReturn.emplace_back(res[i]); @@ -537,7 +538,7 @@ public: /// It has the header @ref Filesystem.h "#include <kodi/Filesystem.h>" be included /// to enjoy it. /// -//@{ +///@{ class ATTRIBUTE_HIDDEN CDirEntry { public: @@ -580,7 +581,7 @@ public: } //---------------------------------------------------------------------------- - /// @defgroup cpp_kodi_vfs_CDirEntry_Help *Value Help* + /// @defgroup cpp_kodi_vfs_CDirEntry_Help Value Help /// @ingroup cpp_kodi_vfs_CDirEntry /// -------------------------------------------------------------------------- /// @@ -598,7 +599,7 @@ public: /// @addtogroup cpp_kodi_vfs_CDirEntry /// @copydetails cpp_kodi_vfs_CDirEntry_Help - //@{ + ///@{ //============================================================================ /// @brief Get the directory entry name. @@ -723,7 +724,7 @@ public: const std::map<std::string, std::string>& GetProperties() const { return m_properties; } //---------------------------------------------------------------------------- - //@} + ///@} private: std::string m_label; @@ -734,7 +735,7 @@ private: int64_t m_size; time_t m_dateTime; }; -//@} +///@} //------------------------------------------------------------------------------ //}}} @@ -1823,7 +1824,7 @@ inline bool ATTRIBUTE_HIDDEN GetCookies(const std::string& url, std::string& coo /// /// ~~~~~~~~~~~~~ /// -//@{ +///@{ class ATTRIBUTE_HIDDEN CFile { public: @@ -2324,6 +2325,7 @@ public: if (res) { std::vector<std::string> vecReturn; + vecReturn.reserve(numValues); for (int i = 0; i < numValues; ++i) { vecReturn.emplace_back(res[i]); @@ -2356,7 +2358,7 @@ public: private: void* m_file = nullptr; }; -//@} +///@} //------------------------------------------------------------------------------ //}}} diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/General.h b/xbmc/addons/kodi-dev-kit/include/kodi/General.h index 3fad5a0d00..ab9452b282 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/General.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/General.h @@ -787,7 +787,7 @@ inline bool ATTRIBUTE_HIDDEN GetKeyboardLayout(int modifierKey, /// @param[out] layout_name new name of used layout (input string not used!) /// @return true if request successed /// -/// @note \ref GetKeyboardLayout must be called afterwards. +/// @note @ref GetKeyboardLayout must be called afterwards. /// /// /// ------------------------------------------------------------------------ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h deleted file mode 100644 index 8008aa118c..0000000000 --- a/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2017-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#pragma once - -#include <inttypes.h> -#include <string.h> - -#define STREAMCRYPTO_VERSION_LEVEL 1 - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - typedef struct CRYPTO_INFO - { - enum CRYPTO_KEY_SYSTEM : uint8_t - { - CRYPTO_KEY_SYSTEM_NONE = 0, - CRYPTO_KEY_SYSTEM_WIDEVINE, - CRYPTO_KEY_SYSTEM_PLAYREADY, - CRYPTO_KEY_SYSTEM_WISEPLAY, - CRYPTO_KEY_SYSTEM_COUNT - } m_CryptoKeySystem; /*!< @brief keysystem for encrypted media, KEY_SYSTEM_NONE for unencrypted media */ - - static const uint8_t FLAG_SECURE_DECODER = - 1; /*!< @brief is set in flags if decoding has to be done in TEE environment */ - - uint8_t flags; - uint16_t m_CryptoSessionIdSize; /*!< @brief The size of the crypto session key id */ - const char* m_CryptoSessionId; /*!< @brief The crypto session key id */ - } CRYPTO_INFO; - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h index a6bea7db64..747225fb35 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h @@ -241,7 +241,7 @@ private: //============================================================================== /// -/// \addtogroup cpp_kodi_addon_audiodecoder +/// @addtogroup cpp_kodi_addon_audiodecoder /// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder } /// **Audio decoder add-on instance** /// @@ -289,9 +289,11 @@ private: /// |:------------------------------|---------------------------------------- /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>. /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. -/// | <b>`name`</b> | The name of the decoder used in Kodi for display. /// | <b>`extension`</b> | The file extensions / styles supported by this addon. -/// | <b>`tags`</b> | Boolean to point out that addon can bring own information to replayed file, if <b>`false`</b> only the file name is used as info.<br>If <b>`true`</b>, \ref CInstanceAudioDecoder::ReadTag is used and must be implemented. +/// | <b>`mimetype`</b> | A stream URL mimetype where can be used to force to this addon. +/// | <b>`name`</b> | The name of the decoder used in Kodi for display. +/// | <b>`tags`</b> | Boolean to point out that addon can bring own information to replayed file, if <b>`false`</b> only the file name is used as info.<br>If <b>`true`</b>, @ref CInstanceAudioDecoder::ReadTag is used and must be implemented. +/// | <b>`tracks`</b> | Boolean to in inform one file can contains several different streams. /// /// -------------------------------------------------------------------------- /// diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h index 396b92ee47..c69c45da99 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h @@ -8,682 +8,1746 @@ #pragma once -/* - * Parts with a comment named "internal" are only used inside header and not - * used or accessed direct during add-on development! - */ - #include "../AddonBase.h" -#include "../StreamCodec.h" -#include "../StreamCrypto.h" +#include "../c-api/addon-instance/inputstream.h" +#include "inputstream/StreamCodec.h" +#include "inputstream/StreamConstants.h" +#include "inputstream/StreamCrypto.h" +#include "inputstream/TimingConstants.h" -#ifdef BUILD_KODI_ADDON -#include "../DemuxPacket.h" -#include "../InputStreamConstants.h" -#else -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" -#endif +#ifdef __cplusplus -//Increment this level always if you add features which can lead to compile failures in the addon -#define INPUTSTREAM_VERSION_LEVEL 2 +#include <map> -#define INPUTSTREAM_MAX_STREAM_COUNT 256 -#define INPUTSTREAM_MAX_STRING_NAME_SIZE 256 -#define INPUTSTREAM_MAX_STRING_CODEC_SIZE 32 -#define INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE 64 +namespace kodi +{ +namespace addon +{ -#ifdef __cplusplus -extern "C" +//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +// "C++" Doxygen group set for the definitions +//{{{ + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs Definitions, structures and enumerators +/// @ingroup cpp_kodi_addon_inputstream +/// @brief **Inputstream add-on instance definition values**\n +/// All inputstream functions associated data structures. +/// +/// Used to exchange the available options between Kodi and addon.\n +/// The groups described here correspond to the groups of functions on inputstream +/// instance class. +/// +/// In addition, some of the things described here are also used on the +/// @ref cpp_kodi_addon_videocodec "video codec" addon. +/// + +//############################################################################## +/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface 1. Interface +/// @ingroup cpp_kodi_addon_inputstream_Defs +/// @brief **Inputstream add-on general variables**\n +/// Used to exchange the available options between Kodi and addon. +/// + +//############################################################################## +/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamConstants 2. Stream constants +/// @ingroup cpp_kodi_addon_inputstream_Defs +/// @brief **Used to exchange any additional data between the caller and processor.**\n +/// This includes the standardized values, in addition, an addon can also use +/// its own special uses to be exchanged in the same way. +/// +/// These values can be used by other addons (e.g. video addon) or stream files +/// to select the respective inputstream addon and to transfer additional values. +/// +/// ---------------------------------------------------------------------------- +/// +/// **Example:** +/// +/// This example use the @ref STREAM_PROPERTY_INPUTSTREAM on a <b>`*.strm`</b> +/// file to select needed addon and a additional value where related to selected +/// addon itself. +/// +/// ~~~~~~~~~~~~ +/// #KODIPROP:inputstream=inputstream.adaptive +/// #KODIPROP:inputstream.adaptive.manifest_type=mpd +/// http://rdmedia.bbc.co.uk/dash/ondemand/testcard/1/client_manifest-events-multilang.mpd +/// ~~~~~~~~~~~~ +/// +/// These are then given to Kodi and the respectively selected addon by means of +/// his @ref kodi::addon::CInstanceInputStream::Open "Open" call +/// in @ref kodi::addon::InputstreamProperty::GetProperties. +/// +/// The largest possible amount of these <b>`#KODIPROP`</b> values is defined +/// with @ref STREAM_MAX_PROPERTY_COUNT. +/// + +//############################################################################## +/// @defgroup cpp_kodi_addon_inputstream_Defs_TimingConstants 3. Stream timing +/// @ingroup cpp_kodi_addon_inputstream_Defs +/// @brief **Timebase and timestamp definitions.**\n +/// Used to exchange the available options between Kodi and addon. +/// + +//############################################################################## +/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamCodec 4. Stream codec +/// @ingroup cpp_kodi_addon_inputstream_Defs +/// @brief **Inputstream codec control**\n +/// Used to manage stream codec data. +/// + +//############################################################################## +/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption 5. Stream encryption +/// @ingroup cpp_kodi_addon_inputstream_Defs +/// @brief **Inputstream encryption control**\n +/// Used to manage encrypted streams within addon. +/// + +//}}} +//______________________________________________________________________________ + +class CInstanceInputStream; + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty class InputstreamProperty +/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface +/// @brief <b>URL and Data of key/value pairs passed to addon on @ref kodi::addon::CInstanceInputStream::Open "Open".</b>\n +/// This is used to have the necessary data of the stream to be opened. +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help +/// +/// @warning This data are only given from Kodi to addon and can't be used +/// on other places on addon. +/// +///@{ +class ATTRIBUTE_HIDDEN InputstreamProperty + : public CStructHdl<InputstreamProperty, INPUTSTREAM_PROPERTY> { -#endif /* __cplusplus */ + /*! \cond PRIVATE */ + friend class CInstanceInputStream; + /*! \endcond */ + +public: + /// @defgroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help Value Help + /// @ingroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_InputstreamProperty :</b> + /// | Name | Type | Get call + /// |------|------|---------- + /// | **Stream URL** | `std::string` | @ref InputstreamProperty::GetURL "GetURL" + /// | **Mime type** | `std::string` | @ref InputstreamProperty::GetMimeType "GetMimeType" + /// | **Available amount of properties** | `unsigned int` | @ref InputstreamProperty::GetPropertiesAmount "GetPropertiesAmount" + /// | **List of properties** | `std::map<std::string, std::string>` | @ref InputstreamProperty::GetProperties "GetProperties" + /// | **Get addon library folder** | `std::string` | @ref InputstreamProperty::GetLibFolder "GetLibFolder" + /// | **Get addon profile/user folder** | `std::string` | @ref InputstreamProperty::GetProfileFolder "GetProfileFolder" + + /// @addtogroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty + ///@{ + + /// @brief Stream URL to open. + std::string GetURL() const { return m_cStructure->m_strURL; } + + /// @brief Stream mime type. + std::string GetMimeType() const { return m_cStructure->m_mimeType; } + + /// @brief Amount of available properties. + unsigned int GetPropertiesAmount() const + { + return m_cStructure->m_nCountInfoValues; + } - /*! - * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. - */ - struct INPUTSTREAM_CAPABILITIES + /// @brief List of available properties- + const std::map<std::string, std::string> GetProperties() const { - enum MASKTYPE : uint32_t + std::map<std::string, std::string> props; + for (unsigned int i = 0; i < m_cStructure->m_nCountInfoValues; ++i) { - /// supports interface IDemux - SUPPORTS_IDEMUX = (1 << 0), + props.emplace(m_cStructure->m_ListItemProperties[i].m_strKey, + m_cStructure->m_ListItemProperties[i].m_strValue); + } + return props; + } + + /// @brief Get addon library folder. + /// + /// @note As alternative can also @ref kodi::GetAddonPath used. + std::string GetLibFolder() const { return m_cStructure->m_libFolder; } + + /// @brief Get addon profile/user folder. + /// + /// @note As alternative can also @ref kodi::GetBaseUserPath used. + std::string GetProfileFolder() const { return m_cStructure->m_profileFolder; } + + ///@} + +private: + InputstreamProperty() = delete; + InputstreamProperty(const InputstreamProperty& stream) = delete; + InputstreamProperty(const INPUTSTREAM_PROPERTY* stream) : CStructHdl(stream) {} + InputstreamProperty(INPUTSTREAM_PROPERTY* stream) : CStructHdl(stream) {} +}; +///@} +//------------------------------------------------------------------------------ + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities class InputstreamCapabilities +/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface +/// @brief **InputStream add-on capabilities. All capabilities are set to "false" as default.**\n +/// Asked to addon on @ref kodi::addon::CInstanceInputStream::GetCapabilities "GetCapabilities". +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help +/// +///@{ +class ATTRIBUTE_HIDDEN InputstreamCapabilities + : public CStructHdl<InputstreamCapabilities, INPUTSTREAM_CAPABILITIES> +{ + /*! \cond PRIVATE */ + friend class CInstanceInputStream; + /*! \endcond */ - /// supports interface IPosTime - SUPPORTS_IPOSTIME = (1 << 1), +public: + /*! \cond PRIVATE */ + InputstreamCapabilities() = default; + InputstreamCapabilities(const InputstreamCapabilities& stream) : CStructHdl(stream) {} + /*! \endcond */ - /// supports interface IDisplayTime - SUPPORTS_IDISPLAYTIME = (1 << 2), + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help Value Help + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities :</b> + /// | Name | Type | Set call | Get call + /// |------|------|----------|---------- + /// | **Capabilities bit mask** | `uint32_t` | @ref InputstreamCapabilities::SetMask "SetMask" | @ref InputstreamCapabilities::GetMask "GetMask" - /// supports seek - SUPPORTS_SEEK = (1 << 3), + /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities + ///@{ - /// supports pause - SUPPORTS_PAUSE = (1 << 4), + /// @brief Set of supported capabilities. + void SetMask(uint32_t mask) const { m_cStructure->m_mask = mask; } - /// supports interface ITime - SUPPORTS_ITIME = (1 << 5), + /// @brief Get of supported capabilities. + uint32_t GetMask() const { return m_cStructure->m_mask; } - /// supports interface IChapter - SUPPORTS_ICHAPTER = (1 << 6), - }; + ///@} - /// set of supported capabilities - uint32_t m_mask; - }; +private: + InputstreamCapabilities(const INPUTSTREAM_CAPABILITIES* stream) : CStructHdl(stream) {} + InputstreamCapabilities(INPUTSTREAM_CAPABILITIES* stream) : CStructHdl(stream) {} +}; +///@} +//------------------------------------------------------------------------------ + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata class InputstreamMasteringMetadata +/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface +/// @brief **Mastering metadata.**\n +/// Describes the metadata for [HDR10](https://en.wikipedia.org/wiki/High-dynamic-range_video). +/// +/// Used when video is compressed using [High Efficiency Video Coding (HEVC)](https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding). +/// This is used to describe the capabilities of the display used to master the +/// content and the luminance values of the content. +/// +/// Used on @ref kodi::addon::InputstreamInfo::SetMasteringMetadata and @ref kodi::addon::InputstreamInfo::GetMasteringMetadata. +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata_Help +/// +///@{ +class ATTRIBUTE_HIDDEN InputstreamMasteringMetadata + : public CStructHdl<InputstreamMasteringMetadata, INPUTSTREAM_MASTERING_METADATA> +{ + /*! \cond PRIVATE */ + friend class CInstanceInputStream; + friend class InputstreamInfo; + /*! \endcond */ - /*! - * @brief structure of key/value pairs passed to addon on Open() - */ - struct INPUTSTREAM +public: + /*! \cond PRIVATE */ + InputstreamMasteringMetadata() = default; + InputstreamMasteringMetadata(const InputstreamMasteringMetadata& stream) : CStructHdl(stream) {} + /*! \endcond */ + + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata_Help Value Help + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata :</b> + /// | Name | Type | Set call | Get call + /// |------|------|----------|---------- + /// | **Chromaticity X coordinates of the red** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryR_ChromaticityX "SetPrimaryR_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryR_ChromaticityX "GetPrimaryR_ChromaticityX" + /// | **Chromaticity Y coordinates of the red** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryR_ChromaticityY "SetPrimaryR_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryR_ChromaticityY "GetPrimaryR_ChromaticityY" + /// | **Chromaticity X coordinates of the green** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryG_ChromaticityX "SetPrimaryG_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryG_ChromaticityX "GetPrimaryG_ChromaticityX" + /// | **Chromaticity Y coordinates of the green** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryG_ChromaticityY "SetPrimaryG_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryG_ChromaticityY "GetPrimaryG_ChromaticityY" + /// | **Chromaticity X coordinates of the blue** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryB_ChromaticityX "SetPrimaryB_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryB_ChromaticityX "GetPrimaryB_ChromaticityX" + /// | **Chromaticity Y coordinates of the blue** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryB_ChromaticityY "SetPrimaryB_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryB_ChromaticityY "GetPrimaryB_ChromaticityY" + /// | **Chromaticity X coordinates of the white point** | `double` | @ref InputstreamMasteringMetadata::SetWhitePoint_ChromaticityX "SetWhitePoint_ChromaticityX" | @ref InputstreamMasteringMetadata::GetWhitePoint_ChromaticityX "GetWhitePoint_ChromaticityX" + /// | **Chromaticity Y coordinates of the white point** | `double` | @ref InputstreamMasteringMetadata::SetWhitePoint_ChromaticityY "SetWhitePoint_ChromaticityY" | @ref InputstreamMasteringMetadata::GetWhitePoint_ChromaticityY "GetWhitePoint_ChromaticityY" + /// | **Maximum number of bits of the display** | `double` | @ref InputstreamMasteringMetadata::SetLuminanceMax "SetLuminanceMax" | @ref InputstreamMasteringMetadata::GetLuminanceMax "GetLuminanceMax" + /// | **Minimum number of bits of the display** | `double` | @ref InputstreamMasteringMetadata::SetLuminanceMin "SetLuminanceMin" | @ref InputstreamMasteringMetadata::GetLuminanceMin "GetLuminanceMin" + + /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata + ///@{ + + /// @brief Metadata class compare. + /// + /// To compare the metadata with another one. + /// + /// @return true if they equal, false otherwise + bool operator==(const kodi::addon::InputstreamMasteringMetadata& right) const { - const char* m_strURL; - const char* m_mimeType; + if (memcmp(m_cStructure, right.m_cStructure, sizeof(INPUTSTREAM_MASTERING_METADATA)) == 0) + return true; + return false; + } - unsigned int m_nCountInfoValues; - struct LISTITEMPROPERTY - { - const char* m_strKey; - const char* m_strValue; - } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT]; - - const char* m_libFolder; - const char* m_profileFolder; - }; - - /*! - * @brief Array of stream IDs - */ - struct INPUTSTREAM_IDS - { - unsigned int m_streamCount; - unsigned int m_streamIds[INPUTSTREAM_MAX_STREAM_COUNT]; - }; - - /*! - * @brief MASTERING Metadata - */ - struct INPUTSTREAM_MASTERING_METADATA - { - double primary_r_chromaticity_x; - double primary_r_chromaticity_y; - double primary_g_chromaticity_x; - double primary_g_chromaticity_y; - double primary_b_chromaticity_x; - double primary_b_chromaticity_y; - double white_point_chromaticity_x; - double white_point_chromaticity_y; - double luminance_max; - double luminance_min; - }; - - /*! - * @brief CONTENTLIGHT Metadata - */ - struct INPUTSTREAM_CONTENTLIGHT_METADATA - { - uint64_t max_cll; - uint64_t max_fall; - }; - - /*! - * @brief stream properties - */ - struct INPUTSTREAM_INFO - { - enum STREAM_TYPE - { - TYPE_NONE = 0, - TYPE_VIDEO, - TYPE_AUDIO, - TYPE_SUBTITLE, - TYPE_TELETEXT, - TYPE_RDS, - } m_streamType; - - enum Codec_FEATURES : uint32_t - { - FEATURE_DECODE = 1 - }; - uint32_t m_features; + /// @brief Set the chromaticity coordinates of the red value in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// X coordinate. The values are normalized to 50,000. + void SetPrimaryR_ChromaticityX(double value) { m_cStructure->primary_r_chromaticity_x = value; } + + /// @brief Get the chromaticity X coordinates of the red value. + double GetPrimaryR_ChromaticityX() { return m_cStructure->primary_r_chromaticity_x; } + + /// @brief The chromaticity coordinates of the red value in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// Y coordinate. The values are normalized to 50,000. + void SetPrimaryR_ChromaticityY(double value) { m_cStructure->primary_r_chromaticity_y = value; } + + /// @brief Get the chromaticity Y coordinates of the red value. + double GetPrimaryR_ChromaticityY() { return m_cStructure->primary_r_chromaticity_y; } + + /// @brief Set the chromaticity coordinates of the green value in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// X coordinate. The values are normalized to 50,000. + void SetPrimaryG_ChromaticityX(double value) { m_cStructure->primary_g_chromaticity_x = value; } + + /// @brief Get the chromaticity X coordinates of the green value. + double GetPrimaryG_ChromaticityX() { return m_cStructure->primary_g_chromaticity_x; } + + /// @brief Set the chromaticity coordinates of the green value in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// Y coordinate. The values are normalized to 50,000. + void SetPrimaryG_ChromaticityY(double value) { m_cStructure->primary_g_chromaticity_y = value; } + + /// @brief Get the chromaticity Y coordinates of the green value. + double GetPrimaryG_ChromaticityY() { return m_cStructure->primary_g_chromaticity_y; } + + /// @brief The chromaticity coordinates of the blue value in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// X coordinate. The values are normalized to 50,000. + void SetPrimaryB_ChromaticityX(double value) { m_cStructure->primary_b_chromaticity_x = value; } + + /// @brief Get the chromaticity X coordinates of the blue value. + double GetPrimaryB_ChromaticityX() { return m_cStructure->primary_b_chromaticity_x; } + + /// @brief The chromaticity coordinates of the blue value in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// Y coordinate. The values are normalized to 50,000. + void SetPrimaryB_ChromaticityY(double value) { m_cStructure->primary_b_chromaticity_y = value; } + + /// @brief Get the chromaticity Y coordinates of the blue value. + double GetPrimaryB_ChromaticityY() { return m_cStructure->primary_b_chromaticity_y; } + + /// @brief Set the chromaticity coordinates of the white point in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// X coordinate. The values are normalized to 50,000. + void SetWhitePoint_ChromaticityX(double value) + { + m_cStructure->white_point_chromaticity_x = value; + } - enum STREAM_FLAGS : uint32_t - { - FLAG_NONE = 0x0000, - FLAG_DEFAULT = 0x0001, - FLAG_DUB = 0x0002, - FLAG_ORIGINAL = 0x0004, - FLAG_COMMENT = 0x0008, - FLAG_LYRICS = 0x0010, - FLAG_KARAOKE = 0x0020, - FLAG_FORCED = 0x0040, - FLAG_HEARING_IMPAIRED = 0x0080, - FLAG_VISUAL_IMPAIRED = 0x0100, - }; - - // Keep in sync with AVColorSpace - enum COLORSPACE - { - COLORSPACE_RGB = 0, - COLORSPACE_BT709 = 1, - COLORSPACE_UNSPECIFIED = 2, - COLORSPACE_UNKNOWN = COLORSPACE_UNSPECIFIED, // compatibility - COLORSPACE_RESERVED = 3, - COLORSPACE_FCC = 4, - COLORSPACE_BT470BG = 5, - COLORSPACE_SMPTE170M = 6, - COLORSPACE_SMPTE240M = 7, - COLORSPACE_YCGCO = 8, - COLORSPACE_YCOCG = COLORSPACE_YCGCO, - COLORSPACE_BT2020_NCL = 9, - COLORSPACE_BT2020_CL = 10, - COLORSPACE_SMPTE2085 = 11, - COLORSPACE_CHROMA_DERIVED_NCL = 12, - COLORSPACE_CHROMA_DERIVED_CL = 13, - COLORSPACE_ICTCP = 14, - COLORSPACE_MAX - }; - - // Keep in sync with AVColorPrimaries - enum COLORPRIMARIES : int32_t - { - COLORPRIMARY_RESERVED0 = 0, - COLORPRIMARY_BT709 = 1, - COLORPRIMARY_UNSPECIFIED = 2, - COLORPRIMARY_RESERVED = 3, - COLORPRIMARY_BT470M = 4, - COLORPRIMARY_BT470BG = 5, - COLORPRIMARY_SMPTE170M = 6, - COLORPRIMARY_SMPTE240M = 7, - COLORPRIMARY_FILM = 8, - COLORPRIMARY_BT2020 = 9, - COLORPRIMARY_SMPTE428 = 10, - COLORPRIMARY_SMPTEST428_1 = COLORPRIMARY_SMPTE428, - COLORPRIMARY_SMPTE431 = 11, - COLORPRIMARY_SMPTE432 = 12, - COLORPRIMARY_JEDEC_P22 = 22, - COLORPRIMARY_MAX - }; - - // Keep in sync with AVColorRange - enum COLORRANGE + /// @brief Get the chromaticity X coordinates of the white point + double GetWhitePoint_ChromaticityX() { return m_cStructure->white_point_chromaticity_x; } + + /// @brief Set the chromaticity coordinates of the white point in the + /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space. + /// + /// Y coordinate. The values are normalized to 50,000. + void SetWhitePoint_ChromaticityY(double value) + { + m_cStructure->white_point_chromaticity_y = value; + } + + /// @brief Get the chromaticity Y coordinates of the white point. + double GetWhitePoint_ChromaticityY() { return m_cStructure->white_point_chromaticity_y; } + + /// @brief Set the maximum number of bits of the display used to master the content. + /// + /// Values are normalized to 10,000. + void SetLuminanceMax(double value) { m_cStructure->luminance_max = value; } + + /// @brief Get the maximum number of bits of the display. + double GetLuminanceMax() { return m_cStructure->luminance_max; } + + /// @brief Set the minimum number of bits of the display used to master the content. + /// + /// Values are normalized to 10,000. + void SetLuminanceMin(double value) { m_cStructure->luminance_min = value; } + + /// @brief Get the minimum number of bits of the display. + double GetLuminanceMin() { return m_cStructure->luminance_min; } + + ///@} + +private: + InputstreamMasteringMetadata(const INPUTSTREAM_MASTERING_METADATA* stream) : CStructHdl(stream) {} + InputstreamMasteringMetadata(INPUTSTREAM_MASTERING_METADATA* stream) : CStructHdl(stream) {} +}; +///@} +//------------------------------------------------------------------------------ + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata class InputstreamContentlightMetadata +/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface +/// @brief **Contentlight metadata**\n +/// Describes the metadata for [HDR10](https://en.wikipedia.org/wiki/High-dynamic-range_video). +/// See also @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata "InputstreamMasteringMetadata". +/// +/// Used on @ref kodi::addon::InputstreamInfo::SetContentLightMetadata and @ref kodi::addon::InputstreamInfo::GetContentLightMetadata. +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata_Help +/// +///@{ +class ATTRIBUTE_HIDDEN InputstreamContentlightMetadata + : public CStructHdl<InputstreamContentlightMetadata, INPUTSTREAM_CONTENTLIGHT_METADATA> +{ + /*! \cond PRIVATE */ + friend class CInstanceInputStream; + friend class InputstreamInfo; + /*! \endcond */ + +public: + /*! \cond PRIVATE */ + InputstreamContentlightMetadata() = default; + InputstreamContentlightMetadata(const InputstreamContentlightMetadata& stream) + : CStructHdl(stream) + { + } + /*! \endcond */ + + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata_Help Value Help + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata :</b> + /// | Name | Type | Set call | Get call + /// |------|------|----------|---------- + /// | **Maximum content light level** | `double` | @ref InputstreamContentlightMetadata::SetMaxCll "SetMaxCll" | @ref InputstreamContentlightMetadata::GetMaxCll "GetMaxCll" + /// | **Maximum frame average light level** | `double` | @ref InputstreamContentlightMetadata::SetMaxFall "SetMaxFall" | @ref InputstreamContentlightMetadata::GetMaxFall "GetMaxFall" + + /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata + ///@{ + + /// @brief Metadata class compare. + /// + /// To compare the metadata with another one. + /// + /// @return true if they equal, false otherwise + bool operator==(const kodi::addon::InputstreamContentlightMetadata& right) const + { + if (memcmp(m_cStructure, right.m_cStructure, sizeof(INPUTSTREAM_CONTENTLIGHT_METADATA)) == 0) + return true; + return false; + } + + /// @brief Set the maximum content light level (MaxCLL). + /// + /// This is the bit value corresponding to the brightest pixel used anywhere + /// in the content. + void SetMaxCll(uint64_t value) { m_cStructure->max_cll = value; } + + /// @brief Get the maximum content light level (MaxCLL). + uint64_t GetMaxCll() { return m_cStructure->max_cll; } + + /// @brief Set the maximum frame average light level (MaxFALL). + /// + /// This is the bit value corresponding to the average luminance of the frame + /// which has the brightest average luminance anywhere in the content. + void SetMaxFall(uint64_t value) { m_cStructure->max_fall = value; } + + /// @brief Get the maximum frame average light level (MaxFALL). + uint64_t GetMaxFall() { return m_cStructure->max_fall; } + + ///@} + +private: + InputstreamContentlightMetadata(const INPUTSTREAM_CONTENTLIGHT_METADATA* stream) + : CStructHdl(stream) + { + } + InputstreamContentlightMetadata(INPUTSTREAM_CONTENTLIGHT_METADATA* stream) : CStructHdl(stream) {} +}; +///@} +//------------------------------------------------------------------------------ + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo class InputstreamInfo +/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface +/// @brief **Inputstream add-on stream info**\n +/// This is used to give Kodi the associated and necessary data for an open stream. +/// +/// Used on @ref kodi::addon::CInstanceInputStream::GetStream(). +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help +/// +///@{ +class ATTRIBUTE_HIDDEN InputstreamInfo : public CStructHdl<InputstreamInfo, INPUTSTREAM_INFO> +{ + /*! \cond PRIVATE */ + friend class CInstanceInputStream; + /*! \endcond */ + +public: + /*! \cond PRIVATE */ + InputstreamInfo() = default; + InputstreamInfo(const InputstreamInfo& stream) : CStructHdl(stream) { CopyExtraData(); } + /*! \endcond */ + + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help Value Help + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo :</b> + /// | Name | Type used | Required | Set call | Get call + /// |------|-----------|----------|----------|--------- + /// | **Stream type** | all | yes | @ref InputstreamInfo::SetStreamType "SetStreamType" | @ref InputstreamInfo::GetStreamType "GetStreamType" + /// | **Feature flags** | all | yes | @ref InputstreamInfo::SetFeatures "SetFeatures" | @ref InputstreamInfo::GetFeatures "GetFeatures" + /// | **Flags** | all | yes | @ref InputstreamInfo::SetFlags "SetFlags" | @ref InputstreamInfo::GetFlags "GetFlags" + /// | **Name** | all | no | @ref InputstreamInfo::SetName "SetName" | @ref InputstreamInfo::GetName "GetName" + /// | **Codec name** | all | yes | @ref InputstreamInfo::SetCodecName "SetCodecName" | @ref InputstreamInfo::GetCodecName "GetCodecName" + /// | **Codec internal name** | all | no | @ref InputstreamInfo::SetCodecInternalName "SetCodecInternalName" | @ref InputstreamInfo::GetCodecInternalName "GetCodecInternalName" + /// | **Codec Profile** | all | no | @ref InputstreamInfo::SetCodecProfile "SetCodecProfile" | @ref InputstreamInfo::GetCodecProfile "GetCodecProfile" + /// | **Physical index** | all | yes | @ref InputstreamInfo::SetPhysicalIndex "SetPhysicalIndex" | @ref InputstreamInfo::GetPhysicalIndex "GetPhysicalIndex" + /// | **Extra data** | Subtitle / all | Type related required | @ref InputstreamInfo::SetExtraData "SetExtraData" | @ref InputstreamInfo::GetExtraData "GetExtraData" + /// | **RFC 5646 language code** | all | no | @ref InputstreamInfo::SetLanguage "SetLanguage" | @ref InputstreamInfo::GetLanguage "GetLanguage" + /// | **FPS scale** | Video | Type related required | @ref InputstreamInfo::SetFpsScale "SetFpsScale" | @ref InputstreamInfo::GetFpsScale "GetFpsScale" + /// | **FPS rate** | Video | Type related required | @ref InputstreamInfo::SetFpsRate "SetFpsRate" | @ref InputstreamInfo::GetFpsRate "GetFpsRate" + /// | **Height** | Video | Type related required | @ref InputstreamInfo::SetHeight "SetHeight" | @ref InputstreamInfo::GetHeight "GetHeight" + /// | **Width** | Video | Type related required | @ref InputstreamInfo::SetWidth "SetWidth" | @ref InputstreamInfo::GetWidth "GetWidth" + /// | **Aspect** | Video | Type related required | @ref InputstreamInfo::SetAspect "SetAspect" | @ref InputstreamInfo::GetAspect "GetAspect" + /// | **Channel quantity** | Audio | Type related required | @ref InputstreamInfo::SetChannels "SetChannels" | @ref InputstreamInfo::GetChannels "GetChannels" + /// | **Sample rate** | Audio | Type related required | @ref InputstreamInfo::SetSampleRate "SetSampleRate" | @ref InputstreamInfo::GetSampleRate "GetSampleRate" + /// | **Bit rate** | Audio | Type related required | @ref InputstreamInfo::SetBitRate "SetBitRate" | @ref InputstreamInfo::GetBitRate "GetBitRate" + /// | **Bits per sample** | Audio | Type related required | @ref InputstreamInfo::SetBitsPerSample "SetBitsPerSample" | @ref InputstreamInfo::GetBitsPerSample "GetBitsPerSample" + /// | **Block align** | | no | @ref InputstreamInfo::SetBlockAlign "SetBlockAlign" | @ref InputstreamInfo::GetBlockAlign "GetBlockAlign" + /// | **Crypto session info** | | no | @ref InputstreamInfo::SetCryptoSession "SetCryptoSession" | @ref InputstreamInfo::GetCryptoSession "GetCryptoSession" + /// | **Four CC code** | | no | @ref InputstreamInfo::SetCodecFourCC "SetCodecFourCC" | @ref InputstreamInfo::GetCodecFourCC "GetCodecFourCC" + /// | **Color space** | | no | @ref InputstreamInfo::SetColorSpace "SetColorSpace" | @ref InputstreamInfo::GetColorSpace "GetColorSpace" + /// | **Color range** | | no | @ref InputstreamInfo::SetColorRange "SetColorRange" | @ref InputstreamInfo::GetColorRange "GetColorRange" + /// | **Color primaries** | | no | @ref InputstreamInfo::SetColorPrimaries "SetColorPrimaries" | @ref InputstreamInfo::GetColorPrimaries "GetColorPrimaries" + /// | **Color transfer characteristic** | | no | @ref InputstreamInfo::SetColorTransferCharacteristic "SetColorTransferCharacteristic" | @ref InputstreamInfo::GetColorTransferCharacteristic "GetColorTransferCharacteristic" + /// | **Mastering metadata** | | no | @ref InputstreamInfo::SetMasteringMetadata "SetMasteringMetadata" | @ref InputstreamInfo::GetMasteringMetadata "GetMasteringMetadata" + /// | **Content light metadata** | | no | @ref InputstreamInfo::SetContentLightMetadata "SetContentLightMetadata" | @ref InputstreamInfo::GetContentLightMetadata "GetContentLightMetadata" + /// + + /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo + ///@{ + + /// @brief Set the wanted stream type. + /// + /// @param[in] streamType By @ref INPUTSTREAM_TYPE defined type + void SetStreamType(INPUTSTREAM_TYPE streamType) { m_cStructure->m_streamType = streamType; } + + /// @brief To get with @ref SetStreamType changed values. + INPUTSTREAM_TYPE GetStreamType() const { return m_cStructure->m_streamType; } + + /// @brief Set special supported feature flags of inputstream. + /// + /// @param[in] features By @ref INPUTSTREAM_CODEC_FEATURES defined type + void SetFeatures(uint32_t features) { m_cStructure->m_features = features; } + + /// @brief To get with @ref SetFeatures changed values. + uint32_t GetFeatures() const { return m_cStructure->m_features; } + + /// @brief Set supported flags of inputstream. + /// + /// @param[in] flags The on @ref INPUTSTREAM_FLAGS defined flags to set + void SetFlags(uint32_t flags) { m_cStructure->m_flags = flags; } + + /// @brief To get with @ref SetFeatures changed values. + uint32_t GetFlags() const { return m_cStructure->m_flags; } + + /// @brief (optional) Name of the stream, leave empty for default handling. + /// + /// @param[in] name Stream name + void SetName(const std::string& name) + { + strncpy(m_cStructure->m_name, name.c_str(), INPUTSTREAM_MAX_STRING_NAME_SIZE); + } + + /// @brief To get with @ref SetName changed values. + std::string GetName() const { return m_cStructure->m_name; } + + /// @brief (required) Name of codec according to ffmpeg. + /// + /// See https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_desc.c about + /// available names. + /// + /// @remark On @ref INPUTSTREAM_TYPE_TELETEXT and @ref INPUTSTREAM_TYPE_RDS + /// this can be ignored and leaved empty. + /// + /// @param[in] codeName Codec name + void SetCodecName(const std::string& codecName) + { + strncpy(m_cStructure->m_codecName, codecName.c_str(), INPUTSTREAM_MAX_STRING_CODEC_SIZE); + } + + /// @brief To get with @ref SetCodecName changed values. + std::string GetCodecName() const { return m_cStructure->m_codecName; } + + /// @brief (optional) Internal name of codec (selectionstream info). + /// + /// @param[in] codecName Internal codec name + void SetCodecInternalName(const std::string& codecName) + { + strncpy(m_cStructure->m_codecInternalName, codecName.c_str(), + INPUTSTREAM_MAX_STRING_CODEC_SIZE); + } + + /// @brief To get with @ref SetCodecInternalName changed values. + std::string GetCodecInternalName() const { return m_cStructure->m_codecInternalName; } + + /// @brief (optional) The profile of the codec. + /// + /// @param[in] codecProfile Values with @ref STREAMCODEC_PROFILE to use + void SetCodecProfile(STREAMCODEC_PROFILE codecProfile) + { + m_cStructure->m_codecProfile = codecProfile; + } + + /// @brief To get with @ref SetCodecProfile changed values. + STREAMCODEC_PROFILE GetCodecProfile() const { return m_cStructure->m_codecProfile; } + + /// @brief (required) Physical index. + /// + /// @param[in] id Index identifier + void SetPhysicalIndex(unsigned int id) { m_cStructure->m_pID = id; } + + /// @brief To get with @ref SetPhysicalIndex changed values. + unsigned int GetPhysicalIndex() const { return m_cStructure->m_pID; } + + /// @brief Additional data where can needed on streams. + /// + /// @param[in] extraData List with memory of extra data + void SetExtraData(const std::vector<uint8_t>& extraData) + { + m_extraData = extraData; + m_cStructure->m_ExtraData = m_extraData.data(); + m_cStructure->m_ExtraSize = m_extraData.size(); + } + + /// @brief Additional data where can needed on streams. + /// + /// @param[in] extraData Pointer with memory of extra data + /// @param[in] extraSize Size to store + void SetExtraData(const uint8_t* extraData, size_t extraSize) + { + m_extraData.clear(); + if (extraData && extraSize > 0) { - COLORRANGE_UNKNOWN = 0, - COLORRANGE_LIMITED, - COLORRANGE_FULLRANGE, - COLORRANGE_MAX - }; - - // keep in sync with AVColorTransferCharacteristic - enum COLORTRC : int32_t + for (size_t i = 0; i < extraSize; ++i) + m_extraData.emplace_back(extraData[i]); + } + + m_cStructure->m_ExtraData = m_extraData.data(); + m_cStructure->m_ExtraSize = m_extraData.size(); + } + + /// @brief To get with @ref SetExtraData changed values. + const std::vector<uint8_t>& GetExtraData() { return m_extraData; } + + /// @brief To get size with @ref SetExtraData changed values. + size_t GetExtraDataSize() { return m_extraData.size(); } + + /// @brief Compare extra data from outside with class + /// + /// @param[in] extraData Pointer with memory of extra data for compare + /// @param[in] extraSize Size to compare + /// @return true if they equal, false otherwise + bool CompareExtraData(const uint8_t* extraData, size_t extraSize) const + { + if (!extraData || m_extraData.size() != extraSize) + return false; + for (size_t i = 0; i < extraSize; ++i) { - COLORTRC_RESERVED0 = 0, - COLORTRC_BT709 = 1, - COLORTRC_UNSPECIFIED = 2, - COLORTRC_RESERVED = 3, - COLORTRC_GAMMA22 = 4, - COLORTRC_GAMMA28 = 5, - COLORTRC_SMPTE170M = 6, - COLORTRC_SMPTE240M = 7, - COLORTRC_LINEAR = 8, - COLORTRC_LOG = 9, - COLORTRC_LOG_SQRT = 10, - COLORTRC_IEC61966_2_4 = 11, - COLORTRC_BT1361_ECG = 12, - COLORTRC_IEC61966_2_1 = 13, - COLORTRC_BT2020_10 = 14, - COLORTRC_BT2020_12 = 15, - COLORTRC_SMPTE2084 = 16, - COLORTRC_SMPTEST2084 = COLORTRC_SMPTE2084, - COLORTRC_SMPTE428 = 17, - COLORTRC_SMPTEST428_1 = COLORTRC_SMPTE428, - COLORTRC_ARIB_STD_B67 = 18, - COLORTRC_MAX - }; + if (m_extraData[i] != extraData[i]) + return false; + } + return true; + } - uint32_t m_flags; + /// @brief Clear additional data. + void ClearExtraData() + { + m_extraData.clear(); + m_cStructure->m_ExtraData = m_extraData.data(); + m_cStructure->m_ExtraSize = m_extraData.size(); + } - //! @brief (optional) name of the stream, \0 for default handling - char m_name[INPUTSTREAM_MAX_STRING_NAME_SIZE]; + /// @brief RFC 5646 language code (empty string if undefined). + /// + /// @param[in] language The language to set + void SetLanguage(const std::string& language) + { + strncpy(m_cStructure->m_language, language.c_str(), INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE); + } - //! @brief (required) name of codec according to ffmpeg - char m_codecName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; + /// @brief To get with @ref SetLanguage changed values. + std::string GetLanguage() const { return m_cStructure->m_language; } - //! @brief (optional) internal name of codec (selectionstream info) - char m_codecInternalName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; + /// @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps. + /// + /// @param[in] fpsScale Scale rate + void SetFpsScale(unsigned int fpsScale) { m_cStructure->m_FpsScale = fpsScale; } - //! @brief (optional) the profile of the codec - STREAMCODEC_PROFILE m_codecProfile; + /// @brief To get with @ref SetFpsScale changed values. + unsigned int GetFpsScale() const { return m_cStructure->m_FpsScale; } - //! @brief (required) physical index - unsigned int m_pID; + /// @brief Rate to use for stream. + /// + /// @param[in] fpsRate Rate to use + void SetFpsRate(unsigned int fpsRate) { m_cStructure->m_FpsRate = fpsRate; } - const uint8_t* m_ExtraData; - unsigned int m_ExtraSize; + /// @brief To get with @ref SetFpsRate changed values. + unsigned int GetFpsRate() const { return m_cStructure->m_FpsRate; } - //! @brief RFC 5646 language code (empty string if undefined) - char m_language[INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE]; + /// @brief Height of the stream reported by the demuxer. + /// + /// @param[in] height Height to use + void SetHeight(unsigned int height) { m_cStructure->m_Height = height; } - //! Video stream related data - //@{ + /// @brief To get with @ref SetHeight changed values. + unsigned int GetHeight() const { return m_cStructure->m_Height; } - //! @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps - unsigned int m_FpsScale; + /// @brief Width of the stream reported by the demuxer. + /// + /// @param[in] width Width to use + void SetWidth(unsigned int width) { m_cStructure->m_Width = width; } - unsigned int m_FpsRate; + /// @brief To get with @ref SetWidth changed values. + unsigned int GetWidth() const { return m_cStructure->m_Width; } - //! @brief height of the stream reported by the demuxer - unsigned int m_Height; + /// @brief Display aspect of stream. + /// + /// @param[in] aspect Aspect ratio to use + void SetAspect(float aspect) { m_cStructure->m_Aspect = aspect; } - //! @brief width of the stream reported by the demuxer - unsigned int m_Width; + /// @brief To get with @ref SetAspect changed values. + float GetAspect() const { return m_cStructure->m_Aspect; } - //! @brief display aspect of stream - float m_Aspect; - - //@} - - //! Audio stream related data - //@{ - - //! @brief (required) amount of channels - unsigned int m_Channels; - - //! @brief (required) sample rate - unsigned int m_SampleRate; - - //! @brief (required) bit rate - unsigned int m_BitRate; - - //! @brief (required) bits per sample - unsigned int m_BitsPerSample; - - unsigned int m_BlockAlign; - - //@} - - CRYPTO_INFO m_cryptoInfo; - - // new in API version 2.0.8 - //@{ - //! @brief Codec If available, the fourcc code codec - unsigned int m_codecFourCC; - - //! @brief definition of colorspace - COLORSPACE m_colorSpace; - - //! @brief color range if available - COLORRANGE m_colorRange; - //@} - - //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1 - //@{ - COLORPRIMARIES m_colorPrimaries; - COLORTRC m_colorTransferCharacteristic; - //@} - - //! @brief mastering static Metadata - INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata; - - //! @brief content light static Metadata - INPUTSTREAM_CONTENTLIGHT_METADATA* m_contentLightMetadata; - }; + /// @brief (required) Amount of channels. + /// + /// @param[in] sampleRate Channels to use + void SetChannels(unsigned int channels) { m_cStructure->m_Channels = channels; } - struct INPUTSTREAM_TIMES - { - time_t startTime; - double ptsStart; - double ptsBegin; - double ptsEnd; - }; + /// @brief To get with @ref SetChannels changed values. + unsigned int GetChannels() const { return m_cStructure->m_Channels; } - /*! - * @brief "C" ABI Structures to transfer the methods from this to Kodi - */ + /// @brief (required) Sample rate. + /// + /// @param[in] sampleRate Rate to use + void SetSampleRate(unsigned int sampleRate) { m_cStructure->m_SampleRate = sampleRate; } - // this are properties given to the addon on create - // at this time we have no parameters for the addon - typedef struct AddonProps_InputStream /* internal */ + /// @brief To get with @ref SetSampleRate changed values. + unsigned int GetSampleRate() const { return m_cStructure->m_SampleRate; } + + /// @brief Bit rate. + /// + /// @param[in] bitRate Rate to use + void SetBitRate(unsigned int bitRate) { m_cStructure->m_BitRate = bitRate; } + + /// @brief To get with @ref SetBitRate changed values. + unsigned int GetBitRate() const { return m_cStructure->m_BitRate; } + + /// @brief (required) Bits per sample. + /// + /// @param[in] bitsPerSample Bits per sample to use + void SetBitsPerSample(unsigned int bitsPerSample) { - int dummy; - } AddonProps_InputStream; + m_cStructure->m_BitsPerSample = bitsPerSample; + } + + /// @brief To get with @ref SetBitsPerSample changed values. + unsigned int GetBitsPerSample() const { return m_cStructure->m_BitsPerSample; } + + /// @brief To set the necessary stream block alignment size. + /// + /// @param[in] blockAlign Block size in byte + void SetBlockAlign(unsigned int blockAlign) { m_cStructure->m_BlockAlign = blockAlign; } - typedef struct AddonToKodiFuncTable_InputStream /* internal */ + /// @brief To get with @ref SetBlockAlign changed values. + unsigned int GetBlockAlign() const { return m_cStructure->m_BlockAlign; } + + /// @brief To set stream crypto session informations. + /// + /// @param[in] cryptoSession The with @ref cpp_kodi_addon_inputstream_Defs_Interface_StreamCryptoSession setable info + /// + void SetCryptoSession(const kodi::addon::StreamCryptoSession& cryptoSession) { - KODI_HANDLE kodiInstance; - DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size); - DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance, - unsigned int data_size, - unsigned int encrypted_subsample_count); - void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet); - } AddonToKodiFuncTable_InputStream; + m_cryptoSession = cryptoSession; + m_cryptoSession.SetSessionId(cryptoSession.GetSessionId()); + memcpy(&m_cStructure->m_cryptoSession, m_cryptoSession.GetCStructure(), + sizeof(STREAM_CRYPTO_SESSION)); + } + + /// @brief To get with @ref GetCryptoSession changed values. + const kodi::addon::StreamCryptoSession& GetCryptoSession() const { return m_cryptoSession; } + + /// @brief Codec If available, the fourcc code codec. + /// + /// @param[in] codecFourCC Codec four CC code + void SetCodecFourCC(unsigned int codecFourCC) { m_cStructure->m_codecFourCC = codecFourCC; } + + /// @brief To get with @ref SetCodecFourCC changed values + unsigned int GetCodecFourCC() const { return m_cStructure->m_codecFourCC; } + + /// @brief Definition of colorspace. + /// + /// @param[in] colorSpace The with @ref INPUTSTREAM_COLORSPACE setable color space + void SetColorSpace(INPUTSTREAM_COLORSPACE colorSpace) { m_cStructure->m_colorSpace = colorSpace; } + + /// @brief To get with @ref SetColorSpace changed values. + INPUTSTREAM_COLORSPACE GetColorSpace() const { return m_cStructure->m_colorSpace; } - struct AddonInstance_InputStream; - typedef struct KodiToAddonFuncTable_InputStream /* internal */ + /// @brief Color range if available. + /// + /// @param[in] colorRange The with @ref INPUTSTREAM_COLORRANGE setable color space + void SetColorRange(INPUTSTREAM_COLORRANGE colorRange) { m_cStructure->m_colorRange = colorRange; } + + /// @brief To get with @ref SetColorRange changed values. + INPUTSTREAM_COLORRANGE GetColorRange() const { return m_cStructure->m_colorRange; } + + /// @brief Chromaticity coordinates of the source primaries. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1. + /// + /// @param[in] colorPrimaries The with @ref INPUTSTREAM_COLORPRIMARIES setable values + void SetColorPrimaries(INPUTSTREAM_COLORPRIMARIES colorPrimaries) { - KODI_HANDLE addonInstance; + m_cStructure->m_colorPrimaries = colorPrimaries; + } - bool(__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props); - void(__cdecl* close)(const AddonInstance_InputStream* instance); - const char*(__cdecl* get_path_list)(const AddonInstance_InputStream* instance); - void(__cdecl* get_capabilities)(const AddonInstance_InputStream* instance, - INPUTSTREAM_CAPABILITIES* capabilities); + /// @brief To get with @ref SetColorPrimaries changed values. + INPUTSTREAM_COLORPRIMARIES GetColorPrimaries() const { return m_cStructure->m_colorPrimaries; } - // IDemux - struct INPUTSTREAM_IDS(__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance); - struct INPUTSTREAM_INFO(__cdecl* get_stream)(const AddonInstance_InputStream* instance, - int streamid); - void(__cdecl* enable_stream)(const AddonInstance_InputStream* instance, - int streamid, - bool enable); - bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid); - void(__cdecl* demux_reset)(const AddonInstance_InputStream* instance); - void(__cdecl* demux_abort)(const AddonInstance_InputStream* instance); - void(__cdecl* demux_flush)(const AddonInstance_InputStream* instance); - DemuxPacket*(__cdecl* demux_read)(const AddonInstance_InputStream* instance); - bool(__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance, - double time, - bool backwards, - double* startpts); - void(__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed); - void(__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance, - int width, - int height); - - // IDisplayTime - int(__cdecl* get_total_time)(const AddonInstance_InputStream* instance); - int(__cdecl* get_time)(const AddonInstance_InputStream* instance); - - // ITime - bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES* times); - - // IPosTime - bool(__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms); - - int(__cdecl* read_stream)(const AddonInstance_InputStream* instance, - uint8_t* buffer, - unsigned int bufferSize); - int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance, - int64_t position, - int whence); - int64_t(__cdecl* position_stream)(const AddonInstance_InputStream* instance); - int64_t(__cdecl* length_stream)(const AddonInstance_InputStream* instance); - bool(__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance); - - // IChapter - int(__cdecl* get_chapter)(const AddonInstance_InputStream* instance); - int(__cdecl* get_chapter_count)(const AddonInstance_InputStream* instance); - const char*(__cdecl* get_chapter_name)(const AddonInstance_InputStream* instance, int ch); - int64_t(__cdecl* get_chapter_pos)(const AddonInstance_InputStream* instance, int ch); - bool(__cdecl* seek_chapter)(const AddonInstance_InputStream* instance, int ch); - - int(__cdecl* block_size_stream)(const AddonInstance_InputStream* instance); - } KodiToAddonFuncTable_InputStream; - - typedef struct AddonInstance_InputStream /* internal */ - { - AddonProps_InputStream* props; - AddonToKodiFuncTable_InputStream* toKodi; - KodiToAddonFuncTable_InputStream* toAddon; - } AddonInstance_InputStream; + /// @brief Color Transfer Characteristic. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.2. + /// + /// @param[in] colorTransferCharacteristic The with @ref INPUTSTREAM_COLORTRC setable characteristic + void SetColorTransferCharacteristic(INPUTSTREAM_COLORTRC colorTransferCharacteristic) + { + m_cStructure->m_colorTransferCharacteristic = colorTransferCharacteristic; + } -#ifdef __cplusplus -} /* extern "C" */ + /// @brief To get with @ref SetColorTransferCharacteristic changed values. + INPUTSTREAM_COLORTRC GetColorTransferCharacteristic() const + { + return m_cStructure->m_colorTransferCharacteristic; + } -namespace kodi -{ -namespace addon -{ + /// @brief Mastering static Metadata. + /// + /// Describes the metadata for HDR10, used when video is compressed using High + /// Efficiency Video Coding (HEVC). This is used to describe the capabilities + /// of the display used to master the content and the luminance values of the + /// content. + /// + /// @param[in] masteringMetadata The with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata setable metadata + void SetMasteringMetadata(const kodi::addon::InputstreamMasteringMetadata& masteringMetadata) + { + m_masteringMetadata = masteringMetadata; + m_cStructure->m_masteringMetadata = m_masteringMetadata; + } -class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance -{ -public: - explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "") - : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM, - !kodiVersion.empty() ? kodiVersion - : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM)) + /// @brief To get with @ref SetMasteringMetadata changed values. + const kodi::addon::InputstreamMasteringMetadata& GetMasteringMetadata() const { - if (CAddonBase::m_interface->globalSingleInstance != nullptr) - throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together " - "with single instance way is not allowed!"); + return m_masteringMetadata; + } - SetAddonStruct(instance, m_kodiVersion); + /// @brief Clear mastering static Metadata. + void ClearMasteringMetadata() { m_cStructure->m_masteringMetadata = nullptr; } + + /// @brief Content light static Metadata. + /// + /// The maximum content light level (MaxCLL) and frame average light level + /// (MaxFALL) for the metadata for HDR10. + /// + /// @param[in] contentLightMetadata The with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata setable metadata + void SetContentLightMetadata( + const kodi::addon::InputstreamContentlightMetadata& contentLightMetadata) + { + m_contentLightMetadata = contentLightMetadata; + m_cStructure->m_contentLightMetadata = m_contentLightMetadata; } - ~CInstanceInputStream() override = default; + /// @brief To get with @ref SetContentLightMetadata changed values. + const kodi::addon::InputstreamContentlightMetadata& GetContentLightMetadata() const + { + return m_contentLightMetadata; + } - /*! - * Open a stream. - * @param props - * @return True if the stream has been opened successfully, false otherwise. - * @remarks - */ - virtual bool Open(INPUTSTREAM& props) = 0; - - /*! - * Close an open stream. - * @remarks - */ - virtual void Close() = 0; + /// @brief Clear content light static Metadata. + void ClearContentLightMetadata() { m_cStructure->m_contentLightMetadata = nullptr; } - /*! - * Get Capabilities of this addon. - * @param capabilities The add-on's capabilities. - * @remarks - */ - virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0; - - /*! - * Get IDs of available streams - * @remarks - */ - virtual INPUTSTREAM_IDS GetStreamIds() = 0; - - /*! - * Get stream properties of a stream. - * @param streamid unique id of stream - * @return struc of stream properties - * @remarks - */ - virtual INPUTSTREAM_INFO GetStream(int streamid) = 0; - - /*! - * Enable or disable a stream. - * A disabled stream does not send demux packets - * @param streamid unique id of stream - * @param enable true for enable, false for disable - * @remarks - */ - virtual void EnableStream(int streamid, bool enable) = 0; - - /*! - * Opens a stream for playback. - * @param streamid unique id of stream - * @remarks - */ - virtual bool OpenStream(int streamid) = 0; + ///@} - /*! - * Reset the demultiplexer in the add-on. - * @remarks Required if bHandlesDemuxing is set to true. - */ - virtual void DemuxReset() {} +private: + InputstreamInfo(const INPUTSTREAM_INFO* stream) : CStructHdl(stream) { CopyExtraData(); } + InputstreamInfo(INPUTSTREAM_INFO* stream) : CStructHdl(stream) { CopyExtraData(); } - /*! - * Abort the demultiplexer thread in the add-on. - * @remarks Required if bHandlesDemuxing is set to true. - */ - virtual void DemuxAbort() {} + void CopyExtraData() + { + if (m_cStructure->m_ExtraData && m_cStructure->m_ExtraSize > 0) + { + for (unsigned int i = 0; i < m_cStructure->m_ExtraSize; ++i) + m_extraData.emplace_back(m_cStructure->m_ExtraData[i]); + } + if (m_cStructure->m_masteringMetadata) + m_masteringMetadata = m_cStructure->m_masteringMetadata; + if (m_cStructure->m_contentLightMetadata) + m_contentLightMetadata = m_cStructure->m_contentLightMetadata; + } + std::vector<uint8_t> m_extraData; + StreamCryptoSession m_cryptoSession; + InputstreamMasteringMetadata m_masteringMetadata; + InputstreamContentlightMetadata m_contentLightMetadata; +}; +///@} +//------------------------------------------------------------------------------ + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes class InputstreamTimes +/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface +/// @brief **Inputstream add-on times**\n +/// Used on @ref kodi::addon::CInstanceInputStream::GetTimes(). +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes_Help +/// +///@{ +class ATTRIBUTE_HIDDEN InputstreamTimes : public CStructHdl<InputstreamTimes, INPUTSTREAM_TIMES> +{ + /*! \cond PRIVATE */ + friend class CInstanceInputStream; + /*! \endcond */ - /*! - * Flush all data that's currently in the demultiplexer buffer in the add-on. - * @remarks Required if bHandlesDemuxing is set to true. - */ - virtual void DemuxFlush() {} +public: + /*! \cond PRIVATE */ + InputstreamTimes() = default; + InputstreamTimes(const InputstreamTimes& stream) : CStructHdl(stream) {} + /*! \endcond */ - /*! - * Read the next packet from the demultiplexer, if there is one. - * @return The next packet. - * If there is no next packet, then the add-on should return the - * packet created by calling AllocateDemuxPacket(0) on the callback. - * If the stream changed and Kodi's player needs to be reinitialised, - * then, the add-on should call AllocateDemuxPacket(0) on the - * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and - * return the value. - * The add-on should return NULL if an error occurred. - * @remarks Return NULL if this add-on won't provide this function. - */ - virtual DemuxPacket* DemuxRead() { return nullptr; } - - /*! - * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time - * Demuxer is required to set stream to an IDR frame - * @param time The absolute time since stream start - * @param backwards True to seek to keyframe BEFORE time, else AFTER - * @param startpts can be updated to point to where display should start - * @return True if the seek operation was possible - * @remarks Optional, and only used if addon has its own demuxer. - */ - virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; } + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes_Help Value Help + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes :</b> + /// | Name | Type | Set call | Get call + /// |------|------|----------|-------------------- + /// | **Start time** | `time_t` | @ref InputstreamTimes::SetStartTime "SetStartTime" | @ref InputstreamTimes::GetStartTime "GetStartTime" + /// | **PTS start** | `double` | @ref InputstreamTimes::SetPtsStart "SetPtsStart" | @ref InputstreamTimes::GetPtsStart "GetPtsStart" + /// | **PTS begin** | `double` | @ref InputstreamTimes::SetPtsBegin "SetPtsBegin" | @ref InputstreamTimes::GetPtsBegin "GetPtsBegin" + /// | **PTS end** | `double` | @ref InputstreamTimes::SetPtsEnd "SetPtsEnd" | @ref InputstreamTimes::GetPtsEnd "GetPtsEnd" + /// - /*! - * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed - * @param speed The requested playback speed - * @remarks Optional, and only used if addon has its own demuxer. - */ - virtual void DemuxSetSpeed(int speed) {} + /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes + ///@{ - /*! - * Sets desired width / height - * @param width / hight - */ - virtual void SetVideoResolution(int width, int height) {} + /// @brief Start time in milliseconds + void SetStartTime(time_t startTime) const { m_cStructure->startTime = startTime; } - /*! - * Totel time in ms - * @remarks - */ - virtual int GetTotalTime() { return -1; } + /// @brief To get with @ref SetStartTime changed values + time_t GetStartTime() const { return m_cStructure->startTime; } - /*! - * Playing time in ms - * @remarks - */ - virtual int GetTime() { return -1; } + /// @brief Start PTS + void SetPtsStart(double ptsStart) const { m_cStructure->ptsStart = ptsStart; } - /*! - * Get current timing values in PTS scale - * @remarks - */ - virtual bool GetTimes(INPUTSTREAM_TIMES& times) { return false; } + /// @brief To get with @ref SetPtsStart changed values + double GetPtsStart() const { return m_cStructure->ptsStart; } - /*! - * Positions inputstream to playing time given in ms - * @remarks - */ - virtual bool PosTime(int ms) { return false; } + /// @brief Begin PTS + void SetPtsBegin(double ptsBegin) const { m_cStructure->ptsBegin = ptsBegin; } - /*! - * Return currently selected chapter - * @remarks - */ - virtual int GetChapter() { return -1; }; + /// @brief To get with @ref SetPtsBegin changed values + double GetPtsBegin() const { return m_cStructure->ptsBegin; } - /*! - * Return number of available chapters - * @remarks - */ - virtual int GetChapterCount() { return 0; }; + /// @brief End PTS + void SetPtsEnd(double ptsEnd) const { m_cStructure->ptsEnd = ptsEnd; } - /*! - * Return name of chapter # ch - * @remarks - */ - virtual const char* GetChapterName(int ch) { return nullptr; }; + /// @brief To get with @ref SetPtsEnd changed values + double GetPtsEnd() const { return m_cStructure->ptsEnd; } - /*! - * Return position if chapter # ch in milliseconds - * @remarks - */ - virtual int64_t GetChapterPos(int ch) { return 0; }; + ///@} - /*! - * Seek to the beginning of chapter # ch - * @remarks - */ - virtual bool SeekChapter(int ch) { return false; }; +private: + InputstreamTimes(const INPUTSTREAM_TIMES* stream) : CStructHdl(stream) {} + InputstreamTimes(INPUTSTREAM_TIMES* stream) : CStructHdl(stream) {} +}; +///@} +//------------------------------------------------------------------------------ + +//============================================================================ +/// +/// @addtogroup cpp_kodi_addon_inputstream +/// @brief \cpp_class{ kodi::addon::CInstanceInputStream } +/// **Inputstream add-on instance** +/// +/// This instance type is for using input streams to video and audio, to process +/// and then give them to Kodi. +/// +/// This usage can be requested under various conditions, for example explicitly +/// by another addon, by a Mimetype protocol defined in `addon.xml` or supported +/// file extensions. +/// +/// In addition, stream files (* .strm) can be linked to an inputstream addon +/// using <b>`#KODIPROP:inputstream=<ADDON_NAME>`</b>. +/// +/// Include the header @ref Inputstream.h "#include <kodi/addon-instance/Inputstream.h>" +/// to use this class. +/// +/// ---------------------------------------------------------------------------- +/// +/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an inputstream addon: +/// +/// ~~~~~~~~~~~~~{.xml} +/// <?xml version="1.0" encoding="UTF-8"?> +/// <addon +/// id="inputstream.myspecialnamefor" +/// version="1.0.0" +/// name="My InputStream addon" +/// provider-name="Your Name"> +/// <requires>@ADDON_DEPENDS@</requires> +/// <extension +/// point="kodi.inputstream" +/// extension=".xyz|.zyx" +/// listitemprops="license_type|license_key|license_data|license_flags" +/// protocols="myspecialnamefor|myspecialnamefors" +/// library_@PLATFORM@="@LIBRARY_FILENAME@"/> +/// <extension point="xbmc.addon.metadata"> +/// <summary lang="en_GB">My InputStream addon</summary> +/// <description lang="en_GB">My InputStream description</description> +/// <platform>@PLATFORM@</platform> +/// </extension> +/// </addon> +/// ~~~~~~~~~~~~~ +/// +/// +/// At <b>`<extension point="kodi.inputstream" ...>`</b> the basic instance definition is declared, this is intended to identify the addon as an input stream and to see its supported types: +/// | Name | Description +/// |------|---------------------- +/// | <b>`point`</b> | The identification of the addon instance to inputstream is mandatory <b>`kodi.inputstream`</b>. In addition, the instance declared in the first <b>`<extension ... />`</b> is also +/// | <b>`extension`</b> | A filename extension is an identifier specified as a suffix to the name of a computer file where supported by addon. +/// | <b>`listitemprops`</b> | Values that are available to the addon at @ref InputstreamProperty::GetProperties() and that can be passed to @ref CInstanceInputStream::Open() ith the respective values. +/// | <b>`protocols`</b> | The streaming protocol is a special protocol supported by the addon for the transmission of streaming media data over a network. +/// | <b>`library_@PLATFORM@`</b> | The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated `addon.xml`. +/// +/// +/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml. +/// +/// +/// -------------------------------------------------------------------------- +/// +/// +/// **Example:** +/// +/// ~~~~~~~~~~~~~{.cpp} +/// #include <kodi/addon-instance/Inputstream.h> +/// +/// class CMyInputstream : public kodi::addon::CInstanceInputStream +/// { +/// public: +/// CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion); +/// +/// void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) override; +/// bool Open(const kodi::addon::InputstreamProperty& props) override; +/// void Close() override; +/// ... +/// }; +/// +/// CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion) +/// : kodi::addon::CInstanceInputStream(instance, kodiVersion) +/// { +/// ... +/// } +/// +/// void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) +/// { +/// capabilities.SetMask(INPUTSTREAM_SUPPORTS_IDEMUX | INPUTSTREAM_SUPPORTS_PAUSE); +/// } +/// +/// void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props) +/// { +/// std::string url = props.GetURL(); +/// ... +/// } +/// +/// void CMyInputstream::Close() +/// { +/// ... +/// } +/// +/// ... +/// +/// //---------------------------------------------------------------------- +/// +/// class CMyAddon : public kodi::addon::CAddonBase +/// { +/// public: +/// CMyAddon() = default; +/// ADDON_STATUS CreateInstance(int instanceType, +/// std::string instanceID, +/// KODI_HANDLE instance, +/// const std::string& version, +/// KODI_HANDLE& addonInstance) override; +/// }; +/// +/// // If you use only one instance in your add-on, can be instanceType and +/// // instanceID ignored +/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, +/// std::string instanceID, +/// KODI_HANDLE instance, +/// const std::string& version, +/// KODI_HANDLE& addonInstance) +/// { +/// if (instanceType == ADDON_INSTANCE_INPUTSTREAM) +/// { +/// kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream"); +/// addonInstance = new CMyInputstream(instance, version); +/// return ADDON_STATUS_OK; +/// } +/// else if (...) +/// { +/// ... +/// } +/// return ADDON_STATUS_UNKNOWN; +/// } +/// +/// ADDONCREATOR(CMyAddon) +/// ~~~~~~~~~~~~~ +/// +/// The destruction of the example class `CMyInputstream` is called from +/// Kodi's header. Manually deleting the add-on instance is not required. +/// +//------------------------------------------------------------------------------ +class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_addon_inputstream + /// @brief Inputstream class constructor used to support multiple instance + /// types + /// + /// @param[in] instance The instance value given to <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b> + /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to + /// allow compatibility to older Kodi versions. + /// + /// @warning Only use `instance` from the @ref CAddonBase::CreateInstance call. + /// + explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "") + : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM, + !kodiVersion.empty() ? kodiVersion + : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM)) + { + if (CAddonBase::m_interface->globalSingleInstance != nullptr) + throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together " + "with single instance way is not allowed!"); - /*! - * Read from an open stream. - * @param buffer The buffer to store the data in. - * @param bufferSize The amount of bytes to read. - * @return The amount of bytes that were actually read from the stream. - * @remarks Return -1 if this add-on won't provide this function. - */ - virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; } + SetAddonStruct(instance, m_kodiVersion); + } + //---------------------------------------------------------------------------- - /*! - * Seek in a stream. - * @param position The position to seek to. - * @param whence ? - * @return The new position. - * @remarks Return -1 if this add-on won't provide this function. - */ + //============================================================================ + /// @ingroup cpp_kodi_addon_inputstream + /// @brief Destructor + /// + ~CInstanceInputStream() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_inputstream + /// @brief Get the list of features that this add-on provides. + /// + /// Called by Kodi to query the add-on's capabilities. + /// Used to check which options should be presented in the UI, which methods to call, etc. + /// All capabilities that the add-on supports should be set to true. + /// + /// @param[out] capabilities The with @ref cpp_kodi_addon_inputstream_Defs_Capabilities defined add-on's capabilities. + /// + /// + /// -------------------------------------------------------------------------- + /// + /// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help + /// + /// -------------------------------------------------------------------------- + /// @note Valid implementation required. + /// + /// + /// -------------------------------------------------------------------------- + /// + /// **Example:** + /// + /// ~~~~~~~~~~~~~{.cpp} + /// void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) + /// { + /// capabilities.SetMask(INPUTSTREAM_SUPPORTS_IDEMUX | INPUTSTREAM_SUPPORTS_PAUSE); + /// } + /// ~~~~~~~~~~~~~ + /// + virtual void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) = 0; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_inputstream + /// @brief Open a stream. + /// + /// @param[in] props The used properties about the stream + /// @return True if the stream has been opened successfully, false otherwise. + /// + /// + /// -------------------------------------------------------------------------- + /// + /// @copydetails cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help + /// + /// -------------------------------------------------------------------------- + /// @note Valid implementation required. + /// + /// + /// -------------------------------------------------------------------------- + /// + /// **Example:** + /// + /// ~~~~~~~~~~~~~{.cpp} + /// void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props) + /// { + /// std::string url = props.GetURL(); + /// std::string license_key = props.GetProperties()["inputstream.myspecialnamefor.license_key"]; + /// ... + /// } + /// ~~~~~~~~~~~~~ + /// + virtual bool Open(const kodi::addon::InputstreamProperty& props) = 0; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_inputstream + /// @brief Close an open stream. + /// + /// @remarks + /// + /// + /// -------------------------------------------------------------------------- + /// @note Valid implementation required. + /// + virtual void Close() = 0; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_inputstream + /// @brief Check for real-time streaming + /// + /// @return true if current stream is real-time + /// + virtual bool IsRealTimeStream() { return true; } + //---------------------------------------------------------------------------- + + //############################################################################ + /// @defgroup cpp_kodi_addon_inputstream_Read 1. Stream read + /// @brief **Functions required to read streams direct and demux inside Kodi.** + /// + /// This part contains at least the functions necessary for addon that have to + /// be supported. This can only be ignored if you use your own demux. + /// + /// The data loaded by Kodi is then processed in it itself. The source does not + /// matter, only Kodi must be able to process this stream data itself and is + /// therefore limited in some things. + /// + /// For more complex things, the addon must integrate its own demuxer and, + /// if necessary, even its own codec processing (see @ref cpp_kodi_addon_codec "Codec"). + /// + /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDEMUX + /// is <em><b>undefined</b></em> in the capabilities (see @ref GetCapabilities()). + /// Otherwise becomes @ref cpp_kodi_addon_inputstream_Demux "demuxing" used. + /// + /// @ingroup cpp_kodi_addon_inputstream + ///@{ + + //============================================================================ + /// @brief Read from an open stream. + /// + /// @param[in] buffer The buffer to store the data in. + /// @param[in] bufferSize The amount of bytes to read. + /// @return The amount of bytes that were actually read from the stream. + /// + virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Seek in a stream. + /// + /// @param[in] position The position to seek to + /// @param[in] whence offset relative to<br> + /// You can set the value of whence to one of three things: + /// | Value | int | Description | + /// |:------------:|:-----:|:----------------------------------------------------| + /// | **SEEK_SET** | `0` | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. + /// | **SEEK_CUR** | `1` | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." + /// | **SEEK_END** | `2` | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. + /// + /// @return Returns the resulting offset location as measured in bytes from + /// the beginning of the file. On error, the value -1 is returned. + /// + /// @remarks Optional and can leaved away or return -1 if this add-on won't + /// provide this function. + /// virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; } - - /*! - * @return The position in the stream that's currently being read. - * @remarks Return -1 if this add-on won't provide this function. - */ + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief The position in the stream that's currently being read. + /// + /// @return Stream position + /// + /// @remarks Optional and can leaved away or return -1 if this add-on won't + /// provide this function. + /// virtual int64_t PositionStream() { return -1; } - - /*! - * @return The total length of the stream that's currently being read. - * @remarks Return -1 if this add-on won't provide this function. - */ + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief The Total length of the stream that's currently being read. + /// + /// @return Length of the stream + /// + /// @remarks Optional and can leaved away or return -1 if this add-on won't + /// provide this function. + /// virtual int64_t LengthStream() { return -1; } - - /*! - * @return Obtain the chunk size to use when reading streams. - * @remarks Return 0 if this add-on won't provide this function. - */ + //-------------------------------------------------------------------------- + + //========================================================================== + /// @brief Obtain the chunk size to use when reading streams. + /// + /// @return Block chunk size + /// + /// @remarks Optional and can leaved away or return 0 if this add-on won't + /// provide this function. + /// virtual int GetBlockSize() { return 0; } + //-------------------------------------------------------------------------- + + ///@} + + //############################################################################ + /// @defgroup cpp_kodi_addon_inputstream_Demux 2. Stream demuxing (optional) + /// @brief **Read demux streams.** + /// + /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDEMUX is set in the capabilities (see @ref GetCapabilities()). + /// + /// @ingroup cpp_kodi_addon_inputstream + ///@{ + + //============================================================================ + /// @brief Get IDs of available streams + /// + /// @param[in] ids list of used identifications + /// @return true if successfully done, otherwise false + /// + /// @remarks This id's are used to identify wanted data on @ref GetStream call. + /// + /// + /// -------------------------------------------------------------------------- + /// + /// **Example:** + /// + /// ~~~~~~~~~~~~~{.cpp} + /// + /// bool CMyInputstream::GetStreamIds(std::vector<unsigned int>& ids) + /// { + /// kodi::Log(ADDON_LOG_DEBUG, "GetStreamIds(...)"); + /// + /// if (m_opened) + /// { + /// // This check not needed to have, the ABI checks also about, but make + /// // sure you not give more as 32 streams. + /// if (m_myStreams.size() > MAX_STREAM_COUNT) + /// { + /// kodi::Log(ADDON_LOG_ERROR, "Too many streams, only %u supported", MAX_STREAM_COUNT); + /// return false; + /// } + /// + /// ids.emplace_back(m_myAudioStreamId); + /// + /// for (const auto& streamPair : m_myOtherStreams) + /// { + /// ids.emplace_back(streamPair.second->uniqueId); + /// } + /// } + /// + /// return !ids.empty(); + /// } + /// ~~~~~~~~~~~~~ + /// + virtual bool GetStreamIds(std::vector<unsigned int>& ids) { return false; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Function for giving detailed stream information + /// + /// The associated information is set here for IDs previously given with + /// @ref GetStreamIds. + /// + /// This data is required to identify the associated codec and, if necessary, + /// to refer to your own codec (if available in the addon). + /// + /// @param[in] streamid unique id of stream + /// @param[out] stream Information data of wanted stream + /// @return true if successfully done, otherwise false + /// + /// @remarks Available stream id's previously asked by @ref GetStreamIds + /// + /// + /// -------------------------------------------------------------------------- + /// + /// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help + /// + /// -------------------------------------------------------------------------- + /// + /// **Example:** + /// + /// ~~~~~~~~~~~~~{.cpp} + /// bool CMyInputstream::GetStream(int streamid, kodi::addon::InputstreamInfo& stream) + /// { + /// // This is just a small example, this type will be significantly larger + /// // for larger and more complex streams. + /// if (streamid == m_myAudioStreamId) + /// { + /// // This only a minimal exampl + /// stream.SetStreamType(INPUTSTREAM_TYPE_AUDIO); + /// stream.SetFeatures(INPUTSTREAM_FEATURE_NONE); // Only added to example, INPUTSTREAM_FEATURE_NONE is default and no need to call + /// stream.SetFlags(INPUTSTREAM_FLAG_NONE); // Only added to example, INPUTSTREAM_FLAG_NONE is default and no need to call + /// stream.SetCodecName("mp2"); // Codec name, string must by equal with FFmpeg, see https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_desc.c + /// stream.SetPhysicalIndex(1); // Identifier required to set + /// stream.SetLanguage("en"); + /// stream.SetChannels(2); + /// stream.SetSampleRate(48000); + /// stream.SetBitRate(0); + /// stream.SetBitsPerSample(16); + /// } + /// else ... + /// ... + /// return true; + /// } + /// ~~~~~~~~~~~~~ + /// + virtual bool GetStream(int streamid, kodi::addon::InputstreamInfo& stream) { return false; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Enable or disable a stream. + /// + /// A disabled stream does not send demux packets + /// + /// @param[in] streamid unique id of stream + /// @param[in] enable true for enable, false for disable + /// + /// @remarks Available stream id's previously asked by @ref GetStreamIds + /// + /// + /// -------------------------------------------------------------------------- + /// @note Valid implementation required. + /// + virtual void EnableStream(int streamid, bool enable) {} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Opens a stream for playback. + /// + /// @param[in] streamid unique id of stream + /// + /// @remarks Available stream id's previously asked by @ref GetStreamIds + /// + /// + /// -------------------------------------------------------------------------- + /// @note Valid implementation required. + /// + virtual bool OpenStream(int streamid) { return false; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Reset the demultiplexer in the add-on. + /// + /// @remarks Optional, and only used if addon has its own demuxer. + /// + virtual void DemuxReset() {} + //---------------------------------------------------------------------------- - /*! - * Check for real-time streaming - * @return true if current stream is real-time - */ - virtual bool IsRealTimeStream() { return true; } + //============================================================================ + /// @brief Abort the demultiplexer thread in the add-on. + /// + /// @remarks Optional, and only used if addon has its own demuxer. + /// + virtual void DemuxAbort() {} + //---------------------------------------------------------------------------- - /*! - * @brief Allocate a demux packet. Free with FreeDemuxPacket - * @param dataSize The size of the data that will go into the packet - * @return The allocated packet - */ - DemuxPacket* AllocateDemuxPacket(int dataSize) + //============================================================================ + /// @brief Flush all data that's currently in the demultiplexer buffer in the add-on. + /// + /// @remarks Optional, and only used if addon has its own demuxer. + /// + virtual void DemuxFlush() {} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Read the next packet from the demultiplexer, if there is one. + /// + /// @return The next packet. + /// If there is no next packet, then the add-on should return the + /// packet created by calling @ref AllocateDemuxPacket "AllocateDemuxPacket(0)" on the callback. + /// If the stream changed and Kodi's player needs to be reinitialised, + /// then, the add-on should call @ref AllocateDemuxPacket "AllocateDemuxPacket(0)" on the + /// callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and + /// return the value. + /// The add-on should return <b>`nullptr`</b> if an error occured. + /// + /// @remarks Return <b>`nullptr`</b> if this add-on won't provide this function. + /// + virtual DEMUX_PACKET* DemuxRead() { return nullptr; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time + /// + /// Demuxer is required to set stream to an IDR frame + /// + /// @param[in] time The absolute time since stream start + /// @param[in] backwards True to seek to keyframe BEFORE time, else AFTER + /// @param[in] startpts can be updated to point to where display should start + /// @return True if the seek operation was possible + /// + /// @remarks Optional, and only used if addon has its own demuxer. + /// + virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Notify the InputStream addon/demuxer that Kodi wishes to change playback speed + /// + /// @param[in] speed The requested playback speed + /// + /// @remarks Optional, and only used if addon has its own demuxer. + /// + virtual void DemuxSetSpeed(int speed) {} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Sets desired width / height + /// + /// @param[in] width Width to set + /// @param[in] height Height to set + /// + virtual void SetVideoResolution(int width, int height) {} + //---------------------------------------------------------------------------- + + //============================================================================= + /// @brief Allocate a demux packet. Free with @ref FreeDemuxPacket + /// + /// @param[in] dataSize The size of the data that will go into the packet + /// @return The allocated packet + /// + /// @remarks Only called from addon itself + /// + DEMUX_PACKET* AllocateDemuxPacket(int dataSize) { return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance, dataSize); } - - /*! - * @brief Allocate a demux packet. Free with FreeDemuxPacket - * @param dataSize The size of the data that will go into the packet - * @return The allocated packet - */ - DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Allocate a encrypted demux packet. Free with @ref FreeDemuxPacket + /// + /// @param[in] dataSize The size of the data that will go into the packet + /// @param[in] encryptedSubsampleCount The encrypted subsample count + /// @return The allocated packet + /// + /// @remarks Only called from addon itself + /// + DEMUX_PACKET* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) { return m_instanceData->toKodi->allocate_encrypted_demux_packet( m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount); } - - /*! - * @brief Free a packet that was allocated with AllocateDemuxPacket - * @param packet The packet to free - */ - void FreeDemuxPacket(DemuxPacket* packet) + //---------------------------------------------------------------------------- + + //============================================================================ + /// @brief Free a packet that was allocated with AllocateDemuxPacket + /// + /// @param[in] packet The packet to free + /// + /// @remarks Only called from addon itself + /// + void FreeDemuxPacket(DEMUX_PACKET* packet) { return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet); } + //---------------------------------------------------------------------------- + + ///@} + + //############################################################################ + /// @defgroup cpp_kodi_addon_inputstream_Time 3. Time (optional) + /// @brief **To get stream position time.** + /// + /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDISPLAYTIME is set in the capabilities (see @ref GetCapabilities()). + /// + /// @ingroup cpp_kodi_addon_inputstream + ///@{ + + //========================================================================== + /// @brief Totel time in ms + /// + /// @return Total time in milliseconds + /// + /// @remarks + /// + virtual int GetTotalTime() { return -1; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @brief Playing time in ms + /// + /// @return Playing time in milliseconds + /// + /// @remarks + /// + virtual int GetTime() { return -1; } + //-------------------------------------------------------------------------- + + ///@} + + //############################################################################ + /// @defgroup cpp_kodi_addon_inputstream_Times 4. Times (optional) + /// @brief **Another way to get stream position time.** + /// + /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_ITIME is set in the capabilities (see @ref GetCapabilities()). + /// + /// @ingroup cpp_kodi_addon_inputstream + ///@{ + + //============================================================================ + /// @brief Get current timing values in PTS scale + /// + /// @param[out] times The with @ref InputstreamTimes to given times + /// @return true if successfully done, false if not + /// + /// @copydetails cpp_kodi_addon_inputstream_Defs_Times_Help + /// + /// @remarks + /// + virtual bool GetTimes(InputstreamTimes& times) { return false; } + //---------------------------------------------------------------------------- + + ///@} + + //############################################################################ + /// @defgroup cpp_kodi_addon_inputstream_PosTime 5. Position time (optional) + /// @brief **Third way get stream position time.** + /// + /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IPOSTIME is set in the capabilities (see @ref GetCapabilities()). + /// + /// @ingroup cpp_kodi_addon_inputstream + ///@{ + + //============================================================================ + /// @brief Positions inputstream to playing time given in ms + /// + /// @param[in] ms Position time in milliseconds + /// + /// @remarks + /// + virtual bool PosTime(int ms) { return false; } + //---------------------------------------------------------------------------- + + ///@} + + //############################################################################ + /// @defgroup cpp_kodi_addon_inputstream_Chapter 6. Chapter (optional) + /// @brief **Used to get available chapters.** + /// + /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_ICHAPTER is set in the capabilities (see @ref GetCapabilities()). + /// + /// @ingroup cpp_kodi_addon_inputstream + ///@{ + + //========================================================================== + /// + /// @brief Return currently selected chapter + /// + /// @return Chapter number + /// + /// @remarks + /// + virtual int GetChapter() { return -1; }; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @brief Return number of available chapters + /// + /// @return Chapter count + /// + /// @remarks + /// + virtual int GetChapterCount() { return 0; }; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @brief Return name of chapter + /// + /// @param[in] ch Chapter identifier + /// @return Chapter name + /// + /// @remarks + /// + virtual const char* GetChapterName(int ch) { return nullptr; }; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @brief Return position if chapter # ch in milliseconds + /// + /// @param[in] ch Chapter to get position from + /// @return Position in milliseconds + /// + /// @remarks + /// + virtual int64_t GetChapterPos(int ch) { return 0; }; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @brief Seek to the beginning of chapter # ch + /// + /// @param[in] ch Chapter to seek + /// @return True if successfully done, false if not + /// + /// @remarks + /// + virtual bool SeekChapter(int ch) { return false; }; + //-------------------------------------------------------------------------- + + ///@} private: static int compareVersion(const int v1[3], const int v2[3]) @@ -752,9 +1816,10 @@ private: */ } - inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) + inline static bool ADDON_Open(const AddonInstance_InputStream* instance, + INPUTSTREAM_PROPERTY* props) { - return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Open(*props); + return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Open(props); } inline static void ADDON_Close(const AddonInstance_InputStream* instance) @@ -765,22 +1830,48 @@ private: inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, INPUTSTREAM_CAPABILITIES* capabilities) { - static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) - ->GetCapabilities(*capabilities); + InputstreamCapabilities caps(capabilities); + static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetCapabilities(caps); } // IDemux - inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) + inline static bool ADDON_GetStreamIds(const AddonInstance_InputStream* instance, + struct INPUTSTREAM_IDS* ids) { - return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetStreamIds(); + std::vector<unsigned int> idList; + bool ret = + static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetStreamIds(idList); + if (ret) + { + for (size_t i = 0; i < idList.size() && i < INPUTSTREAM_MAX_STREAM_COUNT; ++i) + { + ids->m_streamCount++; + ids->m_streamIds[i] = idList[i]; + } + } + return ret; } - inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, - int streamid) + inline static bool ADDON_GetStream( + const AddonInstance_InputStream* instance, + int streamid, + struct INPUTSTREAM_INFO* info, + KODI_HANDLE* demuxStream, + KODI_HANDLE (*transfer_stream)(KODI_HANDLE handle, + int streamId, + struct INPUTSTREAM_INFO* stream)) { - return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) - ->GetStream(streamid); + InputstreamInfo infoData(info); + bool ret = static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) + ->GetStream(streamid, infoData); + if (ret && transfer_stream) + { + // Do this with given callback to prevent memory problems and leaks. This + // then create on Kodi the needed class where then given back on demuxStream. + *demuxStream = transfer_stream(instance->toKodi->kodiInstance, streamid, info); + } + return ret; } inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, @@ -812,7 +1903,7 @@ private: static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxFlush(); } - inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) + inline static DEMUX_PACKET* ADDON_DemuxRead(const AddonInstance_InputStream* instance) { return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxRead(); } @@ -855,7 +1946,8 @@ private: inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES* times) { - return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTimes(*times); + InputstreamTimes cppTimes(times); + return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTimes(cppTimes); } // IPosTime @@ -927,6 +2019,7 @@ private: AddonInstance_InputStream* m_instanceData; }; +//------------------------------------------------------------------------------ } /* namespace addon */ } /* namespace kodi */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h index d5977a780c..9b5088dd70 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h @@ -36,7 +36,7 @@ * Only must be min version increased if a new compile of addon breaks after * changes here. * - * Have by add of new parts a look about **Doxygen** `\\ingroup`, so that + * Have by add of new parts a look about **Doxygen** `\@ingroup`, so that * added parts included in documentation. * * If you add addon side related documentation, where his dev need know, use `///`. @@ -2324,7 +2324,7 @@ public: /// @remarks Required, and only used if addon has its own demuxer. /// Return `nullptr` if this add-on won't provide this function. /// - virtual DemuxPacket* DemuxRead() { return nullptr; } + virtual DEMUX_PACKET* DemuxRead() { return nullptr; } //---------------------------------------------------------------------------- //============================================================================ @@ -2413,7 +2413,7 @@ public: /// /// @remarks Only called from addon itself /// - inline DemuxPacket* AllocateDemuxPacket(int iDataSize) + inline DEMUX_PACKET* AllocateDemuxPacket(int iDataSize) { return m_instanceData->toKodi->AllocateDemuxPacket(m_instanceData->toKodi->kodiInstance, iDataSize); @@ -2428,7 +2428,7 @@ public: /// /// @remarks Only called from addon itself. /// - inline void FreeDemuxPacket(DemuxPacket* pPacket) + inline void FreeDemuxPacket(DEMUX_PACKET* pPacket) { m_instanceData->toKodi->FreeDemuxPacket(m_instanceData->toKodi->kodiInstance, pPacket); } @@ -3364,7 +3364,7 @@ private: static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxFlush(); } - inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_PVR* instance) + inline static DEMUX_PACKET* ADDON_DemuxRead(const AddonInstance_PVR* instance) { return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxRead(); } diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h index 4902fcb655..d4ac1aa3e6 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h @@ -41,7 +41,7 @@ namespace addon /// * <b><c>Render()</c></b> - Called at render time /// * <b><c>Stop()</c></b> - Called when the screensaver has no work /// -/// Additionally, there are several \ref cpp_kodi_addon_screensaver_CB "other functions" +/// Additionally, there are several @ref cpp_kodi_addon_screensaver_CB "other functions" /// available in which the child class can ask about the current hardware, /// including the device, display and several other parts. /// diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h index 177bf7269e..dbfb833ef1 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h @@ -152,7 +152,7 @@ private: //############################################################################## /// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators -/// \ingroup cpp_kodi_addon_vfs +/// @ingroup cpp_kodi_addon_vfs /// @brief **VFS add-on general variables** /// /// Used to exchange the available options between Kodi and addon. @@ -161,7 +161,7 @@ private: //============================================================================== /// -/// \addtogroup cpp_kodi_addon_vfs +/// @addtogroup cpp_kodi_addon_vfs /// @brief \cpp_class{ kodi::addon::CInstanceVFS } /// **Virtual Filesystem (VFS) add-on instance** /// diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h index 12893dbd07..7cf58a0ca3 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h @@ -9,241 +9,456 @@ #pragma once #include "../AddonBase.h" -#include "../StreamCrypto.h" -#include "../StreamCodec.h" +#include "../c-api/addon-instance/video_codec.h" +#include "inputstream/DemuxPacket.h" +#include "inputstream/StreamCodec.h" +#include "inputstream/StreamCrypto.h" -#ifdef BUILD_KODI_ADDON -#include "../DemuxPacket.h" -#else -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#endif +#ifdef __cplusplus -extern "C" +namespace kodi +{ +namespace addon { - enum VIDEOCODEC_FORMAT - { - UnknownVideoFormat = 0, - VideoFormatYV12, - VideoFormatI420, - MaxVideoFormats - }; - - struct VIDEOCODEC_INITDATA +class CInstanceVideoCodec; + +//============================================================================== +/// @defgroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata class VideoCodecInitdata +/// @ingroup cpp_kodi_addon_videocodec_Defs +/// @brief Initialization data to open a video codec stream. +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata_Help +/// +///@{ +class ATTRIBUTE_HIDDEN VideoCodecInitdata + : public CStructHdl<VideoCodecInitdata, VIDEOCODEC_INITDATA> +{ + /*! \cond PRIVATE */ + friend class CInstanceVideoCodec; + /*! \endcond */ + +public: + /// @defgroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata_Help Value Help + /// @ingroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata :</b> + /// | Name | Type | Get call + /// |------|------|---------- + /// | **Codec type** | `VIDEOCODEC_TYPE` | @ref VideoCodecInitdata::GetCodecType "GetCodecType" + /// | **Codec profile** | `STREAMCODEC_PROFILE` | @ref VideoCodecInitdata::GetCodecProfile "GetCodecProfile" + /// | **Video formats** | `std::vector<VIDEOCODEC_FORMAT>` | @ref VideoCodecInitdata::GetVideoFormats "GetVideoFormats" + /// | **Width** | `uint32_t` | @ref VideoCodecInitdata::GetWidth "GetWidth" + /// | **Height** | `uint32_t` | @ref VideoCodecInitdata::GetHeight "GetHeight" + /// | **Extra data** | `const uint8_t*` | @ref VideoCodecInitdata::GetExtraData "GetExtraData" + /// | **Extra data size** | `unsigned int` | @ref VideoCodecInitdata::GetExtraDataSize "GetExtraDataSize" + /// | **Crypto session** | `kodi::addon::StreamCryptoSession` | @ref VideoCodecInitdata::GetCryptoSession "GetCryptoSession" + /// + + /// @addtogroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata + ///@{ + + /// @brief The codec type required by Kodi to process the stream. + /// + /// See @ref VIDEOCODEC_TYPE for possible values. + VIDEOCODEC_TYPE GetCodecType() const { return m_cStructure->codec; } + + /// @brief Used profiles for non-scalable 2D video + STREAMCODEC_PROFILE GetCodecProfile() const { return m_cStructure->codecProfile; } + + /// @brief The video stream representations requested by Kodi + /// + /// This contains a list of the required video formats. One of them has to + /// select the addon to return the created image. + /// + std::vector<VIDEOCODEC_FORMAT> GetVideoFormats() const { - enum Codec { - CodecUnknown = 0, - CodecVp8, - CodecH264, - CodecVp9 - } codec; - - STREAMCODEC_PROFILE codecProfile; - - //UnknownVideoFormat is terminator - VIDEOCODEC_FORMAT *videoFormats; - - uint32_t width, height; - - const uint8_t *extraData; - unsigned int extraDataSize; - - CRYPTO_INFO cryptoInfo; - }; - - struct VIDEOCODEC_PICTURE + std::vector<VIDEOCODEC_FORMAT> formats; + unsigned int i = 0; + while (i < VIDEOCODEC_FORMAT_MAXFORMATS && + m_cStructure->videoFormats[i] != VIDEOCODEC_FORMAT_UNKNOWN) + formats.emplace_back(m_cStructure->videoFormats[i++]); + if (formats.empty()) + formats.emplace_back(VIDEOCODEC_FORMAT_UNKNOWN); + return formats; + } + + /// @brief Picture width. + uint32_t GetWidth() const { return m_cStructure->width; } + + /// @brief Picture height. + uint32_t GetHeight() const { return m_cStructure->height; } + + /// @brief Depending on the required decoding, additional data given by the stream. + const uint8_t* GetExtraData() const { return m_cStructure->extraData; } + + /// @brief Size of the data given with @ref extraData. + unsigned int GetExtraDataSize() const { return m_cStructure->extraDataSize; } + + /// @brief **Data to manage stream cryptography**\n + /// To get class structure manages any encryption values required in order to have + /// them available in their stream processing. + /// + /// ---------------------------------------------------------------------------- + /// + /// @copydetails cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession_Help + /// + kodi::addon::StreamCryptoSession GetCryptoSession() const { return &m_cStructure->cryptoSession; } + + ///@} + +private: + VideoCodecInitdata() = delete; + VideoCodecInitdata(const VideoCodecInitdata& session) : CStructHdl(session) {} + VideoCodecInitdata(const VIDEOCODEC_INITDATA* session) : CStructHdl(session) {} + VideoCodecInitdata(VIDEOCODEC_INITDATA* session) : CStructHdl(session) {} +}; +///@} +//------------------------------------------------------------------------------ + +//############################################################################## +/// @defgroup cpp_kodi_addon_videocodec_Defs Definitions, structures and enumerators +/// @ingroup cpp_kodi_addon_videocodec +/// @brief **Video codec add-on general variables** +/// +/// Used to exchange the available options between Kodi and addon. +/// +/// + +//============================================================================ +/// +/// @addtogroup cpp_kodi_addon_videocodec +/// @brief \cpp_class{ kodi::addon::CInstanceVideoCodec } +/// **Video codec add-on instance** +/// +/// This is an addon instance class to add an additional video decoder to Kodi +/// using addon. +/// +/// This means that either a new type of decoding can be introduced to an input +/// stream add-on that requires special types of decoding. +/// +/// When using the inputstream addon, @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo +/// to @ref cpp_kodi_addon_inputstream_Defs_Info is used to declare that the +/// decoder stored in the addon is used. +/// +/// @note At the moment this can only be used together with input stream addons, +/// independent use as a codec addon is not yet possible. +/// +/// Include the header @ref VideoCodec.h "#include <kodi/addon-instance/VideoCodec.h>" +/// to use this class. +/// +/// -------------------------------------------------------------------------- +/// +/// **Example:** +/// This as an example when used together with @ref cpp_kodi_addon_inputstream "kodi::addon::CInstanceInputStream". +/// +/// ~~~~~~~~~~~~~{.cpp} +/// #include <kodi/addon-instance/Inputstream.h> +/// #include <kodi/addon-instance/VideoCodec.h> +/// +/// class CMyVideoCodec : public kodi::addon::CInstanceVideoCodec +/// { +/// public: +/// CMyVideoCodec(KODI_HANDLE instance, CMyInputstream* inputstream); +/// ... +/// +/// private: +/// CMyInputstream* m_inputstream; +/// }; +/// +/// CMyVideoCodec::CMyVideoCodec(KODI_HANDLE instance, +/// const std::string& version, +/// CMyInputstream* inputstream) +/// : kodi::addon::CInstanceVideoCodec(instance, version), +/// m_inputstream(inputstream) +/// { +/// ... +/// } +/// ... +/// +/// //---------------------------------------------------------------------- +/// +/// class CMyInputstream : public kodi::addon::CInstanceInputStream +/// { +/// public: +/// CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion); +/// +/// ADDON_STATUS CreateInstance(int instanceType, +/// std::string instanceID, +/// KODI_HANDLE instance, +/// const std::string& version, +/// KODI_HANDLE& addonInstance) override; +/// ... +/// }; +/// +/// CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion) +/// : kodi::addon::CInstanceInputStream(instance, kodiVersion) +/// { +/// ... +/// } +/// +/// ADDON_STATUS CMyInputstream::CreateInstance(int instanceType, +/// std::string instanceID, +/// KODI_HANDLE instance, +/// const std::string& version, +/// KODI_HANDLE& addonInstance) +/// { +/// if (instanceType == ADDON_INSTANCE_VIDEOCODEC) +/// { +/// addonInstance = new CMyVideoCodec(instance, version, this); +/// return ADDON_STATUS_OK; +/// } +/// return ADDON_STATUS_NOT_IMPLEMENTED; +/// } +/// +/// ... +/// +/// //---------------------------------------------------------------------- +/// +/// class CMyAddon : public kodi::addon::CAddonBase +/// { +/// public: +/// CMyAddon() { } +/// ADDON_STATUS CreateInstance(int instanceType, +/// std::string instanceID, +/// KODI_HANDLE instance, +/// const std::string& version, +/// KODI_HANDLE& addonInstance) override; +/// }; +/// +/// // If you use only one instance in your add-on, can be instanceType and +/// // instanceID ignored +/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, +/// std::string instanceID, +/// KODI_HANDLE instance, +/// const std::string& version, +/// KODI_HANDLE& addonInstance) +/// { +/// if (instanceType == ADDON_INSTANCE_INPUTSTREAM) +/// { +/// kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream"); +/// addonInstance = new CMyInputstream(instance, version); +/// return ADDON_STATUS_OK; +/// } +/// else if (...) +/// { +/// ... +/// } +/// return ADDON_STATUS_UNKNOWN; +/// } +/// +/// ADDONCREATOR(CMyAddon) +/// ~~~~~~~~~~~~~ +/// +/// The destruction of the example class `CMyInputstream` is called from +/// Kodi's header. Manually deleting the add-on instance is not required. +/// +/// +class ATTRIBUTE_HIDDEN CInstanceVideoCodec : public IAddonInstance +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief Video codec class constructor used to support multiple instance + /// types + /// + /// @param[in] instance The instance value given to <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>, + /// or by a inputstream instance if them declared as parent. + /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to + /// allow compatibility to older Kodi versions. + /// + explicit CInstanceVideoCodec(KODI_HANDLE instance, const std::string& kodiVersion = "") + : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC, + !kodiVersion.empty() ? kodiVersion + : GetKodiTypeVersion(ADDON_INSTANCE_VIDEOCODEC)) { - enum VideoPlane { - YPlane = 0, - UPlane, - VPlane, - MaxPlanes = 3, - }; - - enum Flags : uint32_t { - FLAG_DROP, - FLAG_DRAIN - }; - - VIDEOCODEC_FORMAT videoFormat; - uint32_t flags; - - uint32_t width, height; - - uint8_t *decodedData; - size_t decodedDataSize; - - uint32_t planeOffsets[VideoPlane::MaxPlanes]; - uint32_t stride[VideoPlane::MaxPlanes]; - - int64_t pts; - - KODI_HANDLE videoBufferHandle; //< will be passed in release_frame_buffer - }; - - enum VIDEOCODEC_RETVAL + if (CAddonBase::m_interface->globalSingleInstance != nullptr) + throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with " + "single instance way is not allowed!"); + + SetAddonStruct(instance); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief Destructor + /// + ~CInstanceVideoCodec() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief Open the decoder, returns true on success + /// + /// Decoders not capable of running multiple instances should return false in case + /// there is already a instance open. + /// + /// @param[in] initData Video codec init data + /// @return true if successfully done + /// + /// + /// ---------------------------------------------------------------------------- + /// + /// @copydetails cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata_Help + /// + virtual bool Open(const kodi::addon::VideoCodecInitdata& initData) { return false; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief Reconfigure the decoder, returns true on success + /// + /// Decoders not capable of runnung multiple instances may be capable of reconfiguring + /// the running instance. If Reconfigure returns false, player will close / open + /// the decoder + /// + /// @param[in] initData Video codec reconfigure data + /// @return true if successfully done + /// + virtual bool Reconfigure(const kodi::addon::VideoCodecInitdata& initData) { return false; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief add data, decoder has to consume the entire packet + /// + /// @param[in] packet Data to process for decode + /// @return true if the packet was consumed or if resubmitting it is useless + /// + virtual bool AddData(const DEMUX_PACKET& packet) { return false; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief GetPicture controls decoding. + /// + /// Player calls it on every cycle it can signal a picture, request a buffer, + /// or return none, if nothing applies the data is valid until the next + /// GetPicture return @ref VC_PICTURE + /// + /// @param[in,out] Structure which contains the necessary data + /// @return The with @ref VIDEOCODEC_RETVAL return values + /// + virtual VIDEOCODEC_RETVAL GetPicture(VIDEOCODEC_PICTURE& picture) { return VC_ERROR; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief should return codecs name + /// + /// @return Codec name + /// + virtual const char* GetName() { return nullptr; } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief Reset the decoder + /// + virtual void Reset() {} + //---------------------------------------------------------------------------- + + /*! + * @brief AddonToKodi interface + */ + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec + /// @brief All picture members can be expected to be set correctly except + /// decodedData and pts. + /// + /// GetFrameBuffer has to set decodedData to a valid memory address and return true. + /// + /// @param[out] picture The buffer, or unmodified if false is returned + /// @return In case buffer allocation fails, it return false. + /// + /// @note If this returns true, buffer must be freed using @ref ReleaseFrameBuffer(). + /// + /// @remarks Only called from addon itself + /// + bool GetFrameBuffer(VIDEOCODEC_PICTURE& picture) { - VC_NONE = 0, //< noop - VC_ERROR, //< an error occurred, no other messages will be returned - VC_BUFFER, //< the decoder needs more data - VC_PICTURE, //< the decoder got a picture - VC_EOF, //< the decoder signals EOF - }; - - // this are properties given to the addon on create - // at this time we have no parameters for the addon - typedef struct AddonProps_VideoCodec + return m_instanceData->toKodi->get_frame_buffer(m_instanceData->toKodi->kodiInstance, &picture); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// + /// @ingroup cpp_kodi_addon_videocodec + /// @brief Release the with @ref GetFrameBuffer() given framebuffer. + /// + /// @param[in] handle the on @ref VIDEOCODEC_PICTURE.videoBufferHandle defined buffer handle + /// + /// @remarks Only called from addon itself + /// + void ReleaseFrameBuffer(void* buffer) { - int dummy; - } AddonProps_VideoCodec; + return m_instanceData->toKodi->release_frame_buffer(m_instanceData->toKodi->kodiInstance, + buffer); + } + //---------------------------------------------------------------------------- - struct AddonInstance_VideoCodec; - typedef struct KodiToAddonFuncTable_VideoCodec +private: + void SetAddonStruct(KODI_HANDLE instance) { - KODI_HANDLE addonInstance; - - //! \brief Opens a codec - bool (__cdecl* open) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData); - - //! \brief Reconfigures a codec - bool (__cdecl* reconfigure) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData); - - //! \brief Feed codec if requested from GetPicture() (return VC_BUFFER) - bool (__cdecl* add_data) (const AddonInstance_VideoCodec* instance, const DemuxPacket *packet); - - //! \brief Get a decoded picture / request new data - VIDEOCODEC_RETVAL (__cdecl* get_picture) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture); + if (instance == nullptr) + throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation with empty addon " + "structure not allowed, table must be given from Kodi!"); + + m_instanceData = static_cast<AddonInstance_VideoCodec*>(instance); + + m_instanceData->toAddon->addonInstance = this; + m_instanceData->toAddon->open = ADDON_Open; + m_instanceData->toAddon->reconfigure = ADDON_Reconfigure; + m_instanceData->toAddon->add_data = ADDON_AddData; + m_instanceData->toAddon->get_picture = ADDON_GetPicture; + m_instanceData->toAddon->get_name = ADDON_GetName; + m_instanceData->toAddon->reset = ADDON_Reset; + } + + inline static bool ADDON_Open(const AddonInstance_VideoCodec* instance, + VIDEOCODEC_INITDATA* initData) + { + return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Open(initData); + } - //! \brief Get the name of this video decoder - const char *(__cdecl* get_name) (const AddonInstance_VideoCodec* instance); + inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance, + VIDEOCODEC_INITDATA* initData) + { + return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) + ->Reconfigure(initData); + } - //! \brief Reset the codec - void (__cdecl* reset)(const AddonInstance_VideoCodec* instance); - } KodiToAddonFuncTable_VideoCodec; + inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance, + const DEMUX_PACKET* packet) + { + return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->AddData(*packet); + } - typedef struct AddonToKodiFuncTable_VideoCodec + inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance, + VIDEOCODEC_PICTURE* picture) { - KODI_HANDLE kodiInstance; - bool(*get_frame_buffer)(void* kodiInstance, VIDEOCODEC_PICTURE *picture); - void(*release_frame_buffer)(void* kodiInstance, void *buffer); - } AddonToKodiFuncTable_VideoCodec; + return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) + ->GetPicture(*picture); + } - typedef struct AddonInstance_VideoCodec + inline static const char* ADDON_GetName(const AddonInstance_VideoCodec* instance) { - AddonProps_VideoCodec* props; - AddonToKodiFuncTable_VideoCodec* toKodi; - KodiToAddonFuncTable_VideoCodec* toAddon; - } AddonInstance_VideoCodec; -} + return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->GetName(); + } -namespace kodi -{ - namespace addon + inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance) { + return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Reset(); + } + + AddonInstance_VideoCodec* m_instanceData; +}; - class ATTRIBUTE_HIDDEN CInstanceVideoCodec : public IAddonInstance - { - public: - explicit CInstanceVideoCodec(KODI_HANDLE instance, const std::string& kodiVersion = "") - : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC, - !kodiVersion.empty() ? kodiVersion - : GetKodiTypeVersion(ADDON_INSTANCE_VIDEOCODEC)) - { - if (CAddonBase::m_interface->globalSingleInstance != nullptr) - throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with single instance way is not allowed!"); - - SetAddonStruct(instance); - } - - ~CInstanceVideoCodec() override = default; - - //! \copydoc CInstanceVideoCodec::Open - virtual bool Open(VIDEOCODEC_INITDATA &initData) { return false; }; - - //! \copydoc CInstanceVideoCodec::Reconfigure - virtual bool Reconfigure(VIDEOCODEC_INITDATA &initData) { return false; }; - - //! \copydoc CInstanceVideoCodec::AddData - virtual bool AddData(const DemuxPacket &packet) { return false; }; - - //! \copydoc CInstanceVideoCodec::GetPicture - virtual VIDEOCODEC_RETVAL GetPicture(VIDEOCODEC_PICTURE &picture) { return VC_ERROR; }; - - //! \copydoc CInstanceVideoCodec::GetName - virtual const char *GetName() { return nullptr; }; - - //! \copydoc CInstanceVideoCodec::Reset - virtual void Reset() {}; - - /*! - * @brief AddonToKodi interface - */ - - //! \copydoc CInstanceVideoCodec::GetFrameBuffer - bool GetFrameBuffer(VIDEOCODEC_PICTURE &picture) - { - return m_instanceData->toKodi->get_frame_buffer(m_instanceData->toKodi->kodiInstance, - &picture); - } - - //! \copydoc CInstanceVideoCodec::ReleaseFrameBuffer - void ReleaseFrameBuffer(void *buffer) - { - return m_instanceData->toKodi->release_frame_buffer(m_instanceData->toKodi->kodiInstance, - buffer); - } - - private: - void SetAddonStruct(KODI_HANDLE instance) - { - if (instance == nullptr) - throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation with empty addon structure not allowed, table must be given from Kodi!"); - - m_instanceData = static_cast<AddonInstance_VideoCodec*>(instance); - - m_instanceData->toAddon->addonInstance = this; - m_instanceData->toAddon->open = ADDON_Open; - m_instanceData->toAddon->reconfigure = ADDON_Reconfigure; - m_instanceData->toAddon->add_data = ADDON_AddData; - m_instanceData->toAddon->get_picture = ADDON_GetPicture; - m_instanceData->toAddon->get_name = ADDON_GetName; - m_instanceData->toAddon->reset = ADDON_Reset; - } - - inline static bool ADDON_Open(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData) - { - return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Open(*initData); - } - - inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData) - { - return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) - ->Reconfigure(*initData); - } - - inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance, const DemuxPacket *packet) - { - return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) - ->AddData(*packet); - } - - inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture) - { - return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance) - ->GetPicture(*picture); - } - - inline static const char *ADDON_GetName(const AddonInstance_VideoCodec* instance) - { - return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->GetName(); - } - - inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance) - { - return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Reset(); - } - - AddonInstance_VideoCodec* m_instanceData; - }; - } // namespace addon +} // namespace addon } // namespace kodi + +#endif /* __cplusplus */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h index 7b1db6503e..1dddea2561 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h @@ -721,7 +721,7 @@ public: inline void TransferPresets(const std::vector<std::string>& presets) { m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance); - for (auto it : presets) + for (const auto& it : presets) m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str()); } //---------------------------------------------------------------------------- @@ -915,7 +915,7 @@ private: std::vector<std::string> presets; if (thisClass->GetPresets(presets)) { - for (auto it : presets) + for (const auto& it : presets) thisClass->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str()); } diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/CMakeLists.txt new file mode 100644 index 0000000000..a551b4b523 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/CMakeLists.txt @@ -0,0 +1,8 @@ +set(HEADERS DemuxPacket.h + StreamCodec.h + StreamConstants.h + TimingConstants.h) + +if(NOT ENABLE_STATIC_LIBS) + core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance_inputstream) +endif() diff --git a/xbmc/platform/overrides/freebsd/PlatformPosix.cpp b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/DemuxPacket.h index fa7cf3da05..f965b9f641 100644 --- a/xbmc/platform/overrides/freebsd/PlatformPosix.cpp +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/DemuxPacket.h @@ -1,14 +1,12 @@ /* - * Copyright (C) 2019 Team Kodi + * Copyright (C) 2005-2020 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ -#include "platform/posix/PlatformPosix.h" +#pragma once -CPlatform* CPlatform::CreateInstance() -{ - return new CPlatformPosix(); -} +#include "TimingConstants.h" +#include "../../c-api/addon-instance/inputstream/demux_packet.h" diff --git a/xbmc/platform/overrides/linux/PlatformPosix.cpp b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCodec.h index fa7cf3da05..e80e2ca43b 100644 --- a/xbmc/platform/overrides/linux/PlatformPosix.cpp +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCodec.h @@ -1,14 +1,11 @@ /* - * Copyright (C) 2019 Team Kodi + * Copyright (C) 2005-2020 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ -#include "platform/posix/PlatformPosix.h" +#pragma once -CPlatform* CPlatform::CreateInstance() -{ - return new CPlatformPosix(); -} +#include "../../c-api/addon-instance/inputstream/stream_codec.h" diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamConstants.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamConstants.h new file mode 100644 index 0000000000..200631b6f9 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamConstants.h @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/addon-instance/inputstream/stream_constants.h" diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCrypto.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCrypto.h new file mode 100644 index 0000000000..32af6ae1c7 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCrypto.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/addon-instance/inputstream/stream_crypto.h" +#include "../../AddonBase.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace addon +{ + +class CInstanceInputStream; +class InputstreamInfo; +class VideoCodecInitdata; + +//============================================================================== +/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_StreamCryptoSession class StreamCryptoSession +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption +/// @brief **Data to manage stream cryptography**\n +/// This class structure manages any encryption values required in order to have +/// them available in their stream processing. +/// +/// Used on inputstream by @ref kodi::addon::InputstreamInfo::SetCryptoSession / +/// @ref kodi::addon::InputstreamInfo::GetCryptoSession and are given to the +/// used video codec to decrypt related data. +/// +/// ---------------------------------------------------------------------------- +/// +/// @copydetails cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession_Help +/// +///@{ +class ATTRIBUTE_HIDDEN StreamCryptoSession + : public CStructHdl<StreamCryptoSession, STREAM_CRYPTO_SESSION> +{ + /*! \cond PRIVATE */ + friend class CInstanceInputStream; + friend class InputstreamInfo; + friend class VideoCodecInitdata; + /*! \endcond */ + +public: + /*! \cond PRIVATE */ + StreamCryptoSession() { memset(m_cStructure, 0, sizeof(STREAM_CRYPTO_SESSION)); } + StreamCryptoSession(const StreamCryptoSession& session) + : CStructHdl(session), m_sessionId(session.m_sessionId) + { + } + /*! \endcond */ + + /// @defgroup cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession_Help Value Help + /// @ingroup cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession + /// + /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession :</b> + /// | Name | Type | Set call | Get call + /// |------|------|----------|---------- + /// | **Keysystem for encrypted media** | @ref STREAM_CRYPTO_KEY_SYSTEM | @ref StreamCryptoSession::SetKeySystem "SetKeySystem" | @ref StreamCryptoSession::GetKeySystem "GetKeySystem" + /// | **Flags for special conditions** | `uint8_t` | @ref StreamCryptoSession::SetFlags "SetFlags" | @ref StreamCryptoSession::GetFlags "GetFlags" + /// | **Crypto session key id** | `std::string` | @ref StreamCryptoSession::SetSessionId "SetSessionId" | @ref StreamCryptoSession::GetSessionId "GetSessionId" + + /// @brief To set keysystem for encrypted media, @ref STREAM_CRYPTO_KEY_SYSTEM_NONE for + /// unencrypted media. + /// + /// See @ref STREAM_CRYPTO_KEY_SYSTEM for available options. + void SetKeySystem(STREAM_CRYPTO_KEY_SYSTEM keySystem) { m_cStructure->keySystem = keySystem; } + + /// @brief Get keysystem for encrypted media. + STREAM_CRYPTO_KEY_SYSTEM GetKeySystem() const { return m_cStructure->keySystem; } + + /// @brief Set bit flags to use special conditions, see @ref STREAM_CRYPTO_FLAGS + /// for available flags. + void SetFlags(uint8_t flags) { m_cStructure->flags = flags; } + + /// @brief Get flags for special conditions. + uint8_t GetFlags() const { return m_cStructure->flags; } + + /// @brief To set the crypto session key identifier. + void SetSessionId(const std::string& sessionId) + { + m_sessionId = sessionId; + if (!m_sessionId.empty()) + { + m_cStructure->sessionId = m_sessionId.c_str(); + m_cStructure->sessionIdSize = m_sessionId.size(); + } + else + { + m_cStructure->sessionId = nullptr; + m_cStructure->sessionIdSize = 0; + } + } + + /// @brief To get the crypto session key identifier. + std::string GetSessionId() const { return m_sessionId; } + +private: + StreamCryptoSession(const STREAM_CRYPTO_SESSION* session) + : CStructHdl(session), m_sessionId(session->sessionId) + { + } + StreamCryptoSession(STREAM_CRYPTO_SESSION* session) + : CStructHdl(session), m_sessionId(session->sessionId) + { + } + + std::string m_sessionId; +}; + +} /* namespace addon */ +} /* namespace kodi */ + +#endif /* __cplusplus */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/TimingConstants.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/TimingConstants.h new file mode 100644 index 0000000000..22f8952577 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/TimingConstants.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/addon-instance/inputstream/timing_constants.h" + +#ifdef __cplusplus + +// Unset the on timing_constants.h given defines +#undef STREAM_TIME_TO_MSEC +#undef STREAM_SEC_TO_TIME +#undef STREAM_MSEC_TO_TIME + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Converts a stream time to milliseconds as an integer value. +/// +/// @param[in] x Stream time +/// @return Milliseconds +/// +/// @note Within "C" code this is used as `#define`. +/// +constexpr int STREAM_TIME_TO_MSEC(double x) +{ + return static_cast<int>(x * 1000 / STREAM_TIME_BASE); +} + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Converts a time in seconds to the used stream time format. +/// +/// @param[in] x Seconds +/// @return Stream time +/// +/// @note Within "C" code this is used as `#define`. +/// +constexpr double STREAM_SEC_TO_TIME(double x) +{ + return x * STREAM_TIME_BASE; +} + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Converts a time in milliseconds to the used stream time format. +/// +/// @param[in] x Milliseconds +/// @return Stream time +/// +/// @note Within "C" code this is used as `#define`. +/// +constexpr double STREAM_MSEC_TO_TIME(double x) +{ + return x * STREAM_TIME_BASE / 1000; +} + +#endif /* __cplusplus */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h index febaeb9585..1a6cc6323e 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h @@ -806,7 +806,7 @@ struct DriverPrimitive { protected: /*! - * \brief Construct a driver primitive of the specified type + * @brief Construct a driver primitive of the specified type */ DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex) : m_type(type), m_driverIndex(driverIndex) diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h index 5613947059..4241c233f5 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h @@ -166,7 +166,7 @@ public: m_cStructure->strLanguage[0] = language[0]; m_cStructure->strLanguage[1] = language[1]; m_cStructure->strLanguage[2] = language[2]; - m_cStructure->strLanguage[2] = 0; + m_cStructure->strLanguage[3] = 0; } /// @brief To get with @ref SetLanguage() changed values. diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt index 4edd034ebf..b5d0382e8c 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt @@ -2,10 +2,12 @@ set(HEADERS audio_decoder.h audio_encoder.h game.h image_decoder.h + inputstream.h peripheral.h pvr.h screensaver.h vfs.h + video_codec.h visualization.h) if(NOT ENABLE_STATIC_LIBS) diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h index 8b75ddb119..be6ad16d12 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_AUDIO_DECODER_H #define C_API_ADDONINSTANCE_AUDIO_DECODER_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h index 6f24d1c250..b9f2ab5e5f 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_AUDIO_ENCODER_H #define C_API_ADDONINSTANCE_AUDIO_ENCODER_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h index c97fa5d3aa..b1de8177cb 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_GAME_H #define C_API_ADDONINSTANCE_GAME_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h index 6455b3873b..7093212786 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_IMAGE_DECODER_H #define C_API_ADDONINSTANCE_IMAGE_DECODER_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream.h new file mode 100644 index 0000000000..b291c2f87f --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream.h @@ -0,0 +1,703 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_H + +#include "../addon_base.h" +#include "inputstream/demux_packet.h" +#include "inputstream/stream_codec.h" +#include "inputstream/stream_constants.h" +#include "inputstream/stream_crypto.h" +#include "inputstream/timing_constants.h" + +#include <time.h> + +// Increment this level always if you add features which can lead to compile failures in the addon +#define INPUTSTREAM_VERSION_LEVEL 3 + +#define INPUTSTREAM_MAX_INFO_COUNT 8 +#define INPUTSTREAM_MAX_STREAM_COUNT 256 +#define INPUTSTREAM_MAX_STRING_NAME_SIZE 256 +#define INPUTSTREAM_MAX_STRING_CODEC_SIZE 32 +#define INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE 64 + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + //============================================================================== + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities + /// @brief **Capability types of inputstream addon.**\n + /// This values are needed to tell Kodi which options are supported on the addon. + /// + /// If one of this is defined, then the corresponding methods from + /// @ref cpp_kodi_addon_inputstream "kodi::addon::CInstanceInputStream" need + /// to be implemented. + /// + /// Used on @ref kodi::addon::CInstanceInputStream::GetCapabilities(). + /// + ///@{ + enum INPUTSTREAM_MASKTYPE + { + /// @brief **0000 0000 0000 0001 :** Supports interface demuxing. + /// + /// If set must be @ref cpp_kodi_addon_inputstream_Demux "Demux support" included. + INPUTSTREAM_SUPPORTS_IDEMUX = (1 << 0), + + /// @brief **0000 0000 0000 0010 :** Supports interface position time. + /// + /// This means that the start time and the current stream time are used. + /// + /// If set must be @ref cpp_kodi_addon_inputstream_Time "Time support" included. + INPUTSTREAM_SUPPORTS_IPOSTIME = (1 << 1), + + /// @brief **0000 0000 0000 0100 :** Supports interface for display time. + /// + /// This will call up the complete stream time information. The start time + /// and the individual PTS times are then given using @ref cpp_kodi_addon_inputstream_Defs_Times. + /// + /// If set must be @ref cpp_kodi_addon_inputstream_Times "Times support" included. + INPUTSTREAM_SUPPORTS_IDISPLAYTIME = (1 << 2), + + /// @brief **0000 0000 0000 1000 :** Supports seek + INPUTSTREAM_SUPPORTS_SEEK = (1 << 3), + + /// @brief **0000 0000 0001 0000 :** Supports pause + INPUTSTREAM_SUPPORTS_PAUSE = (1 << 4), + + /// @brief **0000 0000 0010 0000 :** Supports interface to give position time. + /// + /// This will only ask for the current time of the stream, not for length or + /// start. + /// + /// If set must be @ref cpp_kodi_addon_inputstream_PosTime "Position time support" included. + INPUTSTREAM_SUPPORTS_ITIME = (1 << 5), + + /// @brief **0000 0000 0100 0000 :** Supports interface for chapter selection. + /// + /// If set must be @ref cpp_kodi_addon_inputstream_Chapter "Chapter support" included. + INPUTSTREAM_SUPPORTS_ICHAPTER = (1 << 6), + }; + ///@} + //---------------------------------------------------------------------------- + + /*! + * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. + */ + struct INPUTSTREAM_CAPABILITIES + { + /// set of supported capabilities + uint32_t m_mask; + }; + + /*! + * @brief structure of key/value pairs passed to addon on Open() + */ + struct INPUTSTREAM_PROPERTY + { + const char* m_strURL; + const char* m_mimeType; + + unsigned int m_nCountInfoValues; + struct LISTITEMPROPERTY + { + const char* m_strKey; + const char* m_strValue; + } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT]; + + const char* m_libFolder; + const char* m_profileFolder; + }; + + /*! + * @brief Array of stream IDs + */ + struct INPUTSTREAM_IDS + { + unsigned int m_streamCount; + unsigned int m_streamIds[INPUTSTREAM_MAX_STREAM_COUNT]; + }; + + /*! + * @brief MASTERING Metadata + */ + struct INPUTSTREAM_MASTERING_METADATA + { + double primary_r_chromaticity_x; + double primary_r_chromaticity_y; + double primary_g_chromaticity_x; + double primary_g_chromaticity_y; + double primary_b_chromaticity_x; + double primary_b_chromaticity_y; + double white_point_chromaticity_x; + double white_point_chromaticity_y; + double luminance_max; + double luminance_min; + }; + + /*! + * @brief CONTENTLIGHT Metadata + */ + struct INPUTSTREAM_CONTENTLIGHT_METADATA + { + uint64_t max_cll; + uint64_t max_fall; + }; + + //============================================================================== + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_INPUTSTREAM_TYPE enum INPUTSTREAM_TYPE + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Inputstream types**\n + /// To identify type on stream. + /// + /// Used on @ref kodi::addon::InputstreamInfo::SetStreamType and @ref kodi::addon::InputstreamInfo::GetStreamType. + /// + ///@{ + enum INPUTSTREAM_TYPE + { + /// @brief **0 :** To set nothing defined + INPUTSTREAM_TYPE_NONE = 0, + + /// @brief **1 :** To identify @ref cpp_kodi_addon_inputstream_Defs_Info as Video + INPUTSTREAM_TYPE_VIDEO, + + /// @brief **2 :** To identify @ref cpp_kodi_addon_inputstream_Defs_Info as Audio + INPUTSTREAM_TYPE_AUDIO, + + /// @brief **3 :** To identify @ref cpp_kodi_addon_inputstream_Defs_Info as Subtitle + INPUTSTREAM_TYPE_SUBTITLE, + + /// @brief **4 :** To identify @ref cpp_kodi_addon_inputstream_Defs_Info as Teletext + INPUTSTREAM_TYPE_TELETEXT, + + /// @brief **5 :** To identify @ref cpp_kodi_addon_inputstream_Defs_Info as Radio RDS + INPUTSTREAM_TYPE_RDS, + }; + ///@} + //------------------------------------------------------------------------------ + + //============================================================================== + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_INPUTSTREAM_CODEC_FEATURES enum INPUTSTREAM_CODEC_FEATURES + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Inputstream codec features**\n + /// To identify special extra features used for optional codec on inputstream. + /// + /// Used on @ref kodi::addon::InputstreamInfo::SetFeatures and @ref kodi::addon::InputstreamInfo::GetFeatures. + /// + /// @note These variables are bit flags which are created using "|" can be used together. + /// + ///@{ + enum INPUTSTREAM_CODEC_FEATURES + { + /// @brief **0000 0000 0000 0000 :** Empty to set if nothing is used + INPUTSTREAM_FEATURE_NONE = 0, + + /// @brief **0000 0000 0000 0001 :** To set addon decode should used with @ref cpp_kodi_addon_videocodec. + INPUTSTREAM_FEATURE_DECODE = (1 << 0) + }; + ///@} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_INPUTSTREAM_FLAGS enum INPUTSTREAM_FLAGS + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Inputstream flags**\n + /// To identify extra stream flags used on inputstream. + /// + /// Used on @ref kodi::addon::InputstreamInfo::SetFlags and @ref kodi::addon::InputstreamInfo::GetFlags. + /// + /// @note These variables are bit flags which are created using "|" can be used together. + /// + ///@{ + enum INPUTSTREAM_FLAGS + { + /// @brief **0000 0000 0000 0000 :** Empty to set if nothing is used + INPUTSTREAM_FLAG_NONE = (1 << 0), + + /// @brief **0000 0000 0000 0001 :** Default + INPUTSTREAM_FLAG_DEFAULT = (1 << 1), + + /// @brief **0000 0000 0000 0010 :** Dub + INPUTSTREAM_FLAG_DUB = (1 << 2), + + /// @brief **0000 0000 0000 0100 :** Original + INPUTSTREAM_FLAG_ORIGINAL = (1 << 3), + + /// @brief **0000 0000 0000 1000 :** Comment + INPUTSTREAM_FLAG_COMMENT = (1 << 4), + + /// @brief **0000 0000 0001 0000 :** Lyrics + INPUTSTREAM_FLAG_LYRICS = (1 << 5), + + /// @brief **0000 0000 0010 0000 :** Karaoke + INPUTSTREAM_FLAG_KARAOKE = (1 << 6), + + /// @brief **0000 0000 0100 0000 :** Forced + INPUTSTREAM_FLAG_FORCED = (1 << 7), + + /// @brief **0000 0000 1000 0000 :** Hearing impaired + INPUTSTREAM_FLAG_HEARING_IMPAIRED = (1 << 8), + + /// @brief **0000 0001 0000 0000 :** Visual impaired + INPUTSTREAM_FLAG_VISUAL_IMPAIRED = (1 << 9), + }; + ///@} + //---------------------------------------------------------------------------- + + // Keep in sync with AVColorSpace + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_INPUTSTREAM_COLORSPACE enum INPUTSTREAM_COLORSPACE + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Inputstream color space flags**\n + /// YUV colorspace type. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.3. + /// + /// Used on @ref kodi::addon::InputstreamInfo::SetColorSpace and @ref kodi::addon::InputstreamInfo::GetColorSpace. + /// + ///@{ + enum INPUTSTREAM_COLORSPACE + { + /// @brief **0 :** Order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB) + INPUTSTREAM_COLORSPACE_RGB = 0, + + /// @brief **1 :** Also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + INPUTSTREAM_COLORSPACE_BT709 = 1, + + /// @brief **2 :** To set stream is unspecified + INPUTSTREAM_COLORSPACE_UNSPECIFIED = 2, + + /// @brief **2 :** To set stream is unkown + /// @note Same as @ref INPUTSTREAM_COLORSPACE_UNSPECIFIED + INPUTSTREAM_COLORSPACE_UNKNOWN = INPUTSTREAM_COLORSPACE_UNSPECIFIED, // compatibility + + /// @brief **3 :** To set colorspace reserved + INPUTSTREAM_COLORSPACE_RESERVED = 3, + + /// @brief **4 :** FCC Title 47 Code of Federal Regulations 73.682 (a)(20) + INPUTSTREAM_COLORSPACE_FCC = 4, + + /// @brief **5 :** Also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 + INPUTSTREAM_COLORSPACE_BT470BG = 5, + + /// @brief **6 :** Also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + INPUTSTREAM_COLORSPACE_SMPTE170M = 6, + + /// @brief **7 :** Functionally identical to above @ref INPUTSTREAM_COLORSPACE_SMPTE170M + INPUTSTREAM_COLORSPACE_SMPTE240M = 7, + + /// @brief **8 :** Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 + INPUTSTREAM_COLORSPACE_YCGCO = 8, + + /// @brief **8 :** To set colorspace as YCOCG + /// @note Same as @ref INPUTSTREAM_COLORSPACE_YCGCO + INPUTSTREAM_COLORSPACE_YCOCG = INPUTSTREAM_COLORSPACE_YCGCO, + + /// @brief **9 :** ITU-R BT2020 non-constant luminance system + INPUTSTREAM_COLORSPACE_BT2020_NCL = 9, + + /// @brief **10 :** ITU-R BT2020 constant luminance system + INPUTSTREAM_COLORSPACE_BT2020_CL = 10, + + /// @brief **11 :** SMPTE 2085, Y'D'zD'x + INPUTSTREAM_COLORSPACE_SMPTE2085 = 11, + + /// @brief **12 :** Chromaticity-derived non-constant luminance system + INPUTSTREAM_COLORSPACE_CHROMA_DERIVED_NCL = 12, + + /// @brief **13 :** Chromaticity-derived constant luminance system + INPUTSTREAM_COLORSPACE_CHROMA_DERIVED_CL = 13, + + /// @brief **14 :** ITU-R BT.2100-0, ICtCp + INPUTSTREAM_COLORSPACE_ICTCP = 14, + + /// @brief The maximum value to use in a list. + INPUTSTREAM_COLORSPACE_MAX + }; + ///@} + //------------------------------------------------------------------------------ + + // Keep in sync with AVColorPrimaries + //============================================================================== + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_INPUTSTREAM_COLORPRIMARIES enum INPUTSTREAM_COLORPRIMARIES + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Inputstream color primaries flags**\n + /// Chromaticity coordinates of the source primaries. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1. + /// + /// Used on @ref kodi::addon::InputstreamInfo::SetColorPrimaries and @ref kodi::addon::InputstreamInfo::GetColorPrimaries. + /// + ///@{ + enum INPUTSTREAM_COLORPRIMARIES + { + /// @brief **0 :** Reserved + INPUTSTREAM_COLORPRIMARY_RESERVED0 = 0, + + /// @brief **1 :** Also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + INPUTSTREAM_COLORPRIMARY_BT709 = 1, + + /// @brief **2 :** Unspecified + INPUTSTREAM_COLORPRIMARY_UNSPECIFIED = 2, + + /// @brief **3 :** Reserved + INPUTSTREAM_COLORPRIMARY_RESERVED = 3, + + /// @brief **4 :** Also FCC Title 47 Code of Federal Regulations 73.682 (a)(20) + INPUTSTREAM_COLORPRIMARY_BT470M = 4, + + /// @brief **5 :** Also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM + INPUTSTREAM_COLORPRIMARY_BT470BG = 5, + + /// @brief **6 :** Also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + INPUTSTREAM_COLORPRIMARY_SMPTE170M = 6, + + /// @brief **7 :** Functionally identical to above + INPUTSTREAM_COLORPRIMARY_SMPTE240M = 7, + + /// @brief **8 :** Colour filters using Illuminant C + INPUTSTREAM_COLORPRIMARY_FILM = 8, + + /// @brief **9 :** ITU-R BT2020 + INPUTSTREAM_COLORPRIMARY_BT2020 = 9, + + /// @brief **10 :** SMPTE ST 428-1 (CIE 1931 XYZ) + INPUTSTREAM_COLORPRIMARY_SMPTE428 = 10, + + /// @brief **10 :** + /// @note Same as @ref INPUTSTREAM_COLORPRIMARY_SMPTE428 + INPUTSTREAM_COLORPRIMARY_SMPTEST428_1 = INPUTSTREAM_COLORPRIMARY_SMPTE428, + + /// @brief **11 :** SMPTE ST 431-2 (2011) / DCI P3 + INPUTSTREAM_COLORPRIMARY_SMPTE431 = 11, + + /// @brief **12 :** SMPTE ST 432-1 (2010) / P3 D65 / Display P3 + INPUTSTREAM_COLORPRIMARY_SMPTE432 = 12, + + /// @brief **22 :** JEDEC P22 phosphors + INPUTSTREAM_COLORPRIMARY_JEDEC_P22 = 22, + + /// @brief The maximum value to use in a list. + INPUTSTREAM_COLORPRIMARY_MAX + }; + ///@} + //------------------------------------------------------------------------------ + + // Keep in sync with AVColorRange + //============================================================================== + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_INPUTSTREAM_COLORRANGE enum INPUTSTREAM_COLORRANGE + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Inputstream color range flags**\n + /// MPEG vs JPEG YUV range. + /// + /// Used on @ref kodi::addon::InputstreamInfo::SetColorRange and @ref kodi::addon::InputstreamInfo::GetColorRange. + /// + ///@{ + enum INPUTSTREAM_COLORRANGE + { + /// @brief **0 :** To define as unkown + INPUTSTREAM_COLORRANGE_UNKNOWN = 0, + + /// @brief **1 :** The normal 219*2^(n-8) "MPEG" YUV ranges + INPUTSTREAM_COLORRANGE_LIMITED, + + /// @brief **2 :** The normal 2^n-1 "JPEG" YUV ranges + INPUTSTREAM_COLORRANGE_FULLRANGE, + + /// @brief The maximum value to use in a list. + INPUTSTREAM_COLORRANGE_MAX + }; + ///@} + //------------------------------------------------------------------------------ + + // keep in sync with AVColorTransferCharacteristic + //============================================================================== + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_INPUTSTREAM_COLORTRC enum INPUTSTREAM_COLORTRC + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Inputstream color TRC flags**\n + /// Color Transfer Characteristic. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.2. + /// + /// Used on @ref kodi::addon::InputstreamInfo::SetColorTransferCharacteristic and @ref kodi::addon::InputstreamInfo::GetColorTransferCharacteristic. + /// + ///@{ + enum INPUTSTREAM_COLORTRC + { + /// @brief **0 :** Reserved + INPUTSTREAM_COLORTRC_RESERVED0 = 0, + + /// @brief **1 :** Also ITU-R BT1361 + INPUTSTREAM_COLORTRC_BT709 = 1, + + /// @brief **2 :** Unspecified + INPUTSTREAM_COLORTRC_UNSPECIFIED = 2, + + /// @brief **3 :** Reserved + INPUTSTREAM_COLORTRC_RESERVED = 3, + + /// @brief **4 :** Also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM + INPUTSTREAM_COLORTRC_GAMMA22 = 4, + + /// @brief **5 :** Also ITU-R BT470BG + INPUTSTREAM_COLORTRC_GAMMA28 = 5, + + /// @brief **6 :** Also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC + INPUTSTREAM_COLORTRC_SMPTE170M = 6, + + /// @brief **7 :** Functionally identical to above @ref INPUTSTREAM_COLORTRC_SMPTE170M + INPUTSTREAM_COLORTRC_SMPTE240M = 7, + + /// @brief **8 :** Linear transfer characteristics + INPUTSTREAM_COLORTRC_LINEAR = 8, + + /// @brief **9 :** Logarithmic transfer characteristic (100:1 range) + INPUTSTREAM_COLORTRC_LOG = 9, + + /// @brief **10 :** Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range) + INPUTSTREAM_COLORTRC_LOG_SQRT = 10, + + /// @brief **11 :** IEC 61966-2-4 + INPUTSTREAM_COLORTRC_IEC61966_2_4 = 11, + + /// @brief **12 :** ITU-R BT1361 Extended Colour Gamut + INPUTSTREAM_COLORTRC_BT1361_ECG = 12, + + /// @brief **13 :** IEC 61966-2-1 (sRGB or sYCC) + INPUTSTREAM_COLORTRC_IEC61966_2_1 = 13, + + /// @brief **14 :** ITU-R BT2020 for 10-bit system + INPUTSTREAM_COLORTRC_BT2020_10 = 14, + + /// @brief **15 :** ITU-R BT2020 for 12-bit system + INPUTSTREAM_COLORTRC_BT2020_12 = 15, + + /// @brief **16 :** SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems + INPUTSTREAM_COLORTRC_SMPTE2084 = 16, + + /// @brief **16 :** Same as @ref INPUTSTREAM_COLORTRC_SMPTE2084 + INPUTSTREAM_COLORTRC_SMPTEST2084 = INPUTSTREAM_COLORTRC_SMPTE2084, + + /// @brief **17 :** SMPTE ST 428-1 + INPUTSTREAM_COLORTRC_SMPTE428 = 17, + + /// @brief **17 :** Same as @ref INPUTSTREAM_COLORTRC_SMPTE428 + INPUTSTREAM_COLORTRC_SMPTEST428_1 = INPUTSTREAM_COLORTRC_SMPTE428, + + /// @brief **18 :** ARIB STD-B67, known as "Hybrid log-gamma" + INPUTSTREAM_COLORTRC_ARIB_STD_B67 = 18, + + /// @brief The maximum value to use in a list. + INPUTSTREAM_COLORTRC_MAX + }; + ///@} + //------------------------------------------------------------------------------ + + /*! + * @brief stream properties + */ + struct INPUTSTREAM_INFO + { + enum INPUTSTREAM_TYPE m_streamType; + uint32_t m_features; + uint32_t m_flags; + + //! @brief (optional) name of the stream, \0 for default handling + char m_name[INPUTSTREAM_MAX_STRING_NAME_SIZE]; + + //! @brief (required) name of codec according to ffmpeg + char m_codecName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; + + //! @brief (optional) internal name of codec (selectionstream info) + char m_codecInternalName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; + + //! @brief (optional) the profile of the codec + enum STREAMCODEC_PROFILE m_codecProfile; + + //! @brief (required) physical index + unsigned int m_pID; + + const uint8_t* m_ExtraData; + unsigned int m_ExtraSize; + + //! @brief RFC 5646 language code (empty string if undefined) + char m_language[INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE]; + + //! Video stream related data + //@{ + + //! @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps + unsigned int m_FpsScale; + + unsigned int m_FpsRate; + + //! @brief height of the stream reported by the demuxer + unsigned int m_Height; + + //! @brief width of the stream reported by the demuxer + unsigned int m_Width; + + //! @brief display aspect of stream + float m_Aspect; + + //@} + + //! Audio stream related data + //@{ + + //! @brief (required) amount of channels + unsigned int m_Channels; + + //! @brief (required) sample rate + unsigned int m_SampleRate; + + //! @brief (required) bit rate + unsigned int m_BitRate; + + //! @brief (required) bits per sample + unsigned int m_BitsPerSample; + + unsigned int m_BlockAlign; + + //@} + + struct STREAM_CRYPTO_SESSION m_cryptoSession; + + // new in API version 2.0.8 + //@{ + //! @brief Codec If available, the fourcc code codec + unsigned int m_codecFourCC; + + //! @brief definition of colorspace + enum INPUTSTREAM_COLORSPACE m_colorSpace; + + //! @brief color range if available + enum INPUTSTREAM_COLORRANGE m_colorRange; + //@} + + //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1 + //@{ + enum INPUTSTREAM_COLORPRIMARIES m_colorPrimaries; + enum INPUTSTREAM_COLORTRC m_colorTransferCharacteristic; + //@} + + //! @brief mastering static Metadata + struct INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata; + + //! @brief content light static Metadata + struct INPUTSTREAM_CONTENTLIGHT_METADATA* m_contentLightMetadata; + }; + + struct INPUTSTREAM_TIMES + { + time_t startTime; + double ptsStart; + double ptsBegin; + double ptsEnd; + }; + + /*! + * @brief "C" ABI Structures to transfer the methods from this to Kodi + */ + + // this are properties given to the addon on create + // at this time we have no parameters for the addon + typedef struct AddonProps_InputStream /* internal */ + { + int dummy; + } AddonProps_InputStream; + + typedef struct AddonToKodiFuncTable_InputStream /* internal */ + { + KODI_HANDLE kodiInstance; + struct DEMUX_PACKET* (*allocate_demux_packet)(void* kodiInstance, int data_size); + struct DEMUX_PACKET* (*allocate_encrypted_demux_packet)(void* kodiInstance, + unsigned int data_size, + unsigned int encrypted_subsample_count); + void (*free_demux_packet)(void* kodiInstance, struct DEMUX_PACKET* packet); + } AddonToKodiFuncTable_InputStream; + + struct AddonInstance_InputStream; + typedef struct KodiToAddonFuncTable_InputStream /* internal */ + { + KODI_HANDLE addonInstance; + + bool(__cdecl* open)(const struct AddonInstance_InputStream* instance, + struct INPUTSTREAM_PROPERTY* props); + void(__cdecl* close)(const struct AddonInstance_InputStream* instance); + const char*(__cdecl* get_path_list)(const struct AddonInstance_InputStream* instance); + void(__cdecl* get_capabilities)(const struct AddonInstance_InputStream* instance, + struct INPUTSTREAM_CAPABILITIES* capabilities); + + // IDemux + bool(__cdecl* get_stream_ids)(const struct AddonInstance_InputStream* instance, + struct INPUTSTREAM_IDS* ids); + bool(__cdecl* get_stream)(const struct AddonInstance_InputStream* instance, + int streamid, + struct INPUTSTREAM_INFO* info, + KODI_HANDLE* demuxStream, + KODI_HANDLE (*transfer_stream)(KODI_HANDLE handle, + int streamId, + struct INPUTSTREAM_INFO* stream)); + void(__cdecl* enable_stream)(const struct AddonInstance_InputStream* instance, + int streamid, + bool enable); + bool(__cdecl* open_stream)(const struct AddonInstance_InputStream* instance, int streamid); + void(__cdecl* demux_reset)(const struct AddonInstance_InputStream* instance); + void(__cdecl* demux_abort)(const struct AddonInstance_InputStream* instance); + void(__cdecl* demux_flush)(const struct AddonInstance_InputStream* instance); + struct DEMUX_PACKET*(__cdecl* demux_read)(const struct AddonInstance_InputStream* instance); + bool(__cdecl* demux_seek_time)(const struct AddonInstance_InputStream* instance, + double time, + bool backwards, + double* startpts); + void(__cdecl* demux_set_speed)(const struct AddonInstance_InputStream* instance, int speed); + void(__cdecl* set_video_resolution)(const struct AddonInstance_InputStream* instance, + int width, + int height); + + // IDisplayTime + int(__cdecl* get_total_time)(const struct AddonInstance_InputStream* instance); + int(__cdecl* get_time)(const struct AddonInstance_InputStream* instance); + + // ITime + bool(__cdecl* get_times)(const struct AddonInstance_InputStream* instance, + struct INPUTSTREAM_TIMES* times); + + // IPosTime + bool(__cdecl* pos_time)(const struct AddonInstance_InputStream* instance, int ms); + + int(__cdecl* read_stream)(const struct AddonInstance_InputStream* instance, + uint8_t* buffer, + unsigned int bufferSize); + int64_t(__cdecl* seek_stream)(const struct AddonInstance_InputStream* instance, + int64_t position, + int whence); + int64_t(__cdecl* position_stream)(const struct AddonInstance_InputStream* instance); + int64_t(__cdecl* length_stream)(const struct AddonInstance_InputStream* instance); + bool(__cdecl* is_real_time_stream)(const struct AddonInstance_InputStream* instance); + + // IChapter + int(__cdecl* get_chapter)(const struct AddonInstance_InputStream* instance); + int(__cdecl* get_chapter_count)(const struct AddonInstance_InputStream* instance); + const char*(__cdecl* get_chapter_name)(const struct AddonInstance_InputStream* instance, + int ch); + int64_t(__cdecl* get_chapter_pos)(const struct AddonInstance_InputStream* instance, int ch); + bool(__cdecl* seek_chapter)(const struct AddonInstance_InputStream* instance, int ch); + + int(__cdecl* block_size_stream)(const struct AddonInstance_InputStream* instance); + } KodiToAddonFuncTable_InputStream; + + typedef struct AddonInstance_InputStream /* internal */ + { + struct AddonProps_InputStream* props; + struct AddonToKodiFuncTable_InputStream* toKodi; + struct KodiToAddonFuncTable_InputStream* toAddon; + } AddonInstance_InputStream; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/CMakeLists.txt new file mode 100644 index 0000000000..9a22c44230 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/CMakeLists.txt @@ -0,0 +1,9 @@ +set(HEADERS demux_packet.h + stream_codec.h + stream_constants.h + stream_crypto.h + timing_constants.h) + +if(NOT ENABLE_STATIC_LIBS) + core_add_library(addons_kodi-dev-kit_include_kodi_c-api_addon-instance_inputstream) +endif() diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h new file mode 100644 index 0000000000..79686abc9b --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_DEMUXPACKET_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_DEMUXPACKET_H + +#include "timing_constants.h" + +#include <stdbool.h> +#include <stdint.h> + +#define DEMUX_SPECIALID_STREAMINFO -10 +#define DEMUX_SPECIALID_STREAMCHANGE -11 + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + struct DEMUX_CRYPTO_INFO; + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_DEMUX_PACKET struct DEMUX_PACKET + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Demux packet**\n + /// To processed codec and demux inputstream stream. + /// + /// This part is in the "C" style in order to have better performance and + /// possibly to be used in "C" libraries. + /// + /// The structure should be created with @ref kodi::addon::CInstanceInputStream::AllocateDemuxPacket() + /// or @ref kodi::addon::CInstanceInputStream::AllocateEncryptedDemuxPacket() + /// and if not added to Kodi with @ref kodi::addon::CInstanceInputStream::FreeDemuxPacket() + /// be deleted again. + /// + /// Packages that have been given to Kodi and processed will then be deleted + /// by him. + /// + ///@{ + struct DEMUX_PACKET + { + /// @brief Stream package which is given for decoding. + /// + /// @note Associated storage from here is created using + /// @ref kodi::addon::CInstanceInputStream::AllocateDemuxPacket() + /// or @ref kodi::addon::CInstanceInputStream::AllocateEncryptedDemuxPacket(). + uint8_t* pData; + + /// @brief Size of the package given at @ref pData. + int iSize; + + /// @brief Identification of the stream. + int iStreamId; + + /// @brief Identification of the associated demuxer, this can be identical + /// on several streams. + int64_t demuxerId; + + /// @brief The group this data belongs to, used to group data from different + /// streams together. + int iGroupId; + + //------------------------------------------ + + /// @brief Additional packet data that can be provided by the container. + /// + /// Packet can contain several types of side information. + /// + /// This is usually based on that of ffmpeg, see + /// [AVPacketSideData](https://ffmpeg.org/doxygen/trunk/structAVPacketSideData.html). + void* pSideData; + + /// @brief Data elements stored at @ref pSideData. + int iSideDataElems; + + //------------------------------------------ + + /// @brief Presentation time stamp (PTS). + double pts; + + /// @brief Decoding time stamp (DTS). + double dts; + + /// @brief Duration in @ref STREAM_TIME_BASE if available + double duration; + + /// @brief Display time from input stream + int dispTime; + + /// @brief To show that this package allows recreating the presentation by + /// mistake. + bool recoveryPoint; + + //------------------------------------------ + + /// @brief Optional data to allow decryption at processing site if + /// necessary. + /// + /// This can be created using @ref kodi::addon::CInstanceInputStream::AllocateEncryptedDemuxPacket(), + /// otherwise this is declared as <b>`nullptr`</b>. + /// + /// See @ref DEMUX_CRYPTO_INFO for their style. + struct DEMUX_CRYPTO_INFO* cryptoInfo; + }; + ///@} + //---------------------------------------------------------------------------- + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_DEMUXPACKET_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_codec.h index e03037199a..b489cb9097 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_codec.h @@ -6,7 +6,8 @@ * See LICENSES/README.md for more information. */ -#pragma once +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCODEC_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCODEC_H #ifdef __cplusplus extern "C" @@ -14,10 +15,12 @@ extern "C" #endif /* __cplusplus */ //============================================================================== - /// @ingroup cpp_kodi_addon_videocodec_Defs_VIDEOCODEC_INITDATA - /// @brief The standard defines several sets of capabilities, which are referred - /// to as profiles, targeting specific classes of applications. - //@{ + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAMCODEC_PROFILE enum STREAMCODEC_PROFILE + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamCodec + /// @brief **The standard defines several sets of capabilities.**\n + /// Which are referred to as profiles, targeting specific classes of applications. + /// + ///@{ enum STREAMCODEC_PROFILE { /// @brief Unknown codec profile @@ -26,8 +29,8 @@ extern "C" /// @brief If a codec profile is not required CodecProfileNotNeeded, - /// @brief **H264** Baseline Profile (BP, 66) - /// + /// @brief **H264** Baseline Profile (BP, 66)\n + /// \n /// Primarily for low-cost applications that require additional data loss /// robustness, this profile is used in some videoconferencing and mobile /// applications. This profile includes all features that are supported @@ -40,8 +43,8 @@ extern "C" /// profiles share the same profile identifier code value. H264CodecProfileBaseline, - /// @brief **H264** Main Profile (MP, 77) - /// + /// @brief **H264** Main Profile (MP, 77)\n + /// \n /// This profile is used for standard-definition digital TV broadcasts that /// use the MPEG-4 format as defined in the /// [DVB standard](http://www.etsi.org/deliver/etsi_ts/101100_101199/101154/01.09.01_60/ts_101154v010901p.pdf). @@ -50,15 +53,15 @@ extern "C" /// in 2004 for that application. H264CodecProfileMain, - /// @brief **H264** Extended Profile (XP, 88) - /// + /// @brief **H264** Extended Profile (XP, 88)\n + /// \n /// Intended as the streaming video profile, this profile has relatively high /// compression capability and some extra tricks for robustness to data losses /// and server stream switching. H264CodecProfileExtended, - /// @brief **H264** High Profile (HiP, 100) - /// + /// @brief **H264** High Profile (HiP, 100)\n + /// \n /// The primary profile for broadcast and disc storage applications, /// particularly for high-definition television applications (for example, /// this is the profile adopted by the [Blu-ray Disc](https://en.wikipedia.org/wiki/Blu-ray_Disc) @@ -66,31 +69,31 @@ extern "C" /// HDTV broadcast service). H264CodecProfileHigh, - /// @brief **H264** High 10 Profile (Hi10P, 110) - /// + /// @brief **H264** High 10 Profile (Hi10P, 110)\n + /// \n /// Going beyond typical mainstream consumer product capabilities, this /// profile builds on top of the High Profile, adding support for up to 10 /// bits per sample of decoded picture precision. H264CodecProfileHigh10, - /// @brief **H264** High 4:2:2 Profile (Hi422P, 122) - /// + /// @brief **H264** High 4:2:2 Profile (Hi422P, 122)\n + /// \n /// Primarily targeting professional applications that use interlaced video, /// this profile builds on top of the High 10 Profile, adding support for the /// 4:2:2 chroma sampling format while using up to 10 bits per sample of /// decoded picture precision. H264CodecProfileHigh422, - /// @brief **H264** High 4:4:4 Predictive Profile (Hi444PP, 244) - /// + /// @brief **H264** High 4:4:4 Predictive Profile (Hi444PP, 244)\n + /// \n /// This profile builds on top of the High 4:2:2 Profile, supporting up to /// 4:4:4 chroma sampling, up to 14 bits per sample, and additionally /// supporting efficient lossless region coding and the coding of each /// picture as three separate color planes. H264CodecProfileHigh444Predictive, - /// @brief **VP9** profile 0 - /// + /// @brief **VP9** profile 0\n + /// \n /// There are several variants of the VP9 format (known as "coding profiles"), /// which successively allow more features; profile 0 is the basic variant, /// requiring the least from a hardware implementation. @@ -99,28 +102,30 @@ extern "C" /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0 VP9CodecProfile0 = 20, - /// @brief **VP9** profile 1 - /// + /// @brief **VP9** profile 1\n + /// \n /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 8 bit, /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4 VP9CodecProfile1, - /// @brief **VP9** profile 2 - /// + /// @brief **VP9** profile 2\n + /// \n /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit, /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0 VP9CodecProfile2, - /// @brief **VP9** profile 3 - /// + /// @brief **VP9** profile 3\n + /// \n /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit, /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4, /// see [VP9 Bitstream & Decoding Process Specification](https://storage.googleapis.com/downloads.webmproject.org/docs/vp9/vp9-bitstream-specification-v0.6-20160331-draft.pdf) VP9CodecProfile3, }; - //@} + ///@} //------------------------------------------------------------------------------ #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCODEC_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h new file mode 100644 index 0000000000..f442d64ede --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2017-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCONSTANTS_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCONSTANTS_H + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief The name of the inputstream add-on that should be used by Kodi to +/// play the stream. +/// +/// Leave blank to use Kodi's built-in playing capabilities or to allow +/// ffmpeg to handle directly set to @ref STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG. +#define STREAM_PROPERTY_INPUTSTREAM "inputstream" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief Identification string for an input stream. +/// +/// This value can be used in addition to @ref STREAM_PROPERTY_INPUTSTREAM. It is +/// used to provide the respective inpustream addon with additional +/// identification. +/// +/// The difference between this and other stream properties is that it is also +/// passed in the associated @ref kodi::addon::CAddonBase::CreateInstance call. +/// +/// This makes it possible to select different processing classes within the +/// associated add-on. +#define STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID "inputstream-instance-id" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief "true" to denote that the stream that should be played is a +/// realtime stream. Any other value indicates that this is not a realtime +/// stream. +#define STREAM_PROPERTY_ISREALTIMESTREAM "isrealtimestream" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief Special value for @ref STREAM_PROPERTY_INPUTSTREAM to use +/// ffmpeg to directly play a stream URL. +#define STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG "inputstream.ffmpeg" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief Max number of properties that can be sent to an Inputstream addon +#define STREAM_MAX_PROPERTY_COUNT 30 + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCONSTANTS_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h new file mode 100644 index 0000000000..e083cc7a65 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2017-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H + +#include <stdint.h> +#include <string.h> + +#define STREAMCRYPTO_VERSION_LEVEL 2 + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAM_CRYPTO_KEY_SYSTEM enum STREAM_CRYPTO_KEY_SYSTEM + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption + /// @brief **Available ways to process stream cryptography**\n + /// For @ref cpp_kodi_addon_inputstream_Defs_StreamEncryption_StreamCryptoSession, + /// this defines the used and required auxiliary modules which are required to + /// process the encryption stream. + /// + /// Used to set wanted [digital rights management](https://en.wikipedia.org/wiki/Digital_rights_management) + /// (DRM) technology provider for stream. + ///@{ + enum STREAM_CRYPTO_KEY_SYSTEM + { + /// @brief **0** - If no path is to be used, this is the default + STREAM_CRYPTO_KEY_SYSTEM_NONE = 0, + + /// @brief **1** - To use [Widevine](https://en.wikipedia.org/wiki/Widevine) for processing + STREAM_CRYPTO_KEY_SYSTEM_WIDEVINE, + + /// @brief **2** - To use [Playready](https://en.wikipedia.org/wiki/PlayReady) for processing + STREAM_CRYPTO_KEY_SYSTEM_PLAYREADY, + + /// @brief **3** - To use Wiseplay for processing + STREAM_CRYPTO_KEY_SYSTEM_WISEPLAY, + + /// @brief **4** - The maximum value to use in a list. + STREAM_CRYPTO_KEY_SYSTEM_COUNT + }; + ///@} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAM_CRYPTO_FLAGS enum STREAM_CRYPTO_FLAGS + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption + /// @brief **Cryptography flags to use special conditions**\n + /// To identify special extra conditions. + /// + /// @note These variables are bit flags which are created using "|" can be used + /// together. + /// + ///@{ + enum STREAM_CRYPTO_FLAGS + { + /// @brief **0000 0000** - Empty to set if nothing is used. + STREAM_CRYPTO_FLAG_NONE = 0, + + /// @brief **0000 0001** - Is set in flags if decoding has to be done in + /// [trusted execution environment (TEE)](https://en.wikipedia.org/wiki/Trusted_execution_environment). + STREAM_CRYPTO_FLAG_SECURE_DECODER = (1 << 0) + }; + ///@} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_DEMUX_CRYPTO_INFO struct DEMUX_CRYPTO_INFO + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption + /// @brief **C data structure for processing encrypted streams.**\n + /// If required, this structure is used for every DEMUX_PACKET to be processed. + /// + ///@{ + struct DEMUX_CRYPTO_INFO + { + /// @brief Number of subsamples. + uint16_t numSubSamples; + + /// @brief Flags for later use. + uint16_t flags; + + /// @brief @ref numSubSamples uint16_t's wich define the size of clear size + /// of a subsample. + uint16_t* clearBytes; + + /// @brief @ref numSubSamples uint32_t's wich define the size of cipher size + /// of a subsample. + uint32_t* cipherBytes; + + /// @brief Initialization vector + uint8_t iv[16]; + + /// @brief Key id + uint8_t kid[16]; + }; + ///@} + //---------------------------------------------------------------------------- + + // Data to manage stream cryptography + struct STREAM_CRYPTO_SESSION + { + // keysystem for encrypted media, STREAM_CRYPTO_KEY_SYSTEM_NONE for unencrypted + // media. + // + // See STREAM_CRYPTO_KEY_SYSTEM for available options. + enum STREAM_CRYPTO_KEY_SYSTEM keySystem; + + // Flags to use special conditions, see STREAM_CRYPTO_FLAGS for available flags. + uint8_t flags; + + // The size of the crypto session key id set in sessionId. + uint16_t sessionIdSize; + + // The crypto session key id. + // + // WARNING The data set here is not copied and its pointer must still be + // available. + const char* sessionId; + }; + ///@} + //---------------------------------------------------------------------------- + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/timing_constants.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/timing_constants.h new file mode 100644 index 0000000000..a226a0dbcb --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/timing_constants.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_TIMINGCONSTANTS_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_TIMINGCONSTANTS_H + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Speed value to pause stream in playback. +/// +#define STREAM_PLAYSPEED_PAUSE 0 // frame stepping + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Speed value to perform stream playback at normal speed. +/// +/// See @ref STREAM_PLAYSPEED_PAUSE for pause of stream. +/// +#define STREAM_PLAYSPEED_NORMAL 1000 + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Time base represented as integer. +/// +#define STREAM_TIME_BASE 1000000 + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Undefined timestamp value. +/// +/// Usually reported by demuxer that work on containers that do not provide +/// either pts or dts. +/// +#define STREAM_NOPTS_VALUE 0xFFF0000000000000 + +// "C" defines to translate stream times +#define STREAM_TIME_TO_MSEC(x) ((int)((double)(x)*1000 / STREAM_TIME_BASE)) +#define STREAM_SEC_TO_TIME(x) ((double)(x)*STREAM_TIME_BASE) +#define STREAM_MSEC_TO_TIME(x) ((double)(x)*STREAM_TIME_BASE / 1000) + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_TIMINGCONSTANTS_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h index 393f34a0c6..df168bc024 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PERIPHERAL_H #define C_API_ADDONINSTANCE_PERIPHERAL_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h index a50ea2ba65..3a185cbc87 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_H #define C_API_ADDONINSTANCE_PVR_H @@ -124,8 +122,8 @@ extern "C" //--==----==----==----==----==----==----==----==----==----==----==----==----== // Stream demux interface functions - void (*FreeDemuxPacket)(void* kodiInstance, struct DemuxPacket* pPacket); - struct DemuxPacket* (*AllocateDemuxPacket)(void* kodiInstance, int iDataSize); + void (*FreeDemuxPacket)(void* kodiInstance, struct DEMUX_PACKET* pPacket); + struct DEMUX_PACKET* (*AllocateDemuxPacket)(void* kodiInstance, int iDataSize); struct PVR_CODEC (*GetCodecByName)(const void* kodiInstance, const char* strCodecName); //--==----==----==----==----==----==----==----==----==----==----==----==----== @@ -295,7 +293,7 @@ extern "C" // Stream demux interface functions enum PVR_ERROR(__cdecl* GetStreamProperties)(const struct AddonInstance_PVR*, struct PVR_STREAM_PROPERTIES*); - struct DemuxPacket*(__cdecl* DemuxRead)(const struct AddonInstance_PVR*); + struct DEMUX_PACKET*(__cdecl* DemuxRead)(const struct AddonInstance_PVR*); void(__cdecl* DemuxReset)(const struct AddonInstance_PVR*); void(__cdecl* DemuxAbort)(const struct AddonInstance_PVR*); void(__cdecl* DemuxFlush)(const struct AddonInstance_PVR*); diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h index a24d27faca..f8213fbc5c 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H #define C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h index 00daffa04e..a19fba1acb 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_CHANNELS_H #define C_API_ADDONINSTANCE_PVR_CHANNELS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h index 449000f98b..a7651215d1 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_DEFINES_H #define C_API_ADDONINSTANCE_PVR_DEFINES_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h index e7cdf06a44..c74a113322 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_EDL_H #define C_API_ADDONINSTANCE_PVR_EDL_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h index d7512dce69..2ed23cd03d 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_EPG_H #define C_API_ADDONINSTANCE_PVR_EPG_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h index e2136f6bb3..b4470bb16b 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h @@ -6,19 +6,12 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_GENERAL_H #define C_API_ADDONINSTANCE_PVR_GENERAL_H +#include "../inputstream/stream_constants.h" #include "pvr_defines.h" -#ifdef BUILD_KODI_ADDON -#include "../../../InputStreamConstants.h" -#else -#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" -#endif - #include <stdbool.h> //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h index 2ead263cec..e204311e6e 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_MENUHOOK_H #define C_API_ADDONINSTANCE_PVR_MENUHOOK_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h index 2e2c081a16..0bbfe57d24 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_RECORDINGS_H #define C_API_ADDONINSTANCE_PVR_RECORDINGS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h index 1206c6735b..aaca30e08b 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h @@ -6,19 +6,12 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_STREAM_H #define C_API_ADDONINSTANCE_PVR_STREAM_H +#include "../inputstream/demux_packet.h" #include "pvr_defines.h" -#ifdef BUILD_KODI_ADDON -#include "../../../DemuxPacket.h" -#else -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#endif - #include <stdint.h> #include <time.h> diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h index 209726d731..a4b53d63a5 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_PVR_TIMERS_H #define C_API_ADDONINSTANCE_PVR_TIMERS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h index 32cf6e1392..90f971afdf 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h @@ -6,7 +6,8 @@ * See LICENSES/README.md for more information. */ -#pragma once +#ifndef C_API_ADDONINSTANCE_SCREENSAVER_H +#define C_API_ADDONINSTANCE_SCREENSAVER_H #include "../addon_base.h" @@ -73,3 +74,5 @@ extern "C" #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_SCREENSAVER_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h index a6c3f44b63..7021c0f75c 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h @@ -5,8 +5,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDONINSTANCE_VFS_H #define C_API_ADDONINSTANCE_VFS_H @@ -94,7 +92,7 @@ extern "C" VFS_FILE_HANDLE context); bool(__cdecl* io_control_get_cache_status)(const struct AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context, - VFS_CACHE_STATUS_DATA* status); + struct VFS_CACHE_STATUS_DATA* status); bool(__cdecl* io_control_set_cache_rate)(const struct AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context, unsigned int rate); diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/video_codec.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/video_codec.h new file mode 100644 index 0000000000..02d8b06d5f --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/video_codec.h @@ -0,0 +1,261 @@ +/* + * Copyright (C) 2017-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_VIDEOCODEC_H +#define C_API_ADDONINSTANCE_VIDEOCODEC_H + +#include "../addon_base.h" +#include "inputstream/demux_packet.h" +#include "inputstream/stream_codec.h" +#include "inputstream/stream_crypto.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec_Defs + /// @brief Return values used by video decoder interface + enum VIDEOCODEC_RETVAL + { + /// @brief Noop + VC_NONE = 0, + + /// @brief An error occured, no other messages will be returned + VC_ERROR, + + /// @brief The decoder needs more data + VC_BUFFER, + + /// @brief The decoder got a picture + VC_PICTURE, + + /// @brief The decoder signals EOF + VC_EOF, + }; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata + /// @brief The video stream representations requested by Kodi + /// + enum VIDEOCODEC_FORMAT + { + /// @brief Unknown types, this is used to declare the end of a list of + /// requested types + VIDEOCODEC_FORMAT_UNKNOWN = 0, + + /// @brief YV12 4:2:0 YCrCb planar format + VIDEOCODEC_FORMAT_YV12, + + /// @brief These formats are identical to YV12 except that the U and V plane + /// order is reversed. + VIDEOCODEC_FORMAT_I420, + + /// @brief The maximum value to use in a list. + VIDEOCODEC_FORMAT_MAXFORMATS + }; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata + /// @brief Video codec types that can be requested from Kodi + /// + enum VIDEOCODEC_TYPE + { + /// @brief Unknown or other type requested + /// + VIDEOCODEC_UNKNOWN = 0, + + /// @brief [VP8](https://en.wikipedia.org/wiki/VP8) video coding format + /// + VIDEOCODEC_VP8, + + /// @brief [Advanced Video Coding (AVC)](https://en.wikipedia.org/wiki/Advanced_Video_Coding), + /// also referred to as H.264 or [MPEG-4](https://en.wikipedia.org/wiki/MPEG-4) + /// Part 10, Advanced Video Coding (MPEG-4 AVC). + VIDEOCODEC_H264, + + /// @brief [VP9](https://en.wikipedia.org/wiki/VP9) video coding format\n + /// \n + /// VP9 is the successor to VP8 and competes mainly with MPEG's + /// [High Efficiency Video Coding](https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding) + /// (HEVC/H.265). + VIDEOCODEC_VP9 + }; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec_Defs_VIDEOCODEC_PICTURE + /// @brief YUV Plane identification pointers + /// + /// YUV is a color encoding system typically used as part of a color image pipeline. + /// + /// These are used to access stored data in @ref VIDEOCODEC_PICTURE::planeOffsets + /// and @ref VIDEOCODEC_PICTURE::stride. + /// + enum VIDEOCODEC_PLANE + { + /// @brief "luminance" component Y (equivalent to grey scale) + VIDEOCODEC_PICTURE_Y_PLANE = 0, + + /// @brief "chrominance" component U (blue projection) + VIDEOCODEC_PICTURE_U_PLANE, + + /// @brief "chrominance" component V (red projection) + VIDEOCODEC_PICTURE_V_PLANE, + + /// @brief The maximum value to use in a list. + VIDEOCODEC_PICTURE_MAXPLANES = 3, + }; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_addon_videocodec_Defs_VIDEOCODEC_PICTURE + /// @brief Video coded process flags, used to perform special operations in + /// stream calls. + /// + /// These are used to access stored data in @ref VIDEOCODEC_PICTURE::flags. + /// + /// @note These variables are bit flags which are created using "|" can be used together. + /// + enum VIDEOCODEC_PICTURE_FLAG + { + /// @brief Empty and nothing defined + VIDEOCODEC_PICTURE_FLAG_NONE = 0, + + /// @brief Drop in decoder + VIDEOCODEC_PICTURE_FLAG_DROP = (1 << 0), + + /// @brief Squeeze out pictured without feeding new packets + VIDEOCODEC_PICTURE_FLAG_DRAIN = (1 << 1), + }; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @defgroup cpp_kodi_addon_videocodec_Defs_VIDEOCODEC_PICTURE struct VIDEOCODEC_PICTURE + /// @ingroup cpp_kodi_addon_videocodec_Defs + /// @brief Data structure which is given to the addon when a decoding call is made. + /// + ///@{ + struct VIDEOCODEC_PICTURE + { + /// @brief The video format declared with @ref VIDEOCODEC_FORMAT and to be + /// used on the addon. + enum VIDEOCODEC_FORMAT videoFormat; + + /// @brief Video coded process flags, used to perform special operations in + /// stream calls. + /// + /// Possible flags are declared here @ref VIDEOCODEC_PICTURE_FLAGS. + uint32_t flags; + + /// @brief Picture width. + uint32_t width; + + /// @brief Picture height. + uint32_t height; + + /// @brief Data to be decoded in the addon. + uint8_t* decodedData; + + /// @brief Size of the data given with @ref decodedData + size_t decodedDataSize; + + /// @brief YUV color plane calculation array. + /// + /// This includes the three values of the YUV and can be identified using + /// @ref VIDEOCODEC_PLANE. + uint32_t planeOffsets[VIDEOCODEC_PICTURE_MAXPLANES]; + + /// @brief YUV color stride calculation array + /// + /// This includes the three values of the YUV and can be identified using + /// @ref VIDEOCODEC_PLANE. + uint32_t stride[VIDEOCODEC_PICTURE_MAXPLANES]; + + /// @brief Picture presentation time stamp (PTS). + int64_t pts; + + /// @brief This is used to save the related handle from Kodi. + /// + /// To handle the input stream buffer, this is given by Kodi using + /// @ref kodi::addon::CInstanceVideoCodec::GetFrameBuffer and must be + /// released again using @ref kodi::addon::CInstanceVideoCodec::ReleaseFrameBuffer. + KODI_HANDLE videoBufferHandle; + }; + ///@} + //---------------------------------------------------------------------------- + + struct VIDEOCODEC_INITDATA + { + enum VIDEOCODEC_TYPE codec; + enum STREAMCODEC_PROFILE codecProfile; + enum VIDEOCODEC_FORMAT* videoFormats; + uint32_t width; + uint32_t height; + const uint8_t* extraData; + unsigned int extraDataSize; + struct STREAM_CRYPTO_SESSION cryptoSession; + }; + + // this are properties given to the addon on create + // at this time we have no parameters for the addon + typedef struct AddonProps_VideoCodec + { + int dummy; + } AddonProps_VideoCodec; + + struct AddonInstance_VideoCodec; + typedef struct KodiToAddonFuncTable_VideoCodec + { + KODI_HANDLE addonInstance; + + //! @brief Opens a codec + bool(__cdecl* open)(const struct AddonInstance_VideoCodec* instance, + struct VIDEOCODEC_INITDATA* initData); + + //! @brief Reconfigures a codec + bool(__cdecl* reconfigure)(const struct AddonInstance_VideoCodec* instance, + struct VIDEOCODEC_INITDATA* initData); + + //! @brief Feed codec if requested from GetPicture() (return VC_BUFFER) + bool(__cdecl* add_data)(const struct AddonInstance_VideoCodec* instance, + const struct DEMUX_PACKET* packet); + + //! @brief Get a decoded picture / request new data + enum VIDEOCODEC_RETVAL(__cdecl* get_picture)(const struct AddonInstance_VideoCodec* instance, + struct VIDEOCODEC_PICTURE* picture); + + //! @brief Get the name of this video decoder + const char*(__cdecl* get_name)(const struct AddonInstance_VideoCodec* instance); + + //! @brief Reset the codec + void(__cdecl* reset)(const struct AddonInstance_VideoCodec* instance); + } KodiToAddonFuncTable_VideoCodec; + + typedef struct AddonToKodiFuncTable_VideoCodec + { + KODI_HANDLE kodiInstance; + bool (*get_frame_buffer)(void* kodiInstance, struct VIDEOCODEC_PICTURE* picture); + void (*release_frame_buffer)(void* kodiInstance, void* buffer); + } AddonToKodiFuncTable_VideoCodec; + + typedef struct AddonInstance_VideoCodec + { + struct AddonProps_VideoCodec* props; + struct AddonToKodiFuncTable_VideoCodec* toKodi; + struct KodiToAddonFuncTable_VideoCodec* toAddon; + } AddonInstance_VideoCodec; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_VIDEOCODEC_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h index 913aad8d3c..616e0a8666 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h @@ -6,7 +6,8 @@ * See LICENSES/README.md for more information. */ -#pragma once +#ifndef C_API_ADDONINSTANCE_VISUALIZATION_H +#define C_API_ADDONINSTANCE_VISUALIZATION_H #include "../addon_base.h" @@ -115,3 +116,5 @@ extern "C" #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_VISUALIZATION_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h index faa99fad80..1153eca120 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_ADDON_BASE_H #define C_API_ADDON_BASE_H @@ -27,6 +25,8 @@ #endif #endif +// Generic helper definitions for smallest possible alignment +//@{ #undef ATTRIBUTE_PACKED #undef PRAGMA_PACK_BEGIN #undef PRAGMA_PACK_END @@ -34,18 +34,16 @@ #if defined(__GNUC__) #define ATTRIBUTE_PACKED __attribute__((packed)) #define PRAGMA_PACK 0 -#define ATTRIBUTE_HIDDEN __attribute__((visibility("hidden"))) #endif #if !defined(ATTRIBUTE_PACKED) #define ATTRIBUTE_PACKED #define PRAGMA_PACK 1 #endif +//@} -#if !defined(ATTRIBUTE_HIDDEN) -#define ATTRIBUTE_HIDDEN -#endif - +// Generic helper definitions for inline function support +//@{ #ifdef _MSC_VER #define ATTRIBUTE_FORCEINLINE __forceinline #elif defined(__GNUC__) @@ -59,6 +57,27 @@ #else #define ATTRIBUTE_FORCEINLINE inline #endif +//@} + +// Generic helper definitions for shared library support +//@{ +#if defined _WIN32 || defined __CYGWIN__ +#define ATTRIBUTE_DLL_IMPORT __declspec(dllimport) +#define ATTRIBUTE_DLL_EXPORT __declspec(dllexport) +#define ATTRIBUTE_DLL_LOCAL +#else +#if __GNUC__ >= 4 +#define ATTRIBUTE_DLL_IMPORT __attribute__ ((visibility ("default"))) +#define ATTRIBUTE_DLL_EXPORT __attribute__ ((visibility ("default"))) +#define ATTRIBUTE_DLL_LOCAL __attribute__ ((visibility ("hidden"))) +#else +#define ATTRIBUTE_DLL_IMPORT +#define ATTRIBUTE_DLL_EXPORT +#define ATTRIBUTE_DLL_LOCAL +#endif +#endif +#define ATTRIBUTE_HIDDEN ATTRIBUTE_DLL_LOCAL // Fallback to old +//@} // Hardware specific device context interface #define ADDON_HARDWARE_CONTEXT void* @@ -75,9 +94,11 @@ extern "C" #endif /* __cplusplus */ //============================================================================ - /// @ingroup cpp_kodi_addon_addonbase - /// @brief Return value of functions in @ref cpp_kodi_addon_addonbase "kodi::addon::CAddonBase" - /// and associated classes. + /// @ingroup cpp_kodi_addon_addonbase_Defs + /// @defgroup cpp_kodi_addon_addonbase_Defs_ADDON_STATUS enum ADDON_STATUS + /// @brief <b>Return value of functions in @ref cpp_kodi_addon_addonbase "kodi::addon::CAddonBase" + /// and associated classes</b>\n + /// With this Kodi can do any follow-up work or add-on e.g. declare it as defective. /// ///@{ typedef enum ADDON_STATUS @@ -211,7 +232,7 @@ extern "C" typedef struct KodiToAddonFuncTable_Addon { void (*destroy)(); - ADDON_STATUS (*get_status)(); + ADDON_STATUS (*get_status)(); // TODO unused remove by next min version increase ADDON_STATUS(*create_instance) (int instanceType, const char* instanceID, diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h index 97510f7cb6..dcb004c209 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_AUDIO_ENGINE_H #define C_API_AUDIO_ENGINE_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h index 70f9400ebb..4290cb98aa 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_FILESYSTEM_H #define C_API_FILESYSTEM_H @@ -106,16 +104,15 @@ extern "C" /// @brief **CURL message types**\n /// Used on kodi::vfs::CFile::CURLAddOption(). /// - //@{ + ///@{ typedef enum CURLOptiontype { /// @brief Set a general option. ADDON_CURL_OPTION_OPTION, - /// @brief Set a protocol option. - /// + /// @brief Set a protocol option.\n + ///\n /// The following names for *ADDON_CURL_OPTION_PROTOCOL* are possible: - /// /// | Option name | Description /// |------------------------------------:|:-------------------------------- /// | <b>`accept-charset`</b> | Set the "accept-charset" header @@ -140,7 +137,7 @@ extern "C" /// @brief Add a Header ADDON_CURL_OPTION_HEADER } CURLOptiontype; - //@} + ///@} //---------------------------------------------------------------------------- //============================================================================ @@ -151,7 +148,7 @@ extern "C" /// /// Used on kodi::vfs::CFile::GetPropertyValue() and kodi::vfs::CFile::GetPropertyValues(). /// - //@{ + ///@{ typedef enum FilePropertyTypes { /// @brief Get protocol response line. @@ -167,7 +164,7 @@ extern "C" /// @brief Get file effective URL (last one if redirected). ADDON_FILE_PROPERTY_EFFECTIVE_URL } FilePropertyTypes; - //@} + ///@} //---------------------------------------------------------------------------- //}}} diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h index 12afd02b70..8518a96e54 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GENERAL_H #define C_API_GENERAL_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h index 84fd8227d1..46de2629d2 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_BUTTON_H #define C_API_GUI_CONTROLS_BUTTON_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h index ca38b273fc..571c7ce43c 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_EDIT_H #define C_API_GUI_CONTROLS_EDIT_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h index fea014b623..dab4574712 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_FADE_LABEL_H #define C_API_GUI_CONTROLS_FADE_LABEL_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h index 4a46e6da5b..257dd678fd 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_IMAGE_H #define C_API_GUI_CONTROLS_IMAGE_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h index d8a9fe4a58..92af25ca8d 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_LABEL_H #define C_API_GUI_CONTROLS_LABEL_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h index 88638e0859..4f211fdf62 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_PROGRESS_H #define C_API_GUI_CONTROLS_PROGRESS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h index a672d9516a..d652e6727f 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_RADIO_BUTTON_H #define C_API_GUI_CONTROLS_RADIO_BUTTON_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h index d4053a6411..792a8d6df5 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_RENDERING_H #define C_API_GUI_CONTROLS_RENDERING_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h index 2cbc972bdd..42992527cd 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_SETTINGS_SLIDER_H #define C_API_GUI_CONTROLS_SETTINGS_SLIDER_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h index 0a67208c7b..67c6c2fc33 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_SLIDER_H #define C_API_GUI_CONTROLS_SLIDER_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h index d5e5c861a3..0373636afa 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_SPIN_H #define C_API_GUI_CONTROLS_SPIN_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h index 276d04cb28..333689e0b2 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_CONTROLS_TEXT_BOX_H #define C_API_GUI_CONTROLS_TEXT_BOX_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h index ec60bc2843..f0ea9a2e70 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DEFINITIONS_H #define C_API_GUI_DEFINITIONS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h index 8bb5370c28..130d831e5b 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_CONTEXT_MENU_H #define C_API_GUI_DIALOGS_CONTEXT_MENU_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h index e53588fc38..0992d5c228 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H #define C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h index 7ae4facc5f..ef3945b274 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_FILEBROWSER_H #define C_API_GUI_DIALOGS_FILEBROWSER_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h index fc3c34cecf..f84dc204fe 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_KEYBOARD_H #define C_API_GUI_DIALOGS_KEYBOARD_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h index df23cd74a4..08aaf25d86 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_NUMERIC_H #define C_API_GUI_DIALOGS_NUMERIC_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h index 9f37051de9..45fe0fc458 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_OK_H #define C_API_GUI_DIALOGS_OK_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h index f1c8972dec..60a003ab7b 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_PROGRESS_H #define C_API_GUI_DIALOGS_PROGRESS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h index 41ab82f9a2..79635d775e 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_SELECT_H #define C_API_GUI_DIALOGS_SELECT_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h index eb38b0be7f..4a1cfe687c 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_TEXT_VIEWER_H #define C_API_GUI_DIALOGS_TEXT_VIEWER_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h index 01ed80622f..8558acbc46 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_DIALOGS_YES_NO_H #define C_API_GUI_DIALOGS_YES_NO_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h index d0d256c55e..676986725f 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_GENERAL_H #define C_API_GUI_GENERAL_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h index 274f3d9227..5d6258750b 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_ACTION_IDS_H #define C_API_GUI_ACTION_IDS_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h index f0c4dc73d3..d2120ac355 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_LIST_ITEM_H #define C_API_GUI_LIST_ITEM_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h index 0f844f5e9d..d7181c0538 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_GUI_WINDOW_H #define C_API_GUI_WINDOW_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h index 88d5231514..8bd987be60 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_NETWORK_H #define C_API_NETWORK_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h index 568a2fd5ee..09d8c8c91e 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h @@ -6,8 +6,6 @@ * See LICENSES/README.md for more information. */ -#pragma once - #ifndef C_API_PLATFORM_ANDROID_H #define C_API_PLATFORM_ANDROID_H diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h index 3066b3c2e9..10fa6efa21 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h @@ -451,7 +451,7 @@ public: /// @param[in] item List item to add /// @param[in] itemPosition [opt] The position for item, default is on end /// - void AddListItem(std::shared_ptr<CListItem> item, int itemPosition = -1) + void AddListItem(const std::shared_ptr<CListItem>& item, int itemPosition = -1) { m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle, itemPosition); @@ -465,7 +465,7 @@ public: /// @param[in] item List item to add /// @param[in] itemPosition [opt] The position for item, default is on end /// - void AddListItem(const std::string item, int itemPosition = -1) + void AddListItem(const std::string& item, int itemPosition = -1) { m_interface->kodi_gui->window->add_list_item( m_interface->kodiBase, m_controlHandle, @@ -492,7 +492,7 @@ public: /// /// @param[in] item List item control class to remove /// - void RemoveListItem(std::shared_ptr<CListItem> item) + void RemoveListItem(const std::shared_ptr<CListItem>& item) { m_interface->kodi_gui->window->remove_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle); diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h index 42a86f39a4..dc89740a02 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h @@ -33,7 +33,7 @@ namespace dialogs /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. /// -/// It has the header \ref TextViewer.h "#include <kodi/gui/dialogs/TextViewer.h>" +/// It has the header @ref TextViewer.h "#include <kodi/gui/dialogs/TextViewer.h>" /// be included to enjoy it. /// namespace TextViewer diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h index 9b16eaa255..5d4e384187 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h @@ -10,8 +10,9 @@ #ifdef __cplusplus -#include "system_egl.h" +#if defined(WIN32) && defined(HAS_ANGLE) +#include <EGL/egl.h> #include <EGL/eglext.h> #include <angle_gl.h> #include <d3d11.h> @@ -387,4 +388,8 @@ using CRenderHelper = gl::CGLonDX; } /* namespace gui */ } /* namespace kodi */ +#else /* defined(WIN32) && defined(HAS_ANGLE) */ +#pragma message ( "WARNING: GLonDX.h only be available on Windows by use of Angle as depend!" ) +#endif /* defined(WIN32) && defined(HAS_ANGLE) */ + #endif /* __cplusplus */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h index dabe101cb0..b08f8989b9 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h @@ -67,7 +67,7 @@ inline std::shared_ptr<IRenderHelper> ATTRIBUTE_HIDDEN GetRenderHelper() if (static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper) return static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper; - const std::shared_ptr<kodi::gui::IRenderHelper> renderHelper(new CRenderHelper()); + std::shared_ptr<kodi::gui::IRenderHelper> renderHelper(new CRenderHelper()); if (!renderHelper->Init()) return nullptr; diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h index e632f5affe..e5c52d78fb 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/versions.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h @@ -8,6 +8,9 @@ #pragma once +#ifndef KODI_VERSIONS_H +#define KODI_VERSIONS_H + #include <string.h> #define STR_HELPER(x) #x @@ -34,7 +37,7 @@ // because cmake uses this area in this form to perform its addon dependency // check. // clang-format off -#define ADDON_GLOBAL_VERSION_MAIN "1.2.4" +#define ADDON_GLOBAL_VERSION_MAIN "1.3.0" #define ADDON_GLOBAL_VERSION_MAIN_MIN "1.2.0" #define ADDON_GLOBAL_VERSION_MAIN_XML_ID "kodi.binary.global.main" #define ADDON_GLOBAL_VERSION_MAIN_DEPENDS "AddonBase.h" \ @@ -104,10 +107,21 @@ #define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID "kodi.binary.instance.imagedecoder" #define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "addon-instance/ImageDecoder.h" -#define ADDON_INSTANCE_VERSION_INPUTSTREAM "2.3.4" -#define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "2.3.4" +#define ADDON_INSTANCE_VERSION_INPUTSTREAM "3.0.0" +#define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "3.0.0" #define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" -#define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h" +#define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "c-api/addon-instance/inputstream.h" \ + "c-api/addon-instance/inputstream/demux_packet.h" \ + "c-api/addon-instance/inputstream/stream_codec.h" \ + "c-api/addon-instance/inputstream/stream_constants.h" \ + "c-api/addon-instance/inputstream/stream_crypto.h" \ + "c-api/addon-instance/inputstream/timing_constants.h" \ + "addon-instance/Inputstream.h" \ + "addon-instance/inputstream/DemuxPacket.h" \ + "addon-instance/inputstream/StreamCodec.h" \ + "addon-instance/inputstream/StreamConstants.h" \ + "addon-instance/inputstream/StreamCrypto.h" \ + "addon-instance/inputstream/TimingConstants.h" #define ADDON_INSTANCE_VERSION_PERIPHERAL "2.0.0" #define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "2.0.0" @@ -115,8 +129,8 @@ #define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \ "addon-instance/PeripheralUtils.h" -#define ADDON_INSTANCE_VERSION_PVR "7.0.1" -#define ADDON_INSTANCE_VERSION_PVR_MIN "7.0.0" +#define ADDON_INSTANCE_VERSION_PVR "7.0.2" +#define ADDON_INSTANCE_VERSION_PVR_MIN "7.0.2" #define ADDON_INSTANCE_VERSION_PVR_XML_ID "kodi.binary.instance.pvr" #define ADDON_INSTANCE_VERSION_PVR_DEPENDS "c-api/addon-instance/pvr.h" \ "c-api/addon-instance/pvr/pvr_channel_groups.h" \ @@ -158,24 +172,30 @@ #define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "addon-instance/Visualization.h" \ "c-api/addon-instance/visualization.h" -#define ADDON_INSTANCE_VERSION_VIDEOCODEC "1.0.4" -#define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "1.0.4" +#define ADDON_INSTANCE_VERSION_VIDEOCODEC "2.0.0" +#define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "2.0.0" #define ADDON_INSTANCE_VERSION_VIDEOCODEC_XML_ID "kodi.binary.instance.videocodec" -#define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "addon-instance/VideoCodec.h" \ - "StreamCodec.h" \ - "StreamCrypto.h" +#define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "c-api/addon-instance/video_codec.h" \ + "c-api/addon-instance/inputstream/stream_codec.h" \ + "c-api/addon-instance/inputstream/stream_crypto.h" \ + "addon-instance/VideoCodec.h" \ + "addon-instance/inputstream/StreamCodec.h" \ + "addon-instance/inputstream/StreamCrypto.h" \ // clang-format on //============================================================================== -/// -/// @ingroup cpp_kodi_addon_addonbase -/// The currently available instance types for Kodi add-ons +/// @ingroup cpp_kodi_addon_addonbase_Defs +/// @defgroup cpp_kodi_addon_addonbase_Defs_ADDON_TYPE enum ADDON_TYPE +/// **The currently available instance types for Kodi add-ons**\n +/// This identifies the associated API part on the interface in Kodi and in the +/// addon. /// /// \internal /// @note For add of new types take a new number on end. To change /// existing numbers can be make problems on already compiled add-ons. /// \endinternal /// +///@{ typedef enum ADDON_TYPE { /* addon global parts */ @@ -192,39 +212,40 @@ typedef enum ADDON_TYPE /* addon type instances */ - /// Audio decoder instance, see \ref cpp_kodi_addon_audiodecoder "kodi::addon::CInstanceAudioDecoder" + /// Audio decoder instance, see @ref cpp_kodi_addon_audiodecoder "kodi::addon::CInstanceAudioDecoder" ADDON_INSTANCE_AUDIODECODER = 102, - /// Audio encoder instance, see \ref cpp_kodi_addon_audioencoder "kodi::addon::CInstanceAudioEncoder" + /// Audio encoder instance, see @ref cpp_kodi_addon_audioencoder "kodi::addon::CInstanceAudioEncoder" ADDON_INSTANCE_AUDIOENCODER = 103, - /// Game instance, see \ref cpp_kodi_addon_game "kodi::addon::CInstanceGame" + /// Game instance, see @ref cpp_kodi_addon_game "kodi::addon::CInstanceGame" ADDON_INSTANCE_GAME = 104, - /// Input stream instance, see \ref cpp_kodi_addon_inputstream "kodi::addon::CInstanceInputStream" + /// Input stream instance, see @ref cpp_kodi_addon_inputstream "kodi::addon::CInstanceInputStream" ADDON_INSTANCE_INPUTSTREAM = 105, - /// Peripheral instance, see \ref cpp_kodi_addon_peripheral "kodi::addon::CInstancePeripheral" + /// Peripheral instance, see @ref cpp_kodi_addon_peripheral "kodi::addon::CInstancePeripheral" ADDON_INSTANCE_PERIPHERAL = 106, - /// Game instance, see \ref cpp_kodi_addon_pvr "kodi::addon::CInstancePVRClient" + /// Game instance, see @ref cpp_kodi_addon_pvr "kodi::addon::CInstancePVRClient" ADDON_INSTANCE_PVR = 107, - /// PVR client instance, see \ref cpp_kodi_addon_screensaver "kodi::addon::CInstanceScreensaver" + /// PVR client instance, see @ref cpp_kodi_addon_screensaver "kodi::addon::CInstanceScreensaver" ADDON_INSTANCE_SCREENSAVER = 108, - /// Music visualization instance, see \ref cpp_kodi_addon_visualization "kodi::addon::CInstanceVisualization" + /// Music visualization instance, see @ref cpp_kodi_addon_visualization "kodi::addon::CInstanceVisualization" ADDON_INSTANCE_VISUALIZATION = 109, - /// Virtual Filesystem (VFS) instance, see \ref cpp_kodi_addon_vfs "kodi::addon::CInstanceVFS" + /// Virtual Filesystem (VFS) instance, see @ref cpp_kodi_addon_vfs "kodi::addon::CInstanceVFS" ADDON_INSTANCE_VFS = 110, - /// Image Decoder instance, see \ref cpp_kodi_addon_imagedecoder "kodi::addon::CInstanceImageDecoder" + /// Image Decoder instance, see @ref cpp_kodi_addon_imagedecoder "kodi::addon::CInstanceImageDecoder" ADDON_INSTANCE_IMAGEDECODER = 111, - /// Video Decoder instance, see \ref cpp_kodi_addon_videocodec "kodi::addon::CInstanceVideoCodec" + /// Video Decoder instance, see @ref cpp_kodi_addon_videocodec "kodi::addon::CInstanceVideoCodec" ADDON_INSTANCE_VIDEOCODEC = 112, } ADDON_TYPE; +///@} //------------------------------------------------------------------------------ #ifdef __cplusplus @@ -490,3 +511,5 @@ inline int GetTypeId(const char* name) } /* namespace kodi */ } /* extern "C" */ #endif + +#endif /* !KODI_VERSIONS_H */ diff --git a/xbmc/addons/settings/AddonSettings.cpp b/xbmc/addons/settings/AddonSettings.cpp index 92a703c85f..85464fe2df 100644 --- a/xbmc/addons/settings/AddonSettings.cpp +++ b/xbmc/addons/settings/AddonSettings.cpp @@ -43,13 +43,18 @@ static const std::string OldSettingValuesSeparator = "|"; static const int UnknownSettingLabelIdStart = 100000; -bool InfoBool(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool InfoBool(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetGUI()->GetInfoManager().EvaluateBool(value); } template<class TSetting> -SettingPtr InitializeFromOldSettingWithoutDefinition(ADDON::CAddonSettings& settings, const std::string& settingId, typename TSetting::Value defaultValue) +SettingPtr InitializeFromOldSettingWithoutDefinition(ADDON::CAddonSettings& settings, + const std::string& settingId, + const typename TSetting::Value& defaultValue) { std::shared_ptr<TSetting> setting = std::make_shared<TSetting>(settingId, settings.GetSettingsManager()); setting->SetLevel(SettingLevel::Internal); @@ -60,7 +65,10 @@ SettingPtr InitializeFromOldSettingWithoutDefinition(ADDON::CAddonSettings& sett } template<> -SettingPtr InitializeFromOldSettingWithoutDefinition<CSettingString>(ADDON::CAddonSettings& settings, const std::string& settingId, typename CSettingString::Value defaultValue) +SettingPtr InitializeFromOldSettingWithoutDefinition<CSettingString>( + ADDON::CAddonSettings& settings, + const std::string& settingId, + const typename CSettingString::Value& defaultValue) { std::shared_ptr<CSettingString> setting = std::make_shared<CSettingString>(settingId, settings.GetSettingsManager()); setting->SetLevel(SettingLevel::Internal); @@ -75,7 +83,7 @@ template<class TSetting> SettingPtr AddSettingWithoutDefinition(ADDON::CAddonSettings& settings, const std::string& settingId, typename TSetting::Value defaultValue, - Logger logger) + const Logger& logger) { if (settingId.empty()) return nullptr; @@ -131,7 +139,7 @@ SettingPtr AddSettingWithoutDefinition(ADDON::CAddonSettings& settings, namespace ADDON { -CAddonSettings::CAddonSettings(std::shared_ptr<const IAddon> addon) +CAddonSettings::CAddonSettings(const std::shared_ptr<const IAddon>& addon) : CSettingsBase(), m_addon(addon), m_addonId(addon->ID()), @@ -151,7 +159,7 @@ std::shared_ptr<CSetting> CAddonSettings::CreateSetting(const std::string &setti return CSettingCreator::CreateSetting(settingType, settingId, settingsManager); } -void CAddonSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CAddonSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { std::string actionData; bool closeDialog = false; @@ -261,7 +269,7 @@ bool CAddonSettings::Load(const CXBMCTinyXML& doc) // check if this really is a category with setting elements if (category->FirstChild() && category->FirstChild()->Type() == CXBMCTinyXML::TINYXML_ELEMENT) { - const auto categoryId = category->ValueStr(); + const auto& categoryId = category->ValueStr(); auto setting = category->FirstChild(); while (setting != nullptr) { @@ -435,7 +443,10 @@ bool CAddonSettings::ParseSettingVersion(const CXBMCTinyXML& doc, uint32_t& vers return true; } -std::shared_ptr<CSettingGroup> CAddonSettings::ParseOldSettingElement(const TiXmlElement* categoryElement, std::shared_ptr<CSettingCategory> category, std::set<std::string>& settingIds) +std::shared_ptr<CSettingGroup> CAddonSettings::ParseOldSettingElement( + const TiXmlElement* categoryElement, + const std::shared_ptr<CSettingCategory>& category, + std::set<std::string>& settingIds) { // build a vector of settings from the same category std::vector<std::shared_ptr<const CSetting>> categorySettings; @@ -548,11 +559,9 @@ std::shared_ptr<CSettingGroup> CAddonSettings::ParseOldSettingElement(const TiXm { // find the last non-subsetting in the current group and use that as the parent setting const auto groupSettings = group->GetSettings(); - const auto parentSetting = std::find_if(groupSettings.crbegin(), groupSettings.crend(), - [](SettingConstPtr setting) - { - return setting->GetParent().empty(); - }); + const auto parentSetting = std::find_if( + groupSettings.crbegin(), groupSettings.crend(), + [](const SettingConstPtr& setting) { return setting->GetParent().empty(); }); if (parentSetting != groupSettings.crend()) { @@ -708,7 +717,9 @@ bool CAddonSettings::InitializeFromOldSettingDefinitions(const CXBMCTinyXML& doc return true; } -SettingPtr CAddonSettings::InitializeFromOldSettingAction(std::string settingId, const TiXmlElement *settingElement, const std::string& defaultValue) +SettingPtr CAddonSettings::InitializeFromOldSettingAction(const std::string& settingId, + const TiXmlElement* settingElement, + const std::string& defaultValue) { // parse the action attribute std::string action = XMLUtils::GetAttribute(settingElement, "action"); @@ -1326,7 +1337,9 @@ bool CAddonSettings::LoadOldSettingValues(const CXBMCTinyXML& doc, std::map<std: return !settings.empty(); } -bool CAddonSettings::ParseOldLabel(const TiXmlElement* element, const std::string settingId, int& labelId) +bool CAddonSettings::ParseOldLabel(const TiXmlElement* element, + const std::string& settingId, + int& labelId) { labelId = -1; if (element == nullptr) @@ -1357,7 +1370,10 @@ bool CAddonSettings::ParseOldLabel(const TiXmlElement* element, const std::strin return parsed; } -bool CAddonSettings::ParseOldCondition(std::shared_ptr<const CSetting> setting, const std::vector<std::shared_ptr<const CSetting>> settings, const std::string& condition, CSettingDependency& dependeny) const +bool CAddonSettings::ParseOldCondition(const std::shared_ptr<const CSetting>& setting, + const std::vector<std::shared_ptr<const CSetting>>& settings, + const std::string& condition, + CSettingDependency& dependeny) const { if (setting == nullptr) return false; @@ -1366,12 +1382,13 @@ bool CAddonSettings::ParseOldCondition(std::shared_ptr<const CSetting> setting, return true; // find the index of the setting in the list of all settings of the category - auto settingIt = std::find_if(settings.cbegin(), settings.cend(), [setting](SettingConstPtr otherSetting) { - if (otherSetting == nullptr) - return false; + auto settingIt = std::find_if(settings.cbegin(), settings.cend(), + [setting](const SettingConstPtr& otherSetting) { + if (otherSetting == nullptr) + return false; - return setting->GetId() == otherSetting->GetId(); - }); + return setting->GetId() == otherSetting->GetId(); + }); if (settingIt == settings.cend()) { m_logger->warn("failed to parse old setting conditions \"{}\" for \"{}\"", condition, setting->GetId()); @@ -1500,7 +1517,10 @@ bool CAddonSettings::ParseOldConditionExpression(std::string str, ConditionExpre return true; } -void CAddonSettings::FileEnumSettingOptionsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CAddonSettings::FileEnumSettingOptionsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { if (setting == nullptr) return; @@ -1519,7 +1539,7 @@ void CAddonSettings::FileEnumSettingOptionsFiller(std::shared_ptr<const CSetting XFILE::CDirectory::GetDirectory(settingPath->GetSources().front(), items, masking, XFILE::DIR_FLAG_NO_FILE_DIRS); // process the matching files/directories - for (auto item : items) + for (const auto& item : items) { if ((masking == "/" && item->m_bIsFolder) || !item->m_bIsFolder) { diff --git a/xbmc/addons/settings/AddonSettings.h b/xbmc/addons/settings/AddonSettings.h index 9676afaede..d7d149d561 100644 --- a/xbmc/addons/settings/AddonSettings.h +++ b/xbmc/addons/settings/AddonSettings.h @@ -31,7 +31,7 @@ namespace ADDON class CAddonSettings : public CSettingsBase, public CSettingCreator, public CSettingControlCreator, public ISettingCallback { public: - explicit CAddonSettings(std::shared_ptr<const IAddon> addon); + explicit CAddonSettings(const std::shared_ptr<const IAddon>& addon); ~CAddonSettings() override = default; // specialization of CSettingsBase @@ -45,7 +45,7 @@ namespace ADDON std::shared_ptr<CSetting> CreateSetting(const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager = NULL) const override; // implementation of ISettingCallback - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; std::shared_ptr<const IAddon> GetAddon() { return m_addon.lock(); } @@ -76,12 +76,17 @@ namespace ADDON bool ParseSettingVersion(const CXBMCTinyXML& doc, uint32_t& version) const; - std::shared_ptr<CSettingGroup> ParseOldSettingElement(const TiXmlElement *categoryElement, std::shared_ptr<CSettingCategory> category, std::set<std::string>& settingIds); + std::shared_ptr<CSettingGroup> ParseOldSettingElement( + const TiXmlElement* categoryElement, + const std::shared_ptr<CSettingCategory>& category, + std::set<std::string>& settingIds); std::shared_ptr<CSettingCategory> ParseOldCategoryElement(uint32_t &categoryId, const TiXmlElement * categoryElement, std::set<std::string>& settingIds); bool InitializeFromOldSettingDefinitions(const CXBMCTinyXML& doc); - std::shared_ptr<CSetting> InitializeFromOldSettingAction(std::string settingId, const TiXmlElement *settingElement, const std::string& defaultValue); + std::shared_ptr<CSetting> InitializeFromOldSettingAction(const std::string& settingId, + const TiXmlElement* settingElement, + const std::string& defaultValue); std::shared_ptr<CSetting> InitializeFromOldSettingLabel(); std::shared_ptr<CSetting> InitializeFromOldSettingBool(const std::string& settingId, const TiXmlElement *settingElement, const std::string& defaultValue); std::shared_ptr<CSetting> InitializeFromOldSettingTextIpAddress(const std::string& settingId, const std::string& settingType, const TiXmlElement *settingElement, const std::string& defaultValue, const int settingLabel); @@ -107,11 +112,17 @@ namespace ADDON std::string m_value; }; - bool ParseOldLabel(const TiXmlElement* element, const std::string settingId, int& labelId); - bool ParseOldCondition(std::shared_ptr<const CSetting> setting, const std::vector<std::shared_ptr<const CSetting>> settings, const std::string& condition, CSettingDependency& dependeny) const; + bool ParseOldLabel(const TiXmlElement* element, const std::string& settingId, int& labelId); + bool ParseOldCondition(const std::shared_ptr<const CSetting>& setting, + const std::vector<std::shared_ptr<const CSetting>>& settings, + const std::string& condition, + CSettingDependency& dependeny) const; static bool ParseOldConditionExpression(std::string str, ConditionExpression& expression); - static void FileEnumSettingOptionsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); + static void FileEnumSettingOptionsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); std::weak_ptr<const IAddon> m_addon; // store these values so that we don't always have to access the weak pointer diff --git a/xbmc/addons/test/TestAddonDatabase.cpp b/xbmc/addons/test/TestAddonDatabase.cpp index 693549af22..289a6af959 100644 --- a/xbmc/addons/test/TestAddonDatabase.cpp +++ b/xbmc/addons/test/TestAddonDatabase.cpp @@ -12,6 +12,7 @@ #include "settings/AdvancedSettings.h" #include <set> +#include <utility> #include <gtest/gtest.h> @@ -46,10 +47,10 @@ protected: database.UpdateRepositoryContent("repository.b", AddonVersion("1.0.0"), "test", addons); } - void CreateAddon(std::vector<AddonInfoPtr>& addons, std::string id, std::string version) + void CreateAddon(std::vector<AddonInfoPtr>& addons, std::string id, const std::string& version) { CAddonInfoBuilder::CFromDB builder; - builder.SetId(id); + builder.SetId(std::move(id)); builder.SetVersion(AddonVersion(version)); addons.push_back(builder.get()); } diff --git a/xbmc/cdrip/Encoder.cpp b/xbmc/cdrip/Encoder.cpp index a02d486d88..6e8355906b 100644 --- a/xbmc/cdrip/Encoder.cpp +++ b/xbmc/cdrip/Encoder.cpp @@ -12,12 +12,13 @@ #include "utils/log.h" #include <string.h> +#include <utility> CEncoder::CEncoder(std::shared_ptr<IEncoder> encoder) { m_file = NULL; m_dwWriteBufferPointer = 0; - m_impl = encoder; + m_impl = std::move(encoder); } CEncoder::~CEncoder() diff --git a/xbmc/cores/AudioEngine/AESinkFactory.cpp b/xbmc/cores/AudioEngine/AESinkFactory.cpp index 5356359c4a..d86a83eb84 100644 --- a/xbmc/cores/AudioEngine/AESinkFactory.cpp +++ b/xbmc/cores/AudioEngine/AESinkFactory.cpp @@ -19,7 +19,7 @@ using namespace AE; std::map<std::string, AESinkRegEntry> CAESinkFactory::m_AESinkRegEntry; -void CAESinkFactory::RegisterSink(AESinkRegEntry regEntry) +void CAESinkFactory::RegisterSink(const AESinkRegEntry& regEntry) { m_AESinkRegEntry[regEntry.sinkName] = regEntry; @@ -46,7 +46,7 @@ void CAESinkFactory::ParseDevice(std::string &device, std::string &driver) { driver = device.substr(0, pos); - for (auto reg : m_AESinkRegEntry) + for (const auto& reg : m_AESinkRegEntry) { if (!StringUtils::EqualsNoCase(driver, reg.second.sinkName)) continue; @@ -70,7 +70,7 @@ IAESink *CAESinkFactory::Create(std::string &device, AEAudioFormat &desiredForma IAESink *sink; std::string tmpDevice = device; - for (auto reg : m_AESinkRegEntry) + for (const auto& reg : m_AESinkRegEntry) { if (driver != reg.second.sinkName) continue; @@ -85,11 +85,13 @@ IAESink *CAESinkFactory::Create(std::string &device, AEAudioFormat &desiredForma return nullptr; } -void CAESinkFactory::EnumerateEx(std::vector<AESinkInfo>& list, bool force, std::string driver) +void CAESinkFactory::EnumerateEx(std::vector<AESinkInfo>& list, + bool force, + const std::string& driver) { AESinkInfo info; - for(auto reg : m_AESinkRegEntry) + for (const auto& reg : m_AESinkRegEntry) { if (!driver.empty() && driver != reg.second.sinkName) continue; @@ -104,7 +106,7 @@ void CAESinkFactory::EnumerateEx(std::vector<AESinkInfo>& list, bool force, std: void CAESinkFactory::Cleanup() { - for (auto reg : m_AESinkRegEntry) + for (const auto& reg : m_AESinkRegEntry) { if (reg.second.cleanupFunc) reg.second.cleanupFunc(); diff --git a/xbmc/cores/AudioEngine/AESinkFactory.h b/xbmc/cores/AudioEngine/AESinkFactory.h index 2c5d62177a..e8e069f3eb 100644 --- a/xbmc/cores/AudioEngine/AESinkFactory.h +++ b/xbmc/cores/AudioEngine/AESinkFactory.h @@ -42,13 +42,13 @@ struct AESinkRegEntry class CAESinkFactory { public: - static void RegisterSink(AESinkRegEntry regEntry); + static void RegisterSink(const AESinkRegEntry& regEntry); static void ClearSinks(); static bool HasSinks(); static void ParseDevice(std::string &device, std::string &driver); static IAESink *Create(std::string &device, AEAudioFormat &desiredFormat); - static void EnumerateEx(std::vector<AESinkInfo>& list, bool force, std::string driver); + static void EnumerateEx(std::vector<AESinkInfo>& list, bool force, const std::string& driver); static void Cleanup(); protected: diff --git a/xbmc/cores/AudioEngine/CMakeLists.txt b/xbmc/cores/AudioEngine/CMakeLists.txt index eb34be83a3..e6be635ea8 100644 --- a/xbmc/cores/AudioEngine/CMakeLists.txt +++ b/xbmc/cores/AudioEngine/CMakeLists.txt @@ -52,7 +52,7 @@ if(ALSA_FOUND) list(APPEND HEADERS Sinks/AESinkALSA.h Utils/AEELDParser.h) - if(NOT CORE_PLATFORM_NAME_LC STREQUAL x11) + if(NOT "x11" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES Sinks/alsa/ALSAHControlMonitor.cpp) list(APPEND HEADERS Sinks/alsa/ALSAHControlMonitor.h) endif() @@ -114,10 +114,10 @@ endif() if(CORE_SYSTEM_NAME STREQUAL darwin_embedded) list(APPEND SOURCES Sinks/darwin/CoreAudioHelpers.cpp) list(APPEND HEADERS Sinks/darwin/CoreAudioHelpers.h) - if(CORE_PLATFORM_NAME_LC STREQUAL ios) + if("ios" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES Sinks/AESinkDARWINIOS.mm) list(APPEND HEADERS Sinks/AESinkDARWINIOS.h) - elseif(CORE_PLATFORM_NAME_LC STREQUAL tvos) + elseif("tvos" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES Sinks/AESinkDARWINTVOS.mm) list(APPEND HEADERS Sinks/AESinkDARWINTVOS.h) endif() diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp index d9def8434c..f839fc44bc 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp @@ -2891,7 +2891,7 @@ void CActiveAE::DeviceChange() m_controlPort.SendOutMessage(CActiveAEControlProtocol::DEVICECHANGE); } -void CActiveAE::DeviceCountChange(std::string driver) +void CActiveAE::DeviceCountChange(const std::string& driver) { const char* name = driver.c_str(); m_controlPort.SendOutMessage(CActiveAEControlProtocol::DEVICECOUNTCHANGE, name, diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h index 252712c113..372db894a0 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h @@ -8,19 +8,18 @@ #pragma once -#include <list> -#include <string> -#include <vector> - -#include "threads/Thread.h" - #include "ActiveAESink.h" -#include "cores/AudioEngine/Interfaces/AEStream.h" -#include "cores/AudioEngine/Interfaces/AESound.h" #include "cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h" - +#include "cores/AudioEngine/Interfaces/AESound.h" +#include "cores/AudioEngine/Interfaces/AEStream.h" #include "guilib/DispResource.h" +#include "threads/Thread.h" + +#include <list> #include <queue> +#include <string> +#include <utility> +#include <vector> // ffmpeg extern "C" { @@ -66,7 +65,8 @@ struct AudioSettings class CActiveAEControlProtocol : public Protocol { public: - CActiveAEControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + CActiveAEControlProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { INIT = 0, @@ -105,7 +105,8 @@ public: class CActiveAEDataProtocol : public Protocol { public: - CActiveAEDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + CActiveAEDataProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { NEWSOUND = 0, @@ -255,7 +256,7 @@ public: bool IsSettingVisible(const std::string &settingId) override; void KeepConfiguration(unsigned int millis) override; void DeviceChange() override; - void DeviceCountChange(std::string driver) override; + void DeviceCountChange(const std::string& driver) override; bool GetCurrentSinkFormat(AEAudioFormat &SinkFormat) override; void RegisterAudioCallback(IAudioCallback* pCallback) override; diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.cpp index b3e7c90940..f9c4880c62 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.cpp @@ -73,29 +73,34 @@ CActiveAESettings::~CActiveAESettings() m_instance = nullptr; } -void CActiveAESettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CActiveAESettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { CSingleLock lock(m_cs); m_instance->m_audioEngine.OnSettingsChange(); } -void CActiveAESettings::SettingOptionsAudioDevicesFiller(SettingConstPtr setting, - std::vector<StringSettingOption> &list, - std::string ¤t, void *data) +void CActiveAESettings::SettingOptionsAudioDevicesFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { SettingOptionsAudioDevicesFillerGeneral(setting, list, current, false); } -void CActiveAESettings::SettingOptionsAudioDevicesPassthroughFiller(SettingConstPtr setting, - std::vector<StringSettingOption> &list, - std::string ¤t, void *data) +void CActiveAESettings::SettingOptionsAudioDevicesPassthroughFiller( + const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { SettingOptionsAudioDevicesFillerGeneral(setting, list, current, true); } -void CActiveAESettings::SettingOptionsAudioQualityLevelsFiller(SettingConstPtr setting, - std::vector<IntegerSettingOption> &list, - int ¤t, void *data) +void CActiveAESettings::SettingOptionsAudioQualityLevelsFiller( + const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CSingleLock lock(m_instance->m_cs); @@ -111,9 +116,11 @@ void CActiveAESettings::SettingOptionsAudioQualityLevelsFiller(SettingConstPtr s list.emplace_back(g_localizeStrings.Get(38010), AE_QUALITY_GPU); } -void CActiveAESettings::SettingOptionsAudioStreamsilenceFiller(SettingConstPtr setting, - std::vector<IntegerSettingOption> &list, - int ¤t, void *data) +void CActiveAESettings::SettingOptionsAudioStreamsilenceFiller( + const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CSingleLock lock(m_instance->m_cs); @@ -130,8 +137,10 @@ void CActiveAESettings::SettingOptionsAudioStreamsilenceFiller(SettingConstPtr s } } -bool CActiveAESettings::IsSettingVisible(const std::string & condition, const std::string & value, - SettingConstPtr setting, void * data) +bool CActiveAESettings::IsSettingVisible(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL || value.empty()) return false; @@ -143,9 +152,11 @@ bool CActiveAESettings::IsSettingVisible(const std::string & condition, const st return m_instance->m_audioEngine.IsSettingVisible(value); } -void CActiveAESettings::SettingOptionsAudioDevicesFillerGeneral(SettingConstPtr setting, - std::vector<StringSettingOption> &list, - std::string ¤t, bool passthrough) +void CActiveAESettings::SettingOptionsAudioDevicesFillerGeneral( + const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + bool passthrough) { current = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); std::string firstDevice; diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.h index 2243afeb4b..7f814d09c3 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.h @@ -31,23 +31,36 @@ public: CActiveAESettings(CActiveAE &ae); ~CActiveAESettings() override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - - static void SettingOptionsAudioDevicesFiller(std::shared_ptr<const CSetting> setting, - std::vector<StringSettingOption> &list, - std::string ¤t, void *data); - static void SettingOptionsAudioDevicesPassthroughFiller(std::shared_ptr<const CSetting> setting, - std::vector<StringSettingOption> &list, - std::string ¤t, void *data); - static void SettingOptionsAudioQualityLevelsFiller(std::shared_ptr<const CSetting> setting, - std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsAudioStreamsilenceFiller(std::shared_ptr<const CSetting> setting, - std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static bool IsSettingVisible(const std::string &condition, const std::string &value, - std::shared_ptr<const CSetting> setting, void *data); + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + + static void SettingOptionsAudioDevicesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsAudioDevicesPassthroughFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsAudioQualityLevelsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsAudioStreamsilenceFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static bool IsSettingVisible(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); protected: - static void SettingOptionsAudioDevicesFillerGeneral(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, bool passthrough); + static void SettingOptionsAudioDevicesFillerGeneral( + const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + bool passthrough); CActiveAE &m_audioEngine; CCriticalSection m_cs; diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp index cde2e84d69..c604dfc458 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp @@ -205,7 +205,7 @@ bool CActiveAESink::NeedIECPacking() return true; } -bool CActiveAESink::DeviceExist(std::string driver, std::string device) +bool CActiveAESink::DeviceExist(std::string driver, const std::string& device) { if (driver.empty() && m_sink) driver = m_sink->GetName(); @@ -215,9 +215,8 @@ bool CActiveAESink::DeviceExist(std::string driver, std::string device) if (itt.m_sinkName != driver) continue; - for (auto itt2 : itt.m_deviceInfoList) + for (const CAEDeviceInfo& info : itt.m_deviceInfoList) { - CAEDeviceInfo& info = itt2; if (info.m_deviceName == device) return true; } diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.h index da5433861d..2d0d905266 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.h @@ -16,6 +16,8 @@ #include "threads/Thread.h" #include "utils/ActorProtocol.h" +#include <utility> + class CAEBitstreamPacker; namespace ActiveAE @@ -42,7 +44,8 @@ struct SinkReply class CSinkControlProtocol : public Protocol { public: - CSinkControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + CSinkControlProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { CONFIGURE, @@ -66,7 +69,8 @@ public: class CSinkDataProtocol : public Protocol { public: - CSinkDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + CSinkDataProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { SAMPLE = 0, @@ -90,7 +94,7 @@ public: AEDeviceType GetDeviceType(const std::string &device); bool HasPassthroughDevice(); bool SupportsFormat(const std::string &device, AEAudioFormat &format); - bool DeviceExist(std::string driver, std::string device); + bool DeviceExist(std::string driver, const std::string& device); CSinkControlProtocol m_controlPort; CSinkDataProtocol m_dataPort; diff --git a/xbmc/cores/AudioEngine/Interfaces/AE.h b/xbmc/cores/AudioEngine/Interfaces/AE.h index 63f0544181..f95143871a 100644 --- a/xbmc/cores/AudioEngine/Interfaces/AE.h +++ b/xbmc/cores/AudioEngine/Interfaces/AE.h @@ -225,7 +225,7 @@ public: /** * Instruct AE to re-initialize, e.g. after ELD change event */ - virtual void DeviceCountChange(std::string driver) {} + virtual void DeviceCountChange(const std::string& driver) {} /** * Get the current sink data format diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp index f2db9226f5..8b548046aa 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp @@ -454,7 +454,6 @@ static CAEChannelInfo PAChannelToAEChannelMap(const pa_channel_map& channels) return info; } -#if PA_CHECK_VERSION(10,0,0) static void ModuleInfoCallback(pa_context* c, const pa_module_info *i, int eol, void *userdata) { ModuleInfoStruct *mis = static_cast<ModuleInfoStruct*>(userdata); @@ -468,7 +467,7 @@ static void ModuleInfoCallback(pa_context* c, const pa_module_info *i, int eol, } pa_threaded_mainloop_signal(mis->mainloop, 0); } -#endif + static void SinkInfoRequestCallback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { @@ -803,8 +802,6 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device) return false; } - bool use_pa_mixing = false; - if(m_passthrough) { map.channels = 2; @@ -812,42 +809,13 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device) } else { - // version 11 got the new option "remixing-use-all-sink-channels" which - // can be set to "no". Therefore we give the choice back to user and let - // him configure the soundserver the way he likes - this makes the pre 11 - // workaround obsolete -#if PA_CHECK_VERSION(11,0,0) - use_pa_mixing = true; map = AEChannelMapToPAChannel(format.m_channelLayout); -#else - // as we mix for PA now to avoid default upmixing, we need to care for - // channel resolving - CAEChannelInfo target_layout = format.m_channelLayout; - CAEChannelInfo available_layout = PAChannelToAEChannelMap(sinkStruct.map); - target_layout.ResolveChannels(available_layout); - - // if we cannot map all requested channels - tell PA to mix for us - if (target_layout.Count() != format.m_channelLayout.Count()) - { - use_pa_mixing = true; - map = AEChannelMapToPAChannel(format.m_channelLayout); - } - else - { - // use our layout to update AE - map = AEChannelMapToPAChannel(target_layout); - } -#endif format.m_channelLayout = PAChannelToAEChannelMap(map); } m_Channels = format.m_channelLayout.Count(); - // Pulse can resample everything between 1 hz and 192000 hz / 384000 hz (starting with 9.0) - // Make sure we are in the range that we originally added - unsigned int max_pulse_sample_rate = 192000U; -#if PA_CHECK_VERSION(9,0,0) - max_pulse_sample_rate = 384000U; -#endif + // Pulse can resample everything between 5 khz and 384 khz (since 9.0) + unsigned int max_pulse_sample_rate = 384000U; format.m_sampleRate = std::max(5512U, std::min(format.m_sampleRate, max_pulse_sample_rate)); pa_format_info *info[1]; @@ -942,12 +910,6 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device) buffer_attr.tlength = latency; int flags = (PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY); - // by default PA will upmix / remix everything when multi channel layout is configured - // if we have enough channels in the target layout ask PA not to remix to related channels - // 1:1 remapping is allowed though - if (!m_passthrough && !use_pa_mixing) - flags |= PA_STREAM_NO_REMIX_CHANNELS; - if (m_passthrough) flags |= PA_STREAM_PASSTHROUGH; @@ -1248,9 +1210,7 @@ void CAESinkPULSE::EnumerateDevicesEx(AEDeviceInfoList &list, bool force) ModuleInfoStruct mis; mis.mainloop = mainloop; -#if PA_CHECK_VERSION(10,0,0) WaitForOperation(pa_context_get_module_info_list(context, ModuleInfoCallback, &mis), mainloop, "Check PA Modules"); -#endif if (!mis.hasAllowPT) { CLog::Log(LOGWARNING, "Pulseaudio module module-allow-passthrough not loaded - opening PT devices might fail"); diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp index 2d6558c974..53e134039b 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp @@ -692,6 +692,17 @@ bool CAESinkWASAPI::InitializeExclusive(AEAudioFormat &format) CAESinkFactoryWin::BuildWaveFormatExtensible(format, wfxex); } + // Prevents NULL speaker mask. To do: debug exact cause. + // When this happens requested AE format is AE_FMT_FLOAT + channel layout + // RAW, RAW, RAW... (6 channels). Only happens at end of playback PT + // stream, force to defaults does not affect functionality or user + // experience. Only avoids crash. + if (!wfxex.dwChannelMask && format.m_dataFormat <= AE_FMT_FLOAT) + { + CLog::LogF(LOGWARNING, "NULL Channel Mask detected. Default values are enforced."); + format.m_sampleRate = 0; // force defaults in following code + } + /* Test for incomplete format and provide defaults */ if (format.m_sampleRate == 0 || format.m_channelLayout == CAEChannelInfo(nullptr) || diff --git a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp index 60b1d6e40e..d6513d04a7 100644 --- a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp @@ -28,8 +28,6 @@ CAEChannelInfo::CAEChannelInfo(const AEStdChLayout rhs) *this = rhs; } -CAEChannelInfo::~CAEChannelInfo() = default; - void CAEChannelInfo::ResolveChannels(const CAEChannelInfo& rhs) { /* mono gets upmixed to dual mono */ diff --git a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h index de09240bc8..4fd0fb9e57 100644 --- a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h +++ b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h @@ -23,7 +23,7 @@ public: CAEChannelInfo(); explicit CAEChannelInfo(const enum AEChannel* rhs); CAEChannelInfo(const enum AEStdChLayout rhs); - ~CAEChannelInfo(); + ~CAEChannelInfo() = default; CAEChannelInfo& operator=(const CAEChannelInfo& rhs); CAEChannelInfo& operator=(const enum AEChannel* rhs); CAEChannelInfo& operator=(const enum AEStdChLayout rhs); diff --git a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp index 3f6913df60..e961b17336 100644 --- a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp @@ -112,8 +112,6 @@ bool CAEStreamInfo::operator==(const CAEStreamInfo& info) const return true; } -CAEStreamParser::~CAEStreamParser() = default; - void CAEStreamParser::Reset() { m_skipBytes = 0; diff --git a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h index 96232cbf6f..4af4126fc9 100644 --- a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h +++ b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h @@ -53,7 +53,7 @@ class CAEStreamParser public: CAEStreamParser(); - ~CAEStreamParser(); + ~CAEStreamParser() = default; int AddData(uint8_t *data, unsigned int size, uint8_t **buffer = NULL, unsigned int *bufferSize = 0); diff --git a/xbmc/cores/DataCacheCore.cpp b/xbmc/cores/DataCacheCore.cpp index f2029119a6..8d17e811f0 100644 --- a/xbmc/cores/DataCacheCore.cpp +++ b/xbmc/cores/DataCacheCore.cpp @@ -12,6 +12,8 @@ #include "cores/Cut.h" #include "threads/SingleLock.h" +#include <utility> + CDataCacheCore::CDataCacheCore() : m_playerVideoInfo {}, m_playerAudioInfo {}, @@ -76,7 +78,7 @@ void CDataCacheCore::SetVideoDecoderName(std::string name, bool isHw) { CSingleLock lock(m_videoPlayerSection); - m_playerVideoInfo.decoderName = name; + m_playerVideoInfo.decoderName = std::move(name); m_playerVideoInfo.isHwDecoder = isHw; } @@ -99,7 +101,7 @@ void CDataCacheCore::SetVideoDeintMethod(std::string method) { CSingleLock lock(m_videoPlayerSection); - m_playerVideoInfo.deintMethod = method; + m_playerVideoInfo.deintMethod = std::move(method); } std::string CDataCacheCore::GetVideoDeintMethod() @@ -113,7 +115,7 @@ void CDataCacheCore::SetVideoPixelFormat(std::string pixFormat) { CSingleLock lock(m_videoPlayerSection); - m_playerVideoInfo.pixFormat = pixFormat; + m_playerVideoInfo.pixFormat = std::move(pixFormat); } std::string CDataCacheCore::GetVideoPixelFormat() @@ -127,7 +129,7 @@ void CDataCacheCore::SetVideoStereoMode(std::string mode) { CSingleLock lock(m_videoPlayerSection); - m_playerVideoInfo.stereoMode = mode; + m_playerVideoInfo.stereoMode = std::move(mode); } std::string CDataCacheCore::GetVideoStereoMode() @@ -192,7 +194,7 @@ void CDataCacheCore::SetAudioDecoderName(std::string name) { CSingleLock lock(m_audioPlayerSection); - m_playerAudioInfo.decoderName = name; + m_playerAudioInfo.decoderName = std::move(name); } std::string CDataCacheCore::GetAudioDecoderName() @@ -206,7 +208,7 @@ void CDataCacheCore::SetAudioChannels(std::string channels) { CSingleLock lock(m_audioPlayerSection); - m_playerAudioInfo.channels = channels; + m_playerAudioInfo.channels = std::move(channels); } std::string CDataCacheCore::GetAudioChannels() diff --git a/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt b/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt index bb559e4bc8..1dc954afd9 100644 --- a/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt +++ b/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt @@ -24,7 +24,7 @@ if(OPENGL_FOUND) RenderBufferPoolOpenGL.cpp) endif() -if((CORE_PLATFORM_NAME_LC STREQUAL gbm OR CORE_PLATFORM_NAME_LC STREQUAL wayland) AND EGL_FOUND) +if(("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) AND EGL_FOUND) list(APPEND SOURCES RenderBufferDMA.cpp RenderBufferPoolDMA.cpp) list(APPEND HEADERS RenderBufferDMA.h diff --git a/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp index 0deed3b3fe..7d720ad851 100644 --- a/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp +++ b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp @@ -150,7 +150,7 @@ void CGUIGameControl::UpdateInfo(const CGUIListItem* item /* = nullptr */) if (StringUtils::IsNaturalNumber(strRotation)) { unsigned int rotation; - std::istringstream(std::move(strRotation)) >> rotation; + std::istringstream(strRotation) >> rotation; m_renderSettings->SetRotationDegCCW(rotation); m_bHasRotation = true; } diff --git a/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp b/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp index 478905ffd8..9dee726c05 100644 --- a/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp +++ b/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp @@ -58,7 +58,7 @@ void CGUIRenderSettings::SetSettings(CRenderSettings settings) { CSingleLock lock(m_mutex); - m_renderSettings = std::move(settings); + m_renderSettings = settings; } void CGUIRenderSettings::SetDimensions(const CRect& dimensions) diff --git a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt index 30c20b59ce..6f9d9086cc 100644 --- a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt +++ b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt @@ -18,7 +18,7 @@ if(OPENGL_FOUND) list(APPEND HEADERS RPRendererOpenGL.h) endif() -if((CORE_PLATFORM_NAME_LC STREQUAL gbm OR CORE_PLATFORM_NAME_LC STREQUAL wayland) AND EGL_FOUND) +if(("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) AND EGL_FOUND) list(APPEND SOURCES RPRendererDMA.cpp) list(APPEND HEADERS RPRendererDMA.h) endif() diff --git a/xbmc/cores/VideoPlayer/Buffers/CMakeLists.txt b/xbmc/cores/VideoPlayer/Buffers/CMakeLists.txt index a7db7f4de2..a876912363 100644 --- a/xbmc/cores/VideoPlayer/Buffers/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/Buffers/CMakeLists.txt @@ -1,7 +1,7 @@ set(SOURCES VideoBuffer.cpp) set(HEADERS VideoBuffer.h) -if(CORE_PLATFORM_NAME_LC STREQUAL gbm OR CORE_PLATFORM_NAME_LC STREQUAL wayland) +if("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES VideoBufferDMA.cpp VideoBufferDRMPRIME.cpp VideoBufferPoolDMA.cpp) diff --git a/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.cpp b/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.cpp index eb7847ca0a..2543445b33 100644 --- a/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.cpp +++ b/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.cpp @@ -11,6 +11,7 @@ #include "threads/SingleLock.h" #include <string.h> +#include <utility> //----------------------------------------------------------------------------- // CVideoBuffer @@ -30,7 +31,7 @@ void CVideoBuffer::Acquire() void CVideoBuffer::Acquire(std::shared_ptr<IVideoBufferPool> pool) { m_refCount++; - m_pool = pool; + m_pool = std::move(pool); } void CVideoBuffer::Release() @@ -380,14 +381,14 @@ CVideoBufferManager::CVideoBufferManager() RegisterPoolFactory("SysMem", &CVideoBufferPoolSysMem::CreatePool); } -void CVideoBufferManager::RegisterPool(std::shared_ptr<IVideoBufferPool> pool) +void CVideoBufferManager::RegisterPool(const std::shared_ptr<IVideoBufferPool>& pool) { CSingleLock lock(m_critSection); // preferred pools are to the front m_pools.push_front(pool); } -void CVideoBufferManager::RegisterPoolFactory(std::string id, CreatePoolFunc createFunc) +void CVideoBufferManager::RegisterPoolFactory(const std::string& id, CreatePoolFunc createFunc) { CSingleLock lock(m_critSection); m_poolFactories[id] = createFunc; @@ -401,7 +402,7 @@ void CVideoBufferManager::ReleasePools() m_discardedPools = pools; - for (auto pool : pools) + for (const auto& pool : pools) { pool->Discard(this, &CVideoBufferManager::ReadyForDisposal); } @@ -441,7 +442,7 @@ void CVideoBufferManager::ReadyForDisposal(IVideoBufferPool *pool) CVideoBuffer* CVideoBufferManager::Get(AVPixelFormat format, int size, IVideoBufferPool **pPool) { CSingleLock lock(m_critSection); - for (auto pool: m_pools) + for (const auto& pool : m_pools) { if (!pool->IsConfigured()) { @@ -453,7 +454,7 @@ CVideoBuffer* CVideoBufferManager::Get(AVPixelFormat format, int size, IVideoBuf } } - for (auto fact : m_poolFactories) + for (const auto& fact : m_poolFactories) { std::shared_ptr<IVideoBufferPool> pool = fact.second(); m_pools.push_front(pool); diff --git a/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.h b/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.h index 1c1ba21c48..73302a62d1 100644 --- a/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.h +++ b/xbmc/cores/VideoPlayer/Buffers/VideoBuffer.h @@ -173,8 +173,8 @@ class CVideoBufferManager { public: CVideoBufferManager(); - void RegisterPool(std::shared_ptr<IVideoBufferPool> pool); - void RegisterPoolFactory(std::string id, CreatePoolFunc createFunc); + void RegisterPool(const std::shared_ptr<IVideoBufferPool>& pool); + void RegisterPoolFactory(const std::string& id, CreatePoolFunc createFunc); void ReleasePools(); void ReleasePool(IVideoBufferPool *pool); CVideoBuffer* Get(AVPixelFormat format, int size, IVideoBufferPool **pPool); diff --git a/xbmc/cores/VideoPlayer/CMakeLists.txt b/xbmc/cores/VideoPlayer/CMakeLists.txt index b2bffbd665..9e78fe2d83 100644 --- a/xbmc/cores/VideoPlayer/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/CMakeLists.txt @@ -36,9 +36,9 @@ set(HEADERS AudioSinkAE.h VideoPlayerVideo.h VideoReferenceClock.h Interface/StreamInfo.h - Interface/Addon/DemuxPacket.h - Interface/Addon/DemuxCrypto.h - Interface/Addon/InputStreamConstants.h - Interface/Addon/TimingConstants.h) + Interface/DemuxPacket.h + Interface/DemuxCrypto.h + Interface/InputStreamConstants.h + Interface/TimingConstants.h) core_add_library(VideoPlayer) diff --git a/xbmc/cores/VideoPlayer/DVDClock.cpp b/xbmc/cores/VideoPlayer/DVDClock.cpp index ceaa88553a..e860dd30f2 100644 --- a/xbmc/cores/VideoPlayer/DVDClock.cpp +++ b/xbmc/cores/VideoPlayer/DVDClock.cpp @@ -9,7 +9,7 @@ #include "DVDClock.h" #include "VideoReferenceClock.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "threads/SingleLock.h" #include "utils/MathUtils.h" #include "utils/TimeUtils.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodec.h index 7b9b29fcc4..b92f41a4c6 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodec.h @@ -9,8 +9,8 @@ #pragma once #include "cores/AudioEngine/Utils/AEAudioFormat.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" #include "cores/VideoPlayer/Process/ProcessInfo.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" #include <vector> diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecAndroidMediaCodec.cpp index 4c20587b47..9046d42a0f 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecAndroidMediaCodec.cpp @@ -22,7 +22,7 @@ #include "ServiceBroker.h" #include "cores/AudioEngine/Interfaces/AE.h" #include "cores/AudioEngine/Utils/AEUtil.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxCrypto.h" +#include "cores/VideoPlayer/Interface/DemuxCrypto.h" #include "utils/StringUtils.h" #include "utils/log.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecUtils.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecUtils.cpp index 604fab4fa1..66c073367d 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecUtils.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecUtils.cpp @@ -7,9 +7,10 @@ */ #include "DVDCodecUtils.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" -#include "cores/FFmpeg.h" + #include "Util.h" +#include "cores/FFmpeg.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" extern "C" { #include <libswscale/swscale.h> diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp index 4c7e1e040d..605d8b308e 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp @@ -87,7 +87,8 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CProces return nullptr; } -CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodecHW(std::string id, CProcessInfo &processInfo) +CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodecHW(const std::string& id, + CProcessInfo& processInfo) { CSingleLock lock(videoCodecSection); @@ -100,7 +101,10 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodecHW(std::string id, CProcessInf return nullptr; } -IHardwareDecoder* CDVDFactoryCodec::CreateVideoCodecHWAccel(std::string id, CDVDStreamInfo &hint, CProcessInfo &processInfo, AVPixelFormat fmt) +IHardwareDecoder* CDVDFactoryCodec::CreateVideoCodecHWAccel(const std::string& id, + CDVDStreamInfo& hint, + CProcessInfo& processInfo, + AVPixelFormat fmt) { CSingleLock lock(videoCodecSection); @@ -114,7 +118,7 @@ IHardwareDecoder* CDVDFactoryCodec::CreateVideoCodecHWAccel(std::string id, CDVD } -void CDVDFactoryCodec::RegisterHWVideoCodec(std::string id, CreateHWVideoCodec createFunc) +void CDVDFactoryCodec::RegisterHWVideoCodec(const std::string& id, CreateHWVideoCodec createFunc) { CSingleLock lock(videoCodecSection); @@ -133,6 +137,7 @@ std::vector<std::string> CDVDFactoryCodec::GetHWAccels() CSingleLock lock(videoCodecSection); std::vector<std::string> ret; + ret.reserve(m_hwAccels.size()); for (auto &hwaccel : m_hwAccels) { ret.push_back(hwaccel.first); @@ -140,7 +145,7 @@ std::vector<std::string> CDVDFactoryCodec::GetHWAccels() return ret; } -void CDVDFactoryCodec::RegisterHWAccel(std::string id, CreateHWAccel createFunc) +void CDVDFactoryCodec::RegisterHWAccel(const std::string& id, CreateHWAccel createFunc) { CSingleLock lock(videoCodecSection); @@ -200,7 +205,7 @@ CDVDAudioCodec* CDVDFactoryCodec::CreateAudioCodec(CDVDStreamInfo &hint, CProces return nullptr; } -void CDVDFactoryCodec::RegisterHWAudioCodec(std::string id, CreateHWAudioCodec createFunc) +void CDVDFactoryCodec::RegisterHWAudioCodec(const std::string& id, CreateHWAudioCodec createFunc) { CSingleLock lock(audioCodecSection); @@ -214,7 +219,8 @@ void CDVDFactoryCodec::ClearHWAudioCodecs() m_hwAudioCodecs.clear(); } -CDVDAudioCodec* CDVDFactoryCodec::CreateAudioCodecHW(std::string id, CProcessInfo &processInfo) +CDVDAudioCodec* CDVDFactoryCodec::CreateAudioCodecHW(const std::string& id, + CProcessInfo& processInfo) { CSingleLock lock(audioCodecSection); diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h index 92f076b8a8..a24cc9e7b7 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h @@ -39,8 +39,10 @@ public: static CDVDVideoCodec* CreateVideoCodec(CDVDStreamInfo &hint, CProcessInfo &processInfo); - static IHardwareDecoder* CreateVideoCodecHWAccel(std::string id, CDVDStreamInfo &hint, - CProcessInfo &processInfo, AVPixelFormat fmt); + static IHardwareDecoder* CreateVideoCodecHWAccel(const std::string& id, + CDVDStreamInfo& hint, + CProcessInfo& processInfo, + AVPixelFormat fmt); static CDVDAudioCodec* CreateAudioCodec(CDVDStreamInfo &hint, CProcessInfo &processInfo, bool allowpassthrough, bool allowdtshddecode, @@ -48,21 +50,20 @@ public: static CDVDOverlayCodec* CreateOverlayCodec(CDVDStreamInfo &hint); - static void RegisterHWVideoCodec(std::string id, CreateHWVideoCodec createFunc); + static void RegisterHWVideoCodec(const std::string& id, CreateHWVideoCodec createFunc); static void ClearHWVideoCodecs(); - static void RegisterHWAccel(std::string id, CreateHWAccel createFunc); + static void RegisterHWAccel(const std::string& id, CreateHWAccel createFunc); static std::vector<std::string> GetHWAccels(); static void ClearHWAccels(); - static void RegisterHWAudioCodec(std::string id, CreateHWAudioCodec createFunc); + static void RegisterHWAudioCodec(const std::string& id, CreateHWAudioCodec createFunc); static void ClearHWAudioCodecs(); protected: - - static CDVDVideoCodec* CreateVideoCodecHW(std::string id, CProcessInfo &processInfo); - static CDVDAudioCodec* CreateAudioCodecHW(std::string id, CProcessInfo &processInfo); + static CDVDVideoCodec* CreateVideoCodecHW(const std::string& id, CProcessInfo& processInfo); + static CDVDAudioCodec* CreateAudioCodecHW(const std::string& id, CProcessInfo& processInfo); static std::map<std::string, CreateHWVideoCodec> m_hwVideoCodecs; static std::map<std::string, CreateHWAccel> m_hwAccels; diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp index f08c9eaef9..8b31f5b4d9 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodec.cpp @@ -7,8 +7,8 @@ */ #include "DVDOverlayCodec.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" void CDVDOverlayCodec::GetAbsoluteTimes(double &starttime, double &stoptime, DemuxPacket *pkt, bool &replace, double offset/* = 0.0*/) { diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp index aece3388f4..59479c049a 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp @@ -10,8 +10,8 @@ #include "DVDOverlayImage.h" #include "DVDStreamInfo.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/EndianSwap.h" #include "utils/log.h" #include "windowing/GraphicContext.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp index 3856744377..d75737e097 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecSSA.cpp @@ -12,8 +12,8 @@ #include "DVDOverlaySSA.h" #include "DVDStreamInfo.h" #include "Util.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/StringUtils.h" #include <memory> @@ -89,9 +89,9 @@ int CDVDOverlayCodecSSA::Decode(DemuxPacket *pPacket) end = 10000 * ((eh*360000.0)+(em*6000.0)+(es*100.0)+ec); beg = 10000 * ((sh*360000.0)+(sm*6000.0)+(ss*100.0)+sc); - pos = line.find_first_of(",", 0); - pos = line.find_first_of(",", pos+1); - pos = line.find_first_of(",", pos+1); + pos = line.find_first_of(',', 0); + pos = line.find_first_of(',', pos + 1); + pos = line.find_first_of(',', pos + 1); if(pos == std::string::npos) continue; diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp index c89b7bfd85..559fe7d01d 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp @@ -12,7 +12,7 @@ #include "DVDOverlayText.h" #include "DVDStreamInfo.h" #include "ServiceBroker.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" #include "settings/Settings.h" #include "settings/SettingsComponent.h" #include "utils/RegExp.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecText.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecText.cpp index 6abba0406c..fc00f298f4 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecText.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecText.cpp @@ -12,7 +12,7 @@ #include "DVDOverlayText.h" #include "DVDStreamInfo.h" #include "cores/VideoPlayer/DVDSubtitles/DVDSubtitleTagSami.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" #include "utils/log.h" #include "system.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp index 493c84f25e..6b2e51b6de 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp @@ -11,8 +11,8 @@ #include "cores/VideoPlayer/Buffers/VideoBuffer.h" #include "cores/VideoPlayer/DVDCodecs/DVDCodecs.h" #include "cores/VideoPlayer/DVDStreamInfo.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxCrypto.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxCrypto.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/log.h" CAddonVideoCodec::CAddonVideoCodec(CProcessInfo& processInfo, @@ -56,7 +56,7 @@ bool CAddonVideoCodec::CopyToInitData(VIDEOCODEC_INITDATA &initData, CDVDStreamI switch (hints.codec) { case AV_CODEC_ID_H264: - initData.codec = VIDEOCODEC_INITDATA::CodecH264; + initData.codec = VIDEOCODEC_H264; switch (hints.profile) { case 0: @@ -89,10 +89,10 @@ bool CAddonVideoCodec::CopyToInitData(VIDEOCODEC_INITDATA &initData, CDVDStreamI } break; case AV_CODEC_ID_VP8: - initData.codec = VIDEOCODEC_INITDATA::CodecVp8; + initData.codec = VIDEOCODEC_VP8; break; case AV_CODEC_ID_VP9: - initData.codec = VIDEOCODEC_INITDATA::CodecVp9; + initData.codec = VIDEOCODEC_VP9; switch (hints.profile) { case FF_PROFILE_UNKNOWN: @@ -122,23 +122,23 @@ bool CAddonVideoCodec::CopyToInitData(VIDEOCODEC_INITDATA &initData, CDVDStreamI switch (hints.cryptoSession->keySystem) { case CRYPTO_SESSION_SYSTEM_NONE: - initData.cryptoInfo.m_CryptoKeySystem = CRYPTO_INFO::CRYPTO_KEY_SYSTEM_NONE; + initData.cryptoSession.keySystem = STREAM_CRYPTO_KEY_SYSTEM_NONE; break; case CRYPTO_SESSION_SYSTEM_WIDEVINE: - initData.cryptoInfo.m_CryptoKeySystem = CRYPTO_INFO::CRYPTO_KEY_SYSTEM_WIDEVINE; + initData.cryptoSession.keySystem = STREAM_CRYPTO_KEY_SYSTEM_WIDEVINE; break; case CRYPTO_SESSION_SYSTEM_PLAYREADY: - initData.cryptoInfo.m_CryptoKeySystem = CRYPTO_INFO::CRYPTO_KEY_SYSTEM_PLAYREADY; + initData.cryptoSession.keySystem = STREAM_CRYPTO_KEY_SYSTEM_PLAYREADY; break; case CRYPTO_SESSION_SYSTEM_WISEPLAY: - initData.cryptoInfo.m_CryptoKeySystem = CRYPTO_INFO::CRYPTO_KEY_SYSTEM_WISEPLAY; + initData.cryptoSession.keySystem = STREAM_CRYPTO_KEY_SYSTEM_WISEPLAY; break; default: return false; } - initData.cryptoInfo.m_CryptoSessionIdSize = hints.cryptoSession->sessionIdSize; + initData.cryptoSession.sessionIdSize = hints.cryptoSession->sessionIdSize; //We assume that we need this sessionid only for the directly following call - initData.cryptoInfo.m_CryptoSessionId = hints.cryptoSession->sessionId; + initData.cryptoSession.sessionId = hints.cryptoSession->sessionId; } initData.extraData = reinterpret_cast<const uint8_t*>(hints.extradata); @@ -165,8 +165,8 @@ bool CAddonVideoCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) return false; unsigned int nformats(0); - m_formats[nformats++] = VideoFormatYV12; - m_formats[nformats] = UnknownVideoFormat; + m_formats[nformats++] = VIDEOCODEC_FORMAT_YV12; + m_formats[nformats] = VIDEOCODEC_FORMAT_UNKNOWN; VIDEOCODEC_INITDATA initData; if (!CopyToInitData(initData, hints)) @@ -204,7 +204,8 @@ CDVDVideoCodec::VCReturn CAddonVideoCodec::GetPicture(VideoPicture* pVideoPictur return CDVDVideoCodec::VC_ERROR; VIDEOCODEC_PICTURE picture; - picture.flags = (m_codecFlags & DVD_CODEC_CTRL_DRAIN) ? VIDEOCODEC_PICTURE::FLAG_DRAIN : 0; + picture.flags = (m_codecFlags & DVD_CODEC_CTRL_DRAIN) ? VIDEOCODEC_PICTURE_FLAG_DRAIN + : VIDEOCODEC_PICTURE_FLAG_DROP; switch (m_struct.toAddon->get_picture(&m_struct, &picture)) { @@ -305,7 +306,7 @@ void CAddonVideoCodec::Reset() // Get the remaining pictures out of the external decoder VIDEOCODEC_PICTURE picture; - picture.flags = VIDEOCODEC_PICTURE::FLAG_DRAIN; + picture.flags = VIDEOCODEC_PICTURE_FLAG_DRAIN; VIDEOCODEC_RETVAL ret; while ((ret = m_struct.toAddon->get_picture(&m_struct, &picture)) != VIDEOCODEC_RETVAL::VC_EOF) diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.h index a0cd805511..b746b7cbbc 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.h @@ -49,7 +49,7 @@ private: AddonInstance_VideoCodec m_struct; int m_codecFlags; - VIDEOCODEC_FORMAT m_formats[VIDEOCODEC_FORMAT::MaxVideoFormats + 1]; + VIDEOCODEC_FORMAT m_formats[VIDEOCODEC_FORMAT_MAXFORMATS + 1]; float m_displayAspect; unsigned int m_width, m_height; }; diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/CMakeLists.txt b/xbmc/cores/VideoPlayer/DVDCodecs/Video/CMakeLists.txt index c91c19ff55..517acc3cd4 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/CMakeLists.txt @@ -36,7 +36,7 @@ if(CORE_SYSTEM_NAME STREQUAL android) list(APPEND HEADERS DVDVideoCodecAndroidMediaCodec.h) endif() -if(CORE_PLATFORM_NAME_LC STREQUAL gbm OR CORE_PLATFORM_NAME_LC STREQUAL wayland) +if("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES DVDVideoCodecDRMPRIME.cpp) list(APPEND HEADERS DVDVideoCodecDRMPRIME.h) endif() diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h index e1591c2234..a9c0e149f0 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h @@ -10,7 +10,7 @@ #include "DVDResource.h" #include "cores/VideoPlayer/Buffers/VideoBuffer.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" #include "cores/VideoPlayer/Process/ProcessInfo.h" extern "C" { diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index 36a19170df..7c0f26339e 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -18,8 +18,8 @@ #include "DVDCodecs/DVDFactoryCodec.h" #include "ServiceBroker.h" #include "cores/VideoPlayer/Buffers/VideoBuffer.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxCrypto.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxCrypto.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "cores/VideoPlayer/VideoRenderers/RenderFlags.h" #include "cores/VideoPlayer/VideoRenderers/RenderManager.h" #include "media/decoderfilter/DecoderFilterManager.h" @@ -38,6 +38,7 @@ #include <cassert> #include <memory> +#include <utility> #include <vector> #include <GLES2/gl2.h> @@ -136,9 +137,9 @@ void CMediaCodecVideoBuffer::Set(int bufferId, int textureId, { m_bufferId = bufferId; m_textureId = textureId; - m_surfacetexture = surfacetexture; - m_frameready = frameready; - m_videoview = videoview; + m_surfacetexture = std::move(surfacetexture); + m_frameready = std::move(frameready); + m_videoview = std::move(videoview); } bool CMediaCodecVideoBuffer::WaitForFrame(int millis) @@ -647,7 +648,9 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio { std::vector<CJNIMediaCodecInfoCodecProfileLevel> profileLevels = codec_caps.profileLevels(); if (std::find_if(profileLevels.cbegin(), profileLevels.cend(), - [&](const CJNIMediaCodecInfoCodecProfileLevel profileLevel){ return profileLevel.profile() == profile; }) == profileLevels.cend()) + [&](const CJNIMediaCodecInfoCodecProfileLevel& profileLevel) { + return profileLevel.profile() == profile; + }) == profileLevels.cend()) { CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open: profile not supported: %d", profile); continue; diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.h index 1f2a90316f..092d45a9af 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.h @@ -20,6 +20,7 @@ #include <atomic> #include <deque> #include <memory> +#include <utility> #include <vector> #include <android/native_window.h> @@ -90,7 +91,8 @@ private: class CMediaCodecVideoBufferPool : public IVideoBufferPool { public: - CMediaCodecVideoBufferPool(std::shared_ptr<CJNIMediaCodec> mediaCodec) : m_codec(mediaCodec){}; + CMediaCodecVideoBufferPool(std::shared_ptr<CJNIMediaCodec> mediaCodec) + : m_codec(std::move(mediaCodec)){}; ~CMediaCodecVideoBufferPool() override; diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp index 9e6521491c..a12ef9ec1e 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp @@ -96,10 +96,11 @@ CDVDVideoCodec* CDVDVideoCodecDRMPRIME::Create(CProcessInfo& processInfo) void CDVDVideoCodecDRMPRIME::Register() { - CServiceBroker::GetSettingsComponent() - ->GetSettings() - ->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER) - ->SetVisible(true); + auto settings = CServiceBroker::GetSettingsComponent()->GetSettings(); + + settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER)->SetVisible(true); + settings->GetSetting(SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW)->SetVisible(true); + CDVDFactoryCodec::RegisterHWVideoCodec("drm_prime", CDVDVideoCodecDRMPRIME::Create); } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp index 0af254029e..99408b5864 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp @@ -12,7 +12,7 @@ #include "DVDCodecs/DVDFactoryCodec.h" #include "DVDStreamInfo.h" #include "ServiceBroker.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "cores/VideoPlayer/VideoRenderers/RenderManager.h" #include "cores/VideoSettings.h" #include "settings/AdvancedSettings.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp index 6e2ffe1cf8..3ad67df4e2 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp @@ -12,7 +12,7 @@ #include "ServiceBroker.h" #include "cores/VideoPlayer/DVDCodecs/DVDCodecUtils.h" #include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "cores/VideoPlayer/Process/ProcessInfo.h" #include "settings/AdvancedSettings.h" #include "settings/Settings.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h index 958e1382c7..b1c9de2605 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h @@ -23,6 +23,7 @@ #include <list> #include <map> #include <memory> +#include <utility> #include <vector> #include <va/va.h> @@ -190,7 +191,8 @@ public: class COutputControlProtocol : public Protocol { public: - COutputControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + COutputControlProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { INIT, @@ -209,7 +211,8 @@ public: class COutputDataProtocol : public Protocol { public: - COutputDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + COutputDataProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { NEWFRAME = 0, diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp index f65c6b75ae..66a6358491 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp @@ -12,7 +12,7 @@ #include "DVDCodecs/DVDCodecUtils.h" #include "ServiceBroker.h" #include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "cores/VideoPlayer/Process/ProcessInfo.h" #include "cores/VideoPlayer/VideoRenderers/RenderFlags.h" #include "cores/VideoPlayer/VideoRenderers/RenderManager.h" diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.h index 8cad33e4c6..af96cd2607 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.h @@ -40,6 +40,7 @@ #include <deque> #include <list> #include <map> +#include <utility> #include <vector> #include <X11/Xlib.h> @@ -241,7 +242,8 @@ public: class CMixerControlProtocol : public Actor::Protocol { public: - CMixerControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + CMixerControlProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { INIT = 0, @@ -258,7 +260,8 @@ public: class CMixerDataProtocol : public Actor::Protocol { public: - CMixerDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; + CMixerDataProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { FRAME, @@ -348,7 +351,8 @@ protected: class COutputControlProtocol : public Actor::Protocol { public: - COutputControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Actor::Protocol(name, inEvent, outEvent) {}; + COutputControlProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Actor::Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { INIT, @@ -367,7 +371,8 @@ public: class COutputDataProtocol : public Actor::Protocol { public: - COutputDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Actor::Protocol(name, inEvent, outEvent) {}; + COutputDataProtocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : Actor::Protocol(std::move(name), inEvent, outEvent){}; enum OutSignal { NEWFRAME = 0, diff --git a/xbmc/cores/VideoPlayer/DVDDemuxSPU.cpp b/xbmc/cores/VideoPlayer/DVDDemuxSPU.cpp index 538ef05027..007a2e4e0e 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxSPU.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxSPU.cpp @@ -9,7 +9,7 @@ #include "DVDDemuxSPU.h" #include "DVDCodecs/Overlay/DVDOverlaySpu.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/log.h" #include <locale.h> diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.cpp index 64486563f0..1951d39c70 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.cpp @@ -10,7 +10,7 @@ #include "DVDDemuxUtils.h" #include "DVDInputStreams/DVDInputStream.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/StringUtils.h" // AirTunes audio Demuxer. @@ -39,7 +39,7 @@ CDVDDemuxBXA::~CDVDDemuxBXA() Dispose(); } -bool CDVDDemuxBXA::Open(std::shared_ptr<CDVDInputStream> pInput) +bool CDVDDemuxBXA::Open(const std::shared_ptr<CDVDInputStream>& pInput) { Abort(); diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.h index 4f61128d9e..94fa8c9eb2 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxBXA.h @@ -43,7 +43,7 @@ public: CDVDDemuxBXA(); ~CDVDDemuxBXA() override; - bool Open(std::shared_ptr<CDVDInputStream> pInput); + bool Open(const std::shared_ptr<CDVDInputStream>& pInput); void Dispose(); bool Reset() override; void Abort() override; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp index 0111895c46..ce374981cd 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp @@ -10,7 +10,7 @@ #include "DVDDemuxUtils.h" #include "cores/VideoPlayer/DVDCodecs/Overlay/contrib/cc_decoder708.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include <algorithm> @@ -114,6 +114,7 @@ std::vector<CDemuxStream*> CDVDDemuxCC::GetStreams() const std::vector<CDemuxStream*> streams; int num = GetNrOfStreams(); + streams.reserve(num); for (int i = 0; i < num; ++i) { streams.push_back(const_cast<CDemuxStreamSubtitle*>(&m_streams[i])); diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.cpp index 9167f07162..15d17f3207 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.cpp @@ -10,7 +10,7 @@ #include "DVDDemuxUtils.h" #include "DVDInputStreams/DVDInputStream.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" // CDDA audio demuxer based on AirTunes audio Demuxer. @@ -31,7 +31,7 @@ CDVDDemuxCDDA::~CDVDDemuxCDDA() Dispose(); } -bool CDVDDemuxCDDA::Open(std::shared_ptr<CDVDInputStream> pInput) +bool CDVDDemuxCDDA::Open(const std::shared_ptr<CDVDInputStream>& pInput) { Abort(); diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.h index fa65997aff..01b61f1056 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCDDA.h @@ -25,7 +25,7 @@ public: CDVDDemuxCDDA(); ~CDVDDemuxCDDA() override; - bool Open(std::shared_ptr<CDVDInputStream> pInput); + bool Open(const std::shared_ptr<CDVDInputStream>& pInput); void Dispose(); bool Reset() override; void Abort() override; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp index 97b27f5bea..795b9c11e1 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp @@ -10,9 +10,11 @@ #include "DVDDemuxUtils.h" #include "DVDInputStreams/DVDInputStream.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/log.h" +#include <utility> + #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) class CDemuxStreamClientInternal @@ -63,7 +65,7 @@ bool CDVDDemuxClient::Open(std::shared_ptr<CDVDInputStream> pInput) { Abort(); - m_pInput = pInput; + m_pInput = std::move(pInput); m_IDemux = std::dynamic_pointer_cast<CDVDInputStream::IDemux>(m_pInput); if (!m_IDemux) return false; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp index 7f243c3159..46e29ba4c3 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp @@ -13,9 +13,10 @@ #include "DVDInputStreams/DVDInputStreamFFmpeg.h" #include "ServiceBroker.h" #include "URL.h" +#include "Util.h" #include "commons/Exception.h" #include "cores/FFmpeg.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" // for DVD_TIME_BASE +#include "cores/VideoPlayer/Interface/TimingConstants.h" // for DVD_TIME_BASE #include "filesystem/CurlFile.h" #include "filesystem/Directory.h" #include "filesystem/File.h" @@ -28,7 +29,6 @@ #include "utils/URIUtils.h" #include "utils/XTimeUtils.h" #include "utils/log.h" -#include "Util.h" #include <sstream> #include <utility> @@ -200,7 +200,7 @@ bool CDVDDemuxFFmpeg::Aborted() return false; } -bool CDVDDemuxFFmpeg::Open(std::shared_ptr<CDVDInputStream> pInput, bool fileinfo) +bool CDVDDemuxFFmpeg::Open(const std::shared_ptr<CDVDInputStream>& pInput, bool fileinfo) { AVInputFormat* iformat = NULL; std::string strFile; @@ -273,7 +273,7 @@ bool CDVDDemuxFFmpeg::Open(std::shared_ptr<CDVDInputStream> pInput, bool fileinf if (found != std::string::npos) { size_t start = found + 3; - found = strURL.find("@"); + found = strURL.find('@'); if (found != std::string::npos && found > start) { diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.h index a20d9432af..3fe4b507ea 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.h @@ -83,7 +83,7 @@ public: CDVDDemuxFFmpeg(); ~CDVDDemuxFFmpeg() override; - bool Open(std::shared_ptr<CDVDInputStream> pInput, bool fileinfo); + bool Open(const std::shared_ptr<CDVDInputStream>& pInput, bool fileinfo); void Dispose(); bool Reset() override ; void Flush() override; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.cpp index 66c9943f59..d100d0566b 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.cpp @@ -7,9 +7,10 @@ */ #include "DVDDemuxUtils.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxCrypto.h" -#include "utils/log.h" + +#include "cores/VideoPlayer/Interface/DemuxCrypto.h" #include "utils/MemUtils.h" +#include "utils/log.h" extern "C" { #include <libavcodec/avcodec.h> diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h index 56904b755f..dcb44bc324 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h @@ -8,7 +8,7 @@ #pragma once -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" extern "C" { #include <libavcodec/avcodec.h> } diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp index 3f84899e93..452a775129 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp @@ -14,8 +14,8 @@ #include "DVDInputStreams/DVDInputStream.h" #include "DVDStreamInfo.h" #include "DVDSubtitles/DVDSubtitleStream.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include <string.h> diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp index 8a02b2c3db..35ba376ad9 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp @@ -17,7 +17,8 @@ #include "utils/URIUtils.h" #include "utils/log.h" -CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(std::shared_ptr<CDVDInputStream> pInputStream, bool fileinfo) +CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(const std::shared_ptr<CDVDInputStream>& pInputStream, + bool fileinfo) { if (!pInputStream) return NULL; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.h index e01a972e6a..1d2bddf12b 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.h @@ -16,5 +16,6 @@ class CDVDInputStream; class CDVDFactoryDemuxer { public: - static CDVDDemux* CreateDemuxer(std::shared_ptr<CDVDInputStream> pInputStream, bool fileinfo = false); + static CDVDDemux* CreateDemuxer(const std::shared_ptr<CDVDInputStream>& pInputStream, + bool fileinfo = false); }; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp index c34db5f3c5..5de1c4ca99 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp @@ -12,7 +12,7 @@ #include "DVDFactoryDemuxer.h" #include "DVDInputStreams/DVDInputStream.h" #include "Util.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/log.h" @@ -114,7 +114,7 @@ int CDemuxMultiSource::GetStreamLength() return length; } -bool CDemuxMultiSource::Open(std::shared_ptr<CDVDInputStream> pInput) +bool CDemuxMultiSource::Open(const std::shared_ptr<CDVDInputStream>& pInput) { if (!pInput) return false; @@ -216,7 +216,7 @@ bool CDemuxMultiSource::SeekTime(double time, bool backwards, double* startpts) return ret; } -void CDemuxMultiSource::SetMissingStreamDetails(DemuxPtr demuxer) +void CDemuxMultiSource::SetMissingStreamDetails(const DemuxPtr& demuxer) { std::string baseFileName = m_pInput->GetFileName(); std::string fileName = demuxer->GetFileName(); diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.h b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.h index 0d0c7e5bea..4406fd9607 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.h +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.h @@ -20,7 +20,7 @@ typedef std::shared_ptr<CDVDDemux> DemuxPtr; struct comparator{ - bool operator() (std::pair<double, DemuxPtr> x, std::pair<double, DemuxPtr> y) const + bool operator()(const std::pair<double, DemuxPtr>& x, const std::pair<double, DemuxPtr>& y) const { return x.first > y.first; } @@ -35,7 +35,7 @@ public: CDemuxMultiSource(); ~CDemuxMultiSource() override; - bool Open(std::shared_ptr<CDVDInputStream> pInput); + bool Open(const std::shared_ptr<CDVDInputStream>& pInput); // implementation of CDVDDemux void Abort() override; @@ -55,7 +55,7 @@ protected: private: void Dispose(); - void SetMissingStreamDetails(DemuxPtr demuxer); + void SetMissingStreamDetails(const DemuxPtr& demuxer); std::shared_ptr<InputStreamMultiStreams> m_pInput = NULL; std::map<DemuxPtr, InputStreamPtr> m_DemuxerToInputStreamMap; diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp index 16ddea9f4e..bb0f3996ec 100644 --- a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp +++ b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp @@ -132,7 +132,7 @@ bool CDVDFileInfo::ExtractThumb(const CFileItem& fileItem, if (pStreamDetails) { - const std::string strPath = item.GetPath(); + const std::string& strPath = item.GetPath(); DemuxerToStreamDetails(pInputStream, pDemuxer, *pStreamDetails, strPath); //extern subtitles @@ -349,7 +349,10 @@ bool CDVDFileInfo::GetFileStreamDetails(CFileItem *pItem) } } -bool CDVDFileInfo::DemuxerToStreamDetails(std::shared_ptr<CDVDInputStream> pInputStream, CDVDDemux *pDemuxer, const std::vector<CStreamDetailSubtitle> &subs, CStreamDetails &details) +bool CDVDFileInfo::DemuxerToStreamDetails(const std::shared_ptr<CDVDInputStream>& pInputStream, + CDVDDemux* pDemuxer, + const std::vector<CStreamDetailSubtitle>& subs, + CStreamDetails& details) { bool result = DemuxerToStreamDetails(pInputStream, pDemuxer, details); for (unsigned int i = 0; i < subs.size(); i++) @@ -363,7 +366,10 @@ bool CDVDFileInfo::DemuxerToStreamDetails(std::shared_ptr<CDVDInputStream> pInpu } /* returns true if details have been added */ -bool CDVDFileInfo::DemuxerToStreamDetails(std::shared_ptr<CDVDInputStream> pInputStream, CDVDDemux *pDemux, CStreamDetails &details, const std::string &path) +bool CDVDFileInfo::DemuxerToStreamDetails(const std::shared_ptr<CDVDInputStream>& pInputStream, + CDVDDemux* pDemux, + CStreamDetails& details, + const std::string& path) { bool retVal = false; details.Reset(); diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.h b/xbmc/cores/VideoPlayer/DVDFileInfo.h index 86e4d59a9f..bb0a7ab1f6 100644 --- a/xbmc/cores/VideoPlayer/DVDFileInfo.h +++ b/xbmc/cores/VideoPlayer/DVDFileInfo.h @@ -30,12 +30,18 @@ public: // Probe the files streams and store the info in the VideoInfoTag static bool GetFileStreamDetails(CFileItem *pItem); - static bool DemuxerToStreamDetails(std::shared_ptr<CDVDInputStream> pInputStream, CDVDDemux *pDemux, CStreamDetails &details, const std::string &path = ""); + static bool DemuxerToStreamDetails(const std::shared_ptr<CDVDInputStream>& pInputStream, + CDVDDemux* pDemux, + CStreamDetails& details, + const std::string& path = ""); /** \brief Probe the file's internal and external streams and store the info in the StreamDetails parameter. * \param[out] details The file's StreamDetails consisting of internal streams and external subtitle streams. */ - static bool DemuxerToStreamDetails(std::shared_ptr<CDVDInputStream> pInputStream, CDVDDemux *pDemuxer, const std::vector<CStreamDetailSubtitle> &subs, CStreamDetails &details); + static bool DemuxerToStreamDetails(const std::shared_ptr<CDVDInputStream>& pInputStream, + CDVDDemux* pDemuxer, + const std::vector<CStreamDetailSubtitle>& subs, + CStreamDetails& details); static bool GetFileDuration(const std::string &path, int &duration); diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp index c94a615051..094eeb77d0 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp @@ -24,7 +24,7 @@ #include "ServiceBroker.h" #include "URL.h" #include "Util.h" -#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" +#include "cores/VideoPlayer/Interface/InputStreamConstants.h" #include "filesystem/CurlFile.h" #include "filesystem/File.h" #include "filesystem/IFileTypes.h" @@ -36,7 +36,7 @@ std::shared_ptr<CDVDInputStream> CDVDFactoryInputStream::CreateInputStream(IVide { using namespace ADDON; - std::string file = fileitem.GetDynPath(); + const std::string& file = fileitem.GetDynPath(); if (scanforextaudio) { // find any available external audio tracks @@ -52,7 +52,7 @@ std::shared_ptr<CDVDInputStream> CDVDFactoryInputStream::CreateInputStream(IVide std::vector<AddonInfoPtr> addonInfos; CServiceBroker::GetAddonMgr().GetAddonInfos(addonInfos, true /*enabled only*/, ADDON_INPUTSTREAM); - for (auto addonInfo : addonInfos) + for (const auto& addonInfo : addonInfos) { if (CInputStreamAddon::Supports(addonInfo, fileitem)) { diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.cpp index e06456f73d..fee72acd53 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.cpp @@ -9,7 +9,7 @@ #include "DVDInputStream.h" #include "URL.h" -#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" +#include "cores/VideoPlayer/Interface/InputStreamConstants.h" CDVDInputStream::CDVDInputStream(DVDStreamType streamType, const CFileItem& fileitem) { diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h index a732fc6ea2..270c9bdff3 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStream.h @@ -186,7 +186,7 @@ public: virtual ITimes* GetITimes() { return nullptr; } virtual IChapter* GetIChapter() { return nullptr; } - const CVariant &GetProperty(const std::string key){ return m_item.GetProperty(key); } + const CVariant& GetProperty(const std::string& key) { return m_item.GetProperty(key); } protected: DVDStreamType m_streamType; diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp index 93ec1639a0..00d52add9f 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp @@ -156,7 +156,7 @@ bool CDVDInputStreamBluray::Open() { //get rid of the udf:// protocol CURL url2(root); - std::string root2 = url2.GetHostName(); + const std::string& root2 = url2.GetHostName(); CURL url(root2); CFileItem item(url, false); diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp index c37d8321e3..b6aecc7ce7 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp @@ -11,9 +11,9 @@ #include "addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h" #include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h" #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxCrypto.h" -#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxCrypto.h" +#include "cores/VideoPlayer/Interface/InputStreamConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "filesystem/SpecialProtocol.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" @@ -39,7 +39,6 @@ void CInputStreamProvider::GetAddonInstance(INSTANCE_TYPE instance_type, /*****************************************************************************************************************/ using namespace ADDON; -using namespace kodi::addon; CInputStreamAddon::CInputStreamAddon(const AddonInfoPtr& addonInfo, IVideoPlayer* player, @@ -141,7 +140,7 @@ bool CInputStreamAddon::Open() if (CreateInstance(&m_struct) != ADDON_STATUS_OK || !m_struct.toAddon->open) return false; - INPUTSTREAM props = { 0 }; + INPUTSTREAM_PROPERTY props = {0}; std::map<std::string, std::string> propsMap; for (auto &key : m_fileItemProps) { @@ -247,18 +246,18 @@ int CInputStreamAddon::GetBlockSize() bool CInputStreamAddon::CanSeek() { - return (m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_SEEK) != 0; + return (m_caps.m_mask & INPUTSTREAM_SUPPORTS_SEEK) != 0; } bool CInputStreamAddon::CanPause() { - return (m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_PAUSE) != 0; + return (m_caps.m_mask & INPUTSTREAM_SUPPORTS_PAUSE) != 0; } // IDisplayTime CDVDInputStream::IDisplayTime* CInputStreamAddon::GetIDisplayTime() { - if ((m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_IDISPLAYTIME) == 0) + if ((m_caps.m_mask & INPUTSTREAM_SUPPORTS_IDISPLAYTIME) == 0) return nullptr; return this; @@ -283,7 +282,7 @@ int CInputStreamAddon::GetTime() // ITime CDVDInputStream::ITimes* CInputStreamAddon::GetITimes() { - if ((m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_ITIME) == 0) + if ((m_caps.m_mask & INPUTSTREAM_SUPPORTS_ITIME) == 0) return nullptr; return this; @@ -310,7 +309,7 @@ bool CInputStreamAddon::GetTimes(Times ×) // IPosTime CDVDInputStream::IPosTime* CInputStreamAddon::GetIPosTime() { - if ((m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_IPOSTIME) == 0) + if ((m_caps.m_mask & INPUTSTREAM_SUPPORTS_IPOSTIME) == 0) return nullptr; return this; @@ -327,7 +326,7 @@ bool CInputStreamAddon::PosTime(int ms) // IDemux CDVDInputStream::IDemux* CInputStreamAddon::GetIDemux() { - if ((m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_IDEMUX) == 0) + if ((m_caps.m_mask & INPUTSTREAM_SUPPORTS_IDEMUX) == 0) return nullptr; return this; @@ -335,7 +334,7 @@ CDVDInputStream::IDemux* CInputStreamAddon::GetIDemux() bool CInputStreamAddon::OpenDemux() { - if ((m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_IDEMUX) != 0) + if ((m_caps.m_mask & INPUTSTREAM_SUPPORTS_IDEMUX) != 0) return true; else return false; @@ -346,15 +345,16 @@ DemuxPacket* CInputStreamAddon::ReadDemux() if (!m_struct.toAddon->demux_read) return nullptr; - return m_struct.toAddon->demux_read(&m_struct); + return static_cast<DemuxPacket*>(m_struct.toAddon->demux_read(&m_struct)); } std::vector<CDemuxStream*> CInputStreamAddon::GetStreams() const { std::vector<CDemuxStream*> streams; - INPUTSTREAM_IDS streamIDs = m_struct.toAddon->get_stream_ids(&m_struct); - if (streamIDs.m_streamCount > INPUTSTREAM_MAX_STREAM_COUNT) + INPUTSTREAM_IDS streamIDs = {0}; + bool ret = m_struct.toAddon->get_stream_ids(&m_struct, &streamIDs); + if (!ret || streamIDs.m_streamCount > INPUTSTREAM_MAX_STREAM_COUNT) return streams; for (unsigned int i = 0; i < streamIDs.m_streamCount; ++i) @@ -366,15 +366,29 @@ std::vector<CDemuxStream*> CInputStreamAddon::GetStreams() const CDemuxStream* CInputStreamAddon::GetStream(int streamId) const { - INPUTSTREAM_INFO stream = m_struct.toAddon->get_stream(&m_struct, streamId); - if (stream.m_streamType == INPUTSTREAM_INFO::TYPE_NONE) + INPUTSTREAM_INFO stream{}; + KODI_HANDLE demuxStream = nullptr; + bool ret = m_struct.toAddon->get_stream(&m_struct, streamId, &stream, &demuxStream, + cb_get_stream_transfer); + if (!ret || stream.m_streamType == INPUTSTREAM_TYPE_NONE) return nullptr; - std::string codecName(stream.m_codecName); + return static_cast<CDemuxStream*>(demuxStream); +} + +KODI_HANDLE CInputStreamAddon::cb_get_stream_transfer(KODI_HANDLE handle, + int streamId, + INPUTSTREAM_INFO* stream) +{ + CInputStreamAddon* thisClass = static_cast<CInputStreamAddon*>(handle); + if (!thisClass || !stream) + return nullptr; + + std::string codecName(stream->m_codecName); AVCodec* codec = nullptr; - if (stream.m_streamType != INPUTSTREAM_INFO::TYPE_TELETEXT && - stream.m_streamType != INPUTSTREAM_INFO::TYPE_RDS) + if (stream->m_streamType != INPUTSTREAM_TYPE_TELETEXT && + stream->m_streamType != INPUTSTREAM_TYPE_RDS) { StringUtils::ToLower(codecName); codec = avcodec_find_decoder_by_name(codecName.c_str()); @@ -382,79 +396,79 @@ CDemuxStream* CInputStreamAddon::GetStream(int streamId) const return nullptr; } - CDemuxStream *demuxStream; + CDemuxStream* demuxStream; - if (stream.m_streamType == INPUTSTREAM_INFO::TYPE_AUDIO) + if (stream->m_streamType == INPUTSTREAM_TYPE_AUDIO) { CDemuxStreamAudio *audioStream = new CDemuxStreamAudio(); - audioStream->iChannels = stream.m_Channels; - audioStream->iSampleRate = stream.m_SampleRate; - audioStream->iBlockAlign = stream.m_BlockAlign; - audioStream->iBitRate = stream.m_BitRate; - audioStream->iBitsPerSample = stream.m_BitsPerSample; + audioStream->iChannels = stream->m_Channels; + audioStream->iSampleRate = stream->m_SampleRate; + audioStream->iBlockAlign = stream->m_BlockAlign; + audioStream->iBitRate = stream->m_BitRate; + audioStream->iBitsPerSample = stream->m_BitsPerSample; demuxStream = audioStream; } - else if (stream.m_streamType == INPUTSTREAM_INFO::TYPE_VIDEO) + else if (stream->m_streamType == INPUTSTREAM_TYPE_VIDEO) { CDemuxStreamVideo *videoStream = new CDemuxStreamVideo(); - videoStream->iFpsScale = stream.m_FpsScale; - videoStream->iFpsRate = stream.m_FpsRate; - videoStream->iWidth = stream.m_Width; - videoStream->iHeight = stream.m_Height; - videoStream->fAspect = stream.m_Aspect; - videoStream->iBitRate = stream.m_BitRate; - videoStream->profile = ConvertVideoCodecProfile(stream.m_codecProfile); + videoStream->iFpsScale = stream->m_FpsScale; + videoStream->iFpsRate = stream->m_FpsRate; + videoStream->iWidth = stream->m_Width; + videoStream->iHeight = stream->m_Height; + videoStream->fAspect = stream->m_Aspect; + videoStream->iBitRate = stream->m_BitRate; + videoStream->profile = ConvertVideoCodecProfile(stream->m_codecProfile); /*! Added on API version 2.0.8 */ //@{ - videoStream->colorSpace = static_cast<AVColorSpace>(stream.m_colorSpace); - videoStream->colorRange = static_cast<AVColorRange>(stream.m_colorRange); + videoStream->colorSpace = static_cast<AVColorSpace>(stream->m_colorSpace); + videoStream->colorRange = static_cast<AVColorRange>(stream->m_colorRange); //@} /*! Added on API version 2.0.9 */ //@{ - videoStream->colorPrimaries = static_cast<AVColorPrimaries>(stream.m_colorPrimaries); + videoStream->colorPrimaries = static_cast<AVColorPrimaries>(stream->m_colorPrimaries); videoStream->colorTransferCharacteristic = - static_cast<AVColorTransferCharacteristic>(stream.m_colorTransferCharacteristic); + static_cast<AVColorTransferCharacteristic>(stream->m_colorTransferCharacteristic); - if (stream.m_masteringMetadata) + if (stream->m_masteringMetadata) { videoStream->masteringMetaData = std::shared_ptr<AVMasteringDisplayMetadata>(new AVMasteringDisplayMetadata); videoStream->masteringMetaData->display_primaries[0][0] = - av_d2q(stream.m_masteringMetadata->primary_r_chromaticity_x, INT_MAX); + av_d2q(stream->m_masteringMetadata->primary_r_chromaticity_x, INT_MAX); videoStream->masteringMetaData->display_primaries[0][1] = - av_d2q(stream.m_masteringMetadata->primary_r_chromaticity_y, INT_MAX); + av_d2q(stream->m_masteringMetadata->primary_r_chromaticity_y, INT_MAX); videoStream->masteringMetaData->display_primaries[1][0] = - av_d2q(stream.m_masteringMetadata->primary_g_chromaticity_x, INT_MAX); + av_d2q(stream->m_masteringMetadata->primary_g_chromaticity_x, INT_MAX); videoStream->masteringMetaData->display_primaries[1][1] = - av_d2q(stream.m_masteringMetadata->primary_g_chromaticity_y, INT_MAX); + av_d2q(stream->m_masteringMetadata->primary_g_chromaticity_y, INT_MAX); videoStream->masteringMetaData->display_primaries[2][0] = - av_d2q(stream.m_masteringMetadata->primary_b_chromaticity_x, INT_MAX); + av_d2q(stream->m_masteringMetadata->primary_b_chromaticity_x, INT_MAX); videoStream->masteringMetaData->display_primaries[2][1] = - av_d2q(stream.m_masteringMetadata->primary_b_chromaticity_y, INT_MAX); + av_d2q(stream->m_masteringMetadata->primary_b_chromaticity_y, INT_MAX); videoStream->masteringMetaData->white_point[0] = - av_d2q(stream.m_masteringMetadata->white_point_chromaticity_x, INT_MAX); + av_d2q(stream->m_masteringMetadata->white_point_chromaticity_x, INT_MAX); videoStream->masteringMetaData->white_point[1] = - av_d2q(stream.m_masteringMetadata->white_point_chromaticity_y, INT_MAX); + av_d2q(stream->m_masteringMetadata->white_point_chromaticity_y, INT_MAX); videoStream->masteringMetaData->min_luminance = - av_d2q(stream.m_masteringMetadata->luminance_min, INT_MAX); + av_d2q(stream->m_masteringMetadata->luminance_min, INT_MAX); videoStream->masteringMetaData->max_luminance = - av_d2q(stream.m_masteringMetadata->luminance_max, INT_MAX); + av_d2q(stream->m_masteringMetadata->luminance_max, INT_MAX); videoStream->masteringMetaData->has_luminance = videoStream->masteringMetaData->has_primaries = 1; } - if (stream.m_contentLightMetadata) + if (stream->m_contentLightMetadata) { videoStream->contentLightMetaData = std::shared_ptr<AVContentLightMetadata>(new AVContentLightMetadata); videoStream->contentLightMetaData->MaxCLL = - static_cast<unsigned>(stream.m_contentLightMetadata->max_cll); + static_cast<unsigned>(stream->m_contentLightMetadata->max_cll); videoStream->contentLightMetaData->MaxFALL = - static_cast<unsigned>(stream.m_contentLightMetadata->max_fall); + static_cast<unsigned>(stream->m_contentLightMetadata->max_fall); } //@} @@ -465,19 +479,20 @@ CDemuxStream* CInputStreamAddon::GetStream(int streamId) const } */ + demuxStream = videoStream; } - else if (stream.m_streamType == INPUTSTREAM_INFO::TYPE_SUBTITLE) + else if (stream->m_streamType == INPUTSTREAM_TYPE_SUBTITLE) { CDemuxStreamSubtitle *subtitleStream = new CDemuxStreamSubtitle(); demuxStream = subtitleStream; } - else if (stream.m_streamType == INPUTSTREAM_INFO::TYPE_TELETEXT) + else if (stream->m_streamType == INPUTSTREAM_TYPE_TELETEXT) { CDemuxStreamTeletext* teletextStream = new CDemuxStreamTeletext(); demuxStream = teletextStream; } - else if (stream.m_streamType == INPUTSTREAM_INFO::TYPE_RDS) + else if (stream->m_streamType == INPUTSTREAM_TYPE_RDS) { CDemuxStreamRadioRDS* rdsStream = new CDemuxStreamRadioRDS(); demuxStream = rdsStream; @@ -485,32 +500,32 @@ CDemuxStream* CInputStreamAddon::GetStream(int streamId) const else return nullptr; - demuxStream->name = stream.m_name; + demuxStream->name = stream->m_name; if (codec) demuxStream->codec = codec->id; else demuxStream->codec = AV_CODEC_ID_DVB_TELETEXT; - demuxStream->codecName = stream.m_codecInternalName; + demuxStream->codecName = stream->m_codecInternalName; demuxStream->uniqueId = streamId; - demuxStream->flags = static_cast<StreamFlags>(stream.m_flags); - demuxStream->language = stream.m_language; + demuxStream->flags = static_cast<StreamFlags>(stream->m_flags); + demuxStream->language = stream->m_language; - if (GetAddonInfo()->DependencyVersion(ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID) >= + if (thisClass->GetAddonInfo()->DependencyVersion(ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID) >= AddonVersion("2.0.8")) { - demuxStream->codec_fourcc = stream.m_codecFourCC; + demuxStream->codec_fourcc = stream->m_codecFourCC; } - if (stream.m_ExtraData && stream.m_ExtraSize) + if (stream->m_ExtraData && stream->m_ExtraSize) { - demuxStream->ExtraData = new uint8_t[stream.m_ExtraSize]; - demuxStream->ExtraSize = stream.m_ExtraSize; - for (unsigned int j = 0; j < stream.m_ExtraSize; ++j) - demuxStream->ExtraData[j] = stream.m_ExtraData[j]; + demuxStream->ExtraData = new uint8_t[stream->m_ExtraSize]; + demuxStream->ExtraSize = stream->m_ExtraSize; + for (unsigned int j = 0; j < stream->m_ExtraSize; ++j) + demuxStream->ExtraData[j] = stream->m_ExtraData[j]; } - if (stream.m_cryptoInfo.m_CryptoKeySystem != CRYPTO_INFO::CRYPTO_KEY_SYSTEM_NONE && - stream.m_cryptoInfo.m_CryptoKeySystem < CRYPTO_INFO::CRYPTO_KEY_SYSTEM_COUNT) + if (stream->m_cryptoSession.keySystem != STREAM_CRYPTO_KEY_SYSTEM_NONE && + stream->m_cryptoSession.keySystem < STREAM_CRYPTO_KEY_SYSTEM_COUNT) { static const CryptoSessionSystem map[] = { CRYPTO_SESSION_SYSTEM_NONE, @@ -519,10 +534,11 @@ CDemuxStream* CInputStreamAddon::GetStream(int streamId) const CRYPTO_SESSION_SYSTEM_WISEPLAY, }; demuxStream->cryptoSession = std::shared_ptr<DemuxCryptoSession>(new DemuxCryptoSession( - map[stream.m_cryptoInfo.m_CryptoKeySystem], stream.m_cryptoInfo.m_CryptoSessionIdSize, stream.m_cryptoInfo.m_CryptoSessionId, stream.m_cryptoInfo.flags)); + map[stream->m_cryptoSession.keySystem], stream->m_cryptoSession.sessionIdSize, + stream->m_cryptoSession.sessionId, stream->m_cryptoSession.flags)); - if ((stream.m_features & INPUTSTREAM_INFO::FEATURE_DECODE) != 0) - demuxStream->externalInterfaces = m_subAddonProvider; + if ((stream->m_features & INPUTSTREAM_FEATURE_DECODE) != 0) + demuxStream->externalInterfaces = thisClass->m_subAddonProvider; } return demuxStream; } @@ -561,7 +577,7 @@ bool CInputStreamAddon::SeekTime(double time, bool backward, double* startpts) if (!m_struct.toAddon->demux_seek_time) return false; - if ((m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_IPOSTIME) != 0) + if ((m_caps.m_mask & INPUTSTREAM_SUPPORTS_IPOSTIME) != 0) { if (!PosTime(static_cast<int>(time))) return false; @@ -605,7 +621,7 @@ bool CInputStreamAddon::IsRealtime() // IChapter CDVDInputStream::IChapter* CInputStreamAddon::GetIChapter() { - if ((m_caps.m_mask & INPUTSTREAM_CAPABILITIES::SUPPORTS_ICHAPTER) == 0) + if ((m_caps.m_mask & INPUTSTREAM_SUPPORTS_ICHAPTER) == 0) return nullptr; return this; @@ -689,19 +705,20 @@ int CInputStreamAddon::ConvertVideoCodecProfile(STREAMCODEC_PROFILE profile) * Callbacks from add-on to kodi */ //@{ -DemuxPacket* CInputStreamAddon::cb_allocate_demux_packet(void* kodiInstance, int data_size) +DEMUX_PACKET* CInputStreamAddon::cb_allocate_demux_packet(void* kodiInstance, int data_size) { return CDVDDemuxUtils::AllocateDemuxPacket(data_size); } -DemuxPacket* CInputStreamAddon::cb_allocate_encrypted_demux_packet(void* kodiInstance, unsigned int dataSize, unsigned int encryptedSubsampleCount) +DEMUX_PACKET* CInputStreamAddon::cb_allocate_encrypted_demux_packet( + void* kodiInstance, unsigned int dataSize, unsigned int encryptedSubsampleCount) { return CDVDDemuxUtils::AllocateDemuxPacket(dataSize, encryptedSubsampleCount); } -void CInputStreamAddon::cb_free_demux_packet(void* kodiInstance, DemuxPacket* packet) +void CInputStreamAddon::cb_free_demux_packet(void* kodiInstance, DEMUX_PACKET* packet) { - CDVDDemuxUtils::FreeDemuxPacket(packet); + CDVDDemuxUtils::FreeDemuxPacket(static_cast<DemuxPacket*>(packet)); } //@} diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h index 9dc669a78b..c1ff487524 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h @@ -124,7 +124,7 @@ private: * @param iDataSize The size of the data that will go into the packet * @return The allocated packet. */ - static DemuxPacket* cb_allocate_demux_packet(void* kodiInstance, int iDataSize = 0); + static DEMUX_PACKET* cb_allocate_demux_packet(void* kodiInstance, int iDataSize = 0); /*! * @brief Allocate an encrypted demux packet. Free with FreeDemuxPacket @@ -133,13 +133,30 @@ private: * @param encryptedSubsampleCount The number of subsample description blocks to allocate * @return The allocated packet. */ - static DemuxPacket* cb_allocate_encrypted_demux_packet(void* kodiInstance, unsigned int dataSize, unsigned int encryptedSubsampleCount); + static DEMUX_PACKET* cb_allocate_encrypted_demux_packet(void* kodiInstance, + unsigned int dataSize, + unsigned int encryptedSubsampleCount); /*! * @brief Free a packet that was allocated with AllocateDemuxPacket * @param kodiInstance A pointer to the add-on. * @param pPacket The packet to free. */ - static void cb_free_demux_packet(void* kodiInstance, DemuxPacket* pPacket); + static void cb_free_demux_packet(void* kodiInstance, DEMUX_PACKET* pPacket); + + /*! + * @brief Callback used by @ref GetStream to get the data + * + * Used as callback to prevent memleaks as the temporary stack memory on addon + * can be used to give data to Kodi. + * + * @param[in] handle Pointer to identify this class + * @param[in] streamId The related stream Identifier + * @param[in] stream "C" structure with stream information + * @return The created demux stream packet + */ + static KODI_HANDLE cb_get_stream_transfer(KODI_HANDLE handle, + int streamId, + INPUTSTREAM_INFO* stream); //@} }; diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamMultiSource.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamMultiSource.cpp index d7d4692bb3..fc86e59792 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamMultiSource.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamMultiSource.cpp @@ -30,7 +30,7 @@ CInputStreamMultiSource::~CInputStreamMultiSource() void CInputStreamMultiSource::Abort() { - for (auto iter : m_InputStreams) + for (const auto& iter : m_InputStreams) iter->Abort(); } @@ -58,7 +58,7 @@ bool CInputStreamMultiSource::GetCacheStatus(XFILE::SCacheStatus *status) int64_t CInputStreamMultiSource::GetLength() { int64_t length = 0; - for (auto iter : m_InputStreams) + for (const auto& iter : m_InputStreams) { length = std::max(length, iter->GetLength()); } @@ -71,7 +71,7 @@ bool CInputStreamMultiSource::IsEOF() if (m_InputStreams.empty()) return true; - for (auto iter : m_InputStreams) + for (const auto& iter : m_InputStreams) { if (!(iter->IsEOF())) return false; @@ -88,7 +88,7 @@ CDVDInputStream::ENextStream CInputStreamMultiSource::NextStream() CDVDInputStream::ENextStream next; - for (auto iter : m_InputStreams) + for (const auto& iter : m_InputStreams) { next = iter->NextStream(); if (next != NEXTSTREAM_NONE) @@ -136,6 +136,6 @@ int64_t CInputStreamMultiSource::Seek(int64_t offset, int whence) void CInputStreamMultiSource::SetReadRate(unsigned rate) { - for (auto iter : m_InputStreams) + for (const auto& iter : m_InputStreams) iter->SetReadRate(rate); } diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp index 9262999536..b8c6bff337 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp @@ -10,7 +10,7 @@ #include "ServiceBroker.h" #include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" #include "pvr/PVRManager.h" #include "pvr/addons/PVRClient.h" #include "settings/Settings.h" diff --git a/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp b/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp index b26a45413d..b7402b5c97 100644 --- a/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp +++ b/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp @@ -8,8 +8,8 @@ #include "DVDMessageQueue.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "threads/SingleLock.h" #include "utils/log.h" diff --git a/xbmc/cores/VideoPlayer/DVDOverlayContainer.cpp b/xbmc/cores/VideoPlayer/DVDOverlayContainer.cpp index 8bfed844a3..756f72419b 100644 --- a/xbmc/cores/VideoPlayer/DVDOverlayContainer.cpp +++ b/xbmc/cores/VideoPlayer/DVDOverlayContainer.cpp @@ -157,7 +157,8 @@ bool CDVDOverlayContainer::ContainsOverlayType(DVDOverlayType type) /* * iAction should be LIBDVDNAV_BUTTON_NORMAL or LIBDVDNAV_BUTTON_CLICKED */ -void CDVDOverlayContainer::UpdateOverlayInfo(std::shared_ptr<CDVDInputStreamNavigator> pStream, CDVDDemuxSPU *pSpu, int iAction) +void CDVDOverlayContainer::UpdateOverlayInfo( + const std::shared_ptr<CDVDInputStreamNavigator>& pStream, CDVDDemuxSPU* pSpu, int iAction) { CSingleLock lock(*this); diff --git a/xbmc/cores/VideoPlayer/DVDOverlayContainer.h b/xbmc/cores/VideoPlayer/DVDOverlayContainer.h index 6d2e89b5e2..97cc49eb9c 100644 --- a/xbmc/cores/VideoPlayer/DVDOverlayContainer.h +++ b/xbmc/cores/VideoPlayer/DVDOverlayContainer.h @@ -43,7 +43,10 @@ public: void CleanUp(double pts); // validates all overlays against current pts int GetSize(); - void UpdateOverlayInfo(std::shared_ptr<CDVDInputStreamNavigator> pStream, CDVDDemuxSPU *pSpu, int iAction); + void UpdateOverlayInfo(const std::shared_ptr<CDVDInputStreamNavigator>& pStream, + CDVDDemuxSPU* pSpu, + int iAction); + private: VecOverlaysIter Remove(VecOverlaysIter itOverlay); // removes a specific overlay diff --git a/xbmc/cores/VideoPlayer/DVDStreamInfo.cpp b/xbmc/cores/VideoPlayer/DVDStreamInfo.cpp index 90804b4752..a30becd31f 100644 --- a/xbmc/cores/VideoPlayer/DVDStreamInfo.cpp +++ b/xbmc/cores/VideoPlayer/DVDStreamInfo.cpp @@ -9,7 +9,7 @@ #include "DVDStreamInfo.h" #include "DVDDemuxers/DVDDemux.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxCrypto.h" +#include "cores/VideoPlayer/Interface/DemuxCrypto.h" CDVDStreamInfo::CDVDStreamInfo() { extradata = NULL; Clear(); } CDVDStreamInfo::CDVDStreamInfo(const CDVDStreamInfo &right, bool withextradata ) { extradata = NULL; Clear(); Assign(right, withextradata); } diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMPL2.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMPL2.cpp index 3c20765407..7a5b2a3e12 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMPL2.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMPL2.cpp @@ -11,7 +11,7 @@ #include "DVDCodecs/Overlay/DVDOverlayText.h" #include "DVDStreamInfo.h" #include "DVDSubtitleTagMicroDVD.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/RegExp.h" CDVDSubtitleParserMPL2::CDVDSubtitleParserMPL2(std::unique_ptr<CDVDSubtitleStream> && stream, const std::string& filename) diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMicroDVD.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMicroDVD.cpp index 9296a1e432..891fa598e8 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMicroDVD.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserMicroDVD.cpp @@ -11,7 +11,7 @@ #include "DVDCodecs/Overlay/DVDOverlayText.h" #include "DVDStreamInfo.h" #include "DVDSubtitleTagMicroDVD.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/RegExp.h" #include "utils/log.h" diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSSA.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSSA.cpp index b9e845167f..487ea8cc38 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSSA.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSSA.cpp @@ -9,7 +9,7 @@ #include "DVDSubtitleParserSSA.h" #include "DVDCodecs/Overlay/DVDOverlaySSA.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/log.h" CDVDSubtitleParserSSA::CDVDSubtitleParserSSA(std::unique_ptr<CDVDSubtitleStream> && pStream, const std::string& strFile) diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSami.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSami.cpp index e103b3bbac..c3685851bf 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSami.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSami.cpp @@ -11,7 +11,7 @@ #include "DVDCodecs/Overlay/DVDOverlayText.h" #include "DVDStreamInfo.h" #include "DVDSubtitleTagSami.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/RegExp.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp index 9755e804b6..a6ff4905a0 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp @@ -10,7 +10,7 @@ #include "DVDCodecs/Overlay/DVDOverlayText.h" #include "DVDSubtitleTagSami.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/StringUtils.h" CDVDSubtitleParserSubrip::CDVDSubtitleParserSubrip(std::unique_ptr<CDVDSubtitleStream> && pStream, const std::string& strFile) diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserVplayer.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserVplayer.cpp index 5ea4b71717..31fdc74936 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserVplayer.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserVplayer.cpp @@ -9,7 +9,7 @@ #include "DVDSubtitleParserVplayer.h" #include "DVDCodecs/Overlay/DVDOverlayText.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/RegExp.h" CDVDSubtitleParserVplayer::CDVDSubtitleParserVplayer(std::unique_ptr<CDVDSubtitleStream> && pStream, const std::string& strFile) diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp index ea15dfc4da..ac37f0b4bc 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp @@ -9,7 +9,7 @@ #include "DVDSubtitlesLibass.h" #include "ServiceBroker.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "filesystem/File.h" #include "filesystem/SpecialProtocol.h" #include "settings/Settings.h" diff --git a/xbmc/cores/VideoPlayer/Edl.cpp b/xbmc/cores/VideoPlayer/Edl.cpp index 51c14ed5ac..6c09e64325 100644 --- a/xbmc/cores/VideoPlayer/Edl.cpp +++ b/xbmc/cores/VideoPlayer/Edl.cpp @@ -51,7 +51,7 @@ bool CEdl::ReadEditDecisionLists(const CFileItem& fileItem, const float fFramesP * Only check for edit decision lists if the movie is on the local hard drive, or accessed over a * network share. */ - const std::string strMovie = fileItem.GetDynPath(); + const std::string& strMovie = fileItem.GetDynPath(); if ((URIUtils::IsHD(strMovie) || URIUtils::IsOnLAN(strMovie)) && !URIUtils::IsInternetStream(strMovie)) { @@ -147,7 +147,7 @@ bool CEdl::ReadEdl(const std::string& strMovie, const float fFramesPerSecond) int64_t iCutStartEnd[2]; for (int i = 0; i < 2; i++) { - if (strFields[i].find(":") != std::string::npos) // HH:MM:SS.sss format + if (strFields[i].find(':') != std::string::npos) // HH:MM:SS.sss format { std::vector<std::string> fieldParts = StringUtils::Split(strFields[i], '.'); if (fieldParts.size() == 1) // No ms diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxPacket.h b/xbmc/cores/VideoPlayer/Interface/Addon/DemuxPacket.h deleted file mode 100644 index 7f3f85d070..0000000000 --- a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxPacket.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2012-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#pragma once - -#include "TimingConstants.h" - -#include <cstdint> -#include <memory> - -#define DMX_SPECIALID_STREAMINFO -10 -#define DMX_SPECIALID_STREAMCHANGE -11 - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - struct DemuxCryptoInfo; - - typedef struct DemuxPacket - { - DemuxPacket() = default; - - uint8_t* pData = nullptr; - int iSize = 0; - int iStreamId = -1; - int64_t demuxerId = -1; // id of the demuxer that created the packet - int iGroupId = - -1; // the group this data belongs to, used to group data from different streams together - - void* pSideData = nullptr; - int iSideDataElems = 0; - - double pts = DVD_NOPTS_VALUE; - double dts = DVD_NOPTS_VALUE; - double duration = 0; // duration in DVD_TIME_BASE if available - int dispTime = 0; - bool recoveryPoint = false; - - struct DemuxCryptoInfo* cryptoInfo = nullptr; - } DemuxPacket; - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/InputStreamConstants.h b/xbmc/cores/VideoPlayer/Interface/Addon/InputStreamConstants.h deleted file mode 100644 index ff4dbead10..0000000000 --- a/xbmc/cores/VideoPlayer/Interface/Addon/InputStreamConstants.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017-2019 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#pragma once - -/*! - * @brief the name of the inputstream add-on that should be used by Kodi to - * play the stream denoted by STREAM_PROPERTY_STREAMURL. Leave blank to use - * Kodi's built-in playing capabilities or to allow ffmpeg to handle directly - * set to STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG. - */ -#define STREAM_PROPERTY_INPUTSTREAM "inputstream" - -/*! - * @brief Identification string for an input stream. - * - * This value can be used in addition to @ref STREAM_PROPERTY_INPUTSTREAM. It is - * used to provide the respective inpustream addon with additional - * identification. - * - * The difference between this and other stream properties is that it is also - * passed in the associated @ref kodi::addon::CAddonBase::CreateInstance call. - * - * This makes it possible to select different processing classes within the - * associated add-on. - */ -#define STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID "inputstream-instance-id" - -/*! - * @brief "true" to denote that the stream that should be played is a - * realtime stream. Any other value indicates that this is not a realtime - * stream. - */ -#define STREAM_PROPERTY_ISREALTIMESTREAM "isrealtimestream" - -/*! - * @brief special value for STREAM_PROPERTY_INPUTSTREAM to use - * ffmpeg to directly play a stream URL. - */ -#define STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG "inputstream.ffmpeg" - -/*! - * @brief Max number of properties that can be sent to an Inputstream addon - */ -#define STREAM_MAX_PROPERTY_COUNT 30 diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxCrypto.h b/xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h index 416e159c0e..8884ae080d 100644 --- a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxCrypto.h +++ b/xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h @@ -8,7 +8,8 @@ #pragma once -#include <inttypes.h> +#include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h" + #include <string.h> //CryptoSession is usually obtained once per stream, but could change if an key expires @@ -58,14 +59,15 @@ private: //CryptoInfo stores the information to decrypt a sample -struct DemuxCryptoInfo +struct DemuxCryptoInfo : DEMUX_CRYPTO_INFO { explicit DemuxCryptoInfo(const unsigned int numSubs) - : numSubSamples(numSubs) - , flags(0) - , clearBytes(new uint16_t[numSubs]) - , cipherBytes(new uint32_t[numSubs]) - {}; + { + numSubSamples = numSubs; + flags = 0; + clearBytes = new uint16_t[numSubs]; + cipherBytes = new uint32_t[numSubs]; + }; ~DemuxCryptoInfo() { @@ -73,14 +75,6 @@ struct DemuxCryptoInfo delete[] cipherBytes; } - uint16_t numSubSamples; //number of subsamples - uint16_t flags; //flags for later use - - uint16_t *clearBytes; // numSubSamples uint16_t's wich define the size of clear size of a subsample - uint32_t *cipherBytes; // numSubSamples uint32_t's wich define the size of cipher size of a subsample - - uint8_t iv[16]; // initialization vector - uint8_t kid[16]; // key id private: DemuxCryptoInfo(const DemuxCryptoInfo&) = delete; DemuxCryptoInfo& operator=(const DemuxCryptoInfo&) = delete; diff --git a/xbmc/cores/VideoPlayer/Interface/DemuxPacket.h b/xbmc/cores/VideoPlayer/Interface/DemuxPacket.h new file mode 100644 index 0000000000..0a6bc07033 --- /dev/null +++ b/xbmc/cores/VideoPlayer/Interface/DemuxPacket.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "TimingConstants.h" +#include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h" + +#define DMX_SPECIALID_STREAMINFO DEMUX_SPECIALID_STREAMINFO +#define DMX_SPECIALID_STREAMCHANGE DEMUX_SPECIALID_STREAMCHANGE + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + struct DemuxPacket : DEMUX_PACKET + { + DemuxPacket() + { + pData = nullptr; + iSize = 0; + iStreamId = -1; + demuxerId = -1; + iGroupId = -1; + + pSideData = nullptr; + iSideDataElems = 0; + + pts = DVD_NOPTS_VALUE; + dts = DVD_NOPTS_VALUE; + duration = 0; + dispTime = 0; + recoveryPoint = false; + + cryptoInfo = nullptr; + } + }; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ diff --git a/xbmc/cores/VideoPlayer/Interface/InputStreamConstants.h b/xbmc/cores/VideoPlayer/Interface/InputStreamConstants.h new file mode 100644 index 0000000000..93eabc5e9d --- /dev/null +++ b/xbmc/cores/VideoPlayer/Interface/InputStreamConstants.h @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2017-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h" diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/TimingConstants.h b/xbmc/cores/VideoPlayer/Interface/TimingConstants.h index c94e255c20..0672002879 100644 --- a/xbmc/cores/VideoPlayer/Interface/Addon/TimingConstants.h +++ b/xbmc/cores/VideoPlayer/Interface/TimingConstants.h @@ -11,15 +11,9 @@ #define DVD_TIME_BASE 1000000 #define DVD_NOPTS_VALUE 0xFFF0000000000000 -#ifdef __cplusplus constexpr int DVD_TIME_TO_MSEC(double x) { return static_cast<int>(x * 1000 / DVD_TIME_BASE); } constexpr double DVD_SEC_TO_TIME(double x) { return x * DVD_TIME_BASE; } constexpr double DVD_MSEC_TO_TIME(double x) { return x * DVD_TIME_BASE / 1000; } -#else -#define DVD_TIME_TO_MSEC(x) ((int)((double)(x) * 1000 / DVD_TIME_BASE)) -#define DVD_SEC_TO_TIME(x) ((double)(x) * DVD_TIME_BASE) -#define DVD_MSEC_TO_TIME(x) ((double)(x) * DVD_TIME_BASE / 1000) -#endif #define DVD_PLAYSPEED_PAUSE 0 // frame stepping #define DVD_PLAYSPEED_NORMAL 1000 diff --git a/xbmc/cores/VideoPlayer/PTSTracker.cpp b/xbmc/cores/VideoPlayer/PTSTracker.cpp index 90d45876bd..70577919ad 100644 --- a/xbmc/cores/VideoPlayer/PTSTracker.cpp +++ b/xbmc/cores/VideoPlayer/PTSTracker.cpp @@ -9,7 +9,7 @@ #include "PTSTracker.h" #include "DVDCodecs/DVDCodecUtils.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "utils/StringUtils.h" #include "utils/log.h" diff --git a/xbmc/cores/VideoPlayer/Process/ProcessInfo.cpp b/xbmc/cores/VideoPlayer/Process/ProcessInfo.cpp index 99d1de5b90..60e6b78bb9 100644 --- a/xbmc/cores/VideoPlayer/Process/ProcessInfo.cpp +++ b/xbmc/cores/VideoPlayer/Process/ProcessInfo.cpp @@ -17,7 +17,7 @@ CCriticalSection createSection; std::map<std::string, CreateProcessControl> CProcessInfo::m_processControls; -void CProcessInfo::RegisterProcessControl(std::string id, CreateProcessControl createFunc) +void CProcessInfo::RegisterProcessControl(const std::string& id, CreateProcessControl createFunc) { CSingleLock lock(createSection); diff --git a/xbmc/cores/VideoPlayer/Process/ProcessInfo.h b/xbmc/cores/VideoPlayer/Process/ProcessInfo.h index 4b71236e0a..0b351af311 100644 --- a/xbmc/cores/VideoPlayer/Process/ProcessInfo.h +++ b/xbmc/cores/VideoPlayer/Process/ProcessInfo.h @@ -27,7 +27,7 @@ class CProcessInfo { public: static CProcessInfo* CreateInstance(); - static void RegisterProcessControl(std::string id, CreateProcessControl createFunc); + static void RegisterProcessControl(const std::string& id, CreateProcessControl createFunc); virtual ~CProcessInfo() = default; void SetDataCache(CDataCacheCore *cache); diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp index 5abbdeb7a3..f2203edb63 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp @@ -137,6 +137,9 @@ public: if ((ss.flags & StreamFlags::FLAG_FORCED) && (ss.flags & StreamFlags::FLAG_DEFAULT)) return false; + if (ss.language == "cc" && ss.flags & StreamFlags::FLAG_HEARING_IMPAIRED) + return false; + if(!original) { std::string subtitle_language = g_langInfo.GetSubtitleLanguage(); @@ -387,7 +390,7 @@ int CSelectionStreams::TypeIndexOf(StreamType type, int source, int64_t demuxerI return -1; } -int CSelectionStreams::Source(StreamSource source, std::string filename) +int CSelectionStreams::Source(StreamSource source, const std::string& filename) { int index = source - 1; for (size_t i=0; i<m_Streams.size(); i++) @@ -421,7 +424,9 @@ void CSelectionStreams::Update(SelectionStream& s) } } -void CSelectionStreams::Update(std::shared_ptr<CDVDInputStream> input, CDVDDemux* demuxer, std::string filename2) +void CSelectionStreams::Update(const std::shared_ptr<CDVDInputStream>& input, + CDVDDemux* demuxer, + const std::string& filename2) { if(input && input->IsStreamType(DVDSTREAM_TYPE_DVD)) { @@ -543,7 +548,7 @@ void CSelectionStreams::Update(std::shared_ptr<CDVDInputStream> input, CDVDDemux CServiceBroker::GetDataCacheCore().SignalSubtitleInfoChange(); } -void CSelectionStreams::Update(std::shared_ptr<CDVDInputStream> input, CDVDDemux* demuxer) +void CSelectionStreams::Update(const std::shared_ptr<CDVDInputStream>& input, CDVDDemux* demuxer) { Update(input, demuxer, ""); } diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.h b/xbmc/cores/VideoPlayer/VideoPlayer.h index 8661a172c1..75dc2a9050 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.h +++ b/xbmc/cores/VideoPlayer/VideoPlayer.h @@ -18,7 +18,7 @@ #include "VideoPlayerTeletext.h" #include "VideoPlayerVideo.h" #include "cores/IPlayer.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "cores/VideoPlayer/VideoRenderers/RenderManager.h" #include "guilib/DispResource.h" #include "threads/SystemClock.h" @@ -207,10 +207,12 @@ public: SelectionStream& Get(StreamType type, int index); bool Get(StreamType type, StreamFlags flag, SelectionStream& out); void Clear(StreamType type, StreamSource source); - int Source(StreamSource source, std::string filename); + int Source(StreamSource source, const std::string& filename); void Update(SelectionStream& s); - void Update(std::shared_ptr<CDVDInputStream> input, CDVDDemux* demuxer); - void Update(std::shared_ptr<CDVDInputStream> input, CDVDDemux* demuxer, std::string filename2); + void Update(const std::shared_ptr<CDVDInputStream>& input, CDVDDemux* demuxer); + void Update(const std::shared_ptr<CDVDInputStream>& input, + CDVDDemux* demuxer, + const std::string& filename2); std::vector<SelectionStream> Get(StreamType type); template<typename Compare> std::vector<SelectionStream> Get(StreamType type, Compare compare) diff --git a/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp b/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp index f93ca6c2cc..a0ca6696cc 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp @@ -6,19 +6,24 @@ * See LICENSES/README.md for more information. */ -#include "threads/SingleLock.h" #include "VideoPlayerAudio.h" -#include "ServiceBroker.h" + #include "DVDCodecs/Audio/DVDAudioCodec.h" #include "DVDCodecs/DVDFactoryCodec.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" +#include "ServiceBroker.h" +#include "cores/AudioEngine/Interfaces/AE.h" +#include "cores/AudioEngine/Utils/AEUtil.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" #include "settings/Settings.h" #include "settings/SettingsComponent.h" -#include "system.h" -#include "utils/log.h" +#include "threads/SingleLock.h" #include "utils/MathUtils.h" -#include "cores/AudioEngine/Interfaces/AE.h" -#include "cores/AudioEngine/Utils/AEUtil.h" +#include "utils/log.h" + +#include "system.h" +#ifdef TARGET_RASPBERRY_PI +#include "platform/linux/RBP.h" +#endif #include <sstream> #include <iomanip> diff --git a/xbmc/cores/VideoPlayer/VideoPlayerAudio.h b/xbmc/cores/VideoPlayer/VideoPlayerAudio.h index dc593dbd31..1c525499b6 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerAudio.h +++ b/xbmc/cores/VideoPlayer/VideoPlayerAudio.h @@ -13,7 +13,7 @@ #include "DVDMessageQueue.h" #include "DVDStreamInfo.h" #include "IVideoPlayer.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "threads/Thread.h" #include "utils/BitstreamStats.h" diff --git a/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.cpp b/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.cpp index 7c2fc9184e..da1267e01c 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.cpp @@ -31,7 +31,7 @@ #include "GUIUserMessages.h" #include "ServiceBroker.h" #include "cores/FFmpeg.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "dialogs/GUIDialogKaiToast.h" #include "guilib/GUIComponent.h" #include "guilib/GUIWindowManager.h" @@ -723,7 +723,7 @@ std::string CDVDRadioRDSData::GetRadioText(unsigned int line) return str; } -void CDVDRadioRDSData::SetRadioStyle(std::string genre) +void CDVDRadioRDSData::SetRadioStyle(const std::string& genre) { g_application.CurrentFileItem().GetMusicInfoTag()->SetGenre(genre); m_currentInfoTag->SetProgStyle(genre); diff --git a/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.h b/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.h index fc5a83cab4..f3dd30271d 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.h +++ b/xbmc/cores/VideoPlayer/VideoPlayerRadioRDS.h @@ -85,7 +85,7 @@ private: inline unsigned int DecodeTDC(uint8_t *msgElement, unsigned int len); void SendTMCSignal(unsigned int flags, uint8_t *data); - void SetRadioStyle(std::string genre); + void SetRadioStyle(const std::string& genre); std::shared_ptr<PVR::CPVRRadioRDSInfoTag> m_currentInfoTag; std::shared_ptr<PVR::CPVRChannel> m_currentChannel; diff --git a/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp b/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp index 8c90c54ab8..cd71168cbc 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp @@ -13,8 +13,8 @@ #include "DVDCodecs/Overlay/DVDOverlayCodec.h" #include "DVDCodecs/Overlay/DVDOverlaySpu.h" #include "DVDSubtitles/DVDSubtitleParser.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "threads/SingleLock.h" #include "utils/log.h" diff --git a/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.h b/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.h index cbf0a38a27..b4231cbbd5 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.h +++ b/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.h @@ -32,7 +32,10 @@ public: void FindSubtitles(const char* strFilename); int GetSubtitleCount(); - void UpdateOverlayInfo(std::shared_ptr<CDVDInputStreamNavigator> pStream, int iAction) { m_pOverlayContainer->UpdateOverlayInfo(pStream, &m_dvdspus, iAction); } + void UpdateOverlayInfo(const std::shared_ptr<CDVDInputStreamNavigator>& pStream, int iAction) + { + m_pOverlayContainer->UpdateOverlayInfo(pStream, &m_dvdspus, iAction); + } bool AcceptsData() const override; void SendMessage(CDVDMsg* pMsg, int priority = 0) override; diff --git a/xbmc/cores/VideoPlayer/VideoPlayerTeletext.cpp b/xbmc/cores/VideoPlayer/VideoPlayerTeletext.cpp index 14e032e5b4..0c5e417326 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerTeletext.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayerTeletext.cpp @@ -9,8 +9,8 @@ #include "VideoPlayerTeletext.h" #include "DVDStreamInfo.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "threads/SingleLock.h" #include "utils/log.h" diff --git a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp index 3b51d3046d..266cd50ecf 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp @@ -12,8 +12,8 @@ #include "DVDCodecs/DVDFactoryCodec.h" #include "DVDCodecs/Video/DVDVideoCodecFFmpeg.h" #include "ServiceBroker.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/DemuxPacket.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "settings/AdvancedSettings.h" #include "settings/SettingsComponent.h" #include "utils/MathUtils.h" diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp index cbb09fe248..8c78f1beac 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.cpp @@ -483,7 +483,11 @@ void CBaseRenderer::SetVideoSettings(const CVideoSettings &settings) m_videoSettings = settings; } -void CBaseRenderer::SettingOptionsRenderMethodsFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CBaseRenderer::SettingOptionsRenderMethodsFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(13416), RENDER_METHOD_AUTO); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h index 090e45c1e6..7f9864d268 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h @@ -85,7 +85,10 @@ public: void GetVideoRect(CRect &source, CRect &dest, CRect &view); float GetAspectRatio() const; - static void SettingOptionsRenderMethodsFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); + static void SettingOptionsRenderMethodsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); void SetVideoSettings(const CVideoSettings &settings); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/CMakeLists.txt b/xbmc/cores/VideoPlayer/VideoRenderers/CMakeLists.txt index 12b67ebd48..3bc0cc7f65 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/VideoRenderers/CMakeLists.txt @@ -40,12 +40,12 @@ if(OPENGL_FOUND) FrameBufferObject.h) endif() -if(OPENGLES_FOUND AND (CORE_PLATFORM_NAME_LC STREQUAL android OR - CORE_PLATFORM_NAME_LC STREQUAL ios OR - CORE_PLATFORM_NAME_LC STREQUAL tvos OR - CORE_PLATFORM_NAME_LC STREQUAL gbm OR - CORE_PLATFORM_NAME_LC STREQUAL x11 OR - CORE_PLATFORM_NAME_LC STREQUAL wayland)) +if(OPENGLES_FOUND AND ("android" IN_LIST CORE_PLATFORM_NAME_LC OR + "ios" IN_LIST CORE_PLATFORM_NAME_LC OR + "tvos" IN_LIST CORE_PLATFORM_NAME_LC OR + "gbm" IN_LIST CORE_PLATFORM_NAME_LC OR + "x11" IN_LIST CORE_PLATFORM_NAME_LC OR + "wayland" IN_LIST CORE_PLATFORM_NAME_LC)) list(APPEND SOURCES LinuxRendererGLES.cpp FrameBufferObject.cpp) list(APPEND HEADERS LinuxRendererGLES.h diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.cpp index d33a1c65fe..a54bb76b0a 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.cpp @@ -311,7 +311,7 @@ struct H3DLUT // and by the array 'lutDataxx', of length 'lutCompressedSize'. }; -bool CColorManager::Probe3dLut(const std::string filename, int *clutSize) +bool CColorManager::Probe3dLut(const std::string& filename, int* clutSize) { struct H3DLUT header; CFile lutFile; @@ -362,7 +362,10 @@ bool CColorManager::Probe3dLut(const std::string filename, int *clutSize) return true; } -bool CColorManager::Load3dLut(const std::string filename, CMS_DATA_FORMAT format, int CLUTsize, uint16_t *clutData) +bool CColorManager::Load3dLut(const std::string& filename, + CMS_DATA_FORMAT format, + int CLUTsize, + uint16_t* clutData) { struct H3DLUT header; CFile lutFile; @@ -418,7 +421,7 @@ bool CColorManager::Load3dLut(const std::string filename, CMS_DATA_FORMAT format #if defined(HAVE_LCMS2) // ICC profile support -cmsHPROFILE CColorManager::LoadIccDisplayProfile(const std::string filename) +cmsHPROFILE CColorManager::LoadIccDisplayProfile(const std::string& filename) { cmsHPROFILE hProfile; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.h b/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.h index a6c50ea3bb..3fae32c023 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.h @@ -114,7 +114,7 @@ private: \param clutSize pointer to CLUT resolution \return true if the file can be loaded, false otherwise */ - static bool Probe3dLut(const std::string filename, int *clutSize); + static bool Probe3dLut(const std::string& filename, int* clutSize); /*! \brief Load a .3dlut file \param filename full path and filename @@ -123,7 +123,10 @@ private: \param clutData pointer to CLUT data \return true on success, false otherwise */ - static bool Load3dLut(const std::string filename, CMS_DATA_FORMAT format, int clutSize, uint16_t *clutData); + static bool Load3dLut(const std::string& filename, + CMS_DATA_FORMAT format, + int clutSize, + uint16_t* clutData); #if defined(HAVE_LCMS2) @@ -136,7 +139,7 @@ private: \param filename full path and filename \return display profile (cmsHPROFILE) */ - cmsHPROFILE LoadIccDisplayProfile(const std::string filename); + cmsHPROFILE LoadIccDisplayProfile(const std::string& filename); /* \brief Load an ICC device link \param filename full path and filename diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt index 5f1a530ded..cdcd734eb0 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt @@ -41,8 +41,8 @@ if(CORE_SYSTEM_NAME STREQUAL android) RendererMediaCodecSurface.h) endif() -if(CORE_PLATFORM_NAME_LC STREQUAL gbm OR CORE_PLATFORM_NAME_LC STREQUAL wayland) - if(CORE_PLATFORM_NAME_LC STREQUAL gbm) +if("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) + if("gbm" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES RendererDRMPRIME.cpp VideoLayerBridgeDRMPRIME.cpp) list(APPEND HEADERS RendererDRMPRIME.h diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp index 4f72f602d1..1f514c659a 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp @@ -12,10 +12,13 @@ #include "utils/log.h" #include "windowing/gbm/drm/DRMAtomic.h" +#include <utility> + using namespace KODI::WINDOWING::GBM; using namespace DRMPRIME; -CVideoLayerBridgeDRMPRIME::CVideoLayerBridgeDRMPRIME(std::shared_ptr<CDRMAtomic> drm) : m_DRM(drm) +CVideoLayerBridgeDRMPRIME::CVideoLayerBridgeDRMPRIME(std::shared_ptr<CDRMAtomic> drm) + : m_DRM(std::move(drm)) { } diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp index a9a305b46c..5d505adb07 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp @@ -98,8 +98,6 @@ CLinuxRendererGL::CPictureBuffer::CPictureBuffer() loaded = false; } -CLinuxRendererGL::CPictureBuffer::~CPictureBuffer() = default; - CBaseRenderer* CLinuxRendererGL::Create(CVideoBuffer *buffer) { return new CLinuxRendererGL(); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h index dbff9e49c1..43b08052ea 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h @@ -185,7 +185,7 @@ protected: struct CPictureBuffer { CPictureBuffer(); - ~CPictureBuffer(); + ~CPictureBuffer() = default; CYuvPlane fields[MAX_FIELDS][YuvImage::MAX_PLANES]; YuvImage image; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGUI.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGUI.cpp index 47a18fb16d..fabf661b8b 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGUI.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGUI.cpp @@ -40,7 +40,7 @@ CGUITextLayout* COverlayText::GetFontLayout(const std::string &font, int color, { if (CUtil::IsUsingTTFSubtitles()) { - std::string font_file = font; + const std::string& font_file = font; std::string font_path = URIUtils::AddFileToFolder("special://home/media/Fonts/", font_file); if (!XFILE::CFile::Exists(font_path)) font_path = URIUtils::AddFileToFolder("special://xbmc/media/Fonts/", font_file); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp index 2421e33bda..015b4dbf0e 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp @@ -15,7 +15,7 @@ using namespace VIDEOPLAYER; CCriticalSection renderSection; std::map<std::string, VIDEOPLAYER::CreateRenderer> CRendererFactory::m_renderers; -CBaseRenderer* CRendererFactory::CreateRenderer(std::string id, CVideoBuffer *buffer) +CBaseRenderer* CRendererFactory::CreateRenderer(const std::string& id, CVideoBuffer* buffer) { CSingleLock lock(renderSection); @@ -33,6 +33,7 @@ std::vector<std::string> CRendererFactory::GetRenderers() CSingleLock lock(renderSection); std::vector<std::string> ret; + ret.reserve(m_renderers.size()); for (auto &renderer : m_renderers) { ret.push_back(renderer.first); @@ -40,7 +41,7 @@ std::vector<std::string> CRendererFactory::GetRenderers() return ret; } -void CRendererFactory::RegisterRenderer(std::string id, ::CreateRenderer createFunc) +void CRendererFactory::RegisterRenderer(const std::string& id, ::CreateRenderer createFunc) { CSingleLock lock(renderSection); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.h b/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.h index f6b307f0d4..59b55610c1 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.h @@ -22,9 +22,9 @@ typedef CBaseRenderer* (*CreateRenderer)(CVideoBuffer *buffer); class CRendererFactory { public: - static CBaseRenderer* CreateRenderer(std::string id, CVideoBuffer *buffer); + static CBaseRenderer* CreateRenderer(const std::string& id, CVideoBuffer* buffer); - static void RegisterRenderer(std::string id, VIDEOPLAYER::CreateRenderer createFunc); + static void RegisterRenderer(const std::string& id, VIDEOPLAYER::CreateRenderer createFunc); static std::vector<std::string> GetRenderers(); static void ClearRenderer(); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp index 3bafc32427..6cca30e749 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp @@ -13,7 +13,7 @@ #include "RenderFactory.h" #include "RenderFlags.h" #include "ServiceBroker.h" -#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h" +#include "cores/VideoPlayer/Interface/TimingConstants.h" #include "messaging/ApplicationMessenger.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSettings.h" diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/CMakeLists.txt b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/CMakeLists.txt index a5292d87d4..adc3d144a2 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/CMakeLists.txt @@ -22,12 +22,12 @@ if(OPENGL_FOUND) YUV2RGBShaderGL.h) endif() -if(OPENGLES_FOUND AND (CORE_PLATFORM_NAME_LC STREQUAL android OR - CORE_PLATFORM_NAME_LC STREQUAL ios OR - CORE_PLATFORM_NAME_LC STREQUAL tvos OR - CORE_PLATFORM_NAME_LC STREQUAL gbm OR - CORE_PLATFORM_NAME_LC STREQUAL x11 OR - CORE_PLATFORM_NAME_LC STREQUAL wayland)) +if(OPENGLES_FOUND AND ("android" IN_LIST CORE_PLATFORM_NAME_LC OR + "ios" IN_LIST CORE_PLATFORM_NAME_LC OR + "tvos" IN_LIST CORE_PLATFORM_NAME_LC OR + "gbm" IN_LIST CORE_PLATFORM_NAME_LC OR + "x11" IN_LIST CORE_PLATFORM_NAME_LC OR + "wayland" IN_LIST CORE_PLATFORM_NAME_LC)) list(APPEND SOURCES ConversionMatrix.cpp VideoFilterShaderGLES.cpp YUV2RGBShaderGLES.cpp) diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp index 54c0fb3189..cff71f037f 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp @@ -20,6 +20,7 @@ #include <sstream> #include <string> +#include <utility> using namespace Shaders; @@ -41,7 +42,7 @@ BaseYUV2RGBGLSLShader::BaseYUV2RGBGLSLShader(bool rect, EShaderFormat format, bo m_stretch = 0.0f; // get defines from the output stage if used - m_glslOutput = output; + m_glslOutput = std::move(output); if (m_glslOutput) { m_defines += m_glslOutput->GetDefines(); @@ -223,11 +224,15 @@ void BaseYUV2RGBGLSLShader::SetDisplayMetadata(bool hasDisplayMetadata, AVMaster // Use for weave deinterlacing / progressive ////////////////////////////////////////////////////////////////////// -YUV2RGBProgressiveShader::YUV2RGBProgressiveShader(bool rect, EShaderFormat format, bool stretch, - AVColorPrimaries dstPrimaries, AVColorPrimaries srcPrimaries, +YUV2RGBProgressiveShader::YUV2RGBProgressiveShader(bool rect, + EShaderFormat format, + bool stretch, + AVColorPrimaries dstPrimaries, + AVColorPrimaries srcPrimaries, bool toneMap, std::shared_ptr<GLSLOutput> output) - : BaseYUV2RGBGLSLShader(rect, format, stretch, dstPrimaries, srcPrimaries, toneMap, output) + : BaseYUV2RGBGLSLShader( + rect, format, stretch, dstPrimaries, srcPrimaries, toneMap, std::move(output)) { PixelShader()->LoadSource("gl_yuv2rgb_basic.glsl", m_defines); PixelShader()->AppendSource("gl_output.glsl"); @@ -242,11 +247,13 @@ YUV2RGBProgressiveShader::YUV2RGBProgressiveShader(bool rect, EShaderFormat form YUV2RGBFilterShader4::YUV2RGBFilterShader4(bool rect, EShaderFormat format, bool stretch, - AVColorPrimaries dstPrimaries, AVColorPrimaries srcPrimaries, + AVColorPrimaries dstPrimaries, + AVColorPrimaries srcPrimaries, bool toneMap, ESCALINGMETHOD method, std::shared_ptr<GLSLOutput> output) -: BaseYUV2RGBGLSLShader(rect, format, stretch, dstPrimaries, srcPrimaries, toneMap, output) + : BaseYUV2RGBGLSLShader( + rect, format, stretch, dstPrimaries, srcPrimaries, toneMap, std::move(output)) { m_scaling = method; PixelShader()->LoadSource("gl_yuv2rgb_filter4.glsl", m_defines); diff --git a/xbmc/cores/playercorefactory/PlayerCoreConfig.h b/xbmc/cores/playercorefactory/PlayerCoreConfig.h index baeebafdb5..92742cdcd5 100644 --- a/xbmc/cores/playercorefactory/PlayerCoreConfig.h +++ b/xbmc/cores/playercorefactory/PlayerCoreConfig.h @@ -8,26 +8,29 @@ #pragma once -#include "utils/XBMCTinyXML.h" +#include "cores/ExternalPlayer/ExternalPlayer.h" #include "cores/IPlayer.h" +#include "cores/RetroPlayer/RetroPlayer.h" #include "cores/VideoPlayer/VideoPlayer.h" #include "cores/paplayer/PAPlayer.h" -#include "cores/RetroPlayer/RetroPlayer.h" -#include "cores/ExternalPlayer/ExternalPlayer.h" #ifdef HAS_UPNP #include "network/upnp/UPnPPlayer.h" #endif -#include "system.h" +#include "utils/XBMCTinyXML.h" #include "utils/log.h" +#include <utility> + +#include "system.h" + class CPlayerCoreConfig { public: - - CPlayerCoreConfig(std::string name, std::string type, const TiXmlElement* pConfig, const std::string& id = ""): - m_name(name), - m_id(id), - m_type(type) + CPlayerCoreConfig(std::string name, + std::string type, + const TiXmlElement* pConfig, + const std::string& id = "") + : m_name(std::move(name)), m_id(id), m_type(std::move(type)) { m_bPlaysAudio = false; m_bPlaysVideo = false; diff --git a/xbmc/dbwrappers/sqlitedataset.cpp b/xbmc/dbwrappers/sqlitedataset.cpp index fe5ba449c5..da7800b76b 100644 --- a/xbmc/dbwrappers/sqlitedataset.cpp +++ b/xbmc/dbwrappers/sqlitedataset.cpp @@ -236,13 +236,13 @@ void SqliteDatabase::setHostName(const char *newHost) { if ( (host[1] == ':') && isalpha(host[0])) { size_t pos = 0; - while ( (pos = host.find("/", pos)) != std::string::npos ) + while ((pos = host.find('/', pos)) != std::string::npos) host.replace(pos++, 1, "\\"); } else { size_t pos = 0; - while ( (pos = host.find("\\", pos)) != std::string::npos ) + while ((pos = host.find('\\', pos)) != std::string::npos) host.replace(pos++, 1, "/"); } } @@ -761,12 +761,12 @@ int SqliteDataset::exec(const std::string &sql) { size_t pos = 0; size_t pos2 = 0; - if ( (pos = qry.find("(")) != std::string::npos ) + if ((pos = qry.find('(')) != std::string::npos) { pos++; - while ( (pos = qry.find("(", pos)) != std::string::npos ) + while ((pos = qry.find('(', pos)) != std::string::npos) { - if ( (pos2 = qry.find(")", pos)) != std::string::npos ) + if ((pos2 = qry.find(')', pos)) != std::string::npos) { qry.replace(pos, pos2-pos+1, ""); pos = pos2; @@ -808,7 +808,7 @@ const void* SqliteDataset::getExecRes() { bool SqliteDataset::query(const std::string &query) { if(!handle()) throw DbErrors("No Database Connection"); - std::string qry = query; + const std::string& qry = query; int fs = qry.find("select"); int fS = qry.find("SELECT"); if (!( fs >= 0 || fS >=0)) diff --git a/xbmc/dialogs/GUIDialogBoxBase.cpp b/xbmc/dialogs/GUIDialogBoxBase.cpp index b6daba3ccf..203c4331f6 100644 --- a/xbmc/dialogs/GUIDialogBoxBase.cpp +++ b/xbmc/dialogs/GUIDialogBoxBase.cpp @@ -48,7 +48,7 @@ bool CGUIDialogBoxBase::IsConfirmed() const return m_bConfirmed; } -void CGUIDialogBoxBase::SetHeading(CVariant heading) +void CGUIDialogBoxBase::SetHeading(const CVariant& heading) { std::string label = GetLocalized(heading); CSingleLock lock(m_section); @@ -59,7 +59,7 @@ void CGUIDialogBoxBase::SetHeading(CVariant heading) } } -void CGUIDialogBoxBase::SetLine(unsigned int iLine, CVariant line) +void CGUIDialogBoxBase::SetLine(unsigned int iLine, const CVariant& line) { std::string label = GetLocalized(line); CSingleLock lock(m_section); @@ -71,7 +71,7 @@ void CGUIDialogBoxBase::SetLine(unsigned int iLine, CVariant line) SetText(text); } -void CGUIDialogBoxBase::SetText(CVariant text) +void CGUIDialogBoxBase::SetText(const CVariant& text) { std::string label = GetLocalized(text); CSingleLock lock(m_section); diff --git a/xbmc/dialogs/GUIDialogBoxBase.h b/xbmc/dialogs/GUIDialogBoxBase.h index 89ffea896a..41ab31b2aa 100644 --- a/xbmc/dialogs/GUIDialogBoxBase.h +++ b/xbmc/dialogs/GUIDialogBoxBase.h @@ -32,9 +32,9 @@ public: ~CGUIDialogBoxBase(void) override; bool OnMessage(CGUIMessage& message) override; bool IsConfirmed() const; - void SetLine(unsigned int iLine, CVariant line); - void SetText(CVariant text); - void SetHeading(CVariant heading); + void SetLine(unsigned int iLine, const CVariant& line); + void SetText(const CVariant& text); + void SetHeading(const CVariant& heading); void SetChoice(int iButton, const CVariant &choice); protected: std::string GetDefaultLabel(int controlId) const; diff --git a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp index f3b55d118e..349e3a4aa6 100644 --- a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp +++ b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp @@ -327,7 +327,7 @@ bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) } case GUI_MSG_CODINGTABLE_LOOKUP_COMPLETED: { - std::string code = message.GetStringParam(); + const std::string& code = message.GetStringParam(); if (code == m_hzcode) { int response = message.GetParam1(); @@ -721,7 +721,7 @@ void CGUIDialogKeyboardGeneric::ShowWordList(int direct) hzlist.insert(hzlist.length(), 1, L' '); } } - hzlist.erase(hzlist.find_last_not_of(L" ") + 1); + hzlist.erase(hzlist.find_last_not_of(L' ') + 1); if (m_pos > 0) hzlist.insert(0, 1, L'<'); if (m_pos + m_num < static_cast<int>(m_words.size())) diff --git a/xbmc/dialogs/GUIDialogMediaFilter.cpp b/xbmc/dialogs/GUIDialogMediaFilter.cpp index b862f14958..04d267b212 100644 --- a/xbmc/dialogs/GUIDialogMediaFilter.cpp +++ b/xbmc/dialogs/GUIDialogMediaFilter.cpp @@ -217,7 +217,7 @@ void CGUIDialogMediaFilter::OnInitWindow() UpdateControls(); } -void CGUIDialogMediaFilter::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogMediaFilter::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { CGUIDialogSettingsManualBase::OnSettingChanged(setting); @@ -739,7 +739,10 @@ void CGUIDialogMediaFilter::DeleteRule(Field field) } } -void CGUIDialogMediaFilter::GetStringListOptions(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CGUIDialogMediaFilter::GetStringListOptions(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { if (setting == NULL || data == NULL) return; diff --git a/xbmc/dialogs/GUIDialogMediaFilter.h b/xbmc/dialogs/GUIDialogMediaFilter.h index 70aa8474d7..dd87b034e7 100644 --- a/xbmc/dialogs/GUIDialogMediaFilter.h +++ b/xbmc/dialogs/GUIDialogMediaFilter.h @@ -55,7 +55,7 @@ protected: void OnInitWindow() override; // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } @@ -79,7 +79,10 @@ protected: CSmartPlaylistRule* AddRule(Field field, CDatabaseQueryRule::SEARCH_OPERATOR ruleOperator = CDatabaseQueryRule::OPERATOR_CONTAINS); void DeleteRule(Field field); - static void GetStringListOptions(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); + static void GetStringListOptions(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); CDbUrl* m_dbUrl; std::string m_mediaType; diff --git a/xbmc/dialogs/GUIDialogMediaSource.cpp b/xbmc/dialogs/GUIDialogMediaSource.cpp index d152b81edc..df6e5eaafa 100644 --- a/xbmc/dialogs/GUIDialogMediaSource.cpp +++ b/xbmc/dialogs/GUIDialogMediaSource.cpp @@ -240,8 +240,6 @@ void CGUIDialogMediaSource::OnPathBrowse(int item) m_bNameChanged = true; path.clear(); - std::string strDevices = g_localizeStrings.Get(33040); //"% Devices" - if (m_type == "music") { CMediaSource share1; diff --git a/xbmc/dialogs/GUIDialogOK.cpp b/xbmc/dialogs/GUIDialogOK.cpp index b004a8efab..af626dc292 100644 --- a/xbmc/dialogs/GUIDialogOK.cpp +++ b/xbmc/dialogs/GUIDialogOK.cpp @@ -37,7 +37,7 @@ bool CGUIDialogOK::OnMessage(CGUIMessage& message) } // \brief Show CGUIDialogOK dialog, then wait for user to dismiss it. -bool CGUIDialogOK::ShowAndGetInput(CVariant heading, CVariant text) +bool CGUIDialogOK::ShowAndGetInput(const CVariant& heading, const CVariant& text) { CGUIDialogOK *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogOK>(WINDOW_DIALOG_OK); if (!dialog) @@ -49,7 +49,10 @@ bool CGUIDialogOK::ShowAndGetInput(CVariant heading, CVariant text) } // \brief Show CGUIDialogOK dialog, then wait for user to dismiss it. -bool CGUIDialogOK::ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2) +bool CGUIDialogOK::ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2) { CGUIDialogOK *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogOK>(WINDOW_DIALOG_OK); if (!dialog) diff --git a/xbmc/dialogs/GUIDialogOK.h b/xbmc/dialogs/GUIDialogOK.h index 6bb940cc51..94678e3251 100644 --- a/xbmc/dialogs/GUIDialogOK.h +++ b/xbmc/dialogs/GUIDialogOK.h @@ -23,8 +23,11 @@ public: CGUIDialogOK(void); ~CGUIDialogOK(void) override; bool OnMessage(CGUIMessage& message) override; - static bool ShowAndGetInput(CVariant heading, CVariant text); - static bool ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2); + static bool ShowAndGetInput(const CVariant& heading, const CVariant& text); + static bool ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2); /*! \brief Open a OK dialog and wait for input diff --git a/xbmc/dialogs/GUIDialogPlayEject.cpp b/xbmc/dialogs/GUIDialogPlayEject.cpp index d34b5ebe3c..14ee2bc0d3 100644 --- a/xbmc/dialogs/GUIDialogPlayEject.cpp +++ b/xbmc/dialogs/GUIDialogPlayEject.cpp @@ -73,8 +73,8 @@ void CGUIDialogPlayEject::OnInitWindow() CGUIDialogYesNo::OnInitWindow(); } -bool CGUIDialogPlayEject::ShowAndGetInput(const std::string strLine1, - const std::string strLine2, +bool CGUIDialogPlayEject::ShowAndGetInput(const std::string& strLine1, + const std::string& strLine2, unsigned int uiAutoCloseTime /* = 0 */) { @@ -87,8 +87,8 @@ bool CGUIDialogPlayEject::ShowAndGetInput(const std::string strLine1, // Setup dialog parameters pDialog->SetHeading(CVariant{219}); pDialog->SetLine(0, CVariant{429}); - pDialog->SetLine(1, CVariant{std::move(strLine1)}); - pDialog->SetLine(2, CVariant{std::move(strLine2)}); + pDialog->SetLine(1, CVariant{strLine1}); + pDialog->SetLine(2, CVariant{strLine2}); pDialog->SetChoice(ID_BUTTON_PLAY - 10, 208); pDialog->SetChoice(ID_BUTTON_EJECT - 10, 13391); if (uiAutoCloseTime) diff --git a/xbmc/dialogs/GUIDialogPlayEject.h b/xbmc/dialogs/GUIDialogPlayEject.h index bed73dc67c..c8ae319bd4 100644 --- a/xbmc/dialogs/GUIDialogPlayEject.h +++ b/xbmc/dialogs/GUIDialogPlayEject.h @@ -19,8 +19,8 @@ public: bool OnMessage(CGUIMessage& message) override; void FrameMove() override; - static bool ShowAndGetInput(const std::string strLine1, - const std::string strLine2, + static bool ShowAndGetInput(const std::string& strLine1, + const std::string& strLine2, unsigned int uiAutoCloseTime = 0); protected: diff --git a/xbmc/dialogs/GUIDialogSelect.cpp b/xbmc/dialogs/GUIDialogSelect.cpp index d8d3ff4aaa..c0d41f8a87 100644 --- a/xbmc/dialogs/GUIDialogSelect.cpp +++ b/xbmc/dialogs/GUIDialogSelect.cpp @@ -295,7 +295,7 @@ void CGUIDialogSelect::SetSelected(const std::string &strSelectedLabel) } } -void CGUIDialogSelect::SetSelected(std::vector<int> selectedIndexes) +void CGUIDialogSelect::SetSelected(const std::vector<int>& selectedIndexes) { for (auto i : selectedIndexes) SetSelected(i); diff --git a/xbmc/dialogs/GUIDialogSelect.h b/xbmc/dialogs/GUIDialogSelect.h index 2fa3286c63..ab91163e44 100644 --- a/xbmc/dialogs/GUIDialogSelect.h +++ b/xbmc/dialogs/GUIDialogSelect.h @@ -41,7 +41,7 @@ public: void Sort(bool bSortOrder = true); void SetSelected(int iSelected); void SetSelected(const std::string &strSelectedLabel); - void SetSelected(std::vector<int> selectedIndexes); + void SetSelected(const std::vector<int>& selectedIndexes); void SetSelected(const std::vector<std::string> &selectedLabels); void SetUseDetails(bool useDetails); void SetMultiSelection(bool multiSelection); diff --git a/xbmc/dialogs/GUIDialogYesNo.cpp b/xbmc/dialogs/GUIDialogYesNo.cpp index 9cca48e662..9b689b0254 100644 --- a/xbmc/dialogs/GUIDialogYesNo.cpp +++ b/xbmc/dialogs/GUIDialogYesNo.cpp @@ -78,18 +78,34 @@ void CGUIDialogYesNo::OnInitWindow() CGUIDialogBoxBase::OnInitWindow(); } -bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2, bool &bCanceled) +bool CGUIDialogYesNo::ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2, + bool& bCanceled) { return ShowAndGetInput(heading, line0, line1, line2, bCanceled, "", "", NO_TIMEOUT); } -bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2, CVariant noLabel /* = "" */, CVariant yesLabel /* = "" */) +bool CGUIDialogYesNo::ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2, + const CVariant& noLabel /* = "" */, + const CVariant& yesLabel /* = "" */) { bool bDummy(false); return ShowAndGetInput(heading, line0, line1, line2, bDummy, noLabel, yesLabel, NO_TIMEOUT); } -bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2, bool &bCanceled, CVariant noLabel, CVariant yesLabel, unsigned int autoCloseTime) +bool CGUIDialogYesNo::ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2, + bool& bCanceled, + const CVariant& noLabel, + const CVariant& yesLabel, + unsigned int autoCloseTime) { CGUIDialogYesNo *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO); if (!dialog) @@ -111,13 +127,18 @@ bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant line0, CVariant return (dialog->IsConfirmed()) ? true : false; } -bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant text) +bool CGUIDialogYesNo::ShowAndGetInput(const CVariant& heading, const CVariant& text) { bool bDummy(false); return ShowAndGetInput(heading, text, "", "", bDummy); } -bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant text, bool &bCanceled, CVariant noLabel /* = "" */, CVariant yesLabel /* = "" */, unsigned int autoCloseTime) +bool CGUIDialogYesNo::ShowAndGetInput(const CVariant& heading, + const CVariant& text, + bool& bCanceled, + const CVariant& noLabel /* = "" */, + const CVariant& yesLabel /* = "" */, + unsigned int autoCloseTime) { int result = ShowAndGetInput(heading, text, noLabel, yesLabel, "", autoCloseTime); @@ -145,7 +166,12 @@ int CGUIDialogYesNo::GetResult() const return 0; } -int CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, CVariant customLabel, unsigned int autoCloseTime) +int CGUIDialogYesNo::ShowAndGetInput(const CVariant& heading, + const CVariant& text, + const CVariant& noLabel, + const CVariant& yesLabel, + const CVariant& customLabel, + unsigned int autoCloseTime) { CGUIDialogYesNo *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO); if (!dialog) diff --git a/xbmc/dialogs/GUIDialogYesNo.h b/xbmc/dialogs/GUIDialogYesNo.h index be049c04c9..45c5c8aadc 100644 --- a/xbmc/dialogs/GUIDialogYesNo.h +++ b/xbmc/dialogs/GUIDialogYesNo.h @@ -47,7 +47,11 @@ public: \param bCanceled Holds true if the dialog was canceled otherwise false \return true if user selects Yes, otherwise false if user selects No. */ - static bool ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2, bool &bCanceled); + static bool ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2, + bool& bCanceled); /*! \brief Show a yes-no dialog, then wait for user to dismiss it. \param heading Localized label id or string for the heading of the dialog @@ -58,7 +62,12 @@ public: \param iYesLabel Localized label id or string for the yes button \return true if user selects Yes, otherwise false if user selects No. */ - static bool ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2, CVariant noLabel = "", CVariant yesLabel = ""); + static bool ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2, + const CVariant& noLabel = "", + const CVariant& yesLabel = ""); /*! \brief Show a yes-no dialog, then wait for user to dismiss it. \param heading Localized label id or string for the heading of the dialog @@ -71,14 +80,21 @@ public: \param autoCloseTime Time in ms before the dialog becomes automatically closed \return true if user selects Yes, otherwise false if user selects No. */ - static bool ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2, bool &bCanceled, CVariant noLabel, CVariant yesLabel, unsigned int autoCloseTime); + static bool ShowAndGetInput(const CVariant& heading, + const CVariant& line0, + const CVariant& line1, + const CVariant& line2, + bool& bCanceled, + const CVariant& noLabel, + const CVariant& yesLabel, + unsigned int autoCloseTime); /*! \brief Show a yes-no dialog, then wait for user to dismiss it. \param heading Localized label id or string for the heading of the dialog \param text Localized label id or string for the dialog message \return true if user selects Yes, otherwise false if user selects No. */ - static bool ShowAndGetInput(CVariant heading, CVariant text); + static bool ShowAndGetInput(const CVariant& heading, const CVariant& text); /*! \brief Show a yes-no dialog, then wait for user to dismiss it. \param heading Localized label id or string for the heading of the dialog @@ -89,7 +105,12 @@ public: \param autoCloseTime Time in ms before the dialog becomes automatically closed \return true if user selects Yes, otherwise false if user selects No. */ - static bool ShowAndGetInput(CVariant heading, CVariant text, bool &bCanceled, CVariant noLabel, CVariant yesLabel, unsigned int autoCloseTime); + static bool ShowAndGetInput(const CVariant& heading, + const CVariant& text, + bool& bCanceled, + const CVariant& noLabel, + const CVariant& yesLabel, + unsigned int autoCloseTime); /*! \brief Show a yes-no dialog with 3rd custom button, then wait for user to dismiss it. \param heading Localized label id or string for the heading of the dialog @@ -100,7 +121,12 @@ public: \param autoCloseTime Time in ms before the dialog becomes automatically closed \return -1 for cancelled, 0 for No, 1 for Yes and 2 for custom button */ - static int ShowAndGetInput(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, CVariant customLabel, unsigned int autoCloseTime); + static int ShowAndGetInput(const CVariant& heading, + const CVariant& text, + const CVariant& noLabel, + const CVariant& yesLabel, + const CVariant& customLabel, + unsigned int autoCloseTime); /*! \brief Open a Yes/No dialog and wait for input diff --git a/xbmc/events/AddonEvent.cpp b/xbmc/events/AddonEvent.cpp index 6b97e64e5c..459c37d7dc 100644 --- a/xbmc/events/AddonEvent.cpp +++ b/xbmc/events/AddonEvent.cpp @@ -8,32 +8,41 @@ #include "AddonEvent.h" -CAddonEvent::CAddonEvent(ADDON::AddonPtr addon, const CVariant& description) - : CUniqueEvent(addon->Name(), description, addon->Icon()), - m_addon(addon) +CAddonEvent::CAddonEvent(const ADDON::AddonPtr& addon, const CVariant& description) + : CUniqueEvent(addon->Name(), description, addon->Icon()), m_addon(addon) { } -CAddonEvent::CAddonEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details) - : CUniqueEvent(addon->Name(), description, addon->Icon(), details), - m_addon(addon) +CAddonEvent::CAddonEvent(const ADDON::AddonPtr& addon, + const CVariant& description, + const CVariant& details) + : CUniqueEvent(addon->Name(), description, addon->Icon(), details), m_addon(addon) { } -CAddonEvent::CAddonEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details, const CVariant& executionLabel) - : CUniqueEvent(addon->Name(), description, addon->Icon(), details, executionLabel), - m_addon(addon) +CAddonEvent::CAddonEvent(const ADDON::AddonPtr& addon, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel) + : CUniqueEvent(addon->Name(), description, addon->Icon(), details, executionLabel), m_addon(addon) { } -CAddonEvent::CAddonEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description) - : CUniqueEvent(addon->Name(), description, addon->Icon(), level), - m_addon(addon) +CAddonEvent::CAddonEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description) + : CUniqueEvent(addon->Name(), description, addon->Icon(), level), m_addon(addon) { } -CAddonEvent::CAddonEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details) - : CUniqueEvent(addon->Name(), description, addon->Icon(), details, level), - m_addon(addon) +CAddonEvent::CAddonEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details) + : CUniqueEvent(addon->Name(), description, addon->Icon(), details, level), m_addon(addon) { } -CAddonEvent::CAddonEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details, const CVariant& executionLabel) +CAddonEvent::CAddonEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel) : CUniqueEvent(addon->Name(), description, addon->Icon(), details, executionLabel, level), - m_addon(addon) + m_addon(addon) { } diff --git a/xbmc/events/AddonEvent.h b/xbmc/events/AddonEvent.h index d449c2727c..84154f1c04 100644 --- a/xbmc/events/AddonEvent.h +++ b/xbmc/events/AddonEvent.h @@ -14,12 +14,22 @@ class CAddonEvent : public CUniqueEvent { public: - CAddonEvent(ADDON::AddonPtr addon, const CVariant& description); - CAddonEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details); - CAddonEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details, const CVariant& executionLabel); - CAddonEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description); - CAddonEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details); - CAddonEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details, const CVariant& executionLabel); + CAddonEvent(const ADDON::AddonPtr& addon, const CVariant& description); + CAddonEvent(const ADDON::AddonPtr& addon, const CVariant& description, const CVariant& details); + CAddonEvent(const ADDON::AddonPtr& addon, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel); + CAddonEvent(const ADDON::AddonPtr& addon, EventLevel level, const CVariant& description); + CAddonEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details); + CAddonEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel); ~CAddonEvent() override = default; const char* GetType() const override { return "AddonEvent"; } diff --git a/xbmc/events/AddonManagementEvent.cpp b/xbmc/events/AddonManagementEvent.cpp index 429ded5c1c..6d97915a36 100644 --- a/xbmc/events/AddonManagementEvent.cpp +++ b/xbmc/events/AddonManagementEvent.cpp @@ -13,27 +13,42 @@ #include "guilib/LocalizeStrings.h" #include "utils/URIUtils.h" -CAddonManagementEvent::CAddonManagementEvent(ADDON::AddonPtr addon, const CVariant& description) +CAddonManagementEvent::CAddonManagementEvent(const ADDON::AddonPtr& addon, + const CVariant& description) : CAddonEvent(addon, description) { } -CAddonManagementEvent::CAddonManagementEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details) +CAddonManagementEvent::CAddonManagementEvent(const ADDON::AddonPtr& addon, + const CVariant& description, + const CVariant& details) : CAddonEvent(addon, description, details) { } -CAddonManagementEvent::CAddonManagementEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details, const CVariant& executionLabel) +CAddonManagementEvent::CAddonManagementEvent(const ADDON::AddonPtr& addon, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel) : CAddonEvent(addon, description, details, executionLabel) { } -CAddonManagementEvent::CAddonManagementEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description) +CAddonManagementEvent::CAddonManagementEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description) : CAddonEvent(addon, level, description) { } -CAddonManagementEvent::CAddonManagementEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details) +CAddonManagementEvent::CAddonManagementEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details) : CAddonEvent(addon, level, description, details) { } -CAddonManagementEvent::CAddonManagementEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details, const CVariant& executionLabel) +CAddonManagementEvent::CAddonManagementEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel) : CAddonEvent(addon, level, description, details, executionLabel) { } diff --git a/xbmc/events/AddonManagementEvent.h b/xbmc/events/AddonManagementEvent.h index 6d833b2752..f6f0744c72 100644 --- a/xbmc/events/AddonManagementEvent.h +++ b/xbmc/events/AddonManagementEvent.h @@ -13,12 +13,26 @@ class CAddonManagementEvent : public CAddonEvent { public: - CAddonManagementEvent(ADDON::AddonPtr addon, const CVariant& description); - CAddonManagementEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details); - CAddonManagementEvent(ADDON::AddonPtr addon, const CVariant& description, const CVariant& details, const CVariant& executionLabel); - CAddonManagementEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description); - CAddonManagementEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details); - CAddonManagementEvent(ADDON::AddonPtr addon, EventLevel level, const CVariant& description, const CVariant& details, const CVariant& executionLabel); + CAddonManagementEvent(const ADDON::AddonPtr& addon, const CVariant& description); + CAddonManagementEvent(const ADDON::AddonPtr& addon, + const CVariant& description, + const CVariant& details); + CAddonManagementEvent(const ADDON::AddonPtr& addon, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel); + CAddonManagementEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description); + CAddonManagementEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details); + CAddonManagementEvent(const ADDON::AddonPtr& addon, + EventLevel level, + const CVariant& description, + const CVariant& details, + const CVariant& executionLabel); ~CAddonManagementEvent() override = default; const char* GetType() const override { return "AddonManagementEvent"; } diff --git a/xbmc/events/windows/GUIWindowEventLog.cpp b/xbmc/events/windows/GUIWindowEventLog.cpp index 01f95a2fe8..51d4e81236 100644 --- a/xbmc/events/windows/GUIWindowEventLog.cpp +++ b/xbmc/events/windows/GUIWindowEventLog.cpp @@ -219,7 +219,7 @@ bool CGUIWindowEventLog::GetDirectory(const std::string &strDirectory, CFileItem return result; } -bool CGUIWindowEventLog::OnSelect(CFileItemPtr item) +bool CGUIWindowEventLog::OnSelect(const CFileItemPtr& item) { if (item == nullptr) return false; @@ -228,7 +228,7 @@ bool CGUIWindowEventLog::OnSelect(CFileItemPtr item) return true; } -bool CGUIWindowEventLog::OnDelete(CFileItemPtr item) +bool CGUIWindowEventLog::OnDelete(const CFileItemPtr& item) { if (item == nullptr) return false; @@ -241,7 +241,7 @@ bool CGUIWindowEventLog::OnDelete(CFileItemPtr item) return true; } -bool CGUIWindowEventLog::OnExecute(CFileItemPtr item) +bool CGUIWindowEventLog::OnExecute(const CFileItemPtr& item) { if (item == nullptr) return false; @@ -260,7 +260,7 @@ bool CGUIWindowEventLog::OnExecute(CFileItemPtr item) return eventPtr->Execute(); } -void CGUIWindowEventLog::OnEventAdded(CFileItemPtr item) +void CGUIWindowEventLog::OnEventAdded(const CFileItemPtr& item) { if (!IsActive()) return; @@ -268,7 +268,7 @@ void CGUIWindowEventLog::OnEventAdded(CFileItemPtr item) Refresh(true); } -void CGUIWindowEventLog::OnEventRemoved(CFileItemPtr item) +void CGUIWindowEventLog::OnEventRemoved(const CFileItemPtr& item) { if (!IsActive()) return; diff --git a/xbmc/events/windows/GUIWindowEventLog.h b/xbmc/events/windows/GUIWindowEventLog.h index c3596871bb..d3cb22a91c 100644 --- a/xbmc/events/windows/GUIWindowEventLog.h +++ b/xbmc/events/windows/GUIWindowEventLog.h @@ -28,10 +28,10 @@ protected: bool GetDirectory(const std::string &strDirectory, CFileItemList &items) override; std::string GetRootPath() const override { return "events://"; } - bool OnSelect(CFileItemPtr item); - bool OnDelete(CFileItemPtr item); - bool OnExecute(CFileItemPtr item); + bool OnSelect(const CFileItemPtr& item); + bool OnDelete(const CFileItemPtr& item); + bool OnExecute(const CFileItemPtr& item); - void OnEventAdded(CFileItemPtr item); - void OnEventRemoved(CFileItemPtr item); + void OnEventAdded(const CFileItemPtr& item); + void OnEventRemoved(const CFileItemPtr& item); }; diff --git a/xbmc/filesystem/AddonsDirectory.cpp b/xbmc/filesystem/AddonsDirectory.cpp index 2df5cc55c2..31fb5aa0fa 100644 --- a/xbmc/filesystem/AddonsDirectory.cpp +++ b/xbmc/filesystem/AddonsDirectory.cpp @@ -350,7 +350,7 @@ static void GenerateMainCategoryListing(const CURL& path, const VECADDONS& addon static void GenerateCategoryListing(const CURL& path, VECADDONS& addons, CFileItemList& items) { - const std::string category = path.GetFileName(); + const std::string& category = path.GetFileName(); if (category == CATEGORY_INFO_PROVIDERS) { items.SetProperty("addoncategory", g_localizeStrings.Get(24993)); @@ -446,7 +446,7 @@ static void UserInstalledAddons(const CURL& path, CFileItemList &items) if (addons.empty()) return; - const std::string category = path.GetFileName(); + const std::string& category = path.GetFileName(); if (category.empty()) { GenerateMainCategoryListing(path, addons, items); @@ -531,7 +531,7 @@ static void RunningAddons(const CURL& path, CFileItemList &items) static bool Browse(const CURL& path, CFileItemList &items) { - const std::string repoId = path.GetHostName(); + const std::string& repoId = path.GetHostName(); VECADDONS addons; items.SetPath(path.Get()); @@ -577,7 +577,7 @@ static bool Browse(const CURL& path, CFileItemList &items) items.SetLabel(repoAddon->Name()); } - const std::string category = path.GetFileName(); + const std::string& category = path.GetFileName(); if (category.empty()) GenerateMainCategoryListing(path, addons, items); else @@ -682,7 +682,7 @@ bool CAddonsDirectory::GetDirectory(const CURL& url, CFileItemList &items) std::string tmp(url.Get()); URIUtils::RemoveSlashAtEnd(tmp); CURL path(tmp); - const std::string endpoint = path.GetHostName(); + const std::string& endpoint = path.GetHostName(); items.ClearItems(); items.ClearProperties(); items.SetCacheToDisc(CFileItemList::CACHE_NEVER); @@ -763,7 +763,7 @@ bool CAddonsDirectory::GetDirectory(const CURL& url, CFileItemList &items) } else if (endpoint == "more") { - std::string type = path.GetFileName(); + const std::string& type = path.GetFileName(); if (type == "video" || type == "audio" || type == "image" || type == "executable") return Browse(CURL("addons://all/xbmc.addon." + type), items); else if (type == "game") @@ -791,7 +791,7 @@ bool CAddonsDirectory::IsRepoDirectory(const CURL& url) void CAddonsDirectory::GenerateAddonListing(const CURL& path, const VECADDONS& addons, CFileItemList& items, - const std::string label) + const std::string& label) { std::map<std::string, CAddonWithUpdate> addonsWithUpdate; @@ -827,10 +827,12 @@ void CAddonsDirectory::GenerateAddonListing(const CURL& path, bool hasUpdate = CheckOutdatedOrUpdate(true); // check if it's an outdated addon std::string validUpdateVersion; + std::string validUpdateOrigin; if (hasUpdate) { auto mapEntry = addonsWithUpdate.find(addon->ID()); validUpdateVersion = mapEntry->second.m_update->Version().asString(); + validUpdateOrigin = mapEntry->second.m_update->Origin(); } bool fromOfficialRepo = CAddonRepos::IsFromOfficialRepo(addon, CheckAddonPath::NO); @@ -840,6 +842,7 @@ void CAddonsDirectory::GenerateAddonListing(const CURL& path, pItem->SetProperty("Addon.HasUpdate", hasUpdate); pItem->SetProperty("Addon.IsUpdate", isUpdate); pItem->SetProperty("Addon.ValidUpdateVersion", validUpdateVersion); + pItem->SetProperty("Addon.ValidUpdateOrigin", validUpdateOrigin); pItem->SetProperty("Addon.IsFromOfficialRepo", fromOfficialRepo); pItem->SetProperty("Addon.IsBinary", addon->IsBinary()); diff --git a/xbmc/filesystem/AddonsDirectory.h b/xbmc/filesystem/AddonsDirectory.h index 06802cb3e5..0403b50e74 100644 --- a/xbmc/filesystem/AddonsDirectory.h +++ b/xbmc/filesystem/AddonsDirectory.h @@ -45,7 +45,10 @@ namespace XFILE */ static bool GetScriptsAndPlugins(const std::string &content, CFileItemList &items); - static void GenerateAddonListing(const CURL &path, const ADDON::VECADDONS& addons, CFileItemList &items, const std::string label); + static void GenerateAddonListing(const CURL& path, + const ADDON::VECADDONS& addons, + CFileItemList& items, + const std::string& label); static CFileItemPtr FileItemFromAddon(const ADDON::AddonPtr &addon, const std::string& path, bool folder = false); /*! \brief Returns true if `path` is a path or subpath of the repository directory, otherwise false */ diff --git a/xbmc/filesystem/BlurayDirectory.cpp b/xbmc/filesystem/BlurayDirectory.cpp index 02de5bd7ee..003af44dc8 100644 --- a/xbmc/filesystem/BlurayDirectory.cpp +++ b/xbmc/filesystem/BlurayDirectory.cpp @@ -242,7 +242,7 @@ CURL CBlurayDirectory::GetUnderlyingCURL(const CURL& url) { assert(url.IsProtocol("bluray")); std::string host = url.GetHostName(); - std::string filename = url.GetFileName(); + const std::string& filename = url.GetFileName(); return CURL(host.append(filename)); } diff --git a/xbmc/filesystem/BlurayFile.cpp b/xbmc/filesystem/BlurayFile.cpp index 4b987de423..34d2732935 100644 --- a/xbmc/filesystem/BlurayFile.cpp +++ b/xbmc/filesystem/BlurayFile.cpp @@ -26,7 +26,7 @@ namespace XFILE assert(url.IsProtocol("bluray")); std::string host = url.GetHostName(); - std::string filename = url.GetFileName(); + const std::string& filename = url.GetFileName(); if (host.empty() || filename.empty()) return ""; diff --git a/xbmc/filesystem/CurlFile.h b/xbmc/filesystem/CurlFile.h index 2fb05f3040..8a5dbe688f 100644 --- a/xbmc/filesystem/CurlFile.h +++ b/xbmc/filesystem/CurlFile.h @@ -71,7 +71,7 @@ namespace XFILE void SetPostData(const std::string& postdata) { m_postdata = postdata; } void SetReferer(const std::string& referer) { m_referer = referer; } void SetCookie(const std::string& cookie) { m_cookie = cookie; } - void SetMimeType(std::string mimetype) { SetRequestHeader("Content-Type", mimetype); } + void SetMimeType(const std::string& mimetype) { SetRequestHeader("Content-Type", mimetype); } void SetRequestHeader(const std::string& header, const std::string& value); void SetRequestHeader(const std::string& header, long value); diff --git a/xbmc/filesystem/DAVDirectory.cpp b/xbmc/filesystem/DAVDirectory.cpp index b9b0a71d5b..5989fb8336 100644 --- a/xbmc/filesystem/DAVDirectory.cpp +++ b/xbmc/filesystem/DAVDirectory.cpp @@ -144,7 +144,7 @@ bool CDAVDirectory::GetDirectory(const CURL& url, CFileItemList &items) { CFileItem item; ParseResponse(pChild->ToElement(), item); - CURL url2(url); + const CURL& url2(url); CURL url3(item.GetPath()); std::string itemPath(URIUtils::AddFileToFolder(url2.GetWithoutFilename(), url3.GetFileName())); diff --git a/xbmc/filesystem/Directorization.h b/xbmc/filesystem/Directorization.h index b3a221f20f..f413635e6d 100644 --- a/xbmc/filesystem/Directorization.h +++ b/xbmc/filesystem/Directorization.h @@ -51,8 +51,8 @@ namespace XFILE if (url.Get().empty() || entries.empty()) return; - std::string options = url.GetOptions(); - std::string filePath = url.GetFileName(); + const std::string& options = url.GetOptions(); + const std::string& filePath = url.GetFileName(); CURL baseUrl(url); baseUrl.SetOptions(""); // delete options to have a clean path to add stuff too diff --git a/xbmc/filesystem/Directory.cpp b/xbmc/filesystem/Directory.cpp index 98b524c4d4..67ddf184ae 100644 --- a/xbmc/filesystem/Directory.cpp +++ b/xbmc/filesystem/Directory.cpp @@ -124,8 +124,11 @@ bool CDirectory::GetDirectory(const std::string& strPath, CFileItemList &items, return GetDirectory(pathToUrl, items, hints); } -bool CDirectory::GetDirectory(const std::string& strPath, std::shared_ptr<IDirectory> pDirectory, - CFileItemList &items, const std::string &strMask, int flags) +bool CDirectory::GetDirectory(const std::string& strPath, + const std::shared_ptr<IDirectory>& pDirectory, + CFileItemList& items, + const std::string& strMask, + int flags) { CHints hints; hints.flags = flags; @@ -155,8 +158,10 @@ bool CDirectory::GetDirectory(const CURL& url, CFileItemList &items, const CHint return CDirectory::GetDirectory(url, pDirectory, items, hints); } -bool CDirectory::GetDirectory(const CURL& url, std::shared_ptr<IDirectory> pDirectory, - CFileItemList &items, const CHints &hints) +bool CDirectory::GetDirectory(const CURL& url, + const std::shared_ptr<IDirectory>& pDirectory, + CFileItemList& items, + const CHints& hints) { try { diff --git a/xbmc/filesystem/Directory.h b/xbmc/filesystem/Directory.h index dcaa961a3a..0af92f3f35 100644 --- a/xbmc/filesystem/Directory.h +++ b/xbmc/filesystem/Directory.h @@ -38,9 +38,9 @@ public: , int flags); static bool GetDirectory(const CURL& url, - std::shared_ptr<IDirectory> pDirectory, - CFileItemList &items, - const CHints &hints); + const std::shared_ptr<IDirectory>& pDirectory, + CFileItemList& items, + const CHints& hints); static bool GetDirectory(const CURL& url , CFileItemList &items @@ -57,9 +57,9 @@ public: , int flags); static bool GetDirectory(const std::string& strPath, - std::shared_ptr<IDirectory> pDirectory, - CFileItemList &items, - const std::string &strMask, + const std::shared_ptr<IDirectory>& pDirectory, + CFileItemList& items, + const std::string& strMask, int flags); static bool GetDirectory(const std::string& strPath diff --git a/xbmc/filesystem/EventsDirectory.cpp b/xbmc/filesystem/EventsDirectory.cpp index 33f731068d..34e0b2c495 100644 --- a/xbmc/filesystem/EventsDirectory.cpp +++ b/xbmc/filesystem/EventsDirectory.cpp @@ -46,7 +46,7 @@ bool CEventsDirectory::GetDirectory(const CURL& url, CFileItemList &items) events = log.Get(level, includeHigherLevels); } - for (auto eventItem : events) + for (const auto& eventItem : events) items.Add(EventToFileItem(eventItem)); return true; diff --git a/xbmc/filesystem/FTPParse.cpp b/xbmc/filesystem/FTPParse.cpp index ee5e49e75c..3916197e35 100644 --- a/xbmc/filesystem/FTPParse.cpp +++ b/xbmc/filesystem/FTPParse.cpp @@ -45,7 +45,7 @@ time_t CFTPParse::getTime() return m_time; } -void CFTPParse::setTime(std::string str) +void CFTPParse::setTime(const std::string& str) { /* Variables used to capture patterns via the regexes */ std::string month; @@ -324,7 +324,7 @@ int CFTPParse::getDayOfWeek(int month, int date, int year) return day_of_week; } -int CFTPParse::FTPParse(std::string str) +int CFTPParse::FTPParse(const std::string& str) { /* Various variable to capture patterns via the regexes */ std::string permissions; diff --git a/xbmc/filesystem/FTPParse.h b/xbmc/filesystem/FTPParse.h index 7c57bec8ec..56d0202543 100644 --- a/xbmc/filesystem/FTPParse.h +++ b/xbmc/filesystem/FTPParse.h @@ -16,7 +16,7 @@ class CFTPParse { public: CFTPParse(); - int FTPParse(std::string str); + int FTPParse(const std::string& str); std::string getName(); int getFlagtrycwd(); int getFlagtryretr(); @@ -28,6 +28,6 @@ private: int m_flagtryretr; // 0 if retr is definitely pointless, 1 otherwise uint64_t m_size; // number of octets time_t m_time; // modification time - void setTime(std::string str); // Method used to set m_time from a string + void setTime(const std::string& str); // Method used to set m_time from a string int getDayOfWeek(int month, int date, int year); // Method to get day of week }; diff --git a/xbmc/filesystem/HTTPDirectory.cpp b/xbmc/filesystem/HTTPDirectory.cpp index 7bf61dc2d1..851d9bc74a 100644 --- a/xbmc/filesystem/HTTPDirectory.cpp +++ b/xbmc/filesystem/HTTPDirectory.cpp @@ -32,7 +32,7 @@ bool CHTTPDirectory::GetDirectory(const CURL& url, CFileItemList &items) { CCurlFile http; - std::string strBasePath = url.GetFileName(); + const std::string& strBasePath = url.GetFileName(); if(!http.Open(url)) { diff --git a/xbmc/filesystem/MultiPathDirectory.cpp b/xbmc/filesystem/MultiPathDirectory.cpp index 789a0b2beb..77ecaefa3b 100644 --- a/xbmc/filesystem/MultiPathDirectory.cpp +++ b/xbmc/filesystem/MultiPathDirectory.cpp @@ -136,7 +136,7 @@ bool CMultiPathDirectory::Remove(const CURL& url) std::string CMultiPathDirectory::GetFirstPath(const std::string &strPath) { - size_t pos = strPath.find("/", 12); + size_t pos = strPath.find('/', 12); if (pos != std::string::npos) return CURL::Decode(strPath.substr(12, pos - 12)); return ""; diff --git a/xbmc/filesystem/MusicSearchDirectory.cpp b/xbmc/filesystem/MusicSearchDirectory.cpp index 8945e07276..3a5fd6e8f9 100644 --- a/xbmc/filesystem/MusicSearchDirectory.cpp +++ b/xbmc/filesystem/MusicSearchDirectory.cpp @@ -25,7 +25,7 @@ bool CMusicSearchDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // break up our path // format is: musicsearch://<url encoded search string> - std::string search(url.GetHostName()); + const std::string& search(url.GetHostName()); if (search.empty()) return false; diff --git a/xbmc/filesystem/NFSDirectory.cpp b/xbmc/filesystem/NFSDirectory.cpp index 62b1d33499..24119d3ada 100644 --- a/xbmc/filesystem/NFSDirectory.cpp +++ b/xbmc/filesystem/NFSDirectory.cpp @@ -56,7 +56,7 @@ bool CNFSDirectory::GetDirectoryFromExportList(const std::string& strPath, CFile for (const std::string& it : exportList) { - std::string currentExport(it); + const std::string& currentExport(it); URIUtils::RemoveSlashAtEnd(nonConstStrPath); CFileItemPtr pItem(new CFileItem(currentExport)); diff --git a/xbmc/filesystem/NFSFile.cpp b/xbmc/filesystem/NFSFile.cpp index 177b71062f..86bfc69578 100644 --- a/xbmc/filesystem/NFSFile.cpp +++ b/xbmc/filesystem/NFSFile.cpp @@ -376,7 +376,7 @@ void CNfsConnection::removeFromKeepAliveList(struct nfsfh *_pFileHandle) } //reset timeouts on read -void CNfsConnection::resetKeepAlive(std::string _exportPath, struct nfsfh *_pFileHandle) +void CNfsConnection::resetKeepAlive(const std::string& _exportPath, struct nfsfh* _pFileHandle) { CSingleLock lock(keepAliveLock); //refresh last access time of the context aswell @@ -397,7 +397,7 @@ void CNfsConnection::resetKeepAlive(std::string _exportPath, struct nfsfh *_pFi //keep alive the filehandles nfs connection //by blindly doing a read 32bytes - seek back to where //we were before -void CNfsConnection::keepAlive(std::string _exportPath, struct nfsfh *_pFileHandle) +void CNfsConnection::keepAlive(const std::string& _exportPath, struct nfsfh* _pFileHandle) { uint64_t offset = 0; char buffer[32]; diff --git a/xbmc/filesystem/NFSFile.h b/xbmc/filesystem/NFSFile.h index afc1958acf..ba8fbd6c21 100644 --- a/xbmc/filesystem/NFSFile.h +++ b/xbmc/filesystem/NFSFile.h @@ -64,7 +64,7 @@ public: void Deinit(); //adds the filehandle to the keep alive list or resets //the timeout for this filehandle if already in list - void resetKeepAlive(std::string _exportPath, struct nfsfh *_pFileHandle); + void resetKeepAlive(const std::string& _exportPath, struct nfsfh* _pFileHandle); //removes file handle from keep alive list void removeFromKeepAliveList(struct nfsfh *_pFileHandle); @@ -94,7 +94,7 @@ private: void destroyOpenContexts(); void destroyContext(const std::string &exportName); void resolveHost(const CURL &url);//resolve hostname by dnslookup - void keepAlive(std::string _exportPath, struct nfsfh *_pFileHandle); + void keepAlive(const std::string& _exportPath, struct nfsfh* _pFileHandle); static void setTimeout(struct nfs_context* context); }; diff --git a/xbmc/filesystem/NptXbmcFile.cpp b/xbmc/filesystem/NptXbmcFile.cpp index d1d6b3b3e6..4aad76f22f 100644 --- a/xbmc/filesystem/NptXbmcFile.cpp +++ b/xbmc/filesystem/NptXbmcFile.cpp @@ -40,8 +40,7 @@ class NPT_XbmcFileStream { public: // constructors and destructor - explicit NPT_XbmcFileStream(NPT_XbmcFileReference file) : - m_FileReference(file) {} + explicit NPT_XbmcFileStream(const NPT_XbmcFileReference& file) : m_FileReference(file) {} // NPT_FileInterface methods NPT_Result Seek(NPT_Position offset); diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index f41002dab8..ab3d4bb6f4 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -254,7 +254,7 @@ void CPluginDirectory::EndOfDirectory(int handle, bool success, bool replaceList dir->m_fetchComplete.Set(); } -void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const std::string &label2Mask) +void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const std::string &labelMask, const std::string &label2Mask) { CSingleLock lock(m_handleLock); CPluginDirectory *dir = dirFromHandle(handle); @@ -267,114 +267,114 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const s case SORT_METHOD_LABEL: case SORT_METHOD_LABEL_IGNORE_THE: { - dir->m_listItems->AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", label2Mask), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); + dir->m_listItems->AddSortMethod(SortByLabel, 551, LABEL_MASKS(labelMask, label2Mask), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_TITLE: case SORT_METHOD_TITLE_IGNORE_THE: { - dir->m_listItems->AddSortMethod(SortByTitle, 556, LABEL_MASKS("%T", label2Mask), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); + dir->m_listItems->AddSortMethod(SortByTitle, 556, LABEL_MASKS(labelMask, label2Mask), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_ARTIST: case SORT_METHOD_ARTIST_IGNORE_THE: { - dir->m_listItems->AddSortMethod(SortByArtist, 557, LABEL_MASKS("%T", "%A", "%T", "%A"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); + dir->m_listItems->AddSortMethod(SortByArtist, 557, LABEL_MASKS(labelMask, "%A", labelMask, "%A"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_ALBUM: case SORT_METHOD_ALBUM_IGNORE_THE: { - dir->m_listItems->AddSortMethod(SortByAlbum, 558, LABEL_MASKS("%T", "%B", "%T", "%B"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); + dir->m_listItems->AddSortMethod(SortByAlbum, 558, LABEL_MASKS(labelMask, "%B", labelMask, "%B"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_DATE: { - dir->m_listItems->AddSortMethod(SortByDate, 552, LABEL_MASKS("%T", "%J", "%T", "%J")); + dir->m_listItems->AddSortMethod(SortByDate, 552, LABEL_MASKS(labelMask, "%J", labelMask, "%J")); break; } case SORT_METHOD_BITRATE: { - dir->m_listItems->AddSortMethod(SortByBitrate, 623, LABEL_MASKS("%T", "%X", "%T", "%X")); + dir->m_listItems->AddSortMethod(SortByBitrate, 623, LABEL_MASKS(labelMask, "%X", labelMask, "%X")); break; } case SORT_METHOD_SIZE: { - dir->m_listItems->AddSortMethod(SortBySize, 553, LABEL_MASKS("%T", "%I", "%T", "%I")); + dir->m_listItems->AddSortMethod(SortBySize, 553, LABEL_MASKS(labelMask, "%I", labelMask, "%I")); break; } case SORT_METHOD_FILE: { - dir->m_listItems->AddSortMethod(SortByFile, 561, LABEL_MASKS("%T", label2Mask, "%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByFile, 561, LABEL_MASKS(labelMask, label2Mask, labelMask, label2Mask)); break; } case SORT_METHOD_TRACKNUM: { - dir->m_listItems->AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS("[%N. ]%T", label2Mask, "[%N. ]%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(labelMask, label2Mask, labelMask, label2Mask)); break; } case SORT_METHOD_DURATION: case SORT_METHOD_VIDEO_RUNTIME: { - dir->m_listItems->AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D", "%T", "%D")); + dir->m_listItems->AddSortMethod(SortByTime, 180, LABEL_MASKS(labelMask, "%D", labelMask, "%D")); break; } case SORT_METHOD_VIDEO_RATING: case SORT_METHOD_SONG_RATING: { - dir->m_listItems->AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); + dir->m_listItems->AddSortMethod(SortByRating, 563, LABEL_MASKS(labelMask, "%R", labelMask, "%R")); break; } case SORT_METHOD_YEAR: { - dir->m_listItems->AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); + dir->m_listItems->AddSortMethod(SortByYear, 562, LABEL_MASKS(labelMask, "%Y", labelMask, "%Y")); break; } case SORT_METHOD_GENRE: { - dir->m_listItems->AddSortMethod(SortByGenre, 515, LABEL_MASKS("%T", "%G", "%T", "%G")); + dir->m_listItems->AddSortMethod(SortByGenre, 515, LABEL_MASKS(labelMask, "%G", labelMask, "%G")); break; } case SORT_METHOD_COUNTRY: { - dir->m_listItems->AddSortMethod(SortByCountry, 574, LABEL_MASKS("%T", "%G", "%T", "%G")); + dir->m_listItems->AddSortMethod(SortByCountry, 574, LABEL_MASKS(labelMask, "%G", labelMask, "%G")); break; } case SORT_METHOD_VIDEO_TITLE: { - dir->m_listItems->AddSortMethod(SortByTitle, 369, LABEL_MASKS("%T", "%M", "%T", "%M")); + dir->m_listItems->AddSortMethod(SortByTitle, 369, LABEL_MASKS(labelMask, "%M", labelMask, "%M")); break; } case SORT_METHOD_VIDEO_SORT_TITLE: case SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE: { - dir->m_listItems->AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", "%M", "%T", "%M"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); + dir->m_listItems->AddSortMethod(SortBySortTitle, 556, LABEL_MASKS(labelMask, "%M", labelMask, "%M"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_MPAA_RATING: { - dir->m_listItems->AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O", "%T", "%O")); + dir->m_listItems->AddSortMethod(SortByMPAA, 20074, LABEL_MASKS(labelMask, "%O", labelMask, "%O")); break; } case SORT_METHOD_STUDIO: case SORT_METHOD_STUDIO_IGNORE_THE: { - dir->m_listItems->AddSortMethod(SortByStudio, 572, LABEL_MASKS("%T", "%U", "%T", "%U"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); + dir->m_listItems->AddSortMethod(SortByStudio, 572, LABEL_MASKS(labelMask, "%U", labelMask, "%U"), CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_PROGRAM_COUNT: { - dir->m_listItems->AddSortMethod(SortByProgramCount, 567, LABEL_MASKS("%T", "%C", "%T", "%C")); + dir->m_listItems->AddSortMethod(SortByProgramCount, 567, LABEL_MASKS(labelMask, "%C", labelMask, "%C")); break; } case SORT_METHOD_UNSORTED: { - dir->m_listItems->AddSortMethod(SortByNone, 571, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByNone, 571, LABEL_MASKS(labelMask, label2Mask)); break; } case SORT_METHOD_NONE: { - dir->m_listItems->AddSortMethod(SortByNone, 552, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByNone, 552, LABEL_MASKS(labelMask, label2Mask)); break; } case SORT_METHOD_DRIVE_TYPE: @@ -390,48 +390,48 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const s } case SORT_METHOD_EPISODE: { - dir->m_listItems->AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%H. %T", "%R", "%H. %T", "%R")); + dir->m_listItems->AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS(labelMask, "%R", labelMask, "%R")); break; } case SORT_METHOD_PRODUCTIONCODE: { //dir->m_listItems.AddSortMethod(SORT_METHOD_PRODUCTIONCODE,20368,LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); - dir->m_listItems->AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%H. %T", "%P", "%H. %T", "%P")); + dir->m_listItems->AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS(labelMask, "%P", labelMask, "%P")); break; } case SORT_METHOD_LISTENERS: { - dir->m_listItems->AddSortMethod(SortByListeners, 20455, LABEL_MASKS("%T", "%W")); + dir->m_listItems->AddSortMethod(SortByListeners, 20455, LABEL_MASKS(labelMask, "%W")); break; } case SORT_METHOD_DATEADDED: { - dir->m_listItems->AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a")); + dir->m_listItems->AddSortMethod(SortByDateAdded, 570, LABEL_MASKS(labelMask, "%a")); break; } case SORT_METHOD_FULLPATH: { - dir->m_listItems->AddSortMethod(SortByPath, 573, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByPath, 573, LABEL_MASKS(labelMask, label2Mask)); break; } case SORT_METHOD_LABEL_IGNORE_FOLDERS: { - dir->m_listItems->AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS(labelMask, label2Mask)); break; } case SORT_METHOD_LASTPLAYED: { - dir->m_listItems->AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%G")); + dir->m_listItems->AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS(labelMask, "%G")); break; } case SORT_METHOD_PLAYCOUNT: { - dir->m_listItems->AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); + dir->m_listItems->AddSortMethod(SortByPlaycount, 567, LABEL_MASKS(labelMask, "%V", labelMask, "%V")); break; } case SORT_METHOD_CHANNEL: { - dir->m_listItems->AddSortMethod(SortByChannel, 19029, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByChannel, 19029, LABEL_MASKS(labelMask, label2Mask)); break; } @@ -637,7 +637,7 @@ bool CPluginDirectory::IsMediaLibraryScanningAllowed(const std::string& content, auto it = paths.find(content); if (it == paths.end()) return false; - std::string path = url.GetFileName(); + const std::string& path = url.GetFileName(); for (const auto& p : it->second) if (p.empty() || p == "/" || URIUtils::PathHasParent(path, p)) return true; diff --git a/xbmc/filesystem/PluginDirectory.h b/xbmc/filesystem/PluginDirectory.h index 65221ec8cc..2e239d957a 100644 --- a/xbmc/filesystem/PluginDirectory.h +++ b/xbmc/filesystem/PluginDirectory.h @@ -60,7 +60,7 @@ public: static bool AddItem(int handle, const CFileItem *item, int totalItems); static bool AddItems(int handle, const CFileItemList *items, int totalItems); static void EndOfDirectory(int handle, bool success, bool replaceListing, bool cacheToDisc); - static void AddSortMethod(int handle, SORT_METHOD sortMethod, const std::string &label2Mask); + static void AddSortMethod(int handle, SORT_METHOD sortMethod, const std::string &labelMask, const std::string &label2Mask); static std::string GetSetting(int handle, const std::string &key); static void SetSetting(int handle, const std::string &key, const std::string &value); static void SetContent(int handle, const std::string &strContent); diff --git a/xbmc/filesystem/RSSDirectory.cpp b/xbmc/filesystem/RSSDirectory.cpp index f2d9912abb..430daffb43 100644 --- a/xbmc/filesystem/RSSDirectory.cpp +++ b/xbmc/filesystem/RSSDirectory.cpp @@ -420,7 +420,7 @@ static void ParseItem(CFileItem* item, SResources& resources, TiXmlElement* root } } -static bool FindMime(SResources resources, std::string mime) +static bool FindMime(const SResources& resources, const std::string& mime) { for (const auto& it : resources) { diff --git a/xbmc/filesystem/ResourceFile.cpp b/xbmc/filesystem/ResourceFile.cpp index 9f485012f8..f319f12f76 100644 --- a/xbmc/filesystem/ResourceFile.cpp +++ b/xbmc/filesystem/ResourceFile.cpp @@ -37,7 +37,7 @@ bool CResourceFile::TranslatePath(const CURL &url, std::string &translatedPath) return false; // the share name represents an identifier that can be mapped to an addon ID - std::string addonId = url.GetShareName(); + const std::string& addonId = url.GetShareName(); std::string filePath; if (url.GetFileName().length() > addonId.length()) filePath = url.GetFileName().substr(addonId.size() + 1); diff --git a/xbmc/filesystem/SpecialProtocol.cpp b/xbmc/filesystem/SpecialProtocol.cpp index 9dfa1e6b34..2178955750 100644 --- a/xbmc/filesystem/SpecialProtocol.cpp +++ b/xbmc/filesystem/SpecialProtocol.cpp @@ -130,7 +130,7 @@ std::string CSpecialProtocol::TranslatePath(const CURL &url) return url.Get(); } - std::string FullFileName = url.GetFileName(); + const std::string& FullFileName = url.GetFileName(); std::string translatedPath; std::string FileName; diff --git a/xbmc/filesystem/UDFBlockInput.cpp b/xbmc/filesystem/UDFBlockInput.cpp index e25df6f4d4..623bbb9a5d 100644 --- a/xbmc/filesystem/UDFBlockInput.cpp +++ b/xbmc/filesystem/UDFBlockInput.cpp @@ -47,7 +47,7 @@ int CUDFBlockInput::Read( return static_cast<int>(read); } -udfread_block_input* CUDFBlockInput::GetBlockInput(std::string file) +udfread_block_input* CUDFBlockInput::GetBlockInput(const std::string& file) { auto fp = std::make_shared<XFILE::CFile>(); diff --git a/xbmc/filesystem/UDFBlockInput.h b/xbmc/filesystem/UDFBlockInput.h index 0506077ecb..7f0248a5d6 100644 --- a/xbmc/filesystem/UDFBlockInput.h +++ b/xbmc/filesystem/UDFBlockInput.h @@ -21,7 +21,7 @@ public: CUDFBlockInput() = default; ~CUDFBlockInput() = default; - udfread_block_input* GetBlockInput(std::string file); + udfread_block_input* GetBlockInput(const std::string& file); private: static int Close(udfread_block_input* bi); diff --git a/xbmc/filesystem/UPnPDirectory.cpp b/xbmc/filesystem/UPnPDirectory.cpp index 9dc8ff72e3..3a9f76419d 100644 --- a/xbmc/filesystem/UPnPDirectory.cpp +++ b/xbmc/filesystem/UPnPDirectory.cpp @@ -144,7 +144,7 @@ bool CUPnPDirectory::GetResource(const CURL& path, CFileItem &item) if(!upnp) return false; - std::string uuid = path.GetHostName(); + const std::string& uuid = path.GetHostName(); std::string object = path.GetFileName(); StringUtils::TrimRight(object, "/"); object = CURL::Decode(object); diff --git a/xbmc/filesystem/XbtFile.cpp b/xbmc/filesystem/XbtFile.cpp index 7b3f22324e..ab87f5e45b 100644 --- a/xbmc/filesystem/XbtFile.cpp +++ b/xbmc/filesystem/XbtFile.cpp @@ -41,8 +41,6 @@ bool CXbtFile::Open(const CURL& url) if (m_open) return false; - std::string options = url.GetOptions(); - CURL xbtUrl(url); xbtUrl.SetOptions(""); diff --git a/xbmc/filesystem/ZipFile.cpp b/xbmc/filesystem/ZipFile.cpp index 225e9fd624..6c358352a7 100644 --- a/xbmc/filesystem/ZipFile.cpp +++ b/xbmc/filesystem/ZipFile.cpp @@ -36,7 +36,7 @@ CZipFile::~CZipFile() bool CZipFile::Open(const CURL&url) { - std::string strOpts = url.GetOptions(); + const std::string& strOpts = url.GetOptions(); CURL url2(url); url2.SetOptions(""); if (!g_ZipManager.GetZipEntry(url2,mZipItem)) diff --git a/xbmc/filesystem/ZipManager.cpp b/xbmc/filesystem/ZipManager.cpp index b0819f2e29..1be97e7c37 100644 --- a/xbmc/filesystem/ZipManager.cpp +++ b/xbmc/filesystem/ZipManager.cpp @@ -219,7 +219,7 @@ bool CZipManager::GetZipList(const CURL& url, std::vector<SZipEntry>& items) bool CZipManager::GetZipEntry(const CURL& url, SZipEntry& item) { - std::string strFile = url.GetHostName(); + const std::string& strFile = url.GetHostName(); std::map<std::string, std::vector<SZipEntry> >::iterator it = mZipMap.find(strFile); std::vector<SZipEntry> items; @@ -232,7 +232,7 @@ bool CZipManager::GetZipEntry(const CURL& url, SZipEntry& item) items = it->second; } - std::string strFileName = url.GetFileName(); + const std::string& strFileName = url.GetFileName(); for (const auto& it2 : items) { if (std::string(it2.name) == strFileName) diff --git a/xbmc/games/GameSettings.cpp b/xbmc/games/GameSettings.cpp index 2bbfbf2bf0..fb57b815a3 100644 --- a/xbmc/games/GameSettings.cpp +++ b/xbmc/games/GameSettings.cpp @@ -85,7 +85,7 @@ unsigned int CGameSettings::MaxRewindTimeSec() return static_cast<unsigned int>(std::max(rewindTimeSec, 0)); } -void CGameSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGameSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/games/GameSettings.h b/xbmc/games/GameSettings.h index 727ce01cf4..59acac1975 100644 --- a/xbmc/games/GameSettings.h +++ b/xbmc/games/GameSettings.h @@ -35,7 +35,7 @@ public: unsigned int MaxRewindTimeSec(); // Inherited from ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; private: // Construction parameters diff --git a/xbmc/games/GameUtils.cpp b/xbmc/games/GameUtils.cpp index 1c0e884935..0733250c8b 100644 --- a/xbmc/games/GameUtils.cpp +++ b/xbmc/games/GameUtils.cpp @@ -48,10 +48,19 @@ bool CGameUtils::FillInGameClient(CFileItem& item, bool bPrompt) if (candidates.empty() && installable.empty()) { - int errorTextId = - bHasVfsGameClient ? 35214 : // "This game can only be played directly from a hard drive - // or partition. Compressed files must be extracted." - 35212; // "This game isn't compatible with any available emulators." + int errorTextId = 0; + + if (bHasVfsGameClient) + { + // "This game can only be played directly from a hard drive + // or partition. Compressed files must be extracted." + errorTextId = 35214; + } + else + { + // "This game isn't compatible with any available emulators." + errorTextId = 35212; + } // "Failed to play game" KODI::MESSAGING::HELPERS::ShowOKDialogText(CVariant{35210}, CVariant{errorTextId}); diff --git a/xbmc/games/controllers/ControllerManager.cpp b/xbmc/games/controllers/ControllerManager.cpp index 060136240f..428cd6bc99 100644 --- a/xbmc/games/controllers/ControllerManager.cpp +++ b/xbmc/games/controllers/ControllerManager.cpp @@ -26,7 +26,7 @@ ControllerPtr CControllerManager::GetController(const std::string& controllerId) { AddonPtr addon; if (CServiceBroker::GetAddonMgr().GetAddon(controllerId, addon, ADDON_GAME_CONTROLLER, false)) - cachedController = LoadController(std::move(addon)); + cachedController = LoadController(addon); } return cachedController; @@ -60,7 +60,7 @@ ControllerVector CControllerManager::GetControllers() { ControllerPtr& cachedController = m_cache[addon->ID()]; if (!cachedController && m_failedControllers.find(addon->ID()) == m_failedControllers.end()) - cachedController = LoadController(std::move(addon)); + cachedController = LoadController(addon); if (cachedController) controllers.emplace_back(cachedController); @@ -70,7 +70,7 @@ ControllerVector CControllerManager::GetControllers() return controllers; } -ControllerPtr CControllerManager::LoadController(ADDON::AddonPtr addon) +ControllerPtr CControllerManager::LoadController(const ADDON::AddonPtr& addon) { ControllerPtr controller = std::static_pointer_cast<CController>(addon); if (!controller->LoadLayout()) diff --git a/xbmc/games/controllers/ControllerManager.h b/xbmc/games/controllers/ControllerManager.h index 6143d64c95..3e7047b0fc 100644 --- a/xbmc/games/controllers/ControllerManager.h +++ b/xbmc/games/controllers/ControllerManager.h @@ -67,7 +67,7 @@ public: ControllerVector GetControllers(); private: - ControllerPtr LoadController(ADDON::AddonPtr addon); + ControllerPtr LoadController(const ADDON::AddonPtr& addon); std::map<std::string, ControllerPtr> m_cache; std::set<std::string> m_failedControllers; // Controllers that failed to load diff --git a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp index b7f7ef4895..9625f317f9 100644 --- a/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp +++ b/xbmc/games/controllers/dialogs/GUIDialogAxisDetection.cpp @@ -22,7 +22,7 @@ using namespace GAME; std::string CGUIDialogAxisDetection::GetDialogText() { // "Press all analog buttons now to detect them:[CR][CR]%s" - std::string dialogText = g_localizeStrings.Get(35020); + const std::string& dialogText = g_localizeStrings.Get(35020); std::vector<std::string> primitives; diff --git a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp index 943b4d26ec..d6843415cc 100644 --- a/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp +++ b/xbmc/games/controllers/dialogs/GUIDialogIgnoreInput.cpp @@ -39,7 +39,7 @@ std::string CGUIDialogIgnoreInput::GetDialogText() { // "Some controllers have buttons and axes that interfere with mapping. Press // these now to disable them:[CR]%s" - std::string dialogText = g_localizeStrings.Get(35014); + const std::string& dialogText = g_localizeStrings.Get(35014); std::vector<std::string> primitives; diff --git a/xbmc/games/controllers/guicontrols/GUIScalarFeatureButton.cpp b/xbmc/games/controllers/guicontrols/GUIScalarFeatureButton.cpp index aa8a5b6b83..c61945b18e 100644 --- a/xbmc/games/controllers/guicontrols/GUIScalarFeatureButton.cpp +++ b/xbmc/games/controllers/guicontrols/GUIScalarFeatureButton.cpp @@ -32,8 +32,8 @@ bool CGUIScalarFeatureButton::PromptForInput(CEvent& waitEvent) { case STATE::NEED_INPUT: { - std::string strPrompt = g_localizeStrings.Get(35090); // "Press %s" - std::string strWarn = g_localizeStrings.Get(35091); // "Press %s (%d)" + const std::string& strPrompt = g_localizeStrings.Get(35090); // "Press %s" + const std::string& strWarn = g_localizeStrings.Get(35091); // "Press %s (%d)" bInterrupted = DoPrompt(strPrompt, strWarn, m_feature.Label(), waitEvent); diff --git a/xbmc/games/controllers/guicontrols/GUISelectKeyButton.cpp b/xbmc/games/controllers/guicontrols/GUISelectKeyButton.cpp index 3713719196..0ad3640b48 100644 --- a/xbmc/games/controllers/guicontrols/GUISelectKeyButton.cpp +++ b/xbmc/games/controllers/guicontrols/GUISelectKeyButton.cpp @@ -38,8 +38,8 @@ bool CGUISelectKeyButton::PromptForInput(CEvent& waitEvent) { case STATE::NEED_KEY: { - std::string strPrompt = g_localizeStrings.Get(35169); // "Press a key" - std::string strWarn = g_localizeStrings.Get(35170); // "Press a key ({1:d})" + const std::string& strPrompt = g_localizeStrings.Get(35169); // "Press a key" + const std::string& strWarn = g_localizeStrings.Get(35170); // "Press a key ({1:d})" bInterrupted = DoPrompt(strPrompt, strWarn, "", waitEvent); @@ -49,8 +49,8 @@ bool CGUISelectKeyButton::PromptForInput(CEvent& waitEvent) } case STATE::NEED_INPUT: { - std::string strPrompt = g_localizeStrings.Get(35090); // "Press {0:s}" - std::string strWarn = g_localizeStrings.Get(35091); // "Press {0:s} ({1:d})" + const std::string& strPrompt = g_localizeStrings.Get(35090); // "Press {0:s}" + const std::string& strWarn = g_localizeStrings.Get(35091); // "Press {0:s} ({1:d})" bInterrupted = DoPrompt(strPrompt, strWarn, m_selectedKey.Label(), waitEvent); diff --git a/xbmc/games/controllers/windows/ControllerInstaller.cpp b/xbmc/games/controllers/windows/ControllerInstaller.cpp index 74f942e1fa..b6c17c289a 100644 --- a/xbmc/games/controllers/windows/ControllerInstaller.cpp +++ b/xbmc/games/controllers/windows/ControllerInstaller.cpp @@ -98,7 +98,7 @@ void CControllerInstaller::Process() const auto& addon = installableAddons[installedCount]; // Set dialog text - const std::string progressTemplate = g_localizeStrings.Get(24057); // "Installing {0:s}..." + const std::string& progressTemplate = g_localizeStrings.Get(24057); // "Installing {0:s}..." const std::string progressText = StringUtils::Format(progressTemplate, addon->Name()); pProgressDialog->SetLine(0, CVariant{progressText}); diff --git a/xbmc/games/dialogs/osd/DialogGameVolume.h b/xbmc/games/dialogs/osd/DialogGameVolume.h index d06f140a52..a32339d4bd 100644 --- a/xbmc/games/dialogs/osd/DialogGameVolume.h +++ b/xbmc/games/dialogs/osd/DialogGameVolume.h @@ -41,11 +41,11 @@ public: // implementation of IGUIVolumeBarCallback bool IsShown() const override; - // implementation of IAnnouncer - void Announce(ANNOUNCEMENT::AnnouncementFlag flag, - const std::string& sender, - const std::string& message, - const CVariant& data) override; + // implementation of IAnnouncer + void Announce(ANNOUNCEMENT::AnnouncementFlag flag, + const std::string& sender, + const std::string& message, + const CVariant& data) override; protected: // implementation of CGUIWindow via CGUIDialogSlider diff --git a/xbmc/games/windows/GUIViewStateWindowGames.cpp b/xbmc/games/windows/GUIViewStateWindowGames.cpp index 1473542f86..1b82ac4132 100644 --- a/xbmc/games/windows/GUIViewStateWindowGames.cpp +++ b/xbmc/games/windows/GUIViewStateWindowGames.cpp @@ -66,7 +66,7 @@ std::string CGUIViewStateWindowGames::GetExtensions() std::set<std::string> exts = CGameUtils::GetGameExtensions(); // Ensure .zip appears - if (std::find(exts.begin(), exts.end(), ".zip") == exts.end()) + if (exts.find(".zip") == exts.end()) exts.insert(".zip"); return StringUtils::Join(exts, "|"); diff --git a/xbmc/guilib/GUIAudioManager.cpp b/xbmc/guilib/GUIAudioManager.cpp index 0f1488f68e..e3fb16d024 100644 --- a/xbmc/guilib/GUIAudioManager.cpp +++ b/xbmc/guilib/GUIAudioManager.cpp @@ -41,7 +41,7 @@ CGUIAudioManager::~CGUIAudioManager() m_settings->UnregisterCallback(this); } -void CGUIAudioManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIAudioManager::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -54,7 +54,9 @@ void CGUIAudioManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) } } -bool CGUIAudioManager::OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +bool CGUIAudioManager::OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) { if (setting == NULL) return false; diff --git a/xbmc/guilib/GUIAudioManager.h b/xbmc/guilib/GUIAudioManager.h index 88fa21f64e..b081b2f597 100644 --- a/xbmc/guilib/GUIAudioManager.h +++ b/xbmc/guilib/GUIAudioManager.h @@ -44,8 +44,10 @@ public: CGUIAudioManager(); ~CGUIAudioManager() override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) override; void Initialize(); void DeInitialize(); diff --git a/xbmc/guilib/GUIBaseContainer.cpp b/xbmc/guilib/GUIBaseContainer.cpp index 83bd0002fb..b5e3360d01 100644 --- a/xbmc/guilib/GUIBaseContainer.cpp +++ b/xbmc/guilib/GUIBaseContainer.cpp @@ -60,7 +60,7 @@ CGUIBaseContainer::CGUIBaseContainer(const CGUIBaseContainer &) = default; CGUIBaseContainer::~CGUIBaseContainer(void) { // release the container from items - for (auto item : m_items) + for (const auto& item : m_items) item->FreeMemory(); delete m_listProvider; @@ -86,6 +86,9 @@ void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirt // update our auto-scrolling as necessary UpdateAutoScrolling(currentTime); + if (!m_waitForScrollEnd && !m_gestureActive) + ValidateOffset(); + if (m_bInvalidated) UpdateLayout(); @@ -298,7 +301,7 @@ bool CGUIBaseContainer::OnAction(const CAction &action) { std::string letter; g_charsetConverter.wToUTF8({action.GetUnicode()}, letter); - OnJumpLetter(std::move(letter)); + OnJumpLetter(letter); return true; } // stop the timer on any other action @@ -562,7 +565,7 @@ void CGUIBaseContainer::OnPrevLetter() } } -void CGUIBaseContainer::OnJumpLetter(std::string letter, bool skip /*=false*/) +void CGUIBaseContainer::OnJumpLetter(const std::string& letter, bool skip /*=false*/) { if (m_matchTimer.GetElapsedMilliseconds() < letter_match_timeout) m_match += letter; @@ -735,6 +738,7 @@ EVENT_RESULT CGUIBaseContainer::OnMouseEvent(const CPoint &point, const CMouseEv } else if (event.m_id == ACTION_GESTURE_BEGIN) { // grab exclusive access + m_gestureActive = true; CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID()); SendWindowMessage(msg); return EVENT_RESULT_HANDLED; @@ -781,6 +785,7 @@ EVENT_RESULT CGUIBaseContainer::OnMouseEvent(const CPoint &point, const CMouseEv SetCursor(GetCursor()); SetFocus(true); m_waitForScrollEnd = false; + m_gestureActive = false; return EVENT_RESULT_HANDLED; } return EVENT_RESULT_UNHANDLED; @@ -1358,7 +1363,7 @@ std::string CGUIBaseContainer::GetLabel(int info) const case CONTAINER_NUM_NONFOLDER_ITEMS: { int numItems = 0; - for (auto item : m_items) + for (const auto& item : m_items) { if (!item->m_bIsFolder) numItems++; diff --git a/xbmc/guilib/GUIBaseContainer.h b/xbmc/guilib/GUIBaseContainer.h index 832958219d..c9850badfe 100644 --- a/xbmc/guilib/GUIBaseContainer.h +++ b/xbmc/guilib/GUIBaseContainer.h @@ -172,7 +172,7 @@ protected: bool ScrollingUp() const { return m_scroller.IsScrollingUp(); }; void OnNextLetter(); void OnPrevLetter(); - void OnJumpLetter(std::string letter, bool skip = false); + void OnJumpLetter(const std::string& letter, bool skip = false); void OnJumpSMS(int letter); std::vector< std::pair<int, std::string> > m_letterOffsets; @@ -227,6 +227,8 @@ private: float m_scrollItemsPerFrame; static const int letter_match_timeout = 1000; + bool m_gestureActive = false; + // early inertial scroll cancellation bool m_waitForScrollEnd = false; float m_lastScrollValue = 0.0f; diff --git a/xbmc/guilib/GUIComponent.cpp b/xbmc/guilib/GUIComponent.cpp index c2d5301f40..e143e7557e 100644 --- a/xbmc/guilib/GUIComponent.cpp +++ b/xbmc/guilib/GUIComponent.cpp @@ -86,7 +86,7 @@ CGUIAudioManager &CGUIComponent::GetAudioManager() return *m_guiAudioManager; } -bool CGUIComponent::ConfirmDelete(std::string path) +bool CGUIComponent::ConfirmDelete(const std::string& path) { CGUIDialogYesNo* pDialog = GetWindowManager().GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO); if (pDialog) diff --git a/xbmc/guilib/GUIComponent.h b/xbmc/guilib/GUIComponent.h index 5b564885b2..97ada489b5 100644 --- a/xbmc/guilib/GUIComponent.h +++ b/xbmc/guilib/GUIComponent.h @@ -35,7 +35,7 @@ public: CGUIColorManager &GetColorManager(); CGUIAudioManager &GetAudioManager(); - bool ConfirmDelete(std::string path); + bool ConfirmDelete(const std::string& path); protected: // members are pointers in order to avoid includes diff --git a/xbmc/guilib/GUIEditControl.cpp b/xbmc/guilib/GUIEditControl.cpp index ded5f3ecdf..179512f953 100644 --- a/xbmc/guilib/GUIEditControl.cpp +++ b/xbmc/guilib/GUIEditControl.cpp @@ -367,7 +367,7 @@ void CGUIEditControl::UpdateText(bool sendUpdate) SetInvalid(); } -void CGUIEditControl::SetInputType(CGUIEditControl::INPUT_TYPE type, CVariant heading) +void CGUIEditControl::SetInputType(CGUIEditControl::INPUT_TYPE type, const CVariant& heading) { m_inputType = type; if (heading.isString()) diff --git a/xbmc/guilib/GUIEditControl.h b/xbmc/guilib/GUIEditControl.h index 89e9ae266a..7e359eeaec 100644 --- a/xbmc/guilib/GUIEditControl.h +++ b/xbmc/guilib/GUIEditControl.h @@ -61,7 +61,7 @@ public: unsigned int GetCursorPosition() const; void SetCursorPosition(unsigned int iPosition); - void SetInputType(INPUT_TYPE type, CVariant heading); + void SetInputType(INPUT_TYPE type, const CVariant& heading); void SetTextChangeActions(const CGUIAction& textChangeActions) { m_textChangeActions = textChangeActions; }; diff --git a/xbmc/guilib/GUIFontManager.cpp b/xbmc/guilib/GUIFontManager.cpp index e56652487f..0d06193abf 100644 --- a/xbmc/guilib/GUIFontManager.cpp +++ b/xbmc/guilib/GUIFontManager.cpp @@ -453,7 +453,10 @@ void GUIFontManager::GetStyle(const TiXmlNode *fontNode, int &iStyle) } } -void GUIFontManager::SettingOptionsFontsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void GUIFontManager::SettingOptionsFontsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { CFileItemList items; CFileItemList items2; diff --git a/xbmc/guilib/GUIFontManager.h b/xbmc/guilib/GUIFontManager.h index 897cb8de17..0d1165f5d1 100644 --- a/xbmc/guilib/GUIFontManager.h +++ b/xbmc/guilib/GUIFontManager.h @@ -66,7 +66,10 @@ public: void Clear(); void FreeFontFile(CGUIFontTTF* pFont); - static void SettingOptionsFontsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); + static void SettingOptionsFontsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); protected: void ReloadTTFFonts(); diff --git a/xbmc/guilib/GUIIncludes.cpp b/xbmc/guilib/GUIIncludes.cpp index f8f4a90fea..b88be087f0 100644 --- a/xbmc/guilib/GUIIncludes.cpp +++ b/xbmc/guilib/GUIIncludes.cpp @@ -291,7 +291,7 @@ void CGUIIncludes::FlattenSkinVariableConditions() bool CGUIIncludes::HasLoaded(const std::string &file) const { - for (auto loadedFile : m_files) + for (const auto& loadedFile : m_files) { if (loadedFile == file) return true; diff --git a/xbmc/guilib/GUIKeyboardFactory.cpp b/xbmc/guilib/GUIKeyboardFactory.cpp index 181e146c0d..9ee48cbade 100644 --- a/xbmc/guilib/GUIKeyboardFactory.cpp +++ b/xbmc/guilib/GUIKeyboardFactory.cpp @@ -74,7 +74,11 @@ bool CGUIKeyboardFactory::SendTextToActiveKeyboard(const std::string &aTextStrin // Show keyboard with initial value (aTextString) and replace with result string. // Returns: true - successful display and input (empty result may return true or false depending on parameter) // false - unsuccessful display of the keyboard or cancelled editing -bool CGUIKeyboardFactory::ShowAndGetInput(std::string& aTextString, CVariant heading, bool allowEmptyResult, bool hiddenInput /* = false */, unsigned int autoCloseMs /* = 0 */) +bool CGUIKeyboardFactory::ShowAndGetInput(std::string& aTextString, + const CVariant& heading, + bool allowEmptyResult, + bool hiddenInput /* = false */, + unsigned int autoCloseMs /* = 0 */) { bool confirmed = false; //heading can be a string or a localization id @@ -127,7 +131,10 @@ bool CGUIKeyboardFactory::ShowAndGetInput(std::string& aTextString, bool allowEm // Shows keyboard and prompts for a password. // Differs from ShowAndVerifyNewPassword() in that no second verification is necessary. -bool CGUIKeyboardFactory::ShowAndGetNewPassword(std::string& newPassword, CVariant heading, bool allowEmpty, unsigned int autoCloseMs /* = 0 */) +bool CGUIKeyboardFactory::ShowAndGetNewPassword(std::string& newPassword, + const CVariant& heading, + bool allowEmpty, + unsigned int autoCloseMs /* = 0 */) { return ShowAndGetInput(newPassword, heading, allowEmpty, true, autoCloseMs); } @@ -153,7 +160,10 @@ bool CGUIKeyboardFactory::ShowAndGetFilter(std::string &filter, bool searching, // \param heading Heading to display // \param allowEmpty Whether a blank password is valid or not. // \return true if successful display and user input entry/re-entry. false if unsuccessful display, no user input, or canceled editing. -bool CGUIKeyboardFactory::ShowAndVerifyNewPassword(std::string& newPassword, CVariant heading, bool allowEmpty, unsigned int autoCloseMs /* = 0 */) +bool CGUIKeyboardFactory::ShowAndVerifyNewPassword(std::string& newPassword, + const CVariant& heading, + bool allowEmpty, + unsigned int autoCloseMs /* = 0 */) { // Prompt user for password input std::string userInput; @@ -182,7 +192,7 @@ bool CGUIKeyboardFactory::ShowAndVerifyNewPassword(std::string& newPassword, CVa // \return true if successful display and user input entry/re-entry. false if unsuccessful display, no user input, or canceled editing. bool CGUIKeyboardFactory::ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs /* = 0 */) { - std::string heading = g_localizeStrings.Get(12340); + const std::string& heading = g_localizeStrings.Get(12340); return ShowAndVerifyNewPassword(newPassword, heading, false, autoCloseMs); } diff --git a/xbmc/guilib/GUIKeyboardFactory.h b/xbmc/guilib/GUIKeyboardFactory.h index ab53354efc..04272af78a 100644 --- a/xbmc/guilib/GUIKeyboardFactory.h +++ b/xbmc/guilib/GUIKeyboardFactory.h @@ -22,11 +22,21 @@ class CGUIKeyboardFactory virtual ~CGUIKeyboardFactory(void); static bool ShowAndGetInput(std::string& aTextString, bool allowEmptyResult, unsigned int autoCloseMs = 0); - static bool ShowAndGetInput(std::string& aTextString, CVariant heading, bool allowEmptyResult, bool hiddenInput = false, unsigned int autoCloseMs = 0); + static bool ShowAndGetInput(std::string& aTextString, + const CVariant& heading, + bool allowEmptyResult, + bool hiddenInput = false, + unsigned int autoCloseMs = 0); static bool ShowAndGetNewPassword(std::string& strNewPassword, unsigned int autoCloseMs = 0); - static bool ShowAndGetNewPassword(std::string& newPassword, CVariant heading, bool allowEmpty, unsigned int autoCloseMs = 0); + static bool ShowAndGetNewPassword(std::string& newPassword, + const CVariant& heading, + bool allowEmpty, + unsigned int autoCloseMs = 0); static bool ShowAndVerifyNewPassword(std::string& strNewPassword, unsigned int autoCloseMs = 0); - static bool ShowAndVerifyNewPassword(std::string& newPassword, CVariant heading, bool allowEmpty, unsigned int autoCloseMs = 0); + static bool ShowAndVerifyNewPassword(std::string& newPassword, + const CVariant& heading, + bool allowEmpty, + unsigned int autoCloseMs = 0); static int ShowAndVerifyPassword(std::string& strPassword, const std::string& strHeading, int iRetries, unsigned int autoCloseMs = 0); static bool ShowAndGetFilter(std::string& aTextString, bool searching, unsigned int autoCloseMs = 0); diff --git a/xbmc/guilib/GUIStaticItem.cpp b/xbmc/guilib/GUIStaticItem.cpp index ea67c89ca1..f251c0bb5c 100644 --- a/xbmc/guilib/GUIStaticItem.cpp +++ b/xbmc/guilib/GUIStaticItem.cpp @@ -71,7 +71,7 @@ void CGUIStaticItem::UpdateProperties(int contextWindow) const GUIINFO::CGUIInfoLabel& info = i.first; const std::string& name = i.second; bool preferTexture = StringUtils::CompareNoCase("label", name, 5) != 0; - std::string value(info.GetLabel(contextWindow, preferTexture)); + const std::string& value(info.GetLabel(contextWindow, preferTexture)); if (StringUtils::EqualsNoCase(name, "label")) SetLabel(value); else if (StringUtils::EqualsNoCase(name, "label2")) diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp index 72313ab884..a6dc6af933 100644 --- a/xbmc/guilib/GUIWindow.cpp +++ b/xbmc/guilib/GUIWindow.cpp @@ -744,7 +744,8 @@ void CGUIWindow::AllocResources(bool forceLoad /*= false */) std::string xmlFile = GetProperty("xmlfile").asString(); if (xmlFile.size()) { - bool bHasPath = xmlFile.find("\\") != std::string::npos || xmlFile.find("/") != std::string::npos; + bool bHasPath = + xmlFile.find('\\') != std::string::npos || xmlFile.find('/') != std::string::npos; Load(xmlFile, bHasPath); } } diff --git a/xbmc/guilib/Shader.cpp b/xbmc/guilib/Shader.cpp index d6e842ee01..f8f0409bf4 100644 --- a/xbmc/guilib/Shader.cpp +++ b/xbmc/guilib/Shader.cpp @@ -48,7 +48,7 @@ bool CShader::LoadSource(const std::string& filename, const std::string& prefix) size_t versionPos = m_source.find("#version"); if (versionPos != std::string::npos) { - versionPos = m_source.find("\n", versionPos); + versionPos = m_source.find('\n', versionPos); if (versionPos != std::string::npos) pos = versionPos + 1; } diff --git a/xbmc/guilib/StereoscopicsManager.cpp b/xbmc/guilib/StereoscopicsManager.cpp index e99b71c29a..e6f6aeb11d 100644 --- a/xbmc/guilib/StereoscopicsManager.cpp +++ b/xbmc/guilib/StereoscopicsManager.cpp @@ -162,7 +162,7 @@ RENDER_STEREO_MODE CStereoscopicsManager::GetNextSupportedStereoMode(const RENDE std::string CStereoscopicsManager::DetectStereoModeByString(const std::string &needle) const { std::string stereoMode; - std::string searchString(needle); + const std::string& searchString(needle); CRegExp re(true); if (!re.RegComp(CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_stereoscopicregex_3d.c_str())) @@ -377,7 +377,7 @@ CAction CStereoscopicsManager::ConvertActionCommandToAction(const std::string &c return CAction(ACTION_NONE); } -void CStereoscopicsManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CStereoscopicsManager::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/guilib/StereoscopicsManager.h b/xbmc/guilib/StereoscopicsManager.h index 0166d75cda..8de93dc189 100644 --- a/xbmc/guilib/StereoscopicsManager.h +++ b/xbmc/guilib/StereoscopicsManager.h @@ -59,7 +59,7 @@ public: static CAction ConvertActionCommandToAction(const std::string &command, const std::string ¶meter); static std::string NormalizeStereoMode(const std::string &mode); - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; void OnStreamChange(); bool OnMessage(CGUIMessage &message) override; /*! diff --git a/xbmc/guilib/VisibleEffect.cpp b/xbmc/guilib/VisibleEffect.cpp index 470cfd4539..88bcea5f80 100644 --- a/xbmc/guilib/VisibleEffect.cpp +++ b/xbmc/guilib/VisibleEffect.cpp @@ -18,6 +18,8 @@ #include "utils/XMLUtils.h" #include "utils/log.h" +#include <utility> + CAnimEffect::CAnimEffect(const TiXmlElement *node, EFFECT_TYPE effect) { m_effect = effect; @@ -695,7 +697,7 @@ CScroller::CScroller(unsigned int duration /* = 200 */, std::shared_ptr<Tweener> m_startPosition = 0; m_hasResumePoint = false; m_duration = duration > 0 ? duration : 1; - m_pTweener = tweener; + m_pTweener = std::move(tweener); } CScroller::CScroller(const CScroller& right) diff --git a/xbmc/guilib/guiinfo/AddonsGUIInfo.cpp b/xbmc/guilib/guiinfo/AddonsGUIInfo.cpp index da16d960e3..e8af7ae1d6 100644 --- a/xbmc/guilib/guiinfo/AddonsGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/AddonsGUIInfo.cpp @@ -112,10 +112,9 @@ bool CAddonsGUIInfo::GetLabel(std::string& value, const CFileItem *item, int con value = g_localizeStrings.Get(24992); return true; } - ADDON::AddonPtr origin; - if (CServiceBroker::GetAddonMgr().GetAddon(item->GetAddonInfo()->Origin(), origin, ADDON::ADDON_UNKNOWN, false)) + if (!item->GetAddonInfo()->OriginName().empty()) { - value = origin->Name(); + value = item->GetAddonInfo()->OriginName(); return true; } else if (!item->GetAddonInfo()->Origin().empty()) diff --git a/xbmc/guilib/guiinfo/GUIInfoLabel.cpp b/xbmc/guilib/guiinfo/GUIInfoLabel.cpp index 23201146b2..5209ba390e 100644 --- a/xbmc/guilib/guiinfo/GUIInfoLabel.cpp +++ b/xbmc/guilib/guiinfo/GUIInfoLabel.cpp @@ -172,7 +172,7 @@ std::string LocalizeReplacer(const std::string &str) std::string AddonReplacer(const std::string &str) { // assumes "addon.id #####" - size_t length = str.find(" "); + size_t length = str.find(' '); const std::string addonid = str.substr(0, length); int stringid = atoi(str.substr(length + 1).c_str()); return g_localizeStrings.GetAddonString(addonid, stringid); diff --git a/xbmc/guilib/guiinfo/GUIInfoLabels.h b/xbmc/guilib/guiinfo/GUIInfoLabels.h index 306b791237..4063c227ec 100644 --- a/xbmc/guilib/guiinfo/GUIInfoLabels.h +++ b/xbmc/guilib/guiinfo/GUIInfoLabels.h @@ -457,7 +457,7 @@ #define SYSTEM_PLATFORM_DARWIN_IOS 745 #define SYSTEM_PLATFORM_UWP 746 #define SYSTEM_PLATFORM_ANDROID 747 -// previously used by rpi 748 +#define SYSTEM_PLATFORM_WINDOWING 748 #define SYSTEM_PLATFORM_WIN10 749 #define SYSTEM_CAN_POWERDOWN 750 diff --git a/xbmc/guilib/guiinfo/GUIInfoProvider.h b/xbmc/guilib/guiinfo/GUIInfoProvider.h index d807fa75d1..a03159b8f6 100644 --- a/xbmc/guilib/guiinfo/GUIInfoProvider.h +++ b/xbmc/guilib/guiinfo/GUIInfoProvider.h @@ -26,6 +26,15 @@ public: CGUIInfoProvider() = default; ~CGUIInfoProvider() override = default; + bool GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const CGUIInfo& info, + std::string* fallback) override + { + return false; + } + void UpdateAVInfo(const AudioStreamInfo& audioInfo, const VideoStreamInfo& videoInfo, const SubtitleStreamInfo& subtitleInfo) override { m_audioInfo = audioInfo, m_videoInfo = videoInfo, m_subtitleInfo = subtitleInfo; } diff --git a/xbmc/guilib/guiinfo/GUIInfoProviders.cpp b/xbmc/guilib/guiinfo/GUIInfoProviders.cpp index 5a57700a24..274318e220 100644 --- a/xbmc/guilib/guiinfo/GUIInfoProviders.cpp +++ b/xbmc/guilib/guiinfo/GUIInfoProviders.cpp @@ -85,6 +85,11 @@ bool CGUIInfoProviders::GetLabel(std::string& value, const CFileItem *item, int if (provider->GetLabel(value, item, contextWindow, info, fallback)) return true; } + for (const auto& provider : m_providers) + { + if (provider->GetFallbackLabel(value, item, contextWindow, info, fallback)) + return true; + } return false; } diff --git a/xbmc/guilib/guiinfo/IGUIInfoProvider.h b/xbmc/guilib/guiinfo/IGUIInfoProvider.h index d84d337050..4560b08dd2 100644 --- a/xbmc/guilib/guiinfo/IGUIInfoProvider.h +++ b/xbmc/guilib/guiinfo/IGUIInfoProvider.h @@ -49,6 +49,22 @@ public: virtual bool GetLabel(std::string &value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const = 0; /*! + * @brief Get a GUIInfoManager label fallback string. Will be called if none of the registered + * provider's GetLabel() implementation has returned success. + * @param value Will be filled with the requested value. + * @param item The item to get the value for. Can be nullptr. + * @param contextWindow The context window. Can be 0. + * @param info The GUI info (label id + additional data). + * @param fallback A fallback value. Can be nullptr. + * @return True if the value was filled successfully, false otherwise. + */ + virtual bool GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const CGUIInfo& info, + std::string* fallback) = 0; + + /*! * @brief Get a GUIInfoManager integer value. * @param value Will be filled with the requested value. * @param item The item to get the value for. Can be nullptr. diff --git a/xbmc/guilib/guiinfo/MusicGUIInfo.cpp b/xbmc/guilib/guiinfo/MusicGUIInfo.cpp index 256a97f4d0..3e385411e0 100644 --- a/xbmc/guilib/guiinfo/MusicGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/MusicGUIInfo.cpp @@ -41,11 +41,6 @@ bool CMusicGUIInfo::InitCurrentItem(CFileItem *item) item->LoadMusicTag(); CMusicInfoTag* tag = item->GetMusicInfoTag(); // creates item if not yet set, so no nullptr checks needed - if (tag->GetTitle().empty()) - { - // No title in tag, show filename only - tag->SetTitle(CUtil::GetTitleFromPath(item->GetPath())); - } tag->SetLoaded(true); // find a thumb for this file. @@ -103,11 +98,7 @@ bool CMusicGUIInfo::GetLabel(std::string& value, const CFileItem *item, int cont return !value.empty(); case MUSICPLAYER_TITLE: value = tag->GetTitle(); - if (value.empty()) - value = item->GetLabel(); - if (value.empty()) - value = CUtil::GetTitleFromPath(item->GetPath()); - return true; + return !value.empty(); case LISTITEM_TITLE: value = tag->GetTitle(); return true; @@ -122,7 +113,7 @@ bool CMusicGUIInfo::GetLabel(std::string& value, const CFileItem *item, int cont case MUSICPLAYER_LASTPLAYED: case LISTITEM_LASTPLAYED: { - const CDateTime dateTime = tag->GetLastPlayed(); + const CDateTime& dateTime = tag->GetLastPlayed(); if (dateTime.IsValid()) { value = dateTime.GetAsLocalizedDate(); @@ -574,6 +565,32 @@ bool CMusicGUIInfo::GetPlaylistInfo(std::string& value, const CGUIInfo &info) co return GetLabel(value, playlistItem.get(), 0, CGUIInfo(info.m_info), nullptr); } +bool CMusicGUIInfo::GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const CGUIInfo& info, + std::string* fallback) +{ + const CMusicInfoTag* tag = item->GetMusicInfoTag(); + if (tag) + { + switch (info.m_info) + { + ///////////////////////////////////////////////////////////////////////////////////////////// + // MUSICPLAYER_* + ///////////////////////////////////////////////////////////////////////////////////////////// + case MUSICPLAYER_TITLE: + value = item->GetLabel(); + if (value.empty()) + value = CUtil::GetTitleFromPath(item->GetPath()); + return true; + default: + break; + } + } + return false; +} + bool CMusicGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const { return false; diff --git a/xbmc/guilib/guiinfo/MusicGUIInfo.h b/xbmc/guilib/guiinfo/MusicGUIInfo.h index da168e790b..4132ca656e 100644 --- a/xbmc/guilib/guiinfo/MusicGUIInfo.h +++ b/xbmc/guilib/guiinfo/MusicGUIInfo.h @@ -28,6 +28,11 @@ public: // KODI::GUILIB::GUIINFO::IGUIInfoProvider implementation bool InitCurrentItem(CFileItem *item) override; bool GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const override; + bool GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const CGUIInfo& info, + std::string* fallback) override; bool GetInt(int& value, const CGUIListItem *item, int contextWindow, const CGUIInfo &info) const override; bool GetBool(bool& value, const CGUIListItem *item, int contextWindow, const CGUIInfo &info) const override; diff --git a/xbmc/guilib/guiinfo/SystemGUIInfo.cpp b/xbmc/guilib/guiinfo/SystemGUIInfo.cpp index 8357b76052..a310281956 100644 --- a/xbmc/guilib/guiinfo/SystemGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/SystemGUIInfo.cpp @@ -308,6 +308,12 @@ bool CSystemGUIInfo::GetLabel(std::string& value, const CFileItem *item, int con case SYSTEM_ADDON_UPDATE_COUNT: value = CServiceBroker::GetAddonMgr().GetLastAvailableUpdatesCountAsString(); return true; +#if defined(TARGET_LINUX) + case SYSTEM_PLATFORM_WINDOWING: + value = CServiceBroker::GetWinSystem()->GetName(); + StringUtils::ToCapitalize(value); + return true; +#endif /////////////////////////////////////////////////////////////////////////////////////////////// // NETWORK_* diff --git a/xbmc/guilib/guiinfo/VideoGUIInfo.cpp b/xbmc/guilib/guiinfo/VideoGUIInfo.cpp index 80a69a2eb7..3924360304 100644 --- a/xbmc/guilib/guiinfo/VideoGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/VideoGUIInfo.cpp @@ -116,11 +116,7 @@ bool CVideoGUIInfo::GetLabel(std::string& value, const CFileItem *item, int cont return !value.empty(); case VIDEOPLAYER_TITLE: value = tag->m_strTitle; - if (value.empty()) - value = item->GetLabel(); - if (value.empty()) - value = CUtil::GetTitleFromPath(item->GetPath()); - return true; + return !value.empty(); case LISTITEM_TITLE: value = tag->m_strTitle; return true; @@ -637,6 +633,32 @@ bool CVideoGUIInfo::GetPlaylistInfo(std::string& value, const CGUIInfo& info) co return GetLabel(value, playlistItem.get(), 0, CGUIInfo(info.m_info), nullptr); } +bool CVideoGUIInfo::GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const CGUIInfo& info, + std::string* fallback) +{ + const CVideoInfoTag* tag = item->GetVideoInfoTag(); + if (tag) + { + switch (info.m_info) + { + ///////////////////////////////////////////////////////////////////////////////////////////// + // VIDEOPLAYER_* + ///////////////////////////////////////////////////////////////////////////////////////////// + case VIDEOPLAYER_TITLE: + value = item->GetLabel(); + if (value.empty()) + value = CUtil::GetTitleFromPath(item->GetPath()); + return true; + default: + break; + } + } + return false; +} + bool CVideoGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const { if (!gitem->IsFileItem()) diff --git a/xbmc/guilib/guiinfo/VideoGUIInfo.h b/xbmc/guilib/guiinfo/VideoGUIInfo.h index 557ca167c6..1f7b735c12 100644 --- a/xbmc/guilib/guiinfo/VideoGUIInfo.h +++ b/xbmc/guilib/guiinfo/VideoGUIInfo.h @@ -30,6 +30,11 @@ public: // KODI::GUILIB::GUIINFO::IGUIInfoProvider implementation bool InitCurrentItem(CFileItem *item) override; bool GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const override; + bool GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const CGUIInfo& info, + std::string* fallback) override; bool GetInt(int& value, const CGUIListItem *item, int contextWindow, const CGUIInfo &info) const override; bool GetBool(bool& value, const CGUIListItem *item, int contextWindow, const CGUIInfo &info) const override; diff --git a/xbmc/guilib/imagefactory.cpp b/xbmc/guilib/imagefactory.cpp index 1234369b3c..f6bbbb78c4 100644 --- a/xbmc/guilib/imagefactory.cpp +++ b/xbmc/guilib/imagefactory.cpp @@ -38,7 +38,7 @@ IImage* ImageFactory::CreateLoaderFromMimeType(const std::string& strMimeType) { std::vector<AddonInfoPtr> addonInfos; CServiceBroker::GetAddonMgr().GetAddonInfos(addonInfos, true, ADDON_IMAGEDECODER); - for (auto addonInfo : addonInfos) + for (const auto& addonInfo : addonInfos) { std::vector<std::string> mime = StringUtils::Split(addonInfo->Type(ADDON_IMAGEDECODER)->GetValue("@mimetype").asString(), "|"); if (std::find(mime.begin(), mime.end(), strMimeType) != mime.end()) diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp index 66241bd82c..baf82bb837 100644 --- a/xbmc/input/ButtonTranslator.cpp +++ b/xbmc/input/ButtonTranslator.cpp @@ -371,7 +371,7 @@ void CButtonTranslator::MapWindowActions(const TiXmlNode* pWindow, int windowID) } } - for (auto it : m_buttonMappers) + for (const auto& it : m_buttonMappers) { const std::string& device = it.first; IButtonMapper* mapper = it.second; @@ -411,7 +411,7 @@ void CButtonTranslator::UnregisterMapper(IButtonMapper* mapper) } } -uint32_t CButtonTranslator::TranslateString(std::string strMap, std::string strButton) +uint32_t CButtonTranslator::TranslateString(const std::string& strMap, const std::string& strButton) { if (strMap == "KB") // standard keyboard map { diff --git a/xbmc/input/ButtonTranslator.h b/xbmc/input/ButtonTranslator.h index a0ed23f8e1..e13743d58c 100644 --- a/xbmc/input/ButtonTranslator.h +++ b/xbmc/input/ButtonTranslator.h @@ -63,7 +63,7 @@ public: void RegisterMapper(const std::string& device, IButtonMapper* mapper); void UnregisterMapper(IButtonMapper* mapper); - static uint32_t TranslateString(std::string strMap, std::string strButton); + static uint32_t TranslateString(const std::string& strMap, const std::string& strButton); private: struct CButtonAction diff --git a/xbmc/input/IRTranslator.cpp b/xbmc/input/IRTranslator.cpp index 86ac53adaa..b974b6baef 100644 --- a/xbmc/input/IRTranslator.cpp +++ b/xbmc/input/IRTranslator.cpp @@ -50,7 +50,7 @@ void CIRTranslator::Load(const std::string& irMapName) bool CIRTranslator::LoadIRMap(const std::string& irMapPath) { std::string remoteMapTag = URIUtils::GetFileName(irMapPath); - size_t lastindex = remoteMapTag.find_last_of("."); + size_t lastindex = remoteMapTag.find_last_of('.'); if (lastindex != std::string::npos) remoteMapTag = remoteMapTag.substr(0, lastindex); StringUtils::ToLower(remoteMapTag); diff --git a/xbmc/input/InertialScrollingHandler.h b/xbmc/input/InertialScrollingHandler.h index 154ea08c2d..cff8516550 100644 --- a/xbmc/input/InertialScrollingHandler.h +++ b/xbmc/input/InertialScrollingHandler.h @@ -29,10 +29,16 @@ private: bool CheckForInertialScrolling(const CAction* action); bool ProcessInertialScroll(float frameTime); - //-------------------------------------------vars for inertial scrolling animation with gestures - bool m_bScrolling = false; // flag indicating that we currently do the inertial scrolling - // emulation - bool m_bAborting = false; // flag indicating an abort of scrolling + /* + * vars for inertial scrolling animation with gestures + */ + + // flag indicating that we currently do the inertial scrolling emulation + bool m_bScrolling = false; + + // flag indicating an abort of scrolling + bool m_bAborting = false; + CVector m_iFlickVelocity; struct PanPoint diff --git a/xbmc/input/InputCodingTableKorean.cpp b/xbmc/input/InputCodingTableKorean.cpp index a0ec1ecd22..223f81de8d 100644 --- a/xbmc/input/InputCodingTableKorean.cpp +++ b/xbmc/input/InputCodingTableKorean.cpp @@ -103,8 +103,9 @@ std::wstring CInputCodingTableKorean::InputToKorean(const std::wstring& input) { if (jungseong != -1) { - if (choseong == -1) // Jungseong without choseong cannot have jongseong. - // So inputted key is jungseong character, new character is begun. + // Jungseong without choseong cannot have jongseong. + // So inputted key is jungseong character, new character is begun. + if (choseong == -1) { korean += dicJungseong.at(jungseong); jungseong = -1; @@ -112,8 +113,8 @@ std::wstring CInputCodingTableKorean::InputToKorean(const std::wstring& input) } else // Jungseong with choseong can have jongseong. { - if (jongseong == - -1) // Chongseong can have two consonant. So this is first consonant of chongseong. + // Chongseong can have two consonant. So this is first consonant of chongseong. + if (jongseong == -1) { jongseong = dicJongseong.find(dicKorean.at(key)); if (jongseong == -1) // This consonant cannot be jongseong. ex) "ㄸ", "ㅃ", "ㅉ" @@ -155,13 +156,14 @@ std::wstring CInputCodingTableKorean::InputToKorean(const std::wstring& input) } } else // If there is no jungseong, new consonant can be choseong or second part of double - // consonant. + // consonant. { - if (choseong == - -1) // New consonant is choseong. Also it could be first part of double consonant. + // New consonant is choseong. Also it could be first part of double consonant. + if (choseong == -1) { - if (jongseong != -1) // If choseong is already completed, new consonant is another - // choseong. So previous character has only jongseong. + // If choseong is already completed, new consonant is another choseong. + // So previous character has only jongseong. + if (jongseong != -1) { korean += dicJongseong.at(jongseong); jongseong = -1; @@ -233,9 +235,9 @@ std::wstring CInputCodingTableKorean::InputToKorean(const std::wstring& input) } else // If key is vowel, key is jungseong. { - if (jongseong != - -1) // If previous character has jongseong and this key is jungseong, - // actually latest vowel is not jongseong. It's choseong of new character. + // If previous character has jongseong and this key is jungseong, + // actually latest vowel is not jongseong. It's choseong of new character. + if (jongseong != -1) { // If jongseong of previous character is double consonant, we will separate it to two vowel // again. First part of double consonant is jongseong of previous character. Second part of @@ -296,9 +298,10 @@ std::wstring CInputCodingTableKorean::InputToKorean(const std::wstring& input) jongseong = 16; newCho = 9; } - else // If jongseong is single consonant, previous character has no chongseong. - // It's choseong of current character. + else { + // If jongseong is single consonant, previous character has no chongseong. + // It's choseong of current character. newCho = dicChoseong.find(dicJongseong.at(jongseong)); jongseong = -1; } @@ -332,8 +335,9 @@ std::wstring CInputCodingTableKorean::InputToKorean(const std::wstring& input) jungseong = 19; else // If two vowel cannot be double vowel. { - if (choseong != -1) // Previous character is completed. - // Current character is begin with jungseong. + // Previous character is completed. + // Current character is begin with jungseong. + if (choseong != -1) { korean += MergeCode(choseong, jungseong, jongseong); choseong = -1; diff --git a/xbmc/input/InputManager.cpp b/xbmc/input/InputManager.cpp index 772dc250f2..097245822e 100644 --- a/xbmc/input/InputManager.cpp +++ b/xbmc/input/InputManager.cpp @@ -765,7 +765,7 @@ bool CInputManager::IsControllerEnabled() const return m_enableController; } -void CInputManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CInputManager::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/input/InputManager.h b/xbmc/input/InputManager.h index d878cc9666..503193fbbc 100644 --- a/xbmc/input/InputManager.h +++ b/xbmc/input/InputManager.h @@ -223,7 +223,7 @@ public: void QueueAction(const CAction& action); // implementation of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; // implementation of IActionListener bool OnAction(const CAction& action) override; diff --git a/xbmc/input/JoystickMapper.cpp b/xbmc/input/JoystickMapper.cpp index 631f68062d..233238dbd3 100644 --- a/xbmc/input/JoystickMapper.cpp +++ b/xbmc/input/JoystickMapper.cpp @@ -136,7 +136,7 @@ bool CJoystickMapper::DeserializeButton(const TiXmlElement* pButton, std::string strHoldTime; if (pButton->QueryValueAttribute(JOYSTICK_XML_ATTR_HOLDTIME, &strHoldTime) == TIXML_SUCCESS) { - std::istringstream ss(std::move(strHoldTime)); + std::istringstream ss(strHoldTime); ss >> holdtimeMs; } diff --git a/xbmc/input/KeyboardLayoutManager.cpp b/xbmc/input/KeyboardLayoutManager.cpp index afbec28159..47aea2d4a4 100644 --- a/xbmc/input/KeyboardLayoutManager.cpp +++ b/xbmc/input/KeyboardLayoutManager.cpp @@ -138,7 +138,7 @@ inline bool LayoutSort(const StringSettingOption& i, const StringSettingOption& } // namespace void CKeyboardLayoutManager::SettingOptionsKeyboardLayoutsFiller( - SettingConstPtr setting, + const SettingConstPtr& setting, std::vector<StringSettingOption>& list, std::string& current, void* data) diff --git a/xbmc/input/KeyboardLayoutManager.h b/xbmc/input/KeyboardLayoutManager.h index b493155e38..b435f279e7 100644 --- a/xbmc/input/KeyboardLayoutManager.h +++ b/xbmc/input/KeyboardLayoutManager.h @@ -33,7 +33,7 @@ public: const KeyboardLayouts& GetLayouts() const { return m_layouts; } bool GetLayout(const std::string& name, CKeyboardLayout& layout) const; - static void SettingOptionsKeyboardLayoutsFiller(std::shared_ptr<const CSetting> setting, + static void SettingOptionsKeyboardLayoutsFiller(const std::shared_ptr<const CSetting>& setting, std::vector<StringSettingOption>& list, std::string& current, void* data); diff --git a/xbmc/input/KeyboardStat.cpp b/xbmc/input/KeyboardStat.cpp index 9204df3468..1842928853 100644 --- a/xbmc/input/KeyboardStat.cpp +++ b/xbmc/input/KeyboardStat.cpp @@ -38,8 +38,6 @@ CKeyboardStat::CKeyboardStat() m_lastKeyTime = 0; } -CKeyboardStat::~CKeyboardStat() = default; - void CKeyboardStat::Initialize() { } diff --git a/xbmc/input/KeyboardStat.h b/xbmc/input/KeyboardStat.h index 8eed0b2d25..df404f3102 100644 --- a/xbmc/input/KeyboardStat.h +++ b/xbmc/input/KeyboardStat.h @@ -33,7 +33,7 @@ class CKeyboardStat { public: CKeyboardStat(); - ~CKeyboardStat(); + ~CKeyboardStat() = default; void Initialize(); diff --git a/xbmc/input/WindowTranslator.cpp b/xbmc/input/WindowTranslator.cpp index 564582371a..ed6b5cb382 100644 --- a/xbmc/input/WindowTranslator.cpp +++ b/xbmc/input/WindowTranslator.cpp @@ -118,16 +118,26 @@ const CWindowTranslator::WindowMapByName CWindowTranslator::WindowMappingByName {"movieinformation", WINDOW_DIALOG_VIDEO_INFO}, {"textviewer", WINDOW_DIALOG_TEXT_VIEWER}, {"fullscreenvideo", WINDOW_FULLSCREEN_VIDEO}, - {"fullscreenlivetv", WINDOW_FULLSCREEN_LIVETV}, // virtual window for fullscreen radio, uses - // WINDOW_FULLSCREEN_VIDEO as fallback - {"fullscreenlivetvpreview", WINDOW_FULLSCREEN_LIVETV_PREVIEW}, // Live TV channel preview - {"fullscreenlivetvinput", - WINDOW_FULLSCREEN_LIVETV_INPUT}, // Livr TV direct channel number input - {"fullscreenradio", WINDOW_FULLSCREEN_RADIO}, // virtual window for fullscreen radio, uses - // WINDOW_VISUALISATION as fallback - {"fullscreenradiopreview", WINDOW_FULLSCREEN_RADIO_PREVIEW}, // PVR Radio channel preview - {"fullscreenradioinput", - WINDOW_FULLSCREEN_RADIO_INPUT}, // PVR radio direct channel number input + + // Virtual window for fullscreen radio, uses WINDOW_FULLSCREEN_VIDEO as + // fallback + {"fullscreenlivetv", WINDOW_FULLSCREEN_LIVETV}, + + // Live TV channel preview + {"fullscreenlivetvpreview", WINDOW_FULLSCREEN_LIVETV_PREVIEW}, + + // Live TV direct channel number input + {"fullscreenlivetvinput", WINDOW_FULLSCREEN_LIVETV_INPUT}, + + // Virtual window for fullscreen radio, uses WINDOW_VISUALISATION as fallback + {"fullscreenradio", WINDOW_FULLSCREEN_RADIO}, + + // PVR Radio channel preview + {"fullscreenradiopreview", WINDOW_FULLSCREEN_RADIO_PREVIEW}, + + // PVR radio direct channel number input + {"fullscreenradioinput", WINDOW_FULLSCREEN_RADIO_INPUT}, + {"fullscreengame", WINDOW_FULLSCREEN_GAME}, {"visualisation", WINDOW_VISUALISATION}, {"slideshow", WINDOW_SLIDESHOW}, diff --git a/xbmc/input/actions/ActionIDs.h b/xbmc/input/actions/ActionIDs.h index fe1b565cc5..0a3ffd37cf 100644 --- a/xbmc/input/actions/ActionIDs.h +++ b/xbmc/input/actions/ActionIDs.h @@ -32,132 +32,219 @@ #define ACTION_STOP 13 #define ACTION_NEXT_ITEM 14 #define ACTION_PREV_ITEM 15 -#define ACTION_FORWARD \ - 16 //!< Can be used to specify specific action in a window, Playback control is handled in - //!< ACTION_PLAYER_* -#define ACTION_REWIND \ - 17 //!< Can be used to specify specific action in a window, Playback control is handled in - //!< ACTION_PLAYER_* - -#define ACTION_SHOW_GUI 18 //!< toggle between GUI and movie or GUI and visualisation. -#define ACTION_ASPECT_RATIO \ - 19 //!< toggle quick-access zoom modes. Can b used in videoFullScreen.zml window id=2005 -#define ACTION_STEP_FORWARD \ - 20 //!< seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_STEP_BACK \ - 21 //!< seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_BIG_STEP_FORWARD \ - 22 //!< seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_BIG_STEP_BACK \ - 23 //!< seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_SHOW_OSD 24 //!< show/hide OSD. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_SHOW_SUBTITLES \ - 25 //!< turn subtitles on/off. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_NEXT_SUBTITLE \ - 26 //!< switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_PLAYER_DEBUG 27 //!< show debug info for VideoPlayer -#define ACTION_NEXT_PICTURE \ - 28 //!< show next picture of slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_PREV_PICTURE \ - 29 //!< show previous picture of slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_OUT \ - 30 //!< zoom in picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_IN \ - 31 //!< zoom out picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_TOGGLE_SOURCE_DEST \ - 32 //!< used to toggle between source view and destination view. Can be used in myfiles.xml window - //!< id=3 -#define ACTION_SHOW_PLAYLIST \ - 33 //!< used to toggle between current view and playlist view. Can b used in all mymusic xml files -#define ACTION_QUEUE_ITEM \ - 34 //!< used to queue a item to the playlist. Can b used in all mymusic xml files -#define ACTION_REMOVE_ITEM 35 //!< not used anymore -#define ACTION_SHOW_FULLSCREEN 36 //!< not used anymore -#define ACTION_ZOOM_LEVEL_NORMAL \ - 37 //!< zoom 1x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_1 \ - 38 //!< zoom 2x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_2 \ - 39 //!< zoom 3x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_3 \ - 40 //!< zoom 4x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_4 \ - 41 //!< zoom 5x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_5 \ - 42 //!< zoom 6x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_6 \ - 43 //!< zoom 7x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_7 \ - 44 //!< zoom 8x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_8 \ - 45 //!< zoom 9x picture during slideshow. Can b used in slideshow.xml window id=2007 -#define ACTION_ZOOM_LEVEL_9 \ - 46 //!< zoom 10x picture during slideshow. Can b used in slideshow.xml window id=2007 - -#define ACTION_CALIBRATE_SWAP_ARROWS \ - 47 //!< select next arrow. Can b used in: settingsScreenCalibration.xml windowid=11 -#define ACTION_CALIBRATE_RESET \ - 48 //!< reset calibration to defaults. Can b used in: `settingsScreenCalibration.xml` - //!< windowid=11/settingsUICalibration.xml windowid=10 -#define ACTION_ANALOG_MOVE \ - 49 //!< analog thumbstick move. Can b used in: `slideshow.xml` - //!< windowid=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml - //!< windowid=10 - //!< @note see also ACTION_ANALOG_MOVE_X_LEFT, ACTION_ANALOG_MOVE_X_RIGHT, - //!< ACTION_ANALOG_MOVE_Y_UP, ACTION_ANALOG_MOVE_Y_DOWN -#define ACTION_ROTATE_PICTURE_CW \ - 50 //!< rotate current picture clockwise during slideshow. Can be used in slideshow.xml window - //!< id=2007 -#define ACTION_ROTATE_PICTURE_CCW \ - 51 //!< rotate current picture counterclockwise during slideshow. Can be used in slideshow.xml - //!< window id=2007 - -#define ACTION_SUBTITLE_DELAY_MIN \ - 52 //!< Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_SUBTITLE_DELAY_PLUS \ - 53 //!< Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_AUDIO_DELAY_MIN \ - 54 //!< Increase avsync delay. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_AUDIO_DELAY_PLUS \ - 55 //!< Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_AUDIO_NEXT_LANGUAGE \ - 56 //!< Select next language in movie. Can b used in videoFullScreen.xml window id=2005 -#define ACTION_CHANGE_RESOLUTION \ - 57 //!< switch 2 next resolution. Can b used during screen calibration - //!< settingsScreenCalibration.xml windowid=11 - -#define REMOTE_0 58 //!< remote keys 0-9. are used by multiple windows -#define REMOTE_1 59 //!< for example in videoFullScreen.xml window id=2005 you can -#define REMOTE_2 60 //!< enter time (mmss) to jump to particular point in the movie + +//! Can be used to specify specific action in a window, Playback control is +//! handled in ACTION_PLAYER_* +#define ACTION_FORWARD 16 + +//! Can be used to specify specific action in a window, Playback control is +//! handled in ACTION_PLAYER_* +#define ACTION_REWIND 17 + +//! Toggle between GUI and movie or GUI and visualisation. +#define ACTION_SHOW_GUI 18 + +//! Toggle quick-access zoom modes. Can be used in videoFullScreen.zml window id=2005 +#define ACTION_ASPECT_RATIO 19 + +//! Seek +1% in the movie. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_STEP_FORWARD 20 + +//! Seek -1% in the movie. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_STEP_BACK 21 + +//! Seek +10% in the movie. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_BIG_STEP_FORWARD 22 + +//! Seek -10% in the movie. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_BIG_STEP_BACK 23 + +//! Show/hide OSD. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_SHOW_OSD 24 + +//! Turn subtitles on/off. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_SHOW_SUBTITLES 25 + +//! Switch to next subtitle of movie. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_NEXT_SUBTITLE 26 + +//! Show debug info for VideoPlayer +#define ACTION_PLAYER_DEBUG 27 + +//! Show next picture of slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_NEXT_PICTURE 28 + +//! Show previous picture of slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_PREV_PICTURE 29 + +//! Zoom in picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_OUT 30 + +//! Zoom out picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_IN 31 + +//! Used to toggle between source view and destination view. Can be used in +//! myfiles.xml window < id=3 +#define ACTION_TOGGLE_SOURCE_DEST 32 + +//! Used to toggle between current view and playlist view. Can be used in all mymusic xml files +#define ACTION_SHOW_PLAYLIST 33 + +//! Used to queue a item to the playlist. Can be used in all mymusic xml files +#define ACTION_QUEUE_ITEM 34 + +//! Not used anymore +#define ACTION_REMOVE_ITEM 35 + +//! Not used anymore +#define ACTION_SHOW_FULLSCREEN 36 + +//! Zoom 1x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_NORMAL 37 + +//! Zoom 2x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_1 38 + +//! Zoom 3x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_2 39 + +//! Zoom 4x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_3 40 + +//! Zoom 5x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_4 41 + +//! Zoom 6x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_5 42 + +//! Zoom 7x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_6 43 + +//! Zoom 8x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_7 44 + +//! Zoom 9x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_8 45 + +//< Zoom 10x picture during slideshow. Can be used in slideshow.xml window id=2007 +#define ACTION_ZOOM_LEVEL_9 46 + +//< Select next arrow. Can be used in: settingsScreenCalibration.xml windowid=11 +#define ACTION_CALIBRATE_SWAP_ARROWS 47 + +//! Reset calibration to defaults. Can be used in: `settingsScreenCalibration.xml` +//! windowid=11/settingsUICalibration.xml windowid=10 +#define ACTION_CALIBRATE_RESET 48 + +//! Analog thumbstick move. Can be used in: `slideshow.xml` +//! windowid=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml +//! windowid=10 +//! @note see also ACTION_ANALOG_MOVE_X_LEFT, ACTION_ANALOG_MOVE_X_RIGHT, +//! ACTION_ANALOG_MOVE_Y_UP, ACTION_ANALOG_MOVE_Y_DOWN +#define ACTION_ANALOG_MOVE 49 + +//! Rotate current picture clockwise during slideshow. Can be used in +//! slideshow.xml window < id=2007 +#define ACTION_ROTATE_PICTURE_CW 50 + +//! Rotate current picture counterclockwise during slideshow. Can be used in +//! slideshow.xml window id=2007 +#define ACTION_ROTATE_PICTURE_CCW 51 + +//! Decrease subtitle/movie Delay. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_SUBTITLE_DELAY_MIN 52 + +//! Increase subtitle/movie Delay. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_SUBTITLE_DELAY_PLUS 53 + +//! Increase avsync delay. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_AUDIO_DELAY_MIN 54 + +//! Decrease avsync delay. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_AUDIO_DELAY_PLUS 55 + +//! Select next language in movie. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_AUDIO_NEXT_LANGUAGE 56 + +//! Switch 2 next resolution. Can b used during screen calibration +//! settingsScreenCalibration.xml windowid=11 +#define ACTION_CHANGE_RESOLUTION 57 + +//! Remote keys 0-9 are used by multiple windows. +//! +//! For example, in videoFullScreen.xml window id=2005 you can enter +//! time (mmss) to jump to particular point in the movie. +//! +//! With spincontrols you can enter a 3-digit number to quickly set the +//! spincontrol to desired value. +//!@{ +#define REMOTE_0 58 + +//! @see REMOTE_0 about details. +#define REMOTE_1 59 + +//! @see REMOTE_0 about details. +#define REMOTE_2 60 + +//! @see REMOTE_0 about details. #define REMOTE_3 61 -#define REMOTE_4 62 //!< with spincontrols you can enter 3digit number to quickly set -#define REMOTE_5 63 //!< spincontrol to desired value + +//! @see REMOTE_0 about details. +#define REMOTE_4 62 + +//! @see REMOTE_0 about details. +#define REMOTE_5 63 + +//! @see REMOTE_0 about details. #define REMOTE_6 64 + +//! @see REMOTE_0 about details. #define REMOTE_7 65 + +//! @see REMOTE_0 about details. #define REMOTE_8 66 + +//! @see REMOTE_0 about details. #define REMOTE_9 67 +//!@} + +//! Show player process info (video decoder, pixel format, pvr signal strength +//! and the like +#define ACTION_PLAYER_PROCESS_INFO 69 -#define ACTION_PLAYER_PROCESS_INFO \ - 69 //!< show player process info (video decoder, pixel format, pvr signal strength and the like #define ACTION_PLAYER_PROGRAM_SELECT 70 + #define ACTION_PLAYER_RESOLUTION_SELECT 71 -#define ACTION_SMALL_STEP_BACK \ - 76 //!< jumps a few seconds back during playback of movie. Can b used in videoFullScreen.xml - //!< window id=2005 - -#define ACTION_PLAYER_FORWARD 77 //!< FF in current file played. global action, can be used anywhere -#define ACTION_PLAYER_REWIND 78 //!< RW in current file played. global action, can be used anywhere -#define ACTION_PLAYER_PLAY \ - 79 //!< Play current song. Unpauses song and sets playspeed to 1x. global action, can be used - //!< anywhere - -#define ACTION_DELETE_ITEM \ - 80 //!< delete current selected item. Can be used in myfiles.xml window id=3 and in - //!< myvideoTitle.xml window id=25 -#define ACTION_COPY_ITEM 81 //!< copy current selected item. Can be used in myfiles.xml window id=3 -#define ACTION_MOVE_ITEM 82 //!< move current selected item. Can be used in myfiles.xml window id=3 -#define ACTION_TAKE_SCREENSHOT 85 //!< take a screenshot -#define ACTION_RENAME_ITEM 87 //!< rename item + +//! Jumps a few seconds back during playback of movie. Can be used in videoFullScreen.xml +//! window id=2005 +#define ACTION_SMALL_STEP_BACK 76 + +//! FF in current file played. global action, can be used anywhere +#define ACTION_PLAYER_FORWARD 77 + +//! RW in current file played. global action, can be used anywhere +#define ACTION_PLAYER_REWIND 78 + +//! Play current song. Unpauses song and sets playspeed to 1x. global action, +//! can be used anywhere +#define ACTION_PLAYER_PLAY 79 + +//! Delete current selected item. Can be used in myfiles.xml window id=3 and in +//! myvideoTitle.xml window id=25 +#define ACTION_DELETE_ITEM 80 + +//! Copy current selected item. Can be used in myfiles.xml window id=3 +#define ACTION_COPY_ITEM 81 + +//! Move current selected item. Can be used in myfiles.xml window id=3 +#define ACTION_MOVE_ITEM 82 + +//! Take a screenshot +#define ACTION_TAKE_SCREENSHOT 85 + +//! Rename item +#define ACTION_RENAME_ITEM 87 #define ACTION_VOLUME_UP 88 #define ACTION_VOLUME_DOWN 89 @@ -167,19 +254,22 @@ #define ACTION_VOLAMP_UP 93 #define ACTION_VOLAMP_DOWN 94 -#define ACTION_CREATE_EPISODE_BOOKMARK \ - 95 //!< Creates an episode bookmark on the currently playing video file containing more than one - //!< episode -#define ACTION_CREATE_BOOKMARK 96 //!< Creates a bookmark of the currently playing video file +//! Creates an episode bookmark on the currently playing video file containing +//! more than one episode +#define ACTION_CREATE_EPISODE_BOOKMARK 95 + +//! Creates a bookmark of the currently playing video file +#define ACTION_CREATE_BOOKMARK 96 -#define ACTION_CHAPTER_OR_BIG_STEP_FORWARD \ - 97 //!< Goto the next chapter, if not available perform a big step forward -#define ACTION_CHAPTER_OR_BIG_STEP_BACK \ - 98 //!< Goto the previous chapter, if not available perform a big step back +//! Goto the next chapter, if not available perform a big step forward +#define ACTION_CHAPTER_OR_BIG_STEP_FORWARD 97 -#define ACTION_CYCLE_SUBTITLE \ - 99 //!< switch to next subtitle of movie, but will not enable/disable the subtitles. Can be used - //!< in videoFullScreen.xml window id=2005 +//! Goto the previous chapter, if not available perform a big step back +#define ACTION_CHAPTER_OR_BIG_STEP_BACK 98 + +//! Switch to next subtitle of movie, but will not enable/disable the subtitles. +//! Can be used in videoFullScreen.xml window id=2005 +#define ACTION_CYCLE_SUBTITLE 99 #define ACTION_MOUSE_START 100 #define ACTION_MOUSE_LEFT_CLICK 100 @@ -212,8 +302,9 @@ #define ACTION_BUILT_IN_FUNCTION 122 -#define ACTION_SHOW_OSD_TIME \ - 123 //!< displays current time, can be used in videoFullScreen.xml window id=2005 +//! Displays current time, can be used in videoFullScreen.xml window id=2005 +#define ACTION_SHOW_OSD_TIME 123 + #define ACTION_ANALOG_SEEK_FORWARD 124 //!< seeks forward, and displays the seek bar. #define ACTION_ANALOG_SEEK_BACK 125 //!< seeks backward, and displays the seek bar. @@ -320,8 +411,8 @@ #define ACTION_SETTINGS_RESET 241 #define ACTION_SETTINGS_LEVEL_CHANGE 242 -#define ACTION_TRIGGER_OSD \ - 243 //!< show autoclosing OSD. Can b used in videoFullScreen.xml window id=2005 +//! Show autoclosing OSD. Can be used in videoFullScreen.xml window id=2005 +#define ACTION_TRIGGER_OSD 243 #define ACTION_INPUT_TEXT 244 #define ACTION_VOLUME_SET 245 #define ACTION_TOGGLE_COMMSKIP 246 @@ -333,7 +424,9 @@ #define ACTION_TOGGLE_FONT 249 //!< Toggle font. Used in TextViewer dialog #define ACTION_VIDEO_NEXT_STREAM 250 //!< Cycle video streams. Used in videofullscreen. -#define ACTION_QUEUE_ITEM_NEXT 251 //!< used to queue an item to the next position in the playlist + +//! Used to queue an item to the next position in the playlist +#define ACTION_QUEUE_ITEM_NEXT 251 #define ACTION_HDR_TOGGLE 260 //!< Toggle display HDR on/off @@ -348,9 +441,10 @@ #define ACTION_GESTURE_NOTIFY 500 #define ACTION_GESTURE_BEGIN 501 -#define ACTION_GESTURE_ZOOM \ - 502 //!< sendaction with point and currentPinchScale (fingers together < 1.0 -> fingers apart - //!< > 1.0) + +//! sendaction with point and currentPinchScale (fingers together < 1.0 -> +//! fingers apart > 1.0) +#define ACTION_GESTURE_ZOOM 502 #define ACTION_GESTURE_ROTATE 503 #define ACTION_GESTURE_PAN 504 #define ACTION_GESTURE_ABORT 505 //!< gesture was interrupted in unspecified state @@ -363,19 +457,28 @@ #define ACTION_GESTURE_SWIPE_UP_TEN 540 #define ACTION_GESTURE_SWIPE_DOWN 541 #define ACTION_GESTURE_SWIPE_DOWN_TEN 550 -// 5xx is reserved for additional gesture actions + +//! 5xx is reserved for additional gesture actions #define ACTION_GESTURE_END 599 -// other, non-gesture actions -#define ACTION_ANALOG_MOVE_X_LEFT \ - 601 //!< analog thumbstick move, horizontal axis, left; see ACTION_ANALOG_MOVE -#define ACTION_ANALOG_MOVE_X_RIGHT \ - 602 //!< analog thumbstick move, horizontal axis, right; see ACTION_ANALOG_MOVE -#define ACTION_ANALOG_MOVE_Y_UP \ - 603 //!< analog thumbstick move, vertical axis, up; see ACTION_ANALOG_MOVE -#define ACTION_ANALOG_MOVE_Y_DOWN \ - 604 //!< analog thumbstick move, vertical axis, down; see ACTION_ANALOG_MOVE -//@} +/*! + * @brief Other, non-gesture actions + */ +///@{ + +//!< analog thumbstick move, horizontal axis, left; see ACTION_ANALOG_MOVE +#define ACTION_ANALOG_MOVE_X_LEFT 601 + +//!< analog thumbstick move, horizontal axis, right; see ACTION_ANALOG_MOVE +#define ACTION_ANALOG_MOVE_X_RIGHT 602 + +//!< analog thumbstick move, vertical axis, up; see ACTION_ANALOG_MOVE +#define ACTION_ANALOG_MOVE_Y_UP 603 + +//!< analog thumbstick move, vertical axis, down; see ACTION_ANALOG_MOVE +#define ACTION_ANALOG_MOVE_Y_DOWN 604 + +///@} // The NOOP action can be specified to disable an input event. This is // useful in user keyboard.xml etc to disable actions specified in the diff --git a/xbmc/input/button/ButtonStat.cpp b/xbmc/input/button/ButtonStat.cpp index c37853a9bf..679947fc4b 100644 --- a/xbmc/input/button/ButtonStat.cpp +++ b/xbmc/input/button/ButtonStat.cpp @@ -13,9 +13,8 @@ using namespace KODI; using namespace INPUT; CButtonStat::CButtonStat() = default; -CButtonStat::~CButtonStat() = default; -CKey CButtonStat::TranslateKey(CKey key) const +CKey CButtonStat::TranslateKey(const CKey& key) const { uint32_t buttonCode = key.GetButtonCode(); if (key.GetHeld() > HOLD_TRESHOLD) diff --git a/xbmc/input/button/ButtonStat.h b/xbmc/input/button/ButtonStat.h index 139c03dc48..04ee51a134 100644 --- a/xbmc/input/button/ButtonStat.h +++ b/xbmc/input/button/ButtonStat.h @@ -22,9 +22,9 @@ class CButtonStat { public: CButtonStat(); - ~CButtonStat(); + ~CButtonStat() = default; - CKey TranslateKey(CKey key) const; + CKey TranslateKey(const CKey& key) const; }; } // namespace INPUT } // namespace KODI diff --git a/xbmc/input/joysticks/DeadzoneFilter.cpp b/xbmc/input/joysticks/DeadzoneFilter.cpp index 7b565c6abe..d68ff7eb64 100644 --- a/xbmc/input/joysticks/DeadzoneFilter.cpp +++ b/xbmc/input/joysticks/DeadzoneFilter.cpp @@ -20,9 +20,9 @@ using namespace KODI; using namespace JOYSTICK; -#define AXIS_EPSILON \ - 0.01f // Allowed noise for detecting discrete D-pads (value of 0.007 when centered has been - // observed) +//! Allowed noise for detecting discrete D-pads (value of 0.007 when centered +//! has been observed) +#define AXIS_EPSILON 0.01f // Settings for analog sticks #define SETTING_LEFT_STICK_DEADZONE "left_stick_deadzone" diff --git a/xbmc/input/joysticks/keymaps/KeyHandler.cpp b/xbmc/input/joysticks/keymaps/KeyHandler.cpp index 5df45e2c23..cd0f30aafd 100644 --- a/xbmc/input/joysticks/keymaps/KeyHandler.cpp +++ b/xbmc/input/joysticks/keymaps/KeyHandler.cpp @@ -109,6 +109,7 @@ bool CKeyHandler::OnAnalogMotion(float magnitude, unsigned int motionTimeMs) { std::vector<const KeymapAction*> allActions; + allActions.reserve(actions.size()); for (const auto& action : actions) allActions.emplace_back(&action); diff --git a/xbmc/input/mouse/MouseStat.h b/xbmc/input/mouse/MouseStat.h index 5700e2a225..a5b4e728e9 100644 --- a/xbmc/input/mouse/MouseStat.h +++ b/xbmc/input/mouse/MouseStat.h @@ -146,12 +146,15 @@ private: BUTTON_ACTION Update(unsigned int time, int x, int y, bool down); private: - static const unsigned int click_confines = 5; ///< number of pixels that the pointer may move - ///< while the button is down to trigger a click - static const unsigned int short_click_time = - 1000; ///< time for mouse down/up to trigger a short click rather than a long click - static const unsigned int double_click_time = - 500; ///< time for mouse down following a short click to trigger a double click + //! number of pixels that the pointer may move while the button is down to + //! trigger a click + static const unsigned int click_confines = 5; + + //! Time for mouse down/up to trigger a short click rather than a long click + static const unsigned int short_click_time = 1000; + + //! Time for mouse down following a short click to trigger a double click + static const unsigned int double_click_time = 500; bool InClickRange(int x, int y) const; diff --git a/xbmc/input/remote/IRRemote.h b/xbmc/input/remote/IRRemote.h index 10eb52476b..84a7daceef 100644 --- a/xbmc/input/remote/IRRemote.h +++ b/xbmc/input/remote/IRRemote.h @@ -94,8 +94,13 @@ typedef struct _XINPUT_IR_REMOTE { unsigned char wButtons; unsigned char region; // just a guess - unsigned char counter; // some value that is changing while a button is pressed... could be the - // state of the buffer - unsigned char firstEvent; // > 0 - first event triggered after a button was pressed on the remote; - // 0 - not first event + + //! Some value that is changing while a button is pressed... could be the + //! state of the buffer + unsigned char counter; + + //! If > 0: first event triggered after a button was pressed on the remote + //! If 0: not first event + unsigned char firstEvent; + } XINPUT_IR_REMOTE, *PIR_REMOTE; diff --git a/xbmc/interfaces/AnnouncementManager.cpp b/xbmc/interfaces/AnnouncementManager.cpp index 879cbe55a1..54a20a4b38 100644 --- a/xbmc/interfaces/AnnouncementManager.cpp +++ b/xbmc/interfaces/AnnouncementManager.cpp @@ -162,7 +162,7 @@ void CAnnouncementManager::DoAnnounce(AnnouncementFlag flag, void CAnnouncementManager::DoAnnounce(AnnouncementFlag flag, const std::string& sender, const std::string& message, - CFileItemPtr item, + const CFileItemPtr& item, const CVariant& data) { if (item == nullptr) diff --git a/xbmc/interfaces/AnnouncementManager.h b/xbmc/interfaces/AnnouncementManager.h index 87ce3dbad9..bdf5071655 100644 --- a/xbmc/interfaces/AnnouncementManager.h +++ b/xbmc/interfaces/AnnouncementManager.h @@ -65,7 +65,7 @@ namespace ANNOUNCEMENT void DoAnnounce(AnnouncementFlag flag, const std::string& sender, const std::string& message, - CFileItemPtr item, + const CFileItemPtr& item, const CVariant& data); void DoAnnounce(AnnouncementFlag flag, const std::string& sender, diff --git a/xbmc/interfaces/generic/LanguageInvokerThread.cpp b/xbmc/interfaces/generic/LanguageInvokerThread.cpp index 252cd1d9b0..67f3d14875 100644 --- a/xbmc/interfaces/generic/LanguageInvokerThread.cpp +++ b/xbmc/interfaces/generic/LanguageInvokerThread.cpp @@ -10,12 +10,14 @@ #include "ScriptInvocationManager.h" +#include <utility> + CLanguageInvokerThread::CLanguageInvokerThread(LanguageInvokerPtr invoker, CScriptInvocationManager* invocationManager, bool reuseable) : ILanguageInvoker(NULL), CThread("LanguageInvoker"), - m_invoker(invoker), + m_invoker(std::move(invoker)), m_invocationManager(invocationManager), m_reusable(reuseable) { } diff --git a/xbmc/interfaces/generic/ScriptInvocationManager.cpp b/xbmc/interfaces/generic/ScriptInvocationManager.cpp index fe69686699..265ec39499 100644 --- a/xbmc/interfaces/generic/ScriptInvocationManager.cpp +++ b/xbmc/interfaces/generic/ScriptInvocationManager.cpp @@ -240,7 +240,7 @@ int CScriptInvocationManager::ExecuteAsync( int CScriptInvocationManager::ExecuteAsync( const std::string& script, - LanguageInvokerPtr languageInvoker, + const LanguageInvokerPtr& languageInvoker, const ADDON::AddonPtr& addon /* = ADDON::AddonPtr() */, const std::vector<std::string>& arguments /* = std::vector<std::string>() */, bool reuseable /* = false */, @@ -314,7 +314,7 @@ int CScriptInvocationManager::ExecuteSync( int CScriptInvocationManager::ExecuteSync( const std::string& script, - LanguageInvokerPtr languageInvoker, + const LanguageInvokerPtr& languageInvoker, const ADDON::AddonPtr& addon /* = ADDON::AddonPtr() */, const std::vector<std::string>& arguments /* = std::vector<std::string>() */, uint32_t timeoutMs /* = 0 */, diff --git a/xbmc/interfaces/generic/ScriptInvocationManager.h b/xbmc/interfaces/generic/ScriptInvocationManager.h index 3ad4454c18..6e409b87e6 100644 --- a/xbmc/interfaces/generic/ScriptInvocationManager.h +++ b/xbmc/interfaces/generic/ScriptInvocationManager.h @@ -62,7 +62,7 @@ public: * \return -1 if an error occurred, otherwise the ID of the script */ int ExecuteAsync(const std::string& script, - LanguageInvokerPtr languageInvoker, + const LanguageInvokerPtr& languageInvoker, const ADDON::AddonPtr& addon = ADDON::AddonPtr(), const std::vector<std::string>& arguments = std::vector<std::string>(), bool reuseable = false, @@ -107,7 +107,7 @@ public: * \return -1 if an error occurred, 0 if the script terminated or ETIMEDOUT if the given timeout expired */ int ExecuteSync(const std::string& script, - LanguageInvokerPtr languageInvoker, + const LanguageInvokerPtr& languageInvoker, const ADDON::AddonPtr& addon = ADDON::AddonPtr(), const std::vector<std::string>& arguments = std::vector<std::string>(), uint32_t timeoutMs = 0, diff --git a/xbmc/interfaces/info/InfoExpression.cpp b/xbmc/interfaces/info/InfoExpression.cpp index 8aeb5a3583..1bf45a3fc7 100644 --- a/xbmc/interfaces/info/InfoExpression.cpp +++ b/xbmc/interfaces/info/InfoExpression.cpp @@ -81,7 +81,7 @@ void InfoExpression::InfoAssociativeGroup::AddChild(const InfoSubexpressionPtr & m_children.push_front(child); // largely undoes the effect of parsing right-associative } -void InfoExpression::InfoAssociativeGroup::Merge(std::shared_ptr<InfoAssociativeGroup> other) +void InfoExpression::InfoAssociativeGroup::Merge(const std::shared_ptr<InfoAssociativeGroup>& other) { m_children.splice(m_children.end(), other->m_children); } diff --git a/xbmc/interfaces/info/InfoExpression.h b/xbmc/interfaces/info/InfoExpression.h index 3f740d4375..f2c3df0b9a 100644 --- a/xbmc/interfaces/info/InfoExpression.h +++ b/xbmc/interfaces/info/InfoExpression.h @@ -12,6 +12,7 @@ #include <list> #include <stack> +#include <utility> #include <vector> class CGUIListItem; @@ -77,7 +78,7 @@ private: class InfoLeaf : public InfoSubexpression { public: - InfoLeaf(InfoPtr info, bool invert) : m_info(info), m_invert(invert) {}; + InfoLeaf(InfoPtr info, bool invert) : m_info(std::move(info)), m_invert(invert){}; bool Evaluate(const CGUIListItem *item) override; node_type_t Type() const override { return NODE_LEAF; }; private: @@ -91,7 +92,7 @@ private: public: InfoAssociativeGroup(node_type_t type, const InfoSubexpressionPtr &left, const InfoSubexpressionPtr &right); void AddChild(const InfoSubexpressionPtr &child); - void Merge(std::shared_ptr<InfoAssociativeGroup> other); + void Merge(const std::shared_ptr<InfoAssociativeGroup>& other); bool Evaluate(const CGUIListItem *item) override; node_type_t Type() const override { return m_type; }; private: diff --git a/xbmc/interfaces/json-rpc/AddonsOperations.cpp b/xbmc/interfaces/json-rpc/AddonsOperations.cpp index dff6317ef9..e9010032a9 100644 --- a/xbmc/interfaces/json-rpc/AddonsOperations.cpp +++ b/xbmc/interfaces/json-rpc/AddonsOperations.cpp @@ -267,7 +267,11 @@ static CVariant Serialize(const AddonPtr& addon) return variant; } -void CAddonsOperations::FillDetails(AddonPtr addon, const CVariant& fields, CVariant &result, CAddonDatabase &addondb, bool append /* = false */) +void CAddonsOperations::FillDetails(const AddonPtr& addon, + const CVariant& fields, + CVariant& result, + CAddonDatabase& addondb, + bool append /* = false */) { if (addon.get() == NULL) return; diff --git a/xbmc/interfaces/json-rpc/AddonsOperations.h b/xbmc/interfaces/json-rpc/AddonsOperations.h index 488085a6d1..9911b56027 100644 --- a/xbmc/interfaces/json-rpc/AddonsOperations.h +++ b/xbmc/interfaces/json-rpc/AddonsOperations.h @@ -30,7 +30,7 @@ namespace JSONRPC static JSONRPC_STATUS ExecuteAddon(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); private: - static void FillDetails(ADDON::AddonPtr addon, + static void FillDetails(const ADDON::AddonPtr& addon, const CVariant& fields, CVariant& result, ADDON::CAddonDatabase& addondb, diff --git a/xbmc/interfaces/json-rpc/AudioLibrary.cpp b/xbmc/interfaces/json-rpc/AudioLibrary.cpp index 8bf9509cf3..194838150e 100644 --- a/xbmc/interfaces/json-rpc/AudioLibrary.cpp +++ b/xbmc/interfaces/json-rpc/AudioLibrary.cpp @@ -1088,7 +1088,7 @@ bool CAudioLibrary::FillFileItemList(const CVariant ¶meterObject, CFileItemL return success; } -void CAudioLibrary::FillItemArtistIDs(const std::vector<int> artistids, CFileItemPtr &item) +void CAudioLibrary::FillItemArtistIDs(const std::vector<int>& artistids, CFileItemPtr& item) { // Add artistIds as separate property as not part of CMusicInfoTag CVariant artistidObj(CVariant::VariantTypeArray); diff --git a/xbmc/interfaces/json-rpc/AudioLibrary.h b/xbmc/interfaces/json-rpc/AudioLibrary.h index 8cd8b318b8..39a722f02f 100644 --- a/xbmc/interfaces/json-rpc/AudioLibrary.h +++ b/xbmc/interfaces/json-rpc/AudioLibrary.h @@ -57,7 +57,7 @@ namespace JSONRPC private: static void FillAlbumItem(const CAlbum &album, const std::string &path, CFileItemPtr &item); - static void FillItemArtistIDs(const std::vector<int> artistids, CFileItemPtr &item); + static void FillItemArtistIDs(const std::vector<int>& artistids, CFileItemPtr& item); static bool CheckForAdditionalProperties(const CVariant &properties, const std::set<std::string> &checkProperties, std::set<std::string> &foundProperties); }; diff --git a/xbmc/interfaces/json-rpc/FileItemHandler.cpp b/xbmc/interfaces/json-rpc/FileItemHandler.cpp index e38caeffcd..bafbe15aaa 100644 --- a/xbmc/interfaces/json-rpc/FileItemHandler.cpp +++ b/xbmc/interfaces/json-rpc/FileItemHandler.cpp @@ -52,6 +52,32 @@ bool CFileItemHandler::GetField(const std::string &field, const CVariant &info, result[field] = item->GetMimeType(); return true; } + + if (item->HasPVRChannelInfoTag()) + { + // Translate PVR.Details.Broadcast -> List.Item.Base format + if (field == "cast") + { + // string -> Video.Cast + const std::vector<std::string> actors = + StringUtils::Split(info[field].asString(), EPG_STRING_TOKEN_SEPARATOR); + + result[field] = CVariant(CVariant::VariantTypeArray); + for (const auto& actor : actors) + { + CVariant actorVar; + actorVar["name"] = actor; + result[field].push_back(actorVar); + } + return true; + } + else if (field == "director" || field == "writer") + { + // string -> Array.String + result[field] = StringUtils::Split(info[field].asString(), EPG_STRING_TOKEN_SEPARATOR); + return true; + } + } } // check for serialized values @@ -243,7 +269,15 @@ void CFileItemHandler::HandleFileItemList(const char *ID, bool allowFile, const delete thumbLoader; } -void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const CVariant &validFields, CVariant &result, bool append /* = true */, CThumbLoader *thumbLoader /* = NULL */) +void CFileItemHandler::HandleFileItem(const char* ID, + bool allowFile, + const char* resultname, + const CFileItemPtr& item, + const CVariant& parameterObject, + const CVariant& validFields, + CVariant& result, + bool append /* = true */, + CThumbLoader* thumbLoader /* = NULL */) { std::set<std::string> fields; if (parameterObject.isMember("properties") && parameterObject["properties"].isArray()) @@ -255,7 +289,15 @@ void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char HandleFileItem(ID, allowFile, resultname, item, parameterObject, fields, result, append, thumbLoader); } -void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const std::set<std::string> &validFields, CVariant &result, bool append /* = true */, CThumbLoader *thumbLoader /* = NULL */) +void CFileItemHandler::HandleFileItem(const char* ID, + bool allowFile, + const char* resultname, + const CFileItemPtr& item, + const CVariant& parameterObject, + const std::set<std::string>& validFields, + CVariant& result, + bool append /* = true */, + CThumbLoader* thumbLoader /* = NULL */) { CVariant object; std::set<std::string> fields(validFields.begin(), validFields.end()); @@ -298,8 +340,8 @@ void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char { if (item->HasPVRChannelInfoTag() && item->GetPVRChannelInfoTag()->ChannelID() > 0) object[ID] = item->GetPVRChannelInfoTag()->ChannelID(); - else if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->UniqueBroadcastID() > EPG_TAG_INVALID_UID) - object[ID] = item->GetEPGInfoTag()->UniqueBroadcastID(); + else if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->DatabaseID() > 0) + object[ID] = item->GetEPGInfoTag()->DatabaseID(); else if (item->HasPVRRecordingInfoTag() && item->GetPVRRecordingInfoTag()->m_iRecordingId > 0) object[ID] = item->GetPVRRecordingInfoTag()->m_iRecordingId; else if (item->HasPVRTimerInfoTag() && item->GetPVRTimerInfoTag()->m_iTimerId > 0) diff --git a/xbmc/interfaces/json-rpc/FileItemHandler.h b/xbmc/interfaces/json-rpc/FileItemHandler.h index d481138ab5..ca53d2de0d 100644 --- a/xbmc/interfaces/json-rpc/FileItemHandler.h +++ b/xbmc/interfaces/json-rpc/FileItemHandler.h @@ -25,8 +25,24 @@ namespace JSONRPC static void FillDetails(const ISerializable *info, const CFileItemPtr &item, std::set<std::string> &fields, CVariant &result, CThumbLoader *thumbLoader = NULL); static void HandleFileItemList(const char *ID, bool allowFile, const char *resultname, CFileItemList &items, const CVariant ¶meterObject, CVariant &result, bool sortLimit = true); static void HandleFileItemList(const char *ID, bool allowFile, const char *resultname, CFileItemList &items, const CVariant ¶meterObject, CVariant &result, int size, bool sortLimit = true); - static void HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const CVariant &validFields, CVariant &result, bool append = true, CThumbLoader *thumbLoader = NULL); - static void HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const std::set<std::string> &validFields, CVariant &result, bool append = true, CThumbLoader *thumbLoader = NULL); + static void HandleFileItem(const char* ID, + bool allowFile, + const char* resultname, + const CFileItemPtr& item, + const CVariant& parameterObject, + const CVariant& validFields, + CVariant& result, + bool append = true, + CThumbLoader* thumbLoader = NULL); + static void HandleFileItem(const char* ID, + bool allowFile, + const char* resultname, + const CFileItemPtr& item, + const CVariant& parameterObject, + const std::set<std::string>& validFields, + CVariant& result, + bool append = true, + CThumbLoader* thumbLoader = NULL); static bool FillFileItemList(const CVariant ¶meterObject, CFileItemList &list); private: diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 70c075682e..78a027dc50 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -280,7 +280,11 @@ JSONRPC_STATUS CFileOperations::Download(const std::string &method, ITransportLa return transport->Download(parameterObject["path"].asString().c_str(), result) ? OK : InvalidParams; } -bool CFileOperations::FillFileItem(const CFileItemPtr &originalItem, CFileItemPtr &item, std::string media /* = "" */, const CVariant ¶meterObject /* = CVariant(CVariant::VariantTypeArray) */) +bool CFileOperations::FillFileItem( + const CFileItemPtr& originalItem, + CFileItemPtr& item, + const std::string& media /* = "" */, + const CVariant& parameterObject /* = CVariant(CVariant::VariantTypeArray) */) { if (originalItem.get() == NULL) return false; diff --git a/xbmc/interfaces/json-rpc/FileOperations.h b/xbmc/interfaces/json-rpc/FileOperations.h index c3b13db554..d3707f7896 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.h +++ b/xbmc/interfaces/json-rpc/FileOperations.h @@ -26,7 +26,11 @@ namespace JSONRPC static JSONRPC_STATUS PrepareDownload(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS Download(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); - static bool FillFileItem(const CFileItemPtr &originalItem, CFileItemPtr &item, std::string media = "", const CVariant ¶meterObject = CVariant(CVariant::VariantTypeArray)); + static bool FillFileItem( + const CFileItemPtr& originalItem, + CFileItemPtr& item, + const std::string& media = "", + const CVariant& parameterObject = CVariant(CVariant::VariantTypeArray)); static bool FillFileItemList(const CVariant ¶meterObject, CFileItemList &list); }; } diff --git a/xbmc/interfaces/json-rpc/JSONRPCUtils.h b/xbmc/interfaces/json-rpc/JSONRPCUtils.h index f5104ce607..d1dfbe47de 100644 --- a/xbmc/interfaces/json-rpc/JSONRPCUtils.h +++ b/xbmc/interfaces/json-rpc/JSONRPCUtils.h @@ -124,7 +124,7 @@ namespace JSONRPC \param permission String representation of the OperationPermission \return OperationPermission value of the given string representation */ - inline OperationPermission StringToPermission(std::string permission) + inline OperationPermission StringToPermission(const std::string& permission) { if (permission.compare("ControlPlayback") == 0) return ControlPlayback; diff --git a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp index 4b20c8d028..f052d53aa8 100644 --- a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp +++ b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp @@ -70,6 +70,7 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = { { "Player.SetPartymode", CPlayerOperations::SetPartymode }, { "Player.SetAudioStream", CPlayerOperations::SetAudioStream }, + { "Player.AddSubtitle", CPlayerOperations::AddSubtitle }, { "Player.SetSubtitle", CPlayerOperations::SetSubtitle }, { "Player.SetVideoStream", CPlayerOperations::SetVideoStream }, @@ -170,8 +171,10 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = { { "PVR.GetChannelGroupDetails", CPVROperations::GetChannelGroupDetails }, { "PVR.GetChannels", CPVROperations::GetChannels }, { "PVR.GetChannelDetails", CPVROperations::GetChannelDetails }, + { "PVR.GetClients", CPVROperations::GetClients }, { "PVR.GetBroadcasts", CPVROperations::GetBroadcasts }, { "PVR.GetBroadcastDetails", CPVROperations::GetBroadcastDetails }, + { "PVR.GetBroadcastIsPlayable", CPVROperations::GetBroadcastIsPlayable }, { "PVR.GetTimers", CPVROperations::GetTimers }, { "PVR.GetTimerDetails", CPVROperations::GetTimerDetails }, { "PVR.GetRecordings", CPVROperations::GetRecordings }, @@ -1145,15 +1148,15 @@ void JSONSchemaTypeDefinition::ResolveReference() referencedTypeSet = true; // Take care of all nested types - for (auto it : extends) + for (const auto& it : extends) it->ResolveReference(); - for (auto it : unionTypes) + for (const auto& it : unionTypes) it->ResolveReference(); - for (auto it : items) + for (const auto& it : items) it->ResolveReference(); - for (auto it : additionalItems) + for (const auto& it : additionalItems) it->ResolveReference(); - for (auto it : properties) + for (const auto& it : properties) it.second->ResolveReference(); if (additionalProperties) @@ -1197,7 +1200,8 @@ JSONSchemaTypeDefinition::CJsonSchemaPropertiesMap::CJsonSchemaPropertiesMap() : { } -void JSONSchemaTypeDefinition::CJsonSchemaPropertiesMap::add(JSONSchemaTypeDefinitionPtr property) +void JSONSchemaTypeDefinition::CJsonSchemaPropertiesMap::add( + const JSONSchemaTypeDefinitionPtr& property) { std::string name = property->name; StringUtils::ToLower(name); @@ -1345,7 +1349,8 @@ JSONRPC_STATUS JsonRpcMethod::Check(const CVariant &requestParameters, ITranspor return MethodNotFound; } -bool JsonRpcMethod::parseParameter(const CVariant &value, JSONSchemaTypeDefinitionPtr parameter) +bool JsonRpcMethod::parseParameter(const CVariant& value, + const JSONSchemaTypeDefinitionPtr& parameter) { parameter->name = GetString(value["name"], ""); @@ -1376,7 +1381,12 @@ bool JsonRpcMethod::parseReturn(const CVariant &value) return true; } -JSONRPC_STATUS JsonRpcMethod::checkParameter(const CVariant &requestParameters, JSONSchemaTypeDefinitionPtr type, unsigned int position, CVariant &outputParameters, unsigned int &handled, CVariant &errorData) +JSONRPC_STATUS JsonRpcMethod::checkParameter(const CVariant& requestParameters, + const JSONSchemaTypeDefinitionPtr& type, + unsigned int position, + CVariant& outputParameters, + unsigned int& handled, + CVariant& errorData) { // Let's check if the parameter has been provided if (ParameterExists(requestParameters, type->name, position)) @@ -1410,7 +1420,7 @@ JSONRPC_STATUS JsonRpcMethod::checkParameter(const CVariant &requestParameters, void CJSONServiceDescription::ResolveReferences() { - for (auto it : m_types) + for (const auto& it : m_types) it.second->ResolveReference(); } @@ -1708,6 +1718,7 @@ bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector<std::string> &values) { std::vector<CVariant> enums; + enums.reserve(values.size()); for (const auto& it : values) enums.emplace_back(it); @@ -1717,6 +1728,7 @@ bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector<int> &values) { std::vector<CVariant> enums; + enums.reserve(values.size()); for (const auto& it : values) enums.emplace_back(it); @@ -1964,7 +1976,8 @@ bool CJSONServiceDescription::parseJSONSchemaType(const CVariant &value, std::ve return false; } -void CJSONServiceDescription::addReferenceTypeDefinition(JSONSchemaTypeDefinitionPtr typeDefinition) +void CJSONServiceDescription::addReferenceTypeDefinition( + const JSONSchemaTypeDefinitionPtr& typeDefinition) { // If the given json value is no object or does not contain an "id" field // of type string it is no valid type definition @@ -2004,7 +2017,8 @@ void CJSONServiceDescription::removeReferenceTypeDefinition(const std::string &t m_types.erase(type); } -void CJSONServiceDescription::getReferencedTypes(const JSONSchemaTypeDefinitionPtr type, std::vector<std::string> &referencedTypes) +void CJSONServiceDescription::getReferencedTypes(const JSONSchemaTypeDefinitionPtr& type, + std::vector<std::string>& referencedTypes) { // If the current type is a referenceable object, we can add it to the list if (type->ID.size() > 0) diff --git a/xbmc/interfaces/json-rpc/JSONServiceDescription.h b/xbmc/interfaces/json-rpc/JSONServiceDescription.h index 8997898c0d..ee489201e7 100644 --- a/xbmc/interfaces/json-rpc/JSONServiceDescription.h +++ b/xbmc/interfaces/json-rpc/JSONServiceDescription.h @@ -184,7 +184,7 @@ namespace JSONRPC public: CJsonSchemaPropertiesMap(); - void add(JSONSchemaTypeDefinitionPtr property); + void add(const JSONSchemaTypeDefinitionPtr& property); typedef std::map<std::string, JSONSchemaTypeDefinitionPtr>::const_iterator JSONSchemaPropertiesIterator; JSONSchemaPropertiesIterator begin() const; @@ -265,9 +265,14 @@ namespace JSONRPC JSONSchemaTypeDefinitionPtr returns; private: - bool parseParameter(const CVariant &value, JSONSchemaTypeDefinitionPtr parameter); + bool parseParameter(const CVariant& value, const JSONSchemaTypeDefinitionPtr& parameter); bool parseReturn(const CVariant &value); - static JSONRPC_STATUS checkParameter(const CVariant &requestParameters, JSONSchemaTypeDefinitionPtr type, unsigned int position, CVariant &outputParameters, unsigned int &handled, CVariant &errorData); + static JSONRPC_STATUS checkParameter(const CVariant& requestParameters, + const JSONSchemaTypeDefinitionPtr& type, + unsigned int position, + CVariant& outputParameters, + unsigned int& handled, + CVariant& errorData); }; /*! @@ -390,10 +395,11 @@ namespace JSONRPC static bool addMethod(const std::string &jsonMethod, MethodCall method); static void parseHeader(const CVariant &descriptionObject); static bool parseJSONSchemaType(const CVariant &value, std::vector<JSONSchemaTypeDefinitionPtr>& typeDefinitions, JSONSchemaType &schemaType, std::string &missingReference); - static void addReferenceTypeDefinition(JSONSchemaTypeDefinitionPtr typeDefinition); + static void addReferenceTypeDefinition(const JSONSchemaTypeDefinitionPtr& typeDefinition); static void removeReferenceTypeDefinition(const std::string &typeID); - static void getReferencedTypes(const JSONSchemaTypeDefinitionPtr type, std::vector<std::string> &referencedTypes); + static void getReferencedTypes(const JSONSchemaTypeDefinitionPtr& type, + std::vector<std::string>& referencedTypes); class CJsonRpcMethodMap { diff --git a/xbmc/interfaces/json-rpc/JSONUtils.h b/xbmc/interfaces/json-rpc/JSONUtils.h index 66e49a6714..6b4ebf57a3 100644 --- a/xbmc/interfaces/json-rpc/JSONUtils.h +++ b/xbmc/interfaces/json-rpc/JSONUtils.h @@ -120,7 +120,13 @@ namespace JSONRPC the given object is not an array) or for a parameter at the given position (if the given object is an array). */ - static inline bool ParameterExists(const CVariant ¶meterObject, std::string key, unsigned int position) { return IsValueMember(parameterObject, key) || (parameterObject.isArray() && parameterObject.size() > position); } + static inline bool ParameterExists(const CVariant& parameterObject, + const std::string& key, + unsigned int position) + { + return IsValueMember(parameterObject, key) || + (parameterObject.isArray() && parameterObject.size() > position); + } /*! \brief Checks if the given object contains a value @@ -130,7 +136,10 @@ namespace JSONRPC \return True if the given object contains a member with the given key otherwise false */ - static inline bool IsValueMember(const CVariant &value, std::string key) { return value.isMember(key); } + static inline bool IsValueMember(const CVariant& value, const std::string& key) + { + return value.isMember(key); + } /*! \brief Returns the json value of a parameter @@ -144,7 +153,12 @@ namespace JSONRPC the given object is not an array) or of the parameter at the given position (if the given object is an array). */ - static inline CVariant GetParameter(const CVariant ¶meterObject, std::string key, unsigned int position) { return IsValueMember(parameterObject, key) ? parameterObject[key] : parameterObject[position]; } + static inline CVariant GetParameter(const CVariant& parameterObject, + const std::string& key, + unsigned int position) + { + return IsValueMember(parameterObject, key) ? parameterObject[key] : parameterObject[position]; + } /*! \brief Returns the json value of a parameter or the given @@ -161,7 +175,17 @@ namespace JSONRPC given position (if the given object is an array). If the parameter does not exist the given default value is returned. */ - static inline CVariant GetParameter(const CVariant ¶meterObject, std::string key, unsigned int position, CVariant fallback) { return IsValueMember(parameterObject, key) ? parameterObject[key] : ((parameterObject.isArray() && parameterObject.size() > position) ? parameterObject[position] : fallback); } + static inline CVariant GetParameter(const CVariant& parameterObject, + const std::string& key, + unsigned int position, + const CVariant& fallback) + { + return IsValueMember(parameterObject, key) + ? parameterObject[key] + : ((parameterObject.isArray() && parameterObject.size() > position) + ? parameterObject[position] + : fallback); + } /*! \brief Returns the given json value as a string @@ -187,7 +211,7 @@ namespace JSONRPC \param transport String representation of the TransportLayerCapability \return TransportLayerCapability value of the given string representation */ - static inline TransportLayerCapability StringToTransportLayer(std::string transport) + static inline TransportLayerCapability StringToTransportLayer(const std::string& transport) { if (transport.compare("Announcing") == 0) return Announcing; @@ -205,7 +229,7 @@ namespace JSONRPC \param valueType String representation of the JSONSchemaType \return JSONSchemaType value of the given string representation */ - static inline JSONSchemaType StringToSchemaValueType(std::string valueType) + static inline JSONSchemaType StringToSchemaValueType(const std::string& valueType) { if (valueType.compare("null") == 0) return NullValue; @@ -417,7 +441,10 @@ namespace JSONRPC static inline bool HasType(JSONSchemaType typeObject, JSONSchemaType type) { return (typeObject & type) == type; } - static inline bool ParameterNotNull(const CVariant ¶meterObject, std::string key) { return parameterObject.isMember(key) && !parameterObject[key].isNull(); } + static inline bool ParameterNotNull(const CVariant& parameterObject, const std::string& key) + { + return parameterObject.isMember(key) && !parameterObject[key].isNull(); + } /*! \brief Copies the values from the jsonStringArray to the stringArray. diff --git a/xbmc/interfaces/json-rpc/PVROperations.cpp b/xbmc/interfaces/json-rpc/PVROperations.cpp index 883b286850..9a6850a37c 100644 --- a/xbmc/interfaces/json-rpc/PVROperations.cpp +++ b/xbmc/interfaces/json-rpc/PVROperations.cpp @@ -11,11 +11,13 @@ #include "ServiceBroker.h" #include "pvr/PVRManager.h" #include "pvr/PVRPlaybackState.h" +#include "pvr/addons/PVRClients.h" #include "pvr/channels/PVRChannel.h" #include "pvr/channels/PVRChannelGroups.h" #include "pvr/channels/PVRChannelGroupsContainer.h" #include "pvr/epg/Epg.h" #include "pvr/epg/EpgContainer.h" +#include "pvr/epg/EpgInfoTag.h" #include "pvr/guilib/PVRGUIActions.h" #include "pvr/recordings/PVRRecordings.h" #include "pvr/timers/PVRTimerInfoTag.h" @@ -144,6 +146,25 @@ JSONRPC_STATUS CPVROperations::GetChannelDetails(const std::string &method, ITra return OK; } +JSONRPC_STATUS CPVROperations::GetClients(const std::string& method, + ITransportLayer* transport, + IClient* client, + const CVariant& parameterObject, + CVariant& result) +{ + if (!CServiceBroker::GetPVRManager().IsStarted()) + return FailedToExecute; + + int start, end; + + auto clientInfos = CServiceBroker::GetPVRManager().Clients()->GetEnabledClientInfos(); + HandleLimits(parameterObject, result, clientInfos.size(), start, end); + for (int index = start; index < end; index++) + result["clients"].append(clientInfos[index]); + + return OK; +} + JSONRPC_STATUS CPVROperations::GetBroadcasts(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { if (!CServiceBroker::GetPVRManager().IsStarted()) @@ -179,8 +200,9 @@ JSONRPC_STATUS CPVROperations::GetBroadcastDetails(const std::string &method, IT if (!CServiceBroker::GetPVRManager().IsStarted()) return FailedToExecute; - const std::shared_ptr<CPVREpgInfoTag> epgTag = CServiceBroker::GetPVRManager().EpgContainer().GetTagById(nullptr, - parameterObject["broadcastid"].asUnsignedInteger()); + const std::shared_ptr<CPVREpgInfoTag> epgTag = + CServiceBroker::GetPVRManager().EpgContainer().GetTagByDatabaseId( + parameterObject["broadcastid"].asInteger()); if (!epgTag) return InvalidParams; @@ -190,6 +212,26 @@ JSONRPC_STATUS CPVROperations::GetBroadcastDetails(const std::string &method, IT return OK; } +JSONRPC_STATUS CPVROperations::GetBroadcastIsPlayable(const std::string& method, + ITransportLayer* transport, + IClient* client, + const CVariant& parameterObject, + CVariant& result) +{ + if (!CServiceBroker::GetPVRManager().IsStarted()) + return FailedToExecute; + + const std::shared_ptr<CPVREpgInfoTag> epgTag = + CServiceBroker::GetPVRManager().EpgContainer().GetTagByDatabaseId( + parameterObject["broadcastid"].asInteger()); + + if (!epgTag) + return InvalidParams; + + result = epgTag->IsPlayable(); + + return OK; +} JSONRPC_STATUS CPVROperations::Record(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -240,8 +282,19 @@ JSONRPC_STATUS CPVROperations::Scan(const std::string &method, ITransportLayer * if (!CServiceBroker::GetPVRManager().IsStarted()) return FailedToExecute; - CServiceBroker::GetPVRManager().GUIActions()->StartChannelScan(); - return ACK; + if (parameterObject.isMember("clientid")) + { + if (CServiceBroker::GetPVRManager().GUIActions()->StartChannelScan( + parameterObject["clientid"].asInteger())) + return ACK; + } + else + { + if (CServiceBroker::GetPVRManager().GUIActions()->StartChannelScan()) + return ACK; + } + + return FailedToExecute; } JSONRPC_STATUS CPVROperations::GetPropertyValue(const std::string &property, CVariant &result) @@ -351,7 +404,9 @@ JSONRPC_STATUS CPVROperations::AddTimer(const std::string &method, ITransportLay if (CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(epgTag)) return InvalidParams; - std::shared_ptr<CPVRTimerInfoTag> newTimer = CPVRTimerInfoTag::CreateFromEpg(epgTag, parameterObject["timerrule"].asBoolean(false)); + const std::shared_ptr<CPVRTimerInfoTag> newTimer = + CPVRTimerInfoTag::CreateFromEpg(epgTag, parameterObject["timerrule"].asBoolean(false), + parameterObject["reminder"].asBoolean(false)); if (newTimer) { if (CServiceBroker::GetPVRManager().GUIActions()->AddTimer(newTimer)) diff --git a/xbmc/interfaces/json-rpc/PVROperations.h b/xbmc/interfaces/json-rpc/PVROperations.h index d75df45f22..da08390be8 100644 --- a/xbmc/interfaces/json-rpc/PVROperations.h +++ b/xbmc/interfaces/json-rpc/PVROperations.h @@ -25,8 +25,18 @@ namespace JSONRPC static JSONRPC_STATUS GetChannelGroupDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS GetChannels(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS GetChannelDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); + static JSONRPC_STATUS GetClients(const std::string& method, + ITransportLayer* transport, + IClient* client, + const CVariant& parameterObject, + CVariant& result); static JSONRPC_STATUS GetBroadcasts(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS GetBroadcastDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); + static JSONRPC_STATUS GetBroadcastIsPlayable(const std::string& method, + ITransportLayer* transport, + IClient* client, + const CVariant& parameterObject, + CVariant& result); static JSONRPC_STATUS GetTimers(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS GetTimerDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS GetRecordings(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.cpp b/xbmc/interfaces/json-rpc/PlayerOperations.cpp index 74922394df..8572736bef 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.cpp +++ b/xbmc/interfaces/json-rpc/PlayerOperations.cpp @@ -123,7 +123,7 @@ JSONRPC_STATUS CPlayerOperations::GetPlayers(const std::string &method, ITranspo playerCoreFactory.GetPlayers(players, true, video); } - for (auto playername: players) + for (const auto& playername : players) { CVariant player(CVariant::VariantTypeObject); player["name"] = playername; @@ -171,12 +171,9 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const std::string &method, ITransportL { fileItem = std::make_shared<CFileItem>(g_application.CurrentFileItem()); if (IsPVRChannel()) - { - const std::shared_ptr<CPVRChannel> currentChannel = CServiceBroker::GetPVRManager().PlaybackState()->GetPlayingChannel(); - if (currentChannel) - fileItem = std::make_shared<CFileItem>(currentChannel); - } - else if (player == Video) + break; + + if (player == Video) { if (!CVideoLibrary::FillFileItem(fileItem->GetPath(), fileItem, parameterObject)) { @@ -195,33 +192,7 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const std::string &method, ITransportL fileItem->SetPath(originalPath); // Ensure path unchanged } } - } - else - { - if (!CAudioLibrary::FillFileItem(fileItem->GetPath(), fileItem, parameterObject)) - { - // Fallback to item details held by GUI but ensure path unchanged - //! @todo remove this once there is no route to playback that updates - // GUI item without also updating app item e.g. start playback of a - // non-library item via JSON - const MUSIC_INFO::CMusicInfoTag *currentMusicTag = CServiceBroker::GetGUI()->GetInfoManager().GetCurrentSongTag(); - if (currentMusicTag != NULL) - { - std::string originalLabel = fileItem->GetLabel(); - std::string originalPath = fileItem->GetPath(); - fileItem->SetFromMusicInfoTag(*currentMusicTag); - if (fileItem->GetLabel().empty()) - fileItem->SetLabel(originalLabel); - fileItem->SetPath(originalPath); // Ensure path unchanged - } - } - } - if (IsPVRChannel()) - break; - - if (player == Video) - { bool additionalInfo = false; for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++) { @@ -261,8 +232,27 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const std::string &method, ITransportL videodatabase.Close(); } } - else if (player == Audio) + else // Audio { + if (!CAudioLibrary::FillFileItem(fileItem->GetPath(), fileItem, parameterObject)) + { + // Fallback to item details held by GUI but ensure path unchanged + //! @todo remove this once there is no route to playback that updates + // GUI item without also updating app item e.g. start playback of a + // non-library item via JSON + const MUSIC_INFO::CMusicInfoTag* currentMusicTag = + CServiceBroker::GetGUI()->GetInfoManager().GetCurrentSongTag(); + if (currentMusicTag != NULL) + { + std::string originalLabel = fileItem->GetLabel(); + std::string originalPath = fileItem->GetPath(); + fileItem->SetFromMusicInfoTag(*currentMusicTag); + if (fileItem->GetLabel().empty()) + fileItem->SetLabel(originalLabel); + fileItem->SetPath(originalPath); // Ensure path unchanged + } + } + if (fileItem->IsMusicDb()) { CMusicDatabase musicdb; @@ -725,6 +715,21 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye CApplicationMessenger::GetInstance().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "playercontrol(partymode(" + parameterObject["item"]["partymode"].asString() + "))"); return ACK; } + else if (parameterObject["item"].isMember("broadcastid")) + { + const std::shared_ptr<CPVREpgInfoTag> epgTag = + CServiceBroker::GetPVRManager().EpgContainer().GetTagByDatabaseId( + static_cast<unsigned int>(parameterObject["item"]["broadcastid"].asInteger())); + + if (!epgTag || !epgTag->IsPlayable()) + return InvalidParams; + + if (!CServiceBroker::GetPVRManager().GUIActions()->PlayEpgTag( + std::make_shared<CFileItem>(epgTag))) + return FailedToExecute; + + return ACK; + } else if (parameterObject["item"].isMember("channelid")) { const std::shared_ptr<CPVRChannelGroupsContainer> channelGroupContainer = CServiceBroker::GetPVRManager().ChannelGroups(); @@ -806,7 +811,7 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye playerCoreFactory.GetPlayers(*list.Get(0).get(), possiblePlayers); bool match = false; - for (auto entry : possiblePlayers) + for (const auto& entry : possiblePlayers) { if (StringUtils::EqualsNoCase(entry, playername)) { @@ -1104,6 +1109,22 @@ JSONRPC_STATUS CPlayerOperations::SetAudioStream(const std::string &method, ITra return ACK; } +JSONRPC_STATUS CPlayerOperations::AddSubtitle(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) +{ + if (GetPlayer(parameterObject["playerid"]) != Video) + return FailedToExecute; + + if (!g_application.GetAppPlayer().HasPlayer()) + return FailedToExecute; + + if (!parameterObject["subtitle"].isString()) + return FailedToExecute; + + std::string sub = parameterObject["subtitle"].asString(); + g_application.GetAppPlayer().AddSubtitle(sub); + return ACK; +} + JSONRPC_STATUS CPlayerOperations::SetSubtitle(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { switch (GetPlayer(parameterObject["playerid"])) diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.h b/xbmc/interfaces/json-rpc/PlayerOperations.h index ddfc004e14..6e58ea1a7e 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.h +++ b/xbmc/interfaces/json-rpc/PlayerOperations.h @@ -61,6 +61,7 @@ namespace JSONRPC static JSONRPC_STATUS SetPartymode(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS SetAudioStream(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); + static JSONRPC_STATUS AddSubtitle(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS SetSubtitle(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS SetVideoStream(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); private: diff --git a/xbmc/interfaces/json-rpc/ProfilesOperations.cpp b/xbmc/interfaces/json-rpc/ProfilesOperations.cpp index a1804d2f06..1648d930b9 100644 --- a/xbmc/interfaces/json-rpc/ProfilesOperations.cpp +++ b/xbmc/interfaces/json-rpc/ProfilesOperations.cpp @@ -111,7 +111,7 @@ JSONRPC_STATUS CProfilesOperations::LoadProfile(const std::string &method, ITran else if (!bCanceled) // Password needed and user provided it { const CVariant &passwordObject = parameterObject["password"]; - std::string strToVerify = profile->getLockCode(); + const std::string& strToVerify = profile->getLockCode(); std::string password = passwordObject["value"].asString(); // Create password hash from the provided password if md5 is not used diff --git a/xbmc/interfaces/json-rpc/SettingsOperations.cpp b/xbmc/interfaces/json-rpc/SettingsOperations.cpp index 890e6ee7fd..e6bb10068e 100644 --- a/xbmc/interfaces/json-rpc/SettingsOperations.cpp +++ b/xbmc/interfaces/json-rpc/SettingsOperations.cpp @@ -341,7 +341,8 @@ SettingLevel CSettingsOperations::ParseSettingLevel(const std::string &strLevel) return SettingLevel::Standard; } -bool CSettingsOperations::SerializeISetting(std::shared_ptr<const ISetting> setting, CVariant &obj) +bool CSettingsOperations::SerializeISetting(const std::shared_ptr<const ISetting>& setting, + CVariant& obj) { if (setting == NULL) return false; @@ -351,7 +352,8 @@ bool CSettingsOperations::SerializeISetting(std::shared_ptr<const ISetting> sett return true; } -bool CSettingsOperations::SerializeSettingSection(std::shared_ptr<const CSettingSection> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingSection( + const std::shared_ptr<const CSettingSection>& setting, CVariant& obj) { if (!SerializeISetting(setting, obj)) return false; @@ -363,7 +365,8 @@ bool CSettingsOperations::SerializeSettingSection(std::shared_ptr<const CSetting return true; } -bool CSettingsOperations::SerializeSettingCategory(std::shared_ptr<const CSettingCategory> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingCategory( + const std::shared_ptr<const CSettingCategory>& setting, CVariant& obj) { if (!SerializeISetting(setting, obj)) return false; @@ -375,12 +378,14 @@ bool CSettingsOperations::SerializeSettingCategory(std::shared_ptr<const CSettin return true; } -bool CSettingsOperations::SerializeSettingGroup(std::shared_ptr<const CSettingGroup> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingGroup(const std::shared_ptr<const CSettingGroup>& setting, + CVariant& obj) { return SerializeISetting(setting, obj); } -bool CSettingsOperations::SerializeSetting(std::shared_ptr<const CSetting> setting, CVariant &obj) +bool CSettingsOperations::SerializeSetting(const std::shared_ptr<const CSetting>& setting, + CVariant& obj) { if (!SerializeISetting(setting, obj)) return false; @@ -463,7 +468,8 @@ bool CSettingsOperations::SerializeSetting(std::shared_ptr<const CSetting> setti return true; } -bool CSettingsOperations::SerializeSettingBool(std::shared_ptr<const CSettingBool> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingBool(const std::shared_ptr<const CSettingBool>& setting, + CVariant& obj) { if (setting == NULL) return false; @@ -474,7 +480,8 @@ bool CSettingsOperations::SerializeSettingBool(std::shared_ptr<const CSettingBoo return true; } -bool CSettingsOperations::SerializeSettingInt(std::shared_ptr<const CSettingInt> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingInt(const std::shared_ptr<const CSettingInt>& setting, + CVariant& obj) { if (setting == NULL) return false; @@ -540,7 +547,8 @@ bool CSettingsOperations::SerializeSettingInt(std::shared_ptr<const CSettingInt> return true; } -bool CSettingsOperations::SerializeSettingNumber(std::shared_ptr<const CSettingNumber> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingNumber( + const std::shared_ptr<const CSettingNumber>& setting, CVariant& obj) { if (setting == NULL) return false; @@ -555,7 +563,8 @@ bool CSettingsOperations::SerializeSettingNumber(std::shared_ptr<const CSettingN return true; } -bool CSettingsOperations::SerializeSettingString(std::shared_ptr<const CSettingString> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingString( + const std::shared_ptr<const CSettingString>& setting, CVariant& obj) { if (setting == NULL) return false; @@ -643,7 +652,8 @@ bool CSettingsOperations::SerializeSettingString(std::shared_ptr<const CSettingS return true; } -bool CSettingsOperations::SerializeSettingAction(std::shared_ptr<const CSettingAction> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingAction( + const std::shared_ptr<const CSettingAction>& setting, CVariant& obj) { if (setting == NULL) return false; @@ -653,7 +663,8 @@ bool CSettingsOperations::SerializeSettingAction(std::shared_ptr<const CSettingA return true; } -bool CSettingsOperations::SerializeSettingList(std::shared_ptr<const CSettingList> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingList(const std::shared_ptr<const CSettingList>& setting, + CVariant& obj) { if (setting == NULL || !SerializeSetting(setting->GetDefinition(), obj["definition"])) @@ -670,7 +681,8 @@ bool CSettingsOperations::SerializeSettingList(std::shared_ptr<const CSettingLis return true; } -bool CSettingsOperations::SerializeSettingPath(std::shared_ptr<const CSettingPath> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingPath(const std::shared_ptr<const CSettingPath>& setting, + CVariant& obj) { if (setting == NULL) return false; @@ -682,7 +694,8 @@ bool CSettingsOperations::SerializeSettingPath(std::shared_ptr<const CSettingPat return true; } -bool CSettingsOperations::SerializeSettingAddon(std::shared_ptr<const CSettingAddon> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingAddon(const std::shared_ptr<const CSettingAddon>& setting, + CVariant& obj) { if (setting == NULL) return false; @@ -693,7 +706,8 @@ bool CSettingsOperations::SerializeSettingAddon(std::shared_ptr<const CSettingAd return true; } -bool CSettingsOperations::SerializeSettingDate(std::shared_ptr<const CSettingDate> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingDate(const std::shared_ptr<const CSettingDate>& setting, + CVariant& obj) { if (setting == NULL) return false; @@ -703,7 +717,8 @@ bool CSettingsOperations::SerializeSettingDate(std::shared_ptr<const CSettingDat return true; } -bool CSettingsOperations::SerializeSettingTime(std::shared_ptr<const CSettingTime> setting, CVariant &obj) +bool CSettingsOperations::SerializeSettingTime(const std::shared_ptr<const CSettingTime>& setting, + CVariant& obj) { if (setting == NULL) return false; @@ -713,7 +728,8 @@ bool CSettingsOperations::SerializeSettingTime(std::shared_ptr<const CSettingTim return true; } -bool CSettingsOperations::SerializeSettingControl(std::shared_ptr<const ISettingControl> control, CVariant &obj) +bool CSettingsOperations::SerializeSettingControl( + const std::shared_ptr<const ISettingControl>& control, CVariant& obj) { if (control == NULL) return false; diff --git a/xbmc/interfaces/json-rpc/SettingsOperations.h b/xbmc/interfaces/json-rpc/SettingsOperations.h index c1c9731740..fd08d250d7 100644 --- a/xbmc/interfaces/json-rpc/SettingsOperations.h +++ b/xbmc/interfaces/json-rpc/SettingsOperations.h @@ -47,22 +47,36 @@ namespace JSONRPC private: static SettingLevel ParseSettingLevel(const std::string &strLevel); - static bool SerializeISetting(std::shared_ptr<const ISetting> setting, CVariant &obj); - static bool SerializeSettingSection(std::shared_ptr<const CSettingSection> setting, CVariant &obj); - static bool SerializeSettingCategory(std::shared_ptr<const CSettingCategory> setting, CVariant &obj); - static bool SerializeSettingGroup(std::shared_ptr<const CSettingGroup> setting, CVariant &obj); - static bool SerializeSetting(std::shared_ptr<const CSetting> setting, CVariant &obj); - static bool SerializeSettingBool(std::shared_ptr<const CSettingBool> setting, CVariant &obj); - static bool SerializeSettingInt(std::shared_ptr<const CSettingInt> setting, CVariant &obj); - static bool SerializeSettingNumber(std::shared_ptr<const CSettingNumber> setting, CVariant &obj); - static bool SerializeSettingString(std::shared_ptr<const CSettingString> setting, CVariant &obj); - static bool SerializeSettingAction(std::shared_ptr<const CSettingAction> setting, CVariant &obj); - static bool SerializeSettingList(std::shared_ptr<const CSettingList> setting, CVariant &obj); - static bool SerializeSettingPath(std::shared_ptr<const CSettingPath> setting, CVariant &obj); - static bool SerializeSettingAddon(std::shared_ptr<const CSettingAddon> setting, CVariant &obj); - static bool SerializeSettingDate(std::shared_ptr<const CSettingDate> setting, CVariant &obj); - static bool SerializeSettingTime(std::shared_ptr<const CSettingTime> setting, CVariant &obj); - static bool SerializeSettingControl(std::shared_ptr<const ISettingControl> control, CVariant &obj); + static bool SerializeISetting(const std::shared_ptr<const ISetting>& setting, CVariant& obj); + static bool SerializeSettingSection(const std::shared_ptr<const CSettingSection>& setting, + CVariant& obj); + static bool SerializeSettingCategory(const std::shared_ptr<const CSettingCategory>& setting, + CVariant& obj); + static bool SerializeSettingGroup(const std::shared_ptr<const CSettingGroup>& setting, + CVariant& obj); + static bool SerializeSetting(const std::shared_ptr<const CSetting>& setting, CVariant& obj); + static bool SerializeSettingBool(const std::shared_ptr<const CSettingBool>& setting, + CVariant& obj); + static bool SerializeSettingInt(const std::shared_ptr<const CSettingInt>& setting, + CVariant& obj); + static bool SerializeSettingNumber(const std::shared_ptr<const CSettingNumber>& setting, + CVariant& obj); + static bool SerializeSettingString(const std::shared_ptr<const CSettingString>& setting, + CVariant& obj); + static bool SerializeSettingAction(const std::shared_ptr<const CSettingAction>& setting, + CVariant& obj); + static bool SerializeSettingList(const std::shared_ptr<const CSettingList>& setting, + CVariant& obj); + static bool SerializeSettingPath(const std::shared_ptr<const CSettingPath>& setting, + CVariant& obj); + static bool SerializeSettingAddon(const std::shared_ptr<const CSettingAddon>& setting, + CVariant& obj); + static bool SerializeSettingDate(const std::shared_ptr<const CSettingDate>& setting, + CVariant& obj); + static bool SerializeSettingTime(const std::shared_ptr<const CSettingTime>& setting, + CVariant& obj); + static bool SerializeSettingControl(const std::shared_ptr<const ISettingControl>& control, + CVariant& obj); static void SerializeSettingListValues(const std::vector<CVariant> &values, CVariant &obj); }; diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index f809ee1143..d23ad943d7 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -145,6 +145,11 @@ }, { "type": "object", "required": true, "additionalProperties": false, "properties": { + "broadcastid": { "$ref": "Library.Id", "required": true } + } + }, + { "type": "object", "required": true, "additionalProperties": false, + "properties": { "channelid": { "$ref": "Library.Id", "required": true } } }, @@ -359,7 +364,7 @@ "zoom": { "type": "number", "required": true }, "pixelratio": { "type": "number", "required": true }, "verticalshift": { "type": "number", "required": true }, - "nonlinearstretch": { "type": "boolean", "required": true } + "nonlinearstretch": { "type": "boolean", "required": true } } } }, @@ -457,6 +462,17 @@ ], "returns": "string" }, + "Player.AddSubtitle": { + "type": "method", + "description": "Add subtitle to the player", + "transport": "Response", + "permission": "ControlPlayback", + "params": [ + { "name": "playerid", "$ref": "Player.Id", "required": true }, + { "name": "subtitle", "type": "string", "required": true, "description": "Local path or remote URL to the subtitle file to load" } + ], + "returns": "string" + }, "Player.SetSubtitle": { "type": "method", "description": "Set the subtitle displayed by the player", @@ -2050,6 +2066,23 @@ } } }, + "PVR.GetClients": { + "type": "method", + "description": "Retrieves the enabled PVR clients and their capabilities", + "transport": "Response", + "permission": "ReadData", + "params": [ + { "name": "limits", "$ref": "List.Limits" } + ], + "returns": { "type": "object", + "properties": { + "limits": { "$ref": "List.LimitsReturned", "required": true }, + "clients": { "type": "array", "required": true, + "items": { "$ref": "PVR.Details.Client" } + } + } + } + }, "PVR.GetBroadcasts": { "type": "method", "description": "Retrieves the program of a specific channel", @@ -2084,6 +2117,16 @@ } } }, + "PVR.GetBroadcastIsPlayable": { + "type": "method", + "description": "Retrieves whether or not a broadcast is playable", + "transport": "Response", + "permission": "ReadData", + "params": [ + { "name": "broadcastid", "$ref": "Library.Id", "required": true, "description": "the id of the broadcast to to check for playability" } + ], + "returns": "boolean" + }, "PVR.GetTimers": { "type": "method", "description": "Retrieves the timers", @@ -2119,12 +2162,13 @@ }, "PVR.AddTimer": { "type": "method", - "description": "Adds a timer to record the given show one times or a timer rule to record all showings of the given show", + "description": "Adds a timer to record the given show one times or a timer rule to record all showings of the given show or adds a reminder timer or reminder timer rule", "transport": "Response", "permission": "ControlPVR", "params": [ { "name": "broadcastid", "$ref": "Library.Id", "required": true, "description": "the broadcast id of the item to record" }, - { "name": "timerrule", "type": "boolean", "default": false, "description": "controls whether to create a timer rule or a onetime timer" } + { "name": "timerrule", "type": "boolean", "default": false, "description": "controls whether to create a timer rule or a onetime timer" }, + { "name": "reminder", "type": "boolean", "default": false, "description": "controls whether to create a reminder timer or a recording timer" } ], "returns": "string" }, @@ -2203,7 +2247,9 @@ "description": "Starts a channel scan", "transport": "Response", "permission": "ControlPVR", - "params": [ ], + "params": [ + { "name": "clientid", "$ref": "Library.Id", "description": "Specify a PVR client id to avoid UI dialog, optional in kodi 19, required in kodi 20" } + ], "returns": "string" }, "Textures.GetTextures": { diff --git a/xbmc/interfaces/json-rpc/schema/types.json b/xbmc/interfaces/json-rpc/schema/types.json index 0863c002f2..c4d40317e1 100644 --- a/xbmc/interfaces/json-rpc/schema/types.json +++ b/xbmc/interfaces/json-rpc/schema/types.json @@ -112,7 +112,7 @@ }, "order": { "type": "string", "default": "ascending", "enum": [ "ascending", "descending" ] }, "ignorearticle": { "type": "boolean", "default": false }, - "useartistsortname": { "type": "boolean", "default": false } + "useartistsortname": { "type": "boolean", "default": false } } }, "Library.Id": { @@ -211,10 +211,10 @@ { "type": "string", "enum": [ "increase", "decrease" ], "required": true }, { "$ref": "Optional.Number", "minimum":0.5, "maximum": 2.0, "description": "Pixel aspect ratio where 1.0 means square pixel", "required": true } ] }, "verticalshift": { "type": [ - { "type": "string", "enum": [ "increase", "decrease" ], "required": true }, + { "type": "string", "enum": [ "increase", "decrease" ], "required": true }, { "$ref": "Optional.Number", "minimum": -2.0, "maximum": 2.0, "description": "Vertical shift 1.0 means shift to bottom", "required": true } ] }, "nonlinearstretch": { "type": [ - { "type": "string", "enum": [ "increase", "decrease" ], "required": true }, + { "type": "string", "enum": [ "increase", "decrease" ], "required": true }, { "$ref": "Optional.Boolean", "description": "Flag to enable nonlinear stretch", "required": true } ] } } }, @@ -474,7 +474,7 @@ "genreid": { "$ref": "Library.Id", "required": true }, "title": { "type": "string" }, "thumbnail": { "type": "string" }, - "sourceid": { "$ref": "Array.Integer", "description": "The ids of sources with songs of the genre" } + "sourceid": { "$ref": "Array.Integer", "description": "The ids of sources with songs of the genre" } } }, "Library.Fields.Tag": { @@ -651,7 +651,7 @@ "musicbrainzalbumid": { "type": "string" }, "songgenres": {"$ref": "Audio.Details.Genres"}, "lastplayed": { "type": "string" }, - "sourceid": { "$ref": "Array.Integer" }, + "sourceid": { "$ref": "Array.Integer" }, "isboxset" : { "type": "boolean" }, "totaldiscs": { "type": "integer" }, "albumstatus": { "type": "string" }, @@ -708,7 +708,7 @@ "songslastadded": { "type": "string" }, "albumslastadded": { "type": "string" }, "artistslastadded": { "type": "string" }, - "genreslastadded": { "type": "string" }, + "genreslastadded": { "type": "string" }, "songsmodified": { "type": "string" }, "albumsmodified": { "type": "string" }, "artistsmodified": { "type": "string" } @@ -1016,7 +1016,7 @@ "firstaired", "hastimer", "isactive", "parentalrating", "wasactive", "thumbnail", "rating", "originaltitle", "cast", "director", "writer", "year", "imdbnumber", "hastimerrule", - "hasrecording", "recording", "isseries", "isplayable" ] + "hasrecording", "recording", "isseries", "isplayable", "clientid" ] } }, "PVR.Details.Broadcast": { @@ -1052,7 +1052,8 @@ "hasrecording": { "type": "boolean" }, "recording": { "type": "string" }, "isseries": { "type": "boolean" }, - "isplayable": { "type": "boolean" } + "isplayable": { "type": "boolean", "description": "Deprecated - Use GetBroadcastIsPlayable instead" }, + "clientid": { "$ref": "Library.Id" } } }, "PVR.Fields.Channel": { @@ -1060,7 +1061,7 @@ "items": { "type": "string", "enum": [ "thumbnail", "channeltype", "hidden", "locked", "channel", "lastplayed", "broadcastnow", "broadcastnext", "uniqueid", "icon", "channelnumber", - "subchannelnumber", "isrecording", "hasarchive" ] + "subchannelnumber", "isrecording", "hasarchive", "clientid" ] } }, "PVR.Details.Channel": { @@ -1080,7 +1081,8 @@ "channelnumber": { "type": "integer" }, "subchannelnumber": { "type": "integer" }, "isrecording": { "type": "boolean" }, - "hasarchive": { "type": "boolean" } + "hasarchive": { "type": "boolean" }, + "clientid": { "$ref": "Library.Id" } } }, "PVR.Details.ChannelGroup": { @@ -1099,6 +1101,28 @@ } } }, + "PVR.Fields.Client": { + "extends": "Item.Fields.Base", + "items": { "type": "string", + "enum": [ "addonid", "supportstv", "supportsradio", "supportsepg", + "supportsrecordings", "supportstimers", "supportschannelgroups", + "supportschannelscan" ] + } + }, + "PVR.Details.Client": { + "extends": "Item.Details.Base", + "properties": { + "clientid": { "$ref": "Library.Id", "required": true }, + "addonid": { "type": "string" }, + "supportstv": { "type": "boolean" }, + "supportsradio": { "type": "boolean" }, + "supportsepg": { "type": "boolean" }, + "supportsrecordings": { "type": "boolean" }, + "supportstimers": { "type": "boolean" }, + "supportschannelgroups": { "type": "boolean" }, + "supportschannelscan": { "type": "boolean" } + } + }, "PVR.TimerState": { "type": "string", "enum": [ "unknown", "new", "scheduled", "recording", "completed", @@ -1113,7 +1137,7 @@ "weekdays", "priority", "startmargin", "endmargin", "state", "file", "directory", "preventduplicateepisodes", "startanytime", "endanytime", "epgsearchstring", "fulltextepgsearch", "recordinggroup", - "maxrecordings", "epguid", "isreadonly" ] + "maxrecordings", "epguid", "isreadonly", "isreminder", "clientid" ] } }, "PVR.Details.Timer": { @@ -1149,7 +1173,9 @@ "recordinggroup": { "type": "integer" }, "maxrecordings": { "type": "integer" }, "epguid": { "type": "integer" }, - "isreadonly": { "type": "boolean" } + "isreadonly": { "type": "boolean" }, + "isreminder": { "type": "boolean" }, + "clientid": { "$ref": "Library.Id" } } }, "PVR.Fields.Recording": { @@ -1159,7 +1185,7 @@ "resume", "channel", "starttime","endtime", "runtime", "lifetime", "icon", "art", "streamurl", "file", "directory", "radio", "isdeleted", "epgeventid", "channeluid", - "season", "episode", "showtitle" ] + "season", "episode", "showtitle", "clientid" ] } }, "PVR.Details.Recording": { @@ -1188,7 +1214,8 @@ "channeluid": { "type": "integer" }, "season": { "type": "integer" }, "episode": { "type": "integer" }, - "showtitle": { "type": "string" } + "showtitle": { "type": "string" }, + "clientid": { "$ref": "Library.Id" } } }, "Textures.Details.Size": { @@ -1552,12 +1579,13 @@ "disc", "tag", "art", "genreid", "displayartist", "albumartistid", "description", "theme", "mood", "style", "albumlabel", "sorttitle", "episodeguide", "uniqueid", "dateadded", "channel", "channeltype", "hidden", - "locked", "channelnumber", "starttime", "endtime", "specialsortseason", - "specialsortepisode", "compilation", "releasetype", "albumreleasetype", - "contributors", "displaycomposer", "displayconductor", "displayorchestra", "displaylyricist", - "userrating", "votes", "sortartist", "musicbrainzreleasegroupid", "mediapath", "dynpath", - "isboxset", "totaldiscs", "disctitle", "releasedate", "originaldate", "bpm", - "bitrate", "samplerate", "channels", "albumstatus", "datemodified", "datenew", "customproperties", + "locked", "channelnumber", "subchannelnumber", "starttime", "endtime", + "specialsortseason", "specialsortepisode", "compilation", "releasetype", + "albumreleasetype", "contributors", "displaycomposer", "displayconductor", + "displayorchestra", "displaylyricist", "userrating", "votes", "sortartist", + "musicbrainzreleasegroupid", "mediapath", "dynpath", "isboxset", "totaldiscs", + "disctitle", "releasedate", "originaldate", "bpm", "bitrate", "samplerate", + "channels", "albumstatus", "datemodified", "datenew", "customproperties", "albumduration"] } }, @@ -1569,6 +1597,7 @@ "hidden": { "type": "boolean" }, "locked": { "type": "boolean" }, "channelnumber": { "type": "integer" }, + "subchannelnumber": { "type": "integer" }, "starttime": { "type": "string" }, "endtime": { "type": "string" } } diff --git a/xbmc/interfaces/json-rpc/schema/version.txt b/xbmc/interfaces/json-rpc/schema/version.txt index f0bec16621..86885f3d04 100644 --- a/xbmc/interfaces/json-rpc/schema/version.txt +++ b/xbmc/interfaces/json-rpc/schema/version.txt @@ -1 +1 @@ -JSONRPC_VERSION 11.15.0 +JSONRPC_VERSION 11.19.0 diff --git a/xbmc/interfaces/legacy/Control.cpp b/xbmc/interfaces/legacy/Control.cpp index 0b84900732..f4398fec7d 100644 --- a/xbmc/interfaces/legacy/Control.cpp +++ b/xbmc/interfaces/legacy/Control.cpp @@ -1201,7 +1201,8 @@ namespace XBMCAddon sendLabelBind(vecItems.size()); } - void ControlList::internAddListItem(AddonClass::Ref<ListItem> pListItem, bool sendMessage) + void ControlList::internAddListItem(const AddonClass::Ref<ListItem>& pListItem, + bool sendMessage) { if (pListItem.isNull()) throw WindowException("NULL ListItem passed to ControlList::addListItem"); diff --git a/xbmc/interfaces/legacy/Control.h b/xbmc/interfaces/legacy/Control.h index 4d884539e3..cc9a8f4ae7 100644 --- a/xbmc/interfaces/legacy/Control.h +++ b/xbmc/interfaces/legacy/Control.h @@ -1148,7 +1148,7 @@ namespace XBMCAddon /// class ControlList : public Control { - void internAddListItem(AddonClass::Ref<ListItem> listitem, bool sendMessage); + void internAddListItem(const AddonClass::Ref<ListItem>& listitem, bool sendMessage); public: ControlList(long x, long y, long width, long height, const char* font = NULL, diff --git a/xbmc/interfaces/legacy/Dialog.cpp b/xbmc/interfaces/legacy/Dialog.cpp index b00c03facf..d1c641a3dc 100644 --- a/xbmc/interfaces/legacy/Dialog.cpp +++ b/xbmc/interfaces/legacy/Dialog.cpp @@ -282,7 +282,7 @@ namespace XBMCAddon { if (!defaultt.empty() && defaultt.size() == 10) { - std::string sDefault = defaultt; + const std::string& sDefault = defaultt; timedate.day = atoi(sDefault.substr(0, 2).c_str()); timedate.month = atoi(sDefault.substr(3, 4).c_str()); timedate.year = atoi(sDefault.substr(sDefault.size() - 4).c_str()); @@ -296,7 +296,7 @@ namespace XBMCAddon { if (!defaultt.empty() && defaultt.size() == 5) { - std::string sDefault = defaultt; + const std::string& sDefault = defaultt; timedate.hour = atoi(sDefault.substr(0, 2).c_str()); timedate.minute = atoi(sDefault.substr(3, 2).c_str()); } @@ -375,7 +375,7 @@ namespace XBMCAddon { if (!defaultt.empty() && defaultt.size() == 10) { - std::string sDefault = defaultt; + const std::string& sDefault = defaultt; timedate.day = atoi(sDefault.substr(0, 2).c_str()); timedate.month = atoi(sDefault.substr(3, 4).c_str()); timedate.year = atoi(sDefault.substr(sDefault.size() - 4).c_str()); @@ -391,7 +391,7 @@ namespace XBMCAddon { if (!defaultt.empty() && defaultt.size() == 5) { - std::string sDefault = defaultt; + const std::string& sDefault = defaultt; timedate.hour = atoi(sDefault.substr(0, 2).c_str()); timedate.minute = atoi(sDefault.substr(3, 2).c_str()); } diff --git a/xbmc/interfaces/legacy/DrmCryptoSession.cpp b/xbmc/interfaces/legacy/DrmCryptoSession.cpp index 6409e5f094..26f69be5af 100644 --- a/xbmc/interfaces/legacy/DrmCryptoSession.cpp +++ b/xbmc/interfaces/legacy/DrmCryptoSession.cpp @@ -16,10 +16,12 @@ namespace XBMCAddon { namespace xbmcdrm { - CryptoSession::CryptoSession(String UUID, String cipherAlgorithm, String macAlgorithm) - : m_cryptoSession(DRM::CCryptoSession::GetCryptoSession(UUID, cipherAlgorithm, macAlgorithm)) - { - } + CryptoSession::CryptoSession(const String& UUID, + const String& cipherAlgorithm, + const String& macAlgorithm) + : m_cryptoSession(DRM::CCryptoSession::GetCryptoSession(UUID, cipherAlgorithm, macAlgorithm)) + { + } CryptoSession::~CryptoSession() { @@ -56,7 +58,7 @@ namespace XBMCAddon m_cryptoSession->RemoveKeys(); } - void CryptoSession::RestoreKeys(String keySetId) + void CryptoSession::RestoreKeys(const String& keySetId) { if (m_cryptoSession) m_cryptoSession->RestoreKeys(keySetId); diff --git a/xbmc/interfaces/legacy/DrmCryptoSession.h b/xbmc/interfaces/legacy/DrmCryptoSession.h index 562fa8bebe..816bec8bc5 100644 --- a/xbmc/interfaces/legacy/DrmCryptoSession.h +++ b/xbmc/interfaces/legacy/DrmCryptoSession.h @@ -96,8 +96,7 @@ namespace XBMCAddon { DRM::CCryptoSession* m_cryptoSession; public: - - CryptoSession(String UUID, String cipherAlgorithm, String macAlgorithm); + CryptoSession(const String& UUID, const String& cipherAlgorithm, const String& macAlgorithm); ~CryptoSession() override; #ifdef DOXYGEN_SHOULD_USE_THIS @@ -217,7 +216,7 @@ namespace XBMCAddon /// RestoreKeys(...); #else - void RestoreKeys(String keySetId); + void RestoreKeys(const String& keySetId); #endif #ifdef DOXYGEN_SHOULD_USE_THIS diff --git a/xbmc/interfaces/legacy/ListItem.cpp b/xbmc/interfaces/legacy/ListItem.cpp index f73df260bb..b5089e23b8 100644 --- a/xbmc/interfaces/legacy/ListItem.cpp +++ b/xbmc/interfaces/legacy/ListItem.cpp @@ -24,6 +24,7 @@ #include <cstdlib> #include <sstream> +#include <utility> namespace XBMCAddon { @@ -135,7 +136,10 @@ namespace XBMCAddon vtag.SetUniqueID(it.second, it.first, it.first == defaultrating); } - void ListItem::setRating(std::string type, float rating, int votes /* = 0 */, bool defaultt /* = false */) + void ListItem::setRating(const std::string& type, + float rating, + int votes /* = 0 */, + bool defaultt /* = false */) { if (!item) return; @@ -148,7 +152,7 @@ namespace XBMCAddon if (!item) return; XBMCAddonUtils::GuiLock lock(languageHook, m_offscreen); - GetVideoInfoTag()->m_namedSeasons[number] = name; + GetVideoInfoTag()->m_namedSeasons[number] = std::move(name); } void ListItem::select(bool selected) @@ -620,7 +624,7 @@ namespace XBMCAddon for (const auto& genreEntry: alt.later()) { const String& genre = genreEntry.which() == first ? genreEntry.former() : genreEntry.later().first(); - genres.emplace_back(std::move(genre)); + genres.emplace_back(genre); } gametag.SetGenres(genres); @@ -688,7 +692,14 @@ namespace XBMCAddon GetVideoInfoTag()->m_fanart.Pack(); } - void ListItem::addAvailableArtwork(std::string url, std::string art_type, std::string preview, std::string referrer, std::string cache, bool post, bool isgz, int season) + void ListItem::addAvailableArtwork(const std::string& url, + const std::string& art_type, + const std::string& preview, + const std::string& referrer, + const std::string& cache, + bool post, + bool isgz, + int season) { XBMCAddonUtils::GuiLock lock(languageHook, m_offscreen); GetVideoInfoTag()->m_strPictureURL.AddParsedUrl(url, art_type, preview, referrer, cache, post, diff --git a/xbmc/interfaces/legacy/ListItem.h b/xbmc/interfaces/legacy/ListItem.h index 5169837242..e419bb6f3a 100644 --- a/xbmc/interfaces/legacy/ListItem.h +++ b/xbmc/interfaces/legacy/ListItem.h @@ -20,6 +20,7 @@ #include "commons/Exception.h" #include <map> +#include <utility> #include <vector> @@ -79,9 +80,7 @@ namespace XBMCAddon bool offscreen = false); #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS - inline explicit ListItem(CFileItemPtr pitem) : - item(pitem), m_offscreen(false) - {} + inline explicit ListItem(CFileItemPtr pitem) : item(std::move(pitem)), m_offscreen(false) {} static inline AddonClass::Ref<ListItem> fromString(const String& str) { @@ -319,7 +318,7 @@ namespace XBMCAddon /// setRating(...); #else - void setRating(std::string type, float rating, int votes = 0, bool defaultt = false); + void setRating(const std::string& type, float rating, int votes = 0, bool defaultt = false); #endif #ifdef DOXYGEN_SHOULD_USE_THIS @@ -773,7 +772,14 @@ namespace XBMCAddon /// addAvailableArtwork(...); #else - void addAvailableArtwork(std::string url, std::string art_type = "", std::string preview = "", std::string referrer = "", std::string cache = "", bool post = false, bool isgz = false, int season = -1); + void addAvailableArtwork(const std::string& url, + const std::string& art_type = "", + const std::string& preview = "", + const std::string& referrer = "", + const std::string& cache = "", + bool post = false, + bool isgz = false, + int season = -1); #endif #ifdef DOXYGEN_SHOULD_USE_THIS diff --git a/xbmc/interfaces/legacy/ModuleXbmcplugin.cpp b/xbmc/interfaces/legacy/ModuleXbmcplugin.cpp index 4778b7822b..0af97b71ac 100644 --- a/xbmc/interfaces/legacy/ModuleXbmcplugin.cpp +++ b/xbmc/interfaces/legacy/ModuleXbmcplugin.cpp @@ -63,14 +63,22 @@ namespace XBMCAddon XFILE::CPluginDirectory::SetResolvedUrl(handle, succeeded, pListItem->item.get()); } - void addSortMethod(int handle, int sortMethod, const String& clabel2Mask) + void addSortMethod(int handle, int sortMethod, const String& clabelMask, const String& clabel2Mask) { + String labelMask; + if (sortMethod == SORT_METHOD_TRACKNUM) + labelMask = (clabelMask.empty() ? "[%N. ]%T" : clabelMask.c_str()); + else if (sortMethod == SORT_METHOD_EPISODE || sortMethod == SORT_METHOD_PRODUCTIONCODE) + labelMask = (clabelMask.empty() ? "%H. %T" : clabelMask.c_str()); + else + labelMask = (clabelMask.empty() ? "%T" : clabelMask.c_str()); + String label2Mask; label2Mask = (clabel2Mask.empty() ? "%D" : clabel2Mask.c_str()); // call the directory class to add the sort method. if (sortMethod >= SORT_METHOD_NONE && sortMethod < SORT_METHOD_MAX) - XFILE::CPluginDirectory::AddSortMethod(handle, (SORT_METHOD)sortMethod, label2Mask); + XFILE::CPluginDirectory::AddSortMethod(handle, (SORT_METHOD)sortMethod, labelMask, label2Mask); } String getSetting(int handle, const char* id) diff --git a/xbmc/interfaces/legacy/ModuleXbmcplugin.h b/xbmc/interfaces/legacy/ModuleXbmcplugin.h index 01000650a4..f36fe46116 100644 --- a/xbmc/interfaces/legacy/ModuleXbmcplugin.h +++ b/xbmc/interfaces/legacy/ModuleXbmcplugin.h @@ -170,7 +170,8 @@ namespace XBMCAddon #ifdef DOXYGEN_SHOULD_USE_THIS /// /// \ingroup python_xbmcplugin - /// @brief \python_func{ xbmcplugin.addSortMethod(handle, sortMethod [,label2Mask]) } + /// @brief \python_func{ xbmcplugin.addSortMethod(handle, sortMethod [,labelMask, label2Mask]) } + ///------------------------------------------------------------------------- /// Adds a sorting method for the media list. /// /// @param handle integer - handle the plugin was started @@ -222,6 +223,17 @@ namespace XBMCAddon /// | xbmcplugin.SORT_METHOD_DATE_TAKEN | Sort by the taken date /// | xbmcplugin.SORT_METHOD_VIDEO_USER_RATING | Sort by the rating of the user of video /// | xbmcplugin.SORT_METHOD_SONG_USER_RATING | Sort by the rating of the user of song + /// @param labelMask [opt] string - the label mask to use for + /// the first label. + /// - applies to: + /// | sortMethod | labelMask | + /// |---------------------------------------|-----------------------------| + /// | SORT_METHOD_TRACKNUM | Defaults to `[%%N. ]%%T` | + /// | SORT_METHOD_EPISODE | Defaults to `%%H. %%T` | + /// | SORT_METHOD_PRODUCTIONCODE | Defaults to `%%H. %%T` | + /// | All other sort methods | Defaults to `%%T` | + /// + /// /// @param label2Mask [opt] string - the label mask to use for /// the second label. Defaults to `%%D` /// - applies to: @@ -240,6 +252,7 @@ namespace XBMCAddon /// **SORT_METHOD_DATEADDED**, **SORT_METHOD_FULLPATH**, **SORT_METHOD_LABEL_IGNORE_FOLDERS**, /// **SORT_METHOD_LASTPLAYED**, **SORT_METHOD_PLAYCOUNT**, **SORT_METHOD_CHANNEL**. /// @python_v17 Added new sort **SORT_METHOD_VIDEO_USER_RATING**. + /// @python_v19 Added new option **labelMask**. /// /// **Example:** /// ~~~~~~~~~~~~~{.py} @@ -250,7 +263,7 @@ namespace XBMCAddon /// addSortMethod(...); #else - void addSortMethod(int handle, int sortMethod, const String& label2Mask = emptyString); + void addSortMethod(int handle, int sortMethod, const String& labelMask = emptyString, const String& label2Mask = emptyString); #endif #ifdef DOXYGEN_SHOULD_USE_THIS diff --git a/xbmc/interfaces/legacy/Monitor.h b/xbmc/interfaces/legacy/Monitor.h index 7d30aeee15..0d3d83115f 100644 --- a/xbmc/interfaces/legacy/Monitor.h +++ b/xbmc/interfaces/legacy/Monitor.h @@ -43,16 +43,33 @@ namespace XBMCAddon inline void OnScanStarted(const String &library) { XBMC_TRACE; - invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onScanStarted,library)); + invokeCallback( + new CallbackFunction<Monitor, const String>(this, &Monitor::onScanStarted, library)); } inline void OnScanFinished(const String &library) { XBMC_TRACE; - invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onScanFinished,library)); + invokeCallback( + new CallbackFunction<Monitor, const String>(this, &Monitor::onScanFinished, library)); + } + inline void OnCleanStarted(const String& library) + { + XBMC_TRACE; + invokeCallback( + new CallbackFunction<Monitor, const String>(this, &Monitor::onCleanStarted, library)); + } + inline void OnCleanFinished(const String& library) + { + XBMC_TRACE; + invokeCallback( + new CallbackFunction<Monitor, const String>(this, &Monitor::onCleanFinished, library)); + } + inline void OnNotification(const String& sender, const String& method, const String& data) + { + XBMC_TRACE; + invokeCallback(new CallbackFunction<Monitor, const String, const String, const String>( + this, &Monitor::onNotification, sender, method, data)); } - inline void OnCleanStarted(const String &library) { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onCleanStarted,library)); } - inline void OnCleanFinished(const String &library) { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onCleanFinished,library)); } - inline void OnNotification(const String &sender, const String &method, const String &data) { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor,const String,const String,const String>(this,&Monitor::onNotification,sender,method,data)); } inline const String& GetId() { return Id; } inline long GetInvokerId() { return invokerId; } @@ -230,7 +247,10 @@ namespace XBMCAddon /// onNotification(...); #else - virtual void onNotification(const String sender, const String method, const String data) { XBMC_TRACE; } + virtual void onNotification(const String sender, const String method, const String data) + { + XBMC_TRACE; + } #endif #ifdef DOXYGEN_SHOULD_USE_THIS diff --git a/xbmc/interfaces/python/PythonInvoker.cpp b/xbmc/interfaces/python/PythonInvoker.cpp index 7480321ec3..30d095a20e 100644 --- a/xbmc/interfaces/python/PythonInvoker.cpp +++ b/xbmc/interfaces/python/PythonInvoker.cpp @@ -150,7 +150,7 @@ bool CPythonInvoker::Execute( bool CPythonInvoker::execute(const std::string& script, const std::vector<std::string>& arguments) { std::vector<std::wstring> w_arguments; - for (auto argument : arguments) + for (const auto& argument : arguments) { std::wstring w_argument; g_charsetConverter.utf8ToW(argument, w_argument); diff --git a/xbmc/interfaces/python/typemaps/python.buffer.intm b/xbmc/interfaces/python/typemaps/python.buffer.intm index 57f350d81f..f074b2bad2 100644 --- a/xbmc/interfaces/python/typemaps/python.buffer.intm +++ b/xbmc/interfaces/python/typemaps/python.buffer.intm @@ -16,6 +16,15 @@ ${api}.put(str, size); ${api}.flip(); // prepare the buffer for reading from } + else if (PyBytes_Check(${slarg})) + { + Py_ssize_t pysize = PyBytes_GET_SIZE(${slarg}); + const char* str = PyBytes_AS_STRING(${slarg}); + size_t size = static_cast<size_t>(pysize); + ${api}.allocate(size); + ${api}.put(str, size); + ${api}.flip(); // prepare the buffer for reading from + } else if (PyByteArray_Check(${slarg})) { size_t size = PyByteArray_Size(${slarg}); @@ -24,4 +33,4 @@ ${api}.flip(); // prepare the buffer for reading from } else - throw XBMCAddon::WrongTypeException("argument \"%s\" for \"%s\" must be a string or a bytearray", "${api}", "${method.@name}");
\ No newline at end of file + throw XBMCAddon::WrongTypeException("argument \"%s\" for \"%s\" must be a string, bytes or a bytearray", "${api}", "${method.@name}");
\ No newline at end of file diff --git a/xbmc/messaging/ApplicationMessenger.cpp b/xbmc/messaging/ApplicationMessenger.cpp index 15a1497c0f..f4202af2b1 100644 --- a/xbmc/messaging/ApplicationMessenger.cpp +++ b/xbmc/messaging/ApplicationMessenger.cpp @@ -163,12 +163,16 @@ int CApplicationMessenger::SendMsg(uint32_t messageId, int param1, int param2, v int CApplicationMessenger::SendMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam) { - return SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, std::vector<std::string>{} }, true); + return SendMsg(ThreadMessage{messageId, param1, param2, payload, std::move(strParam), + std::vector<std::string>{}}, + true); } int CApplicationMessenger::SendMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam, std::vector<std::string> params) { - return SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, params }, true); + return SendMsg( + ThreadMessage{messageId, param1, param2, payload, std::move(strParam), std::move(params)}, + true); } void CApplicationMessenger::PostMsg(uint32_t messageId) @@ -188,12 +192,15 @@ void CApplicationMessenger::PostMsg(uint32_t messageId, int param1, int param2, void CApplicationMessenger::PostMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam) { - SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, std::vector<std::string>{} }, false); + SendMsg(ThreadMessage{messageId, param1, param2, payload, std::move(strParam), + std::vector<std::string>{}}, + false); } void CApplicationMessenger::PostMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam, std::vector<std::string> params) { - SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, params }, false); + SendMsg(ThreadMessage{messageId, param1, param2, payload, std::move(strParam), std::move(params)}, + false); } void CApplicationMessenger::ProcessMessages() diff --git a/xbmc/messaging/ThreadMessage.h b/xbmc/messaging/ThreadMessage.h index 2c72a2305d..1a277ffcd4 100644 --- a/xbmc/messaging/ThreadMessage.h +++ b/xbmc/messaging/ThreadMessage.h @@ -10,6 +10,7 @@ #include <memory> #include <string> +#include <utility> #include <vector> class CEvent; @@ -49,29 +50,34 @@ public: { } - ThreadMessage(uint32_t messageId, int p1, int p2, void* payload, std::string param, std::vector<std::string> vecParams) - : dwMessage{ messageId } - , param1{ p1 } - , param2{ p2 } - , param3{ 0 } - , lpVoid{ payload } - , strParam( param ) - , params( vecParams ) + ThreadMessage(uint32_t messageId, + int p1, + int p2, + void* payload, + std::string param, + std::vector<std::string> vecParams) + : dwMessage{messageId}, + param1{p1}, + param2{p2}, + param3{0}, + lpVoid{payload}, + strParam(std::move(param)), + params(std::move(vecParams)) { } ThreadMessage(const ThreadMessage& other) = default; - ThreadMessage(ThreadMessage&& other) + ThreadMessage(ThreadMessage&& other) noexcept : dwMessage(other.dwMessage), - param1(other.param1), - param2(other.param2), - param3(other.param3), - lpVoid(other.lpVoid), - strParam(std::move(other.strParam)), - params(std::move(other.params)), - waitEvent(std::move(other.waitEvent)), - result(std::move(other.result)) + param1(other.param1), + param2(other.param2), + param3(other.param3), + lpVoid(other.lpVoid), + strParam(std::move(other.strParam)), + params(std::move(other.params)), + waitEvent(std::move(other.waitEvent)), + result(std::move(other.result)) { } @@ -91,7 +97,7 @@ public: return *this; } - ThreadMessage& operator=(ThreadMessage&& other) + ThreadMessage& operator=(ThreadMessage&& other) noexcept { if (this == &other) return *this; diff --git a/xbmc/messaging/helpers/DialogHelper.cpp b/xbmc/messaging/helpers/DialogHelper.cpp index f6c877d303..2c042f5acb 100644 --- a/xbmc/messaging/helpers/DialogHelper.cpp +++ b/xbmc/messaging/helpers/DialogHelper.cpp @@ -21,7 +21,8 @@ namespace HELPERS { DialogResponse ShowYesNoDialogText(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, uint32_t autoCloseTimeout) { - return ShowYesNoCustomDialog(heading, text, noLabel, yesLabel, "", autoCloseTimeout); + return ShowYesNoCustomDialog(std::move(heading), std::move(text), std::move(noLabel), + std::move(yesLabel), "", autoCloseTimeout); } DialogResponse ShowYesNoCustomDialog(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, CVariant customLabel, uint32_t autoCloseTimeout) diff --git a/xbmc/music/Album.cpp b/xbmc/music/Album.cpp index c91e9e9db4..6561632b6e 100644 --- a/xbmc/music/Album.cpp +++ b/xbmc/music/Album.cpp @@ -271,7 +271,7 @@ void CAlbum::MergeScrapedAlbum(const CAlbum& source, bool override /* = true */) { if (artistCredit.GetMusicBrainzArtistID().empty()) { - for (auto sourceartistCredit : source.artistCredits) + for (const auto& sourceartistCredit : source.artistCredits) { if (StringUtils::EqualsNoCase(artistCredit.GetArtist(), sourceartistCredit.GetArtist())) { @@ -332,7 +332,7 @@ void CAlbum::MergeScrapedAlbum(const CAlbum& source, bool override /* = true */) for (auto &song : songs) { if (!song.strMusicBrainzTrackID.empty()) - for (auto sourceSong : source.songs) + for (const auto& sourceSong : source.songs) if ((sourceSong.strMusicBrainzTrackID == song.strMusicBrainzTrackID) && (sourceSong.iTrack == song.iTrack)) song.MergeScrapedSong(sourceSong, override); } @@ -388,7 +388,7 @@ const std::string CAlbum::GetAlbumArtistSort() const if (!strArtistSort.empty()) return strArtistSort; std::vector<std::string> artistvector; - for (auto artistcredit : artistCredits) + for (const auto& artistcredit : artistCredits) if (!artistcredit.GetSortName().empty()) artistvector.emplace_back(artistcredit.GetSortName()); std::string artistString; diff --git a/xbmc/music/Artist.h b/xbmc/music/Artist.h index c729d75046..37864b61ea 100644 --- a/xbmc/music/Artist.h +++ b/xbmc/music/Artist.h @@ -126,11 +126,17 @@ class CArtistCredit public: CArtistCredit() = default; - explicit CArtistCredit(std::string strArtist) : m_strArtist(strArtist) { } + explicit CArtistCredit(std::string strArtist) : m_strArtist(std::move(strArtist)) {} CArtistCredit(std::string strArtist, std::string strMusicBrainzArtistID) - : m_strArtist(strArtist), m_strMusicBrainzArtistID(strMusicBrainzArtistID) { } + : m_strArtist(std::move(strArtist)), m_strMusicBrainzArtistID(std::move(strMusicBrainzArtistID)) + { + } CArtistCredit(std::string strArtist, std::string strSortName, std::string strMusicBrainzArtistID) - : m_strArtist(strArtist), m_strSortName(strSortName), m_strMusicBrainzArtistID(strMusicBrainzArtistID) { } + : m_strArtist(std::move(strArtist)), + m_strSortName(std::move(strSortName)), + m_strMusicBrainzArtistID(std::move(strMusicBrainzArtistID)) + { + } bool operator<(const CArtistCredit& a) const { @@ -179,8 +185,17 @@ class CMusicRole { public: CMusicRole() = default; - CMusicRole(std::string strRole, std::string strArtist) : idRole(-1), m_strRole(strRole), m_strArtist(strArtist), idArtist(-1) { } - CMusicRole(int role, std::string strRole, std::string strArtist, long ArtistId) : idRole(role), m_strRole(strRole), m_strArtist(strArtist), idArtist(ArtistId) { } + CMusicRole(std::string strRole, std::string strArtist) + : idRole(-1), m_strRole(std::move(strRole)), m_strArtist(std::move(strArtist)), idArtist(-1) + { + } + CMusicRole(int role, std::string strRole, std::string strArtist, long ArtistId) + : idRole(role), + m_strRole(std::move(strRole)), + m_strArtist(std::move(strArtist)), + idArtist(ArtistId) + { + } std::string GetArtist() const { return m_strArtist; } std::string GetRoleDesc() const { return m_strRole; } int GetRoleId() const { return idRole; } diff --git a/xbmc/music/ContextMenus.cpp b/xbmc/music/ContextMenus.cpp index b3bcffa610..8a432f775d 100644 --- a/xbmc/music/ContextMenus.cpp +++ b/xbmc/music/ContextMenus.cpp @@ -12,12 +12,15 @@ #include "music/dialogs/GUIDialogMusicInfo.h" #include "tags/MusicInfoTag.h" +#include <utility> namespace CONTEXTMENU { CMusicInfo::CMusicInfo(MediaType mediaType) - : CStaticContextMenuAction(19033), m_mediaType(mediaType) {} + : CStaticContextMenuAction(19033), m_mediaType(std::move(mediaType)) +{ +} bool CMusicInfo::IsVisible(const CFileItem& item) const { diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp index bedaaee4d1..16b9cf4e7a 100644 --- a/xbmc/music/MusicDatabase.cpp +++ b/xbmc/music/MusicDatabase.cpp @@ -688,7 +688,6 @@ bool CMusicDatabase::AddAlbum(CAlbum& album, int idSource) std::distance(album.artistCredits.begin(), artistCredit)); } - int albumDuration = 0; for (auto song = album.songs.begin(); song != album.songs.end(); ++song) { song->idAlbum = album.idAlbum; @@ -730,9 +729,16 @@ bool CMusicDatabase::AddAlbum(CAlbum& album, int idSource) // Having added artist credits (maybe with MBID) add the other contributing artists (no MBID) // and use COMPOSERSORT tag data to provide sort names for artists that are composers AddSongContributors(song->idSong, song->GetContributors(), song->GetComposerSort()); - albumDuration += song->iDuration; } + // Set album duration as total of all songs on album. + // Folder layout may mean AddAlbum call has added more songs to an existing album + std::string strSQL; + strSQL = PrepareSQL("SELECT SUM(iDuration) FROM song WHERE idAlbum = %i", album.idAlbum); + int albumDuration = static_cast<int>(strtol(GetSingleValue(strSQL).c_str(), nullptr, 10)); + m_pDS->exec(PrepareSQL("UPDATE album SET iAlbumDuration = %i WHERE idAlbum = %i", albumDuration, + album.idAlbum)); + // Add album sources if (idSource > 0) AddAlbumSource(album.idAlbum, idSource); @@ -782,7 +788,6 @@ bool CMusicDatabase::AddAlbum(CAlbum& album, int idSource) For artists that are neither album nor song artists (other roles only) dateadded will be null. */ std::vector<std::string> artistIDs; - std::string strSQL; // Get distinct song and album artist IDs for this album GetArtistsByAlbum(album.idAlbum, artistIDs); std::string strIDs = "(" + StringUtils::Join(artistIDs, ",") + ")"; @@ -791,8 +796,6 @@ bool CMusicDatabase::AddAlbum(CAlbum& album, int idSource) albumdateadded.c_str(), strIDs.c_str(), albumdateadded.c_str()); m_pDS->exec(strSQL); - m_pDS->exec(PrepareSQL("UPDATE album SET iAlbumDuration = %i WHERE idAlbum = %i", albumDuration, - album.idAlbum)); CommitTransaction(); return true; } @@ -2313,7 +2316,10 @@ bool CMusicDatabase::DeleteSongArtistsBySong(int idSong) return ExecuteQuery(PrepareSQL("DELETE FROM song_artist WHERE idSong = %i", idSong)); } -bool CMusicDatabase::AddAlbumArtist(int idArtist, int idAlbum, std::string strArtist, int iOrder) +bool CMusicDatabase::AddAlbumArtist(int idArtist, + int idAlbum, + const std::string& strArtist, + int iOrder) { std::string strSQL; strSQL = PrepareSQL("replace into album_artist (idArtist, idAlbum, strArtist, iOrder) values(%i,%i,'%s',%i)", @@ -3110,7 +3116,7 @@ bool CMusicDatabase::SearchArtists(const std::string& search, CFileItemList &art return false; } - std::string artistLabel(g_localizeStrings.Get(557)); // Artist + const std::string& artistLabel(g_localizeStrings.Get(557)); // Artist while (!m_pDS->eof()) { std::string path = StringUtils::Format("musicdb://artists/%i/", m_pDS->fv(0).get_asInt()); @@ -3679,7 +3685,6 @@ bool CMusicDatabase::SearchSongs(const std::string& search, CFileItemList &items if (!m_pDS->query(strSQL)) return false; if (m_pDS->num_rows() == 0) return false; - std::string songLabel = g_localizeStrings.Get(179); // Song while (!m_pDS->eof()) { CFileItemPtr item(new CFileItem); @@ -3716,7 +3721,7 @@ bool CMusicDatabase::SearchAlbums(const std::string& search, CFileItemList &albu if (!m_pDS->query(strSQL)) return false; - std::string albumLabel(g_localizeStrings.Get(558)); // Album + const std::string& albumLabel(g_localizeStrings.Get(558)); // Album while (!m_pDS->eof()) { CAlbum album = GetAlbumFromDataset(m_pDS.get()); @@ -4294,7 +4299,7 @@ bool CMusicDatabase::LookupCDDBInfo(bool bRequery/*=false*/) std::string strTitle = cddb.getInexactTitle(i); if (strTitle == "") break; - std::string strArtist = cddb.getInexactArtist(i); + const std::string& strArtist = cddb.getInexactArtist(i); if (!strArtist.empty()) strTitle += " - " + strArtist; @@ -7671,8 +7676,8 @@ std::string CMusicDatabase::GetIgnoreArticleSQL(const std::string& strField) StringUtils::Replace(tokenclause, "%", "%%"); // Single %, _ and ' so avoid using PrepareSQL tokenclause = strField + " LIKE '" + tokenclause + "%'"; - if (token.find("_") != std::string::npos) - tokenclause += " ESCAPE '_'"; + if (token.find('_') != std::string::npos) + tokenclause += " ESCAPE '_'"; if (!strWhen.empty()) strWhen += " OR "; strWhen += tokenclause; @@ -10673,7 +10678,7 @@ bool CMusicDatabase::CommitTransaction() return false; } -bool CMusicDatabase::SetScraperAll(const std::string & strBaseDir, const ADDON::ScraperPtr scraper) +bool CMusicDatabase::SetScraperAll(const std::string& strBaseDir, const ADDON::ScraperPtr& scraper) { if (nullptr == m_pDB) return false; @@ -10750,7 +10755,9 @@ bool CMusicDatabase::SetScraperAll(const std::string & strBaseDir, const ADDON:: return false; } -bool CMusicDatabase::SetScraper(int id, const CONTENT_TYPE &content, const ADDON::ScraperPtr scraper) +bool CMusicDatabase::SetScraper(int id, + const CONTENT_TYPE& content, + const ADDON::ScraperPtr& scraper) { if (nullptr == m_pDB) return false; diff --git a/xbmc/music/MusicDatabase.h b/xbmc/music/MusicDatabase.h index 91d69d4ee5..c7ab3328ae 100644 --- a/xbmc/music/MusicDatabase.h +++ b/xbmc/music/MusicDatabase.h @@ -413,7 +413,7 @@ public: ///////////////////////////////////////////////// // Link tables ///////////////////////////////////////////////// - bool AddAlbumArtist(int idArtist, int idAlbum, std::string strArtist, int iOrder); + bool AddAlbumArtist(int idArtist, int idAlbum, const std::string& strArtist, int iOrder); bool GetAlbumsByArtist(int idArtist, std::vector<int>& albums); bool GetArtistsByAlbum(int idAlbum, CFileItem* item); bool GetArtistsByAlbum(int idAlbum, std::vector<std::string>& artistIDs); @@ -540,8 +540,8 @@ public: ///////////////////////////////////////////////// // Scraper ///////////////////////////////////////////////// - bool SetScraper(int id, const CONTENT_TYPE &content, const ADDON::ScraperPtr scraper); - bool SetScraperAll(const std::string& strBaseDir, const ADDON::ScraperPtr scraper); + bool SetScraper(int id, const CONTENT_TYPE& content, const ADDON::ScraperPtr& scraper); + bool SetScraperAll(const std::string& strBaseDir, const ADDON::ScraperPtr& scraper); bool GetScraper(int id, const CONTENT_TYPE &content, ADDON::ScraperPtr& scraper); /*! \brief Check whether a given scraper is in use. diff --git a/xbmc/music/MusicThumbLoader.cpp b/xbmc/music/MusicThumbLoader.cpp index 1f0ff867d9..adfe428b48 100644 --- a/xbmc/music/MusicThumbLoader.cpp +++ b/xbmc/music/MusicThumbLoader.cpp @@ -325,7 +325,7 @@ bool CMusicThumbLoader::FillLibraryArt(CFileItem &item) item.SetArtFallback("fanart", fanartfallback); // Process specific disc art when we have some - for (auto discart : discartmap) + for (const auto& discart : discartmap) { std::map<std::string, std::string>::iterator it; if (tag.GetType() == MediaTypeAlbum) diff --git a/xbmc/music/MusicUtils.cpp b/xbmc/music/MusicUtils.cpp index f7e68547d3..0a15b6f1b8 100644 --- a/xbmc/music/MusicUtils.cpp +++ b/xbmc/music/MusicUtils.cpp @@ -36,15 +36,16 @@ namespace MUSIC_UTILS std::string m_artType; std::string m_newArt; public: - CSetArtJob(const CFileItemPtr item, const std::string& type, const std::string& newArt) : - pItem(item), - m_artType(type), - m_newArt(newArt) + CSetArtJob(const CFileItemPtr& item, const std::string& type, const std::string& newArt) + : pItem(item), m_artType(type), m_newArt(newArt) { } ~CSetArtJob(void) override = default; - bool HasSongExtraArtChanged(const CFileItemPtr pSongItem, const std::string& type, const int itemID, CMusicDatabase& db) + bool HasSongExtraArtChanged(const CFileItemPtr& pSongItem, + const std::string& type, + const int itemID, + CMusicDatabase& db) { if (!pSongItem->HasMusicInfoTag()) return false; @@ -174,7 +175,9 @@ namespace MUSIC_UTILS } }; - void UpdateArtJob(const CFileItemPtr pItem, const std::string& strType, const std::string& strArt) + void UpdateArtJob(const CFileItemPtr& pItem, + const std::string& strType, + const std::string& strArt) { // Asynchronously update that type of art in the database CSetArtJob *job = new CSetArtJob(pItem, strType, strArt); @@ -328,7 +331,7 @@ namespace MUSIC_UTILS return -1; } - void UpdateSongRatingJob(const CFileItemPtr pItem, int userrating) + void UpdateSongRatingJob(const CFileItemPtr& pItem, int userrating) { // Asynchronously update the song user rating in music library const CMusicInfoTag *tag = pItem->GetMusicInfoTag(); diff --git a/xbmc/music/MusicUtils.h b/xbmc/music/MusicUtils.h index 0a4e332fcd..5c395bcc88 100644 --- a/xbmc/music/MusicUtils.h +++ b/xbmc/music/MusicUtils.h @@ -43,7 +43,9 @@ namespace MUSIC_UTILS \param strType the type of art e.g. "fanart" or "thumb" etc. \param strArt art URL, when empty the entry for that type of art is deleted. */ - void UpdateArtJob(const CFileItemPtr pItem, const std::string& strType, const std::string& strArt); + void UpdateArtJob(const CFileItemPtr& pItem, + const std::string& strType, + const std::string& strArt); /*! \brief Show a dialog to allow the selection of user rating. \param iSelected the rating to show initially @@ -55,7 +57,7 @@ namespace MUSIC_UTILS \param pItem pointer to song item being rated \param userrating the userrating 0 = no rating, 1 to 10 */ - void UpdateSongRatingJob(const CFileItemPtr pItem, int userrating); + void UpdateSongRatingJob(const CFileItemPtr& pItem, int userrating); /*! \brief Get the types of art for an artist or album that are to be automatically fetched from local files during scanning diff --git a/xbmc/music/Song.cpp b/xbmc/music/Song.cpp index 5a5f235f92..313a67c987 100644 --- a/xbmc/music/Song.cpp +++ b/xbmc/music/Song.cpp @@ -24,7 +24,6 @@ CSong::CSong(CFileItem& item) CMusicInfoTag& tag = *item.GetMusicInfoTag(); strTitle = tag.GetTitle(); genre = tag.GetGenre(); - std::vector<std::string> artist = tag.GetArtist(); strArtistDesc = tag.GetArtistString(); //Set sort string before processing artist credits strArtistSort = tag.GetArtistSort(); @@ -306,7 +305,7 @@ const std::string CSong::GetArtistSort() const if (!strArtistSort.empty()) return strArtistSort; std::vector<std::string> artistvector; - for (auto artistcredit: artistCredits) + for (const auto& artistcredit : artistCredits) if (!artistcredit.GetSortName().empty()) artistvector.emplace_back(artistcredit.GetSortName()); std::string artistString; diff --git a/xbmc/music/dialogs/GUIDialogInfoProviderSettings.cpp b/xbmc/music/dialogs/GUIDialogInfoProviderSettings.cpp index e487a4aa33..b5964cc43d 100644 --- a/xbmc/music/dialogs/GUIDialogInfoProviderSettings.cpp +++ b/xbmc/music/dialogs/GUIDialogInfoProviderSettings.cpp @@ -133,7 +133,8 @@ void CGUIDialogInfoProviderSettings::OnInitWindow() CGUIDialogSettingsManualBase::OnInitWindow(); } -void CGUIDialogInfoProviderSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogInfoProviderSettings::OnSettingChanged( + const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; @@ -158,7 +159,7 @@ void CGUIDialogInfoProviderSettings::OnSettingChanged(std::shared_ptr<const CSet } } -void CGUIDialogInfoProviderSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogInfoProviderSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/music/dialogs/GUIDialogInfoProviderSettings.h b/xbmc/music/dialogs/GUIDialogInfoProviderSettings.h index 44d6449283..7a9cb7d268 100644 --- a/xbmc/music/dialogs/GUIDialogInfoProviderSettings.h +++ b/xbmc/music/dialogs/GUIDialogInfoProviderSettings.h @@ -13,6 +13,7 @@ #include "settings/dialogs/GUIDialogSettingsManualBase.h" #include <map> +#include <utility> class CFileItemList; @@ -33,9 +34,9 @@ public: bool HasListItems() const override { return true; }; const ADDON::ScraperPtr& GetAlbumScraper() const { return m_albumscraper; } - void SetAlbumScraper(ADDON::ScraperPtr scraper) { m_albumscraper = scraper; } + void SetAlbumScraper(ADDON::ScraperPtr scraper) { m_albumscraper = std::move(scraper); } const ADDON::ScraperPtr& GetArtistScraper() const { return m_artistscraper; } - void SetArtistScraper(ADDON::ScraperPtr scraper) { m_artistscraper = scraper; } + void SetArtistScraper(ADDON::ScraperPtr scraper) { m_artistscraper = std::move(scraper); } /*! \brief Show dialog to change information provider for either artists or albums (not both). Has a list to select how settings are to be applied - as system default, to just current item or to all the filtered items on the node. @@ -56,8 +57,8 @@ protected: void OnInitWindow() override; // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } diff --git a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp index ce75b36a25..94b641ec44 100644 --- a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp @@ -497,7 +497,7 @@ void CGUIDialogMusicInfo::SetDiscography(CMusicDatabase& database) const m_albumSongs->Clear(); database.GetArtistDiscography(m_artist.idArtist, *m_albumSongs); CMusicThumbLoader loader; - for (auto item : *m_albumSongs) + for (const auto& item : *m_albumSongs) { // Load all the album art and related artist(s) art (could be other collaborating artists) loader.LoadItem(item.get()); diff --git a/xbmc/music/tags/MusicInfoTag.cpp b/xbmc/music/tags/MusicInfoTag.cpp index 77429c370d..9b2293c352 100644 --- a/xbmc/music/tags/MusicInfoTag.cpp +++ b/xbmc/music/tags/MusicInfoTag.cpp @@ -758,7 +758,7 @@ void CMusicInfoTag::SetAlbumReleaseType(CAlbum::ReleaseType releaseType) m_albumReleaseType = releaseType; } -void CMusicInfoTag::SetType(const MediaType mediaType) +void CMusicInfoTag::SetType(const MediaType& mediaType) { m_type = mediaType; } diff --git a/xbmc/music/tags/MusicInfoTag.h b/xbmc/music/tags/MusicInfoTag.h index b0cf31eaaf..a0261a382c 100644 --- a/xbmc/music/tags/MusicInfoTag.h +++ b/xbmc/music/tags/MusicInfoTag.h @@ -147,7 +147,7 @@ public: void SetCoverArtInfo(size_t size, const std::string &mimeType); void SetReplayGain(const ReplayGain& aGain); void SetAlbumReleaseType(CAlbum::ReleaseType releaseType); - void SetType(const MediaType mediaType); + void SetType(const MediaType& mediaType); void SetDiscSubtitle(const std::string& strDiscSubtitle); void SetTotalDiscs(int iDiscTotal); void SetBPM(int iBPM); diff --git a/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp b/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp index 2cfea52be9..8b37e34b22 100644 --- a/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp +++ b/xbmc/music/tags/MusicInfoTagLoaderCDDA.cpp @@ -66,7 +66,7 @@ bool CMusicInfoTagLoaderCDDA::Load(const std::string& strFileName, CMusicInfoTag if (cddb.queryCDinfo(pCdInfo)) { // Fill the fileitems music tag with cddb information, if available - std::string strTitle = cddb.getTrackTitle(iTrack); + const std::string& strTitle = cddb.getTrackTitle(iTrack); if (!strTitle.empty()) { // Tracknumber diff --git a/xbmc/music/tags/TagLoaderTagLib.cpp b/xbmc/music/tags/TagLoaderTagLib.cpp index b9890f6658..d5bb2e422e 100644 --- a/xbmc/music/tags/TagLoaderTagLib.cpp +++ b/xbmc/music/tags/TagLoaderTagLib.cpp @@ -1150,8 +1150,8 @@ void CTagLoaderTagLib::AddArtistInstrument(CMusicInfoTag &tag, const std::vector { std::vector<std::string> roles; std::string strArtist = values[i]; - size_t firstLim = values[i].find_first_of("("); - size_t lastLim = values[i].find_last_of(")"); + size_t firstLim = values[i].find_first_of('('); + size_t lastLim = values[i].find_last_of(')'); if (lastLim != std::string::npos && firstLim != std::string::npos && firstLim < lastLim - 1) { //Pair of brackets with something between them diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index 633f48a908..ef91ac9374 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -263,7 +263,7 @@ bool CGUIWindowMusicBase::OnAction(const CAction &action) return CGUIMediaWindow::OnAction(action); } -void CGUIWindowMusicBase::OnItemInfoAll(const std::string strPath, bool refresh ) +void CGUIWindowMusicBase::OnItemInfoAll(const std::string& strPath, bool refresh) { if (StringUtils::EqualsNoCase(m_vecItems->GetContent(), "albums")) g_application.StartMusicAlbumScan(strPath, refresh); @@ -1008,7 +1008,7 @@ bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileIte bool CGUIWindowMusicBase::CheckFilterAdvanced(CFileItemList &items) const { - std::string content = items.GetContent(); + const std::string& content = items.GetContent(); if ((items.IsMusicDb() || CanContainFilter(m_strFilterPath)) && (StringUtils::EqualsNoCase(content, "artists") || StringUtils::EqualsNoCase(content, "albums") || diff --git a/xbmc/music/windows/GUIWindowMusicBase.h b/xbmc/music/windows/GUIWindowMusicBase.h index 9d47f52a83..e772026327 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.h +++ b/xbmc/music/windows/GUIWindowMusicBase.h @@ -90,7 +90,7 @@ protected: void RetrieveMusicInfo(); void OnItemInfo(int iItem); - void OnItemInfoAll(const std::string strPath, bool refresh = false); + void OnItemInfoAll(const std::string& strPath, bool refresh = false); virtual void OnQueueItem(int iItem, bool first = false); enum ALLOW_SELECTION { SELECTION_ALLOWED = 0, SELECTION_AUTO, SELECTION_FORCED }; diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index 82b9dd9666..a0b5533410 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -212,7 +212,7 @@ bool CGUIWindowMusicNav::OnAction(const CAction& action) return CGUIWindowMusicBase::OnAction(action); } -bool CGUIWindowMusicNav::ManageInfoProvider(const CFileItemPtr item) +bool CGUIWindowMusicNav::ManageInfoProvider(const CFileItemPtr& item) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(item->GetPath(), params); diff --git a/xbmc/music/windows/GUIWindowMusicNav.h b/xbmc/music/windows/GUIWindowMusicNav.h index bd8659bf0e..021eaad8e5 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.h +++ b/xbmc/music/windows/GUIWindowMusicNav.h @@ -38,7 +38,7 @@ protected: std::string GetStartFolder(const std::string &url) override; bool GetSongsFromPlayList(const std::string& strPlayList, CFileItemList &items); - bool ManageInfoProvider(const CFileItemPtr item); + bool ManageInfoProvider(const CFileItemPtr& item); VECSOURCES m_shares; diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp index b4be1543c1..52edc48020 100644 --- a/xbmc/network/AirTunesServer.cpp +++ b/xbmc/network/AirTunesServer.cpp @@ -235,7 +235,7 @@ void CAirTunesServer::Process() m_actionQueue.clear(); } - for (auto currentAction : currentActions) + for (const auto& currentAction : currentActions) { CSingleLock lock(m_dacpLock); if (m_pDACP) diff --git a/xbmc/network/EventClient.h b/xbmc/network/EventClient.h index e40cef0285..a8a78b9d71 100644 --- a/xbmc/network/EventClient.h +++ b/xbmc/network/EventClient.h @@ -19,6 +19,7 @@ #include <list> #include <map> #include <queue> +#include <utility> namespace EVENTCLIENT { @@ -63,9 +64,8 @@ namespace EVENTCLIENT float fAmount, bool isAxis, bool bRepeat, - bool bUseAmount): - m_buttonName(buttonName), - m_mapName(mapName) + bool bUseAmount) + : m_buttonName(std::move(buttonName)), m_mapName(std::move(mapName)) { m_iKeyCode = iKeyCode; m_fAmount = fAmount; diff --git a/xbmc/network/GUIDialogNetworkSetup.cpp b/xbmc/network/GUIDialogNetworkSetup.cpp index 768caf7de9..6c85c5c8b9 100644 --- a/xbmc/network/GUIDialogNetworkSetup.cpp +++ b/xbmc/network/GUIDialogNetworkSetup.cpp @@ -81,7 +81,7 @@ bool CGUIDialogNetworkSetup::OnMessage(CGUIMessage& message) return CGUIDialogSettingsManualBase::OnMessage(message); } -void CGUIDialogNetworkSetup::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogNetworkSetup::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -110,7 +110,7 @@ void CGUIDialogNetworkSetup::OnSettingChanged(std::shared_ptr<const CSetting> se m_password = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); } -void CGUIDialogNetworkSetup::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogNetworkSetup::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/network/GUIDialogNetworkSetup.h b/xbmc/network/GUIDialogNetworkSetup.h index 6ed9766367..1758766475 100644 --- a/xbmc/network/GUIDialogNetworkSetup.h +++ b/xbmc/network/GUIDialogNetworkSetup.h @@ -42,8 +42,8 @@ public: protected: // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } diff --git a/xbmc/network/NetworkServices.cpp b/xbmc/network/NetworkServices.cpp index 801c0d65ac..eb519eaac6 100644 --- a/xbmc/network/NetworkServices.cpp +++ b/xbmc/network/NetworkServices.cpp @@ -165,7 +165,7 @@ CNetworkServices::~CNetworkServices() #endif // HAS_WEB_SERVER } -bool CNetworkServices::OnSettingChanging(std::shared_ptr<const CSetting> setting) +bool CNetworkServices::OnSettingChanging(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return false; @@ -470,7 +470,7 @@ bool CNetworkServices::OnSettingChanging(std::shared_ptr<const CSetting> setting return true; } -void CNetworkServices::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CNetworkServices::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -492,7 +492,9 @@ void CNetworkServices::OnSettingChanged(std::shared_ptr<const CSetting> setting) } } -bool CNetworkServices::OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +bool CNetworkServices::OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) { if (setting == NULL) return false; diff --git a/xbmc/network/NetworkServices.h b/xbmc/network/NetworkServices.h index 860243107d..a511954f23 100644 --- a/xbmc/network/NetworkServices.h +++ b/xbmc/network/NetworkServices.h @@ -32,9 +32,11 @@ public: CNetworkServices(); ~CNetworkServices() override; - bool OnSettingChanging(std::shared_ptr<const CSetting> setting) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override; + bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) override; void Start(); void Stop(bool bWait); diff --git a/xbmc/network/WakeOnAccess.cpp b/xbmc/network/WakeOnAccess.cpp index 4e24fb06e9..cc2d13d2aa 100644 --- a/xbmc/network/WakeOnAccess.cpp +++ b/xbmc/network/WakeOnAccess.cpp @@ -449,7 +449,7 @@ CWakeOnAccess &CWakeOnAccess::GetInstance() bool CWakeOnAccess::WakeUpHost(const CURL& url) { - std::string hostName = url.GetHostName(); + const std::string& hostName = url.GetHostName(); if (!hostName.empty()) return WakeUpHost(hostName, url.Get(), url.IsProtocol("upnp")); @@ -753,14 +753,14 @@ void CWakeOnAccess::OnJobComplete(unsigned int jobID, bool success, CJob *job) if (IsEnabled()) { - std::string heading = LOCALIZED(13033); + const std::string& heading = LOCALIZED(13033); std::string message = StringUtils::Format(LOCALIZED(13036).c_str(), host.c_str()); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, heading, message, 4000, true, 3000); } } } -void CWakeOnAccess::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CWakeOnAccess::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/network/WakeOnAccess.h b/xbmc/network/WakeOnAccess.h index df34e93326..797f0c164d 100644 --- a/xbmc/network/WakeOnAccess.h +++ b/xbmc/network/WakeOnAccess.h @@ -29,7 +29,7 @@ public: void QueueMACDiscoveryForAllRemotes(); void OnJobComplete(unsigned int jobID, bool success, CJob *job) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; void OnSettingsLoaded() override; // struct to keep per host settings diff --git a/xbmc/network/WebServer.cpp b/xbmc/network/WebServer.cpp index 16cf5e158c..b920ac1f15 100644 --- a/xbmc/network/WebServer.cpp +++ b/xbmc/network/WebServer.cpp @@ -533,7 +533,7 @@ void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, std::shared_ptr<IHTTPRequestHandler> handler, void** con_cls) const { - connectionHandler->requestHandler = handler; + connectionHandler->requestHandler = std::move(handler); // we might need to handle the POST data ourselves which is done in the next call to // AnswerToConnection diff --git a/xbmc/network/Zeroconf.cpp b/xbmc/network/Zeroconf.cpp index 775da859ed..5ef801c8ec 100644 --- a/xbmc/network/Zeroconf.cpp +++ b/xbmc/network/Zeroconf.cpp @@ -7,9 +7,10 @@ */ #include "Zeroconf.h" -#include <cassert> - #include "ServiceBroker.h" +#if defined(HAS_MDNS) +#include "mdns/ZeroconfMDNS.h" +#endif #include "settings/Settings.h" #include "settings/SettingsComponent.h" #include "threads/Atomics.h" @@ -17,17 +18,18 @@ #include "threads/SingleLock.h" #include "utils/JobManager.h" -#if defined(HAS_AVAHI) -#include "platform/linux/network/zeroconf/ZeroconfAvahi.h" +#if defined(TARGET_ANDROID) +#include "platform/android/network/ZeroconfAndroid.h" #elif defined(TARGET_DARWIN) //on osx use the native implementation #include "platform/darwin/network/ZeroconfDarwin.h" -#elif defined(TARGET_ANDROID) -#include "platform/android/network/ZeroconfAndroid.h" -#elif defined(HAS_MDNS) -#include "mdns/ZeroconfMDNS.h" +#elif defined(HAS_AVAHI) +#include "platform/linux/network/zeroconf/ZeroconfAvahi.h" #endif +#include <cassert> +#include <utility> + #ifndef HAS_ZEROCONF //dummy implementation used if no zeroconf is present //should be optimized away @@ -63,7 +65,7 @@ bool CZeroconf::PublishService(const std::string& fcr_identifier, std::vector<std::pair<std::string, std::string> > txt /* = std::vector<std::pair<std::string, std::string> >() */) { CSingleLock lock(*mp_crit_sec); - CZeroconf::PublishInfo info = {fcr_type, fcr_name, f_port, txt}; + CZeroconf::PublishInfo info = {fcr_type, fcr_name, f_port, std::move(txt)}; std::pair<tServiceMap::const_iterator, bool> ret = m_service_map.insert(std::make_pair(fcr_identifier, info)); if(!ret.second) //identifier exists return false; diff --git a/xbmc/network/cddb.cpp b/xbmc/network/cddb.cpp index 5272369f4e..04c7ee616a 100644 --- a/xbmc/network/cddb.cpp +++ b/xbmc/network/cddb.cpp @@ -537,7 +537,7 @@ void Xcddb::parseData(const char *buffer) addTitle((strKeyword + "=" + strValue).c_str()); else if (strKeyword == "EXTD") { - std::string strExtd(strValue); + const std::string& strExtd(strValue); if (m_strYear.empty()) { @@ -863,8 +863,8 @@ bool Xcddb::queryCDinfo(CCdInfo* pInfo) std::string version = CSysInfo::GetVersion(); std::string lcAppName = CCompileInfo::GetAppName(); StringUtils::ToLower(lcAppName); - if (version.find(" ") != std::string::npos) - version = version.substr(0, version.find(" ")); + if (version.find(' ') != std::string::npos) + version = version.substr(0, version.find(' ')); std::string strGreeting = "cddb hello " + lcAppName + " kodi.tv " + CCompileInfo::GetAppName() + " " + version; if ( ! Send(strGreeting.c_str()) ) { diff --git a/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.cpp b/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.cpp index f2dabfc304..29349942b9 100644 --- a/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.cpp +++ b/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.cpp @@ -318,7 +318,8 @@ const char* CHTTPPythonWsgiInvoker::getInitializationScript() const return RUNSCRIPT; } -std::map<std::string, std::string> CHTTPPythonWsgiInvoker::createCgiEnvironment(const HTTPPythonRequest* httpRequest, ADDON::AddonPtr addon) +std::map<std::string, std::string> CHTTPPythonWsgiInvoker::createCgiEnvironment( + const HTTPPythonRequest* httpRequest, const ADDON::AddonPtr& addon) { std::map<std::string, std::string> environment; diff --git a/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.h b/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.h index 8e4b9349ba..3ec34c0eba 100644 --- a/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.h +++ b/xbmc/network/httprequesthandler/python/HTTPPythonWsgiInvoker.h @@ -39,7 +39,8 @@ protected: const char* getInitializationScript() const override; private: - static std::map<std::string, std::string> createCgiEnvironment(const HTTPPythonRequest* httpRequest, ADDON::AddonPtr addon); + static std::map<std::string, std::string> createCgiEnvironment( + const HTTPPythonRequest* httpRequest, const ADDON::AddonPtr& addon); static void addWsgiEnvironment(HTTPPythonRequest* request, void* environment); XBMCAddon::xbmcwsgi::WsgiResponse* m_wsgiResponse; diff --git a/xbmc/network/upnp/UPnPServer.cpp b/xbmc/network/upnp/UPnPServer.cpp index a593f54807..d8ed19ee94 100644 --- a/xbmc/network/upnp/UPnPServer.cpp +++ b/xbmc/network/upnp/UPnPServer.cpp @@ -255,12 +255,11 @@ NPT_String CUPnPServer::BuildSafeResourceUri(const NPT_HttpUrl &rooturi, /*---------------------------------------------------------------------- | CUPnPServer::Build +---------------------------------------------------------------------*/ -PLT_MediaObject* -CUPnPServer::Build(CFileItemPtr item, - bool with_count, - const PLT_HttpRequestContext& context, - NPT_Reference<CThumbLoader>& thumb_loader, - const char* parent_id /* = NULL */) +PLT_MediaObject* CUPnPServer::Build(const CFileItemPtr& item, + bool with_count, + const PLT_HttpRequestContext& context, + NPT_Reference<CThumbLoader>& thumb_loader, + const char* parent_id /* = NULL */) { PLT_MediaObject* object = NULL; NPT_String path = item->GetPath().c_str(); @@ -491,7 +490,7 @@ void CUPnPServer::Announce(AnnouncementFlag flag, /*---------------------------------------------------------------------- | TranslateWMPObjectId +---------------------------------------------------------------------*/ -static NPT_String TranslateWMPObjectId(NPT_String id, Logger logger) +static NPT_String TranslateWMPObjectId(NPT_String id, const Logger& logger) { if (id == "0") { id = "virtualpath://upnproot/"; @@ -1244,8 +1243,8 @@ CUPnPServer::DefaultSortItems(CFileItemList& items) } } -NPT_Result -CUPnPServer::AddSubtitleUriForSecResponse(NPT_String movie_md5, NPT_String subtitle_uri) +NPT_Result CUPnPServer::AddSubtitleUriForSecResponse(const NPT_String& movie_md5, + const NPT_String& subtitle_uri) { /* using existing m_FileMap to store subtitle uri for movie, adding subtitle:// prefix, because there is already entry for movie md5 with movie path */ diff --git a/xbmc/network/upnp/UPnPServer.h b/xbmc/network/upnp/UPnPServer.h index 89b3a454a4..e6eab41d66 100644 --- a/xbmc/network/upnp/UPnPServer.h +++ b/xbmc/network/upnp/UPnPServer.h @@ -84,7 +84,11 @@ public: const char* host, const char* file_path); - void AddSafeResourceUri(PLT_MediaObject* object, const NPT_HttpUrl& rooturi, NPT_List<NPT_IpAddress> ips, const char* file_path, const NPT_String& info) + void AddSafeResourceUri(PLT_MediaObject* object, + const NPT_HttpUrl& rooturi, + const NPT_List<NPT_IpAddress>& ips, + const char* file_path, + const NPT_String& info) { PLT_MediaItemResource res; for(NPT_List<NPT_IpAddress>::Iterator ip = ips.GetFirstItem(); ip; ++ip) { @@ -96,19 +100,20 @@ public: /* Samsung's devices get subtitles from header in response (for movie file), not from didl. It's a way to store subtitle uri generated when building didl, to use later in http response*/ - NPT_Result AddSubtitleUriForSecResponse(NPT_String movie_md5, NPT_String subtitle_uri); + NPT_Result AddSubtitleUriForSecResponse(const NPT_String& movie_md5, + const NPT_String& subtitle_uri); -private: + private: void OnScanCompleted(int type); void UpdateContainer(const std::string& id); void PropagateUpdates(); - PLT_MediaObject* Build(CFileItemPtr item, - bool with_count, + PLT_MediaObject* Build(const CFileItemPtr& item, + bool with_count, const PLT_HttpRequestContext& context, - NPT_Reference<CThumbLoader>& thumbLoader, - const char* parent_id = NULL); + NPT_Reference<CThumbLoader>& thumbLoader, + const char* parent_id = NULL); NPT_Result BuildResponse(PLT_ActionReference& action, CFileItemList& items, const char* filter, @@ -120,11 +125,13 @@ private: // class methods static void DefaultSortItems(CFileItemList& items); - static NPT_String GetParentFolder(NPT_String file_path) { - int index = file_path.ReverseFind("\\"); - if (index == -1) return ""; + static NPT_String GetParentFolder(const NPT_String& file_path) + { + int index = file_path.ReverseFind("\\"); + if (index == -1) + return ""; - return file_path.Left(index); + return file_path.Left(index); } NPT_Mutex m_CacheMutex; diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp index a37ea29ac3..7101798981 100644 --- a/xbmc/peripherals/Peripherals.cpp +++ b/xbmc/peripherals/Peripherals.cpp @@ -941,7 +941,7 @@ void CPeripherals::UnregisterJoystickButtonMapper(IButtonMapper* mapper) peripheral->UnregisterJoystickButtonMapper(mapper); } -void CPeripherals::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CPeripherals::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; @@ -959,7 +959,7 @@ void CPeripherals::OnSettingChanged(std::shared_ptr<const CSetting> setting) } } -void CPeripherals::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CPeripherals::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/peripherals/Peripherals.h b/xbmc/peripherals/Peripherals.h index 9d8ae885fc..9c07a8d1fa 100644 --- a/xbmc/peripherals/Peripherals.h +++ b/xbmc/peripherals/Peripherals.h @@ -318,8 +318,8 @@ public: void UnregisterJoystickButtonMapper(KODI::JOYSTICK::IButtonMapper* mapper); // implementation of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // implementation of IMessageTarget void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override; diff --git a/xbmc/peripherals/addons/AddonButtonMap.cpp b/xbmc/peripherals/addons/AddonButtonMap.cpp index 07d740ddc4..fbaf1d34a9 100644 --- a/xbmc/peripherals/addons/AddonButtonMap.cpp +++ b/xbmc/peripherals/addons/AddonButtonMap.cpp @@ -480,7 +480,7 @@ bool CAddonButtonMap::GetAxisProperties(unsigned int axisIndex, int& center, uns { CSingleLock lock(m_mutex); - for (auto it : m_driverMap) + for (const auto& it : m_driverMap) { const CDriverPrimitive& primitive = it.first; diff --git a/xbmc/peripherals/addons/PeripheralAddon.cpp b/xbmc/peripherals/addons/PeripheralAddon.cpp index 8a9a942231..89656ed339 100644 --- a/xbmc/peripherals/addons/PeripheralAddon.cpp +++ b/xbmc/peripherals/addons/PeripheralAddon.cpp @@ -264,7 +264,7 @@ PeripheralPtr CPeripheralAddon::GetByPath(const std::string& strPath) const PeripheralPtr result; CSingleLock lock(m_critSection); - for (auto it : m_peripherals) + for (const auto& it : m_peripherals) { if (StringUtils::EqualsNoCase(strPath, it.second->FileLocation())) { @@ -296,7 +296,7 @@ unsigned int CPeripheralAddon::GetPeripheralsWithFeature(PeripheralVector& resul { unsigned int iReturn = 0; CSingleLock lock(m_critSection); - for (auto it : m_peripherals) + for (const auto& it : m_peripherals) { if (it.second->HasFeature(feature)) { @@ -318,7 +318,7 @@ unsigned int CPeripheralAddon::GetNumberOfPeripheralsWithId(const int iVendorId, { unsigned int iReturn = 0; CSingleLock lock(m_critSection); - for (auto it : m_peripherals) + for (const auto& it : m_peripherals) { if (it.second->VendorId() == iVendorId && it.second->ProductId() == iProductId) iReturn++; @@ -330,7 +330,7 @@ unsigned int CPeripheralAddon::GetNumberOfPeripheralsWithId(const int iVendorId, void CPeripheralAddon::GetDirectory(const std::string& strPath, CFileItemList& items) const { CSingleLock lock(m_critSection); - for (auto it : m_peripherals) + for (const auto& it : m_peripherals) { const PeripheralPtr& peripheral = it.second; if (peripheral->IsHidden()) @@ -463,7 +463,7 @@ bool CPeripheralAddon::ProcessEvents(void) } } - for (auto it : m_peripherals) + for (const auto& it : m_peripherals) { if (it.second->Type() == PERIPHERAL_JOYSTICK) std::static_pointer_cast<CPeripheralJoystick>(it.second)->ProcessAxisMotions(); @@ -563,7 +563,7 @@ bool CPeripheralAddon::GetFeatures(const CPeripheral* device, { kodi::addon::JoystickFeature feature(pFeatures[i]); if (feature.Type() != JOYSTICK_FEATURE_TYPE_UNKNOWN) - features[feature.Name()] = std::move(feature); + features[feature.Name()] = feature; } m_struct.toAddon->free_features(&m_struct, featureCount, pFeatures); @@ -598,7 +598,7 @@ bool CPeripheralAddon::MapFeature(const CPeripheral* device, feature.ToStruct(addonFeature); LogError(retVal = m_struct.toAddon->map_features(&m_struct, &joystickStruct, - strControllerId.c_str(), 1, &addonFeature), + strControllerId.c_str(), 1, &addonFeature), "MapFeatures()"); kodi::addon::Joystick::FreeStruct(joystickStruct); @@ -629,7 +629,7 @@ bool CPeripheralAddon::GetIgnoredPrimitives(const CPeripheral* device, Primitive JOYSTICK_DRIVER_PRIMITIVE* pPrimitives = nullptr; LogError(retVal = m_struct.toAddon->get_ignored_primitives(&m_struct, &joystickStruct, - &primitiveCount, &pPrimitives), + &primitiveCount, &pPrimitives), "GetIgnoredPrimitives()"); kodi::addon::Joystick::FreeStruct(joystickStruct); @@ -671,7 +671,7 @@ bool CPeripheralAddon::SetIgnoredPrimitives(const CPeripheral* device, const unsigned int primitiveCount = static_cast<unsigned int>(primitives.size()); LogError(retVal = m_struct.toAddon->set_ignored_primitives(&m_struct, &joystickStruct, - primitiveCount, addonPrimitives), + primitiveCount, addonPrimitives), "SetIgnoredPrimitives()"); kodi::addon::Joystick::FreeStruct(joystickStruct); diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp index 22fe9f509a..e3295b8a30 100644 --- a/xbmc/peripherals/devices/Peripheral.cpp +++ b/xbmc/peripherals/devices/Peripheral.cpp @@ -208,12 +208,13 @@ std::vector<std::shared_ptr<CSetting>> CPeripheral::GetSettings(void) const sort(tmpSettings.begin(), tmpSettings.end(), SortBySettingsOrder()); std::vector<std::shared_ptr<CSetting>> settings; + settings.reserve(tmpSettings.size()); for (const auto& it : tmpSettings) settings.push_back(it.m_setting); return settings; } -void CPeripheral::AddSetting(const std::string& strKey, SettingConstPtr setting, int order) +void CPeripheral::AddSetting(const std::string& strKey, const SettingConstPtr& setting, int order) { if (!setting) { diff --git a/xbmc/peripherals/devices/Peripheral.h b/xbmc/peripherals/devices/Peripheral.h index 5ba510a881..d8f9869e2e 100644 --- a/xbmc/peripherals/devices/Peripheral.h +++ b/xbmc/peripherals/devices/Peripheral.h @@ -159,7 +159,7 @@ public: * @param setting The setting. */ virtual void AddSetting(const std::string& strKey, - std::shared_ptr<const CSetting> setting, + const std::shared_ptr<const CSetting>& setting, int order); /*! diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp index 160b13bcf5..d1ed1cfc98 100644 --- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp +++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp @@ -97,8 +97,11 @@ void CPeripheralCecAdapter::ResetMembers(void) m_lastKeypress = 0; m_lastChange = VOLUME_CHANGE_NONE; m_iExitCode = EXITCODE_QUIT; - m_bIsMuted = false; //! @todo fetch the correct initial value when system audiostatus is - //! implemented in libCEC + + //! @todo fetch the correct initial value when system audiostatus is + //! implemented in libCEC + m_bIsMuted = false; + m_bGoingToStandby = false; m_bIsRunning = false; m_bDeviceRemoved = false; diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.h b/xbmc/peripherals/devices/PeripheralCecAdapter.h index ff57305d48..78ac76aeaf 100644 --- a/xbmc/peripherals/devices/PeripheralCecAdapter.h +++ b/xbmc/peripherals/devices/PeripheralCecAdapter.h @@ -89,7 +89,10 @@ public: CPeripheralBus* bus); ~CPeripheralCecAdapter(void) override; - void Announce(ANNOUNCEMENT::AnnouncementFlag flag, const std::string& sender, const std::string& message, const CVariant &data) override; + void Announce(ANNOUNCEMENT::AnnouncementFlag flag, + const std::string& sender, + const std::string& message, + const CVariant& data) override; // audio control bool HasAudioControl(void); diff --git a/xbmc/peripherals/devices/PeripheralImon.cpp b/xbmc/peripherals/devices/PeripheralImon.cpp index 1661321a3c..e37310fac4 100644 --- a/xbmc/peripherals/devices/PeripheralImon.cpp +++ b/xbmc/peripherals/devices/PeripheralImon.cpp @@ -58,7 +58,7 @@ bool CPeripheralImon::InitialiseFeature(const PeripheralFeature feature) } void CPeripheralImon::AddSetting(const std::string& strKey, - std::shared_ptr<const CSetting> setting, + const std::shared_ptr<const CSetting>& setting, int order) { #if !defined(TARGET_WINDOWS) diff --git a/xbmc/peripherals/devices/PeripheralImon.h b/xbmc/peripherals/devices/PeripheralImon.h index d6e8d2c5d1..612d059019 100644 --- a/xbmc/peripherals/devices/PeripheralImon.h +++ b/xbmc/peripherals/devices/PeripheralImon.h @@ -27,7 +27,7 @@ public: void OnSettingChanged(const std::string& strChangedSetting) override; void OnDeviceRemoved() override; void AddSetting(const std::string& strKey, - std::shared_ptr<const CSetting> setting, + const std::shared_ptr<const CSetting>& setting, int order) override; inline bool IsImonConflictsWithDInput() { return m_bImonConflictsWithDInput; } static inline long GetCountOfImonsConflictWithDInput() diff --git a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp index e70a67fe3d..56fcd28a92 100644 --- a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp +++ b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp @@ -60,7 +60,7 @@ void CGUIDialogPeripheralSettings::SetFileItem(const CFileItem* item) m_item = new CFileItem(*item); } -void CGUIDialogPeripheralSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogPeripheralSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h index bd49a87220..d94d53dada 100644 --- a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h +++ b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h @@ -27,7 +27,7 @@ public: protected: // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index f19f64ab19..7ddcffa8f7 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -962,7 +962,7 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message) case GUI_MSG_SHOW_PICTURE: { - std::string strFile = message.GetStringParam(); + const std::string& strFile = message.GetStringParam(); Reset(); CFileItem item(strFile, false); Add(&item); @@ -972,9 +972,9 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message) case GUI_MSG_START_SLIDESHOW: { - std::string strFolder = message.GetStringParam(); + const std::string& strFolder = message.GetStringParam(); unsigned int iParams = message.GetParam1(); - std::string beginSlidePath = message.GetStringParam(1); + const std::string& beginSlidePath = message.GetStringParam(1); //decode params bool bRecursive = false; bool bRandom = false; @@ -1155,7 +1155,7 @@ void CGUIWindowSlideShow::OnLoadPic( if (URIUtils::IsInRAR(m_slides.at(m_iCurrentSlide)->GetPath()) || URIUtils::IsInZIP(m_slides.at(m_iCurrentSlide)->GetPath())) // move to top for cbr/cbz { CURL url(m_slides.at(m_iCurrentSlide)->GetPath()); - std::string strHostName = url.GetHostName(); + const std::string& strHostName = url.GetHostName(); if (URIUtils::HasExtension(strHostName, ".cbr|.cbz")) { m_Image[iPic].m_bIsComic = true; @@ -1322,12 +1322,13 @@ std::string CGUIWindowSlideShow::GetPicturePath(CFileItem *item) } -void CGUIWindowSlideShow::RunSlideShow(std::vector<std::string> paths, int start /* = 0*/) +void CGUIWindowSlideShow::RunSlideShow(const std::vector<std::string>& paths, int start /* = 0*/) { auto dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW); if (dialog) { std::vector<CFileItemPtr> items; + items.reserve(paths.size()); for (const auto& path : paths) items.push_back(std::make_shared<CFileItem>(CTextureUtils::GetWrappedImageURL(path), false)); diff --git a/xbmc/pictures/GUIWindowSlideShow.h b/xbmc/pictures/GUIWindowSlideShow.h index 1d23234b58..f37420c7ea 100644 --- a/xbmc/pictures/GUIWindowSlideShow.h +++ b/xbmc/pictures/GUIWindowSlideShow.h @@ -94,7 +94,7 @@ public: bool IsShuffled() const { return m_bShuffled; } int GetDirection() const { return m_iDirection; } - static void RunSlideShow(std::vector<std::string> paths, int start=0); + static void RunSlideShow(const std::vector<std::string>& paths, int start = 0); private: void ShowNext(); diff --git a/xbmc/pictures/PictureThumbLoader.cpp b/xbmc/pictures/PictureThumbLoader.cpp index da066c86a2..25163c22e2 100644 --- a/xbmc/pictures/PictureThumbLoader.cpp +++ b/xbmc/pictures/PictureThumbLoader.cpp @@ -226,6 +226,7 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem) // ok, now we've got the files to get the thumbs from, lets create it... // we basically load the 4 images and combine them std::vector<std::string> files; + files.reserve(4); for (int thumb = 0; thumb < 4; thumb++) files.push_back(items[thumb]->GetPath()); std::string thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "picturefolder"); diff --git a/xbmc/platform/Filesystem.h b/xbmc/platform/Filesystem.h index 085bb40531..3e6b7ec52b 100644 --- a/xbmc/platform/Filesystem.h +++ b/xbmc/platform/Filesystem.h @@ -26,7 +26,7 @@ space_info space(const std::string &path, std::error_code &ec); std::string temp_directory_path(std::error_code &ec); std::string create_temp_directory(std::error_code &ec); -std::string temp_file_path(std::string suffix, std::error_code &ec); +std::string temp_file_path(const std::string& suffix, std::error_code& ec); } } } diff --git a/xbmc/platform/Platform.cpp b/xbmc/platform/Platform.cpp index e1f1465c79..5b90611d74 100644 --- a/xbmc/platform/Platform.cpp +++ b/xbmc/platform/Platform.cpp @@ -26,7 +26,8 @@ CPlatform::CPlatform() = default; CPlatform::~CPlatform() = default; -void CPlatform::Init() +bool CPlatform::Init() { + return true; } diff --git a/xbmc/platform/Platform.h b/xbmc/platform/Platform.h index 0059673ac4..75dd21fbd7 100644 --- a/xbmc/platform/Platform.h +++ b/xbmc/platform/Platform.h @@ -33,6 +33,5 @@ public: * This method can be used to do platform specific environment preparation * or initialisation (like setting environment variables for example) */ - virtual void Init(); - + virtual bool Init(); }; diff --git a/xbmc/platform/android/activity/JNIXBMCMediaSession.cpp b/xbmc/platform/android/activity/JNIXBMCMediaSession.cpp index 4d7fdf2dad..67bc63a3d8 100644 --- a/xbmc/platform/android/activity/JNIXBMCMediaSession.cpp +++ b/xbmc/platform/android/activity/JNIXBMCMediaSession.cpp @@ -156,7 +156,7 @@ void CJNIXBMCMediaSession::OnSeekRequested(int64_t pos) g_application.SeekTime(pos / 1000.0); } -bool CJNIXBMCMediaSession::OnMediaButtonEvent(CJNIIntent intent) +bool CJNIXBMCMediaSession::OnMediaButtonEvent(const CJNIIntent& intent) { if (CXBMCApp::HasFocus()) { diff --git a/xbmc/platform/android/activity/JNIXBMCMediaSession.h b/xbmc/platform/android/activity/JNIXBMCMediaSession.h index 80183c6d6b..020a792b88 100644 --- a/xbmc/platform/android/activity/JNIXBMCMediaSession.h +++ b/xbmc/platform/android/activity/JNIXBMCMediaSession.h @@ -39,7 +39,7 @@ public: void OnRewindRequested(); void OnStopRequested(); void OnSeekRequested(int64_t pos); - bool OnMediaButtonEvent(CJNIIntent intent); + bool OnMediaButtonEvent(const CJNIIntent& intent); bool isActive() const; protected: diff --git a/xbmc/platform/android/filesystem/APKDirectory.cpp b/xbmc/platform/android/filesystem/APKDirectory.cpp index 3a2efe43e4..f01473f93a 100644 --- a/xbmc/platform/android/filesystem/APKDirectory.cpp +++ b/xbmc/platform/android/filesystem/APKDirectory.cpp @@ -27,7 +27,7 @@ bool CAPKDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // uses a <fully qualified path>/filename.apk/... std::string path = url.GetFileName(); - std::string host = url.GetHostName(); + const std::string& host = url.GetHostName(); URIUtils::AddSlashAtEnd(path); int zip_flags = 0, zip_error = 0; diff --git a/xbmc/platform/android/filesystem/APKFile.cpp b/xbmc/platform/android/filesystem/APKFile.cpp index 62e82d7841..bfeb1c401a 100644 --- a/xbmc/platform/android/filesystem/APKFile.cpp +++ b/xbmc/platform/android/filesystem/APKFile.cpp @@ -35,8 +35,8 @@ bool CAPKFile::Open(const CURL& url) Close(); m_url = url; - std::string path = url.GetFileName(); - std::string host = url.GetHostName(); + const std::string& path = url.GetFileName(); + const std::string& host = url.GetHostName(); int zip_flags = 0, zip_error = 0; m_zip_archive = zip_open(host.c_str(), zip_flags, &zip_error); @@ -193,7 +193,7 @@ int CAPKFile::Stat(const CURL& url, struct __stat64* buffer) // do not use internal member vars here, // we might be called without opening std::string path = url.GetFileName(); - std::string host = url.GetHostName(); + const std::string& host = url.GetHostName(); struct zip *zip_archive; int zip_flags = 0, zip_error = 0; diff --git a/xbmc/platform/android/network/NetworkAndroid.cpp b/xbmc/platform/android/network/NetworkAndroid.cpp index c6ccc364d2..9c0b06b0b6 100644 --- a/xbmc/platform/android/network/NetworkAndroid.cpp +++ b/xbmc/platform/android/network/NetworkAndroid.cpp @@ -25,10 +25,10 @@ #include <netinet/in.h> #include <sys/wait.h> -CNetworkInterfaceAndroid::CNetworkInterfaceAndroid(CJNINetwork network, CJNILinkProperties lp, CJNINetworkInterface intf) - : m_network(network) - , m_lp(lp) - , m_intf(intf) +CNetworkInterfaceAndroid::CNetworkInterfaceAndroid(const CJNINetwork& network, + const CJNILinkProperties& lp, + const CJNINetworkInterface& intf) + : m_network(network), m_lp(lp), m_intf(intf) { m_name = m_intf.getName(); } @@ -38,6 +38,7 @@ std::vector<std::string> CNetworkInterfaceAndroid::GetNameServers() std::vector<std::string> ret; CJNIList<CJNIInetAddress> lia = m_lp.getDnsServers(); + ret.reserve(lia.size()); for (int i=0; i < lia.size(); ++i) { ret.push_back(lia.get(i).getHostAddress()); @@ -317,7 +318,7 @@ void CNetworkAndroid::RetrieveInterfaces() CJNIConnectivityManager connman(CXBMCApp::getSystemService(CJNIContext::CONNECTIVITY_SERVICE)); std::vector<CJNINetwork> networks = connman.getAllNetworks(); - for (auto n : networks) + for (const auto& n : networks) { CJNILinkProperties lp = connman.getLinkProperties(n); if (lp) diff --git a/xbmc/platform/android/network/NetworkAndroid.h b/xbmc/platform/android/network/NetworkAndroid.h index 5a668490bf..9542b00225 100644 --- a/xbmc/platform/android/network/NetworkAndroid.h +++ b/xbmc/platform/android/network/NetworkAndroid.h @@ -22,7 +22,9 @@ class CNetworkAndroid; class CNetworkInterfaceAndroid : public CNetworkInterface { public: - CNetworkInterfaceAndroid(CJNINetwork network, CJNILinkProperties lp, CJNINetworkInterface intf); + CNetworkInterfaceAndroid(const CJNINetwork& network, + const CJNILinkProperties& lp, + const CJNINetworkInterface& intf); std::vector<std::string> GetNameServers(); // CNetworkInterface interface diff --git a/xbmc/platform/android/network/ZeroconfAndroid.cpp b/xbmc/platform/android/network/ZeroconfAndroid.cpp index fac2c08f5e..ee31fc1712 100644 --- a/xbmc/platform/android/network/ZeroconfAndroid.cpp +++ b/xbmc/platform/android/network/ZeroconfAndroid.cpp @@ -34,7 +34,7 @@ bool CZeroconfAndroid::doPublishService(const std::string& fcr_identifier, const newService.serviceInfo.setHost(CJNIInetAddress::getLocalHost()); newService.serviceInfo.setPort(f_port); - for (auto it : txt) + for (const auto& it : txt) { // CLog::Log(LOGDEBUG, "ZeroconfAndroid: key:%s, value:%s", it.first.c_str(),it.second.c_str()); newService.serviceInfo.setAttribute(it.first, it.second); @@ -92,7 +92,7 @@ void CZeroconfAndroid::doStop() { CSingleLock lock(m_data_guard); CLog::Log(LOGDEBUG, "ZeroconfAndroid: Shutdown services"); - for(auto it : m_services) + for (const auto& it : m_services) { m_manager.unregisterService(it.second.registrationListener); CLog::Log(LOGDEBUG, "CZeroconfAndroid: Removed service %s", it.first.c_str()); diff --git a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp index c7c486cd4f..94b3ace3c8 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp @@ -64,8 +64,8 @@ static void MapAxisIds(int axisId, int primaryAxisId, int secondaryAxisId, std:: axisIds.insert(axisIds.begin(), primaryAxisId); } -CAndroidJoystickState::CAndroidJoystickState(CAndroidJoystickState &&other) : - m_deviceId(other.m_deviceId), +CAndroidJoystickState::CAndroidJoystickState(CAndroidJoystickState&& other) noexcept + : m_deviceId(other.m_deviceId), m_buttons(std::move(other.m_buttons)), m_axes(std::move(other.m_axes)), m_analogState(std::move(other.m_analogState)), diff --git a/xbmc/platform/android/peripherals/AndroidJoystickState.h b/xbmc/platform/android/peripherals/AndroidJoystickState.h index 0219a1b998..42ebb83581 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickState.h +++ b/xbmc/platform/android/peripherals/AndroidJoystickState.h @@ -24,7 +24,7 @@ namespace PERIPHERALS { public: CAndroidJoystickState() = default; - CAndroidJoystickState(CAndroidJoystickState &&other); + CAndroidJoystickState(CAndroidJoystickState&& other) noexcept; virtual ~CAndroidJoystickState(); int GetDeviceId() const { return m_deviceId; } diff --git a/xbmc/platform/darwin/PlatformDarwin.cpp b/xbmc/platform/darwin/PlatformDarwin.cpp index 7c2b6042fc..239fbf4c8a 100644 --- a/xbmc/platform/darwin/PlatformDarwin.cpp +++ b/xbmc/platform/darwin/PlatformDarwin.cpp @@ -10,10 +10,15 @@ #include "filesystem/SpecialProtocol.h" -#include <stdlib.h> +#include <cstdlib> -void CPlatformDarwin::Init() +bool CPlatformDarwin::Init() { - CPlatformPosix::Init(); + if (!CPlatformPosix::Init()) + return false; setenv("SSL_CERT_FILE", CSpecialProtocol::TranslatePath("special://xbmc/system/certs/cacert.pem").c_str(), 0); -}
\ No newline at end of file + + setenv("OS", "OS X", true); // for python scripts that check the OS + + return true; +} diff --git a/xbmc/platform/darwin/PlatformDarwin.h b/xbmc/platform/darwin/PlatformDarwin.h index 7af51bf09c..6e7bbb7138 100644 --- a/xbmc/platform/darwin/PlatformDarwin.h +++ b/xbmc/platform/darwin/PlatformDarwin.h @@ -19,5 +19,5 @@ class CPlatformDarwin : public CPlatformPosix /**\brief D'tor */ ~CPlatformDarwin() override = default; - void Init() override; + bool Init() override; }; diff --git a/xbmc/platform/darwin/ios-common/AnnounceReceiver.mm b/xbmc/platform/darwin/ios-common/AnnounceReceiver.mm index 6931b93423..0211f1923b 100644 --- a/xbmc/platform/darwin/ios-common/AnnounceReceiver.mm +++ b/xbmc/platform/darwin/ios-common/AnnounceReceiver.mm @@ -85,7 +85,7 @@ void AnnounceBridge(ANNOUNCEMENT::AnnouncementFlag flag, int item_id = -1; std::string item_type = ""; CVariant nonConstData = data; - const std::string msg(message); + const std::string& msg(message); // handle data which only has a database id and not the metadata inside if (msg == "OnPlay" || msg == "OnResume") @@ -161,7 +161,7 @@ void AnnounceBridge(ANNOUNCEMENT::AnnouncementFlag flag, if (!genre.empty()) { NSMutableArray* genreArray = [[NSMutableArray alloc] initWithCapacity:genre.size()]; - for (auto genreItem : genre) + for (const auto& genreItem : genre) { [genreArray addObject:@(genreItem.c_str())]; } diff --git a/xbmc/platform/darwin/ios-common/network/NetworkIOS.mm b/xbmc/platform/darwin/ios-common/network/NetworkIOS.mm index 11b53cf6c1..55fbfdb351 100644 --- a/xbmc/platform/darwin/ios-common/network/NetworkIOS.mm +++ b/xbmc/platform/darwin/ios-common/network/NetworkIOS.mm @@ -14,6 +14,7 @@ #import "platform/darwin/ios-common/network/route.h" #import <array> +#include <utility> #import <arpa/inet.h> #import <ifaddrs.h> @@ -29,7 +30,7 @@ #import <sys/sysctl.h> CNetworkInterfaceIOS::CNetworkInterfaceIOS(CNetworkIOS* network, std::string interfaceName) - : m_interfaceName(interfaceName), m_network(network) + : m_interfaceName(std::move(interfaceName)), m_network(network) { } diff --git a/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.h b/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.h index b8f5bf2d5a..c0227f0bd7 100644 --- a/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.h +++ b/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.h @@ -36,10 +36,10 @@ public: bool PerformDeviceScan(PeripheralScanResults& results) override; PeripheralScanResults GetInputDevices(); - void callOnDeviceAdded(const std::string strLocation); - void callOnDeviceRemoved(const std::string strLocation); + void callOnDeviceAdded(const std::string& strLocation); + void callOnDeviceRemoved(const std::string& strLocation); - void SetScanResults(const PeripheralScanResults resScanResults); + void SetScanResults(const PeripheralScanResults& resScanResults); const std::string& getDeviceLocationPrefix() { diff --git a/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.mm b/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.mm index 94410fb85f..abdd4dac93 100644 --- a/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.mm +++ b/xbmc/platform/darwin/ios-common/peripherals/PeripheralBusDarwinEmbedded.mm @@ -121,7 +121,7 @@ bool PERIPHERALS::CPeripheralBusDarwinEmbedded::PerformDeviceScan(PeripheralScan } void PERIPHERALS::CPeripheralBusDarwinEmbedded::SetScanResults( - const PERIPHERALS::PeripheralScanResults resScanResults) + const PERIPHERALS::PeripheralScanResults& resScanResults) { CSingleLock lock(m_critSectionResults); m_scanResults = resScanResults; @@ -214,12 +214,12 @@ PERIPHERALS::PeripheralScanResults PERIPHERALS::CPeripheralBusDarwinEmbedded::Ge return [m_peripheralDarwinEmbedded->callbackClass GetInputDevices]; } -void PERIPHERALS::CPeripheralBusDarwinEmbedded::callOnDeviceAdded(const std::string strLocation) +void PERIPHERALS::CPeripheralBusDarwinEmbedded::callOnDeviceAdded(const std::string& strLocation) { OnDeviceAdded(strLocation); } -void PERIPHERALS::CPeripheralBusDarwinEmbedded::callOnDeviceRemoved(const std::string strLocation) +void PERIPHERALS::CPeripheralBusDarwinEmbedded::callOnDeviceRemoved(const std::string& strLocation) { OnDeviceRemoved(strLocation); } diff --git a/xbmc/platform/darwin/ios/XBMCController.mm b/xbmc/platform/darwin/ios/XBMCController.mm index 27d9d8d54d..0501ab8639 100644 --- a/xbmc/platform/darwin/ios/XBMCController.mm +++ b/xbmc/platform/darwin/ios/XBMCController.mm @@ -73,7 +73,7 @@ public: CServiceBroker::GetSettingsComponent()->GetSettings()->UnregisterCallback(this); } - void OnSettingAction(std::shared_ptr<const CSetting> setting) override + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override { if (!setting || setting->GetId() != CSettings::SETTING_DEBUG_SHARE_LOG) return; diff --git a/xbmc/platform/darwin/osx/XBMCHelper.cpp b/xbmc/platform/darwin/osx/XBMCHelper.cpp index 8cfb0b6a13..96c395510d 100644 --- a/xbmc/platform/darwin/osx/XBMCHelper.cpp +++ b/xbmc/platform/darwin/osx/XBMCHelper.cpp @@ -80,7 +80,7 @@ XBMCHelper::XBMCHelper() } ///////////////////////////////////////////////////////////////////////////// -bool XBMCHelper::OnSettingChanging(std::shared_ptr<const CSetting> setting) +bool XBMCHelper::OnSettingChanging(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return false; diff --git a/xbmc/platform/darwin/osx/XBMCHelper.h b/xbmc/platform/darwin/osx/XBMCHelper.h index 3444075ec3..502d5de772 100644 --- a/xbmc/platform/darwin/osx/XBMCHelper.h +++ b/xbmc/platform/darwin/osx/XBMCHelper.h @@ -25,7 +25,7 @@ class XBMCHelper : public ISettingCallback public: static XBMCHelper& GetInstance(); - bool OnSettingChanging(std::shared_ptr<const CSetting> setting) override; + bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) override; void Start(); void Stop(); diff --git a/xbmc/platform/darwin/tvos/TVOSSettingsHandler.h b/xbmc/platform/darwin/tvos/TVOSSettingsHandler.h index e066cf3e62..04d0f8cd6a 100644 --- a/xbmc/platform/darwin/tvos/TVOSSettingsHandler.h +++ b/xbmc/platform/darwin/tvos/TVOSSettingsHandler.h @@ -17,7 +17,7 @@ public: void Initialize(); - virtual void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + virtual void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; private: CTVOSInputSettings() = default; diff --git a/xbmc/platform/darwin/tvos/TVOSSettingsHandler.mm b/xbmc/platform/darwin/tvos/TVOSSettingsHandler.mm index 4e977a88dd..9c90b7cb38 100644 --- a/xbmc/platform/darwin/tvos/TVOSSettingsHandler.mm +++ b/xbmc/platform/darwin/tvos/TVOSSettingsHandler.mm @@ -45,7 +45,7 @@ void CTVOSInputSettings::Initialize() [g_xbmcController.inputHandler.inputSettings setRemoteIdleTimeout:timeout]; } -void CTVOSInputSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CTVOSInputSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/platform/darwin/tvos/TVOSTopShelf.mm b/xbmc/platform/darwin/tvos/TVOSTopShelf.mm index 71ac4518f5..0344eea9eb 100644 --- a/xbmc/platform/darwin/tvos/TVOSTopShelf.mm +++ b/xbmc/platform/darwin/tvos/TVOSTopShelf.mm @@ -85,9 +85,8 @@ void CTVOSTopShelf::SetTopShelfItems(CFileItemList& items, TVOSTopShelfItemsCate CVideoThumbLoader thumbLoader; auto fillSharedDicts = [&](CFileItemList& items, NSString* categoryKey, NSString* categoryTitle, - std::function<std::string(CFileItemPtr videoItem)> getThumbnailForItem, - std::function<std::string(CFileItemPtr videoItem)> getTitleForItem) { - + const std::function<std::string(CFileItemPtr videoItem)>& getThumbnailForItem, + const std::function<std::string(CFileItemPtr videoItem)>& getTitleForItem) { // Store all old thumbs names of this category in array const auto thumbsPath = [storeUrl URLByAppendingPathComponent:categoryKey isDirectory:YES]; auto thumbsToRemove = [NSMutableSet setWithArray:[fileManager contentsOfDirectoryAtPath:thumbsPath.path error:nil]]; @@ -161,25 +160,25 @@ void CTVOSTopShelf::SetTopShelfItems(CFileItemList& items, TVOSTopShelfItemsCate case TVOSTopShelfItemsCategory::MOVIES: fillSharedDicts( items, @"movies", @(g_localizeStrings.Get(20386).c_str()), - [](CFileItemPtr videoItem) { + [](const CFileItemPtr& videoItem) { if (videoItem->HasArt("poster")) return videoItem->GetArt("poster"); else return videoItem->GetArt("thumb"); }, - [](CFileItemPtr videoItem) { return videoItem->GetLabel(); }); + [](const CFileItemPtr& videoItem) { return videoItem->GetLabel(); }); break; case TVOSTopShelfItemsCategory::TV_SHOWS: CVideoDatabase videoDb; videoDb.Open(); fillSharedDicts( items, @"tvshows", @(g_localizeStrings.Get(20387).c_str()), - [&videoDb](CFileItemPtr videoItem) { + [&videoDb](const CFileItemPtr& videoItem) { int season = videoItem->GetVideoInfoTag()->m_iIdSeason; return season > 0 ? videoDb.GetArtForItem(season, MediaTypeSeason, "poster") : std::string{}; }, - [](CFileItemPtr videoItem) { + [](const CFileItemPtr& videoItem) { return StringUtils::Format("%s s%02de%02d", videoItem->GetVideoInfoTag()->m_strShowTitle.c_str(), videoItem->GetVideoInfoTag()->m_iSeason, diff --git a/xbmc/platform/linux/input/CMakeLists.txt b/xbmc/platform/linux/input/CMakeLists.txt index 8e69fda1aa..ebb2ccd585 100644 --- a/xbmc/platform/linux/input/CMakeLists.txt +++ b/xbmc/platform/linux/input/CMakeLists.txt @@ -6,7 +6,7 @@ if(LIRCCLIENT_FOUND) list(APPEND HEADERS LIRC.h) endif() -if(CORE_PLATFORM_NAME_LC STREQUAL gbm) +if("gbm" IN_LIST CORE_PLATFORM_NAME_LC) if(LIBINPUT_FOUND) list(APPEND SOURCES LibInputHandler.cpp LibInputKeyboard.cpp diff --git a/xbmc/platform/linux/input/LibInputKeyboard.cpp b/xbmc/platform/linux/input/LibInputKeyboard.cpp index 6a3abfc84e..0681cfc2e9 100644 --- a/xbmc/platform/linux/input/LibInputKeyboard.cpp +++ b/xbmc/platform/linux/input/LibInputKeyboard.cpp @@ -26,8 +26,10 @@ #include <xkbcommon/xkbcommon-keysyms.h> #include <xkbcommon/xkbcommon-names.h> -const int REPEAT_DELAY = 400; -const int REPEAT_RATE = 80; +namespace +{ +constexpr int REPEAT_DELAY = 400; +constexpr int REPEAT_RATE = 80; static const std::map<xkb_keysym_t, XBMCKey> xkbMap = { @@ -146,6 +148,7 @@ static const std::map<xkb_keysym_t, XBMCKey> xkbMap = { XKB_KEY_XF86AudioRandomPlay, XBMCK_SHUFFLE } // XBMCK_FASTFORWARD clashes with XBMCK_MEDIA_FASTFORWARD }; +} // namespace CLibInputKeyboard::CLibInputKeyboard() : m_repeatTimer(std::bind(&CLibInputKeyboard::KeyRepeatTimeout, this)) @@ -350,7 +353,7 @@ void CLibInputKeyboard::UpdateLeds(libinput_device *dev) void CLibInputKeyboard::GetRepeat(libinput_device *dev) { - int kbdrep[2] = { 400, 80 }; + int kbdrep[2] = {REPEAT_DELAY, REPEAT_RATE}; const char *name = libinput_device_get_name(dev); const char *sysname = libinput_device_get_sysname(dev); std::string path("/dev/input/"); diff --git a/xbmc/platform/linux/input/LibInputSettings.cpp b/xbmc/platform/linux/input/LibInputSettings.cpp index 804f13de79..76facff5f9 100644 --- a/xbmc/platform/linux/input/LibInputSettings.cpp +++ b/xbmc/platform/linux/input/LibInputSettings.cpp @@ -39,6 +39,7 @@ CLibInputSettings::CLibInputSettings(CLibInputHandler *handler) : const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); settings->GetSettingsManager()->RegisterCallback(this, settingSet); settings->GetSettingsManager()->RegisterSettingOptionsFiller("libinputkeyboardlayout", SettingOptionsKeyboardLayoutsFiller); + settings->GetSetting(SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT)->SetVisible(true); /* load the keyboard layouts from xkeyboard-config */ std::string xkbFile("/usr/share/X11/xkb/rules/base.xml"); @@ -120,12 +121,16 @@ CLibInputSettings::~CLibInputSettings() settings->GetSettingsManager()->UnregisterCallback(this); } -void CLibInputSettings::SettingOptionsKeyboardLayoutsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CLibInputSettings::SettingOptionsKeyboardLayoutsFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { list = layouts; } -void CLibInputSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CLibInputSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/platform/linux/input/LibInputSettings.h b/xbmc/platform/linux/input/LibInputSettings.h index 8509b390c7..83d5edff55 100644 --- a/xbmc/platform/linux/input/LibInputSettings.h +++ b/xbmc/platform/linux/input/LibInputSettings.h @@ -21,8 +21,11 @@ class CLibInputSettings : public ISettingCallback, public ISettingsHandler public: static const std::string SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - static void SettingOptionsKeyboardLayoutsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + static void SettingOptionsKeyboardLayoutsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); CLibInputSettings(CLibInputHandler *handler); ~CLibInputSettings() override; diff --git a/xbmc/platform/linux/network/NetworkLinux.cpp b/xbmc/platform/linux/network/NetworkLinux.cpp index 8da24ddcc8..d4f1a26962 100644 --- a/xbmc/platform/linux/network/NetworkLinux.cpp +++ b/xbmc/platform/linux/network/NetworkLinux.cpp @@ -12,6 +12,7 @@ #include "utils/log.h" #include <errno.h> +#include <utility> #include <arpa/inet.h> #include <net/if.h> @@ -22,7 +23,7 @@ CNetworkInterfaceLinux::CNetworkInterfaceLinux(CNetworkPosix* network, std::string interfaceName, char interfaceMacAddrRaw[6]) - : CNetworkInterfacePosix(network, interfaceName, interfaceMacAddrRaw) + : CNetworkInterfacePosix(network, std::move(interfaceName), interfaceMacAddrRaw) { } diff --git a/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.cpp b/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.cpp index 91872552d1..c0e2ec70c7 100644 --- a/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.cpp +++ b/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.cpp @@ -132,7 +132,7 @@ bool CZeroconfAvahi::doPublishService(const std::string& fcr_identifier, //txt records to AvahiStringList AvahiStringList *txtList = NULL; - for (const auto it : txt) + for (const auto& it : txt) { txtList = avahi_string_list_add_pair(txtList, it.first.c_str(), it.second.c_str()); } @@ -377,7 +377,8 @@ void CZeroconfAvahi::updateServices(AvahiClient* fp_client) } } -void CZeroconfAvahi::addService(tServiceMap::mapped_type fp_service_info, AvahiClient* fp_client) +void CZeroconfAvahi::addService(const tServiceMap::mapped_type& fp_service_info, + AvahiClient* fp_client) { assert(fp_client); CLog::Log(LOGDEBUG, "CZeroconfAvahi::addService() named: %s type: %s port:%i", fp_service_info->m_name.c_str(), fp_service_info->m_type.c_str(), fp_service_info->m_port); diff --git a/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.h b/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.h index b1d534d737..102df9b1e7 100644 --- a/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.h +++ b/xbmc/platform/linux/network/zeroconf/ZeroconfAvahi.h @@ -65,7 +65,7 @@ private: // from the callbacks) void updateServices(AvahiClient* fp_client); //helper that actually does the work of publishing - void addService(tServiceMap::mapped_type fp_service_info, AvahiClient* fp_client); + void addService(const tServiceMap::mapped_type& fp_service_info, AvahiClient* fp_client); AvahiClient* mp_client = 0; AvahiThreadedPoll* mp_poll = 0; diff --git a/xbmc/platform/linux/storage/UDisks2Provider.cpp b/xbmc/platform/linux/storage/UDisks2Provider.cpp index eefc8ad808..885b6f2867 100644 --- a/xbmc/platform/linux/storage/UDisks2Provider.cpp +++ b/xbmc/platform/linux/storage/UDisks2Provider.cpp @@ -42,10 +42,8 @@ CUDisks2Provider::Drive::Drive(const char *object) : m_object(object) bool CUDisks2Provider::Drive::IsOptical() { - return std::any_of(m_mediaCompatibility.begin(), m_mediaCompatibility.end(), [](std::string kind) - { - return kind.compare(0, 7, "optical") == 0; - }); + return std::any_of(m_mediaCompatibility.begin(), m_mediaCompatibility.end(), + [](const std::string& kind) { return kind.compare(0, 7, "optical") == 0; }); } std::string CUDisks2Provider::Drive::toString() diff --git a/xbmc/platform/overrides/android/PlatformAndroid.cpp b/xbmc/platform/overrides/android/PlatformAndroid.cpp index 52f145b7c6..f27e3db141 100644 --- a/xbmc/platform/overrides/android/PlatformAndroid.cpp +++ b/xbmc/platform/overrides/android/PlatformAndroid.cpp @@ -9,6 +9,9 @@ #include "PlatformAndroid.h" #include "filesystem/SpecialProtocol.h" +#include "windowing/android/WinSystemAndroidGLESContext.h" + +#include "platform/android/powermanagement/AndroidPowerSyscall.h" #include <stdlib.h> @@ -17,8 +20,17 @@ CPlatform* CPlatform::CreateInstance() return new CPlatformAndroid(); } -void CPlatformAndroid::Init() +bool CPlatformAndroid::Init() { - CPlatformPosix::Init(); + if (!CPlatformPosix::Init()) + return false; setenv("SSL_CERT_FILE", CSpecialProtocol::TranslatePath("special://xbmc/system/certs/cacert.pem").c_str(), 1); + + setenv("OS", "Linux", true); // for python scripts that check the OS + + CWinSystemAndroidGLESContext::Register(); + + CAndroidPowerSyscall::Register(); + + return true; } diff --git a/xbmc/platform/overrides/android/PlatformAndroid.h b/xbmc/platform/overrides/android/PlatformAndroid.h index f3860929ab..c88c5411ce 100644 --- a/xbmc/platform/overrides/android/PlatformAndroid.h +++ b/xbmc/platform/overrides/android/PlatformAndroid.h @@ -19,5 +19,5 @@ class CPlatformAndroid : public CPlatformPosix /**\brief D'tor */ ~CPlatformAndroid() override = default; - void Init() override; + bool Init() override; }; diff --git a/xbmc/platform/overrides/darwin_embedded/PlatformDarwinEmbedded.cpp b/xbmc/platform/overrides/darwin_embedded/PlatformDarwinEmbedded.cpp index 1fb3f50895..09fe5dd899 100644 --- a/xbmc/platform/overrides/darwin_embedded/PlatformDarwinEmbedded.cpp +++ b/xbmc/platform/overrides/darwin_embedded/PlatformDarwinEmbedded.cpp @@ -6,13 +6,39 @@ * See LICENSES/README.md for more information. */ -#include "filesystem/SpecialProtocol.h" +#include "PlatformDarwinEmbedded.h" -#include "platform/darwin/PlatformDarwin.h" +#include "Util.h" -#include <stdlib.h> +// clang-format off +#if defined(TARGET_DARWIN_IOS) +#include "windowing/ios/WinSystemIOS.h" +#endif +#if defined(TARGET_DARWIN_TVOS) +#include "platform/darwin/tvos/powermanagement/TVOSPowerSyscall.h" +#include "windowing/tvos/WinSystemTVOS.h" +#endif +// clang-format on CPlatform* CPlatform::CreateInstance() { - return new CPlatformDarwin(); + return new CPlatformDarwinEmbedded(); +} + +bool CPlatformDarwinEmbedded::Init() +{ + if (!CPlatformDarwin::Init()) + return false; + +#if defined(TARGET_DARWIN_IOS) + CUtil::CopyUserDataIfNeeded("special://masterprofile/", "iOS/sources.xml", "sources.xml"); + CWinSystemIOS::Register(); +#endif +#if defined(TARGET_DARWIN_TVOS) + CWinSystemTVOS::Register(); + + CTVOSPowerSyscall::Register(); +#endif + + return true; } diff --git a/xbmc/platform/overrides/darwin_embedded/PlatformDarwinEmbedded.h b/xbmc/platform/overrides/darwin_embedded/PlatformDarwinEmbedded.h new file mode 100644 index 0000000000..665dd61b7e --- /dev/null +++ b/xbmc/platform/overrides/darwin_embedded/PlatformDarwinEmbedded.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "platform/darwin/PlatformDarwin.h" + +class CPlatformDarwinEmbedded : public CPlatformDarwin +{ +public: + CPlatformDarwinEmbedded() = default; + + ~CPlatformDarwinEmbedded() override = default; + + bool Init() override; +}; diff --git a/xbmc/platform/overrides/freebsd/PlatformFreebsd.cpp b/xbmc/platform/overrides/freebsd/PlatformFreebsd.cpp new file mode 100644 index 0000000000..e56e54f817 --- /dev/null +++ b/xbmc/platform/overrides/freebsd/PlatformFreebsd.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "PlatformFreebsd.h" + +#include "platform/linux/powermanagement/LinuxPowerSyscall.h" + +// clang-format off +#if defined(HAS_GLES) +#if defined(HAVE_WAYLAND) +#include "windowing/wayland/WinSystemWaylandEGLContextGLES.h" +#endif +#if defined(HAVE_X11) +#include "windowing/X11/WinSystemX11GLESContext.h" +#endif +#if defined(HAVE_GBM) +#include "windowing/gbm/WinSystemGbmGLESContext.h" +#endif +#endif + +#if defined(HAS_GL) +#if defined(HAVE_WAYLAND) +#include "windowing/wayland/WinSystemWaylandEGLContextGL.h" +#endif +#if defined(HAVE_X11) +#include "windowing/X11/WinSystemX11GLContext.h" +#endif +#if defined(HAVE_GBM) +#include "windowing/gbm/WinSystemGbmGLContext.h" +#endif +#endif +// clang-format on + +#include <cstdlib> + +CPlatform* CPlatform::CreateInstance() +{ + return new CPlatformFreebsd(); +} + +bool CPlatformFreebsd::Init() +{ + if (!CPlatformPosix::Init()) + return false; + + setenv("OS", "Linux", true); // for python scripts that check the OS + +#if defined(HAS_GLES) +#if defined(HAVE_WAYLAND) + KODI::WINDOWING::WAYLAND::CWinSystemWaylandEGLContextGLES::Register(); +#endif +#if defined(HAVE_X11) + KODI::WINDOWING::X11::CWinSystemX11GLESContext::Register(); +#endif +#if defined(HAVE_GBM) + KODI::WINDOWING::GBM::CWinSystemGbmGLESContext::Register(); +#endif +#endif + +#if defined(HAS_GL) +#if defined(HAVE_WAYLAND) + KODI::WINDOWING::WAYLAND::CWinSystemWaylandEGLContextGL::Register(); +#endif +#if defined(HAVE_X11) + KODI::WINDOWING::X11::CWinSystemX11GLContext::Register(); +#endif +#if defined(HAVE_GBM) + KODI::WINDOWING::GBM::CWinSystemGbmGLContext::Register(); +#endif +#endif + + CLinuxPowerSyscall::Register(); + + return true; +} diff --git a/xbmc/platform/overrides/freebsd/PlatformFreebsd.h b/xbmc/platform/overrides/freebsd/PlatformFreebsd.h new file mode 100644 index 0000000000..c98be81999 --- /dev/null +++ b/xbmc/platform/overrides/freebsd/PlatformFreebsd.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "platform/posix/PlatformPosix.h" + +class CPlatformFreebsd : public CPlatformPosix +{ +public: + CPlatformFreebsd() = default; + ~CPlatformFreebsd() override = default; + + bool Init() override; +}; diff --git a/xbmc/platform/overrides/linux/PlatformLinux.cpp b/xbmc/platform/overrides/linux/PlatformLinux.cpp new file mode 100644 index 0000000000..8f34287b10 --- /dev/null +++ b/xbmc/platform/overrides/linux/PlatformLinux.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "PlatformLinux.h" + +#include "platform/linux/powermanagement/LinuxPowerSyscall.h" + +// clang-format off +#if defined(HAS_GLES) +#if defined(HAVE_WAYLAND) +#include "windowing/wayland/WinSystemWaylandEGLContextGLES.h" +#endif +#if defined(HAVE_X11) +#include "windowing/X11/WinSystemX11GLESContext.h" +#endif +#if defined(HAVE_GBM) +#include "windowing/gbm/WinSystemGbmGLESContext.h" +#endif +#endif + +#if defined(HAS_GL) +#if defined(HAVE_WAYLAND) +#include "windowing/wayland/WinSystemWaylandEGLContextGL.h" +#endif +#if defined(HAVE_X11) +#include "windowing/X11/WinSystemX11GLContext.h" +#endif +#if defined(HAVE_GBM) +#include "windowing/gbm/WinSystemGbmGLContext.h" +#endif +#endif +// clang-format on + +#include <cstdlib> + +CPlatform* CPlatform::CreateInstance() +{ + return new CPlatformLinux(); +} + +bool CPlatformLinux::Init() +{ + if (!CPlatformPosix::Init()) + return false; + + setenv("OS", "Linux", true); // for python scripts that check the OS + +#if defined(HAS_GLES) +#if defined(HAVE_WAYLAND) + KODI::WINDOWING::WAYLAND::CWinSystemWaylandEGLContextGLES::Register(); +#endif +#if defined(HAVE_X11) + KODI::WINDOWING::X11::CWinSystemX11GLESContext::Register(); +#endif +#if defined(HAVE_GBM) + KODI::WINDOWING::GBM::CWinSystemGbmGLESContext::Register(); +#endif +#endif + +#if defined(HAS_GL) +#if defined(HAVE_WAYLAND) + KODI::WINDOWING::WAYLAND::CWinSystemWaylandEGLContextGL::Register(); +#endif +#if defined(HAVE_X11) + KODI::WINDOWING::X11::CWinSystemX11GLContext::Register(); +#endif +#if defined(HAVE_GBM) + KODI::WINDOWING::GBM::CWinSystemGbmGLContext::Register(); +#endif +#endif + + CLinuxPowerSyscall::Register(); + + return true; +} diff --git a/xbmc/platform/overrides/linux/PlatformLinux.h b/xbmc/platform/overrides/linux/PlatformLinux.h new file mode 100644 index 0000000000..1f9af158cc --- /dev/null +++ b/xbmc/platform/overrides/linux/PlatformLinux.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "platform/posix/PlatformPosix.h" + +class CPlatformLinux : public CPlatformPosix +{ +public: + CPlatformLinux() = default; + + ~CPlatformLinux() override = default; + + bool Init() override; +}; diff --git a/xbmc/platform/overrides/osx/PlatformDarwinOSX.cpp b/xbmc/platform/overrides/osx/PlatformDarwinOSX.cpp index 1fb3f50895..076d4939bd 100644 --- a/xbmc/platform/overrides/osx/PlatformDarwinOSX.cpp +++ b/xbmc/platform/overrides/osx/PlatformDarwinOSX.cpp @@ -6,13 +6,29 @@ * See LICENSES/README.md for more information. */ -#include "filesystem/SpecialProtocol.h" +#include "PlatformDarwinOSX.h" -#include "platform/darwin/PlatformDarwin.h" +#include "windowing/osx/WinSystemOSXGL.h" -#include <stdlib.h> +#include "platform/darwin/osx/XBMCHelper.h" +#include "platform/darwin/osx/powermanagement/CocoaPowerSyscall.h" CPlatform* CPlatform::CreateInstance() { - return new CPlatformDarwin(); + return new CPlatformDarwinOSX(); +} + +bool CPlatformDarwinOSX::Init() +{ + if (!CPlatformDarwin::Init()) + return false; + + // Configure and possible manually start the helper. + XBMCHelper::GetInstance().Configure(); + + CWinSystemOSXGL::Register(); + + CCocoaPowerSyscall::Register(); + + return true; } diff --git a/xbmc/platform/overrides/osx/PlatformDarwinOSX.h b/xbmc/platform/overrides/osx/PlatformDarwinOSX.h new file mode 100644 index 0000000000..ca2c331c97 --- /dev/null +++ b/xbmc/platform/overrides/osx/PlatformDarwinOSX.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "platform/darwin/PlatformDarwin.h" + +class CPlatformDarwinOSX : public CPlatformDarwin +{ +public: + CPlatformDarwinOSX() = default; + + ~CPlatformDarwinOSX() override = default; + + bool Init() override; +}; diff --git a/xbmc/platform/overrides/windows/PlatformWin32.cpp b/xbmc/platform/overrides/windows/PlatformWin32.cpp new file mode 100644 index 0000000000..6cdaab3dce --- /dev/null +++ b/xbmc/platform/overrides/windows/PlatformWin32.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "PlatformWin32.h" + +#include "platform/Environment.h" +#include "win32util.h" +#include "windowing/windows/WinSystemWin32DX.h" + +#include "platform/win32/powermanagement/Win32PowerSyscall.h" + +CPlatform* CPlatform::CreateInstance() +{ + return new CPlatformWin32(); +} + +bool CPlatformWin32::Init() +{ + if (!CPlatform::Init()) + return false; + + CEnvironment::setenv("OS", "win32"); // for python scripts that check the OS + + // enable independent locale for each thread, see https://connect.microsoft.com/VisualStudio/feedback/details/794122 + CWIN32Util::SetThreadLocalLocale(true); + + CWinSystemWin32DX::Register(); + + CWin32PowerSyscall::Register(); + + return true; +} diff --git a/xbmc/platform/overrides/windows/PlatformWin32.h b/xbmc/platform/overrides/windows/PlatformWin32.h new file mode 100644 index 0000000000..c2685c187f --- /dev/null +++ b/xbmc/platform/overrides/windows/PlatformWin32.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "platform/Platform.h" + +class CPlatformWin32 : public CPlatform +{ +public: + CPlatformWin32() = default; + + ~CPlatformWin32() override = default; + + bool Init() override; +}; diff --git a/xbmc/platform/overrides/windowsstore/PlatformWin10.cpp b/xbmc/platform/overrides/windowsstore/PlatformWin10.cpp index 7c72a835b3..0d0aa73862 100644 --- a/xbmc/platform/overrides/windowsstore/PlatformWin10.cpp +++ b/xbmc/platform/overrides/windowsstore/PlatformWin10.cpp @@ -10,6 +10,10 @@ #include "filesystem/SpecialProtocol.h" #include "platform/Environment.h" +#include "win32util.h" +#include "windowing/win10/WinSystemWin10DX.h" + +#include "platform/win10/powermanagement/Win10PowerSyscall.h" #include <stdlib.h> @@ -18,11 +22,21 @@ CPlatform* CPlatform::CreateInstance() return new CPlatformWin10(); } -CPlatformWin10::CPlatformWin10() = default; - -CPlatformWin10::~CPlatformWin10() = default; - -void CPlatformWin10::Init() +bool CPlatformWin10::Init() { + if (!CPlatform::Init()) + return false; + CEnvironment::setenv("SSL_CERT_FILE", CSpecialProtocol::TranslatePath("special://xbmc/system/certs/cacert.pem").c_str(), 1); + + CEnvironment::setenv("OS", "win32"); // for python scripts that check the OS + + // enable independent locale for each thread, see https://connect.microsoft.com/VisualStudio/feedback/details/794122 + CWIN32Util::SetThreadLocalLocale(true); + + CWinSystemWin10DX::Register(); + + CPowerSyscall::Register(); + + return true; } diff --git a/xbmc/platform/overrides/windowsstore/PlatformWin10.h b/xbmc/platform/overrides/windowsstore/PlatformWin10.h index c42143d6d7..62abfda4ba 100644 --- a/xbmc/platform/overrides/windowsstore/PlatformWin10.h +++ b/xbmc/platform/overrides/windowsstore/PlatformWin10.h @@ -14,10 +14,10 @@ class CPlatformWin10 : public CPlatform { public: /**\brief C'tor */ - CPlatformWin10(); + CPlatformWin10() = default; /**\brief D'tor */ - virtual ~CPlatformWin10(); + ~CPlatformWin10() override = default; - void Init() override; + bool Init() override; }; diff --git a/xbmc/platform/posix/Filesystem.cpp b/xbmc/platform/posix/Filesystem.cpp index 71baf5b5aa..477e7b660f 100644 --- a/xbmc/platform/posix/Filesystem.cpp +++ b/xbmc/platform/posix/Filesystem.cpp @@ -90,7 +90,7 @@ std::string create_temp_directory(std::error_code &ec) return std::string(tmp); } -std::string temp_file_path(std::string suffix, std::error_code &ec) +std::string temp_file_path(const std::string& suffix, std::error_code& ec) { char tmp[PATH_MAX]; diff --git a/xbmc/platform/posix/PlatformPosix.cpp b/xbmc/platform/posix/PlatformPosix.cpp index 0a061a8498..eb7f938343 100644 --- a/xbmc/platform/posix/PlatformPosix.cpp +++ b/xbmc/platform/posix/PlatformPosix.cpp @@ -8,14 +8,37 @@ #include "PlatformPosix.h" +#include "filesystem/SpecialProtocol.h" + +#include <cstdlib> +#include <time.h> + std::atomic_flag CPlatformPosix::ms_signalFlag; -void CPlatformPosix::Init() +bool CPlatformPosix::Init() { - CPlatform::Init(); + + if (!CPlatform::Init()) + return false; // Initialize to "set" state ms_signalFlag.test_and_set(); + + // Initialize timezone information variables + tzset(); + + // set special://envhome + if (getenv("HOME")) + { + CSpecialProtocol::SetEnvHomePath(getenv("HOME")); + } + else + { + fprintf(stderr, "The HOME environment variable is not set!\n"); + return false; + } + + return true; } bool CPlatformPosix::TestQuitFlag() diff --git a/xbmc/platform/posix/PlatformPosix.h b/xbmc/platform/posix/PlatformPosix.h index f4c9071bf3..7b64abe09f 100644 --- a/xbmc/platform/posix/PlatformPosix.h +++ b/xbmc/platform/posix/PlatformPosix.h @@ -15,7 +15,7 @@ class CPlatformPosix : public CPlatform { public: - void Init() override; + bool Init() override; static bool TestQuitFlag(); static void RequestQuit(); diff --git a/xbmc/platform/posix/PosixTimezone.cpp b/xbmc/platform/posix/PosixTimezone.cpp index e9aaa84356..10450bfd34 100644 --- a/xbmc/platform/posix/PosixTimezone.cpp +++ b/xbmc/platform/posix/PosixTimezone.cpp @@ -135,7 +135,7 @@ CPosixTimezone::CPosixTimezone() free(line); } -void CPosixTimezone::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CPosixTimezone::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -180,7 +180,7 @@ std::string CPosixTimezone::GetCountryByTimezone(const std::string& timezone) #endif } -void CPosixTimezone::SetTimezone(std::string timezoneName) +void CPosixTimezone::SetTimezone(const std::string& timezoneName) { #if !defined(TARGET_DARWIN) bool use_timezone = true; @@ -234,14 +234,21 @@ std::string CPosixTimezone::GetOSConfiguredTimezone() return timezoneName; } -void CPosixTimezone::SettingOptionsTimezoneCountriesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CPosixTimezone::SettingOptionsTimezoneCountriesFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { std::vector<std::string> countries = g_timezone.GetCounties(); for (unsigned int i = 0; i < countries.size(); i++) list.emplace_back(countries[i], countries[i]); } -void CPosixTimezone::SettingOptionsTimezonesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CPosixTimezone::SettingOptionsTimezonesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { current = std::static_pointer_cast<const CSettingString>(setting)->GetValue(); bool found = false; diff --git a/xbmc/platform/posix/PosixTimezone.h b/xbmc/platform/posix/PosixTimezone.h index 8272c4082d..076e87fa51 100644 --- a/xbmc/platform/posix/PosixTimezone.h +++ b/xbmc/platform/posix/PosixTimezone.h @@ -23,7 +23,7 @@ class CPosixTimezone : public ISettingCallback, public ISettingsHandler public: CPosixTimezone(); - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; void OnSettingsLoaded() override; @@ -33,11 +33,17 @@ public: std::vector<std::string> GetTimezonesByCountry(const std::string& country); std::string GetCountryByTimezone(const std::string& timezone); - void SetTimezone(std::string timezone); + void SetTimezone(const std::string& timezone); int m_IsDST = 0; - static void SettingOptionsTimezoneCountriesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsTimezonesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); + static void SettingOptionsTimezoneCountriesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsTimezonesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); private: std::vector<std::string> m_counties; diff --git a/xbmc/platform/posix/filesystem/PosixDirectory.cpp b/xbmc/platform/posix/filesystem/PosixDirectory.cpp index c5e350201c..6685c0e1db 100644 --- a/xbmc/platform/posix/filesystem/PosixDirectory.cpp +++ b/xbmc/platform/posix/filesystem/PosixDirectory.cpp @@ -102,7 +102,7 @@ bool CPosixDirectory::Create(const CURL& url) return true; } -bool CPosixDirectory::Create(std::string path) +bool CPosixDirectory::Create(const std::string& path) { if (mkdir(path.c_str(), 0755) != 0) { diff --git a/xbmc/platform/posix/filesystem/PosixDirectory.h b/xbmc/platform/posix/filesystem/PosixDirectory.h index 146f0031e6..eb323b68e9 100644 --- a/xbmc/platform/posix/filesystem/PosixDirectory.h +++ b/xbmc/platform/posix/filesystem/PosixDirectory.h @@ -24,6 +24,6 @@ public: bool Remove(const CURL& url) override; bool RemoveRecursive(const CURL& url) override; private: - bool Create(std::string path); + bool Create(const std::string& path); }; } diff --git a/xbmc/platform/posix/network/NetworkPosix.cpp b/xbmc/platform/posix/network/NetworkPosix.cpp index 403be71a82..f09302d728 100644 --- a/xbmc/platform/posix/network/NetworkPosix.cpp +++ b/xbmc/platform/posix/network/NetworkPosix.cpp @@ -11,6 +11,8 @@ #include "utils/StringUtils.h" #include "utils/log.h" +#include <utility> + #include <arpa/inet.h> #include <net/if.h> #include <netinet/in.h> @@ -20,7 +22,7 @@ CNetworkInterfacePosix::CNetworkInterfacePosix(CNetworkPosix* network, std::string interfaceName, char interfaceMacAddrRaw[6]) - : m_interfaceName(interfaceName), + : m_interfaceName(std::move(interfaceName)), m_interfaceMacAdr(StringUtils::Format("%02X:%02X:%02X:%02X:%02X:%02X", (uint8_t)interfaceMacAddrRaw[0], (uint8_t)interfaceMacAddrRaw[1], diff --git a/xbmc/platform/win32/Filesystem.cpp b/xbmc/platform/win32/Filesystem.cpp index 5de937f850..df3f579f62 100644 --- a/xbmc/platform/win32/Filesystem.cpp +++ b/xbmc/platform/win32/Filesystem.cpp @@ -89,7 +89,7 @@ std::string create_temp_directory(std::error_code &ec) return win::FromW(lpTempPathBuffer); } -std::string temp_file_path(std::string, std::error_code &ec) +std::string temp_file_path(const std::string&, std::error_code& ec) { wchar_t lpTempPathBuffer[MAX_PATH + 1]; diff --git a/xbmc/playlists/PlayListB4S.cpp b/xbmc/playlists/PlayListB4S.cpp index 1c84d9ecfc..7df5d668fc 100644 --- a/xbmc/playlists/PlayListB4S.cpp +++ b/xbmc/playlists/PlayListB4S.cpp @@ -69,7 +69,7 @@ bool CPlayListB4S::LoadData(std::istream& stream) while (pEntryElement) { std::string strFileName = XMLUtils::GetAttribute(pEntryElement, "Playstring"); - size_t iColon = strFileName.find(":"); + size_t iColon = strFileName.find(':'); if (iColon != std::string::npos) { iColon++; diff --git a/xbmc/playlists/PlayListM3U.cpp b/xbmc/playlists/PlayListM3U.cpp index 265476308f..16bd67cd08 100644 --- a/xbmc/playlists/PlayListM3U.cpp +++ b/xbmc/playlists/PlayListM3U.cpp @@ -88,8 +88,8 @@ bool CPlayListM3U::Load(const std::string& strFileName) if (StringUtils::StartsWith(strLine, InfoMarker)) { // start of info - size_t iColon = strLine.find(":"); - size_t iComma = strLine.find(","); + size_t iColon = strLine.find(':'); + size_t iComma = strLine.find(','); if (iColon != std::string::npos && iComma != std::string::npos && iComma > iColon) @@ -105,8 +105,8 @@ bool CPlayListM3U::Load(const std::string& strFileName) } else if (StringUtils::StartsWith(strLine, OffsetMarker)) { - size_t iColon = strLine.find(":"); - size_t iComma = strLine.find(","); + size_t iColon = strLine.find(':'); + size_t iComma = strLine.find(','); if (iColon != std::string::npos && iComma != std::string::npos && iComma > iColon) @@ -121,8 +121,8 @@ bool CPlayListM3U::Load(const std::string& strFileName) else if (StringUtils::StartsWith(strLine, PropertyMarker) || StringUtils::StartsWith(strLine, VLCOptMarker)) { - size_t iColon = strLine.find(":"); - size_t iEqualSign = strLine.find("="); + size_t iColon = strLine.find(':'); + size_t iEqualSign = strLine.find('='); if (iColon != std::string::npos && iEqualSign != std::string::npos && iEqualSign > iColon) diff --git a/xbmc/playlists/PlayListPLS.cpp b/xbmc/playlists/PlayListPLS.cpp index 27d461e9e9..6d67fc88c9 100644 --- a/xbmc/playlists/PlayListPLS.cpp +++ b/xbmc/playlists/PlayListPLS.cpp @@ -105,7 +105,7 @@ bool CPlayListPLS::Load(const std::string &strFile) { strLine = szLine; StringUtils::RemoveCRLF(strLine); - size_t iPosEqual = strLine.find("="); + size_t iPosEqual = strLine.find('='); if (iPosEqual != std::string::npos) { std::string strLeft = strLine.substr(0, iPosEqual); diff --git a/xbmc/playlists/PlayListXSPF.cpp b/xbmc/playlists/PlayListXSPF.cpp index 06b496ae14..bc84ed7c81 100644 --- a/xbmc/playlists/PlayListXSPF.cpp +++ b/xbmc/playlists/PlayListXSPF.cpp @@ -103,12 +103,12 @@ bool CPlayListXSPF::Load(const std::string& strFileName) if (!localpath.empty()) { + // We don't use URIUtils::CanonicalizePath because m_strBasePath may be a + // protocol e.g. smb #ifdef TARGET_WINDOWS StringUtils::Replace(localpath, "/", "\\"); - localpath = URIUtils::CanonicalizePath(localpath, '\\'); -#else - localpath = URIUtils::CanonicalizePath(localpath, '/'); #endif + localpath = URIUtils::GetRealPath(localpath); newItem->SetPath(localpath); } diff --git a/xbmc/powermanagement/PowerManager.cpp b/xbmc/powermanagement/PowerManager.cpp index ac19c48539..a2714feabb 100644 --- a/xbmc/powermanagement/PowerManager.cpp +++ b/xbmc/powermanagement/PowerManager.cpp @@ -262,7 +262,10 @@ void CPowerManager::RestorePlayerState() g_application.PlayFile(*m_lastPlayedFileItem, m_lastUsedPlayer); } -void CPowerManager::SettingOptionsShutdownStatesFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CPowerManager::SettingOptionsShutdownStatesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { if (CServiceBroker::GetPowerManager().CanPowerdown()) list.emplace_back(g_localizeStrings.Get(13005), POWERSTATE_SHUTDOWN); diff --git a/xbmc/powermanagement/PowerManager.h b/xbmc/powermanagement/PowerManager.h index 7d35abea35..5e9bc9c745 100644 --- a/xbmc/powermanagement/PowerManager.h +++ b/xbmc/powermanagement/PowerManager.h @@ -46,7 +46,10 @@ public: void ProcessEvents(); - static void SettingOptionsShutdownStatesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); + static void SettingOptionsShutdownStatesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); IPowerSyscall* GetPowerSyscall() const { return m_instance.get(); }; diff --git a/xbmc/profiles/ProfileManager.cpp b/xbmc/profiles/ProfileManager.cpp index 14fbc37663..26c5529eff 100644 --- a/xbmc/profiles/ProfileManager.cpp +++ b/xbmc/profiles/ProfileManager.cpp @@ -471,7 +471,7 @@ bool CProfileManager::DeleteProfile(unsigned int index) if (dlgYesNo == NULL) return false; - std::string str = g_localizeStrings.Get(13201); + const std::string& str = g_localizeStrings.Get(13201); dlgYesNo->SetHeading(CVariant{13200}); dlgYesNo->SetLine(0, CVariant{StringUtils::Format(str.c_str(), profile->getName().c_str())}); dlgYesNo->SetLine(1, CVariant{""}); @@ -716,7 +716,7 @@ CEventLog& CProfileManager::GetEventLog() return m_eventLogs->GetEventLog(GetCurrentProfileId()); } -void CProfileManager::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CProfileManager::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/profiles/ProfileManager.h b/xbmc/profiles/ProfileManager.h index 14850d1091..e39451893f 100644 --- a/xbmc/profiles/ProfileManager.h +++ b/xbmc/profiles/ProfileManager.h @@ -191,7 +191,7 @@ public: protected: // implementation of ISettingCallback - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; private: /*! \brief Set the current profile id and update the special://profile path diff --git a/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp b/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp index 8a8497fea0..31a7077890 100644 --- a/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp +++ b/xbmc/profiles/dialogs/GUIDialogLockSettings.cpp @@ -99,7 +99,7 @@ bool CGUIDialogLockSettings::ShowAndGetUserAndPassword(std::string &user, std::s return true; } -void CGUIDialogLockSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogLockSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -131,7 +131,7 @@ void CGUIDialogLockSettings::OnSettingChanged(std::shared_ptr<const CSetting> se m_changed = true; } -void CGUIDialogLockSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogLockSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/profiles/dialogs/GUIDialogLockSettings.h b/xbmc/profiles/dialogs/GUIDialogLockSettings.h index 39c3a13198..4ad482a6bd 100644 --- a/xbmc/profiles/dialogs/GUIDialogLockSettings.h +++ b/xbmc/profiles/dialogs/GUIDialogLockSettings.h @@ -23,8 +23,8 @@ public: protected: // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } diff --git a/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp b/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp index d3d0eb5dc3..d7ce0dabdf 100644 --- a/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp +++ b/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp @@ -194,7 +194,7 @@ void CGUIDialogProfileSettings::OnWindowLoaded() CGUIDialogSettingsManualBase::OnWindowLoaded(); } -void CGUIDialogProfileSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogProfileSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -214,7 +214,7 @@ void CGUIDialogProfileSettings::OnSettingChanged(std::shared_ptr<const CSetting> m_needsSaving = true; } -void CGUIDialogProfileSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogProfileSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/profiles/dialogs/GUIDialogProfileSettings.h b/xbmc/profiles/dialogs/GUIDialogProfileSettings.h index dff49cf438..a17ccaa844 100644 --- a/xbmc/profiles/dialogs/GUIDialogProfileSettings.h +++ b/xbmc/profiles/dialogs/GUIDialogProfileSettings.h @@ -26,8 +26,8 @@ protected: void OnWindowLoaded() override; // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } diff --git a/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp b/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp index ea90b575f8..cc111a0da3 100644 --- a/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp +++ b/xbmc/profiles/windows/GUIWindowSettingsProfile.cpp @@ -245,7 +245,7 @@ bool CGUIWindowSettingsProfile::GetAutoLoginProfileChoice(int &iProfile) for (unsigned int i = 0; i < profileManager->GetNumberOfProfiles(); i++) { const CProfile *profile = profileManager->GetProfile(i); - std::string locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165); + const std::string& locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165); CFileItemPtr item(new CFileItem(profile->getName())); item->SetLabel2(locked); // lock setting std::string thumb = profile->getThumb(); diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index a60049786a..0a684faf2b 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -716,14 +716,14 @@ bool CPVRManager::IsCurrentlyParentalLocked(const std::shared_ptr<CPVRChannel>& return bReturn; } -void CPVRManager::OnPlaybackStarted(const CFileItemPtr item) +void CPVRManager::OnPlaybackStarted(const CFileItemPtr& item) { m_playbackState->OnPlaybackStarted(item); m_guiActions->OnPlaybackStarted(item); m_epgContainer.OnPlaybackStarted(); } -void CPVRManager::OnPlaybackStopped(const CFileItemPtr item) +void CPVRManager::OnPlaybackStopped(const CFileItemPtr& item) { // Playback ended due to user interaction if (m_playbackState->OnPlaybackStopped(item)) @@ -733,7 +733,7 @@ void CPVRManager::OnPlaybackStopped(const CFileItemPtr item) m_epgContainer.OnPlaybackStopped(); } -void CPVRManager::OnPlaybackEnded(const CFileItemPtr item) +void CPVRManager::OnPlaybackEnded(const CFileItemPtr& item) { // Playback ended, but not due to user interaction OnPlaybackStopped(item); diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 7356c4cdf3..6fd6494acc 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -244,19 +244,19 @@ namespace PVR * @brief Inform PVR manager that playback of an item just started. * @param item The item that started to play. */ - void OnPlaybackStarted(const std::shared_ptr<CFileItem> item); + void OnPlaybackStarted(const std::shared_ptr<CFileItem>& item); /*! * @brief Inform PVR manager that playback of an item was stopped due to user interaction. * @param item The item that stopped to play. */ - void OnPlaybackStopped(const std::shared_ptr<CFileItem> item); + void OnPlaybackStopped(const std::shared_ptr<CFileItem>& item); /*! * @brief Inform PVR manager that playback of an item has stopped without user interaction. * @param item The item that ended to play. */ - void OnPlaybackEnded(const std::shared_ptr<CFileItem> item); + void OnPlaybackEnded(const std::shared_ptr<CFileItem>& item); /*! * @brief Let the background thread create epg tags for all channels. diff --git a/xbmc/pvr/PVRPlaybackState.cpp b/xbmc/pvr/PVRPlaybackState.cpp index 1acb09bd18..1ecd90e1e1 100644 --- a/xbmc/pvr/PVRPlaybackState.cpp +++ b/xbmc/pvr/PVRPlaybackState.cpp @@ -72,7 +72,7 @@ void CPVRPlaybackState::Clear() m_lastWatchedUpdateTimer.reset(); } -void CPVRPlaybackState::OnPlaybackStarted(const std::shared_ptr<CFileItem> item) +void CPVRPlaybackState::OnPlaybackStarted(const std::shared_ptr<CFileItem>& item) { CSingleLock lock(m_critSection); @@ -128,7 +128,7 @@ void CPVRPlaybackState::OnPlaybackStarted(const std::shared_ptr<CFileItem> item) } } -bool CPVRPlaybackState::OnPlaybackStopped(const std::shared_ptr<CFileItem> item) +bool CPVRPlaybackState::OnPlaybackStopped(const std::shared_ptr<CFileItem>& item) { // Playback ended due to user interaction @@ -183,7 +183,7 @@ bool CPVRPlaybackState::OnPlaybackStopped(const std::shared_ptr<CFileItem> item) return bChanged; } -void CPVRPlaybackState::OnPlaybackEnded(const std::shared_ptr<CFileItem> item) +void CPVRPlaybackState::OnPlaybackEnded(const std::shared_ptr<CFileItem>& item) { // Playback ended, but not due to user interaction OnPlaybackStopped(item); diff --git a/xbmc/pvr/PVRPlaybackState.h b/xbmc/pvr/PVRPlaybackState.h index eebc49db5f..b315b47c45 100644 --- a/xbmc/pvr/PVRPlaybackState.h +++ b/xbmc/pvr/PVRPlaybackState.h @@ -45,20 +45,20 @@ public: * @brief Inform that playback of an item just started. * @param item The item that started to play. */ - void OnPlaybackStarted(const std::shared_ptr<CFileItem> item); + void OnPlaybackStarted(const std::shared_ptr<CFileItem>& item); /*! * @brief Inform that playback of an item was stopped due to user interaction. * @param item The item that stopped to play. * @return True, if the state has changed, false otherwise */ - bool OnPlaybackStopped(const std::shared_ptr<CFileItem> item); + bool OnPlaybackStopped(const std::shared_ptr<CFileItem>& item); /*! * @brief Inform that playback of an item has stopped without user interaction. * @param item The item that ended to play. */ - void OnPlaybackEnded(const std::shared_ptr<CFileItem> item); + void OnPlaybackEnded(const std::shared_ptr<CFileItem>& item); /*! * @brief Check if a TV channel, radio channel or recording is playing. diff --git a/xbmc/pvr/PVRThumbLoader.cpp b/xbmc/pvr/PVRThumbLoader.cpp index ad5d8147c3..ddb2010c32 100644 --- a/xbmc/pvr/PVRThumbLoader.cpp +++ b/xbmc/pvr/PVRThumbLoader.cpp @@ -116,9 +116,9 @@ std::string CPVRThumbLoader::CreateChannelGroupThumb(const CFileItem& channelGro break; } - const std::string thumb = StringUtils::Format("%s?ts=%d", // append timestamp to Thumb URL to enforce texture refresh - CTextureUtils::GetWrappedImageURL(channelGroupItem.GetPath(), "pvr"), - std::time(nullptr)); + std::string thumb = StringUtils::Format( + "%s?ts=%d", // append timestamp to Thumb URL to enforce texture refresh + CTextureUtils::GetWrappedImageURL(channelGroupItem.GetPath(), "pvr"), std::time(nullptr)); const std::string relativeCacheFile = CTextureCache::GetCacheFile(thumb) + ".png"; if (CPicture::CreateTiledThumb(channelIcons, CTextureCache::GetCachedPath(relativeCacheFile))) { diff --git a/xbmc/pvr/addons/PVRClient.cpp b/xbmc/pvr/addons/PVRClient.cpp index 34a486d8b2..226df1955b 100644 --- a/xbmc/pvr/addons/PVRClient.cpp +++ b/xbmc/pvr/addons/PVRClient.cpp @@ -11,7 +11,6 @@ #include "ServiceBroker.h" #include "addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h" // added for compile test on related sources only! #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h" -#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" #include "dialogs/GUIDialogKaiToast.h" #include "events/EventLog.h" #include "events/NotificationEvent.h" @@ -702,7 +701,7 @@ class CAddonEpgTag : public EPG_TAG { public: CAddonEpgTag() = delete; - explicit CAddonEpgTag(const std::shared_ptr<const CPVREpgInfoTag> kodiTag) + explicit CAddonEpgTag(const std::shared_ptr<const CPVREpgInfoTag>& kodiTag) : m_strTitle(kodiTag->Title()), m_strPlotOutline(kodiTag->PlotOutline()), m_strPlot(kodiTag->Plot()), @@ -1315,7 +1314,7 @@ PVR_ERROR CPVRClient::DemuxRead(DemuxPacket*& packet) return DoAddonCall( __func__, [&packet](const AddonInstance* addon) { - packet = addon->toAddon->DemuxRead(addon); + packet = static_cast<DemuxPacket*>(addon->toAddon->DemuxRead(addon)); return packet ? PVR_ERROR_NO_ERROR : PVR_ERROR_NOT_IMPLEMENTED; }, m_clientCapabilities.HandlesDemuxing()); @@ -1350,7 +1349,7 @@ const char* CPVRClient::ToString(const PVR_ERROR error) } PVR_ERROR CPVRClient::DoAddonCall(const char* strFunctionName, - std::function<PVR_ERROR(const AddonInstance*)> function, + const std::function<PVR_ERROR(const AddonInstance*)>& function, bool bIsImplemented /* = true */, bool bCheckReadyToUse /* = true */) const { @@ -1872,12 +1871,12 @@ void CPVRClient::cb_trigger_epg_update(void* kodiInstance, unsigned int iChannel CServiceBroker::GetPVRManager().EpgContainer().UpdateRequest(client->GetID(), iChannelUid); } -void CPVRClient::cb_free_demux_packet(void* kodiInstance, DemuxPacket* pPacket) +void CPVRClient::cb_free_demux_packet(void* kodiInstance, DEMUX_PACKET* pPacket) { - CDVDDemuxUtils::FreeDemuxPacket(pPacket); + CDVDDemuxUtils::FreeDemuxPacket(static_cast<DemuxPacket*>(pPacket)); } -DemuxPacket* CPVRClient::cb_allocate_demux_packet(void* kodiInstance, int iDataSize) +DEMUX_PACKET* CPVRClient::cb_allocate_demux_packet(void* kodiInstance, int iDataSize) { return CDVDDemuxUtils::AllocateDemuxPacket(iDataSize); } diff --git a/xbmc/pvr/addons/PVRClient.h b/xbmc/pvr/addons/PVRClient.h index f466d769ca..f85af4d0fc 100644 --- a/xbmc/pvr/addons/PVRClient.h +++ b/xbmc/pvr/addons/PVRClient.h @@ -18,6 +18,8 @@ #include <utility> #include <vector> +struct DemuxPacket; + namespace PVR { class CPVRChannel; @@ -1054,7 +1056,7 @@ private: */ typedef AddonInstance_PVR AddonInstance; PVR_ERROR DoAddonCall(const char* strFunctionName, - std::function<PVR_ERROR(const AddonInstance*)> function, + const std::function<PVR_ERROR(const AddonInstance*)>& function, bool bIsImplemented = true, bool bCheckReadyToUse = true) const; @@ -1178,7 +1180,7 @@ private: * @param kodiInstance Pointer to Kodi's CPVRClient class * @param pPacket The packet to free. */ - static void cb_free_demux_packet(void* kodiInstance, DemuxPacket* pPacket); + static void cb_free_demux_packet(void* kodiInstance, DEMUX_PACKET* pPacket); /*! * @brief Allocate a demux packet. Free with FreeDemuxPacket @@ -1186,7 +1188,7 @@ private: * @param iDataSize The size of the data that will go into the packet * @return The allocated packet. */ - static DemuxPacket* cb_allocate_demux_packet(void* kodiInstance, int iDataSize = 0); + static DEMUX_PACKET* cb_allocate_demux_packet(void* kodiInstance, int iDataSize = 0); /*! * @brief Notify a state change for a PVR backend connection diff --git a/xbmc/pvr/addons/PVRClientMenuHooks.cpp b/xbmc/pvr/addons/PVRClientMenuHooks.cpp index 6c257cccff..b1297d5a19 100644 --- a/xbmc/pvr/addons/PVRClientMenuHooks.cpp +++ b/xbmc/pvr/addons/PVRClientMenuHooks.cpp @@ -113,7 +113,8 @@ void CPVRClientMenuHooks::Clear() m_hooks.reset(); } -std::vector<CPVRClientMenuHook> CPVRClientMenuHooks::GetHooks(std::function<bool(const CPVRClientMenuHook& hook)> function) const +std::vector<CPVRClientMenuHook> CPVRClientMenuHooks::GetHooks( + const std::function<bool(const CPVRClientMenuHook& hook)>& function) const { std::vector<CPVRClientMenuHook> hooks; diff --git a/xbmc/pvr/addons/PVRClientMenuHooks.h b/xbmc/pvr/addons/PVRClientMenuHooks.h index a2b1c65913..1a0522d85a 100644 --- a/xbmc/pvr/addons/PVRClientMenuHooks.h +++ b/xbmc/pvr/addons/PVRClientMenuHooks.h @@ -63,7 +63,8 @@ namespace PVR std::vector<CPVRClientMenuHook> GetSettingsHooks() const; private: - std::vector<CPVRClientMenuHook> GetHooks(std::function<bool(const CPVRClientMenuHook& hook)> function) const; + std::vector<CPVRClientMenuHook> GetHooks( + const std::function<bool(const CPVRClientMenuHook& hook)>& function) const; std::string m_addonId; std::unique_ptr<std::vector<CPVRClientMenuHook>> m_hooks; diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index 732f7cdd26..ebebe76b03 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -417,6 +417,44 @@ int CPVRClients::EnabledClientAmount() const return iReturn; } +std::vector<CVariant> CPVRClients::GetEnabledClientInfos() const +{ + std::vector<CVariant> clientInfos; + + CPVRClientMap clientMap; + { + CSingleLock lock(m_critSection); + clientMap = m_clientMap; + } + + for (const auto& client : clientMap) + { + const auto& addonInfo = CServiceBroker::GetAddonMgr().GetAddonInfo(client.second->ID()); + + if (addonInfo) + { + // This will be the same variant structure used in the json api + CVariant clientInfo(CVariant::VariantTypeObject); + clientInfo["clientid"] = client.first; + clientInfo["addonid"] = client.second->ID(); + clientInfo["label"] = addonInfo->Name(); // Note that this is called label instead of name + + const auto& capabilities = client.second->GetClientCapabilities(); + clientInfo["supportstv"] = capabilities.SupportsTV(); + clientInfo["supportsradio"] = capabilities.SupportsRadio(); + clientInfo["supportsepg"] = capabilities.SupportsEPG(); + clientInfo["supportsrecordings"] = capabilities.SupportsRecordings(); + clientInfo["supportstimers"] = capabilities.SupportsTimers(); + clientInfo["supportschannelgroups"] = capabilities.SupportsChannelGroups(); + clientInfo["supportschannelscan"] = capabilities.SupportsChannelScan(); + + clientInfos.push_back(clientInfo); + } + } + + return clientInfos; +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // client API calls //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -678,13 +716,16 @@ void CPVRClients::ConnectionStateChange(CPVRClient* client, } } -PVR_ERROR CPVRClients::ForCreatedClients(const char* strFunctionName, PVRClientFunction function) const +PVR_ERROR CPVRClients::ForCreatedClients(const char* strFunctionName, + const PVRClientFunction& function) const { std::vector<int> failedClients; return ForCreatedClients(strFunctionName, function, failedClients); } -PVR_ERROR CPVRClients::ForCreatedClients(const char* strFunctionName, PVRClientFunction function, std::vector<int>& failedClients) const +PVR_ERROR CPVRClients::ForCreatedClients(const char* strFunctionName, + const PVRClientFunction& function, + std::vector<int>& failedClients) const { PVR_ERROR lastError = PVR_ERROR_NO_ERROR; diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h index 62380bfc5e..e7b7c0b338 100644 --- a/xbmc/pvr/addons/PVRClients.h +++ b/xbmc/pvr/addons/PVRClients.h @@ -154,6 +154,12 @@ namespace PVR */ int EnabledClientAmount() const; + /*! + * @brief Get a list of the enabled client infos. + * @return A list of enabled client infos. + */ + std::vector<CVariant> GetEnabledClientInfos() const; + //@} /*! @name general methods */ @@ -354,7 +360,8 @@ namespace PVR * @param function The function to wrap. It has to have return type PVR_ERROR and must take a const reference to a std::shared_ptr<CPVRClient> as parameter. * @return PVR_ERROR_NO_ERROR on success, any other PVR_ERROR_* value otherwise. */ - PVR_ERROR ForCreatedClients(const char* strFunctionName, PVRClientFunction function) const; + PVR_ERROR ForCreatedClients(const char* strFunctionName, + const PVRClientFunction& function) const; /*! * @brief Wraps calls to all created clients in order to do common pre and post function invocation actions. @@ -363,7 +370,9 @@ namespace PVR * @param failedClients Contains a list of the ids of clients for that the call failed, if any. * @return PVR_ERROR_NO_ERROR on success, any other PVR_ERROR_* value otherwise. */ - PVR_ERROR ForCreatedClients(const char* strFunctionName, PVRClientFunction function, std::vector<int>& failedClients) const; + PVR_ERROR ForCreatedClients(const char* strFunctionName, + const PVRClientFunction& function, + std::vector<int>& failedClients) const; mutable CCriticalSection m_critSection; CPVRClientMap m_clientMap; diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 658f9334e4..5187b1647d 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -96,6 +96,7 @@ void CPVRChannel::Serialize(CVariant& value) const value["isrecording"] = false; // compat value["hasarchive"] = m_bHasArchive; + value["clientid"] = m_iClientId; } /********** XBMC related channel methods **********/ diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index adf5fa74c9..d6c1f24dfe 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -879,7 +879,7 @@ bool CPVRChannelGroup::HasChanges() const return m_bChanged || HasNewChannels() || HasChangedChannels(); } -void CPVRChannelGroup::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CPVRChannelGroup::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index 985391085b..2977a921f4 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -37,12 +37,18 @@ namespace PVR { PVRChannelGroupMember() = default; - PVRChannelGroupMember(const std::shared_ptr<CPVRChannel> _channel, const CPVRChannelNumber& _channelNumber, int _iClientPriority, int _iOrder, const CPVRChannelNumber& _clientChannelNumber) - : channel(_channel) - , channelNumber(_channelNumber) - , clientChannelNumber(_clientChannelNumber) - , iClientPriority(_iClientPriority) - , iOrder(_iOrder) {} + PVRChannelGroupMember(const std::shared_ptr<CPVRChannel>& _channel, + const CPVRChannelNumber& _channelNumber, + int _iClientPriority, + int _iOrder, + const CPVRChannelNumber& _clientChannelNumber) + : channel(_channel), + channelNumber(_channelNumber), + clientChannelNumber(_clientChannelNumber), + iClientPriority(_iClientPriority), + iOrder(_iOrder) + { + } std::shared_ptr<CPVRChannel> channel; CPVRChannelNumber channelNumber; // the channel number this channel has in the group @@ -292,7 +298,7 @@ namespace PVR //@} - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; /*! * @brief Get a channel given it's EPG ID. diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 663ba0d4a6..96e065d9dd 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -58,7 +58,7 @@ void CPVRChannelGroupInternal::CheckGroupName() CSingleLock lock(m_critSection); /* check whether the group name is still correct, or channels will fail to load after the language setting changed */ - const std::string strNewGroupName = g_localizeStrings.Get(19287); + const std::string& strNewGroupName = g_localizeStrings.Get(19287); if (GroupName() != strNewGroupName) { SetGroupName(strNewGroupName); diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp index 419ee0b592..66a6394c7b 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.cpp +++ b/xbmc/pvr/channels/PVRChannelGroups.cpp @@ -156,7 +156,7 @@ std::vector<std::shared_ptr<CPVRChannelGroup>> CPVRChannelGroups::GetGroupsByCha std::vector<std::shared_ptr<CPVRChannelGroup>> groups; CSingleLock lock(m_critSection); - for (std::shared_ptr<CPVRChannelGroup> group : m_groups) + for (const std::shared_ptr<CPVRChannelGroup>& group : m_groups) { if ((!bExcludeHidden || !group->IsHidden()) && group->IsGroupMember(channel)) groups.push_back(group); @@ -433,7 +433,7 @@ std::vector<std::shared_ptr<CPVRChannelGroup>> CPVRChannelGroups::GetMembers(boo std::vector<std::shared_ptr<CPVRChannelGroup>> groups; CSingleLock lock(m_critSection); - for (std::shared_ptr<CPVRChannelGroup> group : m_groups) + for (const std::shared_ptr<CPVRChannelGroup>& group : m_groups) { if (!bExcludeHidden || !group->IsHidden()) groups.push_back(group); diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp index b10b6a6d66..ea8aee1f71 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp @@ -144,8 +144,8 @@ std::shared_ptr<CPVRChannel> CPVRChannelGroupsContainer::GetByUniqueID(int iUniq std::shared_ptr<CPVRChannel> CPVRChannelGroupsContainer::GetLastPlayedChannel() const { - const std::shared_ptr<CPVRChannel> channelTV = m_groupsTV->GetGroupAll()->GetLastPlayedChannel(); - const std::shared_ptr<CPVRChannel> channelRadio = m_groupsRadio->GetGroupAll()->GetLastPlayedChannel(); + std::shared_ptr<CPVRChannel> channelTV = m_groupsTV->GetGroupAll()->GetLastPlayedChannel(); + std::shared_ptr<CPVRChannel> channelRadio = m_groupsRadio->GetGroupAll()->GetLastPlayedChannel(); if (!channelTV || (channelRadio && channelRadio->LastWatched() > channelTV->LastWatched())) diff --git a/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp b/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp index 3a4ed11e33..5e9ac641d9 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp @@ -37,7 +37,8 @@ void CGUIDialogPVRClientPriorities::SetupView() SET_CONTROL_LABEL(CONTROL_SETTINGS_CANCEL_BUTTON, 222); // Cancel } -std::string CGUIDialogPVRClientPriorities::GetSettingsLabel(std::shared_ptr<ISetting> pSetting) +std::string CGUIDialogPVRClientPriorities::GetSettingsLabel( + const std::shared_ptr<ISetting>& pSetting) { int iClientId = std::atoi(pSetting->GetId().c_str()); auto clientEntry = m_clients.find(iClientId); @@ -75,7 +76,7 @@ void CGUIDialogPVRClientPriorities::InitializeSettings() } } -void CGUIDialogPVRClientPriorities::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogPVRClientPriorities::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) { diff --git a/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.h b/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.h index 5218b00070..6cd9ce2c3d 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.h @@ -23,10 +23,10 @@ namespace PVR protected: // implementation of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase - std::string GetSettingsLabel(std::shared_ptr<ISetting> pSetting) override; + std::string GetSettingsLabel(const std::shared_ptr<ISetting>& pSetting) override; bool AllowResettingSettings() const override { return false; } void Save() override; void SetupView() override; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.cpp index 100e8392e1..d08999cce4 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.cpp @@ -115,7 +115,8 @@ bool CGUIDialogPVRRecordingSettings::CanEditRecording(const CFileItem& item) capabilities.SupportsRecordingsLifetimeChange(); } -bool CGUIDialogPVRRecordingSettings::OnSettingChanging(std::shared_ptr<const CSetting> setting) +bool CGUIDialogPVRRecordingSettings::OnSettingChanging( + const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) { @@ -140,7 +141,8 @@ bool CGUIDialogPVRRecordingSettings::OnSettingChanging(std::shared_ptr<const CSe return CGUIDialogSettingsManualBase::OnSettingChanging(setting); } -void CGUIDialogPVRRecordingSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogPVRRecordingSettings::OnSettingChanged( + const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) { @@ -178,8 +180,10 @@ void CGUIDialogPVRRecordingSettings::Save() m_recording->m_iLifetime = m_iLifetime; } -void CGUIDialogPVRRecordingSettings::LifetimesFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRRecordingSettings::LifetimesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRRecordingSettings* pThis = static_cast<CGUIDialogPVRRecordingSettings*>(data); if (pThis) diff --git a/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.h b/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.h index 7508de7c02..f5dd9566ce 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRRecordingSettings.h @@ -33,8 +33,8 @@ namespace PVR protected: // implementation of ISettingCallback - bool OnSettingChanging(std::shared_ptr<const CSetting> setting) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } @@ -45,9 +45,10 @@ namespace PVR void InitializeSettings() override; private: - static void LifetimesFiller(std::shared_ptr<const CSetting> setting, + static void LifetimesFiller(const std::shared_ptr<const CSetting>& setting, std::vector<IntegerSettingOption>& list, - int& current, void* data); + int& current, + void* data); std::shared_ptr<CPVRRecording> m_recording; std::string m_strTitle; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index b533160be0..0c9cbec447 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -353,7 +353,7 @@ void CGUIDialogPVRTimerSettings::InitializeSettings() AddTypeDependentEnableCondition(setting, SETTING_TMR_REC_GROUP); } -int CGUIDialogPVRTimerSettings::GetWeekdaysFromSetting(SettingConstPtr setting) +int CGUIDialogPVRTimerSettings::GetWeekdaysFromSetting(const SettingConstPtr& setting) { std::shared_ptr<const CSettingList> settingList = std::static_pointer_cast<const CSettingList>(setting); if (settingList->GetElementType() != SettingType::Integer) @@ -376,7 +376,7 @@ int CGUIDialogPVRTimerSettings::GetWeekdaysFromSetting(SettingConstPtr setting) return weekdays; } -void CGUIDialogPVRTimerSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogPVRTimerSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) { @@ -491,7 +491,7 @@ void CGUIDialogPVRTimerSettings::OnSettingChanged(std::shared_ptr<const CSetting } } -void CGUIDialogPVRTimerSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogPVRTimerSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) { @@ -657,9 +657,11 @@ void CGUIDialogPVRTimerSettings::SetButtonLabels() } } -void CGUIDialogPVRTimerSettings::AddCondition( - std::shared_ptr<CSetting> setting, const std::string& identifier, SettingConditionCheck condition, - SettingDependencyType depType, const std::string& settingId) +void CGUIDialogPVRTimerSettings::AddCondition(const std::shared_ptr<CSetting>& setting, + const std::string& identifier, + SettingConditionCheck condition, + SettingDependencyType depType, + const std::string& settingId) { GetSettingsManager()->AddDynamicCondition(identifier, condition, this); CSettingDependency dep(depType, GetSettingsManager()); @@ -795,8 +797,10 @@ void CGUIDialogPVRTimerSettings::InitializeChannelsList() } } -void CGUIDialogPVRTimerSettings::TypesFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::TypesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -824,8 +828,10 @@ void CGUIDialogPVRTimerSettings::TypesFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::ChannelsFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::ChannelsFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -859,8 +865,10 @@ void CGUIDialogPVRTimerSettings::ChannelsFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::DaysFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::DaysFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -903,8 +911,10 @@ void CGUIDialogPVRTimerSettings::DaysFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::DupEpisodesFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::DupEpisodesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -922,8 +932,10 @@ void CGUIDialogPVRTimerSettings::DupEpisodesFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::WeekdaysFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::WeekdaysFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -943,8 +955,10 @@ void CGUIDialogPVRTimerSettings::WeekdaysFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::PrioritiesFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::PrioritiesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -977,8 +991,10 @@ void CGUIDialogPVRTimerSettings::PrioritiesFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::LifetimesFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::LifetimesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -1011,8 +1027,10 @@ void CGUIDialogPVRTimerSettings::LifetimesFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::MaxRecordingsFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::MaxRecordingsFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -1045,8 +1063,10 @@ void CGUIDialogPVRTimerSettings::MaxRecordingsFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::RecordingGroupFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::RecordingGroupFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -1064,8 +1084,10 @@ void CGUIDialogPVRTimerSettings::RecordingGroupFiller( CLog::LogF(LOGERROR, "No dialog"); } -void CGUIDialogPVRTimerSettings::MarginTimeFiller( - SettingConstPtr setting, std::vector<IntegerSettingOption>& list, int& current, void* data) +void CGUIDialogPVRTimerSettings::MarginTimeFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIDialogPVRTimerSettings* pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); if (pThis) @@ -1106,12 +1128,13 @@ void CGUIDialogPVRTimerSettings::MarginTimeFiller( CLog::LogF(LOGERROR, "No dialog"); } -std::string CGUIDialogPVRTimerSettings::WeekdaysValueFormatter(SettingConstPtr setting) +std::string CGUIDialogPVRTimerSettings::WeekdaysValueFormatter(const SettingConstPtr& setting) { return CPVRTimerInfoTag::GetWeekdaysString(GetWeekdaysFromSetting(setting), true, true); } -void CGUIDialogPVRTimerSettings::AddTypeDependentEnableCondition(std::shared_ptr<CSetting> setting, const std::string& identifier) +void CGUIDialogPVRTimerSettings::AddTypeDependentEnableCondition( + const std::shared_ptr<CSetting>& setting, const std::string& identifier) { // Enable setting depending on read-only attribute of the selected timer type std::string id(identifier); @@ -1119,7 +1142,10 @@ void CGUIDialogPVRTimerSettings::AddTypeDependentEnableCondition(std::shared_ptr AddCondition(setting, id, TypeReadOnlyCondition, SettingDependencyType::Enable, SETTING_TMR_TYPE); } -bool CGUIDialogPVRTimerSettings::TypeReadOnlyCondition(const std::string& condition, const std::string& value, SettingConstPtr setting, void* data) +bool CGUIDialogPVRTimerSettings::TypeReadOnlyCondition(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -1174,7 +1200,8 @@ bool CGUIDialogPVRTimerSettings::TypeReadOnlyCondition(const std::string& condit return false; } -void CGUIDialogPVRTimerSettings::AddTypeDependentVisibilityCondition(std::shared_ptr<CSetting> setting, const std::string& identifier) +void CGUIDialogPVRTimerSettings::AddTypeDependentVisibilityCondition( + const std::shared_ptr<CSetting>& setting, const std::string& identifier) { // Show or hide setting depending on attributes of the selected timer type std::string id(identifier); @@ -1182,7 +1209,10 @@ void CGUIDialogPVRTimerSettings::AddTypeDependentVisibilityCondition(std::shared AddCondition(setting, id, TypeSupportsCondition, SettingDependencyType::Visible, SETTING_TMR_TYPE); } -bool CGUIDialogPVRTimerSettings::TypeSupportsCondition(const std::string& condition, const std::string& value, SettingConstPtr setting, void* data) +bool CGUIDialogPVRTimerSettings::TypeSupportsCondition(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -1254,7 +1284,8 @@ bool CGUIDialogPVRTimerSettings::TypeSupportsCondition(const std::string& condit return false; } -void CGUIDialogPVRTimerSettings::AddStartAnytimeDependentVisibilityCondition(std::shared_ptr<CSetting> setting, const std::string& identifier) +void CGUIDialogPVRTimerSettings::AddStartAnytimeDependentVisibilityCondition( + const std::shared_ptr<CSetting>& setting, const std::string& identifier) { // Show or hide setting depending on value of setting "any time" std::string id(identifier); @@ -1262,7 +1293,10 @@ void CGUIDialogPVRTimerSettings::AddStartAnytimeDependentVisibilityCondition(std AddCondition(setting, id, StartAnytimeSetCondition, SettingDependencyType::Visible, SETTING_TMR_START_ANYTIME); } -bool CGUIDialogPVRTimerSettings::StartAnytimeSetCondition(const std::string& condition, const std::string& value, SettingConstPtr setting, void* data) +bool CGUIDialogPVRTimerSettings::StartAnytimeSetCondition(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -1297,7 +1331,8 @@ bool CGUIDialogPVRTimerSettings::StartAnytimeSetCondition(const std::string& con return false; } -void CGUIDialogPVRTimerSettings::AddEndAnytimeDependentVisibilityCondition(std::shared_ptr<CSetting> setting, const std::string& identifier) +void CGUIDialogPVRTimerSettings::AddEndAnytimeDependentVisibilityCondition( + const std::shared_ptr<CSetting>& setting, const std::string& identifier) { // Show or hide setting depending on value of setting "any time" std::string id(identifier); @@ -1305,7 +1340,10 @@ void CGUIDialogPVRTimerSettings::AddEndAnytimeDependentVisibilityCondition(std:: AddCondition(setting, id, EndAnytimeSetCondition, SettingDependencyType::Visible, SETTING_TMR_END_ANYTIME); } -bool CGUIDialogPVRTimerSettings::EndAnytimeSetCondition(const std::string& condition, const std::string& value, SettingConstPtr setting, void* data) +bool CGUIDialogPVRTimerSettings::EndAnytimeSetCondition(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h index 4c60294824..ec8da192a3 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h @@ -40,8 +40,8 @@ namespace PVR protected: // implementation of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } @@ -60,49 +60,83 @@ namespace PVR static void SetDateFromIndex(CDateTime& datetime, int date); static void SetTimeFromSystemTime(CDateTime& datetime, const KODI::TIME::SystemTime& time); - static int GetWeekdaysFromSetting(std::shared_ptr<const CSetting> setting); - - static void TypesFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void ChannelsFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void DaysFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void DupEpisodesFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void WeekdaysFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void PrioritiesFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void LifetimesFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void MaxRecordingsFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void RecordingGroupFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - static void MarginTimeFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); - - static std::string WeekdaysValueFormatter(std::shared_ptr<const CSetting> setting); - - void AddCondition( - std::shared_ptr<CSetting> setting, const std::string& identifier, SettingConditionCheck condition, - SettingDependencyType depType, const std::string& settingId); - - void AddTypeDependentEnableCondition(std::shared_ptr<CSetting> setting, const std::string& identifier); - static bool TypeReadOnlyCondition( - const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data); - - void AddTypeDependentVisibilityCondition(std::shared_ptr<CSetting> setting, const std::string& identifier); - static bool TypeSupportsCondition( - const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data); - - void AddStartAnytimeDependentVisibilityCondition(std::shared_ptr<CSetting> setting, const std::string& identifier); - static bool StartAnytimeSetCondition( - const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data); - void AddEndAnytimeDependentVisibilityCondition(std::shared_ptr<CSetting> setting, const std::string& identifier); - static bool EndAnytimeSetCondition( - const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data); + static int GetWeekdaysFromSetting(const std::shared_ptr<const CSetting>& setting); + + static void TypesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void ChannelsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void DaysFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void DupEpisodesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void WeekdaysFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void PrioritiesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void LifetimesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void MaxRecordingsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void RecordingGroupFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void MarginTimeFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + + static std::string WeekdaysValueFormatter(const std::shared_ptr<const CSetting>& setting); + + void AddCondition(const std::shared_ptr<CSetting>& setting, + const std::string& identifier, + SettingConditionCheck condition, + SettingDependencyType depType, + const std::string& settingId); + + void AddTypeDependentEnableCondition(const std::shared_ptr<CSetting>& setting, + const std::string& identifier); + static bool TypeReadOnlyCondition(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); + + void AddTypeDependentVisibilityCondition(const std::shared_ptr<CSetting>& setting, + const std::string& identifier); + static bool TypeSupportsCondition(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); + + void AddStartAnytimeDependentVisibilityCondition(const std::shared_ptr<CSetting>& setting, + const std::string& identifier); + static bool StartAnytimeSetCondition(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); + void AddEndAnytimeDependentVisibilityCondition(const std::shared_ptr<CSetting>& setting, + const std::string& identifier); + static bool EndAnytimeSetCondition(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); typedef std::map<int, std::shared_ptr<CPVRTimerType>> TypeEntriesMap; diff --git a/xbmc/pvr/epg/Epg.cpp b/xbmc/pvr/epg/Epg.cpp index 6f7d107622..8fce752b2c 100644 --- a/xbmc/pvr/epg/Epg.cpp +++ b/xbmc/pvr/epg/Epg.cpp @@ -125,6 +125,12 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpg::GetTagByBroadcastId(unsigned int iUniqu return m_tags.GetTag(iUniqueBroadcastId); } +std::shared_ptr<CPVREpgInfoTag> CPVREpg::GetTagByDatabaseId(int iDatabaseId) const +{ + CSingleLock lock(m_critSection); + return m_tags.GetTagByDatabaseID(iDatabaseId); +} + std::shared_ptr<CPVREpgInfoTag> CPVREpg::GetTagBetween(const CDateTime& beginTime, const CDateTime& endTime, bool bUpdateFromClient /* = false */) { std::shared_ptr<CPVREpgInfoTag> tag; diff --git a/xbmc/pvr/epg/Epg.h b/xbmc/pvr/epg/Epg.h index 55f7bb65d4..09577c378f 100644 --- a/xbmc/pvr/epg/Epg.h +++ b/xbmc/pvr/epg/Epg.h @@ -156,6 +156,13 @@ namespace PVR std::shared_ptr<CPVREpgInfoTag> GetTagByBroadcastId(unsigned int iUniqueBroadcastId) const; /*! + * @brief Get the event matching the given database id + * @param iDatabaseId The id to look up + * @return The matching event or NULL if it wasn't found. + */ + std::shared_ptr<CPVREpgInfoTag> GetTagByDatabaseId(int iDatabaseId) const; + + /*! * @brief Update an entry in this EPG. * @param data The tag to update. * @param iClientId The id of the pvr client this event belongs to. diff --git a/xbmc/pvr/epg/EpgContainer.cpp b/xbmc/pvr/epg/EpgContainer.cpp index 22753920f2..5aff3f3df3 100644 --- a/xbmc/pvr/epg/EpgContainer.cpp +++ b/xbmc/pvr/epg/EpgContainer.cpp @@ -518,14 +518,22 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgContainer::GetTagById(const std::shared_p { retval = epg->GetTagByBroadcastId(iBroadcastId); } - else + + return retval; +} + +std::shared_ptr<CPVREpgInfoTag> CPVREpgContainer::GetTagByDatabaseId(int iDatabaseId) const +{ + std::shared_ptr<CPVREpgInfoTag> retval; + + if (iDatabaseId <= 0) + return retval; + + for (const auto& epgEntry : m_epgIdToEpgMap) { - for (const auto& epgEntry : m_epgIdToEpgMap) - { - retval = epgEntry.second->GetTagByBroadcastId(iBroadcastId); - if (retval) - break; - } + retval = epgEntry.second->GetTagByDatabaseId(iDatabaseId); + if (retval) + break; } return retval; @@ -538,7 +546,7 @@ std::vector<std::shared_ptr<CPVREpgInfoTag>> CPVREpgContainer::GetTags( PersistAll(XbmcThreads::EndTime::InfiniteValue); const std::shared_ptr<CPVREpgDatabase> database = GetEpgDatabase(); - const std::vector<std::shared_ptr<CPVREpgInfoTag>> results = database->GetEpgTags(searchData); + std::vector<std::shared_ptr<CPVREpgInfoTag>> results = database->GetEpgTags(searchData); for (const auto& tag : results) { diff --git a/xbmc/pvr/epg/EpgContainer.h b/xbmc/pvr/epg/EpgContainer.h index ba6b06badf..edfc48c4e6 100644 --- a/xbmc/pvr/epg/EpgContainer.h +++ b/xbmc/pvr/epg/EpgContainer.h @@ -149,6 +149,13 @@ namespace PVR std::shared_ptr<CPVREpgInfoTag> GetTagById(const std::shared_ptr<CPVREpg>& epg, unsigned int iBroadcastId) const; /*! + * @brief Get the EPG event with the given database id + * @param iDatabaseId The id to lookup. + * @return The requested event, or an empty tag when not found + */ + std::shared_ptr<CPVREpgInfoTag> GetTagByDatabaseId(int iDatabaseId) const; + + /*! * @brief Get all EPG tags matching the given search criteria. * @param searchData The search criteria. * @return The matching tags. diff --git a/xbmc/pvr/epg/EpgDatabase.cpp b/xbmc/pvr/epg/EpgDatabase.cpp index 251ed57a51..383872d6a1 100644 --- a/xbmc/pvr/epg/EpgDatabase.cpp +++ b/xbmc/pvr/epg/EpgDatabase.cpp @@ -341,7 +341,7 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::CreateEpgTag( { if (!pDS->eof()) { - const std::shared_ptr<CPVREpgInfoTag> newTag(new CPVREpgInfoTag()); + std::shared_ptr<CPVREpgInfoTag> newTag(new CPVREpgInfoTag()); time_t iStartTime; iStartTime = static_cast<time_t>(m_pDS->fv("iStartTime").get_asInt()); @@ -711,7 +711,7 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::GetEpgTagByUniqueBroadcastID( { try { - const std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); + std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); m_pDS->close(); return tag; } @@ -725,6 +725,32 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::GetEpgTagByUniqueBroadcastID( return {}; } +std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::GetEpgTagByDatabaseID(int iEpgID, int iDatabaseId) +{ + CSingleLock lock(m_critSection); + const std::string strQuery = PrepareSQL("SELECT * " + "FROM epgtags " + "WHERE idEpg = %u AND idBroadcast = %u;", + iEpgID, iDatabaseId); + + if (ResultQuery(strQuery)) + { + try + { + std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); + m_pDS->close(); + return tag; + } + catch (...) + { + CLog::LogF(LOGERROR, "Could not load EPG tag with database ID (%u) from the database", + iDatabaseId); + } + } + + return {}; +} + std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::GetEpgTagByStartTime(int iEpgID, const CDateTime& startTime) { @@ -741,7 +767,7 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::GetEpgTagByStartTime(int iEpgID { try { - const std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); + std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); m_pDS->close(); return tag; } @@ -772,7 +798,7 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::GetEpgTagByMinStartTime( { try { - const std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); + std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); m_pDS->close(); return tag; } @@ -803,7 +829,7 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::GetEpgTagByMaxEndTime(int iEpgI { try { - const std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); + std::shared_ptr<CPVREpgInfoTag> tag = CreateEpgTag(m_pDS); m_pDS->close(); return tag; } diff --git a/xbmc/pvr/epg/EpgDatabase.h b/xbmc/pvr/epg/EpgDatabase.h index 99960cdfb0..1e02e6f90b 100644 --- a/xbmc/pvr/epg/EpgDatabase.h +++ b/xbmc/pvr/epg/EpgDatabase.h @@ -154,6 +154,14 @@ namespace PVR unsigned int iUniqueBroadcastId); /*! + * @brief Get an EPG tag given its EPG id and database ID. + * @param iEpgID The ID of the EPG for the tag to get. + * @param iDatabaseId The database ID for the tag to get. + * @return The tag or nullptr, if not found. + */ + std::shared_ptr<CPVREpgInfoTag> GetEpgTagByDatabaseID(int iEpgID, int iDatabaseId); + + /*! * @brief Get an EPG tag given its EPG ID and start time. * @param iEpgID The ID of the EPG for the tag to get. * @param startTime The start time for the tag to get. diff --git a/xbmc/pvr/epg/EpgInfoTag.cpp b/xbmc/pvr/epg/EpgInfoTag.cpp index 401c099bbd..f288f45b79 100644 --- a/xbmc/pvr/epg/EpgInfoTag.cpp +++ b/xbmc/pvr/epg/EpgInfoTag.cpp @@ -153,7 +153,7 @@ bool CPVREpgInfoTag::operator !=(const CPVREpgInfoTag& right) const void CPVREpgInfoTag::Serialize(CVariant& value) const { CSingleLock lock(m_critSection); - value["broadcastid"] = m_iUniqueBroadcastID; + value["broadcastid"] = m_iDatabaseID; // Use DB id here as it is unique across PVR clients value["channeluid"] = m_channelData->UniqueClientChannelId(); value["parentalrating"] = m_iParentalRating; value["rating"] = m_iStarRating; @@ -185,6 +185,7 @@ void CPVREpgInfoTag::Serialize(CVariant& value) const value["wasactive"] = WasActive(); value["isseries"] = IsSeries(); value["serieslink"] = m_strSeriesLink; + value["clientid"] = m_channelData->ClientId(); } int CPVREpgInfoTag::ClientID() const diff --git a/xbmc/pvr/epg/EpgTagsContainer.cpp b/xbmc/pvr/epg/EpgTagsContainer.cpp index f249040adc..797f0c10c7 100644 --- a/xbmc/pvr/epg/EpgTagsContainer.cpp +++ b/xbmc/pvr/epg/EpgTagsContainer.cpp @@ -368,6 +368,23 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgTagsContainer::GetTag(unsigned int iUniqu return {}; } +std::shared_ptr<CPVREpgInfoTag> CPVREpgTagsContainer::GetTagByDatabaseID(int iDatabaseID) const +{ + if (iDatabaseID <= 0) + return {}; + + for (const auto& tag : m_changedTags) + { + if (tag.second->DatabaseID() == iDatabaseID) + return tag.second; + } + + if (m_database) + return CreateEntry(m_database->GetEpgTagByDatabaseID(m_iEpgID, iDatabaseID)); + + return {}; +} + std::shared_ptr<CPVREpgInfoTag> CPVREpgTagsContainer::GetTagBetween(const CDateTime& start, const CDateTime& end) const { diff --git a/xbmc/pvr/epg/EpgTagsContainer.h b/xbmc/pvr/epg/EpgTagsContainer.h index 3900f28b83..75ed5029b9 100644 --- a/xbmc/pvr/epg/EpgTagsContainer.h +++ b/xbmc/pvr/epg/EpgTagsContainer.h @@ -95,6 +95,13 @@ public: std::shared_ptr<CPVREpgInfoTag> GetTag(unsigned int iUniqueBroadcastID) const; /*! + * @brief Get an EPG tag given its database ID. + * @param iDatabaseID The ID. + * @return The tag or nullptr if no tag was found. + */ + std::shared_ptr<CPVREpgInfoTag> GetTagByDatabaseID(int iDatabaseID) const; + + /*! * @brief Get the event that occurs between the given begin and end time. * @param start The start of the time interval. * @param end The end of the time interval. diff --git a/xbmc/pvr/guilib/PVRGUIActionListener.cpp b/xbmc/pvr/guilib/PVRGUIActionListener.cpp index 93e8f37e3b..d4fb39b185 100644 --- a/xbmc/pvr/guilib/PVRGUIActionListener.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionListener.cpp @@ -274,7 +274,7 @@ bool CPVRGUIActionListener::OnAction(const CAction& action) return false; } -void CPVRGUIActionListener::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CPVRGUIActionListener::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; @@ -299,7 +299,7 @@ void CPVRGUIActionListener::OnSettingChanged(std::shared_ptr<const CSetting> set } } -void CPVRGUIActionListener::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CPVRGUIActionListener::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/pvr/guilib/PVRGUIActionListener.h b/xbmc/pvr/guilib/PVRGUIActionListener.h index f84ee97d1b..d24818bff2 100644 --- a/xbmc/pvr/guilib/PVRGUIActionListener.h +++ b/xbmc/pvr/guilib/PVRGUIActionListener.h @@ -31,8 +31,8 @@ public: bool OnAction(const CAction& action) override; // ISettingCallback implementation - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; void OnPVRManagerEvent(const PVREvent& event); diff --git a/xbmc/pvr/guilib/PVRGUIActions.cpp b/xbmc/pvr/guilib/PVRGUIActions.cpp index 36d9d99173..d5d3e1fb1d 100644 --- a/xbmc/pvr/guilib/PVRGUIActions.cpp +++ b/xbmc/pvr/guilib/PVRGUIActions.cpp @@ -219,20 +219,18 @@ namespace PVR }; CPVRGUIActions::CPVRGUIActions() - : m_settings({ - CSettings::SETTING_LOOKANDFEEL_STARTUPACTION, - CSettings::SETTING_PVRMANAGER_PRESELECTPLAYINGCHANNEL, - CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME, - CSettings::SETTING_PVRRECORD_INSTANTRECORDACTION, - CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH, - CSettings::SETTING_PVRPLAYBACK_SWITCHTOFULLSCREENCHANNELTYPES, - CSettings::SETTING_PVRPARENTAL_PIN, - CSettings::SETTING_PVRPARENTAL_ENABLED, - CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME, - CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME, - CSettings::SETTING_PVRREMINDERS_AUTOCLOSEDELAY, - CSettings::SETTING_PVRREMINDERS_AUTORECORD - }) + : m_settings({CSettings::SETTING_LOOKANDFEEL_STARTUPACTION, + CSettings::SETTING_PVRMANAGER_PRESELECTPLAYINGCHANNEL, + CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME, + CSettings::SETTING_PVRRECORD_INSTANTRECORDACTION, + CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH, + CSettings::SETTING_PVRPLAYBACK_SWITCHTOFULLSCREENCHANNELTYPES, + CSettings::SETTING_PVRPARENTAL_PIN, CSettings::SETTING_PVRPARENTAL_ENABLED, + CSettings::SETTING_PVRPOWERMANAGEMENT_DAILYWAKEUPTIME, + CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME, + CSettings::SETTING_PVRREMINDERS_AUTOCLOSEDELAY, + CSettings::SETTING_PVRREMINDERS_AUTORECORD, + CSettings::SETTING_PVRREMINDERS_AUTOSWITCH}) { } @@ -1563,6 +1561,11 @@ namespace PVR bool CPVRGUIActions::StartChannelScan() { + return StartChannelScan(PVR_INVALID_CLIENT_ID); + } + + bool CPVRGUIActions::StartChannelScan(int clientId) + { if (!CServiceBroker::GetPVRManager().IsStarted() || IsRunningChannelScan()) return false; @@ -1570,8 +1573,28 @@ namespace PVR std::vector<std::shared_ptr<CPVRClient>> possibleScanClients = CServiceBroker::GetPVRManager().Clients()->GetClientsSupportingChannelScan(); m_bChannelScanRunning = true; + if (clientId != PVR_INVALID_CLIENT_ID) + { + for (const auto& client : possibleScanClients) + { + if (client->GetID() == clientId) + { + scanClient = client; + break; + } + } + + if (!scanClient) + { + CLog::LogF(LOGERROR, + "Provided client id '%d' could not be found in list of possible scan clients!", + clientId); + m_bChannelScanRunning = false; + return false; + } + } /* multiple clients found */ - if (possibleScanClients.size() > 1) + else if (possibleScanClients.size() > 1) { CGUIDialogSelect* pDialog= CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!pDialog) @@ -2072,7 +2095,11 @@ namespace PVR dialog->ShowChoice(2, CVariant{222}); // "Cancel" if (m_settings.GetBoolValue(CSettings::SETTING_PVRREMINDERS_AUTORECORD)) - text += "\n\n" + g_localizeStrings.Get(19309); // (Auto-close of this reminder will schedule a recording...) + text += "\n\n" + g_localizeStrings.Get( + 19309); // (Auto-close of this reminder will schedule a recording...) + else if (m_settings.GetBoolValue(CSettings::SETTING_PVRREMINDERS_AUTOSWITCH)) + text += "\n\n" + g_localizeStrings.Get( + 19331); // (Auto-close of this reminder will swicth to channel...) } else { @@ -2105,54 +2132,59 @@ namespace PVR dialog->Close(); - if (iRemaining <= 0) // auto-closed? + bool bAutoClosed = (iRemaining <= 0); + bool bSwitch = (result == 0); + bool bRecord = (result == 1); + + if (bAutoClosed) { - if (bCanRecord && m_settings.GetBoolValue(CSettings::SETTING_PVRREMINDERS_AUTORECORD)) - result = 1; // -> schedule recording - else - result = CGUIDialogProgress::CHOICE_CANCELED; // -> do nothing + bRecord = (bCanRecord && m_settings.GetBoolValue(CSettings::SETTING_PVRREMINDERS_AUTORECORD)); + bSwitch = m_settings.GetBoolValue(CSettings::SETTING_PVRREMINDERS_AUTOSWITCH); } - switch (result) + if (bRecord) { - case 0: - SwitchToChannel(std::make_shared<CFileItem>(timer->Channel()), false); - break; - case 1: - if (bCanRecord) + std::shared_ptr<CPVRTimerInfoTag> newTimer; + + std::shared_ptr<CPVREpgInfoTag> epgTag = timer->GetEpgInfoTag(); + if (epgTag) + { + newTimer = CPVRTimerInfoTag::CreateFromEpg(epgTag, false); + if (newTimer) { - std::shared_ptr<CPVRTimerInfoTag> newTimer; + // an epgtag can only have max one timer - we need to clear the reminder to be able to + // attach the recording timer + DeleteTimer(timer, false, false); + } + } + else + { + int iDuration = (timer->EndAsUTC() - timer->StartAsUTC()).GetSecondsTotal() / 60; + newTimer = + CPVRTimerInfoTag::CreateTimerTag(timer->Channel(), timer->StartAsUTC(), iDuration); + } - std::shared_ptr<CPVREpgInfoTag> epgTag = timer->GetEpgInfoTag(); - if (epgTag) - { - newTimer = CPVRTimerInfoTag::CreateFromEpg(epgTag, false); - if (newTimer) - { - // an epgtag can only have max one timer - we need to clear the reminder to be able to attach the recording timer - DeleteTimer(timer, false, false); - } - } - else - { - int iDuration = (timer->EndAsUTC() - timer->StartAsUTC()).GetSecondsTotal() / 60; - newTimer = CPVRTimerInfoTag::CreateTimerTag(timer->Channel(), timer->StartAsUTC(), iDuration); - } + if (newTimer) + { + // schedule recording + AddTimer(std::make_shared<CFileItem>(newTimer), false); + } - if (newTimer) - { - // schedule recording - AddTimer(std::make_shared<CFileItem>(newTimer), false); - } + if (bAutoClosed) + { + AddEventLogEntry(timer, 19310, + 19311); // Scheduled recording for auto-closed PVR reminder ... + } + } - if (iRemaining <= 0) // auto-closed? - { - AddEventLogEntry(timer, 19310, 19311); // Scheduled recording for auto-closed PVR reminder ... - } - } - break; - default: - break; + if (bSwitch) + { + SwitchToChannel(std::make_shared<CFileItem>(timer->Channel()), false); + + if (bAutoClosed) + { + AddEventLogEntry(timer, 19332, 19333); // Switched channel for auto-closed PVR reminder ... + } } } diff --git a/xbmc/pvr/guilib/PVRGUIActions.h b/xbmc/pvr/guilib/PVRGUIActions.h index 7630202270..dc71ade4b6 100644 --- a/xbmc/pvr/guilib/PVRGUIActions.h +++ b/xbmc/pvr/guilib/PVRGUIActions.h @@ -309,6 +309,13 @@ namespace PVR bool StartChannelScan(); /*! + * @brief Start a channel scan on the specified client or open a dialog to select a client + * @param clientId the id of client to scan or PVR_INVALID_CLIENT_ID if a dialog will be opened + * @return true on success, false otherwise. + */ + bool StartChannelScan(int clientId); + + /*! * @return True when a channel scan is currently running, false otherwise. */ bool IsRunningChannelScan() const { return m_bChannelScanRunning; } diff --git a/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp b/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp index db55e2dfa6..ba57aaa764 100644 --- a/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp +++ b/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp @@ -130,7 +130,8 @@ namespace PVR return {}; } - void CPVRGUIChannelNavigator::SelectChannel(const std::shared_ptr<CPVRChannel> channel, ChannelSwitchMode eSwitchMode) + void CPVRGUIChannelNavigator::SelectChannel(const std::shared_ptr<CPVRChannel>& channel, + ChannelSwitchMode eSwitchMode) { CServiceBroker::GetGUI()->GetInfoManager().SetCurrentItem(CFileItem(channel)); @@ -253,7 +254,7 @@ namespace PVR ShowInfo(); } - void CPVRGUIChannelNavigator::SetPlayingChannel(const std::shared_ptr<CPVRChannel> channel) + void CPVRGUIChannelNavigator::SetPlayingChannel(const std::shared_ptr<CPVRChannel>& channel) { CFileItemPtr item; diff --git a/xbmc/pvr/guilib/PVRGUIChannelNavigator.h b/xbmc/pvr/guilib/PVRGUIChannelNavigator.h index 3d1cb1b959..df52367203 100644 --- a/xbmc/pvr/guilib/PVRGUIChannelNavigator.h +++ b/xbmc/pvr/guilib/PVRGUIChannelNavigator.h @@ -75,7 +75,7 @@ namespace PVR * @brief Set a new playing channel and show the channel info OSD for the new channel. * @param channel The new playing channel */ - void SetPlayingChannel(const std::shared_ptr<CPVRChannel> channel); + void SetPlayingChannel(const std::shared_ptr<CPVRChannel>& channel); /*! * @brief Clear the currently playing channel and hide the channel info OSD. @@ -95,7 +95,7 @@ namespace PVR * @param item The channel to select. * @param eSwitchMode The channel switch mode. */ - void SelectChannel(const std::shared_ptr<CPVRChannel> channel, ChannelSwitchMode eSwitchMode); + void SelectChannel(const std::shared_ptr<CPVRChannel>& channel, ChannelSwitchMode eSwitchMode); /*! * @brief Show the channel info OSD. diff --git a/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp b/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp index ba0f54f988..d15a83abc4 100644 --- a/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp +++ b/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp @@ -301,6 +301,20 @@ namespace return datetime.IsValid() ? datetime.GetAsLocalizedDateTime(false, false) : ""; } + std::string GetEpgTagTitle(const std::shared_ptr<CPVREpgInfoTag>& epgTag) + { + if (epgTag) + { + if (CServiceBroker::GetPVRManager().IsParentalLocked(epgTag)) + return g_localizeStrings.Get(19266); // Parental locked + else if (!epgTag->Title().empty() || + CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( + CSettings::SETTING_EPG_HIDENOINFOAVAILABLE)) + return epgTag->Title(); + } + return g_localizeStrings.Get(19055); // no information available + } + } // unnamed namespace bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, const CGUIInfo& info, std::string& strValue) const @@ -490,20 +504,13 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, const CGUIInf { // special handling for channels without epg or with radio rds data case PLAYER_TITLE: - case VIDEOPLAYER_TITLE: case LISTITEM_TITLE: case VIDEOPLAYER_NEXT_TITLE: case LISTITEM_NEXT_TITLE: case LISTITEM_EPG_EVENT_TITLE: // Note: in difference to LISTITEM_TITLE, LISTITEM_EPG_EVENT_TITLE returns the title // associated with the epg event of a timer, if any, and not the title of the timer. - if (epgTag) - { - bool bLocked = CServiceBroker::GetPVRManager().IsParentalLocked(epgTag); - strValue = bLocked ? g_localizeStrings.Get(19266) /* Parental locked */ : epgTag->Title(); - } - if (strValue.empty() && !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_EPG_HIDENOINFOAVAILABLE)) - strValue = g_localizeStrings.Get(19055); // no information available + strValue = GetEpgTagTitle(epgTag); return true; } } @@ -1047,6 +1054,30 @@ bool CPVRGUIInfo::GetRadioRDSLabel(const CFileItem* item, const CGUIInfo& info, return false; } +bool CPVRGUIInfo::GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const CGUIInfo& info, + std::string* fallback) +{ + if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer()) + { + switch (info.m_info) + { + ///////////////////////////////////////////////////////////////////////////////////////////// + // VIDEOPLAYER_*, MUSICPLAYER_* + ///////////////////////////////////////////////////////////////////////////////////////////// + case VIDEOPLAYER_TITLE: + case MUSICPLAYER_TITLE: + value = GetEpgTagTitle(CPVRItem(item).GetEpgInfoTag()); + return !value.empty(); + default: + break; + } + } + return false; +} + bool CPVRGUIInfo::GetInt(int& value, const CGUIListItem* item, int contextWindow, const CGUIInfo& info) const { if (!item->IsFileItem()) diff --git a/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.h b/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.h index 49dbdf578b..4adff0c3cb 100644 --- a/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.h +++ b/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.h @@ -55,6 +55,11 @@ namespace PVR // KODI::GUILIB::GUIINFO::IGUIInfoProvider implementation bool InitCurrentItem(CFileItem* item) override; bool GetLabel(std::string& value, const CFileItem* item, int contextWindow, const KODI::GUILIB::GUIINFO::CGUIInfo& info, std::string* fallback) const override; + bool GetFallbackLabel(std::string& value, + const CFileItem* item, + int contextWindow, + const KODI::GUILIB::GUIINFO::CGUIInfo& info, + std::string* fallback) override; bool GetInt(int& value, const CGUIListItem* item, int contextWindow, const KODI::GUILIB::GUIINFO::CGUIInfo& info) const override; bool GetBool(bool& value, const CGUIListItem* item, int contextWindow, const KODI::GUILIB::GUIINFO::CGUIInfo& info) const override; diff --git a/xbmc/pvr/recordings/PVRRecording.cpp b/xbmc/pvr/recordings/PVRRecording.cpp index b517846eaf..3675ba6bbb 100644 --- a/xbmc/pvr/recordings/PVRRecording.cpp +++ b/xbmc/pvr/recordings/PVRRecording.cpp @@ -201,6 +201,8 @@ void CPVRRecording::Serialize(CVariant& value) const value["art"]["thumb"] = m_strThumbnailPath; if (!m_strFanartPath.empty()) value["art"]["fanart"] = m_strFanartPath; + + value["clientid"] = m_iClientId; } void CPVRRecording::ToSortable(SortItem& sortable, Field field) const @@ -581,6 +583,12 @@ CDateTime CPVRRecording::FirstAired() const return m_firstAired; } +void CPVRRecording::SetYear(int year) +{ + if (year > 0) + m_premiered = CDateTime(year, 1, 1, 0, 0, 0); +} + int CPVRRecording::GetYear() const { return m_premiered.GetYear(); diff --git a/xbmc/pvr/recordings/PVRRecording.h b/xbmc/pvr/recordings/PVRRecording.h index b9f7389b51..6df5b96b18 100644 --- a/xbmc/pvr/recordings/PVRRecording.h +++ b/xbmc/pvr/recordings/PVRRecording.h @@ -304,13 +304,13 @@ namespace PVR void SetGenre(int iGenreType, int iGenreSubType, const std::string& strGenre); /*! - * @brief Get the genre type ID of this event. + * @brief Get the genre type ID of this recording. * @return The genre type ID. */ int GenreType() const { return m_iGenreType; } /*! - * @brief Get the genre subtype ID of this event. + * @brief Get the genre subtype ID of this recording. * @return The genre subtype ID. */ int GenreSubType() const { return m_iGenreSubType; } @@ -322,26 +322,32 @@ namespace PVR const std::vector<std::string> Genre() const { return m_genre; } /*! - * @brief Get the genre(s) of this event as formatted string. + * @brief Get the genre(s) of this recording as formatted string. * @return The genres label. */ const std::string GetGenresLabel() const; /*! - * @brief Get the first air date of this event. + * @brief Get the first air date of this recording. * @return The first air date. */ CDateTime FirstAired() const; /*! - * @brief Get the premiere year of this event. + * @brief Get the premiere year of this recording. * @return The premiere year */ int GetYear() const override; /*! - * @brief Check if the premiere year of this event is valid - * @return True if the event has as valid premiere date, false otherwise + * @brief Set the premiere year of this recording. + * @param year The premiere year + */ + void SetYear(int year) override; + + /*! + * @brief Check if the premiere year of this recording is valid + * @return True if the recording has as valid premiere date, false otherwise */ bool HasYear() const override; @@ -381,7 +387,21 @@ namespace PVR */ int64_t GetSizeInBytes() const; + /*! + * @brief Mark a recording as dirty/clean. + * @param bDirty true to mark as dirty, false to mark as clean. + */ + void SetDirty(bool bDirty) { m_bDirty = bDirty; } + + /*! + * @brief Return whether the recording is marked dirty. + * @return true if dirty, false otherwise. + */ + bool IsDirty() const { return m_bDirty; } + private: + void UpdatePath(); + CDateTime m_recordingTime; /*!< start time of the recording */ bool m_bGotMetaData; bool m_bIsDeleted; /*!< set if entry is a deleted recording which can be undelete */ @@ -394,8 +414,7 @@ namespace PVR unsigned int m_iFlags = 0; /*!< the flags applicable to this recording */ mutable XbmcThreads::EndTime m_recordingSizeRefetchTimeout; int64_t m_sizeInBytes = 0; /*!< the size of the recording in bytes */ - - void UpdatePath(); + bool m_bDirty = false; mutable CCriticalSection m_critSection; }; diff --git a/xbmc/pvr/recordings/PVRRecordings.cpp b/xbmc/pvr/recordings/PVRRecordings.cpp index 0e1e5d5efa..6f4fb21864 100644 --- a/xbmc/pvr/recordings/PVRRecordings.cpp +++ b/xbmc/pvr/recordings/PVRRecordings.cpp @@ -36,9 +36,21 @@ CPVRRecordings::~CPVRRecordings() void CPVRRecordings::UpdateFromClients() { CSingleLock lock(m_critSection); - Unload(); + + for (const auto& recording : m_recordings) + recording.second->SetDirty(true); + CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, false); CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, true); + + // remove recordings that were deleted at the backend + for (auto it = m_recordings.begin(); it != m_recordings.end();) + { + if ((*it).second->IsDirty()) + it = m_recordings.erase(it); + else + ++it; + } } int CPVRRecordings::Load() @@ -201,6 +213,7 @@ void CPVRRecordings::UpdateFromClient(const std::shared_ptr<CPVRRecording>& tag) if (existingTag) { existingTag->Update(*tag); + existingTag->SetDirty(false); } else { diff --git a/xbmc/pvr/settings/PVRSettings.cpp b/xbmc/pvr/settings/PVRSettings.cpp index 7ef2e091dd..ceeb219a8c 100644 --- a/xbmc/pvr/settings/PVRSettings.cpp +++ b/xbmc/pvr/settings/PVRSettings.cpp @@ -93,7 +93,7 @@ void CPVRSettings::OnSettingsLoaded() Init(settingNames); } -void CPVRSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CPVRSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; @@ -147,8 +147,10 @@ std::string CPVRSettings::GetStringValue(const std::string& settingName) const return ""; } -void CPVRSettings::MarginTimeFiller( - SettingConstPtr /*setting*/, std::vector<IntegerSettingOption>& list, int& current, void* /*data*/) +void CPVRSettings::MarginTimeFiller(const SettingConstPtr& /*setting*/, + std::vector<IntegerSettingOption>& list, + int& current, + void* /*data*/) { list.clear(); @@ -163,7 +165,10 @@ void CPVRSettings::MarginTimeFiller( } } -bool CPVRSettings::IsSettingVisible(const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data) +bool CPVRSettings::IsSettingVisible(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data) { if (setting == nullptr) return false; @@ -198,7 +203,10 @@ bool CPVRSettings::IsSettingVisible(const std::string& condition, const std::str } } -bool CPVRSettings::CheckParentalPin(const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data) +bool CPVRSettings::CheckParentalPin(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data) { return CServiceBroker::GetPVRManager().GUIActions()->CheckParentalPIN() == ParentalCheckResult::SUCCESS; } diff --git a/xbmc/pvr/settings/PVRSettings.h b/xbmc/pvr/settings/PVRSettings.h index 38770b54fc..57d5c9655c 100644 --- a/xbmc/pvr/settings/PVRSettings.h +++ b/xbmc/pvr/settings/PVRSettings.h @@ -34,21 +34,29 @@ namespace PVR void OnSettingsLoaded() override; // ISettingCallback implementation - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; bool GetBoolValue(const std::string& settingName) const; int GetIntValue(const std::string& settingName) const; std::string GetStringValue(const std::string& settingName) const; // settings value filler for start/end recording margin time for PVR timers. - static void MarginTimeFiller( - std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption>& list, int& current, void* data); + static void MarginTimeFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); // Dynamically hide or show settings. - static bool IsSettingVisible(const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data); + static bool IsSettingVisible(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); // Do parental PIN check. - static bool CheckParentalPin(const std::string& condition, const std::string& value, std::shared_ptr<const CSetting> setting, void* data); + static bool CheckParentalPin(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); private: CPVRSettings(const CPVRSettings&) = delete; diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp index 7bc8e295b0..e733a402c1 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp +++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp @@ -299,6 +299,7 @@ void CPVRTimerInfoTag::Serialize(CVariant& value) const value["istimerrule"] = m_timerType && m_timerType->IsTimerRule(); value["ismanual"] = m_timerType && m_timerType->IsManual(); value["isreadonly"] = m_timerType && m_timerType->IsReadOnly(); + value["isreminder"] = m_timerType && m_timerType->IsReminder(); value["epgsearchstring"] = m_strEpgSearchString; value["fulltextepgsearch"] = m_bFullTextEpgSearch; @@ -306,6 +307,8 @@ void CPVRTimerInfoTag::Serialize(CVariant& value) const value["maxrecordings"] = m_iMaxRecordings; value["epguid"] = m_iEpgUid; value["serieslink"] = m_strSeriesLink; + + value["clientid"] = m_iClientId; } void CPVRTimerInfoTag::UpdateSummary() @@ -696,7 +699,8 @@ std::shared_ptr<CPVRTimerInfoTag> CPVRTimerInfoTag::CreateReminderFromDate( const std::shared_ptr<CPVRTimerInfoTag>& parent /* = std::shared_ptr<CPVRTimerInfoTag>() */) { bool bReadOnly = !!parent; // children of reminder rules are always read-only - const std::shared_ptr<CPVRTimerInfoTag> newTimer = CreateFromDate(parent->Channel(), start, iDuration, true, bReadOnly); + std::shared_ptr<CPVRTimerInfoTag> newTimer = + CreateFromDate(parent->Channel(), start, iDuration, true, bReadOnly); if (newTimer && parent) { // set parent @@ -836,7 +840,7 @@ std::shared_ptr<CPVRTimerInfoTag> CPVRTimerInfoTag::CreateReminderFromEpg( const std::shared_ptr<CPVRTimerInfoTag>& parent /* = std::shared_ptr<CPVRTimerInfoTag>() */) { bool bReadOnly = !!parent; // children of reminder rules are always read-only - const std::shared_ptr<CPVRTimerInfoTag> newTimer = CreateFromEpg(tag, false, true, bReadOnly); + std::shared_ptr<CPVRTimerInfoTag> newTimer = CreateFromEpg(tag, false, true, bReadOnly); if (newTimer && parent) { // set parent @@ -856,7 +860,10 @@ std::shared_ptr<CPVRTimerInfoTag> CPVRTimerInfoTag::CreateFromEpg( } std::shared_ptr<CPVRTimerInfoTag> CPVRTimerInfoTag::CreateFromEpg( - const std::shared_ptr<CPVREpgInfoTag>& tag, bool bCreateRule, bool bCreateReminder, bool bReadOnly) + const std::shared_ptr<CPVREpgInfoTag>& tag, + bool bCreateRule, + bool bCreateReminder, + bool bReadOnly /* = false */) { std::shared_ptr<CPVRTimerInfoTag> newTag(new CPVRTimerInfoTag()); diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.h b/xbmc/pvr/timers/PVRTimerInfoTag.h index 357ca13e2c..75380be8d4 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.h +++ b/xbmc/pvr/timers/PVRTimerInfoTag.h @@ -66,6 +66,20 @@ namespace PVR static std::shared_ptr<CPVRTimerInfoTag> CreateTimerTag(const std::shared_ptr<CPVRChannel>& channel, const CDateTime& start, int iDuration); /*! + * @brief create a recording or reminder timer or timer rule for the given epg info tag. + * @param tag the epg info tag + * @param bCreateRule if true, create a timer rule, create a one shot timer otherwise + * @param bCreateReminder if true, create a reminder timer or rule, create a recording timer or rule otherwise + * @param bReadOnly whether the timer/rule is read only + * @return the timer or null if timer could not be created + */ + static std::shared_ptr<CPVRTimerInfoTag> CreateFromEpg( + const std::shared_ptr<CPVREpgInfoTag>& tag, + bool bCreateRule, + bool bCreateReminder, + bool bReadOnly = false); + + /*! * @brief create a timer or timer rule for the given epg info tag. * @param tag the epg info tag * @param bCreateRule if true, create a timer rule, create a one shot timer otherwise @@ -353,7 +367,6 @@ namespace PVR std::string GetWeekdaysString() const; void UpdateEpgInfoTag(); - static std::shared_ptr<CPVRTimerInfoTag> CreateFromEpg(const std::shared_ptr<CPVREpgInfoTag>& tag, bool bCreateRule, bool bCreateReminder, bool bReadOnly); static std::shared_ptr<CPVRTimerInfoTag> CreateFromDate(const std::shared_ptr<CPVRChannel>& channel, const CDateTime& start, int iDuration, bool bCreateReminder, bool bReadOnly); mutable CCriticalSection m_critSection; diff --git a/xbmc/pvr/windows/GUIViewStatePVR.cpp b/xbmc/pvr/windows/GUIViewStatePVR.cpp index 05a9d78939..8530061c6e 100644 --- a/xbmc/pvr/windows/GUIViewStatePVR.cpp +++ b/xbmc/pvr/windows/GUIViewStatePVR.cpp @@ -14,6 +14,7 @@ #include "pvr/addons/PVRClients.h" #include "pvr/recordings/PVRRecordingsPath.h" #include "pvr/timers/PVRTimersPath.h" +#include "settings/AdvancedSettings.h" #include "settings/Settings.h" #include "settings/SettingsComponent.h" #include "view/ViewStateSettings.h" @@ -50,8 +51,8 @@ CGUIViewStateWindowPVRRecordings::CGUIViewStateWindowPVRRecordings(const int win if (CServiceBroker::GetPVRManager().Clients()->AnyClientSupportingRecordingsSize()) AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // "Size" : Filename, DateTime | Foldername, empty - // Default sorting - SetSortMethod(SortByDate); + SetSortMethod(CServiceBroker::GetSettingsComponent()->GetAdvancedSettings() + ->m_PVRDefaultSortOrder); LoadViewState(items.GetPath(), m_windowId); } diff --git a/xbmc/rendering/gl/GLShader.cpp b/xbmc/rendering/gl/GLShader.cpp index 772fefb80b..e91af97b56 100644 --- a/xbmc/rendering/gl/GLShader.cpp +++ b/xbmc/rendering/gl/GLShader.cpp @@ -17,7 +17,7 @@ using namespace Shaders; -CGLShader::CGLShader(const char *shader, std::string prefix) +CGLShader::CGLShader(const char* shader, const std::string& prefix) { m_proj = nullptr; m_model = nullptr; @@ -27,7 +27,7 @@ CGLShader::CGLShader(const char *shader, std::string prefix) PixelShader()->LoadSource(shader, prefix); } -CGLShader::CGLShader(const char *vshader, const char *fshader, std::string prefix) +CGLShader::CGLShader(const char* vshader, const char* fshader, const std::string& prefix) { m_proj = nullptr; m_model = nullptr; diff --git a/xbmc/rendering/gl/GLShader.h b/xbmc/rendering/gl/GLShader.h index c39fb29d7d..d5b82f3a07 100644 --- a/xbmc/rendering/gl/GLShader.h +++ b/xbmc/rendering/gl/GLShader.h @@ -15,8 +15,8 @@ class CGLShader : public Shaders::CGLSLShaderProgram { public: - CGLShader(const char *shader, std::string prefix); - CGLShader(const char *vshader, const char *fshader, std::string prefix); + CGLShader(const char* shader, const std::string& prefix); + CGLShader(const char* vshader, const char* fshader, const std::string& prefix); void OnCompiledAndLinked() override; bool OnEnabled() override; void Free(); diff --git a/xbmc/rendering/gles/GLESShader.cpp b/xbmc/rendering/gles/GLESShader.cpp index 3835cd687a..3964f4ba47 100644 --- a/xbmc/rendering/gles/GLESShader.cpp +++ b/xbmc/rendering/gles/GLESShader.cpp @@ -16,7 +16,7 @@ using namespace Shaders; -CGLESShader::CGLESShader( const char *shader, std::string prefix) +CGLESShader::CGLESShader(const char* shader, const std::string& prefix) { m_proj = nullptr; m_model = nullptr; @@ -26,7 +26,7 @@ CGLESShader::CGLESShader( const char *shader, std::string prefix) PixelShader()->LoadSource(shader, prefix); } -CGLESShader::CGLESShader(const char *vshader, const char *fshader, std::string prefix) +CGLESShader::CGLESShader(const char* vshader, const char* fshader, const std::string& prefix) { m_proj = nullptr; m_model = nullptr; diff --git a/xbmc/rendering/gles/GLESShader.h b/xbmc/rendering/gles/GLESShader.h index 53c0772fbc..8ce31e5570 100644 --- a/xbmc/rendering/gles/GLESShader.h +++ b/xbmc/rendering/gles/GLESShader.h @@ -15,8 +15,8 @@ class CGLESShader : public Shaders::CGLSLShaderProgram { public: - CGLESShader( const char *shader, std::string prefix); - CGLESShader(const char *vshader, const char *fshader, std::string prefix); + CGLESShader(const char* shader, const std::string& prefix); + CGLESShader(const char* vshader, const char* fshader, const std::string& prefix); void OnCompiledAndLinked() override; bool OnEnabled() override; void Free(); diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index 872b1785da..bc1352b84c 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -75,7 +75,7 @@ void CAdvancedSettings::OnSettingsUnloaded() m_initialized = false; } -void CAdvancedSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CAdvancedSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -232,7 +232,8 @@ void CAdvancedSettings::Initialize() // foo.s01.e01, foo.s01_e01, S01E02 foo, S01 - E02, S01xE02 m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"s([0-9]+)[ ._x-]*e([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$")); // foo.ep01, foo.EP_01, foo.E01 - m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\._ -]()e(?:p[ ._-]?)?([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$")); + m_tvshowEnumRegExps.push_back(TVShowRegexp( + false, "[\\._ -]?()e(?:p[ ._-]?)?([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$")); // foo.yyyy.mm.dd.* (byDate=true) m_tvshowEnumRegExps.push_back(TVShowRegexp(true,"([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})")); // foo.mm.dd.yyyy.* (byDate=true) @@ -371,6 +372,8 @@ void CAdvancedSettings::Initialize() m_iPVRNumericChannelSwitchTimeout = 2000; m_iPVRTimeshiftThreshold = 10; m_bPVRTimeshiftSimpleOSD = true; + m_PVRDefaultSortOrder.sortBy = SortByDate; + m_PVRDefaultSortOrder.sortOrder = SortOrderDescending; m_cacheMemSize = 1024 * 1024 * 20; // 20 MiB m_cacheBufferMode = CACHE_BUFFER_MODE_INTERNET; // Default (buffer all internet streams/filesystems) @@ -1086,6 +1089,24 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file) XMLUtils::GetInt(pPVR, "numericchannelswitchtimeout", m_iPVRNumericChannelSwitchTimeout, 50, 60000); XMLUtils::GetInt(pPVR, "timeshiftthreshold", m_iPVRTimeshiftThreshold, 0, 60); XMLUtils::GetBoolean(pPVR, "timeshiftsimpleosd", m_bPVRTimeshiftSimpleOSD); + TiXmlElement* pSortDecription = pPVR->FirstChildElement("pvrrecordings"); + if (pSortDecription) + { + const char* XML_SORTMETHOD = "sortmethod"; + const char* XML_SORTORDER = "sortorder"; + int sortMethod; + // ignore SortByTime for duration defaults + if (XMLUtils::GetInt(pSortDecription, XML_SORTMETHOD, sortMethod, SortByLabel, SortByFile)) + { + int sortOrder; + if (XMLUtils::GetInt(pSortDecription, XML_SORTORDER, sortOrder, SortOrderAscending, + SortOrderDescending)) + { + m_PVRDefaultSortOrder.sortBy = (SortBy)sortMethod; + m_PVRDefaultSortOrder.sortOrder = (SortOrder)sortOrder; + } + } + } } TiXmlElement* pDatabase = pRootElement->FirstChildElement("videodatabase"); @@ -1421,6 +1442,7 @@ void CAdvancedSettings::MigrateOldArtSettings() thumbs2.emplace_back(it); } std::vector<CVariant> thumbs; + thumbs.reserve(thumbs2.size()); for (const auto& it : thumbs2) thumbs.emplace_back(it); settings->SetList(CSettings::SETTING_MUSICLIBRARY_MUSICTHUMBS, thumbs); diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h index d1def14e43..0f9e1bbe69 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -11,6 +11,7 @@ #include "pictures/PictureScalingAlgorithm.h" #include "settings/lib/ISettingCallback.h" #include "settings/lib/ISettingsHandler.h" +#include "utils/SortUtils.h" #include <set> #include <string> @@ -111,7 +112,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler void OnSettingsLoaded() override; void OnSettingsUnloaded() override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; void Initialize(const CAppParamParser ¶ms, CSettingsManager& settingsMgr); void Uninitialize(CSettingsManager& settingsMgr); @@ -312,6 +313,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler int m_iPVRNumericChannelSwitchTimeout; /*!< @brief time in msecs after that a channel switch occurs after entering a channel number, if confirmchannelswitch is disabled */ int m_iPVRTimeshiftThreshold; /*!< @brief time diff between current playing time and timeshift buffer end, in seconds, before a playing stream is displayed as timeshifting. */ bool m_bPVRTimeshiftSimpleOSD; /*!< @brief use simple timeshift OSD (with progress only for the playing event instead of progress for the whole ts buffer). */ + SortDescription m_PVRDefaultSortOrder; /*!< @brief SortDecription used to store default recording sort type and sort order */ + DatabaseSettings m_databaseMusic; // advanced music database setup DatabaseSettings m_databaseVideo; // advanced video database setup DatabaseSettings m_databaseTV; // advanced tv database setup diff --git a/xbmc/settings/DiscSettings.cpp b/xbmc/settings/DiscSettings.cpp index 76f2884c3c..de8bb33c80 100644 --- a/xbmc/settings/DiscSettings.cpp +++ b/xbmc/settings/DiscSettings.cpp @@ -28,7 +28,7 @@ CDiscSettings& CDiscSettings::GetInstance() return sDiscSettings; } -void CDiscSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CDiscSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { #if (BLURAY_VERSION >= BLURAY_VERSION_CODE(1,0,1)) if (setting == NULL) diff --git a/xbmc/settings/DiscSettings.h b/xbmc/settings/DiscSettings.h index a4cbad56a0..9d62eea18f 100644 --- a/xbmc/settings/DiscSettings.h +++ b/xbmc/settings/DiscSettings.h @@ -26,7 +26,7 @@ public: /* ISettingCallback*/ static CDiscSettings& GetInstance(); - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; private: CDiscSettings() = default; diff --git a/xbmc/settings/DisplaySettings.cpp b/xbmc/settings/DisplaySettings.cpp index c0696548c9..63db011a92 100644 --- a/xbmc/settings/DisplaySettings.cpp +++ b/xbmc/settings/DisplaySettings.cpp @@ -236,7 +236,7 @@ void CDisplaySettings::Clear() m_nonLinearStretched = false; } -void CDisplaySettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CDisplaySettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -264,7 +264,7 @@ void CDisplaySettings::OnSettingAction(std::shared_ptr<const CSetting> setting) } } -bool CDisplaySettings::OnSettingChanging(std::shared_ptr<const CSetting> setting) +bool CDisplaySettings::OnSettingChanging(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return false; @@ -356,7 +356,9 @@ bool CDisplaySettings::OnSettingChanging(std::shared_ptr<const CSetting> setting return true; } -bool CDisplaySettings::OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +bool CDisplaySettings::OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) { if (setting == NULL) return false; @@ -398,7 +400,17 @@ bool CDisplaySettings::OnSettingUpdate(std::shared_ptr<CSetting> setting, const return false; } -void CDisplaySettings::SetMonitor(std::string monitor) +void CDisplaySettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) +{ + if (!setting) + return; + + const std::string& settingId = setting->GetId(); + if (settingId == CSettings::SETTING_VIDEOSCREEN_WHITELIST) + CResolutionUtils::PrintWhitelist(); +} + +void CDisplaySettings::SetMonitor(const std::string& monitor) { const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); const std::string curMonitor = settings->GetString(CSettings::SETTING_VIDEOSCREEN_MONITOR); @@ -690,12 +702,15 @@ RESOLUTION CDisplaySettings::GetResolutionForScreen() return RES_DESKTOP; } -static inline bool ModeSort(StringSettingOption i,StringSettingOption j) +static inline bool ModeSort(const StringSettingOption& i, const StringSettingOption& j) { return (i.value > j.value); } -void CDisplaySettings::SettingOptionsModesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CDisplaySettings::SettingOptionsModesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { RESOLUTION res = CDisplaySettings::GetInstance().GetDisplayResolution(); RESOLUTION_INFO info = CDisplaySettings::GetInstance().GetResolutionInfo(res); @@ -717,7 +732,11 @@ void CDisplaySettings::SettingOptionsModesFiller(std::shared_ptr<const CSetting> std::sort(list.begin(), list.end(), ModeSort); } -void CDisplaySettings::SettingOptionsRefreshChangeDelaysFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsRefreshChangeDelaysFiller( + const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(13551), 0); @@ -725,7 +744,10 @@ void CDisplaySettings::SettingOptionsRefreshChangeDelaysFiller(SettingConstPtr s list.emplace_back(StringUtils::Format(g_localizeStrings.Get(13553).c_str(), static_cast<double>(i) / 10.0), i); } -void CDisplaySettings::SettingOptionsRefreshRatesFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CDisplaySettings::SettingOptionsRefreshRatesFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { // get the proper resolution RESOLUTION res = CDisplaySettings::GetInstance().GetDisplayResolution(); @@ -757,7 +779,10 @@ void CDisplaySettings::SettingOptionsRefreshRatesFiller(SettingConstPtr setting, current = GetStringFromResolution(res, CServiceBroker::GetWinSystem()->DefaultRefreshRate(refreshrates).RefreshRate); } -void CDisplaySettings::SettingOptionsResolutionsFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsResolutionsFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { RESOLUTION res = CDisplaySettings::GetInstance().GetDisplayResolution(); RESOLUTION_INFO info = CDisplaySettings::GetInstance().GetResolutionInfo(res); @@ -785,7 +810,10 @@ void CDisplaySettings::SettingOptionsResolutionsFiller(SettingConstPtr setting, } } -void CDisplaySettings::SettingOptionsDispModeFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsDispModeFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { // The user should only be able to disable windowed modes with the canwindowed // setting. When the user sets canwindowed to true but the windowing system @@ -797,7 +825,11 @@ void CDisplaySettings::SettingOptionsDispModeFiller(SettingConstPtr setting, std list.emplace_back(g_localizeStrings.Get(244), DM_FULLSCREEN); } -void CDisplaySettings::SettingOptionsStereoscopicModesFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsStereoscopicModesFiller( + const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { CGUIComponent *gui = CServiceBroker::GetGUI(); if (gui != nullptr) @@ -813,7 +845,11 @@ void CDisplaySettings::SettingOptionsStereoscopicModesFiller(SettingConstPtr set } } -void CDisplaySettings::SettingOptionsPreferredStereoscopicViewModesFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsPreferredStereoscopicViewModesFiller( + const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { const CStereoscopicsManager &stereoscopicsManager = CServiceBroker::GetGUI()->GetStereoscopicsManager(); @@ -829,7 +865,10 @@ void CDisplaySettings::SettingOptionsPreferredStereoscopicViewModesFiller(Settin } } -void CDisplaySettings::SettingOptionsMonitorsFiller(SettingConstPtr setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data) +void CDisplaySettings::SettingOptionsMonitorsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { #if defined(HAVE_X11) || defined(TARGET_DARWIN) || defined(HAVE_WAYLAND) || \ defined(TARGET_WINDOWS_DESKTOP) @@ -877,7 +916,10 @@ void CDisplaySettings::ClearCustomResolutions() } } -void CDisplaySettings::SettingOptionsCmsModesFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsCmsModesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(36580), CMS_MODE_3DLUT); #ifdef HAVE_LCMS2 @@ -885,13 +927,19 @@ void CDisplaySettings::SettingOptionsCmsModesFiller(SettingConstPtr setting, std #endif } -void CDisplaySettings::SettingOptionsCmsWhitepointsFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsCmsWhitepointsFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(36586), CMS_WHITEPOINT_D65); list.emplace_back(g_localizeStrings.Get(36587), CMS_WHITEPOINT_D93); } -void CDisplaySettings::SettingOptionsCmsPrimariesFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsCmsPrimariesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(36588), CMS_PRIMARIES_AUTO); list.emplace_back(g_localizeStrings.Get(36589), CMS_PRIMARIES_BT709); @@ -902,7 +950,10 @@ void CDisplaySettings::SettingOptionsCmsPrimariesFiller(SettingConstPtr setting, list.emplace_back(g_localizeStrings.Get(36593), CMS_PRIMARIES_240M); } -void CDisplaySettings::SettingOptionsCmsGammaModesFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CDisplaySettings::SettingOptionsCmsGammaModesFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(36582), CMS_TRC_BT1886); list.emplace_back(g_localizeStrings.Get(36583), CMS_TRC_INPUT_OFFSET); diff --git a/xbmc/settings/DisplaySettings.h b/xbmc/settings/DisplaySettings.h index 6ed0e9ee3b..e02e80c8e3 100644 --- a/xbmc/settings/DisplaySettings.h +++ b/xbmc/settings/DisplaySettings.h @@ -33,9 +33,12 @@ public: bool Save(TiXmlNode *settings) const override; void Clear() override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; - bool OnSettingChanging(std::shared_ptr<const CSetting> setting) override; - bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; + bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) override; + bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; /*! \brief Returns the currently active resolution @@ -84,20 +87,58 @@ public: void SetVerticalShift(float verticalShift) { m_verticalShift = verticalShift; } bool IsNonLinearStretched() const { return m_nonLinearStretched; } void SetNonLinearStretched(bool nonLinearStretch) { m_nonLinearStretched = nonLinearStretch; } - void SetMonitor(std::string monitor); - - static void SettingOptionsModesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsRefreshChangeDelaysFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsRefreshRatesFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsResolutionsFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsDispModeFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsStereoscopicModesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsPreferredStereoscopicViewModesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsMonitorsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption> &list, std::string ¤t, void *data); - static void SettingOptionsCmsModesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsCmsWhitepointsFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsCmsPrimariesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - static void SettingOptionsCmsGammaModesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); + void SetMonitor(const std::string& monitor); + + static void SettingOptionsModesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsRefreshChangeDelaysFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsRefreshRatesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsResolutionsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsDispModeFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsStereoscopicModesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsPreferredStereoscopicViewModesFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsMonitorsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + static void SettingOptionsCmsModesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsCmsWhitepointsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsCmsPrimariesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + static void SettingOptionsCmsGammaModesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); protected: diff --git a/xbmc/settings/MediaSettings.cpp b/xbmc/settings/MediaSettings.cpp index d842376a8f..27c5ac7bea 100644 --- a/xbmc/settings/MediaSettings.cpp +++ b/xbmc/settings/MediaSettings.cpp @@ -284,7 +284,7 @@ bool CMediaSettings::Save(TiXmlNode *settings) const return true; } -void CMediaSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CMediaSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -343,7 +343,7 @@ void CMediaSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) } } -void CMediaSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CMediaSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/settings/MediaSettings.h b/xbmc/settings/MediaSettings.h index 4f6dab4c3e..a00b2cf287 100644 --- a/xbmc/settings/MediaSettings.h +++ b/xbmc/settings/MediaSettings.h @@ -38,8 +38,8 @@ public: bool Load(const TiXmlNode *settings) override; bool Save(TiXmlNode *settings) const override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; void OnSettingsLoaded() override; const CVideoSettings& GetDefaultVideoSettings() const { return m_defaultVideoSettings; } diff --git a/xbmc/settings/SettingConditions.cpp b/xbmc/settings/SettingConditions.cpp index ebf3318107..f4c8f7dbeb 100644 --- a/xbmc/settings/SettingConditions.cpp +++ b/xbmc/settings/SettingConditions.cpp @@ -28,7 +28,10 @@ #include "utils/StringUtils.h" #include "windowing/WinSystem.h" -bool AddonHasSettings(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool AddonHasSettings(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -47,107 +50,170 @@ bool AddonHasSettings(const std::string &condition, const std::string &value, Se return addon->HasSettings(); } -bool CheckMasterLock(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool CheckMasterLock(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return g_passwordManager.IsMasterLockUnlocked(StringUtils::EqualsNoCase(value, "true")); } -bool HasPeripherals(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool HasPeripherals(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetPeripherals().GetNumberOfPeripherals() > 0; } -bool HasPeripheralLibraries(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool HasPeripheralLibraries(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetAddonMgr().HasInstalledAddons(ADDON::ADDON_PERIPHERALDLL); } -bool HasRumbleFeature(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool HasRumbleFeature(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetPeripherals().SupportsFeature(PERIPHERALS::FEATURE_RUMBLE); } -bool HasRumbleController(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool HasRumbleController(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetPeripherals().HasPeripheralWithFeature(PERIPHERALS::FEATURE_RUMBLE); } -bool HasPowerOffFeature(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool HasPowerOffFeature(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetPeripherals().SupportsFeature(PERIPHERALS::FEATURE_POWER_OFF); } -bool IsFullscreen(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool IsFullscreen(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetWinSystem()->IsFullScreen(); } -bool IsHDRDisplay(const std::string& condition, const std::string& value, SettingConstPtr setting, void* data) +bool IsHDRDisplay(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CServiceBroker::GetWinSystem()->IsHDRDisplay(); } -bool IsMasterUser(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool IsMasterUser(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return g_passwordManager.bMasterUser; } -bool IsUsingTTFSubtitles(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool IsUsingTTFSubtitles(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CUtil::IsUsingTTFSubtitles(); } -bool ProfileCanWriteDatabase(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileCanWriteDatabase(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().canWriteDatabases(); } -bool ProfileCanWriteSources(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileCanWriteSources(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().canWriteSources(); } -bool ProfileHasAddons(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasAddons(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().hasAddons(); } -bool ProfileHasDatabase(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasDatabase(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().hasDatabases(); } -bool ProfileHasSources(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasSources(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().hasSources(); } -bool ProfileHasAddonManagerLocked(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasAddonManagerLocked(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().addonmanagerLocked(); } -bool ProfileHasFilesLocked(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasFilesLocked(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().filesLocked(); } -bool ProfileHasMusicLocked(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasMusicLocked(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().musicLocked(); } -bool ProfileHasPicturesLocked(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasPicturesLocked(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().picturesLocked(); } -bool ProfileHasProgramsLocked(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasProgramsLocked(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().programsLocked(); } -bool ProfileHasSettingsLocked(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasSettingsLocked(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { LOCK_LEVEL::SETTINGS_LOCK slValue=LOCK_LEVEL::ALL; if (StringUtils::EqualsNoCase(value, "none")) @@ -161,12 +227,18 @@ bool ProfileHasSettingsLocked(const std::string &condition, const std::string &v return slValue <= CSettingConditions::GetCurrentProfile().settingsLockLevel(); } -bool ProfileHasVideosLocked(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileHasVideosLocked(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return CSettingConditions::GetCurrentProfile().videoLocked(); } -bool ProfileLockMode(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool ProfileLockMode(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { char *tmp = NULL; LockType lock = (LockType)strtol(value.c_str(), &tmp, 0); @@ -176,7 +248,10 @@ bool ProfileLockMode(const std::string &condition, const std::string &value, Set return CSettingConditions::GetCurrentProfile().getLockMode() == lock; } -bool GreaterThan(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool GreaterThan(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -193,7 +268,10 @@ bool GreaterThan(const std::string &condition, const std::string &value, Setting return lhs > rhs; } -bool GreaterThanOrEqual(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool GreaterThanOrEqual(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -210,7 +288,10 @@ bool GreaterThanOrEqual(const std::string &condition, const std::string &value, return lhs >= rhs; } -bool LessThan(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool LessThan(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -227,7 +308,10 @@ bool LessThan(const std::string &condition, const std::string &value, SettingCon return lhs < rhs; } -bool LessThanOrEqual(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool LessThanOrEqual(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { if (setting == NULL) return false; @@ -380,7 +464,9 @@ const CProfile& CSettingConditions::GetCurrentProfile() return emptyProfile; } -bool CSettingConditions::Check(const std::string &condition, const std::string &value /* = "" */, SettingConstPtr setting /* = NULL */) +bool CSettingConditions::Check(const std::string& condition, + const std::string& value /* = "" */, + const SettingConstPtr& setting /* = NULL */) { if (m_simpleConditions.find(condition) != m_simpleConditions.end()) return true; diff --git a/xbmc/settings/SettingConditions.h b/xbmc/settings/SettingConditions.h index 7eb3bc4fcc..f51d9e0eaf 100644 --- a/xbmc/settings/SettingConditions.h +++ b/xbmc/settings/SettingConditions.h @@ -27,7 +27,9 @@ public: static const std::set<std::string>& GetSimpleConditions() { return m_simpleConditions; } static const std::map<std::string, SettingConditionCheck>& GetComplexConditions() { return m_complexConditions; } - static bool Check(const std::string &condition, const std::string &value = "", std::shared_ptr<const CSetting> setting = NULL); + static bool Check(const std::string& condition, + const std::string& value = "", + const std::shared_ptr<const CSetting>& setting = NULL); private: // Initialization parameters diff --git a/xbmc/settings/SettingControl.h b/xbmc/settings/SettingControl.h index 751bb49673..73dd98d494 100644 --- a/xbmc/settings/SettingControl.h +++ b/xbmc/settings/SettingControl.h @@ -168,7 +168,8 @@ protected: }; class CSetting; -using SettingControlListValueFormatter = std::string (*)(std::shared_ptr<const CSetting> setting); +using SettingControlListValueFormatter = + std::string (*)(const std::shared_ptr<const CSetting>& setting); class CSettingControlList : public CSettingControlFormattedRange { @@ -204,7 +205,12 @@ protected: }; class CSettingControlSlider; -using SettingControlSliderFormatter = std::string (*)(std::shared_ptr<const CSettingControlSlider> control, const CVariant &value, const CVariant &minimum, const CVariant &step, const CVariant &maximum); +using SettingControlSliderFormatter = + std::string (*)(const std::shared_ptr<const CSettingControlSlider>& control, + const CVariant& value, + const CVariant& minimum, + const CVariant& step, + const CVariant& maximum); class CSettingControlSlider : public ISettingControl { diff --git a/xbmc/settings/SettingPath.cpp b/xbmc/settings/SettingPath.cpp index 378d53b149..dc0d7a349c 100644 --- a/xbmc/settings/SettingPath.cpp +++ b/xbmc/settings/SettingPath.cpp @@ -68,7 +68,7 @@ bool CSettingPath::Deserialize(const TiXmlNode *node, bool update /* = false */) auto child = source->FirstChild(); if (child != nullptr) { - std::string strSource = child->ValueStr(); + const std::string& strSource = child->ValueStr(); if (!strSource.empty()) m_sources.push_back(strSource); } @@ -102,9 +102,9 @@ std::string CSettingPath::GetMasking(const CFileExtensionProvider& fileExtension return m_masking; // setup masking - const auto audioMask = fileExtensionProvider.GetMusicExtensions(); - const auto videoMask = fileExtensionProvider.GetVideoExtensions(); - const auto imageMask = fileExtensionProvider.GetPictureExtensions(); + auto audioMask = fileExtensionProvider.GetMusicExtensions(); + auto videoMask = fileExtensionProvider.GetVideoExtensions(); + auto imageMask = fileExtensionProvider.GetPictureExtensions(); auto execMask = ""; #if defined(TARGET_WINDOWS) execMask = ".exe|.bat|.cmd|.py"; diff --git a/xbmc/settings/SettingUtils.cpp b/xbmc/settings/SettingUtils.cpp index 2aebb1c385..a98005fa93 100644 --- a/xbmc/settings/SettingUtils.cpp +++ b/xbmc/settings/SettingUtils.cpp @@ -14,12 +14,13 @@ #include <algorithm> -std::vector<CVariant> CSettingUtils::GetList(std::shared_ptr<const CSettingList> settingList) +std::vector<CVariant> CSettingUtils::GetList(const std::shared_ptr<const CSettingList>& settingList) { return ListToValues(settingList, settingList->GetValue()); } -bool CSettingUtils::SetList(std::shared_ptr<CSettingList> settingList, const std::vector<CVariant> &value) +bool CSettingUtils::SetList(const std::shared_ptr<CSettingList>& settingList, + const std::vector<CVariant>& value) { SettingList newValues; if (!ValuesToList(settingList, value, newValues)) @@ -28,7 +29,9 @@ bool CSettingUtils::SetList(std::shared_ptr<CSettingList> settingList, const std return settingList->SetValue(newValues); } -std::vector<CVariant> CSettingUtils::ListToValues(std::shared_ptr<const CSettingList> setting, const std::vector< std::shared_ptr<CSetting> > &values) +std::vector<CVariant> CSettingUtils::ListToValues( + const std::shared_ptr<const CSettingList>& setting, + const std::vector<std::shared_ptr<CSetting>>& values) { std::vector<CVariant> realValues; @@ -63,8 +66,9 @@ std::vector<CVariant> CSettingUtils::ListToValues(std::shared_ptr<const CSetting return realValues; } -bool CSettingUtils::ValuesToList(std::shared_ptr<const CSettingList> setting, const std::vector<CVariant> &values, - std::vector< std::shared_ptr<CSetting> > &newValues) +bool CSettingUtils::ValuesToList(const std::shared_ptr<const CSettingList>& setting, + const std::vector<CVariant>& values, + std::vector<std::shared_ptr<CSetting>>& newValues) { if (setting == NULL) return false; @@ -121,7 +125,7 @@ bool CSettingUtils::ValuesToList(std::shared_ptr<const CSettingList> setting, co return true; } -bool CSettingUtils::FindIntInList(std::shared_ptr<const CSettingList> settingList, int value) +bool CSettingUtils::FindIntInList(const std::shared_ptr<const CSettingList>& settingList, int value) { if (settingList == nullptr || settingList->GetElementType() != SettingType::Integer) return false; diff --git a/xbmc/settings/SettingUtils.h b/xbmc/settings/SettingUtils.h index 2bc731349b..d7e456bb1f 100644 --- a/xbmc/settings/SettingUtils.h +++ b/xbmc/settings/SettingUtils.h @@ -24,7 +24,7 @@ public: \param settingList List setting \return List of values of the given list setting */ - static std::vector<CVariant> GetList(std::shared_ptr<const CSettingList> settingList); + static std::vector<CVariant> GetList(const std::shared_ptr<const CSettingList>& settingList); /*! \brief Sets the values of the given list setting. @@ -32,10 +32,14 @@ public: \param value Values to set \return True if setting the values was successful, false otherwise */ - static bool SetList(std::shared_ptr<CSettingList> settingList, const std::vector<CVariant> &value); + static bool SetList(const std::shared_ptr<CSettingList>& settingList, + const std::vector<CVariant>& value); - static std::vector<CVariant> ListToValues(std::shared_ptr<const CSettingList> setting, const std::vector< std::shared_ptr<CSetting> > &values); - static bool ValuesToList(std::shared_ptr<const CSettingList> setting, const std::vector<CVariant> &values, std::vector< std::shared_ptr<CSetting> > &newValues); + static std::vector<CVariant> ListToValues(const std::shared_ptr<const CSettingList>& setting, + const std::vector<std::shared_ptr<CSetting>>& values); + static bool ValuesToList(const std::shared_ptr<const CSettingList>& setting, + const std::vector<CVariant>& values, + std::vector<std::shared_ptr<CSetting>>& newValues); /*! \brief Search in a list of Ints for a given value. @@ -44,5 +48,5 @@ public: \param value value to search for \return True if value was found in list, false otherwise */ - static bool FindIntInList(std::shared_ptr<const CSettingList> settingList, int value); + static bool FindIntInList(const std::shared_ptr<const CSettingList>& settingList, int value); }; diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index 57852a5f5e..1d2e681965 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -230,6 +230,7 @@ const std::string CSettings::SETTING_PVRRECORD_TIMERNOTIFICATIONS = "pvrrecord.t const std::string CSettings::SETTING_PVRRECORD_GROUPRECORDINGS = "pvrrecord.grouprecordings"; const std::string CSettings::SETTING_PVRREMINDERS_AUTOCLOSEDELAY = "pvrreminders.autoclosedelay"; const std::string CSettings::SETTING_PVRREMINDERS_AUTORECORD = "pvrreminders.autorecord"; +const std::string CSettings::SETTING_PVRREMINDERS_AUTOSWITCH = "pvrreminders.autoswitch"; const std::string CSettings::SETTING_PVRPOWERMANAGEMENT_ENABLED = "pvrpowermanagement.enabled"; const std::string CSettings::SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME = "pvrpowermanagement.backendidletime"; const std::string CSettings::SETTING_PVRPOWERMANAGEMENT_SETWAKEUPCMD = "pvrpowermanagement.setwakeupcmd"; @@ -940,6 +941,7 @@ void CSettings::InitializeISettingCallbacks() settingSet.insert(CSettings::SETTING_VIDEOSCREEN_3DLUT); settingSet.insert(CSettings::SETTING_VIDEOSCREEN_DISPLAYPROFILE); settingSet.insert(CSettings::SETTING_VIDEOSCREEN_BLANKDISPLAYS); + settingSet.insert(CSettings::SETTING_VIDEOSCREEN_WHITELIST); GetSettingsManager()->RegisterCallback(&CDisplaySettings::GetInstance(), settingSet); settingSet.clear(); diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h index 4fbb277ba2..a5e419964c 100644 --- a/xbmc/settings/Settings.h +++ b/xbmc/settings/Settings.h @@ -191,6 +191,7 @@ public: static const std::string SETTING_PVRRECORD_GROUPRECORDINGS; static const std::string SETTING_PVRREMINDERS_AUTOCLOSEDELAY; static const std::string SETTING_PVRREMINDERS_AUTORECORD; + static const std::string SETTING_PVRREMINDERS_AUTOSWITCH; static const std::string SETTING_PVRPOWERMANAGEMENT_ENABLED; static const std::string SETTING_PVRPOWERMANAGEMENT_BACKENDIDLETIME; static const std::string SETTING_PVRPOWERMANAGEMENT_SETWAKEUPCMD; diff --git a/xbmc/settings/SettingsValueFlatJsonSerializer.cpp b/xbmc/settings/SettingsValueFlatJsonSerializer.cpp index 13c382fd0c..736c37d746 100644 --- a/xbmc/settings/SettingsValueFlatJsonSerializer.cpp +++ b/xbmc/settings/SettingsValueFlatJsonSerializer.cpp @@ -44,7 +44,7 @@ std::string CSettingsValueFlatJsonSerializer::SerializeValues( } void CSettingsValueFlatJsonSerializer::SerializeSection( - CVariant& parent, std::shared_ptr<CSettingSection> section) const + CVariant& parent, const std::shared_ptr<CSettingSection>& section) const { if (section == nullptr) return; @@ -55,7 +55,7 @@ void CSettingsValueFlatJsonSerializer::SerializeSection( } void CSettingsValueFlatJsonSerializer::SerializeCategory( - CVariant& parent, std::shared_ptr<CSettingCategory> category) const + CVariant& parent, const std::shared_ptr<CSettingCategory>& category) const { if (category == nullptr) return; @@ -66,7 +66,7 @@ void CSettingsValueFlatJsonSerializer::SerializeCategory( } void CSettingsValueFlatJsonSerializer::SerializeGroup( - CVariant& parent, std::shared_ptr<CSettingGroup> group) const + CVariant& parent, const std::shared_ptr<CSettingGroup>& group) const { if (group == nullptr) return; @@ -77,7 +77,7 @@ void CSettingsValueFlatJsonSerializer::SerializeGroup( } void CSettingsValueFlatJsonSerializer::SerializeSetting( - CVariant& parent, std::shared_ptr<CSetting> setting) const + CVariant& parent, const std::shared_ptr<CSetting>& setting) const { if (setting == nullptr) return; @@ -94,7 +94,7 @@ void CSettingsValueFlatJsonSerializer::SerializeSetting( } CVariant CSettingsValueFlatJsonSerializer::SerializeSettingValue( - std::shared_ptr<CSetting> setting) const + const std::shared_ptr<CSetting>& setting) const { switch (setting->GetType()) { diff --git a/xbmc/settings/SettingsValueFlatJsonSerializer.h b/xbmc/settings/SettingsValueFlatJsonSerializer.h index 5708224b06..05214ab887 100644 --- a/xbmc/settings/SettingsValueFlatJsonSerializer.h +++ b/xbmc/settings/SettingsValueFlatJsonSerializer.h @@ -30,11 +30,11 @@ public: std::string SerializeValues(const CSettingsManager* settingsManager) const override; private: - void SerializeSection(CVariant& parent, std::shared_ptr<CSettingSection> section) const; - void SerializeCategory(CVariant& parent, std::shared_ptr<CSettingCategory> category) const; - void SerializeGroup(CVariant& parent, std::shared_ptr<CSettingGroup> group) const; - void SerializeSetting(CVariant& parent, std::shared_ptr<CSetting> setting) const; - CVariant SerializeSettingValue(std::shared_ptr<CSetting> setting) const; + void SerializeSection(CVariant& parent, const std::shared_ptr<CSettingSection>& section) const; + void SerializeCategory(CVariant& parent, const std::shared_ptr<CSettingCategory>& category) const; + void SerializeGroup(CVariant& parent, const std::shared_ptr<CSettingGroup>& group) const; + void SerializeSetting(CVariant& parent, const std::shared_ptr<CSetting>& setting) const; + CVariant SerializeSettingValue(const std::shared_ptr<CSetting>& setting) const; bool m_compact; }; diff --git a/xbmc/settings/SettingsValueXmlSerializer.cpp b/xbmc/settings/SettingsValueXmlSerializer.cpp index cd224bfe34..42f83e31b8 100644 --- a/xbmc/settings/SettingsValueXmlSerializer.cpp +++ b/xbmc/settings/SettingsValueXmlSerializer.cpp @@ -41,7 +41,7 @@ std::string CSettingsValueXmlSerializer::SerializeValues( } void CSettingsValueXmlSerializer::SerializeSection( - TiXmlNode* parent, std::shared_ptr<CSettingSection> section) const + TiXmlNode* parent, const std::shared_ptr<CSettingSection>& section) const { if (section == nullptr) return; @@ -52,7 +52,7 @@ void CSettingsValueXmlSerializer::SerializeSection( } void CSettingsValueXmlSerializer::SerializeCategory( - TiXmlNode* parent, std::shared_ptr<CSettingCategory> category) const + TiXmlNode* parent, const std::shared_ptr<CSettingCategory>& category) const { if (category == nullptr) return; @@ -62,8 +62,8 @@ void CSettingsValueXmlSerializer::SerializeCategory( SerializeGroup(parent, group); } -void CSettingsValueXmlSerializer::SerializeGroup( - TiXmlNode* parent, std::shared_ptr<CSettingGroup> group) const +void CSettingsValueXmlSerializer::SerializeGroup(TiXmlNode* parent, + const std::shared_ptr<CSettingGroup>& group) const { if (group == nullptr) return; @@ -73,8 +73,8 @@ void CSettingsValueXmlSerializer::SerializeGroup( SerializeSetting(parent, setting); } -void CSettingsValueXmlSerializer::SerializeSetting( - TiXmlNode* parent, std::shared_ptr<CSetting> setting) const +void CSettingsValueXmlSerializer::SerializeSetting(TiXmlNode* parent, + const std::shared_ptr<CSetting>& setting) const { if (setting == nullptr) return; diff --git a/xbmc/settings/SettingsValueXmlSerializer.h b/xbmc/settings/SettingsValueXmlSerializer.h index 7ab8687c5f..010c036775 100644 --- a/xbmc/settings/SettingsValueXmlSerializer.h +++ b/xbmc/settings/SettingsValueXmlSerializer.h @@ -28,8 +28,9 @@ public: std::string SerializeValues(const CSettingsManager* settingsManager) const override; private: - void SerializeSection(TiXmlNode* parent, std::shared_ptr<CSettingSection> section) const; - void SerializeCategory(TiXmlNode* parent, std::shared_ptr<CSettingCategory> category) const; - void SerializeGroup(TiXmlNode* parent, std::shared_ptr<CSettingGroup> group) const; - void SerializeSetting(TiXmlNode* parent, std::shared_ptr<CSetting> setting) const; + void SerializeSection(TiXmlNode* parent, const std::shared_ptr<CSettingSection>& section) const; + void SerializeCategory(TiXmlNode* parent, + const std::shared_ptr<CSettingCategory>& category) const; + void SerializeGroup(TiXmlNode* parent, const std::shared_ptr<CSettingGroup>& group) const; + void SerializeSetting(TiXmlNode* parent, const std::shared_ptr<CSetting>& setting) const; }; diff --git a/xbmc/settings/dialogs/GUIDialogContentSettings.cpp b/xbmc/settings/dialogs/GUIDialogContentSettings.cpp index 3bb2846f02..7897754874 100644 --- a/xbmc/settings/dialogs/GUIDialogContentSettings.cpp +++ b/xbmc/settings/dialogs/GUIDialogContentSettings.cpp @@ -149,7 +149,7 @@ void CGUIDialogContentSettings::OnInitWindow() CGUIDialogSettingsManualBase::OnInitWindow(); } -void CGUIDialogContentSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogContentSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -174,7 +174,7 @@ void CGUIDialogContentSettings::OnSettingChanged(std::shared_ptr<const CSetting> m_allExternalAudio = std::static_pointer_cast<const CSettingBool>(setting)->GetValue(); } -void CGUIDialogContentSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogContentSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/settings/dialogs/GUIDialogContentSettings.h b/xbmc/settings/dialogs/GUIDialogContentSettings.h index 97f7dbe30b..1c4401c70f 100644 --- a/xbmc/settings/dialogs/GUIDialogContentSettings.h +++ b/xbmc/settings/dialogs/GUIDialogContentSettings.h @@ -12,6 +12,7 @@ #include "settings/dialogs/GUIDialogSettingsManualBase.h" #include <map> +#include <utility> namespace VIDEO { @@ -32,7 +33,7 @@ public: void ResetContent(); const ADDON::ScraperPtr& GetScraper() const { return m_scraper; } - void SetScraper(ADDON::ScraperPtr scraper) { m_scraper = scraper; } + void SetScraper(ADDON::ScraperPtr scraper) { m_scraper = std::move(scraper); } void SetScanSettings(const VIDEO::SScanSettings &scanSettings); bool GetScanRecursive() const { return m_scanRecursive; } @@ -50,8 +51,8 @@ protected: void OnInitWindow() override; // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } diff --git a/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp b/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp index cce70b1744..432413a077 100644 --- a/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +++ b/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp @@ -79,7 +79,7 @@ void CGUIDialogLibExportSettings::OnInitWindow() CGUIDialogSettingsManualBase::OnInitWindow(); } -void CGUIDialogLibExportSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogLibExportSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (!setting) return; @@ -136,7 +136,7 @@ void CGUIDialogLibExportSettings::OnSettingChanged(std::shared_ptr<const CSettin } } -void CGUIDialogLibExportSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogLibExportSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -427,7 +427,7 @@ void CGUIDialogLibExportSettings::SetFocus(const std::string &settingid) SET_CONTROL_FOCUS(settingControl->GetID(), 0); } -int CGUIDialogLibExportSettings::GetExportItemsFromSetting(SettingConstPtr setting) +int CGUIDialogLibExportSettings::GetExportItemsFromSetting(const SettingConstPtr& setting) { std::shared_ptr<const CSettingList> settingList = std::static_pointer_cast<const CSettingList>(setting); if (settingList->GetElementType() != SettingType::Integer) diff --git a/xbmc/settings/dialogs/GUIDialogLibExportSettings.h b/xbmc/settings/dialogs/GUIDialogLibExportSettings.h index 666476311e..f948057af3 100644 --- a/xbmc/settings/dialogs/GUIDialogLibExportSettings.h +++ b/xbmc/settings/dialogs/GUIDialogLibExportSettings.h @@ -27,8 +27,8 @@ protected: void OnInitWindow() override; // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool OnMessage(CGUIMessage& message) override; @@ -49,7 +49,7 @@ private: using CGUIDialogSettingsManualBase::SetFocus; void SetFocus(const std::string &settingid); - static int GetExportItemsFromSetting(SettingConstPtr setting); + static int GetExportItemsFromSetting(const SettingConstPtr& setting); void UpdateToggles(); void UpdateDescription(); diff --git a/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp b/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp index ecd060a859..a0a523c888 100644 --- a/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp +++ b/xbmc/settings/dialogs/GUIDialogSettingsBase.cpp @@ -495,7 +495,7 @@ void CGUIDialogSettingsBase::OnTimeout() UpdateSettingControl(m_delayedSetting, true); } -void CGUIDialogSettingsBase::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogSettingsBase::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL || setting->GetType() == SettingType::Unknown || setting->GetType() == SettingType::Action) @@ -504,8 +504,8 @@ void CGUIDialogSettingsBase::OnSettingChanged(std::shared_ptr<const CSetting> se UpdateSettingControl(setting->GetId(), true); } -void CGUIDialogSettingsBase::OnSettingPropertyChanged(std::shared_ptr<const CSetting> setting, - const char* propertyName) +void CGUIDialogSettingsBase::OnSettingPropertyChanged( + const std::shared_ptr<const CSetting>& setting, const char* propertyName) { if (setting == NULL || propertyName == NULL) return; @@ -606,7 +606,7 @@ std::set<std::string> CGUIDialogSettingsBase::CreateSettings() return settingMap; } -std::string CGUIDialogSettingsBase::GetSettingsLabel(std::shared_ptr<ISetting> pSetting) +std::string CGUIDialogSettingsBase::GetSettingsLabel(const std::shared_ptr<ISetting>& pSetting) { return GetLocalizedString(pSetting->GetLabel()); } @@ -626,7 +626,7 @@ void CGUIDialogSettingsBase::UpdateSettings() } } -CGUIControl* CGUIDialogSettingsBase::AddSetting(std::shared_ptr<CSetting> pSetting, +CGUIControl* CGUIDialogSettingsBase::AddSetting(const std::shared_ptr<CSetting>& pSetting, float width, int& iControlID) { @@ -777,7 +777,7 @@ CGUIControl* CGUIDialogSettingsBase::AddSeparator(float width, int& iControlID) width, iControlID); } -CGUIControl* CGUIDialogSettingsBase::AddGroupLabel(std::shared_ptr<CSettingGroup> group, +CGUIControl* CGUIDialogSettingsBase::AddGroupLabel(const std::shared_ptr<CSettingGroup>& group, float width, int& iControlID) { @@ -846,7 +846,7 @@ void CGUIDialogSettingsBase::OnResetSettings() } } -void CGUIDialogSettingsBase::OnClick(BaseSettingControlPtr pSettingControl) +void CGUIDialogSettingsBase::OnClick(const BaseSettingControlPtr& pSettingControl) { if (AllowResettingSettings() && pSettingControl->GetSetting()->GetId() == SETTINGS_RESET_SETTING_ID) @@ -892,7 +892,7 @@ void CGUIDialogSettingsBase::UpdateSettingControl(const std::string& settingId, return UpdateSettingControl(GetSettingControl(settingId), updateDisplayOnly); } -void CGUIDialogSettingsBase::UpdateSettingControl(BaseSettingControlPtr pSettingControl, +void CGUIDialogSettingsBase::UpdateSettingControl(const BaseSettingControlPtr& pSettingControl, bool updateDisplayOnly /* = false */) { if (pSettingControl == NULL) diff --git a/xbmc/settings/dialogs/GUIDialogSettingsBase.h b/xbmc/settings/dialogs/GUIDialogSettingsBase.h index 56a92282d9..940091f10f 100644 --- a/xbmc/settings/dialogs/GUIDialogSettingsBase.h +++ b/xbmc/settings/dialogs/GUIDialogSettingsBase.h @@ -83,8 +83,8 @@ protected: void OnTimeout() override; // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingPropertyChanged(std::shared_ptr<const CSetting> setting, + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting, const char* propertyName) override; // new virtual methods @@ -112,9 +112,11 @@ protected: \param pSetting Base settings class which need the name \return Name used on settings dialog */ - virtual std::string GetSettingsLabel(std::shared_ptr<ISetting> pSetting); + virtual std::string GetSettingsLabel(const std::shared_ptr<ISetting>& pSetting); - virtual CGUIControl* AddSetting(std::shared_ptr<CSetting> pSetting, float width, int& iControlID); + virtual CGUIControl* AddSetting(const std::shared_ptr<CSetting>& pSetting, + float width, + int& iControlID); virtual CGUIControl* AddSettingControl(CGUIControl* pControl, BaseSettingControlPtr pSettingControl, float width, @@ -141,17 +143,20 @@ protected: \param pSettingControl Setting control that has been interacted with */ - virtual void OnClick(BaseSettingControlPtr pSettingControl); + virtual void OnClick(const BaseSettingControlPtr& pSettingControl); void UpdateSettingControl(const std::string& settingId, bool updateDisplayOnly = false); - void UpdateSettingControl(BaseSettingControlPtr pSettingControl, bool updateDisplayOnly = false); + void UpdateSettingControl(const BaseSettingControlPtr& pSettingControl, + bool updateDisplayOnly = false); void SetControlLabel(int controlId, const CVariant& label); BaseSettingControlPtr GetSettingControl(const std::string& setting); BaseSettingControlPtr GetSettingControl(int controlId); CGUIControl* AddSeparator(float width, int& iControlID); - CGUIControl* AddGroupLabel(std::shared_ptr<CSettingGroup> group, float width, int& iControlID); + CGUIControl* AddGroupLabel(const std::shared_ptr<CSettingGroup>& group, + float width, + int& iControlID); std::vector<std::shared_ptr<CSettingCategory>> m_categories; std::vector<BaseSettingControlPtr> m_settingControls; diff --git a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp index 0ee7f4a362..35d6379e9d 100644 --- a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp +++ b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp @@ -88,7 +88,11 @@ SettingCategoryPtr CGUIDialogSettingsManualBase::AddCategory(const std::string & return category; } -SettingGroupPtr CGUIDialogSettingsManualBase::AddGroup(SettingCategoryPtr category, int label /* = -1 */, int help /* = -1 */, bool separatorBelowLabel /* = true */, bool hideSeparator /* = false */) +SettingGroupPtr CGUIDialogSettingsManualBase::AddGroup(const SettingCategoryPtr& category, + int label /* = -1 */, + int help /* = -1 */, + bool separatorBelowLabel /* = true */, + bool hideSeparator /* = false */) { if (category == NULL) return NULL; @@ -109,8 +113,14 @@ SettingGroupPtr CGUIDialogSettingsManualBase::AddGroup(SettingCategoryPtr catego return group; } -std::shared_ptr<CSettingBool> CGUIDialogSettingsManualBase::AddToggle(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, bool value, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingBool> CGUIDialogSettingsManualBase::AddToggle(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + bool value, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -127,9 +137,20 @@ std::shared_ptr<CSettingBool> CGUIDialogSettingsManualBase::AddToggle(SettingGro return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddEdit(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, - int minimum /* = 0 */, int step /* = 1 */, int maximum /* = 0 */, bool verifyNewValue /* = false */, - int heading /* = -1 */, bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddEdit( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int minimum /* = 0 */, + int step /* = 1 */, + int maximum /* = 0 */, + bool verifyNewValue /* = false */, + int heading /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -146,10 +167,20 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddEdit(SettingGroupP return setting; } -std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddEdit(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float value, - float minimum /* = 0.0f */, float step /* = 1.0f */, float maximum /* = 0.0f */, - bool verifyNewValue /* = false */, int heading /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddEdit( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float value, + float minimum /* = 0.0f */, + float step /* = 1.0f */, + float maximum /* = 0.0f */, + bool verifyNewValue /* = false */, + int heading /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -166,9 +197,17 @@ std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddEdit(SettingGro return setting; } -std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddEdit(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, - bool allowEmpty /* = false */, bool hidden /* = false */, - int heading /* = -1 */, bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddEdit(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty /* = false */, + bool hidden /* = false */, + int heading /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -186,9 +225,16 @@ std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddEdit(SettingGro return setting; } -std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddIp(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, - bool allowEmpty /* = false */, int heading /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddIp(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty /* = false */, + int heading /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -206,9 +252,17 @@ std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddIp(SettingGroup return setting; } -std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddPasswordMd5(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, - bool allowEmpty /* = false */, int heading /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddPasswordMd5( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty /* = false */, + int heading /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -226,8 +280,15 @@ std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddPasswordMd5(Set return setting; } -std::shared_ptr<CSettingAction> CGUIDialogSettingsManualBase::AddButton(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, const std::string& data /* = "" */, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingAction> CGUIDialogSettingsManualBase::AddButton( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& data /* = "" */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -245,8 +306,14 @@ std::shared_ptr<CSettingAction> CGUIDialogSettingsManualBase::AddButton(SettingG return setting; } -std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddInfoLabelButton(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string info, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddInfoLabelButton( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& info, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -263,10 +330,22 @@ std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddInfoLabelButton return setting; } -std::shared_ptr<CSettingAddon> CGUIDialogSettingsManualBase::AddAddon(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, ADDON::TYPE addonType, - bool allowEmpty /* = false */, int heading /* = -1 */, bool hideValue /* = false */, bool showInstalledAddons /* = true */, - bool showInstallableAddons /* = false */, bool showMoreAddons /* = true */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingAddon> CGUIDialogSettingsManualBase::AddAddon( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + ADDON::TYPE addonType, + bool allowEmpty /* = false */, + int heading /* = -1 */, + bool hideValue /* = false */, + bool showInstalledAddons /* = true */, + bool showInstallableAddons /* = false */, + bool showMoreAddons /* = true */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -285,10 +364,20 @@ std::shared_ptr<CSettingAddon> CGUIDialogSettingsManualBase::AddAddon(SettingGro return setting; } -std::shared_ptr<CSettingPath> CGUIDialogSettingsManualBase::AddPath(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, bool writable /* = true */, - const std::vector<std::string> &sources /* = std::vector<std::string>() */, bool allowEmpty /* = false */, - int heading /* = -1 */, bool hideValue /* = false */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingPath> CGUIDialogSettingsManualBase::AddPath( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool writable /* = true */, + const std::vector<std::string>& sources /* = std::vector<std::string>() */, + bool allowEmpty /* = false */, + int heading /* = -1 */, + bool hideValue /* = false */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -308,9 +397,16 @@ std::shared_ptr<CSettingPath> CGUIDialogSettingsManualBase::AddPath(SettingGroup return setting; } -std::shared_ptr<CSettingDate> CGUIDialogSettingsManualBase::AddDate(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, - bool allowEmpty /* = false */, int heading /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingDate> CGUIDialogSettingsManualBase::AddDate(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty /* = false */, + int heading /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) return NULL; @@ -327,9 +423,16 @@ std::shared_ptr<CSettingDate> CGUIDialogSettingsManualBase::AddDate(SettingGroup return setting; } -std::shared_ptr<CSettingTime> CGUIDialogSettingsManualBase::AddTime(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, - bool allowEmpty /* = false */, int heading /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingTime> CGUIDialogSettingsManualBase::AddTime(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty /* = false */, + int heading /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) return NULL; @@ -346,8 +449,16 @@ std::shared_ptr<CSettingTime> CGUIDialogSettingsManualBase::AddTime(SettingGroup return setting; } -std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, - StringSettingOptionsFiller filler, bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddSpinner( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + StringSettingOptionsFiller filler, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -365,9 +476,19 @@ std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddSpinner(Setting return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, int minimum, int step, int maximum, - int formatLabel /* = -1 */, int minimumLabel /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int minimum, + int step, + int maximum, + int formatLabel /* = -1 */, + int minimumLabel /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -387,9 +508,20 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGro return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, int minimum, int step, int maximum, - const std::string &formatString, int minimumLabel /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int minimum, + int step, + int maximum, + const std::string& formatString, + int minimumLabel /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -409,8 +541,16 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGro return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, const TranslatableIntegerSettingOptions &entries, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const TranslatableIntegerSettingOptions& entries, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -428,8 +568,16 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGro return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, const IntegerSettingOptions &entries, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const IntegerSettingOptions& entries, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -447,8 +595,16 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGro return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, IntegerSettingOptionsFiller filler, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + IntegerSettingOptionsFiller filler, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -466,9 +622,20 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSpinner(SettingGro return setting; } -std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float value, float minimum, float step, float maximum, - int formatLabel /* = -1 */, int minimumLabel /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSpinner( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float value, + float minimum, + float step, + float maximum, + int formatLabel /* = -1 */, + int minimumLabel /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -488,9 +655,20 @@ std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSpinner(Setting return setting; } -std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSpinner(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float value, float minimum, float step, float maximum, - const std::string &formatString, int minimumLabel /* = -1 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSpinner( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float value, + float minimum, + float step, + float maximum, + const std::string& formatString, + int minimumLabel /* = -1 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -510,8 +688,16 @@ std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSpinner(Setting return setting; } -std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::string value, - StringSettingOptionsFiller filler, int heading, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + StringSettingOptionsFiller filler, + int heading, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -529,8 +715,16 @@ std::shared_ptr<CSettingString> CGUIDialogSettingsManualBase::AddList(SettingGro return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, const TranslatableIntegerSettingOptions &entries, - int heading, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const TranslatableIntegerSettingOptions& entries, + int heading, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -548,8 +742,16 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList(SettingGroupP return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, const IntegerSettingOptions &entries, - int heading, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const IntegerSettingOptions& entries, + int heading, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -567,8 +769,16 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList(SettingGroupP return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, IntegerSettingOptionsFiller filler, - int heading, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + IntegerSettingOptionsFiller filler, + int heading, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -586,9 +796,18 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddList(SettingGroupP return setting; } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::vector<std::string> values, - StringSettingOptionsFiller filler, int heading, int minimumItems /* = 0 */, int maximumItems /* = -1 */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<std::string> values, + StringSettingOptionsFiller filler, + int heading, + int minimumItems /* = 0 */, + int maximumItems /* = -1 */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -622,9 +841,18 @@ std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroup return setting; } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::vector<int> values, - const TranslatableIntegerSettingOptions &entries, int heading, int minimumItems /* = 0 */, int maximumItems /* = -1 */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<int> values, + const TranslatableIntegerSettingOptions& entries, + int heading, + int minimumItems /* = 0 */, + int maximumItems /* = -1 */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -658,9 +886,18 @@ std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroup return setting; } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::vector<int> values, - const IntegerSettingOptions &entries, int heading, int minimumItems /* = 0 */, int maximumItems /* = -1 */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<int> values, + const IntegerSettingOptions& entries, + int heading, + int minimumItems /* = 0 */, + int maximumItems /* = -1 */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -694,9 +931,19 @@ std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroup return setting; } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, std::vector<int> values, - IntegerSettingOptionsFiller filler, int heading, int minimumItems /* = 0 */, int maximumItems /* = -1 */, - bool visible /* = true */, int help /* = -1 */, SettingControlListValueFormatter formatter /* = NULL */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<int> values, + IntegerSettingOptionsFiller filler, + int heading, + int minimumItems /* = 0 */, + int maximumItems /* = -1 */, + bool visible /* = true */, + int help /* = -1 */, + SettingControlListValueFormatter formatter /* = NULL */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -730,9 +977,19 @@ std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddList(SettingGroup return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddPercentageSlider(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, int formatLabel, - int step /* = 1 */, int heading /* = -1 */, bool usePopup /* = false */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddPercentageSlider( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int formatLabel, + int step /* = 1 */, + int heading /* = -1 */, + bool usePopup /* = false */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -752,9 +1009,19 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddPercentageSlider(S return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddPercentageSlider(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, const std::string &formatString, - int step /* = 1 */, int heading /* = -1 */, bool usePopup /* = false */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddPercentageSlider( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const std::string& formatString, + int step /* = 1 */, + int heading /* = -1 */, + bool usePopup /* = false */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -774,9 +1041,20 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddPercentageSlider(S return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSlider(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, int formatLabel, int minimum, int step, - int maximum, int heading /* = -1 */, bool usePopup /* = false */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSlider(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int formatLabel, + int minimum, + int step, + int maximum, + int heading /* = -1 */, + bool usePopup /* = false */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -796,9 +1074,21 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSlider(SettingGrou return setting; } -std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSlider(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int value, const std::string &formatString, - int minimum, int step, int maximum, int heading /* = -1 */, bool usePopup /* = false */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSlider( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const std::string& formatString, + int minimum, + int step, + int maximum, + int heading /* = -1 */, + bool usePopup /* = false */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -818,9 +1108,21 @@ std::shared_ptr<CSettingInt> CGUIDialogSettingsManualBase::AddSlider(SettingGrou return setting; } -std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSlider(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float value, int formatLabel, float minimum, - float step, float maximum, int heading /* = -1 */, bool usePopup /* = false */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSlider( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float value, + int formatLabel, + float minimum, + float step, + float maximum, + int heading /* = -1 */, + bool usePopup /* = false */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -840,9 +1142,21 @@ std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSlider(SettingG return setting; } -std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSlider(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float value, const std::string &formatString, - float minimum, float step, float maximum, int heading /* = -1 */, bool usePopup /* = false */, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSlider( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float value, + const std::string& formatString, + float minimum, + float step, + float maximum, + int heading /* = -1 */, + bool usePopup /* = false */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -862,79 +1176,207 @@ std::shared_ptr<CSettingNumber> CGUIDialogSettingsManualBase::AddSlider(SettingG return setting; } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddPercentageRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, - int valueFormatLabel, int step /* = 1 */, int formatLabel /* = 21469 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddPercentageRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int valueFormatLabel, + int step /* = 1 */, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, 0, step, 100, "percentage", formatLabel, valueFormatLabel, "", delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddPercentageRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, - const std::string &valueFormatString /* = "%i %%" */, int step /* = 1 */, int formatLabel /* = 21469 */, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddPercentageRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + const std::string& valueFormatString /* = "%i %%" */, + int step /* = 1 */, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, 0, step, 100, "percentage", formatLabel, -1, valueFormatString, delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, - int step, int maximum, int valueFormatLabel, int formatLabel /* = 21469 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + int valueFormatLabel, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "integer", formatLabel, valueFormatLabel, "", delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, - int step, int maximum, const std::string &valueFormatString /* = "%d" */, int formatLabel /* = 21469 */, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& valueFormatString /* = "%d" */, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "integer", formatLabel, -1, valueFormatString, delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float valueLower, float valueUpper, float minimum, - float step, float maximum, int valueFormatLabel, int formatLabel /* = 21469 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float valueLower, + float valueUpper, + float minimum, + float step, + float maximum, + int valueFormatLabel, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "number", formatLabel, valueFormatLabel, "", delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float valueLower, float valueUpper, float minimum, - float step, float maximum, const std::string &valueFormatString /* = "%.1f" */, int formatLabel /* = 21469 */, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float valueLower, + float valueUpper, + float minimum, + float step, + float maximum, + const std::string& valueFormatString /* = "%.1f" */, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "number", formatLabel, -1, valueFormatString, delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddDateRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, - int step, int maximum, int valueFormatLabel, int formatLabel /* = 21469 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddDateRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + int valueFormatLabel, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "date", formatLabel, valueFormatLabel, "", delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddDateRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, - int step, int maximum, const std::string &valueFormatString /* = "" */, int formatLabel /* = 21469 */, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddDateRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& valueFormatString /* = "" */, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "date", formatLabel, -1, valueFormatString, delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddTimeRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, - int step, int maximum, int valueFormatLabel, int formatLabel /* = 21469 */, bool delayed /* = false */, - bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddTimeRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + int valueFormatLabel, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "time", formatLabel, valueFormatLabel, "", delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddTimeRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, - int step, int maximum, const std::string &valueFormatString /* = "mm:ss" */, int formatLabel /* = 21469 */, - bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddTimeRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& valueFormatString /* = "mm:ss" */, + int formatLabel /* = 21469 */, + bool delayed /* = false */, + bool visible /* = true */, + int help /* = -1 */) { return AddRange(group, id, label, level, valueLower, valueUpper, minimum, step, maximum, "time", formatLabel, -1, valueFormatString, delayed, visible, help); } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, - int step, int maximum, const std::string &format, int formatLabel, int valueFormatLabel, - const std::string &valueFormatString, bool delayed, bool visible, int help) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& format, + int formatLabel, + int valueFormatLabel, + const std::string& valueFormatString, + bool delayed, + bool visible, + int help) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -971,9 +1413,23 @@ std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGrou return setting; } -std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGroupPtr group, const std::string &id, int label, SettingLevel level, float valueLower, float valueUpper, float minimum, - float step, float maximum, const std::string &format, int formatLabel, int valueFormatLabel, - const std::string &valueFormatString, bool delayed, bool visible, int help) +std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange( + const SettingGroupPtr& group, + const std::string& id, + int label, + SettingLevel level, + float valueLower, + float valueUpper, + float minimum, + float step, + float maximum, + const std::string& format, + int formatLabel, + int valueFormatLabel, + const std::string& valueFormatString, + bool delayed, + bool visible, + int help) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) @@ -1010,7 +1466,10 @@ std::shared_ptr<CSettingList> CGUIDialogSettingsManualBase::AddRange(SettingGrou return setting; } -void CGUIDialogSettingsManualBase::setSettingDetails(std::shared_ptr<CSetting> setting, SettingLevel level, bool visible, int help) +void CGUIDialogSettingsManualBase::setSettingDetails(const std::shared_ptr<CSetting>& setting, + SettingLevel level, + bool visible, + int help) { if (setting == NULL) return; diff --git a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h index a6c0f821a2..6dc4742a62 100644 --- a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h +++ b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h @@ -51,106 +51,536 @@ protected: virtual void InitializeSettings(); std::shared_ptr<CSettingCategory> AddCategory(const std::string &id, int label, int help = -1); - std::shared_ptr<CSettingGroup> AddGroup(std::shared_ptr<CSettingCategory> category, int label = -1, int help = -1, bool separatorBelowLabel = true, bool hideSeparator = false); + std::shared_ptr<CSettingGroup> AddGroup(const std::shared_ptr<CSettingCategory>& category, + int label = -1, + int help = -1, + bool separatorBelowLabel = true, + bool hideSeparator = false); // checkmark control - std::shared_ptr<CSettingBool> AddToggle(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, bool value, bool delayed = false, bool visible = true, int help = -1); + std::shared_ptr<CSettingBool> AddToggle(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + bool value, + bool delayed = false, + bool visible = true, + int help = -1); // edit controls - std::shared_ptr<CSettingInt> AddEdit(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, int minimum = 0, int step = 1, int maximum = 0, - bool verifyNewValue = false, int heading = -1, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingNumber> AddEdit(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float value, float minimum = 0.0f, float step = 1.0f, float maximum = 0.0f, - bool verifyNewValue = false, int heading = -1, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingString> AddEdit(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, bool allowEmpty = false, - bool hidden = false, int heading = -1, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingString> AddIp(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, bool allowEmpty = false, - int heading = -1, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingString> AddPasswordMd5(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, bool allowEmpty = false, - int heading = -1, bool delayed = false, bool visible = true, int help = -1); + std::shared_ptr<CSettingInt> AddEdit(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int minimum = 0, + int step = 1, + int maximum = 0, + bool verifyNewValue = false, + int heading = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingNumber> AddEdit(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float value, + float minimum = 0.0f, + float step = 1.0f, + float maximum = 0.0f, + bool verifyNewValue = false, + int heading = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingString> AddEdit(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty = false, + bool hidden = false, + int heading = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingString> AddIp(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty = false, + int heading = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingString> AddPasswordMd5(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty = false, + int heading = -1, + bool delayed = false, + bool visible = true, + int help = -1); // button controls - std::shared_ptr<CSettingAction> AddButton(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, const std::string& data = "", bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingString> AddInfoLabelButton(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string info, bool visible = true, int help = -1); - std::shared_ptr<CSettingAddon> AddAddon(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, ADDON::TYPE addonType, - bool allowEmpty = false, int heading = -1, bool hideValue = false, bool showInstalledAddons = true, bool showInstallableAddons = false, - bool showMoreAddons = true, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingPath> AddPath(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, bool writable = true, - const std::vector<std::string> &sources = std::vector<std::string>(), bool allowEmpty = false, int heading = -1, bool hideValue = false, - bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingDate> AddDate(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, bool allowEmpty = false, int heading = -1, - bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingTime> AddTime(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, bool allowEmpty = false, int heading = -1, - bool delayed = false, bool visible = true, int help = -1); + std::shared_ptr<CSettingAction> AddButton(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& data = "", + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingString> AddInfoLabelButton(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& info, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingAddon> AddAddon(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + ADDON::TYPE addonType, + bool allowEmpty = false, + int heading = -1, + bool hideValue = false, + bool showInstalledAddons = true, + bool showInstallableAddons = false, + bool showMoreAddons = true, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingPath> AddPath( + const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool writable = true, + const std::vector<std::string>& sources = std::vector<std::string>(), + bool allowEmpty = false, + int heading = -1, + bool hideValue = false, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingDate> AddDate(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty = false, + int heading = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingTime> AddTime(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + bool allowEmpty = false, + int heading = -1, + bool delayed = false, + bool visible = true, + int help = -1); // spinner controls - std::shared_ptr<CSettingString> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, StringSettingOptionsFiller filler, - bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, int minimum, int step, int maximum, int formatLabel = -1, - int minimumLabel = -1, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, int minimum, int step, int maximum, const std::string &formatString, - int minimumLabel = -1, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, const TranslatableIntegerSettingOptions &entries, - bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, const IntegerSettingOptions &entries, - bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, IntegerSettingOptionsFiller filler, - bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingNumber> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float value, float minimum, float step, float maximum, - int formatLabel = -1, int minimumLabel = -1, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingNumber> AddSpinner(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float value, float minimum, float step, float maximum, - const std::string &formatString, int minimumLabel = -1, bool delayed = false, bool visible = true, int help = -1); + std::shared_ptr<CSettingString> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + StringSettingOptionsFiller filler, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int minimum, + int step, + int maximum, + int formatLabel = -1, + int minimumLabel = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int minimum, + int step, + int maximum, + const std::string& formatString, + int minimumLabel = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const TranslatableIntegerSettingOptions& entries, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const IntegerSettingOptions& entries, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + IntegerSettingOptionsFiller filler, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingNumber> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float value, + float minimum, + float step, + float maximum, + int formatLabel = -1, + int minimumLabel = -1, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingNumber> AddSpinner(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float value, + float minimum, + float step, + float maximum, + const std::string& formatString, + int minimumLabel = -1, + bool delayed = false, + bool visible = true, + int help = -1); // list controls - std::shared_ptr<CSettingString> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::string value, StringSettingOptionsFiller filler, - int heading, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, const TranslatableIntegerSettingOptions &entries, - int heading, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, const IntegerSettingOptions &entries, - int heading, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, IntegerSettingOptionsFiller filler, - int heading, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::vector<std::string> values, StringSettingOptionsFiller filler, - int heading, int minimumItems = 0, int maximumItems = -1, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::vector<int> values, const TranslatableIntegerSettingOptions &entries, - int heading, int minimumItems = 0, int maximumItems = -1, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::vector<int> values, const IntegerSettingOptions &entries, - int heading, int minimumItems = 0, int maximumItems = -1, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddList(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, std::vector<int> values, IntegerSettingOptionsFiller filler, - int heading, int minimumItems = 0, int maximumItems = -1, bool visible = true, int help = -1, SettingControlListValueFormatter formatter = NULL); + std::shared_ptr<CSettingString> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + const std::string& value, + StringSettingOptionsFiller filler, + int heading, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const TranslatableIntegerSettingOptions& entries, + int heading, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const IntegerSettingOptions& entries, + int heading, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + IntegerSettingOptionsFiller filler, + int heading, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<std::string> values, + StringSettingOptionsFiller filler, + int heading, + int minimumItems = 0, + int maximumItems = -1, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<int> values, + const TranslatableIntegerSettingOptions& entries, + int heading, + int minimumItems = 0, + int maximumItems = -1, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<int> values, + const IntegerSettingOptions& entries, + int heading, + int minimumItems = 0, + int maximumItems = -1, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddList(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + std::vector<int> values, + IntegerSettingOptionsFiller filler, + int heading, + int minimumItems = 0, + int maximumItems = -1, + bool visible = true, + int help = -1, + SettingControlListValueFormatter formatter = NULL); // slider controls - std::shared_ptr<CSettingInt> AddPercentageSlider(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, int formatLabel, int step = 1, int heading = -1, - bool usePopup = false, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddPercentageSlider(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, const std::string &formatString, int step = 1, - int heading = -1, bool usePopup = false, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddSlider(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, int formatLabel, int minimum, int step, int maximum, - int heading = -1, bool usePopup = false, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingInt> AddSlider(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int value, const std::string &formatString, int minimum, int step, int maximum, - int heading = -1, bool usePopup = false, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingNumber> AddSlider(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float value, int formatLabel, float minimum, float step, float maximum, - int heading = -1, bool usePopup = false, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingNumber> AddSlider(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float value, const std::string &formatString, float minimum, float step, - float maximum, int heading = -1, bool usePopup = false, bool delayed = false, bool visible = true, int help = -1); + std::shared_ptr<CSettingInt> AddPercentageSlider(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int formatLabel, + int step = 1, + int heading = -1, + bool usePopup = false, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddPercentageSlider(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const std::string& formatString, + int step = 1, + int heading = -1, + bool usePopup = false, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddSlider(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + int formatLabel, + int minimum, + int step, + int maximum, + int heading = -1, + bool usePopup = false, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingInt> AddSlider(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int value, + const std::string& formatString, + int minimum, + int step, + int maximum, + int heading = -1, + bool usePopup = false, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingNumber> AddSlider(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float value, + int formatLabel, + float minimum, + float step, + float maximum, + int heading = -1, + bool usePopup = false, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingNumber> AddSlider(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float value, + const std::string& formatString, + float minimum, + float step, + float maximum, + int heading = -1, + bool usePopup = false, + bool delayed = false, + bool visible = true, + int help = -1); // range controls - std::shared_ptr<CSettingList> AddPercentageRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int valueFormatLabel, int step = 1, - int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddPercentageRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, - const std::string &valueFormatString = "%i %%", int step = 1, int formatLabel = 21469, - bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, int step, int maximum, - int valueFormatLabel, int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, int step, int maximum, - const std::string &valueFormatString = "%d", int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float valueLower, float valueUpper, float minimum, float step, float maximum, - int valueFormatLabel, int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float valueLower, float valueUpper, float minimum, float step, float maximum, - const std::string &valueFormatString = "%.1f", int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddDateRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, int step, int maximum, - int valueFormatLabel, int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddDateRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, int step, int maximum, - const std::string &valueFormatString = "", int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddTimeRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, int step, int maximum, - int valueFormatLabel, int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); - std::shared_ptr<CSettingList> AddTimeRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, int step, int maximum, - const std::string &valueFormatString = "mm:ss", int formatLabel = 21469, bool delayed = false, bool visible = true, int help = -1); + std::shared_ptr<CSettingList> AddPercentageRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int valueFormatLabel, + int step = 1, + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddPercentageRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + const std::string& valueFormatString = "%i %%", + int step = 1, + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + int valueFormatLabel, + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& valueFormatString = "%d", + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float valueLower, + float valueUpper, + float minimum, + float step, + float maximum, + int valueFormatLabel, + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float valueLower, + float valueUpper, + float minimum, + float step, + float maximum, + const std::string& valueFormatString = "%.1f", + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddDateRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + int valueFormatLabel, + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddDateRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& valueFormatString = "", + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddTimeRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + int valueFormatLabel, + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); + std::shared_ptr<CSettingList> AddTimeRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& valueFormatString = "mm:ss", + int formatLabel = 21469, + bool delayed = false, + bool visible = true, + int help = -1); std::shared_ptr<ISettingControl> GetTitleControl(bool separatorBelowLabel = true, bool hideSeparator = false); std::shared_ptr<ISettingControl> GetCheckmarkControl(bool delayed = false); @@ -163,12 +593,43 @@ protected: std::shared_ptr<ISettingControl> GetRangeControl(const std::string &format, bool delayed = false, int formatLabel = -1, int valueFormatLabel = -1, const std::string &valueFormatString = ""); private: - std::shared_ptr<CSettingList> AddRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, int valueLower, int valueUpper, int minimum, int step, int maximum, - const std::string &format, int formatLabel, int valueFormatLabel, const std::string &valueFormatString, bool delayed, bool visible, int help); - std::shared_ptr<CSettingList> AddRange(std::shared_ptr<CSettingGroup> group, const std::string &id, int label, SettingLevel level, float valueLower, float valueUpper, float minimum, float step, float maximum, - const std::string &format, int formatLabel, int valueFormatLabel, const std::string &valueFormatString, bool delayed, bool visible, int help); + std::shared_ptr<CSettingList> AddRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + int valueLower, + int valueUpper, + int minimum, + int step, + int maximum, + const std::string& format, + int formatLabel, + int valueFormatLabel, + const std::string& valueFormatString, + bool delayed, + bool visible, + int help); + std::shared_ptr<CSettingList> AddRange(const std::shared_ptr<CSettingGroup>& group, + const std::string& id, + int label, + SettingLevel level, + float valueLower, + float valueUpper, + float minimum, + float step, + float maximum, + const std::string& format, + int formatLabel, + int valueFormatLabel, + const std::string& valueFormatString, + bool delayed, + bool visible, + int help); - void setSettingDetails(std::shared_ptr<CSetting> setting, SettingLevel level, bool visible, int help); + void setSettingDetails(const std::shared_ptr<CSetting>& setting, + SettingLevel level, + bool visible, + int help); mutable CSettingsManager *m_settingsManager; std::shared_ptr<CSettingSection> m_section; diff --git a/xbmc/settings/lib/ISettingCallback.h b/xbmc/settings/lib/ISettingCallback.h index 7806c6564c..00fc428c8b 100644 --- a/xbmc/settings/lib/ISettingCallback.h +++ b/xbmc/settings/lib/ISettingCallback.h @@ -30,7 +30,7 @@ public: \param setting The setting whose value is being changed (already containing the changed value) \return True if the new value is acceptable otherwise false */ - virtual bool OnSettingChanging(std::shared_ptr<const CSetting> setting) { return true; } + virtual bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) { return true; } /*! \brief The value of the given setting has changed. @@ -41,7 +41,7 @@ public: \param setting The setting whose value has been changed */ - virtual void OnSettingChanged(std::shared_ptr<const CSetting> setting) { } + virtual void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) {} /*! \brief The given setting has been activated. @@ -51,7 +51,7 @@ public: \param setting The setting which has been activated. */ - virtual void OnSettingAction(std::shared_ptr<const CSetting> setting) { } + virtual void OnSettingAction(const std::shared_ptr<const CSetting>& setting) {} /*! \brief The given setting needs to be updated. @@ -65,7 +65,12 @@ public: \param oldSettingNode The old setting node \return True if the setting has been successfully updated otherwise false */ - virtual bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { return false; } + virtual bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) + { + return false; + } /*! \brief The given property of the given setting has changed @@ -76,5 +81,8 @@ public: \param setting The setting which has a changed property \param propertyName The string representation of the changed property */ - virtual void OnSettingPropertyChanged(std::shared_ptr<const CSetting> setting, const char *propertyName) { } + virtual void OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting, + const char* propertyName) + { + } }; diff --git a/xbmc/settings/lib/Setting.cpp b/xbmc/settings/lib/Setting.cpp index 3b464c68b8..526944c92f 100644 --- a/xbmc/settings/lib/Setting.cpp +++ b/xbmc/settings/lib/Setting.cpp @@ -17,11 +17,12 @@ #include "utils/log.h" #include <sstream> +#include <utility> template<typename TKey, typename TValue> bool CheckSettingOptionsValidity(const TValue& value, const std::vector<std::pair<TKey, TValue>>& options) { - for (auto it : options) + for (const auto& it : options) { if (it.second == value) return true; @@ -33,7 +34,7 @@ bool CheckSettingOptionsValidity(const TValue& value, const std::vector<std::pai template<typename TKey, typename TValue> bool CheckSettingOptionsValidity(const TValue& value, const std::vector<TKey>& options) { - for (auto it : options) + for (const auto& it : options) { if (it.value == value) return true; @@ -199,7 +200,7 @@ bool CSetting::IsEnabled() const } bool enabled = m_enabled; - for (auto dep : m_dependencies) + for (const auto& dep : m_dependencies) { if (dep.GetType() != SettingDependencyType::Enable) continue; @@ -239,7 +240,7 @@ bool CSetting::IsVisible() const return false; bool visible = true; - for (auto dep : m_dependencies) + for (const auto& dep : m_dependencies) { if (dep.GetType() != SettingDependencyType::Visible) continue; @@ -254,7 +255,7 @@ bool CSetting::IsVisible() const return visible; } -bool CSetting::OnSettingChanging(std::shared_ptr<const CSetting> setting) +bool CSetting::OnSettingChanging(const std::shared_ptr<const CSetting>& setting) { if (m_callback == nullptr) return true; @@ -262,7 +263,7 @@ bool CSetting::OnSettingChanging(std::shared_ptr<const CSetting> setting) return m_callback->OnSettingChanging(setting); } -void CSetting::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CSetting::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (m_callback == nullptr) return; @@ -270,7 +271,7 @@ void CSetting::OnSettingChanged(std::shared_ptr<const CSetting> setting) m_callback->OnSettingChanged(setting); } -void CSetting::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CSetting::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (m_callback == nullptr) return; @@ -278,7 +279,9 @@ void CSetting::OnSettingAction(std::shared_ptr<const CSetting> setting) m_callback->OnSettingAction(setting); } -bool CSetting::OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +bool CSetting::OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) { if (m_callback == nullptr) return false; @@ -286,7 +289,8 @@ bool CSetting::OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *ol return m_callback->OnSettingUpdate(setting, oldSettingId, oldSettingNode); } -void CSetting::OnSettingPropertyChanged(std::shared_ptr<const CSetting> setting, const char *propertyName) +void CSetting::OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting, + const char* propertyName) { if (m_callback == nullptr) return; @@ -319,14 +323,14 @@ void CSetting::Copy(const CSetting &setting) CSettingList::CSettingList(const std::string& id, std::shared_ptr<CSetting> settingDefinition, CSettingsManager* settingsManager /* = nullptr */) - : CSetting(id, settingsManager, "CSettingList"), m_definition(settingDefinition) + : CSetting(id, settingsManager, "CSettingList"), m_definition(std::move(settingDefinition)) { } CSettingList::CSettingList(const std::string& id, std::shared_ptr<CSetting> settingDefinition, int label, CSettingsManager* settingsManager /* = nullptr */) - : CSetting(id, settingsManager, "CSettingList"), m_definition(settingDefinition) + : CSetting(id, settingsManager, "CSettingList"), m_definition(std::move(settingDefinition)) { SetLabel(label); } @@ -477,7 +481,7 @@ void CSettingList::Reset() { CExclusiveLock lock(m_critical); SettingList values; - for (auto it : m_defaults) + for (const auto& it : m_defaults) values.push_back(it->Clone(it->GetId())); SetValue(values); @@ -545,7 +549,7 @@ void CSettingList::SetDefault(const SettingList &values) if (!m_changed) { m_values.clear(); - for (auto it : m_defaults) + for (const auto& it : m_defaults) m_values.push_back(it->Clone(it->GetId())); } } @@ -573,7 +577,7 @@ void CSettingList::copy(const SettingList &srcValues, SettingList &dstValues) { dstValues.clear(); - for (auto value : srcValues) + for (const auto& value : srcValues) { if (value == nullptr) continue; @@ -599,7 +603,7 @@ bool CSettingList::fromValues(const std::vector<std::string> &strValues, Setting bool ret = true; int index = 0; - for (auto value : strValues) + for (const auto& value : strValues) { auto settingValue = m_definition->Clone(StringUtils::Format("{}.{}", m_id, index++)); if (settingValue == nullptr || @@ -621,7 +625,7 @@ bool CSettingList::fromValues(const std::vector<std::string> &strValues, Setting std::string CSettingList::toString(const SettingList &values) const { std::vector<std::string> strValues; - for (auto value : values) + for (const auto& value : values) { if (value != nullptr) strValues.push_back(value->ToString()); diff --git a/xbmc/settings/lib/Setting.h b/xbmc/settings/lib/Setting.h index e01338cff2..3b4c8b997e 100644 --- a/xbmc/settings/lib/Setting.h +++ b/xbmc/settings/lib/Setting.h @@ -22,6 +22,7 @@ #include <memory> #include <set> #include <string> +#include <utility> #include <vector> enum class SettingOptionsType { @@ -76,7 +77,7 @@ public: void SetLevel(SettingLevel level) { m_level = level; } std::shared_ptr<const ISettingControl> GetControl() const { return m_control; } std::shared_ptr<ISettingControl> GetControl() { return m_control; } - void SetControl(std::shared_ptr<ISettingControl> control) { m_control = control; } + void SetControl(std::shared_ptr<ISettingControl> control) { m_control = std::move(control); } const SettingDependencies& GetDependencies() const { return m_dependencies; } void SetDependencies(const SettingDependencies &dependencies) { m_dependencies = dependencies; } const std::set<CSettingUpdate>& GetUpdates() const { return m_updates; } @@ -93,14 +94,17 @@ public: bool IsVisible() const override; // implementation of ISettingCallback - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; protected: // implementation of ISettingCallback - bool OnSettingChanging(std::shared_ptr<const CSetting> setting) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override; - void OnSettingPropertyChanged(std::shared_ptr<const CSetting> setting, const char *propertyName) override; + bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) override; + void OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting, + const char* propertyName) override; void Copy(const CSetting &setting); @@ -176,7 +180,7 @@ public: SettingType GetElementType() const; std::shared_ptr<CSetting> GetDefinition() { return m_definition; } std::shared_ptr<const CSetting> GetDefinition() const { return m_definition; } - void SetDefinition(std::shared_ptr<CSetting> definition) { m_definition = definition; } + void SetDefinition(std::shared_ptr<CSetting> definition) { m_definition = std::move(definition); } const std::string& GetDelimiter() const { return m_delimiter; } void SetDelimiter(const std::string &delimiter) { m_delimiter = delimiter; } diff --git a/xbmc/settings/lib/SettingConditions.cpp b/xbmc/settings/lib/SettingConditions.cpp index 5c2bdf3aed..7146834f74 100644 --- a/xbmc/settings/lib/SettingConditions.cpp +++ b/xbmc/settings/lib/SettingConditions.cpp @@ -126,7 +126,10 @@ void CSettingConditionsManager::RemoveDynamicCondition(std::string identifier) m_conditions.erase(it); } -bool CSettingConditionsManager::Check(std::string condition, const std::string &value /* = "" */, std::shared_ptr<const CSetting> setting /* = nullptr */) const +bool CSettingConditionsManager::Check( + std::string condition, + const std::string& value /* = "" */, + const std::shared_ptr<const CSetting>& setting /* = nullptr */) const { if (condition.empty()) return false; diff --git a/xbmc/settings/lib/SettingConditions.h b/xbmc/settings/lib/SettingConditions.h index 50c05f04c1..aee2c0614c 100644 --- a/xbmc/settings/lib/SettingConditions.h +++ b/xbmc/settings/lib/SettingConditions.h @@ -19,7 +19,10 @@ class CSettingsManager; class CSetting; -using SettingConditionCheck = bool (*)(const std::string &condition, const std::string &value, std::shared_ptr<const CSetting> setting, void *data); +using SettingConditionCheck = bool (*)(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); class ISettingCondition { @@ -88,7 +91,10 @@ public: void AddDynamicCondition(std::string identifier, SettingConditionCheck condition, void *data = nullptr); void RemoveDynamicCondition(std::string identifier); - bool Check(std::string condition, const std::string &value = "", std::shared_ptr<const CSetting> setting = std::shared_ptr<const CSetting>()) const; + bool Check( + std::string condition, + const std::string& value = "", + const std::shared_ptr<const CSetting>& setting = std::shared_ptr<const CSetting>()) const; private: using SettingConditionPair = std::pair<std::string, std::pair<SettingConditionCheck, void*>>; diff --git a/xbmc/settings/lib/SettingDefinitions.h b/xbmc/settings/lib/SettingDefinitions.h index a82cb5a01b..545e41e58c 100644 --- a/xbmc/settings/lib/SettingDefinitions.h +++ b/xbmc/settings/lib/SettingDefinitions.h @@ -110,8 +110,14 @@ using TranslatableStringSettingOptions = std::vector<TranslatableStringSettingOp using StringSettingOptions = std::vector<StringSettingOption>; class CSetting; -using IntegerSettingOptionsFiller = void (*)(std::shared_ptr<const CSetting> setting, IntegerSettingOptions &list, int ¤t, void *data); -using StringSettingOptionsFiller = void (*)(std::shared_ptr<const CSetting> setting, StringSettingOptions &list, std::string ¤t, void *data); +using IntegerSettingOptionsFiller = void (*)(const std::shared_ptr<const CSetting>& setting, + IntegerSettingOptions& list, + int& current, + void* data); +using StringSettingOptionsFiller = void (*)(const std::shared_ptr<const CSetting>& setting, + StringSettingOptions& list, + std::string& current, + void* data); enum class SettingOptionsSort { diff --git a/xbmc/settings/lib/SettingDependency.cpp b/xbmc/settings/lib/SettingDependency.cpp index 2458cc6095..e5b49fb81f 100644 --- a/xbmc/settings/lib/SettingDependency.cpp +++ b/xbmc/settings/lib/SettingDependency.cpp @@ -292,7 +292,8 @@ bool CSettingDependencyConditionCombination::Deserialize(const TiXmlNode *node) return true; } -CSettingDependencyConditionCombination* CSettingDependencyConditionCombination::Add(CSettingDependencyConditionPtr condition) +CSettingDependencyConditionCombination* CSettingDependencyConditionCombination::Add( + const CSettingDependencyConditionPtr& condition) { if (condition != nullptr) { @@ -306,7 +307,8 @@ CSettingDependencyConditionCombination* CSettingDependencyConditionCombination:: return this; } -CSettingDependencyConditionCombination* CSettingDependencyConditionCombination::Add(CSettingDependencyConditionCombinationPtr operation) +CSettingDependencyConditionCombination* CSettingDependencyConditionCombination::Add( + const CSettingDependencyConditionCombinationPtr& operation) { if (operation != nullptr) { diff --git a/xbmc/settings/lib/SettingDependency.h b/xbmc/settings/lib/SettingDependency.h index fd599040a0..1ba83f90a1 100644 --- a/xbmc/settings/lib/SettingDependency.h +++ b/xbmc/settings/lib/SettingDependency.h @@ -87,8 +87,9 @@ public: const std::set<std::string>& GetSettings() const { return m_settings; } - CSettingDependencyConditionCombination* Add(CSettingDependencyConditionPtr condition); - CSettingDependencyConditionCombination* Add(CSettingDependencyConditionCombinationPtr operation); + CSettingDependencyConditionCombination* Add(const CSettingDependencyConditionPtr& condition); + CSettingDependencyConditionCombination* Add( + const CSettingDependencyConditionCombinationPtr& operation); private: CBooleanLogicOperation* newOperation() override { return new CSettingDependencyConditionCombination(m_settingsManager); } diff --git a/xbmc/settings/lib/SettingSection.cpp b/xbmc/settings/lib/SettingSection.cpp index db3de8906c..bb199fc0e6 100644 --- a/xbmc/settings/lib/SettingSection.cpp +++ b/xbmc/settings/lib/SettingSection.cpp @@ -145,7 +145,7 @@ SettingList CSettingGroup::GetSettings(SettingLevel level) const return settings; } -void CSettingGroup::AddSetting(SettingPtr setting) +void CSettingGroup::AddSetting(const SettingPtr& setting) { addISetting(nullptr, setting, m_settings); } @@ -156,7 +156,8 @@ void CSettingGroup::AddSettings(const SettingList &settings) addISetting(nullptr, setting, m_settings); } -bool CSettingGroup::ReplaceSetting(std::shared_ptr<const CSetting> currentSetting, std::shared_ptr<CSetting> newSetting) +bool CSettingGroup::ReplaceSetting(const std::shared_ptr<const CSetting>& currentSetting, + const std::shared_ptr<CSetting>& newSetting) { for (auto itSetting = m_settings.begin(); itSetting != m_settings.end(); ++itSetting) { @@ -243,7 +244,7 @@ bool CSettingCategory::CanAccess() const return m_accessCondition.Check(); } -void CSettingCategory::AddGroup(SettingGroupPtr group) +void CSettingCategory::AddGroup(const SettingGroupPtr& group) { addISetting(nullptr, group, m_groups); } @@ -312,7 +313,7 @@ SettingCategoryList CSettingSection::GetCategories(SettingLevel level) const return categories; } -void CSettingSection::AddCategory(SettingCategoryPtr category) +void CSettingSection::AddCategory(const SettingCategoryPtr& category) { addISetting(nullptr, category, m_categories); } diff --git a/xbmc/settings/lib/SettingSection.h b/xbmc/settings/lib/SettingSection.h index f29fc8d392..f02d026af4 100644 --- a/xbmc/settings/lib/SettingSection.h +++ b/xbmc/settings/lib/SettingSection.h @@ -14,6 +14,7 @@ #include "utils/StaticLoggerBase.h" #include <string> +#include <utility> #include <vector> class CSettingsManager; @@ -55,14 +56,15 @@ public: */ SettingList GetSettings(SettingLevel level) const; - void AddSetting(std::shared_ptr<CSetting> setting); + void AddSetting(const std::shared_ptr<CSetting>& setting); void AddSettings(const SettingList &settings); - bool ReplaceSetting(std::shared_ptr<const CSetting> currentSetting, std::shared_ptr<CSetting> newSetting); + bool ReplaceSetting(const std::shared_ptr<const CSetting>& currentSetting, + const std::shared_ptr<CSetting>& newSetting); std::shared_ptr<const ISettingControl> GetControl() const { return m_control; } std::shared_ptr<ISettingControl> GetControl() { return m_control; } - void SetControl(std::shared_ptr<ISettingControl> control) { m_control = control; } + void SetControl(std::shared_ptr<ISettingControl> control) { m_control = std::move(control); } private: SettingList m_settings; @@ -117,7 +119,7 @@ public: */ bool CanAccess() const; - void AddGroup(SettingGroupPtr group); + void AddGroup(const SettingGroupPtr& group); void AddGroups(const SettingGroupList &groups); private: @@ -166,7 +168,7 @@ public: */ SettingCategoryList GetCategories(SettingLevel level) const; - void AddCategory(SettingCategoryPtr category); + void AddCategory(const SettingCategoryPtr& category); void AddCategories(const SettingCategoryList &categories); private: diff --git a/xbmc/settings/lib/SettingsManager.cpp b/xbmc/settings/lib/SettingsManager.cpp index 8f5b165024..1a3f37c9a5 100644 --- a/xbmc/settings/lib/SettingsManager.cpp +++ b/xbmc/settings/lib/SettingsManager.cpp @@ -262,7 +262,7 @@ void CSettingsManager::SetInitialized() ResolveSettingDependencies(setting.second); } -void CSettingsManager::AddSection(SettingSectionPtr section) +void CSettingsManager::AddSection(const SettingSectionPtr& section) { if (section == nullptr) return; @@ -304,8 +304,10 @@ void CSettingsManager::AddSection(SettingSectionPtr section) } } -bool CSettingsManager::AddSetting(std::shared_ptr<CSetting> setting, std::shared_ptr<CSettingSection> section, - std::shared_ptr<CSettingCategory> category, std::shared_ptr<CSettingGroup> group) +bool CSettingsManager::AddSetting(const std::shared_ptr<CSetting>& setting, + const std::shared_ptr<CSettingSection>& section, + const std::shared_ptr<CSettingCategory>& category, + const std::shared_ptr<CSettingGroup>& group) { if (setting == nullptr || section == nullptr || category == nullptr || group == nullptr) return false; @@ -458,7 +460,7 @@ void CSettingsManager::UnregisterSettingOptionsFiller(const std::string &identif m_optionsFillers.erase(identifier); } -void* CSettingsManager::GetSettingOptionsFiller(SettingConstPtr setting) +void* CSettingsManager::GetSettingOptionsFiller(const SettingConstPtr& setting) { CSharedLock lock(m_critical); if (setting == nullptr) @@ -567,7 +569,7 @@ SettingDependencyMap CSettingsManager::GetDependencies(const std::string &id) co return setting->second.dependencies; } -SettingDependencyMap CSettingsManager::GetDependencies(SettingConstPtr setting) const +SettingDependencyMap CSettingsManager::GetDependencies(const SettingConstPtr& setting) const { if (setting == nullptr) return SettingDependencyMap(); @@ -790,7 +792,7 @@ bool CSettingsManager::Deserialize(const TiXmlNode *node, bool &updated, std::ma return true; } -bool CSettingsManager::OnSettingChanging(std::shared_ptr<const CSetting> setting) +bool CSettingsManager::OnSettingChanging(const std::shared_ptr<const CSetting>& setting) { if (setting == nullptr) return false; @@ -848,7 +850,7 @@ bool CSettingsManager::OnSettingChanging(std::shared_ptr<const CSetting> setting return true; } -void CSettingsManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CSettingsManager::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { CSharedLock lock(m_settingsCritical); if (!m_loaded || setting == nullptr) @@ -874,7 +876,7 @@ void CSettingsManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) } } -void CSettingsManager::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CSettingsManager::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { CSharedLock lock(m_settingsCritical); if (!m_loaded || setting == nullptr) @@ -892,7 +894,9 @@ void CSettingsManager::OnSettingAction(std::shared_ptr<const CSetting> setting) callback->OnSettingAction(setting); } -bool CSettingsManager::OnSettingUpdate(SettingPtr setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +bool CSettingsManager::OnSettingUpdate(const SettingPtr& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) { CSharedLock lock(m_settingsCritical); if (setting == nullptr) @@ -913,7 +917,8 @@ bool CSettingsManager::OnSettingUpdate(SettingPtr setting, const char *oldSettin return ret; } -void CSettingsManager::OnSettingPropertyChanged(std::shared_ptr<const CSetting> setting, const char *propertyName) +void CSettingsManager::OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting, + const char* propertyName) { CSharedLock lock(m_settingsCritical); if (!m_loaded || setting == nullptr) @@ -1040,7 +1045,7 @@ void CSettingsManager::OnSettingsCleared() settingsHandler->OnSettingsCleared(); } -bool CSettingsManager::LoadSetting(const TiXmlNode *node, SettingPtr setting, bool &updated) +bool CSettingsManager::LoadSetting(const TiXmlNode* node, const SettingPtr& setting, bool& updated) { updated = false; @@ -1107,7 +1112,9 @@ bool CSettingsManager::LoadSetting(const TiXmlNode *node, SettingPtr setting, bo return true; } -bool CSettingsManager::UpdateSetting(const TiXmlNode *node, SettingPtr setting, const CSettingUpdate& update) +bool CSettingsManager::UpdateSetting(const TiXmlNode* node, + const SettingPtr& setting, + const CSettingUpdate& update) { if (node == nullptr || setting == nullptr || update.GetType() == SettingUpdateType::Unknown) return false; @@ -1202,7 +1209,7 @@ void CSettingsManager::UpdateSettingByDependency(const std::string &settingId, S } } -void CSettingsManager::AddSetting(std::shared_ptr<CSetting> setting) +void CSettingsManager::AddSetting(const std::shared_ptr<CSetting>& setting) { setting->CheckRequirements(); @@ -1221,7 +1228,7 @@ void CSettingsManager::AddSetting(std::shared_ptr<CSetting> setting) } } -void CSettingsManager::ResolveReferenceSettings(std::shared_ptr<CSettingSection> section) +void CSettingsManager::ResolveReferenceSettings(const std::shared_ptr<CSettingSection>& section) { struct GroupedReferenceSettings { @@ -1345,7 +1352,7 @@ void CSettingsManager::RegisterSettingOptionsFiller(const std::string &identifie m_optionsFillers.insert(make_pair(identifier, optionsFiller)); } -void CSettingsManager::ResolveSettingDependencies(std::shared_ptr<CSetting> setting) +void CSettingsManager::ResolveSettingDependencies(const std::shared_ptr<CSetting>& setting) { if (setting == nullptr) return; diff --git a/xbmc/settings/lib/SettingsManager.h b/xbmc/settings/lib/SettingsManager.h index 31ed7006ed..a52fc0d9c4 100644 --- a/xbmc/settings/lib/SettingsManager.h +++ b/xbmc/settings/lib/SettingsManager.h @@ -162,7 +162,7 @@ public: This is possible before and after the setting definitions have been initialized. */ - void AddSection(std::shared_ptr<CSettingSection> section); + void AddSection(const std::shared_ptr<CSettingSection>& section); /*! \brief Adds the given setting to the given group in the given category in @@ -182,8 +182,10 @@ public: \param group Group the new setting should be added to \return True if the setting has been added, false otherwise */ - bool AddSetting(std::shared_ptr<CSetting> setting, std::shared_ptr<CSettingSection> section, - std::shared_ptr<CSettingCategory> category, std::shared_ptr<CSettingGroup> group); + bool AddSetting(const std::shared_ptr<CSetting>& setting, + const std::shared_ptr<CSettingSection>& section, + const std::shared_ptr<CSettingCategory>& category, + const std::shared_ptr<CSettingGroup>& group); /*! \brief Registers the given ISettingCallback implementation to be triggered @@ -267,7 +269,7 @@ public: \param setting Setting object \return Implementation of the setting options filler (either IntegerSettingOptionsFiller or StringSettingOptionsFiller) */ - void* GetSettingOptionsFiller(std::shared_ptr<const CSetting> setting); + void* GetSettingOptionsFiller(const std::shared_ptr<const CSetting>& setting); /*! \brief Checks whether any settings have been initialized. @@ -319,7 +321,7 @@ public: \param setting Setting object \return Map of settings (and their dependencies) which depend on the given setting */ - SettingDependencyMap GetDependencies(std::shared_ptr<const CSetting> setting) const; + SettingDependencyMap GetDependencies(const std::shared_ptr<const CSetting>& setting) const; /*! \brief Gets the boolean value of the setting with the given identifier. @@ -453,11 +455,14 @@ public: private: // implementation of ISettingCallback - bool OnSettingChanging(std::shared_ptr<const CSetting> setting) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; - bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override; - void OnSettingPropertyChanged(std::shared_ptr<const CSetting> setting, const char *propertyName) override; + bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; + bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, + const char* oldSettingId, + const TiXmlNode* oldSettingNode) override; + void OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting, + const char* propertyName) override; // implementation of ISettingsHandler bool OnSettingsLoading() override; @@ -470,14 +475,16 @@ private: bool Serialize(TiXmlNode *parent) const; bool Deserialize(const TiXmlNode *node, bool &updated, std::map<std::string, std::shared_ptr<CSetting>> *loadedSettings = nullptr); - bool LoadSetting(const TiXmlNode *node, std::shared_ptr<CSetting> setting, bool &updated); - bool UpdateSetting(const TiXmlNode *node, std::shared_ptr<CSetting> setting, const CSettingUpdate& update); + bool LoadSetting(const TiXmlNode* node, const std::shared_ptr<CSetting>& setting, bool& updated); + bool UpdateSetting(const TiXmlNode* node, + const std::shared_ptr<CSetting>& setting, + const CSettingUpdate& update); void UpdateSettingByDependency(const std::string &settingId, const CSettingDependency &dependency); void UpdateSettingByDependency(const std::string &settingId, SettingDependencyType dependencyType); - void AddSetting(std::shared_ptr<CSetting> setting); + void AddSetting(const std::shared_ptr<CSetting>& setting); - void ResolveReferenceSettings(std::shared_ptr<CSettingSection> section); + void ResolveReferenceSettings(const std::shared_ptr<CSettingSection>& section); void CleanupIncompleteSettings(); enum class SettingOptionsFillerType { @@ -499,7 +506,7 @@ private: using SettingMap = std::map<std::string, Setting>; - void ResolveSettingDependencies(std::shared_ptr<CSetting> setting); + void ResolveSettingDependencies(const std::shared_ptr<CSetting>& setting); void ResolveSettingDependencies(const Setting& setting); SettingMap::const_iterator FindSetting(std::string settingId) const; diff --git a/xbmc/settings/windows/GUIControlSettings.cpp b/xbmc/settings/windows/GUIControlSettings.cpp index 75c06fbaca..dc807bb338 100644 --- a/xbmc/settings/windows/GUIControlSettings.cpp +++ b/xbmc/settings/windows/GUIControlSettings.cpp @@ -94,7 +94,7 @@ static bool CompareSettingOptionDeseconding(const SettingOption& lhs, const Sett return StringUtils::CompareNoCase(lhs.label, rhs.label) > 0; } -static bool GetIntegerOptions(SettingConstPtr setting, +static bool GetIntegerOptions(const SettingConstPtr& setting, IntegerSettingOptions& options, std::set<int>& selectedOptions, ILocalizer* localizer, @@ -200,7 +200,7 @@ static bool GetIntegerOptions(SettingConstPtr setting, return true; } -static bool GetStringOptions(SettingConstPtr setting, +static bool GetStringOptions(const SettingConstPtr& setting, StringSettingOptions& options, std::set<std::string>& selectedOptions, ILocalizer* localizer, @@ -291,7 +291,11 @@ static bool GetStringOptions(SettingConstPtr setting, CGUIControlBaseSetting::CGUIControlBaseSetting(int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : m_id(id), m_pSetting(pSetting), m_localizer(localizer), m_delayed(false), m_valid(true) + : m_id(id), + m_pSetting(std::move(pSetting)), + m_localizer(localizer), + m_delayed(false), + m_valid(true) { } @@ -334,7 +338,7 @@ CGUIControlRadioButtonSetting::CGUIControlRadioButtonSetting(CGUIRadioButtonCont int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : CGUIControlBaseSetting(id, pSetting, localizer) + : CGUIControlBaseSetting(id, std::move(pSetting), localizer) { m_pRadioButton = pRadioButton; if (m_pRadioButton == NULL) @@ -366,7 +370,7 @@ CGUIControlSpinExSetting::CGUIControlSpinExSetting(CGUISpinControlEx* pSpin, int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : CGUIControlBaseSetting(id, pSetting, localizer) + : CGUIControlBaseSetting(id, std::move(pSetting), localizer) { m_pSpin = pSpin; if (m_pSpin == NULL) @@ -564,7 +568,7 @@ CGUIControlListSetting::CGUIControlListSetting(CGUIButtonControl* pButton, int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : CGUIControlBaseSetting(id, pSetting, localizer) + : CGUIControlBaseSetting(id, std::move(pSetting), localizer) { m_pButton = pButton; if (m_pButton == NULL) @@ -795,7 +799,7 @@ void CGUIControlListSetting::Update(bool fromControl, bool updateDisplayOnly) } } -bool CGUIControlListSetting::GetItems(SettingConstPtr setting, +bool CGUIControlListSetting::GetItems(const SettingConstPtr& setting, CFileItemList& items, bool updateItems) const { @@ -824,7 +828,7 @@ bool CGUIControlListSetting::GetItems(SettingConstPtr setting, return true; } -bool CGUIControlListSetting::GetIntegerItems(SettingConstPtr setting, +bool CGUIControlListSetting::GetIntegerItems(const SettingConstPtr& setting, CFileItemList& items, bool updateItems) const { @@ -841,7 +845,7 @@ bool CGUIControlListSetting::GetIntegerItems(SettingConstPtr setting, return true; } -bool CGUIControlListSetting::GetStringItems(SettingConstPtr setting, +bool CGUIControlListSetting::GetStringItems(const SettingConstPtr& setting, CFileItemList& items, bool updateItems) const { @@ -862,7 +866,7 @@ CGUIControlButtonSetting::CGUIControlButtonSetting(CGUIButtonControl* pButton, int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : CGUIControlBaseSetting(id, pSetting, localizer) + : CGUIControlBaseSetting(id, std::move(pSetting), localizer) { m_pButton = pButton; if (m_pButton == NULL) @@ -1102,7 +1106,7 @@ void CGUIControlButtonSetting::Update(bool fromControl, bool updateDisplayOnly) m_pButton->SetLabel2(strText); } -bool CGUIControlButtonSetting::GetPath(std::shared_ptr<CSettingPath> pathSetting, +bool CGUIControlButtonSetting::GetPath(const std::shared_ptr<CSettingPath>& pathSetting, ILocalizer* localizer) { if (pathSetting == NULL) @@ -1201,7 +1205,7 @@ void CGUIControlButtonSetting::OnSliderChange(void* data, CGUISliderControl* sli CGUIControlEditSetting::CGUIControlEditSetting(CGUIEditControl* pEdit, int id, - std::shared_ptr<CSetting> pSetting, + const std::shared_ptr<CSetting>& pSetting, ILocalizer* localizer) : CGUIControlBaseSetting(id, pSetting, localizer) { @@ -1301,7 +1305,7 @@ CGUIControlSliderSetting::CGUIControlSliderSetting(CGUISettingsSliderControl* pS int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : CGUIControlBaseSetting(id, pSetting, localizer) + : CGUIControlBaseSetting(id, std::move(pSetting), localizer) { m_pSlider = pSlider; if (m_pSlider == NULL) @@ -1423,7 +1427,7 @@ void CGUIControlSliderSetting::Update(bool fromControl, bool updateDisplayOnly) m_pSlider->SetTextValue(strText); } -std::string CGUIControlSliderSetting::GetText(std::shared_ptr<CSetting> setting, +std::string CGUIControlSliderSetting::GetText(const std::shared_ptr<CSetting>& setting, const CVariant& value, const CVariant& minimum, const CVariant& step, @@ -1484,7 +1488,7 @@ CGUIControlRangeSetting::CGUIControlRangeSetting(CGUISettingsSliderControl* pSli int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : CGUIControlBaseSetting(id, pSetting, localizer) + : CGUIControlBaseSetting(id, std::move(pSetting), localizer) { m_pSlider = pSlider; if (m_pSlider == NULL) @@ -1723,7 +1727,7 @@ CGUIControlLabelSetting::CGUIControlLabelSetting(CGUIButtonControl* pButton, int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer) - : CGUIControlBaseSetting(id, pSetting, localizer) + : CGUIControlBaseSetting(id, std::move(pSetting), localizer) { m_pButton = pButton; if (m_pButton == NULL) diff --git a/xbmc/settings/windows/GUIControlSettings.h b/xbmc/settings/windows/GUIControlSettings.h index 734b668a53..f0dfae8180 100644 --- a/xbmc/settings/windows/GUIControlSettings.h +++ b/xbmc/settings/windows/GUIControlSettings.h @@ -160,13 +160,13 @@ protected: void Update(bool fromControl, bool updateDisplayOnly) override; private: - bool GetItems(std::shared_ptr<const CSetting> setting, + bool GetItems(const std::shared_ptr<const CSetting>& setting, CFileItemList& items, bool updateItems) const; - bool GetIntegerItems(std::shared_ptr<const CSetting> setting, + bool GetIntegerItems(const std::shared_ptr<const CSetting>& setting, CFileItemList& items, bool updateItems) const; - bool GetStringItems(std::shared_ptr<const CSetting> setting, + bool GetStringItems(const std::shared_ptr<const CSetting>& setting, CFileItemList& items, bool updateItems) const; @@ -186,7 +186,7 @@ public: bool OnClick() override; void Clear() override { m_pButton = NULL; } - static bool GetPath(std::shared_ptr<CSettingPath> pathSetting, ILocalizer* localizer); + static bool GetPath(const std::shared_ptr<CSettingPath>& pathSetting, ILocalizer* localizer); protected: // specialization of CGUIControlBaseSetting @@ -204,7 +204,7 @@ class CGUIControlEditSetting : public CGUIControlBaseSetting public: CGUIControlEditSetting(CGUIEditControl* pButton, int id, - std::shared_ptr<CSetting> pSetting, + const std::shared_ptr<CSetting>& pSetting, ILocalizer* localizer); ~CGUIControlEditSetting() override; @@ -235,7 +235,7 @@ public: bool OnClick() override; void Clear() override { m_pSlider = NULL; } - static std::string GetText(std::shared_ptr<CSetting> setting, + static std::string GetText(const std::shared_ptr<CSetting>& setting, const CVariant& value, const CVariant& minimum, const CVariant& step, diff --git a/xbmc/storage/MediaManager.cpp b/xbmc/storage/MediaManager.cpp index eb549000fa..f975294ec1 100644 --- a/xbmc/storage/MediaManager.cpp +++ b/xbmc/storage/MediaManager.cpp @@ -194,7 +194,7 @@ void CMediaManager::GetNetworkLocations(VECSOURCES &locations, bool autolocation #ifdef HAS_UPNP if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SERVICES_UPNP)) { - std::string strDevices = g_localizeStrings.Get(33040); //"% Devices" + const std::string& strDevices = g_localizeStrings.Get(33040); //"% Devices" share.strPath = "upnp://"; share.strName = StringUtils::Format(strDevices.c_str(), "UPnP"); //"UPnP Devices" locations.push_back(share); diff --git a/xbmc/storage/cdioSupport.h b/xbmc/storage/cdioSupport.h index da06d2c275..6fca99711e 100644 --- a/xbmc/storage/cdioSupport.h +++ b/xbmc/storage/cdioSupport.h @@ -20,6 +20,7 @@ #include <map> #include <memory> #include <string> +#include <utility> #include "PlatformDefs.h" // for ssize_t typedef, used by cdio @@ -206,8 +207,12 @@ public: void SetFirstDataTrack( int nTrack ) { m_nFirstData = nTrack; } void SetDataTrackCount( int nCount ) { m_nNumData = nCount; } void SetAudioTrackCount( int nCount ) { m_nNumAudio = nCount; } - void SetTrackInformation( int nTrack, trackinfo nInfo ) { if ( nTrack > 0 && nTrack <= 99 ) m_ti[nTrack - 1] = nInfo; } - void SetDiscCDTextInformation( xbmc_cdtext_t cdtext ) { m_cdtext = cdtext; } + void SetTrackInformation(int nTrack, trackinfo nInfo) + { + if (nTrack > 0 && nTrack <= 99) + m_ti[nTrack - 1] = std::move(nInfo); + } + void SetDiscCDTextInformation(xbmc_cdtext_t cdtext) { m_cdtext = std::move(cdtext); } void SetCddbDiscId( uint32_t ulCddbDiscId ) { m_ulCddbDiscId = ulCddbDiscId; } void SetDiscLength( int nLength ) { m_nLength = nLength; } diff --git a/xbmc/system_egl.h b/xbmc/system_egl.h index 18ef124b59..4a8860b123 100644 --- a/xbmc/system_egl.h +++ b/xbmc/system_egl.h @@ -8,7 +8,7 @@ #pragma once -#if defined(TARGET_LINUX) +#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) #if defined(WL_EGL_PLATFORM) #undef WL_EGL_PLATFORM @@ -31,7 +31,7 @@ #include <EGL/egl.h> -#if defined(TARGET_LINUX) +#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) #if defined(KODI_WL_EGL_PLATFORM) #undef KODI_WL_EGL_PLATFORM diff --git a/xbmc/utils/ActorProtocol.h b/xbmc/utils/ActorProtocol.h index 97297a6dde..7c6d41ebe5 100644 --- a/xbmc/utils/ActorProtocol.h +++ b/xbmc/utils/ActorProtocol.h @@ -14,6 +14,7 @@ #include <memory> #include <queue> #include <string> +#include <utility> class CEvent; @@ -71,10 +72,11 @@ private: class Protocol { public: - Protocol(std::string name, CEvent* inEvent, CEvent *outEvent) - :portName(name), containerInEvent(inEvent), containerOutEvent(outEvent) {} - Protocol(std::string name) - : Protocol(name, nullptr, nullptr) {} + Protocol(std::string name, CEvent* inEvent, CEvent* outEvent) + : portName(std::move(name)), containerInEvent(inEvent), containerOutEvent(outEvent) + { + } + Protocol(std::string name) : Protocol(std::move(name), nullptr, nullptr) {} ~Protocol(); Message *GetMessage(); void ReturnMessage(Message *msg); diff --git a/xbmc/utils/BitstreamConverter.cpp b/xbmc/utils/BitstreamConverter.cpp index 011a1e4c9c..0aaa4d491b 100644 --- a/xbmc/utils/BitstreamConverter.cpp +++ b/xbmc/utils/BitstreamConverter.cpp @@ -258,8 +258,6 @@ static bool has_sei_recovery_point(const uint8_t *p, const uint8_t *end) ///////////////////////////////////////////////////////////////////////////////////////////// CBitstreamParser::CBitstreamParser() = default; -CBitstreamParser::~CBitstreamParser() = default; - void CBitstreamParser::Close() { } diff --git a/xbmc/utils/BitstreamConverter.h b/xbmc/utils/BitstreamConverter.h index 92448702e4..7d98a15d7e 100644 --- a/xbmc/utils/BitstreamConverter.h +++ b/xbmc/utils/BitstreamConverter.h @@ -73,7 +73,7 @@ class CBitstreamParser { public: CBitstreamParser(); - ~CBitstreamParser(); + ~CBitstreamParser() = default; static bool Open(){ return true; }; static void Close(); diff --git a/xbmc/utils/BufferObject.h b/xbmc/utils/BufferObject.h index 11d0a0666b..277a439aa1 100644 --- a/xbmc/utils/BufferObject.h +++ b/xbmc/utils/BufferObject.h @@ -28,11 +28,11 @@ public: */ static std::unique_ptr<CBufferObject> GetBufferObject(bool needsCreateBySize); - virtual bool CreateBufferObject(uint64_t size) override { return false; } + bool CreateBufferObject(uint64_t size) override { return false; } - virtual int GetFd() override; - virtual uint32_t GetStride() override; - virtual uint64_t GetModifier() override; + int GetFd() override; + uint32_t GetStride() override; + uint64_t GetModifier() override; void SyncStart() override; void SyncEnd() override; diff --git a/xbmc/utils/BufferObjectFactory.cpp b/xbmc/utils/BufferObjectFactory.cpp index eb1ec7e07c..13ada4bac6 100644 --- a/xbmc/utils/BufferObjectFactory.cpp +++ b/xbmc/utils/BufferObjectFactory.cpp @@ -12,7 +12,7 @@ std::list<std::function<std::unique_ptr<CBufferObject>()>> CBufferObjectFactory: std::unique_ptr<CBufferObject> CBufferObjectFactory::CreateBufferObject(bool needsCreateBySize) { - for (const auto bufferObject : m_bufferObjects) + for (const auto& bufferObject : m_bufferObjects) { auto bo = bufferObject(); @@ -31,7 +31,7 @@ std::unique_ptr<CBufferObject> CBufferObjectFactory::CreateBufferObject(bool nee } void CBufferObjectFactory::RegisterBufferObject( - std::function<std::unique_ptr<CBufferObject>()> createFunc) + const std::function<std::unique_ptr<CBufferObject>()>& createFunc) { m_bufferObjects.emplace_front(createFunc); } diff --git a/xbmc/utils/BufferObjectFactory.h b/xbmc/utils/BufferObjectFactory.h index a466e840cd..1420129b66 100644 --- a/xbmc/utils/BufferObjectFactory.h +++ b/xbmc/utils/BufferObjectFactory.h @@ -35,7 +35,7 @@ public: * @brief Registers a CBufferObject class to class to the factory. * */ - static void RegisterBufferObject(std::function<std::unique_ptr<CBufferObject>()>); + static void RegisterBufferObject(const std::function<std::unique_ptr<CBufferObject>()>&); /** * @brief Clears the list of registered CBufferObject types diff --git a/xbmc/utils/CMakeLists.txt b/xbmc/utils/CMakeLists.txt index f6e55d0b96..4e46c05b2f 100644 --- a/xbmc/utils/CMakeLists.txt +++ b/xbmc/utils/CMakeLists.txt @@ -189,13 +189,13 @@ if(OPENGL_FOUND OR OPENGLES_FOUND) list(APPEND HEADERS GLUtils.h) endif() -if(CORE_PLATFORM_NAME_LC STREQUAL gbm OR CORE_PLATFORM_NAME_LC STREQUAL wayland) +if("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES BufferObject.cpp BufferObjectFactory.cpp) list(APPEND HEADERS BufferObject.h BufferObjectFactory.h) - if(CORE_PLATFORM_NAME_LC STREQUAL gbm) + if("gbm" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES DumbBufferObject.cpp) list(APPEND SOURCES DumbBufferObject.h) endif() @@ -210,7 +210,7 @@ if(CORE_PLATFORM_NAME_LC STREQUAL gbm OR CORE_PLATFORM_NAME_LC STREQUAL wayland) list(APPEND HEADERS DMAHeapBufferObject.h) endif() - if(GBM_HAS_BO_MAP AND CORE_PLATFORM_NAME_LC STREQUAL gbm) + if(GBM_HAS_BO_MAP AND "gbm" IN_LIST CORE_PLATFORM_NAME_LC) list(APPEND SOURCES GBMBufferObject.cpp) list(APPEND HEADERS GBMBufferObject.h) endif() diff --git a/xbmc/utils/CharsetConverter.cpp b/xbmc/utils/CharsetConverter.cpp index 8dffd65e1b..7613fa6c91 100644 --- a/xbmc/utils/CharsetConverter.cpp +++ b/xbmc/utils/CharsetConverter.cpp @@ -565,7 +565,7 @@ static struct SCharsetMapping CCharsetConverter::CCharsetConverter() = default; -void CCharsetConverter::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CCharsetConverter::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -860,7 +860,10 @@ bool CCharsetConverter::utf8logicalToVisualBiDi(const std::string& utf8StringSrc return CInnerConverter::stdConvert(Utf32ToUtf8, utf32flipped, utf8StringDst, failOnBadString); } -void CCharsetConverter::SettingOptionsCharsetsFiller(SettingConstPtr setting, std::vector<StringSettingOption>& list, std::string& current, void *data) +void CCharsetConverter::SettingOptionsCharsetsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { std::vector<std::string> vecCharsets = g_charsetConverter.getCharsetLabels(); sort(vecCharsets.begin(), vecCharsets.end(), sortstringbyname()); diff --git a/xbmc/utils/CharsetConverter.h b/xbmc/utils/CharsetConverter.h index 1c7e0142c1..70a1e42479 100644 --- a/xbmc/utils/CharsetConverter.h +++ b/xbmc/utils/CharsetConverter.h @@ -23,7 +23,7 @@ class CCharsetConverter : public ISettingCallback public: CCharsetConverter(); - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; static void reset(); static void resetSystemCharset(); @@ -156,7 +156,11 @@ public: static bool toW(const std::string& stringSrc, std::wstring& wStringDst, const std::string& enc); static bool fromW(const std::wstring& wStringSrc, std::string& stringDst, const std::string& enc); - static void SettingOptionsCharsetsFiller(std::shared_ptr<const CSetting> setting, std::vector<StringSettingOption>& list, std::string& current, void *data); + static void SettingOptionsCharsetsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); + private: static void resetUserCharset(void); static void resetSubtitleCharset(void); diff --git a/xbmc/utils/CharsetDetection.cpp b/xbmc/utils/CharsetDetection.cpp index 06a04168d2..ac8b3df3c8 100644 --- a/xbmc/utils/CharsetDetection.cpp +++ b/xbmc/utils/CharsetDetection.cpp @@ -584,7 +584,8 @@ size_t CCharsetDetection::GetHtmlAttribute(const std::string& htmlContent, size_ return std::string::npos; // rest of htmlContent was attribute value } -std::string CCharsetDetection::ExtractEncodingFromHtmlMeta(std::string metaContent, size_t pos /*= 0*/) +std::string CCharsetDetection::ExtractEncodingFromHtmlMeta(const std::string& metaContent, + size_t pos /*= 0*/) { size_t len = metaContent.length(); if (pos >= len) diff --git a/xbmc/utils/CharsetDetection.h b/xbmc/utils/CharsetDetection.h index 1ff3905e5c..d1b9ba9d90 100644 --- a/xbmc/utils/CharsetDetection.h +++ b/xbmc/utils/CharsetDetection.h @@ -82,7 +82,7 @@ private: static std::string GetHtmlEncodingFromHead(const std::string& htmlContent); static size_t GetHtmlAttribute(const std::string& htmlContent, size_t pos, std::string& atrName, std::string& strValue); - static std::string ExtractEncodingFromHtmlMeta(std::string metaContent, size_t pos = 0); + static std::string ExtractEncodingFromHtmlMeta(const std::string& metaContent, size_t pos = 0); static bool checkConversion(const std::string& srcCharset, const std::string& src, std::string& dst); static void appendCharAsAsciiUpperCase(std::string& str, const char chr); diff --git a/xbmc/utils/JSONVariantParser.cpp b/xbmc/utils/JSONVariantParser.cpp index f003cdfb10..48431d19e1 100644 --- a/xbmc/utils/JSONVariantParser.cpp +++ b/xbmc/utils/JSONVariantParser.cpp @@ -40,7 +40,7 @@ private: return true; } - void PushObject(CVariant variant); + void PushObject(const CVariant& variant); void PopObject(); CVariant& m_parsedObject; @@ -146,7 +146,7 @@ bool CJSONVariantParserHandler::EndArray(rapidjson::SizeType elementCount) return true; } -void CJSONVariantParserHandler::PushObject(CVariant variant) +void CJSONVariantParserHandler::PushObject(const CVariant& variant) { if (m_status == PARSE_STATUS::Object) { diff --git a/xbmc/utils/LangCodeExpander.cpp b/xbmc/utils/LangCodeExpander.cpp index bc1e06b9d0..2175b224cd 100644 --- a/xbmc/utils/LangCodeExpander.cpp +++ b/xbmc/utils/LangCodeExpander.cpp @@ -83,7 +83,7 @@ void CLangCodeExpander::LoadUserCodes(const TiXmlElement* pRootElement) bool CLangCodeExpander::Lookup(const std::string& code, std::string& desc) { - int iSplit = code.find("-"); + int iSplit = code.find('-'); if (iSplit > 0) { std::string strLeft, strRight; diff --git a/xbmc/utils/Locale.cpp b/xbmc/utils/Locale.cpp index 0a2d692d14..ff63ed4806 100644 --- a/xbmc/utils/Locale.cpp +++ b/xbmc/utils/Locale.cpp @@ -220,7 +220,7 @@ bool CLocale::ParseLocale(const std::string &locale, std::string &language, std: std::string tmp = locale; // look for the modifier after @ - size_t pos = tmp.find("@"); + size_t pos = tmp.find('@'); if (pos != std::string::npos) { modifier = tmp.substr(pos + 1); @@ -228,7 +228,7 @@ bool CLocale::ParseLocale(const std::string &locale, std::string &language, std: } // look for the codeset after . - pos = tmp.find("."); + pos = tmp.find('.'); if (pos != std::string::npos) { codeset = tmp.substr(pos + 1); @@ -236,7 +236,7 @@ bool CLocale::ParseLocale(const std::string &locale, std::string &language, std: } // look for the codeset after _ - pos = tmp.find("_"); + pos = tmp.find('_'); if (pos != std::string::npos) { territory = tmp.substr(pos + 1); diff --git a/xbmc/utils/POUtils.cpp b/xbmc/utils/POUtils.cpp index 7d8afd3469..df622074a8 100644 --- a/xbmc/utils/POUtils.cpp +++ b/xbmc/utils/POUtils.cpp @@ -259,7 +259,7 @@ void CPODocument::GetString(CStrEntry &strEntry) while (startPos < m_Entry.Content.size()) { - nextLFPos = m_Entry.Content.find("\n", startPos); + nextLFPos = m_Entry.Content.find('\n', startPos); if (nextLFPos == std::string::npos) nextLFPos = m_Entry.Content.size(); @@ -277,7 +277,7 @@ void CPODocument::GetString(CStrEntry &strEntry) void CPODocument::ConvertLineEnds(const std::string &filename) { - size_t foundPos = m_strBuffer.find_first_of("\r"); + size_t foundPos = m_strBuffer.find_first_of('\r'); if (foundPos == std::string::npos) return; // We have only Linux style line endings in the file, nothing to do diff --git a/xbmc/utils/RecentlyAddedJob.cpp b/xbmc/utils/RecentlyAddedJob.cpp index 93344a984f..80093a3859 100644 --- a/xbmc/utils/RecentlyAddedJob.cpp +++ b/xbmc/utils/RecentlyAddedJob.cpp @@ -280,7 +280,7 @@ bool CRecentlyAddedJob::UpdateMusic() artfound = musicdatabase.GetArtForItem(-1, album.idAlbum, -1, true, art); if (artfound) { - for (auto artitem : art) + for (const auto& artitem : art) { if (artitem.mediaType == MediaTypeAlbum && artitem.artType == "thumb") strThumb = artitem.url; diff --git a/xbmc/utils/RssManager.cpp b/xbmc/utils/RssManager.cpp index 69cae01416..67b8f78ba9 100644 --- a/xbmc/utils/RssManager.cpp +++ b/xbmc/utils/RssManager.cpp @@ -56,7 +56,7 @@ void CRssManager::OnSettingsUnloaded() Clear(); } -void CRssManager::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CRssManager::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/utils/RssManager.h b/xbmc/utils/RssManager.h index 399cfa48a5..2b807d739f 100644 --- a/xbmc/utils/RssManager.h +++ b/xbmc/utils/RssManager.h @@ -35,7 +35,7 @@ public: void OnSettingsLoaded() override; void OnSettingsUnloaded() override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; void Start(); void Stop(); diff --git a/xbmc/utils/ScopeGuard.h b/xbmc/utils/ScopeGuard.h index a1aa0a6eb3..2f731fbeb3 100644 --- a/xbmc/utils/ScopeGuard.h +++ b/xbmc/utils/ScopeGuard.h @@ -89,13 +89,13 @@ public: CScopeGuard& operator= (const CScopeGuard& rhs) = delete; //Allow moving - CScopeGuard(CScopeGuard&& rhs) + CScopeGuard(CScopeGuard&& rhs) noexcept : m_handle{std::move(rhs.m_handle)}, m_deleter{std::move(rhs.m_deleter)} { // Bring moved-from object into released state so destructor will not do anything rhs.release(); } - CScopeGuard& operator=(CScopeGuard&& rhs) + CScopeGuard& operator=(CScopeGuard&& rhs) noexcept { attach(rhs.release()); m_deleter = std::move(rhs.m_deleter); diff --git a/xbmc/utils/ScraperParser.cpp b/xbmc/utils/ScraperParser.cpp index 81fcf37c4a..4499e827e5 100644 --- a/xbmc/utils/ScraperParser.cpp +++ b/xbmc/utils/ScraperParser.cpp @@ -155,7 +155,7 @@ void CScraperParser::ReplaceBuffers(std::string& strDest) iIndex = 0; while ((iIndex = strDest.find("$INFO[", iIndex)) != std::string::npos) { - size_t iEnd = strDest.find("]", iIndex); + size_t iEnd = strDest.find(']', iIndex); std::string strInfo = strDest.substr(iIndex+6, iEnd - iIndex - 6); std::string strReplace; if (m_scraper) @@ -167,7 +167,7 @@ void CScraperParser::ReplaceBuffers(std::string& strDest) iIndex = 0; while ((iIndex = strDest.find("$LOCALIZE[", iIndex)) != std::string::npos) { - size_t iEnd = strDest.find("]", iIndex); + size_t iEnd = strDest.find(']', iIndex); std::string strInfo = strDest.substr(iIndex+10, iEnd - iIndex - 10); std::string strReplace; if (m_scraper) diff --git a/xbmc/utils/ScraperUrl.cpp b/xbmc/utils/ScraperUrl.cpp index f242a40f57..43df6dd6eb 100644 --- a/xbmc/utils/ScraperUrl.cpp +++ b/xbmc/utils/ScraperUrl.cpp @@ -31,9 +31,9 @@ CScraperUrl::CScraperUrl() : m_relevance(0.0), m_parsed(false) { } -CScraperUrl::CScraperUrl(std::string strUrl) : CScraperUrl() +CScraperUrl::CScraperUrl(const std::string& strUrl) : CScraperUrl() { - ParseFromData(std::move(strUrl)); + ParseFromData(strUrl); } CScraperUrl::CScraperUrl(const TiXmlElement* element) : CScraperUrl() @@ -127,10 +127,10 @@ bool CScraperUrl::Parse() auto dataToParse = m_data; m_data.clear(); - return ParseFromData(std::move(dataToParse)); + return ParseFromData(dataToParse); } -bool CScraperUrl::ParseFromData(std::string data) +bool CScraperUrl::ParseFromData(const std::string& data) { if (data.empty()) return false; @@ -209,7 +209,7 @@ bool CScraperUrl::ParseAndAppendUrl(const TiXmlElement* element) // XML format is of strUrls is: // <TAG><url>...</url>...</TAG> (parsed by ParseElement) or <url>...</url> (ditto) -bool CScraperUrl::ParseAndAppendUrlsFromEpisodeGuide(std::string episodeGuide) +bool CScraperUrl::ParseAndAppendUrlsFromEpisodeGuide(const std::string& episodeGuide) { if (episodeGuide.empty()) return false; @@ -239,11 +239,11 @@ bool CScraperUrl::ParseAndAppendUrlsFromEpisodeGuide(std::string episodeGuide) return true; } -void CScraperUrl::AddParsedUrl(std::string url, - std::string aspect, - std::string preview, - std::string referrer, - std::string cache, +void CScraperUrl::AddParsedUrl(const std::string& url, + const std::string& aspect, + const std::string& preview, + const std::string& referrer, + const std::string& cache, bool post, bool isgz, int season) diff --git a/xbmc/utils/ScraperUrl.h b/xbmc/utils/ScraperUrl.h index f6c13bacf7..c68aa3b076 100644 --- a/xbmc/utils/ScraperUrl.h +++ b/xbmc/utils/ScraperUrl.h @@ -45,7 +45,7 @@ public: }; CScraperUrl(); - explicit CScraperUrl(std::string strUrl); + explicit CScraperUrl(const std::string& strUrl); explicit CScraperUrl(const TiXmlElement* element); ~CScraperUrl(); @@ -87,14 +87,14 @@ public: bool unique = false) const; bool Parse(); - bool ParseFromData(std::string data); // copies by intention + bool ParseFromData(const std::string& data); // copies by intention bool ParseAndAppendUrl(const TiXmlElement* element); - bool ParseAndAppendUrlsFromEpisodeGuide(std::string episodeGuide); // copies by intention - void AddParsedUrl(std::string url, - std::string aspect = "", - std::string preview = "", - std::string referrer = "", - std::string cache = "", + bool ParseAndAppendUrlsFromEpisodeGuide(const std::string& episodeGuide); // copies by intention + void AddParsedUrl(const std::string& url, + const std::string& aspect = "", + const std::string& preview = "", + const std::string& referrer = "", + const std::string& cache = "", bool post = false, bool isgz = false, int season = -1); diff --git a/xbmc/utils/Screenshot.cpp b/xbmc/utils/Screenshot.cpp index 8e37bc12ed..94b04859f1 100644 --- a/xbmc/utils/Screenshot.cpp +++ b/xbmc/utils/Screenshot.cpp @@ -26,7 +26,7 @@ using namespace XFILE; std::vector<std::function<std::unique_ptr<IScreenshotSurface>()>> CScreenShot::m_screenShotSurfaces; -void CScreenShot::Register(std::function<std::unique_ptr<IScreenshotSurface>()> createFunc) +void CScreenShot::Register(const std::function<std::unique_ptr<IScreenshotSurface>()>& createFunc) { m_screenShotSurfaces.emplace_back(createFunc); } diff --git a/xbmc/utils/Screenshot.h b/xbmc/utils/Screenshot.h index 8642ca3191..6c44558005 100644 --- a/xbmc/utils/Screenshot.h +++ b/xbmc/utils/Screenshot.h @@ -18,7 +18,7 @@ class CScreenShot { public: - static void Register(std::function<std::unique_ptr<IScreenshotSurface>()> createFunc); + static void Register(const std::function<std::unique_ptr<IScreenshotSurface>()>& createFunc); static void TakeScreenshot(); static void TakeScreenshot(const std::string &filename, bool sync); diff --git a/xbmc/utils/Stopwatch.cpp b/xbmc/utils/Stopwatch.cpp index bec498f378..5314d7affc 100644 --- a/xbmc/utils/Stopwatch.cpp +++ b/xbmc/utils/Stopwatch.cpp @@ -33,8 +33,6 @@ CStopWatch::CStopWatch(bool useFrameTime /*=false*/) #endif } -CStopWatch::~CStopWatch() = default; - int64_t CStopWatch::GetTicks() const { if (m_useFrameTime) diff --git a/xbmc/utils/Stopwatch.h b/xbmc/utils/Stopwatch.h index 186a54c286..64fdaeb47a 100644 --- a/xbmc/utils/Stopwatch.h +++ b/xbmc/utils/Stopwatch.h @@ -14,7 +14,7 @@ class CStopWatch { public: explicit CStopWatch(bool useFrameTime=false); - ~CStopWatch(); + ~CStopWatch() = default; /*! \brief Retrieve the running state of the stopwatch. diff --git a/xbmc/utils/StringUtils.cpp b/xbmc/utils/StringUtils.cpp index 0d83181ab5..5a93035012 100644 --- a/xbmc/utils/StringUtils.cpp +++ b/xbmc/utils/StringUtils.cpp @@ -1778,7 +1778,7 @@ void StringUtils::Tokenize(const std::string& input, std::vector<std::string>& t } } -uint64_t StringUtils::ToUint64(std::string str, uint64_t fallback) noexcept +uint64_t StringUtils::ToUint64(const std::string& str, uint64_t fallback) noexcept { std::istringstream iss(str); uint64_t result(fallback); diff --git a/xbmc/utils/StringUtils.h b/xbmc/utils/StringUtils.h index 6aab4cd1e6..dd0b107f82 100644 --- a/xbmc/utils/StringUtils.h +++ b/xbmc/utils/StringUtils.h @@ -374,7 +374,7 @@ public: static void Tokenize(const std::string& input, std::vector<std::string>& tokens, const std::string& delimiters); static std::vector<std::string> Tokenize(const std::string& input, const char delimiter); static void Tokenize(const std::string& input, std::vector<std::string>& tokens, const char delimiter); - static uint64_t ToUint64(std::string str, uint64_t fallback) noexcept; + static uint64_t ToUint64(const std::string& str, uint64_t fallback) noexcept; /*! * Returns bytes in a human readable format using the smallest unit that will fit `bytes` in at diff --git a/xbmc/utils/TimeUtils.cpp b/xbmc/utils/TimeUtils.cpp index 16d75b9fe6..369d5aadbf 100644 --- a/xbmc/utils/TimeUtils.cpp +++ b/xbmc/utils/TimeUtils.cpp @@ -95,7 +95,7 @@ CDateTime CTimeUtils::GetLocalTime(time_t time) return result; } -std::string CTimeUtils::WithoutSeconds(const std::string hhmmss) +std::string CTimeUtils::WithoutSeconds(const std::string& hhmmss) { return hhmmss.substr(0, 5); } diff --git a/xbmc/utils/TimeUtils.h b/xbmc/utils/TimeUtils.h index 078753e7ff..d7740d7c57 100644 --- a/xbmc/utils/TimeUtils.h +++ b/xbmc/utils/TimeUtils.h @@ -38,7 +38,8 @@ public: * @brief Returns a time string without seconds, i.e: HH:MM * @param hhmmss Time string in the format HH:MM:SS */ - static std::string WithoutSeconds(const std::string hhmmss); + static std::string WithoutSeconds(const std::string& hhmmss); + private: static unsigned int frameTime; }; diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index 738c946a50..9ee77f4f9f 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -507,7 +507,7 @@ std::string URIUtils::SubstitutePath(const std::string& strPath, bool reverse /* for (const auto& pathPair : m_advancedSettings->m_pathSubstitutions) { const std::string fromPath = reverse ? pathPair.second : pathPair.first; - const std::string toPath = reverse ? pathPair.first : pathPair.second; + std::string toPath = reverse ? pathPair.first : pathPair.second; if (strncmp(strPath.c_str(), fromPath.c_str(), HasSlashAtEnd(fromPath) ? fromPath.size() - 1 : fromPath.size()) == 0) { @@ -665,7 +665,7 @@ bool URIUtils::IsOnLAN(const std::string& strPath) if(!IsRemote(strPath)) return false; - std::string host = url.GetHostName(); + const std::string& host = url.GetHostName(); return IsHostOnLAN(host); } @@ -1163,7 +1163,7 @@ bool URIUtils::HasSlashAtEnd(const std::string& strFile, bool checkURL /* = fals if (checkURL && IsURL(strFile)) { CURL url(strFile); - std::string file = url.GetFileName(); + const std::string& file = url.GetFileName(); return file.empty() || HasSlashAtEnd(file, false); } char kar = strFile.c_str()[strFile.size() - 1]; diff --git a/xbmc/utils/Variant.cpp b/xbmc/utils/Variant.cpp index 97676f6e90..8ea688ab81 100644 --- a/xbmc/utils/Variant.cpp +++ b/xbmc/utils/Variant.cpp @@ -282,7 +282,7 @@ CVariant::CVariant(const CVariant &variant) *this = variant; } -CVariant::CVariant(CVariant&& rhs) +CVariant::CVariant(CVariant&& rhs) noexcept { //Set this so that operator= don't try and run cleanup //when we're not initialized. @@ -624,7 +624,7 @@ CVariant &CVariant::operator=(const CVariant &rhs) return *this; } -CVariant& CVariant::operator=(CVariant&& rhs) +CVariant& CVariant::operator=(CVariant&& rhs) noexcept { if (m_type == VariantTypeConstNull || this == &rhs) return *this; @@ -634,7 +634,7 @@ CVariant& CVariant::operator=(CVariant&& rhs) cleanup(); m_type = rhs.m_type; - m_data = std::move(rhs.m_data); + m_data = rhs.m_data; //Should be enough to just set m_type here //but better safe than sorry, could probably lead to coverity warnings diff --git a/xbmc/utils/Variant.h b/xbmc/utils/Variant.h index 45f8e9084e..9d48a3df23 100644 --- a/xbmc/utils/Variant.h +++ b/xbmc/utils/Variant.h @@ -64,7 +64,7 @@ public: CVariant(const std::map<std::string, std::string> &strMap); CVariant(const std::map<std::string, CVariant> &variantMap); CVariant(const CVariant &variant); - CVariant(CVariant &&rhs); + CVariant(CVariant&& rhs) noexcept; ~CVariant(); @@ -98,7 +98,7 @@ public: const CVariant &operator[](unsigned int position) const; CVariant &operator=(const CVariant &rhs); - CVariant &operator=(CVariant &&rhs); + CVariant& operator=(CVariant&& rhs) noexcept; bool operator==(const CVariant &rhs) const; bool operator!=(const CVariant &rhs) const { return !(*this == rhs); } diff --git a/xbmc/utils/log.cpp b/xbmc/utils/log.cpp index b1f221380d..2fb00fa0ee 100644 --- a/xbmc/utils/log.cpp +++ b/xbmc/utils/log.cpp @@ -69,7 +69,7 @@ void CLog::OnSettingsLoaded() SetComponentLogLevel(settings->GetList(CSettings::SETTING_DEBUG_SETEXTRALOGLEVEL)); } -void CLog::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CLog::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -141,7 +141,7 @@ void CLog::Uninitialize() settingsManager->UnregisterCallback(this); // flush all loggers - spdlog::apply_all([](std::shared_ptr<spdlog::logger> logger) { logger->flush(); }); + spdlog::apply_all([](const std::shared_ptr<spdlog::logger>& logger) { logger->flush(); }); // flush the file sink m_fileSink->flush(); @@ -190,7 +190,7 @@ bool CLog::CanLogComponent(uint32_t component) const return ((m_componentLogLevels & component) == component); } -void CLog::SettingOptionsLoggingComponentsFiller(SettingConstPtr setting, +void CLog::SettingOptionsLoggingComponentsFiller(const SettingConstPtr& setting, std::vector<IntegerSettingOption>& list, int& current, void* data) diff --git a/xbmc/utils/log.h b/xbmc/utils/log.h index 7287918453..9809f85acf 100644 --- a/xbmc/utils/log.h +++ b/xbmc/utils/log.h @@ -46,7 +46,7 @@ public: void OnSettingsLoaded() override; // implementation of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; void Initialize(const std::string& path); void Uninitialize(); @@ -56,7 +56,7 @@ public: bool IsLogLevelLogged(int loglevel); bool CanLogComponent(uint32_t component) const; - static void SettingOptionsLoggingComponentsFiller(std::shared_ptr<const CSetting> setting, + static void SettingOptionsLoggingComponentsFiller(const std::shared_ptr<const CSetting>& setting, std::vector<IntegerSettingOption>& list, int& current, void* data); diff --git a/xbmc/video/ContextMenus.cpp b/xbmc/video/ContextMenus.cpp index c0de0360bc..f9684d1b96 100644 --- a/xbmc/video/ContextMenus.cpp +++ b/xbmc/video/ContextMenus.cpp @@ -21,11 +21,15 @@ #include "video/windows/GUIWindowVideoBase.h" #include "view/GUIViewState.h" +#include <utility> + namespace CONTEXTMENU { CVideoInfo::CVideoInfo(MediaType mediaType) - : CStaticContextMenuAction(19033), m_mediaType(mediaType) {} + : CStaticContextMenuAction(19033), m_mediaType(std::move(mediaType)) +{ +} bool CVideoInfo::IsVisible(const CFileItem& item) const { diff --git a/xbmc/video/PlayerController.cpp b/xbmc/video/PlayerController.cpp index f1df869f23..29ccc5dea5 100644 --- a/xbmc/video/PlayerController.cpp +++ b/xbmc/video/PlayerController.cpp @@ -452,7 +452,7 @@ bool CPlayerController::OnAction(const CAction &action) { int playing = 0; int idx = 0; - for (auto prog : programs) + for (const auto& prog : programs) { dialog->Add(prog.name); if (prog.playing) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 3a03966c0c..bed0426c1d 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -4319,10 +4319,17 @@ void CVideoDatabase::GetCast(int media_id, const std::string &media_type, std::v SActorInfo info; info.strName = m_pDS2->fv(0).get_asString(); info.strRole = m_pDS2->fv(1).get_asString(); - info.order = m_pDS2->fv(2).get_asInt(); - info.thumbUrl.ParseFromData(m_pDS2->fv(3).get_asString()); - info.thumb = m_pDS2->fv(4).get_asString(); - cast.emplace_back(std::move(info)); + + // ignore identical actors (since cast might already be prefilled) + if (std::none_of(cast.begin(), cast.end(), [info](const SActorInfo& actor) { + return actor.strName == info.strName && actor.strRole == info.strRole; + })) + { + info.order = m_pDS2->fv(2).get_asInt(); + info.thumbUrl.ParseFromData(m_pDS2->fv(3).get_asString()); + info.thumb = m_pDS2->fv(4).get_asString(); + cast.emplace_back(std::move(info)); + } m_pDS2->next(); } @@ -6060,7 +6067,7 @@ void CVideoDatabase::EraseAllVideoSettings() } } -void CVideoDatabase::EraseAllVideoSettings(std::string path) +void CVideoDatabase::EraseAllVideoSettings(const std::string& path) { std::string itemsToDelete; @@ -8478,7 +8485,9 @@ bool CVideoDatabase::GetMusicVideosByWhere(const std::string &baseDir, const Fil std::string strSQL = "select %s from musicvideo_view "; CVideoDbUrl videoUrl; - videoUrl.FromString(baseDir); + if (!videoUrl.FromString(baseDir)) + return false; + std::string strSQLExtra; const CUrlOptions::UrlOptions& options = videoUrl.GetOptions(); std::string strArtist; @@ -9430,7 +9439,7 @@ std::vector<int> CVideoDatabase::CleanMediaType(const std::string &mediaType, co if (mediaType.empty() || cleanableFileIDs.empty()) return cleanedIDs; - std::string table = mediaType; + const std::string& table = mediaType; std::string idField; std::string parentPathIdField; bool isEpisode = false; @@ -10544,7 +10553,7 @@ std::string CVideoDatabase::GetSafeFile(const std::string &dir, const std::strin return URIUtils::AddFileToFolder(dir, CUtil::MakeLegalFileName(safeThumb)); } -void CVideoDatabase::AnnounceRemove(std::string content, int id, bool scanning /* = false */) +void CVideoDatabase::AnnounceRemove(const std::string& content, int id, bool scanning /* = false */) { CVariant data; data["type"] = content; @@ -10554,7 +10563,7 @@ void CVideoDatabase::AnnounceRemove(std::string content, int id, bool scanning / CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::VideoLibrary, "OnRemove", data); } -void CVideoDatabase::AnnounceUpdate(std::string content, int id) +void CVideoDatabase::AnnounceUpdate(const std::string& content, int id) { CVariant data; data["type"] = content; @@ -10564,7 +10573,7 @@ void CVideoDatabase::AnnounceUpdate(std::string content, int id) bool CVideoDatabase::GetItemsForPath(const std::string &content, const std::string &strPath, CFileItemList &items) { - std::string path(strPath); + const std::string& path(strPath); if(URIUtils::IsMultiPath(path)) { diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index ade34df2d8..f22155d922 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -605,7 +605,7 @@ public: * Erases video settings for files starting with path * @param path pattern */ - void EraseAllVideoSettings(std::string path); + void EraseAllVideoSettings(const std::string& path); bool GetStackTimes(const std::string &filePath, std::vector<uint64_t> ×); void SetStackTimes(const std::string &filePath, const std::vector<uint64_t> ×); @@ -1014,6 +1014,6 @@ private: std::vector<int> CleanMediaType(const std::string &mediaType, const std::string &cleanableFileIDs, std::map<int, bool> &pathsDeleteDecisions, std::string &deletedFileIDs, bool silent); - static void AnnounceRemove(std::string content, int id, bool scanning = false); - static void AnnounceUpdate(std::string content, int id); + static void AnnounceRemove(const std::string& content, int id, bool scanning = false); + static void AnnounceUpdate(const std::string& content, int id); }; diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp index a5f9827328..bfb3ea5eb9 100644 --- a/xbmc/video/VideoInfoScanner.cpp +++ b/xbmc/video/VideoInfoScanner.cpp @@ -1534,7 +1534,7 @@ namespace VIDEO if (moviePartOfSet) { movieSetArtTypes = CVideoThumbLoader::GetArtTypes(MediaTypeVideoCollection); - for (std::string artType : movieSetArtTypes) + for (const std::string& artType : movieSetArtTypes) artTypes.push_back("set." + artType); } bool addAll = artLevel == CSettings::VIDEOLIBRARY_ARTWORK_LEVEL_ALL; @@ -1631,9 +1631,8 @@ namespace VIDEO std::string CVideoInfoScanner::GetImage(const CScraperUrl::SUrlEntry &image, const std::string& itemPath) { std::string thumb = CScraperUrl::GetThumbUrl(image); - if (!thumb.empty() && - thumb.find("/") == std::string::npos && - thumb.find("\\") == std::string::npos) + if (!thumb.empty() && thumb.find('/') == std::string::npos && + thumb.find('\\') == std::string::npos) { std::string strPath = URIUtils::GetDirectory(itemPath); thumb = URIUtils::AddFileToFolder(strPath, thumb); @@ -1695,7 +1694,7 @@ namespace VIDEO // handle .nfo files CInfoScanner::INFO_TYPE result=CInfoScanner::NO_NFO; CScraperUrl scrUrl; - ScraperPtr info(scraper); + const ScraperPtr& info(scraper); std::unique_ptr<IVideoInfoTagLoader> loader; if (useLocal) { diff --git a/xbmc/video/VideoInfoTag.cpp b/xbmc/video/VideoInfoTag.cpp index 9a715cac51..bab6ce7c46 100644 --- a/xbmc/video/VideoInfoTag.cpp +++ b/xbmc/video/VideoInfoTag.cpp @@ -57,6 +57,7 @@ void CVideoInfoTag::Reset() m_artist.clear(); m_strTrailer.clear(); m_iTop250 = 0; + m_year = -1; m_iSeason = -1; m_iEpisode = -1; m_iIdUniqueID = -1; @@ -592,7 +593,7 @@ void CVideoInfoTag::Serialize(CVariant& value) const value["playcount"] = GetPlayCount(); value["lastplayed"] = m_lastPlayed.IsValid() ? m_lastPlayed.GetAsDBDateTime() : StringUtils::Empty; value["top250"] = m_iTop250; - value["year"] = m_premiered.GetYear(); + value["year"] = GetYear(); value["season"] = m_iSeason; value["episode"] = m_iEpisode; for (const auto& i : m_uniqueIDs) @@ -680,7 +681,7 @@ void CVideoInfoTag::ToSortable(SortItem& sortable, Field field) const case FieldPlaycount: sortable[FieldPlaycount] = GetPlayCount(); break; case FieldLastPlayed: sortable[FieldLastPlayed] = m_lastPlayed.IsValid() ? m_lastPlayed.GetAsDBDateTime() : StringUtils::Empty; break; case FieldTop250: sortable[FieldTop250] = m_iTop250; break; - case FieldYear: sortable[FieldYear] = m_premiered.GetYear(); break; + case FieldYear: sortable[FieldYear] = GetYear(); break; case FieldSeason: sortable[FieldSeason] = m_iSeason; break; case FieldEpisodeNumber: sortable[FieldEpisodeNumber] = m_iEpisode; break; case FieldNumberOfEpisodes: sortable[FieldNumberOfEpisodes] = m_iEpisode; break; @@ -731,11 +732,13 @@ const std::string& CVideoInfoTag::GetDefaultRating() const bool CVideoInfoTag::HasYear() const { - return m_firstAired.IsValid() || m_premiered.IsValid(); + return m_year > 0 || m_firstAired.IsValid() || m_premiered.IsValid(); } int CVideoInfoTag::GetYear() const { + if (m_year > 0) + return m_year; if (m_firstAired.IsValid()) return GetFirstAired().GetYear(); if (m_premiered.IsValid()) @@ -1387,16 +1390,16 @@ void CVideoInfoTag::SetVotes(int votes, const std::string& type /* = "" */) m_ratings[type].votes = votes; } -void CVideoInfoTag::SetPremiered(CDateTime premiered) +void CVideoInfoTag::SetPremiered(const CDateTime& premiered) { - m_premiered = std::move(premiered); + m_premiered = premiered; m_bHasPremiered = premiered.IsValid(); } -void CVideoInfoTag::SetPremieredFromDBDate(std::string premieredString) +void CVideoInfoTag::SetPremieredFromDBDate(const std::string& premieredString) { CDateTime premiered; - premiered.SetFromDBDate(std::move(premieredString)); + premiered.SetFromDBDate(premieredString); SetPremiered(premiered); } @@ -1405,10 +1408,7 @@ void CVideoInfoTag::SetYear(int year) if (year <= 0) return; - if (m_bHasPremiered) - m_premiered.SetDate(year, m_premiered.GetMonth(), m_premiered.GetDay()); - else - m_premiered = CDateTime(year, 1, 1, 0, 0, 0); + m_year = year; } void CVideoInfoTag::SetArtist(std::vector<std::string> artist) diff --git a/xbmc/video/VideoInfoTag.h b/xbmc/video/VideoInfoTag.h index 197a6aa6eb..810bef1020 100644 --- a/xbmc/video/VideoInfoTag.h +++ b/xbmc/video/VideoInfoTag.h @@ -137,9 +137,9 @@ public: void SetRatings(RatingMap ratings); void SetVotes(int votes, const std::string& type = ""); void SetUniqueIDs(std::map<std::string, std::string> uniqueIDs); - void SetPremiered(CDateTime premiered); - void SetPremieredFromDBDate(std::string premieredString); - void SetYear(int year); + void SetPremiered(const CDateTime& premiered); + void SetPremieredFromDBDate(const std::string& premieredString); + virtual void SetYear(int year); void SetArtist(std::vector<std::string> artist); void SetSet(std::string set); void SetSetOverview(std::string setOverview); @@ -255,6 +255,7 @@ public: std::vector<std::string> m_showLink; std::map<int, std::string> m_namedSeasons; int m_iTop250; + int m_year; int m_iSeason; int m_iEpisode; int m_iIdUniqueID; diff --git a/xbmc/video/VideoLibraryQueue.cpp b/xbmc/video/VideoLibraryQueue.cpp index e2a488b658..00230f262c 100644 --- a/xbmc/video/VideoLibraryQueue.cpp +++ b/xbmc/video/VideoLibraryQueue.cpp @@ -116,7 +116,8 @@ void CVideoLibraryQueue::CleanLibraryModal(const std::set<int>& paths /* = std:: void CVideoLibraryQueue::RefreshItem(CFileItemPtr item, bool ignoreNfo /* = false */, bool forceRefresh /* = true */, bool refreshAll /* = false */, const std::string& searchTitle /* = "" */) { - AddJob(new CVideoLibraryRefreshingJob(item, forceRefresh, refreshAll, ignoreNfo, searchTitle)); + AddJob(new CVideoLibraryRefreshingJob(std::move(item), forceRefresh, refreshAll, ignoreNfo, + searchTitle)); } bool CVideoLibraryQueue::RefreshItemModal(CFileItemPtr item, bool forceRefresh /* = true */, bool refreshAll /* = false */) @@ -126,7 +127,7 @@ bool CVideoLibraryQueue::RefreshItemModal(CFileItemPtr item, bool forceRefresh / return false; m_modal = true; - CVideoLibraryRefreshingJob refreshingJob(item, forceRefresh, refreshAll); + CVideoLibraryRefreshingJob refreshingJob(std::move(item), forceRefresh, refreshAll); bool result = refreshingJob.DoModal(); m_modal = false; @@ -142,7 +143,7 @@ void CVideoLibraryQueue::MarkAsWatched(const CFileItemPtr &item, bool watched) AddJob(new CVideoLibraryMarkWatchedJob(item, watched)); } -void CVideoLibraryQueue::ResetResumePoint(const CFileItemPtr item) +void CVideoLibraryQueue::ResetResumePoint(const CFileItemPtr& item) { if (item == nullptr) return; diff --git a/xbmc/video/VideoLibraryQueue.h b/xbmc/video/VideoLibraryQueue.h index 328c132da6..57b17ec392 100644 --- a/xbmc/video/VideoLibraryQueue.h +++ b/xbmc/video/VideoLibraryQueue.h @@ -105,7 +105,7 @@ public: \param[in] item Item to reset the resume point for */ - void ResetResumePoint(const CFileItemPtr item); + void ResetResumePoint(const CFileItemPtr& item); /*! \brief Adds the given job to the queue. diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp index ac3edf950a..cef753f4ff 100644 --- a/xbmc/video/VideoThumbLoader.cpp +++ b/xbmc/video/VideoThumbLoader.cpp @@ -232,7 +232,7 @@ std::vector<std::string> GetSettingListAsString(const std::string& settingID) CServiceBroker::GetSettingsComponent()->GetSettings()->GetList(settingID); std::vector<std::string> result; std::transform(values.begin(), values.end(), std::back_inserter(result), - [](CVariant s) { return s.asString(); }); + [](const CVariant& s) { return s.asString(); }); return result; } diff --git a/xbmc/video/ViewModeSettings.cpp b/xbmc/video/ViewModeSettings.cpp index 860752261b..387bdd9f2b 100644 --- a/xbmc/video/ViewModeSettings.cpp +++ b/xbmc/video/ViewModeSettings.cpp @@ -88,7 +88,10 @@ int CViewModeSettings::GetViewModeStringIndex(int viewMode) /** Fills the list with all visible view modes */ -void CViewModeSettings::ViewModesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CViewModeSettings::ViewModesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { // Add all appropriate view modes to the list control for (const auto &item : viewModes) diff --git a/xbmc/video/ViewModeSettings.h b/xbmc/video/ViewModeSettings.h index 1a08988b1e..b43ed85dc1 100644 --- a/xbmc/video/ViewModeSettings.h +++ b/xbmc/video/ViewModeSettings.h @@ -39,6 +39,8 @@ public: /** Fills the list with all visible view modes */ - static void ViewModesFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - + static void ViewModesFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); }; diff --git a/xbmc/video/dialogs/GUIDialogAudioSettings.cpp b/xbmc/video/dialogs/GUIDialogAudioSettings.cpp index 2fa630b073..1e36c6de35 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogAudioSettings.cpp @@ -89,7 +89,7 @@ std::string CGUIDialogAudioSettings::FormatPercentAsDecibel(float value) return StringUtils::Format(g_localizeStrings.Get(14054).c_str(), CAEUtil::PercentToGain(value)); } -void CGUIDialogAudioSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogAudioSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -134,7 +134,7 @@ void CGUIDialogAudioSettings::OnSettingChanged(std::shared_ptr<const CSetting> s } } -void CGUIDialogAudioSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogAudioSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -285,7 +285,8 @@ bool CGUIDialogAudioSettings::SupportsAudioFeature(int feature) return false; } -void CGUIDialogAudioSettings::AddAudioStreams(std::shared_ptr<CSettingGroup> group, const std::string &settingId) +void CGUIDialogAudioSettings::AddAudioStreams(const std::shared_ptr<CSettingGroup>& group, + const std::string& settingId) { if (group == NULL || settingId.empty()) return; @@ -297,12 +298,18 @@ void CGUIDialogAudioSettings::AddAudioStreams(std::shared_ptr<CSettingGroup> gro AddList(group, settingId, 460, SettingLevel::Basic, m_audioStream, AudioStreamsOptionFiller, 460); } -bool CGUIDialogAudioSettings::IsPlayingPassthrough(const std::string &condition, const std::string &value, SettingConstPtr setting, void *data) +bool CGUIDialogAudioSettings::IsPlayingPassthrough(const std::string& condition, + const std::string& value, + const SettingConstPtr& setting, + void* data) { return g_application.GetAppPlayer().IsPassthrough(); } -void CGUIDialogAudioSettings::AudioStreamsOptionFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CGUIDialogAudioSettings::AudioStreamsOptionFiller(const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { int audioStreamCount = g_application.GetAppPlayer().GetAudioStreamCount(); @@ -338,7 +345,12 @@ void CGUIDialogAudioSettings::AudioStreamsOptionFiller(SettingConstPtr setting, } } -std::string CGUIDialogAudioSettings::SettingFormatterDelay(std::shared_ptr<const CSettingControlSlider> control, const CVariant &value, const CVariant &minimum, const CVariant &step, const CVariant &maximum) +std::string CGUIDialogAudioSettings::SettingFormatterDelay( + const std::shared_ptr<const CSettingControlSlider>& control, + const CVariant& value, + const CVariant& minimum, + const CVariant& step, + const CVariant& maximum) { if (!value.isDouble()) return ""; @@ -354,7 +366,12 @@ std::string CGUIDialogAudioSettings::SettingFormatterDelay(std::shared_ptr<const return StringUtils::Format(g_localizeStrings.Get(22005).c_str(), fValue); } -std::string CGUIDialogAudioSettings::SettingFormatterPercentAsDecibel(std::shared_ptr<const CSettingControlSlider> control, const CVariant &value, const CVariant &minimum, const CVariant &step, const CVariant &maximum) +std::string CGUIDialogAudioSettings::SettingFormatterPercentAsDecibel( + const std::shared_ptr<const CSettingControlSlider>& control, + const CVariant& value, + const CVariant& minimum, + const CVariant& step, + const CVariant& maximum) { if (control == NULL || !value.isDouble()) return ""; diff --git a/xbmc/video/dialogs/GUIDialogAudioSettings.h b/xbmc/video/dialogs/GUIDialogAudioSettings.h index ea0fb12446..3a66d8e7e4 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSettings.h +++ b/xbmc/video/dialogs/GUIDialogAudioSettings.h @@ -33,8 +33,8 @@ public: protected: // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } @@ -46,14 +46,30 @@ protected: bool SupportsAudioFeature(int feature); - void AddAudioStreams(std::shared_ptr<CSettingGroup> group, const std::string &settingId); - - static bool IsPlayingPassthrough(const std::string &condition, const std::string &value, std::shared_ptr<const CSetting> setting, void *data); - - static void AudioStreamsOptionFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - - static std::string SettingFormatterDelay(std::shared_ptr<const CSettingControlSlider> control, const CVariant &value, const CVariant &minimum, const CVariant &step, const CVariant &maximum); - static std::string SettingFormatterPercentAsDecibel(std::shared_ptr<const CSettingControlSlider> control, const CVariant &value, const CVariant &minimum, const CVariant &step, const CVariant &maximum); + void AddAudioStreams(const std::shared_ptr<CSettingGroup>& group, const std::string& settingId); + + static bool IsPlayingPassthrough(const std::string& condition, + const std::string& value, + const std::shared_ptr<const CSetting>& setting, + void* data); + + static void AudioStreamsOptionFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + + static std::string SettingFormatterDelay( + const std::shared_ptr<const CSettingControlSlider>& control, + const CVariant& value, + const CVariant& minimum, + const CVariant& step, + const CVariant& maximum); + static std::string SettingFormatterPercentAsDecibel( + const std::shared_ptr<const CSettingControlSlider>& control, + const CVariant& value, + const CVariant& minimum, + const CVariant& step, + const CVariant& maximum); float m_volume; int m_audioStream; diff --git a/xbmc/video/dialogs/GUIDialogCMSSettings.cpp b/xbmc/video/dialogs/GUIDialogCMSSettings.cpp index d3fa1c183c..e2e298d80c 100644 --- a/xbmc/video/dialogs/GUIDialogCMSSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogCMSSettings.cpp @@ -171,7 +171,7 @@ void CGUIDialogCMSSettings::InitializeSettings() settingCmsLutSize->SetDependencies(depsCmsIcc); } -void CGUIDialogCMSSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogCMSSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -209,11 +209,10 @@ void CGUIDialogCMSSettings::Save() CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); } -void CGUIDialogCMSSettings::Cms3dLutsFiller( - SettingConstPtr setting, - std::vector<StringSettingOption> &list, - std::string ¤t, - void *data) +void CGUIDialogCMSSettings::Cms3dLutsFiller(const SettingConstPtr& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data) { // get 3dLut directory from settings CFileItemList items; diff --git a/xbmc/video/dialogs/GUIDialogCMSSettings.h b/xbmc/video/dialogs/GUIDialogCMSSettings.h index 71c7ba4046..67614f54de 100644 --- a/xbmc/video/dialogs/GUIDialogCMSSettings.h +++ b/xbmc/video/dialogs/GUIDialogCMSSettings.h @@ -20,7 +20,7 @@ public: protected: // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } @@ -32,9 +32,8 @@ protected: void InitializeSettings() override; private: - static void Cms3dLutsFiller( - std::shared_ptr<const CSetting> setting, - std::vector<StringSettingOption> &list, - std::string ¤t, - void *data); + static void Cms3dLutsFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<StringSettingOption>& list, + std::string& current, + void* data); }; diff --git a/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp b/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp index ad2770715b..ab5a27b39e 100644 --- a/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogSubtitleSettings.cpp @@ -80,7 +80,7 @@ bool CGUIDialogSubtitleSettings::OnMessage(CGUIMessage& message) return CGUIDialogSettingsManualBase::OnMessage(message); } -void CGUIDialogSubtitleSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogSubtitleSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -154,7 +154,7 @@ std::string CGUIDialogSubtitleSettings::BrowseForSubtitle() return ""; } -void CGUIDialogSubtitleSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogSubtitleSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -296,7 +296,8 @@ bool CGUIDialogSubtitleSettings::SupportsSubtitleFeature(int feature) return false; } -void CGUIDialogSubtitleSettings::AddSubtitleStreams(std::shared_ptr<CSettingGroup> group, const std::string &settingId) +void CGUIDialogSubtitleSettings::AddSubtitleStreams(const std::shared_ptr<CSettingGroup>& group, + const std::string& settingId) { if (group == NULL || settingId.empty()) return; @@ -308,7 +309,11 @@ void CGUIDialogSubtitleSettings::AddSubtitleStreams(std::shared_ptr<CSettingGrou m_subtitleStreamSetting = AddList(group, settingId, 462, SettingLevel::Basic, m_subtitleStream, SubtitleStreamsOptionFiller, 462); } -void CGUIDialogSubtitleSettings::SubtitleStreamsOptionFiller(SettingConstPtr setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CGUIDialogSubtitleSettings::SubtitleStreamsOptionFiller( + const SettingConstPtr& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { int subtitleStreamCount = g_application.GetAppPlayer().GetSubtitleCount(); @@ -343,7 +348,12 @@ void CGUIDialogSubtitleSettings::SubtitleStreamsOptionFiller(SettingConstPtr set } } -std::string CGUIDialogSubtitleSettings::SettingFormatterDelay(std::shared_ptr<const CSettingControlSlider> control, const CVariant &value, const CVariant &minimum, const CVariant &step, const CVariant &maximum) +std::string CGUIDialogSubtitleSettings::SettingFormatterDelay( + const std::shared_ptr<const CSettingControlSlider>& control, + const CVariant& value, + const CVariant& minimum, + const CVariant& step, + const CVariant& maximum) { if (!value.isDouble()) return ""; diff --git a/xbmc/video/dialogs/GUIDialogSubtitleSettings.h b/xbmc/video/dialogs/GUIDialogSubtitleSettings.h index ac7436fa6e..1c14938368 100644 --- a/xbmc/video/dialogs/GUIDialogSubtitleSettings.h +++ b/xbmc/video/dialogs/GUIDialogSubtitleSettings.h @@ -32,8 +32,8 @@ public: protected: // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; // specialization of CGUIDialogSettingsBase bool AllowResettingSettings() const override { return false; } @@ -46,7 +46,8 @@ protected: private: bool SupportsSubtitleFeature(int feature); - void AddSubtitleStreams(std::shared_ptr<CSettingGroup> group, const std::string &settingId); + void AddSubtitleStreams(const std::shared_ptr<CSettingGroup>& group, + const std::string& settingId); int m_subtitleStream; bool m_subtitleVisible; @@ -55,7 +56,15 @@ private: std::vector<int> m_subtitleCapabilities; static std::string FormatFlags(StreamFlags flags); - static void SubtitleStreamsOptionFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - - static std::string SettingFormatterDelay(std::shared_ptr<const CSettingControlSlider> control, const CVariant &value, const CVariant &minimum, const CVariant &step, const CVariant &maximum); + static void SubtitleStreamsOptionFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + + static std::string SettingFormatterDelay( + const std::shared_ptr<const CSettingControlSlider>& control, + const CVariant& value, + const CVariant& minimum, + const CVariant& step, + const CVariant& maximum); }; diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp index d1423a5d0f..759358b420 100644 --- a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp @@ -64,7 +64,7 @@ CGUIDialogVideoSettings::CGUIDialogVideoSettings() CGUIDialogVideoSettings::~CGUIDialogVideoSettings() = default; -void CGUIDialogVideoSettings::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CGUIDialogVideoSettings::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -201,7 +201,7 @@ void CGUIDialogVideoSettings::OnSettingChanged(std::shared_ptr<const CSetting> s } } -void CGUIDialogVideoSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CGUIDialogVideoSettings::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -426,7 +426,8 @@ void CGUIDialogVideoSettings::InitializeSettings() AddButton(groupSaveAsDefault, SETTING_VIDEO_CALIBRATION, 214, SettingLevel::Basic); } -void CGUIDialogVideoSettings::AddVideoStreams(std::shared_ptr<CSettingGroup> group, const std::string &settingId) +void CGUIDialogVideoSettings::AddVideoStreams(const std::shared_ptr<CSettingGroup>& group, + const std::string& settingId) { if (group == NULL || settingId.empty()) return; @@ -438,7 +439,11 @@ void CGUIDialogVideoSettings::AddVideoStreams(std::shared_ptr<CSettingGroup> gro AddList(group, settingId, 38031, SettingLevel::Basic, m_videoStream, VideoStreamsOptionFiller, 38031); } -void CGUIDialogVideoSettings::VideoStreamsOptionFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CGUIDialogVideoSettings::VideoStreamsOptionFiller( + const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { int videoStreamCount = g_application.GetAppPlayer().GetVideoStreamCount(); @@ -487,7 +492,10 @@ void CGUIDialogVideoSettings::VideoStreamsOptionFiller(std::shared_ptr<const CSe } } -void CGUIDialogVideoSettings::VideoOrientationFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data) +void CGUIDialogVideoSettings::VideoOrientationFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data) { list.emplace_back(g_localizeStrings.Get(687), 0); list.emplace_back(g_localizeStrings.Get(35229), 90); diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.h b/xbmc/video/dialogs/GUIDialogVideoSettings.h index 2cf5af8ef9..dd1e1f5fa2 100644 --- a/xbmc/video/dialogs/GUIDialogVideoSettings.h +++ b/xbmc/video/dialogs/GUIDialogVideoSettings.h @@ -25,13 +25,19 @@ public: protected: // implementations of ISettingCallback - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; - - void AddVideoStreams(std::shared_ptr<CSettingGroup> group, const std::string & settingId); - static void VideoStreamsOptionFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); - - static void VideoOrientationFiller(std::shared_ptr<const CSetting> setting, std::vector<IntegerSettingOption> &list, int ¤t, void *data); + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; + + void AddVideoStreams(const std::shared_ptr<CSettingGroup>& group, const std::string& settingId); + static void VideoStreamsOptionFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); + + static void VideoOrientationFiller(const std::shared_ptr<const CSetting>& setting, + std::vector<IntegerSettingOption>& list, + int& current, + void* data); static std::string FormatFlags(StreamFlags flags); diff --git a/xbmc/video/jobs/VideoLibraryRefreshingJob.cpp b/xbmc/video/jobs/VideoLibraryRefreshingJob.cpp index cc42552317..9737e1a797 100644 --- a/xbmc/video/jobs/VideoLibraryRefreshingJob.cpp +++ b/xbmc/video/jobs/VideoLibraryRefreshingJob.cpp @@ -30,12 +30,18 @@ #include "video/tags/VideoInfoTagLoaderFactory.h" #include "video/tags/VideoTagLoaderPlugin.h" +#include <utility> + using namespace KODI::MESSAGING; using namespace VIDEO; -CVideoLibraryRefreshingJob::CVideoLibraryRefreshingJob(CFileItemPtr item, bool forceRefresh, bool refreshAll, bool ignoreNfo /* = false */, const std::string& searchTitle /* = "" */) +CVideoLibraryRefreshingJob::CVideoLibraryRefreshingJob(CFileItemPtr item, + bool forceRefresh, + bool refreshAll, + bool ignoreNfo /* = false */, + const std::string& searchTitle /* = "" */) : CVideoLibraryProgressJob(nullptr), - m_item(item), + m_item(std::move(item)), m_forceRefresh(forceRefresh), m_refreshAll(refreshAll), m_ignoreNfo(ignoreNfo), diff --git a/xbmc/video/jobs/VideoLibraryResetResumePointJob.cpp b/xbmc/video/jobs/VideoLibraryResetResumePointJob.cpp index d3dec07546..52fdbf8e44 100644 --- a/xbmc/video/jobs/VideoLibraryResetResumePointJob.cpp +++ b/xbmc/video/jobs/VideoLibraryResetResumePointJob.cpp @@ -24,7 +24,7 @@ #include "utils/URIUtils.h" #include "video/VideoDatabase.h" -CVideoLibraryResetResumePointJob::CVideoLibraryResetResumePointJob(const CFileItemPtr item) +CVideoLibraryResetResumePointJob::CVideoLibraryResetResumePointJob(const CFileItemPtr& item) : m_item(item) { } diff --git a/xbmc/video/jobs/VideoLibraryResetResumePointJob.h b/xbmc/video/jobs/VideoLibraryResetResumePointJob.h index d9403b4575..367f37c61f 100644 --- a/xbmc/video/jobs/VideoLibraryResetResumePointJob.h +++ b/xbmc/video/jobs/VideoLibraryResetResumePointJob.h @@ -22,7 +22,7 @@ public: \param[in] item Item for that the resume point shall be reset. */ - CVideoLibraryResetResumePointJob(const CFileItemPtr item); + CVideoLibraryResetResumePointJob(const CFileItemPtr& item); ~CVideoLibraryResetResumePointJob() override = default; const char *GetType() const override { return "CVideoLibraryResetResumePointJob"; } diff --git a/xbmc/video/tags/IVideoInfoTagLoader.h b/xbmc/video/tags/IVideoInfoTagLoader.h index b6180721f4..8afc31ec85 100644 --- a/xbmc/video/tags/IVideoInfoTagLoader.h +++ b/xbmc/video/tags/IVideoInfoTagLoader.h @@ -12,6 +12,7 @@ #include "addons/Scraper.h" #include <string> +#include <utility> class CFileItem; class CVideoInfoTag; @@ -28,9 +29,10 @@ public: //! \param item The item to load info for //! \param info Scraper info //! \param llokInFolder True to look in folder holding file - IVideoInfoTagLoader(const CFileItem& item, - ADDON::ScraperPtr info, - bool lookInFolder) : m_item(item), m_info(info) {} + IVideoInfoTagLoader(const CFileItem& item, ADDON::ScraperPtr info, bool lookInFolder) + : m_item(item), m_info(std::move(info)) + { + } virtual ~IVideoInfoTagLoader() = default; //! \brief Returns true if we have info to provide. diff --git a/xbmc/video/tags/VideoInfoTagLoaderFactory.cpp b/xbmc/video/tags/VideoInfoTagLoaderFactory.cpp index 4760724332..00ed67a528 100644 --- a/xbmc/video/tags/VideoInfoTagLoaderFactory.cpp +++ b/xbmc/video/tags/VideoInfoTagLoaderFactory.cpp @@ -19,7 +19,7 @@ using namespace VIDEO; IVideoInfoTagLoader* CVideoInfoTagLoaderFactory::CreateLoader(const CFileItem& item, - ADDON::ScraperPtr info, + const ADDON::ScraperPtr& info, bool lookInFolder, bool forceRefresh) { diff --git a/xbmc/video/tags/VideoInfoTagLoaderFactory.h b/xbmc/video/tags/VideoInfoTagLoaderFactory.h index 0e000ef9d7..9b8861f575 100644 --- a/xbmc/video/tags/VideoInfoTagLoaderFactory.h +++ b/xbmc/video/tags/VideoInfoTagLoaderFactory.h @@ -22,7 +22,7 @@ namespace VIDEO //! \param item The item to find tag loader for //! \param type Type of tag loader. In particular used for tvshows static IVideoInfoTagLoader* CreateLoader(const CFileItem& item, - ADDON::ScraperPtr info, + const ADDON::ScraperPtr& info, bool lookInFolder, bool forceRefresh = false); diff --git a/xbmc/video/tags/VideoTagLoaderNFO.cpp b/xbmc/video/tags/VideoTagLoaderNFO.cpp index e85e62d4f4..d80f41630b 100644 --- a/xbmc/video/tags/VideoTagLoaderNFO.cpp +++ b/xbmc/video/tags/VideoTagLoaderNFO.cpp @@ -18,12 +18,14 @@ #include "utils/log.h" #include "video/VideoInfoTag.h" +#include <utility> + using namespace XFILE; CVideoTagLoaderNFO::CVideoTagLoaderNFO(const CFileItem& item, ADDON::ScraperPtr info, bool lookInFolder) - : IVideoInfoTagLoader(item, info, lookInFolder) + : IVideoInfoTagLoader(item, std::move(info), lookInFolder) { if (m_info && m_info->Content() == CONTENT_TVSHOWS && m_item.m_bIsFolder) m_path = URIUtils::AddFileToFolder(m_item.GetPath(), "tvshow.nfo"); diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index f94a8fce75..adc2d0e05d 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -313,10 +313,10 @@ void CGUIWindowFullScreen::FrameMove() { // get the "View Mode" string - std::string strTitle = g_localizeStrings.Get(629); + const std::string& strTitle = g_localizeStrings.Get(629); const auto& vs = g_application.GetAppPlayer().GetVideoSettings(); int sId = CViewModeSettings::GetViewModeStringIndex(vs.m_ViewMode); - std::string strMode = g_localizeStrings.Get(sId); + const std::string& strMode = g_localizeStrings.Get(sId); std::string strInfo = StringUtils::Format("%s : %s", strTitle.c_str(), strMode.c_str()); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); msg.SetLabel(strInfo); diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 0a07fa5a32..e10db027fd 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -315,7 +315,7 @@ bool CGUIWindowVideoBase::ShowIMDB(CFileItemPtr item, const ScraperPtr &info2, b CGUIDialogSelect* pDlgSelect = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); CGUIDialogVideoInfo* pDlgInfo = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogVideoInfo>(WINDOW_DIALOG_VIDEO_INFO); - ScraperPtr info(info2); // use this as nfo might change it.. + const ScraperPtr& info(info2); // use this as nfo might change it.. if (!pDlgProgress) return false; if (!pDlgSelect) return false; @@ -659,7 +659,7 @@ bool CGUIWindowVideoBase::OnSelect(int iItem) return CGUIMediaWindow::OnSelect(iItem); } -bool CGUIWindowVideoBase::OnFileAction(int iItem, int action, std::string player) +bool CGUIWindowVideoBase::OnFileAction(int iItem, int action, const std::string& player) { CFileItemPtr item = m_vecItems->Get(iItem); @@ -1181,7 +1181,7 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem, const std::string &player) return true; } -bool CGUIWindowVideoBase::OnPlayAndQueueMedia(const CFileItemPtr &item, std::string player) +bool CGUIWindowVideoBase::OnPlayAndQueueMedia(const CFileItemPtr& item, const std::string& player) { // Get the current playlist and make sure it is not shuffled int iPlaylist = m_guiState->GetPlaylist(); @@ -1217,7 +1217,7 @@ void CGUIWindowVideoBase::OnDeleteItem(int iItem) m_viewControl.SetSelectedItem(iItem); } -void CGUIWindowVideoBase::OnDeleteItem(CFileItemPtr item) +void CGUIWindowVideoBase::OnDeleteItem(const CFileItemPtr& item) { // HACK: stacked files need to be treated as folders in order to be deleted if (item->IsStack()) @@ -1419,7 +1419,7 @@ void CGUIWindowVideoBase::GetGroupedItems(CFileItemList &items) bool CGUIWindowVideoBase::CheckFilterAdvanced(CFileItemList &items) const { - std::string content = items.GetContent(); + const std::string& content = items.GetContent(); if ((items.IsVideoDb() || CanContainFilter(m_strFilterPath)) && (StringUtils::EqualsNoCase(content, "movies") || StringUtils::EqualsNoCase(content, "tvshows") || diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index ba5e3f0843..9e4a90b1c5 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -86,7 +86,7 @@ protected: void GetContextButtons(int itemNumber, CContextButtons &buttons) override; bool OnContextButton(int itemNumber, CONTEXT_BUTTON button) override; virtual void OnQueueItem(int iItem, bool first = false); - virtual void OnDeleteItem(CFileItemPtr pItem); + virtual void OnDeleteItem(const CFileItemPtr& pItem); void OnDeleteItem(int iItem) override; virtual void DoSearch(const std::string& strSearch, CFileItemList& items) {}; std::string GetStartFolder(const std::string &dir) override; @@ -103,13 +103,13 @@ protected: \param action the action to perform \return true if the action is performed, false otherwise */ - bool OnFileAction(int item, int action, std::string player); + bool OnFileAction(int item, int action, const std::string& player); void OnRestartItem(int iItem, const std::string &player = ""); bool OnResumeItem(int iItem, const std::string &player = ""); void PlayItem(int iItem, const std::string &player = ""); bool OnPlayMedia(int iItem, const std::string &player = "") override; - bool OnPlayAndQueueMedia(const CFileItemPtr &item, std::string player = "") override; + bool OnPlayAndQueueMedia(const CFileItemPtr& item, const std::string& player = "") override; using CGUIMediaWindow::LoadPlayList; void LoadPlayList(const std::string& strPlayList, int iPlayList = PLAYLIST_VIDEO); diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 779558e9b8..8ee21cc75c 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -152,7 +152,7 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) if (url.GetOption("showinfo") == "true") { // We are here if the item is filtered out in the nav window - std::string path = message.GetStringParam(0); + const std::string& path = message.GetStringParam(0); CFileItem item(path, URIUtils::HasSlashAtEnd(path)); if (item.IsVideoDb()) { @@ -718,9 +718,9 @@ bool CGUIWindowVideoNav::GetFilteredItems(const std::string &filter, CFileItemLi void CGUIWindowVideoNav::DoSearch(const std::string& strSearch, CFileItemList& items) { CFileItemList tempItems; - std::string strGenre = g_localizeStrings.Get(515); // Genre - std::string strActor = g_localizeStrings.Get(20337); // Actor - std::string strDirector = g_localizeStrings.Get(20339); // Director + const std::string& strGenre = g_localizeStrings.Get(515); // Genre + const std::string& strActor = g_localizeStrings.Get(20337); // Actor + const std::string& strDirector = g_localizeStrings.Get(20339); // Director //get matching names m_database.GetMoviesByName(strSearch, tempItems); @@ -807,7 +807,7 @@ void CGUIWindowVideoNav::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr CGUIWindowVideoBase::OnItemInfo(fileItem, scraper); } -void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem) +void CGUIWindowVideoNav::OnDeleteItem(const CFileItemPtr& pItem) { if (m_vecItems->IsParentFolder()) return; @@ -824,6 +824,10 @@ void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem) pItem->GetPath().size() > 22 && pItem->m_bIsFolder) { CGUIDialogYesNo* pDialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO); + + if (!pDialog) + return; + pDialog->SetHeading(CVariant{432}); std::string strLabel = StringUtils::Format(g_localizeStrings.Get(433).c_str(),pItem->GetLabel().c_str()); pDialog->SetLine(1, CVariant{std::move(strLabel)}); diff --git a/xbmc/video/windows/GUIWindowVideoNav.h b/xbmc/video/windows/GUIWindowVideoNav.h index cd3b6375c0..1e3288eea4 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.h +++ b/xbmc/video/windows/GUIWindowVideoNav.h @@ -65,7 +65,7 @@ protected: void UpdateButtons() override; void DoSearch(const std::string& strSearch, CFileItemList& items) override; virtual void PlayItem(int iItem); - void OnDeleteItem(CFileItemPtr pItem) override; + void OnDeleteItem(const CFileItemPtr& pItem) override; void GetContextButtons(int itemNumber, CContextButtons &buttons) override; bool OnContextButton(int itemNumber, CONTEXT_BUTTON button) override; bool OnAddMediaSource() override; diff --git a/xbmc/video/windows/VideoFileItemListModifier.cpp b/xbmc/video/windows/VideoFileItemListModifier.cpp index aab689b826..d1677682ca 100644 --- a/xbmc/video/windows/VideoFileItemListModifier.cpp +++ b/xbmc/video/windows/VideoFileItemListModifier.cpp @@ -64,7 +64,7 @@ void CVideoFileItemListModifier::AddQueuingFolder(CFileItemList& items) { case NODE_TYPE_SEASONS: { - std::string strLabel = g_localizeStrings.Get(20366); + const std::string& strLabel = g_localizeStrings.Get(20366); pItem.reset(new CFileItem(strLabel)); // "All Seasons" videoUrl.AppendPath("-1/"); pItem->SetPath(videoUrl.ToString()); diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index ecd39c9c27..9267cd85cb 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -553,7 +553,7 @@ void CGUIViewState::SaveViewToDb(const std::string &path, int windowID, CViewSta settings->Save(); } -void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks) +void CGUIViewState::AddPlaylistOrder(const CFileItemList& items, const LABEL_MASKS& label_masks) { SortBy sortBy = SortByPlaylistOrder; int sortLabel = 559; diff --git a/xbmc/view/GUIViewState.h b/xbmc/view/GUIViewState.h index 5d2b34dc25..84adf54017 100644 --- a/xbmc/view/GUIViewState.h +++ b/xbmc/view/GUIViewState.h @@ -73,7 +73,7 @@ protected: \param items the list of items for the view state. \param label_mask the label masks for formatting items. */ - void AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks); + void AddPlaylistOrder(const CFileItemList& items, const LABEL_MASKS& label_masks); void AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone, SortOrder sortOrder = SortOrderNone); void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks, SortOrder sortOrder = SortOrderNone); diff --git a/xbmc/weather/WeatherJob.cpp b/xbmc/weather/WeatherJob.cpp index cfa118d4a3..e649c12ddd 100644 --- a/xbmc/weather/WeatherJob.cpp +++ b/xbmc/weather/WeatherJob.cpp @@ -165,7 +165,7 @@ void CWeatherJob::LoadLocalizedToken() std::string CWeatherJob::ConstructPath(std::string in) // copy intended { - if (in.find("/") != std::string::npos || in.find("\\") != std::string::npos) + if (in.find('/') != std::string::npos || in.find('\\') != std::string::npos) return in; if (in.empty() || in == "N/A") in = "na.png"; diff --git a/xbmc/weather/WeatherManager.cpp b/xbmc/weather/WeatherManager.cpp index f9e2ba122f..18248116a6 100644 --- a/xbmc/weather/WeatherManager.cpp +++ b/xbmc/weather/WeatherManager.cpp @@ -149,7 +149,7 @@ void CWeatherManager::OnJobComplete(unsigned int jobID, bool success, CJob *job) CInfoLoader::OnJobComplete(jobID, success, job); } -void CWeatherManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CWeatherManager::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; @@ -165,7 +165,7 @@ void CWeatherManager::OnSettingChanged(std::shared_ptr<const CSetting> setting) } } -void CWeatherManager::OnSettingAction(std::shared_ptr<const CSetting> setting) +void CWeatherManager::OnSettingAction(const std::shared_ptr<const CSetting>& setting) { if (setting == NULL) return; diff --git a/xbmc/weather/WeatherManager.h b/xbmc/weather/WeatherManager.h index 13457a9827..730725bf62 100644 --- a/xbmc/weather/WeatherManager.h +++ b/xbmc/weather/WeatherManager.h @@ -99,8 +99,8 @@ protected: std::string BusyInfo(int info) const override; void OnJobComplete(unsigned int jobID, bool success, CJob *job) override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; - void OnSettingAction(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; + void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override; private: diff --git a/xbmc/windowing/CMakeLists.txt b/xbmc/windowing/CMakeLists.txt index 00439f5a26..21c7611912 100644 --- a/xbmc/windowing/CMakeLists.txt +++ b/xbmc/windowing/CMakeLists.txt @@ -1,12 +1,14 @@ set(SOURCES GraphicContext.cpp OSScreenSaver.cpp Resolution.cpp + WindowSystemFactory.cpp WinSystem.cpp) set(HEADERS GraphicContext.h OSScreenSaver.h Resolution.h WinEvents.h + WindowSystemFactory.h WinSystem.h XBMC_events.h VideoSync.h) diff --git a/xbmc/windowing/Resolution.cpp b/xbmc/windowing/Resolution.cpp index f2835c090c..7f1e1c2ed1 100644 --- a/xbmc/windowing/Resolution.cpp +++ b/xbmc/windowing/Resolution.cpp @@ -20,6 +20,15 @@ #include <cstdlib> +namespace +{ + +const char* SETTING_VIDEOSCREEN_WHITELIST_PULLDOWN{"videoscreen.whitelistpulldown"}; +const char* SETTING_VIDEOSCREEN_WHITELIST_DOUBLEREFRESHRATE{ + "videoscreen.whitelistdoublerefreshrate"}; + +} // namespace + EdgeInsets::EdgeInsets(float l, float t, float r, float b) : left(l), top(t), right(r), bottom(b) { } @@ -80,13 +89,16 @@ RESOLUTION CResolutionUtils::ChooseBestResolution(float fps, int width, int heig void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int height, bool is3D, RESOLUTION &resolution) { RESOLUTION_INFO curr = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(resolution); - CLog::Log(LOGINFO, "Whitelist search for: width: %d, height: %d, fps: %0.3f, 3D: %s", width, - height, fps, is3D ? "true" : "false"); + CLog::Log(LOGINFO, + "[WHITELIST] Searching the whitelist for: width: {}, height: {}, fps: {:0.3f}, 3D: {}", + width, height, fps, is3D ? "true" : "false"); std::vector<CVariant> indexList = CServiceBroker::GetSettingsComponent()->GetSettings()->GetList(CSettings::SETTING_VIDEOSCREEN_WHITELIST); + if (indexList.empty()) { - CLog::Log(LOGDEBUG, "Whitelist is empty using default one"); + CLog::Log(LOGDEBUG, + "[WHITELIST] Using the default whitelist because the user whitelist is empty"); std::vector<RESOLUTION> candidates; RESOLUTION_INFO info; std::string resString; @@ -110,7 +122,7 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei } } - CLog::Log(LOGDEBUG, "Trying to find exact refresh rate"); + CLog::Log(LOGDEBUG, "[WHITELIST] Searching for an exact resolution with an exact refresh rate"); for (const auto& mode : indexList) { @@ -124,64 +136,78 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (curr.dwFlags & D3DPRESENTFLAG_MODEMASK) && MathUtils::FloatEquals(info.fRefreshRate, fps, 0.01f)) { - CLog::Log(LOGDEBUG, "Matched exact whitelisted Resolution %s (%d)", info.strMode.c_str(), i); + CLog::Log(LOGDEBUG, + "[WHITELIST] Matched an exact resolution with an exact refresh rate {} ({})", + info.strMode, i); resolution = i; return; } } - CLog::Log(LOGDEBUG, "No exact whitelisted resolution matched, trying double refresh rate"); + CLog::Log(LOGDEBUG, "[WHITELIST] No match for an exact resolution with an exact refresh rate"); - for (const auto& mode : indexList) + if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( + SETTING_VIDEOSCREEN_WHITELIST_DOUBLEREFRESHRATE)) { - auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); - const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + CLog::Log(LOGDEBUG, + "[WHITELIST] Searching for an exact resolution with double the refresh rate"); - // allow resolutions that are exact and have double the refresh rate - // allow macroblock alignement / padding errors (e.g. 1080 mod16 == 8) - if (((height == info.iScreenHeight && width <= info.iScreenWidth + 8) || - (width == info.iScreenWidth && height <= info.iScreenHeight + 8)) && - (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (curr.dwFlags & D3DPRESENTFLAG_MODEMASK) && - MathUtils::FloatEquals(info.fRefreshRate, fps * 2, 0.01f)) + for (const auto& mode : indexList) { - CLog::Log(LOGDEBUG, "Matched fuzzy whitelisted Resolution %s (%d)", info.strMode.c_str(), i); - resolution = i; - return; + auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); + const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + + // allow resolutions that are exact and have double the refresh rate + // allow macroblock alignement / padding errors (e.g. 1080 mod16 == 8) + if (((height == info.iScreenHeight && width <= info.iScreenWidth + 8) || + (width == info.iScreenWidth && height <= info.iScreenHeight + 8)) && + (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (curr.dwFlags & D3DPRESENTFLAG_MODEMASK) && + MathUtils::FloatEquals(info.fRefreshRate, fps * 2, 0.01f)) + { + CLog::Log(LOGDEBUG, + "[WHITELIST] Matched an exact resolution with double the refresh rate {} ({})", + info.strMode, i); + resolution = i; + return; + } } - } - CLog::Log(LOGDEBUG, "No double whitelisted resolution matched, trying 3:2 pullback"); + CLog::Log(LOGDEBUG, + "[WHITELIST] No match for an exact resolution with double the refresh rate"); + } - for (const auto& mode : indexList) + if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( + SETTING_VIDEOSCREEN_WHITELIST_PULLDOWN)) { - auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); - const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + CLog::Log(LOGDEBUG, + "[WHITELIST] Searching for an exact resolution with a 3:2 pulldown refresh rate"); - // allow resolutions that are exact and have 2.5 times the refresh rate - // allow macroblock alignement / padding errors (e.g. 1080 mod16 == 8) - if (((height == info.iScreenHeight && width <= info.iScreenWidth + 8) || - (width == info.iScreenWidth && height <= info.iScreenHeight + 8)) && - (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (curr.dwFlags & D3DPRESENTFLAG_MODEMASK) && - MathUtils::FloatEquals(info.fRefreshRate, fps * 2.5f, 0.01f)) + for (const auto& mode : indexList) { - CLog::Log(LOGDEBUG, "Matched fuzzy whitelisted Resolution %s (%d)", info.strMode.c_str(), i); - resolution = i; - return; + auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); + const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + + // allow resolutions that are exact and have 2.5 times the refresh rate + // allow macroblock alignement / padding errors (e.g. 1080 mod16 == 8) + if (((height == info.iScreenHeight && width <= info.iScreenWidth + 8) || + (width == info.iScreenWidth && height <= info.iScreenHeight + 8)) && + (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (curr.dwFlags & D3DPRESENTFLAG_MODEMASK) && + MathUtils::FloatEquals(info.fRefreshRate, fps * 2.5f, 0.01f)) + { + CLog::Log( + LOGDEBUG, + "[WHITELIST] Matched an exact resolution with a 3:2 pulldown refresh rate {} ({})", + info.strMode, i); + resolution = i; + return; + } } - } - - CLog::Log(LOGDEBUG, "No 3:2 pullback refresh rate whitelisted resolution matched, trying current resolution"); - if (width <= curr.iScreenWidth - && height <= curr.iScreenHeight - && (MathUtils::FloatEquals(curr.fRefreshRate, fps, 0.01f) - || MathUtils::FloatEquals(curr.fRefreshRate, fps * 2, 0.01f))) - { - CLog::Log(LOGDEBUG, "Matched current Resolution %s (%d)", curr.strMode.c_str(), resolution); - return; + CLog::Log(LOGDEBUG, "[WHITELIST] No match for a resolution with a 3:2 pulldown refresh rate"); } - CLog::Log(LOGDEBUG, "Current resolution doesn't match, trying default resolution"); + + CLog::Log(LOGDEBUG, "[WHITELIST] Searching for a desktop resolution with an exact refresh rate"); const RESOLUTION_INFO desktop_info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(CDisplaySettings::GetInstance().GetCurrentResolution()); @@ -195,49 +221,76 @@ void CResolutionUtils::FindResolutionFromWhitelist(float fps, int width, int hei (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (desktop_info.dwFlags & D3DPRESENTFLAG_MODEMASK) && MathUtils::FloatEquals(info.fRefreshRate, fps, 0.01f)) { - CLog::Log(LOGDEBUG, "Matched fuzzy whitelisted Resolution %s (%d)", info.strMode.c_str(), i); + CLog::Log(LOGDEBUG, + "[WHITELIST] Matched a desktop resolution with an exact refresh rate {} ({})", + info.strMode, i); resolution = i; return; } } - CLog::Log(LOGDEBUG, "Default resolution doesn't provide reqired refreshrate, trying default resolution with double refreshrate"); + CLog::Log(LOGDEBUG, "[WHITELIST] No match for a desktop resolution with an exact refresh rate"); - for (const auto& mode : indexList) + if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( + SETTING_VIDEOSCREEN_WHITELIST_DOUBLEREFRESHRATE)) { - auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); - const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + CLog::Log(LOGDEBUG, + "[WHITELIST] Searching for a desktop resolution with double the refresh rate"); - // allow resolutions that are desktop resolution but have double the refresh rate - if (info.iScreenWidth == desktop_info.iScreenWidth && - (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (desktop_info.dwFlags & D3DPRESENTFLAG_MODEMASK) && - MathUtils::FloatEquals(info.fRefreshRate, fps * 2, 0.01f)) + for (const auto& mode : indexList) { - CLog::Log(LOGDEBUG, "Matched fuzzy whitelisted Resolution %s (%d)", info.strMode.c_str(), i); - resolution = i; - return; + auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); + const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + + // allow resolutions that are desktop resolution but have double the refresh rate + if (info.iScreenWidth == desktop_info.iScreenWidth && + (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == + (desktop_info.dwFlags & D3DPRESENTFLAG_MODEMASK) && + MathUtils::FloatEquals(info.fRefreshRate, fps * 2, 0.01f)) + { + CLog::Log(LOGDEBUG, + "[WHITELIST] Matched a desktop resolution with double the refresh rate {} ({})", + info.strMode, i); + resolution = i; + return; + } } - } - CLog::Log(LOGDEBUG, "Default resolution doesn't provide reqired refreshrate, trying default resolution with 3:2 pullback"); + CLog::Log(LOGDEBUG, + "[WHITELIST] No match for a desktop resolution with double the refresh rate"); + } - for (const auto& mode : indexList) + if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( + SETTING_VIDEOSCREEN_WHITELIST_PULLDOWN)) { - auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); - const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + CLog::Log(LOGDEBUG, + "[WHITELIST] Searching for a desktop resolution with a 3:2 pulldown refresh rate"); - // allow resolutions that are desktop resolution but have 2.5 times the refresh rate - if (info.iScreenWidth == desktop_info.iScreenWidth && - (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == (desktop_info.dwFlags & D3DPRESENTFLAG_MODEMASK) && - MathUtils::FloatEquals(info.fRefreshRate, fps * 2.5f, 0.01f)) + for (const auto& mode : indexList) { - CLog::Log(LOGDEBUG, "Matched fuzzy whitelisted Resolution %s (%d)", info.strMode.c_str(), i); - resolution = i; - return; + auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); + const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + + // allow resolutions that are desktop resolution but have 2.5 times the refresh rate + if (info.iScreenWidth == desktop_info.iScreenWidth && + (info.dwFlags & D3DPRESENTFLAG_MODEMASK) == + (desktop_info.dwFlags & D3DPRESENTFLAG_MODEMASK) && + MathUtils::FloatEquals(info.fRefreshRate, fps * 2.5f, 0.01f)) + { + CLog::Log( + LOGDEBUG, + "[WHITELIST] Matched a desktop resolution with a 3:2 pulldown refresh rate {} ({})", + info.strMode, i); + resolution = i; + return; + } } + + CLog::Log(LOGDEBUG, + "[WHITELIST] No match for a desktop resolution with a 3:2 pulldown refresh rate"); } - CLog::Log(LOGDEBUG, "No whitelisted resolution matched"); + CLog::Log(LOGDEBUG, "[WHITELIST] No resolution matched"); } bool CResolutionUtils::FindResolutionFromOverride(float fps, int width, bool is3D, RESOLUTION &resolution, float& weight, bool fallback) @@ -323,3 +376,21 @@ bool CResolutionUtils::HasWhitelist() std::vector<CVariant> indexList = CServiceBroker::GetSettingsComponent()->GetSettings()->GetList(CSettings::SETTING_VIDEOSCREEN_WHITELIST); return !indexList.empty(); } + +void CResolutionUtils::PrintWhitelist() +{ + std::string modeStr; + auto indexList = CServiceBroker::GetSettingsComponent()->GetSettings()->GetList( + CSettings::SETTING_VIDEOSCREEN_WHITELIST); + if (!indexList.empty()) + { + for (const auto& mode : indexList) + { + auto i = CDisplaySettings::GetInstance().GetResFromString(mode.asString()); + const RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(i); + modeStr.append("\n" + info.strMode); + } + + CLog::Log(LOGDEBUG, "[WHITELIST] whitelisted modes:{}", modeStr); + } +} diff --git a/xbmc/windowing/Resolution.h b/xbmc/windowing/Resolution.h index 6709d22d03..0fb00719a7 100644 --- a/xbmc/windowing/Resolution.h +++ b/xbmc/windowing/Resolution.h @@ -80,6 +80,8 @@ class CResolutionUtils public: static RESOLUTION ChooseBestResolution(float fps, int width, int height, bool is3D); static bool HasWhitelist(); + static void PrintWhitelist(); + protected: static void FindResolutionFromWhitelist(float fps, int width, int height, bool is3D, RESOLUTION &resolution); static bool FindResolutionFromOverride(float fps, int width, bool is3D, RESOLUTION &resolution, float& weight, bool fallback); diff --git a/xbmc/windowing/WinSystem.cpp b/xbmc/windowing/WinSystem.cpp index a75faddb43..b74c8e1728 100644 --- a/xbmc/windowing/WinSystem.cpp +++ b/xbmc/windowing/WinSystem.cpp @@ -33,6 +33,9 @@ bool CWinSystemBase::InitWindowSystem() { UpdateResolutions(); CDisplaySettings::GetInstance().ApplyCalibrations(); + + CResolutionUtils::PrintWhitelist(); + return true; } diff --git a/xbmc/windowing/WinSystem.h b/xbmc/windowing/WinSystem.h index 076d915b04..5e7c2c595d 100644 --- a/xbmc/windowing/WinSystem.h +++ b/xbmc/windowing/WinSystem.h @@ -50,6 +50,8 @@ public: // Access render system interface virtual CRenderSystemBase *GetRenderSystem() { return nullptr; } + virtual const std::string GetName() { return "platform default"; } + // windowing interfaces virtual bool InitWindowSystem(); virtual bool DestroyWindowSystem(); diff --git a/xbmc/windowing/WindowSystemFactory.cpp b/xbmc/windowing/WindowSystemFactory.cpp new file mode 100644 index 0000000000..edb6098e99 --- /dev/null +++ b/xbmc/windowing/WindowSystemFactory.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "WindowSystemFactory.h" + +#include <algorithm> + +using namespace KODI::WINDOWING; + +std::list<std::pair<std::string, std::function<std::unique_ptr<CWinSystemBase>()>>> + CWindowSystemFactory::m_windowSystems; + +std::list<std::string> CWindowSystemFactory::GetWindowSystems() +{ + std::list<std::string> available; + for (const auto& windowSystem : m_windowSystems) + available.emplace_back(windowSystem.first); + + return available; +} + +std::unique_ptr<CWinSystemBase> CWindowSystemFactory::CreateWindowSystem(const std::string& name) +{ + auto windowSystem = + std::find_if(m_windowSystems.begin(), m_windowSystems.end(), + [&name](auto& windowSystem) { return windowSystem.first == name; }); + if (windowSystem != m_windowSystems.end()) + return windowSystem->second(); + + return nullptr; +} + +void CWindowSystemFactory::RegisterWindowSystem( + const std::function<std::unique_ptr<CWinSystemBase>()>& createFunction, const std::string& name) +{ + m_windowSystems.emplace_back(std::make_pair(name, createFunction)); +} diff --git a/xbmc/windowing/WindowSystemFactory.h b/xbmc/windowing/WindowSystemFactory.h new file mode 100644 index 0000000000..20e051dc84 --- /dev/null +++ b/xbmc/windowing/WindowSystemFactory.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "WinSystem.h" + +#include <functional> +#include <list> +#include <map> +#include <memory> + +namespace KODI +{ +namespace WINDOWING +{ + +class CWindowSystemFactory +{ +public: + static std::unique_ptr<CWinSystemBase> CreateWindowSystem(const std::string& name); + static std::list<std::string> GetWindowSystems(); + static void RegisterWindowSystem( + const std::function<std::unique_ptr<CWinSystemBase>()>& createFunction, + const std::string& name = "default"); + +private: + static std::list<std::pair<std::string, std::function<std::unique_ptr<CWinSystemBase>()>>> + m_windowSystems; +}; + +} // namespace WINDOWING +} // namespace KODI diff --git a/xbmc/windowing/X11/VideoSyncGLX.cpp b/xbmc/windowing/X11/VideoSyncGLX.cpp index f2edd6109e..a7f40ea4c5 100644 --- a/xbmc/windowing/X11/VideoSyncGLX.cpp +++ b/xbmc/windowing/X11/VideoSyncGLX.cpp @@ -66,7 +66,7 @@ bool CVideoSyncGLX::Setup(PUPDATECLOCK func) CLog::Log(LOGDEBUG, "CVideoReferenceClock: Setting up GLX"); - m_winSystem.Register(this); + static_cast<CWinSystemX11*>(&m_winSystem)->Register(this); m_displayLost = false; m_displayReset = false; diff --git a/xbmc/windowing/X11/VideoSyncOML.cpp b/xbmc/windowing/X11/VideoSyncOML.cpp index c2f85e4e1c..8e8075449f 100644 --- a/xbmc/windowing/X11/VideoSyncOML.cpp +++ b/xbmc/windowing/X11/VideoSyncOML.cpp @@ -22,7 +22,8 @@ bool CVideoSyncOML::Setup(PUPDATECLOCK func) UpdateClock = func; m_abort = false; - m_winSystem.Register(this); + + static_cast<CWinSystemX11*>(&m_winSystem)->Register(this); return true; } diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp index cf539504cb..8a18288fd8 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -27,8 +27,6 @@ #include "utils/log.h" #include "windowing/GraphicContext.h" -#include "platform/linux/powermanagement/LinuxPowerSyscall.h" - #include <string> #include <vector> @@ -56,7 +54,6 @@ CWinSystemX11::CWinSystemX11() : CWinSystemBase() m_winEventsX11 = new CWinEventsX11(*this); m_winEvents.reset(m_winEventsX11); - CLinuxPowerSyscall::Register(); } CWinSystemX11::~CWinSystemX11() = default; @@ -73,6 +70,12 @@ bool CWinSystemX11::InitWindowSystem() if ((m_dpy = XOpenDisplay(NULL))) { bool ret = CWinSystemBase::InitWindowSystem(); + + CServiceBroker::GetSettingsComponent() + ->GetSettings() + ->GetSetting(CSettings::SETTING_VIDEOSCREEN_LIMITEDRANGE) + ->SetVisible(true); + return ret; } else @@ -471,7 +474,7 @@ void CWinSystemX11::GetConnectedOutputs(std::vector<std::string> *outputs) } } -bool CWinSystemX11::IsCurrentOutput(std::string output) +bool CWinSystemX11::IsCurrentOutput(const std::string& output) { return (StringUtils::EqualsNoCase(output, "Default")) || (m_currentOutput.compare(output.c_str()) == 0); } @@ -814,7 +817,7 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const std: XTextProperty windowName, iconName; std::string titleString = CCompileInfo::GetAppName(); - std::string classString = titleString; + const std::string& classString = titleString; char *title = const_cast<char*>(titleString.c_str()); XStringListToTextProperty(&title, 1, &windowName); diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h index 632f35b6f9..dec8e81b74 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h @@ -37,6 +37,8 @@ public: CWinSystemX11(); ~CWinSystemX11() override; + const std::string GetName() override { return "x11"; } + // CWinSystemBase bool InitWindowSystem() override; bool DestroyWindowSystem() override; @@ -65,7 +67,7 @@ public: int GetScreen() { return m_screen; } void NotifyXRREvent(); void GetConnectedOutputs(std::vector<std::string> *outputs); - bool IsCurrentOutput(std::string output); + bool IsCurrentOutput(const std::string& output); void RecreateWindow(); int GetCrtc() { return m_crtc; } diff --git a/xbmc/windowing/X11/WinSystemX11GLContext.cpp b/xbmc/windowing/X11/WinSystemX11GLContext.cpp index cd497244e2..6f09ef58cf 100644 --- a/xbmc/windowing/X11/WinSystemX11GLContext.cpp +++ b/xbmc/windowing/X11/WinSystemX11GLContext.cpp @@ -25,6 +25,7 @@ #include "utils/StringUtils.h" #include "utils/log.h" #include "windowing/GraphicContext.h" +#include "windowing/WindowSystemFactory.h" #include "platform/freebsd/OptionalsReg.h" #include "platform/linux/OptionalsReg.h" @@ -38,10 +39,14 @@ using namespace KODI; using namespace KODI::WINDOWING::X11; -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemX11GLContext::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemX11GLContext()); - return winSystem; + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem, "x11"); +} + +std::unique_ptr<CWinSystemBase> CWinSystemX11GLContext::CreateWinSystem() +{ + return std::make_unique<CWinSystemX11GLContext>(); } CWinSystemX11GLContext::CWinSystemX11GLContext() diff --git a/xbmc/windowing/X11/WinSystemX11GLContext.h b/xbmc/windowing/X11/WinSystemX11GLContext.h index ae19c6f0ff..ce5fae21fa 100644 --- a/xbmc/windowing/X11/WinSystemX11GLContext.h +++ b/xbmc/windowing/X11/WinSystemX11GLContext.h @@ -34,6 +34,9 @@ public: CWinSystemX11GLContext(); ~CWinSystemX11GLContext() override; + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystem via CWinSystemX11 CRenderSystemBase *GetRenderSystem() override { return this; } bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override; diff --git a/xbmc/windowing/X11/WinSystemX11GLESContext.cpp b/xbmc/windowing/X11/WinSystemX11GLESContext.cpp index e4314e7a2d..86c8b435e5 100644 --- a/xbmc/windowing/X11/WinSystemX11GLESContext.cpp +++ b/xbmc/windowing/X11/WinSystemX11GLESContext.cpp @@ -23,16 +23,21 @@ #include "threads/SingleLock.h" #include "utils/log.h" #include "windowing/GraphicContext.h" +#include "windowing/WindowSystemFactory.h" #include "platform/linux/OptionalsReg.h" using namespace KODI; using namespace KODI::WINDOWING::X11; -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemX11GLESContext::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemX11GLESContext()); - return winSystem; + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem, "x11"); +} + +std::unique_ptr<CWinSystemBase> CWinSystemX11GLESContext::CreateWinSystem() +{ + return std::make_unique<CWinSystemX11GLESContext>(); } CWinSystemX11GLESContext::CWinSystemX11GLESContext() diff --git a/xbmc/windowing/X11/WinSystemX11GLESContext.h b/xbmc/windowing/X11/WinSystemX11GLESContext.h index 85dae0c4e5..02caf60917 100644 --- a/xbmc/windowing/X11/WinSystemX11GLESContext.h +++ b/xbmc/windowing/X11/WinSystemX11GLESContext.h @@ -31,6 +31,9 @@ public: CWinSystemX11GLESContext(); virtual ~CWinSystemX11GLESContext(); + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystem via CWinSystemX11 CRenderSystemBase* GetRenderSystem() override { return this; } bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override; diff --git a/xbmc/windowing/X11/XRandR.cpp b/xbmc/windowing/X11/XRandR.cpp index 93727400b8..99572fb0ab 100644 --- a/xbmc/windowing/X11/XRandR.cpp +++ b/xbmc/windowing/X11/XRandR.cpp @@ -228,7 +228,7 @@ void CXRandR::SaveState() Query(true); } -bool CXRandR::SetMode(XOutput output, XMode mode) +bool CXRandR::SetMode(const XOutput& output, const XMode& mode) { if ((output.name == "" && mode.id == "")) return true; @@ -480,7 +480,7 @@ int CXRandR::GetCrtc(int x, int y, float &hz) (m_outputs[i].y <= y && (m_outputs[i].y+m_outputs[i].h) > y)) { crtc = m_outputs[i].crtc; - for (auto mode: m_outputs[i].modes) + for (const auto& mode : m_outputs[i].modes) { if (mode.isCurrent) { diff --git a/xbmc/windowing/X11/XRandR.h b/xbmc/windowing/X11/XRandR.h index 09495ba437..918c3c28b0 100644 --- a/xbmc/windowing/X11/XRandR.h +++ b/xbmc/windowing/X11/XRandR.h @@ -88,7 +88,7 @@ public: XMode GetCurrentMode(const std::string& outputName); XMode GetPreferredMode(const std::string& outputName); XOutput *GetOutput(const std::string& outputName); - bool SetMode(XOutput output, XMode mode); + bool SetMode(const XOutput& output, const XMode& mode); void LoadCustomModeLinesToAllOutputs(void); void SaveState(); void SetNumScreens(unsigned int num); diff --git a/xbmc/windowing/android/AndroidUtils.cpp b/xbmc/windowing/android/AndroidUtils.cpp index a5afacf40a..ff3a11c924 100644 --- a/xbmc/windowing/android/AndroidUtils.cpp +++ b/xbmc/windowing/android/AndroidUtils.cpp @@ -128,7 +128,7 @@ CAndroidUtils::CAndroidUtils() if (CJNIBase::GetSDKVersion() >= 24) { fetchDisplayModes(); - for (auto res : s_res_displayModes) + for (const auto& res : s_res_displayModes) { if (res.iWidth > m_width || res.iHeight > m_height) { @@ -334,7 +334,7 @@ bool CAndroidUtils::IsHDRDisplay() return ret; } -void CAndroidUtils::OnSettingChanged(std::shared_ptr<const CSetting> setting) +void CAndroidUtils::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) { const std::string &settingId = setting->GetId(); /* Calibration (overscan / subtitles) are based on GUI size -> reset required */ diff --git a/xbmc/windowing/android/AndroidUtils.h b/xbmc/windowing/android/AndroidUtils.h index 28e32152cb..2c531c8673 100644 --- a/xbmc/windowing/android/AndroidUtils.h +++ b/xbmc/windowing/android/AndroidUtils.h @@ -29,7 +29,7 @@ public: // Implementation of ISettingCallback static const std::string SETTING_LIMITGUI; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; + void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; protected: mutable int m_width; diff --git a/xbmc/windowing/android/WinSystemAndroid.cpp b/xbmc/windowing/android/WinSystemAndroid.cpp index b4dca4063b..8e5ef7d83f 100644 --- a/xbmc/windowing/android/WinSystemAndroid.cpp +++ b/xbmc/windowing/android/WinSystemAndroid.cpp @@ -33,7 +33,6 @@ #include "platform/android/activity/XBMCApp.h" #include "platform/android/media/decoderfilter/MediaCodecDecoderFilterManager.h" #include "platform/android/media/drm/MediaDrmCryptoSession.h" -#include "platform/android/powermanagement/AndroidPowerSyscall.h" #include <float.h> #include <string.h> @@ -57,7 +56,6 @@ CWinSystemAndroid::CWinSystemAndroid() m_android = nullptr; m_winEvents.reset(new CWinEventsAndroid()); - CAndroidPowerSyscall::Register(); } CWinSystemAndroid::~CWinSystemAndroid() diff --git a/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp b/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp index 1a438a63fa..fa5590a5e3 100644 --- a/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp +++ b/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp @@ -15,16 +15,20 @@ #include "settings/SettingsComponent.h" #include "threads/SingleLock.h" #include "utils/log.h" +#include "windowing/WindowSystemFactory.h" #include "platform/android/activity/XBMCApp.h" #include <EGL/eglext.h> +void CWinSystemAndroidGLESContext::Register() +{ + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem); +} -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +std::unique_ptr<CWinSystemBase> CWinSystemAndroidGLESContext::CreateWinSystem() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemAndroidGLESContext()); - return winSystem; + return std::make_unique<CWinSystemAndroidGLESContext>(); } bool CWinSystemAndroidGLESContext::InitWindowSystem() diff --git a/xbmc/windowing/android/WinSystemAndroidGLESContext.h b/xbmc/windowing/android/WinSystemAndroidGLESContext.h index 78d285b337..525f05b312 100644 --- a/xbmc/windowing/android/WinSystemAndroidGLESContext.h +++ b/xbmc/windowing/android/WinSystemAndroidGLESContext.h @@ -22,6 +22,9 @@ public: CWinSystemAndroidGLESContext() = default; ~CWinSystemAndroidGLESContext() override = default; + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemAndroid CRenderSystemBase *GetRenderSystem() override { return this; } bool InitWindowSystem() override; diff --git a/xbmc/windowing/gbm/WinSystemGbm.cpp b/xbmc/windowing/gbm/WinSystemGbm.cpp index 27fb49b133..21c6e77411 100644 --- a/xbmc/windowing/gbm/WinSystemGbm.cpp +++ b/xbmc/windowing/gbm/WinSystemGbm.cpp @@ -25,7 +25,6 @@ #include "platform/freebsd/OptionalsReg.h" #include "platform/linux/OptionalsReg.h" -#include "platform/linux/powermanagement/LinuxPowerSyscall.h" #include <string.h> @@ -75,7 +74,6 @@ CWinSystemGbm::CWinSystemGbm() : } m_dpms = std::make_shared<CGBMDPMSSupport>(); - CLinuxPowerSyscall::Register(); m_lirc.reset(OPTIONALS::LircRegister()); m_libinput->Start(); } @@ -121,6 +119,15 @@ bool CWinSystemGbm::InitWindowSystem() return false; } + CServiceBroker::GetSettingsComponent() + ->GetSettings() + ->GetSetting(CSettings::SETTING_VIDEOSCREEN_LIMITEDRANGE) + ->SetVisible(true); + CServiceBroker::GetSettingsComponent() + ->GetSettings() + ->GetSetting("videoscreen.limitguisize") + ->SetVisible(true); + CLog::Log(LOGDEBUG, "CWinSystemGbm::%s - initialized DRM", __FUNCTION__); return CWinSystemBase::InitWindowSystem(); } diff --git a/xbmc/windowing/gbm/WinSystemGbm.h b/xbmc/windowing/gbm/WinSystemGbm.h index 4bb19b734f..3087ea52c5 100644 --- a/xbmc/windowing/gbm/WinSystemGbm.h +++ b/xbmc/windowing/gbm/WinSystemGbm.h @@ -17,6 +17,8 @@ #include "platform/linux/OptionalsReg.h" #include "platform/linux/input/LibInputHandler.h" +#include <utility> + #include <gbm.h> class IDispResource; @@ -34,6 +36,8 @@ public: CWinSystemGbm(); ~CWinSystemGbm() override = default; + const std::string GetName() override { return "gbm"; } + bool InitWindowSystem() override; bool DestroyWindowSystem() override; @@ -55,7 +59,10 @@ public: void Unregister(IDispResource* resource) override; std::shared_ptr<CVideoLayerBridge> GetVideoLayerBridge() const { return m_videoLayerBridge; }; - void RegisterVideoLayerBridge(std::shared_ptr<CVideoLayerBridge> bridge) { m_videoLayerBridge = bridge; }; + void RegisterVideoLayerBridge(std::shared_ptr<CVideoLayerBridge> bridge) + { + m_videoLayerBridge = std::move(bridge); + }; CGBMUtils::CGBMDevice* GetGBMDevice() const { return m_GBM->GetDevice(); } std::shared_ptr<CDRMUtils> GetDrm() const { return m_DRM; } diff --git a/xbmc/windowing/gbm/WinSystemGbmGLContext.cpp b/xbmc/windowing/gbm/WinSystemGbmGLContext.cpp index a3c47e9f4a..f31eec06dd 100644 --- a/xbmc/windowing/gbm/WinSystemGbmGLContext.cpp +++ b/xbmc/windowing/gbm/WinSystemGbmGLContext.cpp @@ -23,6 +23,7 @@ #include "utils/UDMABufferObject.h" #include "utils/XTimeUtils.h" #include "utils/log.h" +#include "windowing/WindowSystemFactory.h" #include <EGL/eglext.h> @@ -32,10 +33,14 @@ CWinSystemGbmGLContext::CWinSystemGbmGLContext() : CWinSystemGbmEGLContext(EGL_PLATFORM_GBM_MESA, "EGL_MESA_platform_gbm") {} -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemGbmGLContext::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemGbmGLContext()); - return winSystem; + CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem, "gbm"); +} + +std::unique_ptr<CWinSystemBase> CWinSystemGbmGLContext::CreateWinSystem() +{ + return std::make_unique<CWinSystemGbmGLContext>(); } bool CWinSystemGbmGLContext::InitWindowSystem() diff --git a/xbmc/windowing/gbm/WinSystemGbmGLContext.h b/xbmc/windowing/gbm/WinSystemGbmGLContext.h index ead8459de0..8994ce6111 100644 --- a/xbmc/windowing/gbm/WinSystemGbmGLContext.h +++ b/xbmc/windowing/gbm/WinSystemGbmGLContext.h @@ -29,6 +29,9 @@ public: CWinSystemGbmGLContext(); ~CWinSystemGbmGLContext() override = default; + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemGbm CRenderSystemBase *GetRenderSystem() override { return this; } bool InitWindowSystem() override; diff --git a/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp b/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp index 20885ccb9f..d07092ba78 100644 --- a/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp +++ b/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp @@ -27,6 +27,7 @@ #include "utils/UDMABufferObject.h" #include "utils/XTimeUtils.h" #include "utils/log.h" +#include "windowing/WindowSystemFactory.h" #include <gbm.h> @@ -36,10 +37,14 @@ CWinSystemGbmGLESContext::CWinSystemGbmGLESContext() : CWinSystemGbmEGLContext(EGL_PLATFORM_GBM_MESA, "EGL_MESA_platform_gbm") {} -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemGbmGLESContext::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemGbmGLESContext()); - return winSystem; + CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem, "gbm"); +} + +std::unique_ptr<CWinSystemBase> CWinSystemGbmGLESContext::CreateWinSystem() +{ + return std::make_unique<CWinSystemGbmGLESContext>(); } bool CWinSystemGbmGLESContext::InitWindowSystem() diff --git a/xbmc/windowing/gbm/WinSystemGbmGLESContext.h b/xbmc/windowing/gbm/WinSystemGbmGLESContext.h index 446a923277..8b9de7700c 100644 --- a/xbmc/windowing/gbm/WinSystemGbmGLESContext.h +++ b/xbmc/windowing/gbm/WinSystemGbmGLESContext.h @@ -29,6 +29,9 @@ public: CWinSystemGbmGLESContext(); ~CWinSystemGbmGLESContext() override = default; + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemGbm CRenderSystemBase *GetRenderSystem() override { return this; } bool InitWindowSystem() override; diff --git a/xbmc/windowing/gbm/drm/DRMAtomic.cpp b/xbmc/windowing/gbm/drm/DRMAtomic.cpp index 35dbdca948..9270aa7e99 100644 --- a/xbmc/windowing/gbm/drm/DRMAtomic.cpp +++ b/xbmc/windowing/gbm/drm/DRMAtomic.cpp @@ -30,20 +30,6 @@ namespace const auto SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter"; -enum drm_scaling_filter -{ - DRM_SCALING_FILTER_DEFAULT, - DRM_SCALING_FILTER_NEAREST_NEIGHBOR, -}; - -uint32_t GetScalingFilterType(const char* type) -{ - if (!strcmp(type, "Nearest Neighbor")) - return DRM_SCALING_FILTER_NEAREST_NEIGHBOR; - else - return DRM_SCALING_FILTER_DEFAULT; -} - uint32_t GetScalingFactor(uint32_t srcWidth, uint32_t srcHeight, uint32_t destWidth, @@ -58,19 +44,15 @@ uint32_t GetScalingFactor(uint32_t srcWidth, } // namespace -bool CDRMAtomic::SetScalingFilter(struct CDRMObject* object, const char* name, const char* type) +bool CDRMAtomic::SetScalingFilter(CDRMObject* object, const char* name, const char* type) { - uint32_t filter_type = GetScalingFilterType(type); - if (object->SupportsPropertyAndValue(name, filter_type)) + uint64_t filter_type{}; + if (m_gui_plane->GetPropertyValue(name, type, filter_type)) { if (AddProperty(object, name, filter_type)) { uint32_t mar_scale_factor = GetScalingFactor(m_width, m_height, m_mode->hdisplay, m_mode->vdisplay); - uint32_t diff_w = m_mode->hdisplay - (mar_scale_factor * m_width); - uint32_t diff_h = m_mode->vdisplay - (mar_scale_factor * m_height); - AddProperty(object, "CRTC_X", (diff_w / 2)); - AddProperty(object, "CRTC_Y", (diff_h / 2)); AddProperty(object, "CRTC_W", (mar_scale_factor * m_width)); AddProperty(object, "CRTC_H", (mar_scale_factor * m_height)); return true; @@ -116,6 +98,8 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video AddProperty(m_gui_plane, "SRC_Y", 0); AddProperty(m_gui_plane, "SRC_W", m_width << 16); AddProperty(m_gui_plane, "SRC_H", m_height << 16); + AddProperty(m_gui_plane, "CRTC_X", 0); + AddProperty(m_gui_plane, "CRTC_Y", 0); //! @todo: disabled until upstream kernel changes are merged // if (DisplayHardwareScalingEnabled()) // { @@ -123,8 +107,6 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video // } // else { - AddProperty(m_gui_plane, "CRTC_X", 0); - AddProperty(m_gui_plane, "CRTC_Y", 0); AddProperty(m_gui_plane, "CRTC_W", m_mode->hdisplay); AddProperty(m_gui_plane, "CRTC_H", m_mode->vdisplay); } @@ -137,21 +119,33 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video AddProperty(m_gui_plane, "CRTC_ID", 0); } - auto ret = drmModeAtomicCommit(m_fd, m_req, flags | DRM_MODE_ATOMIC_TEST_ONLY, nullptr); + auto ret = drmModeAtomicCommit(m_fd, m_req->Get(), flags | DRM_MODE_ATOMIC_TEST_ONLY, nullptr); if (ret < 0) { - CLog::Log(LOGERROR, "CDRMAtomic::{} - test commit failed: {}", __FUNCTION__, strerror(errno)); + CLog::Log(LOGERROR, + "CDRMAtomic::{} - test commit failed: ({}) - falling back to last successful atomic " + "request", + __FUNCTION__, strerror(errno)); + + auto oldRequest = m_atomicRequestQueue.front().get(); + CDRMAtomicRequest::LogAtomicDiff(m_req, oldRequest); + m_req = oldRequest; + + // update the old atomic request with the new fb id to avoid tearing + if (rendered) + AddProperty(m_gui_plane, "FB_ID", fb_id); } - else if (ret == 0) + + ret = drmModeAtomicCommit(m_fd, m_req->Get(), flags, nullptr); + if (ret < 0) { - ret = drmModeAtomicCommit(m_fd, m_req, flags, nullptr); - if (ret < 0) - { - CLog::Log(LOGERROR, "CDRMAtomic::{} - atomic commit failed: {}", __FUNCTION__, - strerror(errno)); - } + CLog::Log(LOGERROR, "CDRMAtomic::{} - atomic commit failed: {}", __FUNCTION__, + strerror(errno)); } + if (CServiceBroker::GetLogging().CanLogComponent(LOGWINDOWING)) + m_req->LogAtomicRequest(); + if (flags & DRM_MODE_ATOMIC_ALLOW_MODESET) { if (drmModeDestroyPropertyBlob(m_fd, blob_id) != 0) @@ -159,8 +153,11 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video strerror(errno)); } - drmModeAtomicFree(m_req); - m_req = drmModeAtomicAlloc(); + if (m_atomicRequestQueue.size() > 1) + m_atomicRequestQueue.pop_back(); + + m_atomicRequestQueue.emplace_back(std::make_unique<CDRMAtomicRequest>()); + m_req = m_atomicRequestQueue.back().get(); } void CDRMAtomic::FlipPage(struct gbm_bo *bo, bool rendered, bool videoLayer) @@ -207,7 +204,8 @@ bool CDRMAtomic::InitDrm() return false; } - m_req = drmModeAtomicAlloc(); + m_atomicRequestQueue.emplace_back(std::make_unique<CDRMAtomicRequest>()); + m_req = m_atomicRequestQueue.back().get(); if (!CDRMUtils::InitDrm()) return false; @@ -234,9 +232,6 @@ bool CDRMAtomic::InitDrm() void CDRMAtomic::DestroyDrm() { CDRMUtils::DestroyDrm(); - - drmModeAtomicFree(m_req); - m_req = nullptr; } bool CDRMAtomic::SetVideoMode(const RESOLUTION_INFO& res, struct gbm_bo *bo) @@ -256,23 +251,92 @@ bool CDRMAtomic::SetActive(bool active) bool CDRMAtomic::AddProperty(CDRMObject* object, const char* name, uint64_t value) { - uint32_t propId = object->GetPropertyId(name); - if (propId == 0) + return m_req->AddProperty(object, name, value); +} + +bool CDRMAtomic::DisplayHardwareScalingEnabled() +{ + auto settings = CServiceBroker::GetSettingsComponent()->GetSettings(); + + if (settings && settings->GetBool(SETTING_VIDEOSCREEN_HW_SCALING_FILTER)) + return true; + + return false; +} + +CDRMAtomic::CDRMAtomicRequest::CDRMAtomicRequest() : m_atomicRequest(drmModeAtomicAlloc()) +{ +} + +bool CDRMAtomic::CDRMAtomicRequest::AddProperty(CDRMObject* object, const char* name, uint64_t value) +{ + uint32_t propertyId = object->GetPropertyId(name); + if (propertyId == 0) return false; - int ret = drmModeAtomicAddProperty(m_req, object->GetId(), propId, value); + int ret = drmModeAtomicAddProperty(m_atomicRequest.get(), object->GetId(), propertyId, value); if (ret < 0) return false; + m_atomicRequestItems[object][propertyId] = value; return true; } -bool CDRMAtomic::DisplayHardwareScalingEnabled() +void CDRMAtomic::CDRMAtomicRequest::LogAtomicDiff(CDRMAtomicRequest* current, + CDRMAtomicRequest* old) { - auto settings = CServiceBroker::GetSettingsComponent()->GetSettings(); + std::map<CDRMObject*, std::map<uint32_t, uint64_t>> atomicDiff; - if (settings && settings->GetBool(SETTING_VIDEOSCREEN_HW_SCALING_FILTER)) - return true; + for (const auto& object : current->m_atomicRequestItems) + { + auto sameObject = old->m_atomicRequestItems.find(object.first); + if (sameObject != old->m_atomicRequestItems.end()) + { + std::map<uint32_t, uint64_t> propertyDiff; - return false; + std::set_difference(current->m_atomicRequestItems[object.first].begin(), + current->m_atomicRequestItems[object.first].end(), + old->m_atomicRequestItems[object.first].begin(), + old->m_atomicRequestItems[object.first].end(), + std::inserter(propertyDiff, propertyDiff.begin())); + + atomicDiff[object.first] = propertyDiff; + } + else + { + atomicDiff[object.first] = current->m_atomicRequestItems[object.first]; + } + } + + CLog::Log(LOGDEBUG, "CDRMAtomicRequest::{} - DRM Atomic Request Diff:", __FUNCTION__); + + LogAtomicRequest(LOGERROR, atomicDiff); +} + +void CDRMAtomic::CDRMAtomicRequest::LogAtomicRequest() +{ + CLog::Log(LOGDEBUG, "CDRMAtomicRequest::{} - DRM Atomic Request:", __FUNCTION__); + LogAtomicRequest(LOGDEBUG, m_atomicRequestItems); +} + +void CDRMAtomic::CDRMAtomicRequest::LogAtomicRequest( + uint8_t logLevel, std::map<CDRMObject*, std::map<uint32_t, uint64_t>>& atomicRequestItems) +{ + std::string message; + for (const auto& object : atomicRequestItems) + { + message.append("\nObject: " + object.first->GetTypeName() + + "\tID: " + std::to_string(object.first->GetId())); + for (const auto& property : object.second) + message.append("\n Property: " + object.first->GetPropertyName(property.first) + + "\tID: " + std::to_string(property.first) + + "\tValue: " + std::to_string(property.second)); + } + + CLog::Log(logLevel, "{}", message); } + +void CDRMAtomic::CDRMAtomicRequest::DrmModeAtomicReqDeleter::operator()(drmModeAtomicReqPtr p) const +{ + drmModeAtomicFree(p); +}; diff --git a/xbmc/windowing/gbm/drm/DRMAtomic.h b/xbmc/windowing/gbm/drm/DRMAtomic.h index 95b23b7f08..ca2cd9a1d0 100644 --- a/xbmc/windowing/gbm/drm/DRMAtomic.h +++ b/xbmc/windowing/gbm/drm/DRMAtomic.h @@ -10,6 +10,11 @@ #include "DRMUtils.h" +#include <cstdint> +#include <deque> +#include <map> +#include <memory> + namespace KODI { namespace WINDOWING @@ -34,11 +39,41 @@ public: private: void DrmAtomicCommit(int fb_id, int flags, bool rendered, bool videoLayer); - bool SetScalingFilter(struct CDRMObject* object, const char* name, const char* type); + bool SetScalingFilter(CDRMObject* object, const char* name, const char* type); bool m_need_modeset; bool m_active = true; - drmModeAtomicReq *m_req = nullptr; + + class CDRMAtomicRequest + { + public: + CDRMAtomicRequest(); + ~CDRMAtomicRequest() = default; + CDRMAtomicRequest(const CDRMAtomicRequest& right) = delete; + + drmModeAtomicReqPtr Get() const { return m_atomicRequest.get(); } + + bool AddProperty(CDRMObject* object, const char* name, uint64_t value); + void LogAtomicRequest(); + + static void LogAtomicDiff(CDRMAtomicRequest* current, CDRMAtomicRequest* old); + + private: + static void LogAtomicRequest( + uint8_t logLevel, std::map<CDRMObject*, std::map<uint32_t, uint64_t>>& atomicRequestItems); + + std::map<CDRMObject*, std::map<uint32_t, uint64_t>> m_atomicRequestItems; + + struct DrmModeAtomicReqDeleter + { + void operator()(drmModeAtomicReqPtr p) const; + }; + + std::unique_ptr<drmModeAtomicReq, DrmModeAtomicReqDeleter> m_atomicRequest; + }; + + CDRMAtomicRequest* m_req = nullptr; + std::deque<std::unique_ptr<CDRMAtomicRequest>> m_atomicRequestQueue; }; } diff --git a/xbmc/windowing/gbm/drm/DRMCrtc.cpp b/xbmc/windowing/gbm/drm/DRMCrtc.cpp index 906cb6dae0..426fd953bb 100644 --- a/xbmc/windowing/gbm/drm/DRMCrtc.cpp +++ b/xbmc/windowing/gbm/drm/DRMCrtc.cpp @@ -9,7 +9,9 @@ #include "DRMCrtc.h" #include <cstring> +#include <errno.h> #include <stdexcept> +#include <string> using namespace KODI::WINDOWING::GBM; diff --git a/xbmc/windowing/gbm/drm/DRMEncoder.cpp b/xbmc/windowing/gbm/drm/DRMEncoder.cpp index 4c0b92f708..e4289c6b68 100644 --- a/xbmc/windowing/gbm/drm/DRMEncoder.cpp +++ b/xbmc/windowing/gbm/drm/DRMEncoder.cpp @@ -9,7 +9,9 @@ #include "DRMEncoder.h" #include <cstring> +#include <errno.h> #include <stdexcept> +#include <string> using namespace KODI::WINDOWING::GBM; diff --git a/xbmc/windowing/gbm/drm/DRMObject.cpp b/xbmc/windowing/gbm/drm/DRMObject.cpp index d126049285..6449cfd86e 100644 --- a/xbmc/windowing/gbm/drm/DRMObject.cpp +++ b/xbmc/windowing/gbm/drm/DRMObject.cpp @@ -12,13 +12,48 @@ #include "utils/log.h" #include <algorithm> +#include <array> using namespace KODI::WINDOWING::GBM; +namespace +{ + +constexpr std::array<std::pair<uint32_t, const char*>, 8> DrmModeObjectTypes = { + {{DRM_MODE_OBJECT_CRTC, "crtc"}, + {DRM_MODE_OBJECT_CONNECTOR, "connector"}, + {DRM_MODE_OBJECT_ENCODER, "encoder"}, + {DRM_MODE_OBJECT_MODE, "mode"}, + {DRM_MODE_OBJECT_PROPERTY, "property"}, + {DRM_MODE_OBJECT_FB, "framebuffer"}, + {DRM_MODE_OBJECT_BLOB, "blob"}, + {DRM_MODE_OBJECT_PLANE, "plane"}}}; +} + CDRMObject::CDRMObject(int fd) : m_fd(fd) { } +std::string CDRMObject::GetTypeName() const +{ + auto name = std::find_if(DrmModeObjectTypes.begin(), DrmModeObjectTypes.end(), + [this](auto& p) { return p.first == m_type; }); + if (name != DrmModeObjectTypes.end()) + return name->second; + + return "invalid type"; +} + +std::string CDRMObject::GetPropertyName(uint32_t propertyId) const +{ + auto prop = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), + [&propertyId](auto& p) { return p->prop_id == propertyId; }); + if (prop != m_propsInfo.end()) + return prop->get()->name; + + return "invalid property"; +} + uint32_t CDRMObject::GetPropertyId(const char* name) const { auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { @@ -47,6 +82,32 @@ bool CDRMObject::GetProperties(uint32_t id, uint32_t type) return true; } +bool CDRMObject::GetPropertyValue(std::string name, const std::string& type, uint64_t& value) const +{ + auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { + return StringUtils::EqualsNoCase(prop->name, name); + }); + + if (property == m_propsInfo.end()) + return false; + + auto prop = property->get(); + + if (drm_property_type_is(prop, DRM_MODE_PROP_ENUM) != 0) + { + for (int j = 0; j < prop->count_enums; j++) + { + if (std::strcmp(prop->enums[j].name, type.c_str()) == 0) + { + value = prop->enums[j].value; + return true; + } + } + } + + return false; +} + bool CDRMObject::SetProperty(const char* name, uint64_t value) { auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) { diff --git a/xbmc/windowing/gbm/drm/DRMObject.h b/xbmc/windowing/gbm/drm/DRMObject.h index e736f876ec..836418813f 100644 --- a/xbmc/windowing/gbm/drm/DRMObject.h +++ b/xbmc/windowing/gbm/drm/DRMObject.h @@ -29,8 +29,12 @@ public: CDRMObject& operator=(const CDRMObject&) = delete; virtual ~CDRMObject() = default; + std::string GetTypeName() const; + std::string GetPropertyName(uint32_t propertyId) const; + uint32_t GetId() const { return m_id; } uint32_t GetPropertyId(const char* name) const; + bool GetPropertyValue(std::string name, const std::string& type, uint64_t& value) const; bool SetProperty(const char* name, uint64_t value); bool SupportsProperty(const char* name); diff --git a/xbmc/windowing/gbm/drm/DRMUtils.cpp b/xbmc/windowing/gbm/drm/DRMUtils.cpp index 20c5ffded5..836597b46a 100644 --- a/xbmc/windowing/gbm/drm/DRMUtils.cpp +++ b/xbmc/windowing/gbm/drm/DRMUtils.cpp @@ -181,7 +181,7 @@ bool CDRMUtils::FindPlanes() if (!(m_encoder->GetPossibleCrtcs() & (1 << i))) continue; - auto videoPlane = std::find_if(m_planes.begin(), m_planes.end(), [this, &i](auto& plane) { + auto videoPlane = std::find_if(m_planes.begin(), m_planes.end(), [&i](auto& plane) { if (plane->GetPossibleCrtcs() & (1 << i)) { return plane->SupportsFormat(DRM_FORMAT_NV12); @@ -195,7 +195,7 @@ bool CDRMUtils::FindPlanes() videoPlaneId = videoPlane->get()->GetPlaneId(); auto guiPlane = - std::find_if(m_planes.begin(), m_planes.end(), [this, &i, &videoPlaneId](auto& plane) { + std::find_if(m_planes.begin(), m_planes.end(), [&i, &videoPlaneId](auto& plane) { if (plane->GetPossibleCrtcs() & (1 << i)) { return (plane->GetPlaneId() != videoPlaneId && @@ -205,7 +205,7 @@ bool CDRMUtils::FindPlanes() return false; }); - if (videoPlane->get() && guiPlane->get()) + if (videoPlane != m_planes.end() && guiPlane != m_planes.end()) { m_crtc = m_crtcs[i].get(); m_video_plane = videoPlane->get(); @@ -213,12 +213,13 @@ bool CDRMUtils::FindPlanes() break; } - if (guiPlane->get()) + if (guiPlane != m_planes.end()) { if (!m_crtc && m_encoder->GetCrtcId() == m_crtcs[i]->GetCrtcId()) { m_crtc = m_crtcs[i].get(); m_gui_plane = guiPlane->get(); + m_video_plane = nullptr; } } } @@ -320,48 +321,45 @@ bool CDRMUtils::OpenDrm(bool needConnector) for (const auto device : devices) { - for (int i = 0; i < DRM_NODE_MAX; i++) - { - if (device->available_nodes & 1 << i) - { - CLog::Log(LOGDEBUG, "CDRMUtils::{} - opening device: {}", __FUNCTION__, device->nodes[i]); - PrintDrmDeviceInfo(device); + if (!(device->available_nodes & 1 << DRM_NODE_PRIMARY)) + continue; - close(m_fd); - m_fd = open(device->nodes[i], O_RDWR | O_CLOEXEC); - if (m_fd < 0) - continue; + close(m_fd); + m_fd = open(device->nodes[DRM_NODE_PRIMARY], O_RDWR | O_CLOEXEC); + if (m_fd < 0) + continue; - if (needConnector) - { - auto resources = drmModeGetResources(m_fd); - if (!resources) - continue; + if (needConnector) + { + auto resources = drmModeGetResources(m_fd); + if (!resources) + continue; - for (int i = 0; i < resources->count_connectors; i++) - { - auto connector = std::make_unique<CDRMConnector>(m_fd, resources->connectors[i]); - if (connector->GetEncoderId() > 0 && connector->IsConnected()) - break; - } + m_connectors.clear(); + for (int i = 0; i < resources->count_connectors; i++) + m_connectors.emplace_back(std::make_unique<CDRMConnector>(m_fd, resources->connectors[i])); - drmModeFreeResources(resources); - } + drmModeFreeResources(resources); - CLog::Log(LOGDEBUG, "CDRMUtils::{} - opened device: {}", __FUNCTION__, device->nodes[i]); + if (!FindConnector()) + continue; + } - const char* renderPath = drmGetRenderDeviceNameFromFd(m_fd); - if (renderPath) - { - m_renderFd = open(renderPath, O_RDWR | O_CLOEXEC); - if (m_renderFd != 0) - CLog::Log(LOGDEBUG, "CDRMUtils::{} - opened render node: {}", __FUNCTION__, renderPath); - } + CLog::Log(LOGDEBUG, "CDRMUtils::{} - opened device: {}", __FUNCTION__, + device->nodes[DRM_NODE_PRIMARY]); - drmFreeDevices(devices.data(), devices.size()); - return true; - } + PrintDrmDeviceInfo(device); + + const char* renderPath = drmGetRenderDeviceNameFromFd(m_fd); + if (renderPath) + { + m_renderFd = open(renderPath, O_RDWR | O_CLOEXEC); + if (m_renderFd != 0) + CLog::Log(LOGDEBUG, "CDRMUtils::{} - opened render node: {}", __FUNCTION__, renderPath); } + + drmFreeDevices(devices.data(), devices.size()); + return true; } drmFreeDevices(devices.data(), devices.size()); @@ -404,12 +402,15 @@ bool CDRMUtils::InitDrm() return false; } + m_connectors.clear(); for (int i = 0; i < resources->count_connectors; i++) m_connectors.emplace_back(std::make_unique<CDRMConnector>(m_fd, resources->connectors[i])); + m_encoders.clear(); for (int i = 0; i < resources->count_encoders; i++) m_encoders.emplace_back(std::make_unique<CDRMEncoder>(m_fd, resources->encoders[i])); + m_crtcs.clear(); for (int i = 0; i < resources->count_crtcs; i++) m_crtcs.emplace_back(std::make_unique<CDRMCrtc>(m_fd, resources->crtcs[i])); @@ -422,6 +423,7 @@ bool CDRMUtils::InitDrm() return false; } + m_planes.clear(); for (uint32_t i = 0; i < planeResources->count_planes; i++) { m_planes.emplace_back(std::make_unique<CDRMPlane>(m_fd, planeResources->planes[i])); @@ -478,7 +480,7 @@ bool CDRMUtils::InitDrm() bool CDRMUtils::FindConnector() { - auto connector = std::find_if(m_connectors.begin(), m_connectors.end(), [this](auto& connector) { + auto connector = std::find_if(m_connectors.begin(), m_connectors.end(), [](auto& connector) { return connector->GetEncoderId() > 0 && connector->IsConnected(); }); diff --git a/xbmc/windowing/ios/WinSystemIOS.h b/xbmc/windowing/ios/WinSystemIOS.h index 882a7cd14c..cb910185a8 100644 --- a/xbmc/windowing/ios/WinSystemIOS.h +++ b/xbmc/windowing/ios/WinSystemIOS.h @@ -27,6 +27,9 @@ public: CWinSystemIOS(); ~CWinSystemIOS() override; + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + int GetDisplayIndexFromSettings(); // Implementation of CWinSystemBase CRenderSystemBase *GetRenderSystem() override { return this; } diff --git a/xbmc/windowing/ios/WinSystemIOS.mm b/xbmc/windowing/ios/WinSystemIOS.mm index 274a6b17f9..91c173f35c 100644 --- a/xbmc/windowing/ios/WinSystemIOS.mm +++ b/xbmc/windowing/ios/WinSystemIOS.mm @@ -31,6 +31,7 @@ #include "utils/StringUtils.h" #include "utils/log.h" #include "windowing/GraphicContext.h" +#include "windowing/WindowSystemFactory.h" #import "platform/darwin/ios/IOSScreenManager.h" #import "platform/darwin/ios/XBMCController.h" @@ -64,10 +65,14 @@ struct CADisplayLinkWrapper IOSDisplayLinkCallback *callbackClass; }; -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemIOS::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemIOS()); - return winSystem; + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem); +} + +std::unique_ptr<CWinSystemBase> CWinSystemIOS::CreateWinSystem() +{ + return std::make_unique<CWinSystemIOS>(); } int CWinSystemIOS::GetDisplayIndexFromSettings() @@ -238,7 +243,7 @@ bool CWinSystemIOS::GetScreenResolution(int* w, int* h, double* fps, int screenI *w = firstMode.size.width; *h = firstMode.size.height; } - + // for mainscreen use the eagl bounds from xbmcController // because mainscreen is might be 90° rotate dependend on // the device and eagl gives the correct values in all cases. @@ -256,7 +261,7 @@ bool CWinSystemIOS::GetScreenResolution(int* w, int* h, double* fps, int screenI m_internalTouchscreenResolutionWidth = [g_xbmcController getScreenSize].width; m_internalTouchscreenResolutionHeight = [g_xbmcController getScreenSize].height; } - + *w = m_internalTouchscreenResolutionWidth; *h = m_internalTouchscreenResolutionHeight; } diff --git a/xbmc/windowing/osx/WinSystemOSX.mm b/xbmc/windowing/osx/WinSystemOSX.mm index 37781218a4..b6a3b2e35c 100644 --- a/xbmc/windowing/osx/WinSystemOSX.mm +++ b/xbmc/windowing/osx/WinSystemOSX.mm @@ -43,7 +43,6 @@ #include "platform/darwin/osx/CocoaInterface.h" #import "platform/darwin/osx/OSXTextInputResponder.h" #include "platform/darwin/osx/XBMCHelper.h" -#include "platform/darwin/osx/powermanagement/CocoaPowerSyscall.h" #include <cstdlib> #include <signal.h> @@ -273,7 +272,7 @@ CFArrayRef GetAllDisplayModes(CGDirectDisplayID display) // mimic former behavior of deprecated CGDisplayBestModeForParameters CGDisplayModeRef BestMatchForMode(CGDirectDisplayID display, size_t bitsPerPixel, size_t width, size_t height, boolean_t &match) { - + // Get a copy of the current display mode CGDisplayModeRef displayMode = CGDisplayCopyDisplayMode(display); @@ -445,7 +444,7 @@ NSString* screenNameForDisplay(CGDirectDisplayID displayID) return screenName; } -int GetDisplayIndex(std::string dispName) +int GetDisplayIndex(const std::string& dispName) { int ret = 0; @@ -670,7 +669,6 @@ CWinSystemOSX::CWinSystemOSX() AE::CAESinkFactory::ClearSinks(); CAESinkDARWINOSX::Register(); - CCocoaPowerSyscall::Register(); m_dpms = std::make_shared<CCocoaDPMSSupport>(); } @@ -1125,7 +1123,7 @@ void CWinSystemOSX::UpdateResolutions() int dispIdx = GetDisplayIndex(CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_VIDEOSCREEN_MONITOR)); GetScreenResolution(&w, &h, &fps, dispIdx); - NSString *dispName = screenNameForDisplay(GetDisplayID(dispIdx)); + NSString* dispName = screenNameForDisplay(GetDisplayID(dispIdx)); UpdateDesktopResolution(CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP), [dispName UTF8String], w, h, fps, 0); CDisplaySettings::GetInstance().ClearCustomResolutions(); diff --git a/xbmc/windowing/osx/WinSystemOSXGL.h b/xbmc/windowing/osx/WinSystemOSXGL.h index d7b05c9319..e40fe1abde 100644 --- a/xbmc/windowing/osx/WinSystemOSXGL.h +++ b/xbmc/windowing/osx/WinSystemOSXGL.h @@ -17,6 +17,9 @@ public: CWinSystemOSXGL() = default; ~CWinSystemOSXGL() override = default; + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemOSX CRenderSystemBase *GetRenderSystem() override { return this; } bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override; diff --git a/xbmc/windowing/osx/WinSystemOSXGL.mm b/xbmc/windowing/osx/WinSystemOSXGL.mm index 4b6b20575c..717c79ae87 100644 --- a/xbmc/windowing/osx/WinSystemOSXGL.mm +++ b/xbmc/windowing/osx/WinSystemOSXGL.mm @@ -10,14 +10,17 @@ #include "guilib/Texture.h" #include "rendering/gl/RenderSystemGL.h" +#include "windowing/WindowSystemFactory.h" -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemOSXGL::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemOSXGL()); - return winSystem; + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem); +} + +std::unique_ptr<CWinSystemBase> CWinSystemOSXGL::CreateWinSystem() +{ + return std::make_unique<CWinSystemOSXGL>(); } void CWinSystemOSXGL::PresentRenderImpl(bool rendered) diff --git a/xbmc/windowing/tvos/WinSystemTVOS.h b/xbmc/windowing/tvos/WinSystemTVOS.h index c03e46803d..720bcc779f 100644 --- a/xbmc/windowing/tvos/WinSystemTVOS.h +++ b/xbmc/windowing/tvos/WinSystemTVOS.h @@ -30,6 +30,9 @@ public: CWinSystemTVOS(); virtual ~CWinSystemTVOS(); + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // ITimerCallback interface virtual void OnTimeout() override {} diff --git a/xbmc/windowing/tvos/WinSystemTVOS.mm b/xbmc/windowing/tvos/WinSystemTVOS.mm index abf09927d2..f7d9d73ff5 100644 --- a/xbmc/windowing/tvos/WinSystemTVOS.mm +++ b/xbmc/windowing/tvos/WinSystemTVOS.mm @@ -29,6 +29,7 @@ #include "utils/log.h" #include "windowing/GraphicContext.h" #include "windowing/OSScreenSaver.h" +#include "windowing/WindowSystemFactory.h" #import "windowing/tvos/OSScreenSaverTVOS.h" #import "windowing/tvos/VideoSyncTVos.h" #import "windowing/tvos/WinEventsTVOS.h" @@ -36,7 +37,6 @@ #import "platform/darwin/DarwinUtils.h" #import "platform/darwin/tvos/TVOSDisplayManager.h" #import "platform/darwin/tvos/XBMCController.h" -#include "platform/darwin/tvos/powermanagement/TVOSPowerSyscall.h" #include <memory> #include <vector> @@ -73,10 +73,14 @@ struct CADisplayLinkWrapper TVOSDisplayLinkCallback* callbackClass; }; -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemTVOS::Register() { - std::unique_ptr<CWinSystemBase> winSystem = std::make_unique<CWinSystemTVOS>(); - return winSystem; + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem); +} + +std::unique_ptr<CWinSystemBase> CWinSystemTVOS::CreateWinSystem() +{ + return std::make_unique<CWinSystemTVOS>(); } void CWinSystemTVOS::MessagePush(XBMC_Event* newEvent) @@ -136,7 +140,6 @@ CWinSystemTVOS::CWinSystemTVOS() : CWinSystemBase(), m_lostDeviceTimer(this) m_winEvents.reset(new CWinEventsTVOS()); CAESinkDARWINTVOS::Register(); - CTVOSPowerSyscall::Register(); } CWinSystemTVOS::~CWinSystemTVOS() diff --git a/xbmc/windowing/wayland/InputProcessorKeyboard.cpp b/xbmc/windowing/wayland/InputProcessorKeyboard.cpp index 58607be124..0f4241c4e3 100644 --- a/xbmc/windowing/wayland/InputProcessorKeyboard.cpp +++ b/xbmc/windowing/wayland/InputProcessorKeyboard.cpp @@ -52,12 +52,17 @@ void CInputProcessorKeyboard::OnKeyboardKeymap(CSeat* seat, wayland::keyboard_ke } } -void CInputProcessorKeyboard::OnKeyboardEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, wayland::array_t keys) +void CInputProcessorKeyboard::OnKeyboardEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + const wayland::array_t& keys) { m_handler.OnKeyboardEnter(); } -void CInputProcessorKeyboard::OnKeyboardLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) +void CInputProcessorKeyboard::OnKeyboardLeave(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface) { m_keyRepeatTimer.Stop(); m_handler.OnKeyboardLeave(); diff --git a/xbmc/windowing/wayland/InputProcessorKeyboard.h b/xbmc/windowing/wayland/InputProcessorKeyboard.h index f5efb8c27f..73a37cee7f 100644 --- a/xbmc/windowing/wayland/InputProcessorKeyboard.h +++ b/xbmc/windowing/wayland/InputProcessorKeyboard.h @@ -40,8 +40,13 @@ public: CInputProcessorKeyboard(IInputHandlerKeyboard& handler); void OnKeyboardKeymap(CSeat* seat, wayland::keyboard_keymap_format format, std::string const& keymap) override; - void OnKeyboardEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, wayland::array_t keys) override; - void OnKeyboardLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) override; + void OnKeyboardEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + const wayland::array_t& keys) override; + void OnKeyboardLeave(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface) override; void OnKeyboardKey(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::uint32_t key, wayland::keyboard_key_state state) override; void OnKeyboardModifiers(CSeat* seat, std::uint32_t serial, std::uint32_t modsDepressed, std::uint32_t modsLatched, std::uint32_t modsLocked, std::uint32_t group) override; void OnKeyboardRepeatInfo(CSeat* seat, std::int32_t rate, std::int32_t delay) override; diff --git a/xbmc/windowing/wayland/InputProcessorPointer.cpp b/xbmc/windowing/wayland/InputProcessorPointer.cpp index 851a7b0f69..7cb9805709 100644 --- a/xbmc/windowing/wayland/InputProcessorPointer.cpp +++ b/xbmc/windowing/wayland/InputProcessorPointer.cpp @@ -42,7 +42,11 @@ CInputProcessorPointer::CInputProcessorPointer(wayland::surface_t const& surface { } -void CInputProcessorPointer::OnPointerEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, double surfaceX, double surfaceY) +void CInputProcessorPointer::OnPointerEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + double surfaceX, + double surfaceY) { if (surface == m_surface) { @@ -53,7 +57,9 @@ void CInputProcessorPointer::OnPointerEnter(CSeat* seat, std::uint32_t serial, w } } -void CInputProcessorPointer::OnPointerLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) +void CInputProcessorPointer::OnPointerLeave(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface) { if (m_pointerOnSurface) { diff --git a/xbmc/windowing/wayland/InputProcessorPointer.h b/xbmc/windowing/wayland/InputProcessorPointer.h index f510215ce9..ce44601a7d 100644 --- a/xbmc/windowing/wayland/InputProcessorPointer.h +++ b/xbmc/windowing/wayland/InputProcessorPointer.h @@ -40,8 +40,14 @@ public: CInputProcessorPointer(wayland::surface_t const& surface, IInputHandlerPointer& handler); void SetCoordinateScale(std::int32_t scale) { m_coordinateScale = scale; } - void OnPointerEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, double surfaceX, double surfaceY) override; - void OnPointerLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) override; + void OnPointerEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + double surfaceX, + double surfaceY) override; + void OnPointerLeave(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface) override; void OnPointerMotion(CSeat* seat, std::uint32_t time, double surfaceX, double surfaceY) override; void OnPointerButton(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::uint32_t button, wayland::pointer_button_state state) override; void OnPointerAxis(CSeat* seat, std::uint32_t time, wayland::pointer_axis axis, double value) override; diff --git a/xbmc/windowing/wayland/InputProcessorTouch.cpp b/xbmc/windowing/wayland/InputProcessorTouch.cpp index 8f1208b9d9..a664e32ef6 100644 --- a/xbmc/windowing/wayland/InputProcessorTouch.cpp +++ b/xbmc/windowing/wayland/InputProcessorTouch.cpp @@ -17,7 +17,13 @@ CInputProcessorTouch::CInputProcessorTouch(wayland::surface_t const& surface) { } -void CInputProcessorTouch::OnTouchDown(CSeat* seat, std::uint32_t serial, std::uint32_t time, wayland::surface_t surface, std::int32_t id, double x, double y) +void CInputProcessorTouch::OnTouchDown(CSeat* seat, + std::uint32_t serial, + std::uint32_t time, + const wayland::surface_t& surface, + std::int32_t id, + double x, + double y) { if (surface != m_surface) { diff --git a/xbmc/windowing/wayland/InputProcessorTouch.h b/xbmc/windowing/wayland/InputProcessorTouch.h index 782749c5be..fa6f606976 100644 --- a/xbmc/windowing/wayland/InputProcessorTouch.h +++ b/xbmc/windowing/wayland/InputProcessorTouch.h @@ -35,7 +35,13 @@ public: ~CInputProcessorTouch() noexcept; void SetCoordinateScale(std::int32_t scale) { m_coordinateScale = scale; } - void OnTouchDown(CSeat* seat, std::uint32_t serial, std::uint32_t time, wayland::surface_t surface, std::int32_t id, double x, double y) override; + void OnTouchDown(CSeat* seat, + std::uint32_t serial, + std::uint32_t time, + const wayland::surface_t& surface, + std::int32_t id, + double x, + double y) override; void OnTouchUp(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::int32_t id) override; void OnTouchMotion(CSeat* seat, std::uint32_t time, std::int32_t id, double x, double y) override; void OnTouchCancel(CSeat* seat) override; diff --git a/xbmc/windowing/wayland/Output.cpp b/xbmc/windowing/wayland/Output.cpp index 2aaae07539..09beef7f07 100644 --- a/xbmc/windowing/wayland/Output.cpp +++ b/xbmc/windowing/wayland/Output.cpp @@ -12,16 +12,21 @@ #include <cmath> #include <set> #include <stdexcept> +#include <utility> using namespace KODI::WINDOWING::WAYLAND; -COutput::COutput(std::uint32_t globalName, wayland::output_t const & output, std::function<void()> doneHandler) -: m_globalName{globalName}, m_output{output}, m_doneHandler{doneHandler} +COutput::COutput(std::uint32_t globalName, + wayland::output_t const& output, + std::function<void()> doneHandler) + : m_globalName{globalName}, m_output{output}, m_doneHandler{std::move(doneHandler)} { assert(m_output); - m_output.on_geometry() = [this](std::int32_t x, std::int32_t y, std::int32_t physWidth, std::int32_t physHeight, wayland::output_subpixel, std::string const& make, std::string const& model, wayland::output_transform) - { + m_output.on_geometry() = [this](std::int32_t x, std::int32_t y, std::int32_t physWidth, + std::int32_t physHeight, wayland::output_subpixel, + std::string const& make, std::string const& model, + const wayland::output_transform&) { CSingleLock lock(m_geometryCriticalSection); m_position = {x, y}; // Some monitors report invalid (negative) values that would cause an exception @@ -33,8 +38,8 @@ COutput::COutput(std::uint32_t globalName, wayland::output_t const & output, std m_make = make; m_model = model; }; - m_output.on_mode() = [this](wayland::output_mode flags, std::int32_t width, std::int32_t height, std::int32_t refresh) - { + m_output.on_mode() = [this](const wayland::output_mode& flags, std::int32_t width, + std::int32_t height, std::int32_t refresh) { // std::set.emplace returns pair of iterator to the (possibly) inserted // element and boolean information whether the element was actually added // which we do not need diff --git a/xbmc/windowing/wayland/Registry.cpp b/xbmc/windowing/wayland/Registry.cpp index d1fb860ab2..e7885636de 100644 --- a/xbmc/windowing/wayland/Registry.cpp +++ b/xbmc/windowing/wayland/Registry.cpp @@ -81,8 +81,8 @@ void CRegistry::Bind() m_registry = displayProxy.get_registry(); - m_registry.on_global() = [this] (std::uint32_t name, std::string interface, std::uint32_t version) - { + m_registry.on_global() = [this](std::uint32_t name, const std::string& interface, + std::uint32_t version) { { auto it = m_singletonBinds.find(interface); if (it != m_singletonBinds.end()) diff --git a/xbmc/windowing/wayland/Registry.h b/xbmc/windowing/wayland/Registry.h index 628092bb01..f440782266 100644 --- a/xbmc/windowing/wayland/Registry.h +++ b/xbmc/windowing/wayland/Registry.h @@ -13,6 +13,7 @@ #include <cstdint> #include <functional> #include <map> +#include <utility> #include <wayland-client-protocol.hpp> @@ -79,7 +80,10 @@ public: * type is removed */ template<typename T> - void Request(std::uint32_t minVersion, std::uint32_t maxVersion, AddHandler addHandler, RemoveHandler removeHandler) + void Request(std::uint32_t minVersion, + std::uint32_t maxVersion, + const AddHandler& addHandler, + const RemoveHandler& removeHandler) { RequestInternal([]{ return T(); }, T::interface_name, minVersion, maxVersion, addHandler, removeHandler); } @@ -136,8 +140,16 @@ private: std::uint32_t maxVersion; AddHandler addHandler; RemoveHandler removeHandler; - BindInfo(std::function<wayland::proxy_t()> constructor, std::uint32_t minVersion, std::uint32_t maxVersion, AddHandler addHandler, RemoveHandler removeHandler) - : constructor{constructor}, minVersion{minVersion}, maxVersion{maxVersion}, addHandler{addHandler}, removeHandler{removeHandler} + BindInfo(std::function<wayland::proxy_t()> constructor, + std::uint32_t minVersion, + std::uint32_t maxVersion, + AddHandler addHandler, + RemoveHandler removeHandler) + : constructor{std::move(constructor)}, + minVersion{minVersion}, + maxVersion{maxVersion}, + addHandler{std::move(addHandler)}, + removeHandler{std::move(removeHandler)} {} }; std::map<std::string, BindInfo> m_binds; diff --git a/xbmc/windowing/wayland/Seat.cpp b/xbmc/windowing/wayland/Seat.cpp index 34ea171474..d3c07cc902 100644 --- a/xbmc/windowing/wayland/Seat.cpp +++ b/xbmc/windowing/wayland/Seat.cpp @@ -14,6 +14,7 @@ #include "platform/posix/utils/Mmap.h" #include <cassert> +#include <utility> #include <unistd.h> @@ -40,8 +41,8 @@ namespace * protocol instance if the capability has been added */ template<typename T, typename InstanceProviderT> -bool HandleCapabilityChange(wayland::seat_capability caps, - wayland::seat_capability cap, +bool HandleCapabilityChange(const wayland::seat_capability& caps, + const wayland::seat_capability& cap, std::string const& seatName, std::string const& capName, T& proxy, @@ -76,10 +77,7 @@ bool HandleCapabilityChange(wayland::seat_capability caps, CSeat::CSeat(std::uint32_t globalName, wayland::seat_t const& seat, CConnection& connection) : m_globalName{globalName}, m_seat{seat}, m_selection{connection, seat} { - m_seat.on_name() = [this](std::string name) - { - m_name = name; - }; + m_seat.on_name() = [this](std::string name) { m_name = std::move(name); }; m_seat.on_capabilities() = std::bind(&CSeat::HandleOnCapabilities, this, std::placeholders::_1); } @@ -118,7 +116,7 @@ void CSeat::RemoveRawInputHandlerTouch(KODI::WINDOWING::WAYLAND::IRawInputHandle m_rawTouchHandlers.erase(rawTouchHandler); } -void CSeat::HandleOnCapabilities(wayland::seat_capability caps) +void CSeat::HandleOnCapabilities(const wayland::seat_capability& caps) { if (HandleCapabilityChange(caps, wayland::seat_capability::keyboard, GetName(), "keyboard", m_keyboard, std::bind(&wayland::seat_t::get_keyboard, m_seat))) { @@ -154,15 +152,14 @@ void CSeat::HandleKeyboardCapability() handler->OnKeyboardKeymap(this, format, keymap); } }; - m_keyboard.on_enter() = [this](std::uint32_t serial, wayland::surface_t surface, wayland::array_t keys) - { + m_keyboard.on_enter() = [this](std::uint32_t serial, const wayland::surface_t& surface, + const wayland::array_t& keys) { for (auto handler : m_rawKeyboardHandlers) { handler->OnKeyboardEnter(this, serial, surface, keys); } }; - m_keyboard.on_leave() = [this](std::uint32_t serial, wayland::surface_t surface) - { + m_keyboard.on_leave() = [this](std::uint32_t serial, const wayland::surface_t& surface) { for (auto handler : m_rawKeyboardHandlers) { handler->OnKeyboardLeave(this, serial, surface); @@ -194,15 +191,14 @@ void CSeat::HandleKeyboardCapability() void CSeat::HandlePointerCapability() { - m_pointer.on_enter() = [this](std::uint32_t serial, wayland::surface_t surface, double surfaceX, double surfaceY) - { + m_pointer.on_enter() = [this](std::uint32_t serial, const wayland::surface_t& surface, + double surfaceX, double surfaceY) { for (auto handler : m_rawPointerHandlers) { handler->OnPointerEnter(this, serial, surface, surfaceX, surfaceY); } }; - m_pointer.on_leave() = [this](std::uint32_t serial, wayland::surface_t surface) - { + m_pointer.on_leave() = [this](std::uint32_t serial, const wayland::surface_t& surface) { for (auto handler : m_rawPointerHandlers) { handler->OnPointerLeave(this, serial, surface); @@ -240,8 +236,9 @@ void CSeat::HandlePointerCapability() void CSeat::HandleTouchCapability() { - m_touch.on_down() = [this](std::uint32_t serial, std::uint32_t time, wayland::surface_t surface, std::int32_t id, double x, double y) - { + m_touch.on_down() = [this](std::uint32_t serial, std::uint32_t time, + const wayland::surface_t& surface, std::int32_t id, double x, + double y) { for (auto handler : m_rawTouchHandlers) { handler->OnTouchDown(this, serial, time, surface, id, x, y); diff --git a/xbmc/windowing/wayland/Seat.h b/xbmc/windowing/wayland/Seat.h index 93cfcfd071..095f18dd89 100644 --- a/xbmc/windowing/wayland/Seat.h +++ b/xbmc/windowing/wayland/Seat.h @@ -34,8 +34,15 @@ class IRawInputHandlerKeyboard { public: virtual void OnKeyboardKeymap(CSeat* seat, wayland::keyboard_keymap_format format, std::string const& keymap) {} - virtual void OnKeyboardEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, wayland::array_t keys) {} - virtual void OnKeyboardLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) {} + virtual void OnKeyboardEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + const wayland::array_t& keys) + { + } + virtual void OnKeyboardLeave(CSeat* seat, std::uint32_t serial, const wayland::surface_t& surface) + { + } virtual void OnKeyboardKey(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::uint32_t key, wayland::keyboard_key_state state) {} virtual void OnKeyboardModifiers(CSeat* seat, std::uint32_t serial, std::uint32_t modsDepressed, std::uint32_t modsLatched, std::uint32_t modsLocked, std::uint32_t group) {} virtual void OnKeyboardRepeatInfo(CSeat* seat, std::int32_t rate, std::int32_t delay) {} @@ -51,8 +58,16 @@ protected: class IRawInputHandlerPointer { public: - virtual void OnPointerEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, double surfaceX, double surfaceY) {} - virtual void OnPointerLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) {} + virtual void OnPointerEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + double surfaceX, + double surfaceY) + { + } + virtual void OnPointerLeave(CSeat* seat, std::uint32_t serial, const wayland::surface_t& surface) + { + } virtual void OnPointerMotion(CSeat* seat, std::uint32_t time, double surfaceX, double surfaceY) {} virtual void OnPointerButton(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::uint32_t button, wayland::pointer_button_state state) {} virtual void OnPointerAxis(CSeat* seat, std::uint32_t time, wayland::pointer_axis axis, double value) {} @@ -68,7 +83,15 @@ protected: class IRawInputHandlerTouch { public: - virtual void OnTouchDown(CSeat* seat, std::uint32_t serial, std::uint32_t time, wayland::surface_t surface, std::int32_t id, double x, double y) {} + virtual void OnTouchDown(CSeat* seat, + std::uint32_t serial, + std::uint32_t time, + const wayland::surface_t& surface, + std::int32_t id, + double x, + double y) + { + } virtual void OnTouchUp(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::int32_t id) {} virtual void OnTouchMotion(CSeat* seat, std::uint32_t time, std::int32_t id, double x, double y) {} virtual void OnTouchCancel(CSeat* seat) {} @@ -155,7 +178,7 @@ private: CSeat(CSeat const& other) = delete; CSeat& operator=(CSeat const& other) = delete; - void HandleOnCapabilities(wayland::seat_capability caps); + void HandleOnCapabilities(const wayland::seat_capability& caps); void HandlePointerCapability(); void HandleKeyboardCapability(); void HandleTouchCapability(); diff --git a/xbmc/windowing/wayland/SeatSelection.cpp b/xbmc/windowing/wayland/SeatSelection.cpp index 1f2f473ac8..c0a6948dc7 100644 --- a/xbmc/windowing/wayland/SeatSelection.cpp +++ b/xbmc/windowing/wayland/SeatSelection.cpp @@ -21,6 +21,7 @@ #include <chrono> #include <cstring> #include <system_error> +#include <utility> #include <poll.h> #include <unistd.h> @@ -63,15 +64,14 @@ CSeatSelection::CSeatSelection(CConnection& connection, wayland::seat_t const& s { // We don't know yet whether this is drag-and-drop or selection, so collect // MIME types in either case - m_currentOffer = offer; + m_currentOffer = std::move(offer); m_mimeTypeOffers.clear(); m_currentOffer.on_offer() = [this](std::string mime) { m_mimeTypeOffers.push_back(std::move(mime)); }; }; - m_dataDevice.on_selection() = [this](wayland::data_offer_t offer) - { + m_dataDevice.on_selection() = [this](const wayland::data_offer_t& offer) { CSingleLock lock(m_currentSelectionMutex); m_matchedMimeType.clear(); diff --git a/xbmc/windowing/wayland/ShellSurfaceWlShell.cpp b/xbmc/windowing/wayland/ShellSurfaceWlShell.cpp index 600e5320ef..2c91858c8b 100644 --- a/xbmc/windowing/wayland/ShellSurfaceWlShell.cpp +++ b/xbmc/windowing/wayland/ShellSurfaceWlShell.cpp @@ -15,8 +15,12 @@ using namespace KODI::WINDOWING::WAYLAND; using namespace std::placeholders; -CShellSurfaceWlShell::CShellSurfaceWlShell(IShellSurfaceHandler& handler, CConnection& connection, const wayland::surface_t& surface, std::string title, std::string class_) -: m_handler{handler} +CShellSurfaceWlShell::CShellSurfaceWlShell(IShellSurfaceHandler& handler, + CConnection& connection, + const wayland::surface_t& surface, + const std::string& title, + const std::string& class_) + : m_handler{handler} { { CRegistry registry{connection}; @@ -33,8 +37,8 @@ CShellSurfaceWlShell::CShellSurfaceWlShell(IShellSurfaceHandler& handler, CConne { m_shellSurface.pong(serial); }; - m_shellSurface.on_configure() = [this](wayland::shell_surface_resize, std::int32_t width, std::int32_t height) - { + m_shellSurface.on_configure() = [this](const wayland::shell_surface_resize&, std::int32_t width, + std::int32_t height) { // wl_shell does not have serials m_handler.OnConfigure(0, {width, height}, m_surfaceState); }; diff --git a/xbmc/windowing/wayland/ShellSurfaceWlShell.h b/xbmc/windowing/wayland/ShellSurfaceWlShell.h index 22fdd60c2f..8b60d60a9d 100644 --- a/xbmc/windowing/wayland/ShellSurfaceWlShell.h +++ b/xbmc/windowing/wayland/ShellSurfaceWlShell.h @@ -31,7 +31,11 @@ public: * \param class_ class of the surface, which should match the name of the * .desktop file of the application */ - CShellSurfaceWlShell(IShellSurfaceHandler& handler, CConnection& connection, wayland::surface_t const& surface, std::string title, std::string class_); + CShellSurfaceWlShell(IShellSurfaceHandler& handler, + CConnection& connection, + wayland::surface_t const& surface, + const std::string& title, + const std::string& class_); void Initialize() override; diff --git a/xbmc/windowing/wayland/ShellSurfaceXdgShell.cpp b/xbmc/windowing/wayland/ShellSurfaceXdgShell.cpp index b2c2aeedbb..e92d33c3fa 100644 --- a/xbmc/windowing/wayland/ShellSurfaceXdgShell.cpp +++ b/xbmc/windowing/wayland/ShellSurfaceXdgShell.cpp @@ -67,8 +67,8 @@ CShellSurfaceXdgShell::CShellSurfaceXdgShell(IShellSurfaceHandler& handler, wayl { m_handler.OnClose(); }; - m_xdgToplevel.on_configure() = [this](std::int32_t width, std::int32_t height, std::vector<wayland::xdg_toplevel_state> states) - { + m_xdgToplevel.on_configure() = [this](std::int32_t width, std::int32_t height, + const std::vector<wayland::xdg_toplevel_state>& states) { m_configuredSize.Set(width, height); m_configuredState.reset(); for (auto state : states) diff --git a/xbmc/windowing/wayland/ShellSurfaceXdgShellUnstableV6.cpp b/xbmc/windowing/wayland/ShellSurfaceXdgShellUnstableV6.cpp index 3814eb1d10..ca68b98090 100644 --- a/xbmc/windowing/wayland/ShellSurfaceXdgShellUnstableV6.cpp +++ b/xbmc/windowing/wayland/ShellSurfaceXdgShellUnstableV6.cpp @@ -67,15 +67,16 @@ CShellSurfaceXdgShellUnstableV6::CShellSurfaceXdgShellUnstableV6(IShellSurfaceHa { m_handler.OnClose(); }; - m_xdgToplevel.on_configure() = [this](std::int32_t width, std::int32_t height, std::vector<wayland::zxdg_toplevel_v6_state> states) - { - m_configuredSize.Set(width, height); - m_configuredState.reset(); - for (auto state : states) - { - m_configuredState.set(ConvertStateFlag(state)); - } - }; + m_xdgToplevel.on_configure() = + [this](std::int32_t width, std::int32_t height, + const std::vector<wayland::zxdg_toplevel_v6_state>& states) { + m_configuredSize.Set(width, height); + m_configuredState.reset(); + for (auto state : states) + { + m_configuredState.set(ConvertStateFlag(state)); + } + }; m_xdgToplevel.set_app_id(app_id); m_xdgToplevel.set_title(title); // Set sensible minimum size diff --git a/xbmc/windowing/wayland/WinSystemWayland.cpp b/xbmc/windowing/wayland/WinSystemWayland.cpp index 694c41ebdd..450876a40e 100644 --- a/xbmc/windowing/wayland/WinSystemWayland.cpp +++ b/xbmc/windowing/wayland/WinSystemWayland.cpp @@ -34,6 +34,7 @@ #include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/SettingsComponent.h" +#include "settings/lib/Setting.h" #include "threads/SingleLock.h" #include "utils/ActorProtocol.h" #include "utils/MathUtils.h" @@ -45,7 +46,6 @@ #include "platform/freebsd/OptionalsReg.h" #include "platform/linux/OptionalsReg.h" #include "platform/linux/TimeUtils.h" -#include "platform/linux/powermanagement/LinuxPowerSyscall.h" #include <algorithm> #include <limits> @@ -177,7 +177,6 @@ CWinSystemWayland::CWinSystemWayland() } } m_winEvents.reset(new CWinEventsWayland()); - CLinuxPowerSyscall::Register(); m_lirc.reset(OPTIONALS::LircRegister()); } @@ -195,8 +194,7 @@ bool CWinSystemWayland::InitWindowSystem() return false; } - wayland::set_log_handler([](std::string message) - { + wayland::set_log_handler([](const std::string& message) { CLog::Log(LOGWARNING, "wayland-client log message: %s", message.c_str()); }); @@ -240,6 +238,11 @@ bool CWinSystemWayland::InitWindowSystem() // Always use the generic touch action handler CGenericTouchInputHandler::GetInstance().RegisterHandler(&CGenericTouchActionHandler::GetInstance()); + CServiceBroker::GetSettingsComponent() + ->GetSettings() + ->GetSetting(CSettings::SETTING_VIDEOSCREEN_LIMITEDRANGE) + ->SetVisible(true); + return CWinSystemBase::InitWindowSystem(); } @@ -278,8 +281,7 @@ bool CWinSystemWayland::CreateNewWindow(const std::string& name, CLog::LogF(LOGINFO, "Starting %s size %dx%d", fullScreen ? "full screen" : "windowed", res.iWidth, res.iHeight); m_surface = m_compositor.create_surface(); - m_surface.on_enter() = [this](wayland::output_t wloutput) - { + m_surface.on_enter() = [this](const wayland::output_t& wloutput) { if (auto output = FindOutputByWaylandOutput(wloutput)) { CLog::Log(LOGDEBUG, "Entering output \"%s\" with scale %d and %.3f dpi", UserFriendlyOutputName(output).c_str(), output->GetScale(), output->GetCurrentDpi()); @@ -294,8 +296,7 @@ bool CWinSystemWayland::CreateNewWindow(const std::string& name, CLog::Log(LOGWARNING, "Entering output that was not configured yet, ignoring"); } }; - m_surface.on_leave() = [this](wayland::output_t wloutput) - { + m_surface.on_leave() = [this](const wayland::output_t& wloutput) { if (auto output = FindOutputByWaylandOutput(wloutput)) { CLog::Log(LOGDEBUG, "Leaving output \"%s\" with scale %d", UserFriendlyOutputName(output).c_str(), output->GetScale()); @@ -1334,8 +1335,7 @@ void CWinSystemWayland::PrepareFramePresentation() iter = m_surfaceSubmissions.emplace(m_surfaceSubmissions.end(), tStart, feedback); } - feedback.on_sync_output() = [this](wayland::output_t wloutput) - { + feedback.on_sync_output() = [this](const wayland::output_t& wloutput) { m_syncOutputID = wloutput.get_id(); auto output = FindOutputByWaylandOutput(wloutput); if (output) @@ -1347,8 +1347,10 @@ void CWinSystemWayland::PrepareFramePresentation() CLog::Log(LOGWARNING, "Could not find Wayland output that is supposedly the sync output"); } }; - feedback.on_presented() = [this,iter](std::uint32_t tvSecHi, std::uint32_t tvSecLo, std::uint32_t tvNsec, std::uint32_t refresh, std::uint32_t seqHi, std::uint32_t seqLo, wayland::presentation_feedback_kind flags) - { + feedback.on_presented() = [this, iter](std::uint32_t tvSecHi, std::uint32_t tvSecLo, + std::uint32_t tvNsec, std::uint32_t refresh, + std::uint32_t seqHi, std::uint32_t seqLo, + const wayland::presentation_feedback_kind& flags) { timespec tv = { .tv_sec = static_cast<std::time_t> ((static_cast<std::uint64_t>(tvSecHi) << 32) + tvSecLo), .tv_nsec = static_cast<long>(tvNsec) }; std::int64_t latency{KODI::LINUX::TimespecDifference(iter->submissionTime, tv)}; std::uint64_t msc{(static_cast<std::uint64_t>(seqHi) << 32) + seqLo}; @@ -1452,7 +1454,8 @@ float CWinSystemWayland::GetSyncOutputRefreshRate() return m_syncOutputRefreshRate; } -KODI::CSignalRegistration CWinSystemWayland::RegisterOnPresentationFeedback(PresentationFeedbackHandler handler) +KODI::CSignalRegistration CWinSystemWayland::RegisterOnPresentationFeedback( + const PresentationFeedbackHandler& handler) { return m_presentationFeedbackHandlers.Register(handler); } diff --git a/xbmc/windowing/wayland/WinSystemWayland.h b/xbmc/windowing/wayland/WinSystemWayland.h index db695e4b08..26952c33ef 100644 --- a/xbmc/windowing/wayland/WinSystemWayland.h +++ b/xbmc/windowing/wayland/WinSystemWayland.h @@ -52,6 +52,8 @@ public: CWinSystemWayland(); ~CWinSystemWayland() noexcept override; + const std::string GetName() override { return "wayland"; } + bool InitWindowSystem() override; bool DestroyWindowSystem() override; @@ -87,7 +89,7 @@ public: void Unregister(IDispResource* resource) override; using PresentationFeedbackHandler = std::function<void(timespec /* tv */, std::uint32_t /* refresh */, std::uint32_t /* sync output id */, float /* sync output fps */, std::uint64_t /* msc */)>; - CSignalRegistration RegisterOnPresentationFeedback(PresentationFeedbackHandler handler); + CSignalRegistration RegisterOnPresentationFeedback(const PresentationFeedbackHandler& handler); // Like CWinSystemX11 void GetConnectedOutputs(std::vector<std::string>* outputs); diff --git a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.cpp b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.cpp index 05e8997eb1..2bdf426bbb 100644 --- a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.cpp +++ b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.cpp @@ -18,15 +18,20 @@ #include "utils/DMAHeapBufferObject.h" #include "utils/UDMABufferObject.h" #include "utils/log.h" +#include "windowing/WindowSystemFactory.h" #include <EGL/eglext.h> using namespace KODI::WINDOWING::WAYLAND; -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemWaylandEGLContextGL::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemWaylandEGLContextGL()); - return winSystem; + CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem, "wayland"); +} + +std::unique_ptr<CWinSystemBase> CWinSystemWaylandEGLContextGL::CreateWinSystem() +{ + return std::make_unique<CWinSystemWaylandEGLContextGL>(); } bool CWinSystemWaylandEGLContextGL::InitWindowSystem() diff --git a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.h b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.h index 6cc3b685f3..540a7b8179 100644 --- a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.h +++ b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGL.h @@ -23,6 +23,9 @@ class CVaapiProxy; class CWinSystemWaylandEGLContextGL : public CWinSystemWaylandEGLContext, public CRenderSystemGL { public: + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemWaylandEGLContext CRenderSystemBase *GetRenderSystem() override { return this; } bool InitWindowSystem() override; diff --git a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.cpp b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.cpp index b8c37d8371..1827da1d9a 100644 --- a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.cpp +++ b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.cpp @@ -21,13 +21,18 @@ #include "utils/DMAHeapBufferObject.h" #include "utils/UDMABufferObject.h" #include "utils/log.h" +#include "windowing/WindowSystemFactory.h" using namespace KODI::WINDOWING::WAYLAND; -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemWaylandEGLContextGLES::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemWaylandEGLContextGLES()); - return winSystem; + CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem, "wayland"); +} + +std::unique_ptr<CWinSystemBase> CWinSystemWaylandEGLContextGLES::CreateWinSystem() +{ + return std::make_unique<CWinSystemWaylandEGLContextGLES>(); } bool CWinSystemWaylandEGLContextGLES::InitWindowSystem() diff --git a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.h b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.h index 9f8b2d2a02..0a3c71c05f 100644 --- a/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.h +++ b/xbmc/windowing/wayland/WinSystemWaylandEGLContextGLES.h @@ -23,6 +23,9 @@ class CVaapiProxy; class CWinSystemWaylandEGLContextGLES : public CWinSystemWaylandEGLContext, public CRenderSystemGLES { public: + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemWaylandEGLContext CRenderSystemBase *GetRenderSystem() override { return this; } bool InitWindowSystem() override; diff --git a/xbmc/windowing/wayland/WindowDecorator.cpp b/xbmc/windowing/wayland/WindowDecorator.cpp index 9f7888e67d..1f7f59dc36 100644 --- a/xbmc/windowing/wayland/WindowDecorator.cpp +++ b/xbmc/windowing/wayland/WindowDecorator.cpp @@ -383,8 +383,8 @@ std::string CursorForResizeEdge(wayland::shell_surface_resize edge) } template<typename T, typename InstanceProviderT> -bool HandleCapabilityChange(wayland::seat_capability caps, - wayland::seat_capability cap, +bool HandleCapabilityChange(const wayland::seat_capability& caps, + const wayland::seat_capability& cap, T& proxy, InstanceProviderT instanceProvider) { @@ -439,7 +439,11 @@ void CWindowDecorator::RemoveSeat(CSeat* seat) UpdateButtonHoverState(); } -void CWindowDecorator::OnPointerEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, double surfaceX, double surfaceY) +void CWindowDecorator::OnPointerEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + double surfaceX, + double surfaceY) { auto seatStateI = m_seats.find(seat->GetGlobalName()); if (seatStateI == m_seats.end()) @@ -464,7 +468,9 @@ void CWindowDecorator::OnPointerEnter(CSeat* seat, std::uint32_t serial, wayland } } -void CWindowDecorator::OnPointerLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) +void CWindowDecorator::OnPointerLeave(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface) { auto seatStateI = m_seats.find(seat->GetGlobalName()); if (seatStateI == m_seats.end()) @@ -509,7 +515,13 @@ void CWindowDecorator::OnPointerButton(CSeat* seat, std::uint32_t serial, std::u } } -void CWindowDecorator::OnTouchDown(CSeat* seat, std::uint32_t serial, std::uint32_t time, wayland::surface_t surface, std::int32_t id, double x, double y) +void CWindowDecorator::OnTouchDown(CSeat* seat, + std::uint32_t serial, + std::uint32_t time, + const wayland::surface_t& surface, + std::int32_t id, + double x, + double y) { auto seatStateI = m_seats.find(seat->GetGlobalName()); if (seatStateI == m_seats.end()) diff --git a/xbmc/windowing/wayland/WindowDecorator.h b/xbmc/windowing/wayland/WindowDecorator.h index 481c401a46..23db2370df 100644 --- a/xbmc/windowing/wayland/WindowDecorator.h +++ b/xbmc/windowing/wayland/WindowDecorator.h @@ -144,10 +144,22 @@ private: CWindowDecorator& operator=(CWindowDecorator const& other) = delete; // IRawInputHandlerTouch - void OnTouchDown(CSeat* seat, std::uint32_t serial, std::uint32_t time, wayland::surface_t surface, std::int32_t id, double x, double y) override; + void OnTouchDown(CSeat* seat, + std::uint32_t serial, + std::uint32_t time, + const wayland::surface_t& surface, + std::int32_t id, + double x, + double y) override; // IRawInputHandlerPointer - void OnPointerEnter(CSeat* seat, std::uint32_t serial, wayland::surface_t surface, double surfaceX, double surfaceY) override; - void OnPointerLeave(CSeat* seat, std::uint32_t serial, wayland::surface_t surface) override; + void OnPointerEnter(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface, + double surfaceX, + double surfaceY) override; + void OnPointerLeave(CSeat* seat, + std::uint32_t serial, + const wayland::surface_t& surface) override; void OnPointerMotion(CSeat* seat, std::uint32_t time, double surfaceX, double surfaceY) override; void OnPointerButton(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::uint32_t button, wayland::pointer_button_state state) override; diff --git a/xbmc/windowing/win10/WinSystemWin10.cpp b/xbmc/windowing/win10/WinSystemWin10.cpp index cb8a4cc35d..2810e453f2 100644 --- a/xbmc/windowing/win10/WinSystemWin10.cpp +++ b/xbmc/windowing/win10/WinSystemWin10.cpp @@ -12,7 +12,6 @@ #include "cores/AudioEngine/Sinks/AESinkWASAPI.h" #include "windowing/GraphicContext.h" #include "platform/win10/AsyncHelpers.h" -#include "platform/win10/powermanagement/Win10PowerSyscall.h" #include "platform/win32/CharsetConverter.h" #include "rendering/dx/DirectXHelper.h" #include "rendering/dx/RenderContext.h" @@ -65,7 +64,6 @@ CWinSystemWin10::CWinSystemWin10() { CAESinkWASAPI::Register(); } - CPowerSyscall::Register(); } CWinSystemWin10::~CWinSystemWin10() diff --git a/xbmc/windowing/win10/WinSystemWin10DX.cpp b/xbmc/windowing/win10/WinSystemWin10DX.cpp index 85311cb2ae..3d5d50ee99 100644 --- a/xbmc/windowing/win10/WinSystemWin10DX.cpp +++ b/xbmc/windowing/win10/WinSystemWin10DX.cpp @@ -13,10 +13,16 @@ #include "rendering/dx/DirectXHelper.h" #include "utils/XTimeUtils.h" #include "utils/log.h" +#include "windowing/WindowSystemFactory.h" #include "platform/win32/WIN32Util.h" -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemWin10DX::Register() +{ + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem); +} + +std::unique_ptr<CWinSystemBase> CWinSystemWin10DX::CreateWinSystem() { return std::make_unique<CWinSystemWin10DX>(); } diff --git a/xbmc/windowing/win10/WinSystemWin10DX.h b/xbmc/windowing/win10/WinSystemWin10DX.h index f83d1c01d3..e9ba46c735 100644 --- a/xbmc/windowing/win10/WinSystemWin10DX.h +++ b/xbmc/windowing/win10/WinSystemWin10DX.h @@ -18,6 +18,9 @@ public: CWinSystemWin10DX(); ~CWinSystemWin10DX(); + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemWin10 CRenderSystemBase *GetRenderSystem() override { return this; } bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override; diff --git a/xbmc/windowing/windows/WinSystemWin32.cpp b/xbmc/windowing/windows/WinSystemWin32.cpp index dd1dc7f424..91e2b10e1e 100644 --- a/xbmc/windowing/windows/WinSystemWin32.cpp +++ b/xbmc/windowing/windows/WinSystemWin32.cpp @@ -33,7 +33,6 @@ #include "platform/win32/CharsetConverter.h" #include "platform/win32/input/IRServerSuite.h" -#include "platform/win32/powermanagement/Win32PowerSyscall.h" #include <algorithm> @@ -72,7 +71,6 @@ CWinSystemWin32::CWinSystemWin32() AE::CAESinkFactory::ClearSinks(); CAESinkDirectSound::Register(); CAESinkWASAPI::Register(); - CWin32PowerSyscall::Register(); CScreenshotSurfaceWindows::Register(); if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_bScanIRServer) diff --git a/xbmc/windowing/windows/WinSystemWin32DX.cpp b/xbmc/windowing/windows/WinSystemWin32DX.cpp index 85c8e23669..305e4068b2 100644 --- a/xbmc/windowing/windows/WinSystemWin32DX.cpp +++ b/xbmc/windowing/windows/WinSystemWin32DX.cpp @@ -17,6 +17,7 @@ #include "utils/XTimeUtils.h" #include "utils/log.h" #include "windowing/GraphicContext.h" +#include "windowing/WindowSystemFactory.h" #include "platform/win32/CharsetConverter.h" #include "platform/win32/WIN32Util.h" @@ -50,10 +51,14 @@ static PFND3D10DDI_OPENADAPTER s_fnOpenAdapter10_2{ nullptr }; static PFND3D10DDI_CREATEDEVICE s_fnCreateDeviceOrig{ nullptr }; static PFND3D10DDI_CREATERESOURCE s_fnCreateResourceOrig{ nullptr }; -std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem() +void CWinSystemWin32DX::Register() { - std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemWin32DX()); - return winSystem; + KODI::WINDOWING::CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem); +} + +std::unique_ptr<CWinSystemBase> CWinSystemWin32DX::CreateWinSystem() +{ + return std::make_unique<CWinSystemWin32DX>(); } CWinSystemWin32DX::CWinSystemWin32DX() : CRenderSystemDX() diff --git a/xbmc/windowing/windows/WinSystemWin32DX.h b/xbmc/windowing/windows/WinSystemWin32DX.h index b57df21be2..a33891e624 100644 --- a/xbmc/windowing/windows/WinSystemWin32DX.h +++ b/xbmc/windowing/windows/WinSystemWin32DX.h @@ -21,6 +21,9 @@ public: CWinSystemWin32DX(); ~CWinSystemWin32DX(); + static void Register(); + static std::unique_ptr<CWinSystemBase> CreateWinSystem(); + // Implementation of CWinSystemBase via CWinSystemWin32 CRenderSystemBase *GetRenderSystem() override { return this; } bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override; diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index a3306f8894..b4cf681a37 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -859,7 +859,7 @@ bool CGUIMediaWindow::Update(const std::string &strDirectory, bool updateFilterP // Removable sources VECSOURCES removables; CServiceBroker::GetMediaManager().GetRemovableDrives(removables); - for (auto s : removables) + for (const auto& s : removables) { if (URIUtils::CompareWithoutSlashAtEnd(s.strPath, m_vecItems->GetPath())) { @@ -903,7 +903,7 @@ bool CGUIMediaWindow::Update(const std::string &strDirectory, bool updateFilterP showLabel = 35250; // "Add games..." if (showLabel && (m_vecItems->Size() == 0 || !m_guiState->DisableAddSourceButtons())) // add 'add source button' { - std::string strLabel = g_localizeStrings.Get(showLabel); + const std::string& strLabel = g_localizeStrings.Get(showLabel); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->SetPath("add"); pItem->SetArt("icon", "DefaultAddSource.png"); @@ -1508,7 +1508,7 @@ bool CGUIMediaWindow::OnPlayMedia(int iItem, const std::string &player) * * This function is called by OnClick() */ -bool CGUIMediaWindow::OnPlayAndQueueMedia(const CFileItemPtr &item, std::string player) +bool CGUIMediaWindow::OnPlayAndQueueMedia(const CFileItemPtr& item, const std::string& player) { //play and add current directory to temporary playlist int iPlaylist = m_guiState->GetPlaylist(); diff --git a/xbmc/windows/GUIMediaWindow.h b/xbmc/windows/GUIMediaWindow.h index 7730a9221e..548739573a 100644 --- a/xbmc/windows/GUIMediaWindow.h +++ b/xbmc/windows/GUIMediaWindow.h @@ -154,7 +154,7 @@ protected: void SetHistoryForPath(const std::string& strDirectory); virtual void LoadPlayList(const std::string& strFileName) {} virtual bool OnPlayMedia(int iItem, const std::string &player = ""); - virtual bool OnPlayAndQueueMedia(const CFileItemPtr &item, std::string player = ""); + virtual bool OnPlayAndQueueMedia(const CFileItemPtr& item, const std::string& player = ""); void UpdateFileList(); virtual void OnDeleteItem(int iItem); void OnRenameItem(int iItem); diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index f5ca1abe8d..736f49346d 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -487,7 +487,7 @@ bool CGUIWindowFileManager::Update(int iList, const std::string &strDirectory) URIUtils::GetParentPath(strDirectory, strParentPath); if (strDirectory.empty() && (m_vecItems[iList]->Size() == 0 || CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_SHOWADDSOURCEBUTTONS))) { // add 'add source button' - std::string strLabel = g_localizeStrings.Get(1026); + const std::string& strLabel = g_localizeStrings.Get(1026); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->SetPath("add"); pItem->SetArt("icon", "DefaultAddSource.png"); @@ -630,7 +630,7 @@ void CGUIWindowFileManager::OnStart(CFileItem *pItem, const std::string &player) // start playlists from file manager if (pItem->IsPlayList()) { - std::string strPlayList = pItem->GetPath(); + const std::string& strPlayList = pItem->GetPath(); std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(strPlayList)); if (nullptr != pPlayList) { diff --git a/xbmc/windows/GUIWindowSystemInfo.cpp b/xbmc/windows/GUIWindowSystemInfo.cpp index 2b0c23f12c..faa47ab8c9 100644 --- a/xbmc/windows/GUIWindowSystemInfo.cpp +++ b/xbmc/windows/GUIWindowSystemInfo.cpp @@ -135,6 +135,9 @@ void CGUIWindowSystemInfo::FrameMove() #ifndef HAS_DX SetControlLabel(i++, "%s %s", 22007, SYSTEM_RENDER_VENDOR); SetControlLabel(i++, "%s %s", 22009, SYSTEM_RENDER_VERSION); +#if defined(TARGET_LINUX) + SetControlLabel(i++, "%s %s", 39153, SYSTEM_PLATFORM_WINDOWING); +#endif #else SetControlLabel(i++, "%s %s", 22024, SYSTEM_RENDER_VERSION); #endif |