diff options
65 files changed, 6614 insertions, 1 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/.gitignore b/xbmc/addons/kodi-addon-dev-kit/.gitignore index 039c6a72a8..08cbb2ccdb 100644 --- a/xbmc/addons/kodi-addon-dev-kit/.gitignore +++ b/xbmc/addons/kodi-addon-dev-kit/.gitignore @@ -29,3 +29,5 @@ /docs /build +.cmake-kit +.create-kit diff --git a/xbmc/addons/kodi-addon-dev-kit/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/CMakeLists.txt new file mode 100644 index 0000000000..e0066460f0 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/CMakeLists.txt @@ -0,0 +1,18 @@ +project(kodi-addon-dev-kit) + +cmake_minimum_required(VERSION 3.0.0) + +# add a target to generate API documentation with Doxygen +find_package(Doxygen) + +if(DOXYGEN_FOUND) + add_custom_target(doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" VERBATIM + ) +endif(DOXYGEN_FOUND) + +add_subdirectory(src/api2/kodi-addon-sharedlibrary) + +install(DIRECTORY include/kodi DESTINATION include) diff --git a/xbmc/addons/kodi-addon-dev-kit/LICENSE.GPL b/xbmc/addons/kodi-addon-dev-kit/LICENSE.GPL new file mode 100644 index 0000000000..3f9ab9609f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/LICENSE.GPL @@ -0,0 +1,287 @@ +1 + You may use, distribute and copy Kodi under the terms of GNU General + Public License version 2, which is displayed below. + +------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library 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. + + GNU GENERAL PUBLIC LICENSE + 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 +------------------------------------------------------------------------- diff --git a/xbmc/addons/kodi-addon-dev-kit/PkgConfigHandler.cmake b/xbmc/addons/kodi-addon-dev-kit/PkgConfigHandler.cmake new file mode 100644 index 0000000000..52c28df3ed --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/PkgConfigHandler.cmake @@ -0,0 +1,97 @@ +# translate a list of libraries into a command-line that can be passed to the +# compiler/linker. first parameter is the name of the variable that will +# receive this list, the rest is considered the list of libraries +function (linker_cmdline what INTO outvar FROM) + # if we are going to put these in regexps, we must escape period + string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}") + string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}") + string (REPLACE "." "\\." esc_ar_pref "${CMAKE_STATIC_LIBRARY_PREFIX}") + string (REPLACE "." "\\." esc_ar_suff "${CMAKE_STATIC_LIBRARY_PREFIX}") + + # CMake loves absolute paths, whereas libtool won't have any of it! + # (you get an error message about argument not parsed). translate each + # of the libraries into a linker option + set (deplib_list "") + foreach (deplib IN LISTS ARGN) + # starts with a hyphen already? then just add it + string (SUBSTRING ${deplib} 0 1 dash) + if (${dash} STREQUAL "-") + list (APPEND deplib_list ${deplib}) + else (${dash} STREQUAL "-") + # otherwise, parse the name into a directory and a name + get_filename_component (deplib_dir ${deplib} PATH) + get_filename_component (deplib_orig ${deplib} NAME) + string (REGEX REPLACE + "^${esc_dl_pref}(.*)${esc_dl_suff}$" + "\\1" + deplib_name + ${deplib_orig} + ) + string (REGEX REPLACE + "^${esc_ar_pref}(.*)${esc_ar_suff}$" + "\\1" + deplib_name + ${deplib_name} + ) + # directory and name each on their own; this is somewhat + # unsatisfactory because it may be that a system dir is specified + # by an earlier directory and you start picking up libraries from + # there instead of the "closest" path here. also, the soversion + # is more or less lost. remove system default path, to lessen the + # chance that we pick the wrong library + if (NOT ((deplib_dir STREQUAL "/usr/lib") OR + (deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}"))) + list (APPEND deplib_list "-L${deplib_dir}") + endif (NOT ((deplib_dir STREQUAL "/usr/lib") OR + (deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}"))) + # if there was no translation of the name, the library is named + # unconventionally (.so.3gf, I'm looking at you), so pass this + # name unmodified to the linker switch + if (deplib_orig STREQUAL deplib_name) + list (APPEND deplib_list "-l:${deplib_orig}") + else (deplib_orig STREQUAL deplib_name) + list (APPEND deplib_list "-l${deplib_name}") + endif (deplib_orig STREQUAL deplib_name) + endif (${dash} STREQUAL "-") + endforeach (deplib) + # caller determines whether we want it returned as a list or a string + if ("${what}" STREQUAL "LIST") + set (${outvar} ${deplib_list}) + else ("${what}" STREQUAL "LIST") + set (${outvar} "${deplib_list}") + string (REPLACE ";" " " ${outvar} "${${outvar}}") + endif ("${what}" STREQUAL "LIST") + set (${outvar} "${${outvar}}" PARENT_SCOPE) +endfunction (linker_cmdline what INTO outvar FROM) + +# convert a list back to a command-line string +function (unseparate_args var_name prefix value) + separate_arguments (value) + foreach (item IN LISTS value) + set (prefixed_item "${prefix}${item}") + if (${var_name}) + set (${var_name} "${${var_name}} ${prefixed_item}") + else (${var_name}) + set (${var_name} "${prefixed_item}") + endif (${var_name}) + endforeach (item) + set (${var_name} "${${var_name}}" PARENT_SCOPE) +endfunction (unseparate_args var_name prefix value) + +# wrapper to set variables in pkg-config file +function (configure_pc_file name source dest prefix libdir includedir) + # escape set of standard strings + unseparate_args (includes "-I" "${${name}_INCLUDE_DIRS}") + unseparate_args (defs "" "${${name}_DEFINITIONS}") + linker_cmdline (STRING INTO libs FROM ${${name}_LIBRARIES}) + + # necessary to make these variables visible to configure_file + set (name "${${name}_NAME}") + set (description "${${name}_DESCRIPTION}") + set (major "${${name}_VERSION_MAJOR}") + set (minor "${${name}_VERSION_MINOR}") + set (target "${name}") + linker_cmdline (STRING INTO target from ${target}) + + configure_file (${source} ${dest} @ONLY) +endfunction (configure_pc_file name source dist prefix libdir includedir) diff --git a/xbmc/addons/kodi-addon-dev-kit/UseMultiArch.cmake b/xbmc/addons/kodi-addon-dev-kit/UseMultiArch.cmake new file mode 100644 index 0000000000..1e338f68cc --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/UseMultiArch.cmake @@ -0,0 +1,49 @@ +# - Multiarch support in object code library directories +# +# This module sets the following variable +# CMAKE_INSTALL_LIBDIR to lib, lib64 or lib/x86_64-linux-gnu +# depending on the platform; use this path +# for platform-specific binaries. +# +# CMAKE_INSTALL_LIBDIR_NOARCH to lib or lib64 depending on the platform; +# use this path for architecture-independent +# files. +# +# Note that it will override the results of GNUInstallDirs if included after +# that module. + +# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu; +# Fedora put module files in lib64/ too, but Debian uses lib/ for that +if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND + "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr") + # Debian or Ubuntu? + if (EXISTS "/etc/debian_version") + set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}") + set (_libdir_noarch "lib") + elseif (EXISTS "/etc/fedora-release" OR + EXISTS "/etc/redhat-release" OR + EXISTS "/etc/slackware-version" OR + EXISTS "/etc/gentoo-release") + # 64-bit system? + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (_libdir_noarch "lib64") + else (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (_libdir_noarch "lib") + endif (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (_libdir_def "${_libdir_noarch}") + else () + set (_libdir_def "lib") + set (_libdir_noarch "lib") + endif () +else () + set (_libdir_def "lib") + set (_libdir_noarch "lib") +endif () + +# let the user override if somewhere else is desirable +set (CMAKE_INSTALL_LIBDIR "${_libdir_def}" CACHE PATH "Object code libraries") +set (CMAKE_INSTALL_LIBDIR_NOARCH "${_libdir_noarch}" CACHE PATH "Architecture-independent library files") +mark_as_advanced ( + CMAKE_INSTALL_LIBDIR + CMAKE_INSTALL_LIBDIR_NOARCH + ) diff --git a/xbmc/addons/kodi-addon-dev-kit/doxygen/Doxyfile b/xbmc/addons/kodi-addon-dev-kit/doxygen/Doxyfile index 13a35a1987..2db19ea96b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/doxygen/Doxyfile +++ b/xbmc/addons/kodi-addon-dev-kit/doxygen/Doxyfile @@ -783,6 +783,7 @@ INPUT = main.txt \ ../../../GUIInfoManager.cpp \ Modules/modules_general.dox \ Modules/modules_python.dox \ + Modules/modules_cpp.dox \ Skin/skin.dox \ ../../../guilib/GUIRenderingControl.dox \ ../../../guilib/GUIButtonControl.dox \ @@ -856,6 +857,57 @@ INPUT = main.txt \ ../../../interfaces/legacy/wsgi/WsgiResponseBody.h \ ../../../interfaces/legacy/wsgi/WsgiResponse.h \ ../../../pictures/PictureInfoTag.cpp + ../include/kodi/api2/AddonLib.hpp \ + ../include/kodi/api2/definitions-all.hpp \ + ../include/kodi/api2/definitions.hpp \ + ../include/kodi/api2/addon/definitions_addon.hpp \ + ../include/kodi/api2/addon/General.hpp \ + ../include/kodi/api2/addon/SoundPlay.hpp \ + ../include/kodi/api2/addon/Network.hpp \ + ../include/kodi/api2/addon/VFSUtils.hpp \ + ../include/kodi/api2/audioengine/definitions_audioengine.hpp \ + ../include/kodi/api2/audioengine/General.hpp \ + ../include/kodi/api2/audioengine/Stream.hpp \ + ../include/kodi/api2/gui/definitions_gui.hpp \ + ../include/kodi/api2/gui/General.hpp \ + ../include/kodi/api2/gui/Window.hpp \ + ../include/kodi/api2/gui/ListItem.hpp \ + ../include/kodi/api2/gui/DialogContextMenu.hpp \ + ../include/kodi/api2/gui/DialogExtendedProgress.hpp \ + ../include/kodi/api2/gui/DialogFileBrowser.hpp \ + ../include/kodi/api2/gui/DialogKeyboard.hpp \ + ../include/kodi/api2/gui/DialogNumeric.hpp \ + ../include/kodi/api2/gui/DialogOK.hpp \ + ../include/kodi/api2/gui/DialogProgress.hpp \ + ../include/kodi/api2/gui/DialogSelect.hpp \ + ../include/kodi/api2/gui/DialogTextViewer.hpp \ + ../include/kodi/api2/gui/DialogYesNo.hpp \ + ../include/kodi/api2/gui/ControlButton.hpp \ + ../include/kodi/api2/gui/ControlEdit.hpp \ + ../include/kodi/api2/gui/ControlFadeLabel.hpp \ + ../include/kodi/api2/gui/ControlImage.hpp \ + ../include/kodi/api2/gui/ControlLabel.hpp \ + ../include/kodi/api2/gui/ControlProgress.hpp \ + ../include/kodi/api2/gui/ControlRadioButton.hpp \ + ../include/kodi/api2/gui/ControlRendering.hpp \ + ../include/kodi/api2/gui/ControlSettingsSlider.hpp \ + ../include/kodi/api2/gui/ControlSlider.hpp \ + ../include/kodi/api2/gui/ControlSpin.hpp \ + ../include/kodi/api2/gui/ControlTextBox.hpp \ + ../include/kodi/api2/inputstream/definitions_inputstream.hpp \ + ../include/kodi/api2/inputstream/InputStream.hpp \ + ../include/kodi/api2/peripheral/definitions_peripheral.hpp \ + ../include/kodi/api2/peripheral/Peripheral.hpp \ + ../include/kodi/api2/player/Player.hpp \ + ../include/kodi/api2/player/PlayList.hpp \ + ../include/kodi/api2/player/definitions_player.hpp \ + ../include/kodi/api2/player/InfoTagMusic.hpp \ + ../include/kodi/api2/player/InfoTagVideo.hpp \ + ../include/kodi/api2/pvr/definitions_pvr.hpp \ + ../include/kodi/api2/pvr/General.hpp \ + ../include/kodi/api2/pvr/StreamUtils.hpp \ + ../include/kodi/api2/pvr/Transfer.hpp \ + ../include/kodi/api2/pvr/Trigger.hpp # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/logo-cpp.png b/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/logo-cpp.png Binary files differnew file mode 100644 index 0000000000..870065eb44 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/logo-cpp.png diff --git a/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/modules_cpp.dox b/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/modules_cpp.dox new file mode 100644 index 0000000000..c0b8b775e0 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/modules_cpp.dox @@ -0,0 +1,14 @@ +namespace V2 +{ +/*! + +\defgroup cpp C++ +\image html logo-cpp.png +\brief \htmlonly + <h3><span style="text-decoration: underline;"><span style="font-style: italic;"><span + style="color: rgb(102, 102, 102);">C++ Binary Add-On Development</span></span></span></h3> + \endhtmlonly + +*/ + +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/modules_general.dox b/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/modules_general.dox index 481a0db8d6..fcb9febf6e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/modules_general.dox +++ b/xbmc/addons/kodi-addon-dev-kit/doxygen/Modules/modules_general.dox @@ -4,5 +4,6 @@ \brief \doc_header{ General Add-On Development parts } \subpage modules__General__List_of_gui_access + \subpage page_List_of_built_in_functions */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/api2/gui/ListItem.hpp b/xbmc/addons/kodi-addon-dev-kit/include/kodi/api2/gui/ListItem.hpp index 51a9c895d6..d4bbf06499 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/api2/gui/ListItem.hpp +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/api2/gui/ListItem.hpp @@ -53,7 +53,7 @@ namespace GUI /// /// The list item control is used for creating item lists in Kodi /// - /// The with \ref ListItem.hpp "#include <kodi/api3/addon/IListItem.hpp>" given + /// The with \ref ListItem.hpp "#include <kodi/api2/addon/IListItem.hpp>" given /// class is used to create a item entry for a list on window and to support it's /// control. /// diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/dev-kit-api-level.cmake b/xbmc/addons/kodi-addon-dev-kit/src/api2/dev-kit-api-level.cmake new file mode 100644 index 0000000000..7eab848c72 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/dev-kit-api-level.cmake @@ -0,0 +1,2 @@ +SET(ADDON_API_LEVEL 2) +SET(ADDON_API_VERSION 2.0.0) diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/AddonLib.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/AddonLib.cpp new file mode 100644 index 0000000000..e4533c801d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/AddonLib.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2015-2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, AddonLib.hpp) + +#include "../version.h" + +#include <string> +#include <stdarg.h> /* va_list, va_start, va_arg, va_end */ +#include <stdio.h> + +API_NAMESPACE + +namespace KodiAPI +{ +extern "C" +{ + +int KODI_API_Level = ADDON_API_LEVEL; +const char* KODI_API_Version = ADDON_API_VERSION; + +int InitLibAddon(void* hdl) +{ + return g_interProcess.InitLibAddon(hdl); +} + +int Finalize() +{ + return g_interProcess.Finalize(); +} + +void Log(const addon_log loglevel, const char* format, ... ) +{ + char buffer[16384]; + va_list args; + va_start(args, format); + vsprintf(buffer, format, args); + va_end(args); + g_interProcess.Log(loglevel, buffer); +} + +} /* extern "C" */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/CMakeLists.txt new file mode 100644 index 0000000000..684c3faf79 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/CMakeLists.txt @@ -0,0 +1,108 @@ +project(kodi-addon-sharedlibrary-api2) + +cmake_minimum_required(VERSION 3.0.0) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}) + +enable_language(C CXX) + +include(../dev-kit-api-level.cmake) +include(../../../UseMultiArch.cmake) + +set(kodi-addon-sharedlibrary_NAME kodi-addon-sharedlibrary) +set(kodi-addon-sharedlibrary_DESCRIPTION "Kodi add-on API 3 development kit for shared libraries") +set(kodi-addon-sharedlibrary_API_LEVEL=${ADDON_API_LEVEL}) +set(kodi-addon-sharedlibrary_VERSION ${ADDON_API_VERSION}) + +add_definitions(-DUSE_DEMUX) +add_definitions(-DADDON_API_LEVEL=${ADDON_API_LEVEL}) + +list(APPEND LIB_SOURCES InterProcess.cpp + AddonLib.cpp + ErrorCodeNames.cpp + addon/AddonLib_Addon_General.cpp + addon/AddonLib_Addon_Network.cpp + addon/AddonLib_Addon_SoundPlay.cpp + addon/AddonLib_Addon_VFSUtils.cpp + audioengine/AddonLib_AudioEngine_General.cpp + audioengine/AddonLib_AudioEngine_Stream.cpp + gui/AddonLib_GUI_General.cpp + gui/AddonLib_GUI_ControlButton.cpp + gui/AddonLib_GUI_ControlEdit.cpp + gui/AddonLib_GUI_ControlFadeLabel.cpp + gui/AddonLib_GUI_ControlImage.cpp + gui/AddonLib_GUI_ControlLabel.cpp + gui/AddonLib_GUI_ControlProgress.cpp + gui/AddonLib_GUI_ControlRadioButton.cpp + gui/AddonLib_GUI_ControlRendering.cpp + gui/AddonLib_GUI_ControlSettingsSlider.cpp + gui/AddonLib_GUI_ControlSlider.cpp + gui/AddonLib_GUI_ControlSpin.cpp + gui/AddonLib_GUI_ControlTextBox.cpp + gui/AddonLib_GUI_DialogContextMenu.cpp + gui/AddonLib_GUI_DialogExtendedProgress.cpp + gui/AddonLib_GUI_DialogFileBrowser.cpp + gui/AddonLib_GUI_DialogKeyboard.cpp + gui/AddonLib_GUI_DialogNumeric.cpp + gui/AddonLib_GUI_DialogOK.cpp + gui/AddonLib_GUI_DialogProgress.cpp + gui/AddonLib_GUI_DialogSelect.cpp + gui/AddonLib_GUI_DialogTextViewer.cpp + gui/AddonLib_GUI_DialogYesNo.cpp + gui/AddonLib_GUI_ListItem.cpp + gui/AddonLib_GUI_Window.cpp + inputstream/AddonLib_InputStream.cpp + peripheral/AddonLib_Peripheral.cpp + player/AddonLib_Player_InfoTagMusic.cpp + player/AddonLib_Player_InfoTagVideo.cpp + player/AddonLib_Player_Player.cpp + player/AddonLib_Player_PlayList.cpp + pvr/AddonLib_PVR_General.cpp + pvr/AddonLib_PVR_Stream.cpp + pvr/AddonLib_PVR_Transfer.cpp + pvr/AddonLib_PVR_Trigger.cpp) + +if(WIN32) + list(APPEND DEPLIBS ws2_32) + list(APPEND LIB_SOURCES dlfcn-win32.cpp) +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11") +endif() + +if(BUILD_KODI_ADDON) + list(APPEND INCLUDES ${KODI_INCLUDE_DIR}) +else() + list(APPEND INCLUDES ../../../../../ + ../../../../../cores/VideoPlayer/DVDDemuxers) +endif() + +include_directories(${INCLUDES} + ../../../include/ + .) + +add_library(kodi.addon.sharedlibrary.api${ADDON_API_LEVEL} STATIC ${LIB_SOURCES}) +target_link_libraries(kodi.addon.sharedlibrary.api${ADDON_API_LEVEL} ${DEPLIBS}) +set_target_properties(kodi.addon.sharedlibrary.api${ADDON_API_LEVEL} PROPERTIES OUTPUT_NAME kodi.addon.sharedlibrary.api${ADDON_API_LEVEL}) + +install(TARGETS kodi.addon.sharedlibrary.api${ADDON_API_LEVEL} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# Set this way for compatibility to old configure system of kodi +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix ${CMAKE_INSTALL_PREFIX}) +set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) +set(includedir ${CMAKE_INSTALL_PREFIX}/include) +set(CXX ${CMAKE_CXX_COMPILER} ${CXX_STD0X_FLAGS}) +set(CC ${CMAKE_C_COMPILER} ${C_STD99_FLAGS}) +set(CXXFLAGS ${CMAKE_CXX_FLAGS}) + +IF(NOT WIN32) + configure_file(kodi-addon-sharedlibrary-api2.pc.in ${CMAKE_BINARY_DIR}/kodi-addon-sharedlibrary-api2.pc @ONLY) + install(FILES ${CMAKE_BINARY_DIR}/kodi-addon-sharedlibrary-api2.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}/pkgconfig) +ENDIF(NOT WIN32) + +# config mode +configure_file (kodi-addon-sharedlibrary-api2-config.cmake.in + ${CMAKE_BINARY_DIR}/kodi-addon-sharedlibrary-api2-config.cmake @ONLY) +install(FILES ${CMAKE_BINARY_DIR}/kodi-addon-sharedlibrary-api2-config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}/kodi) diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/ErrorCodeNames.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/ErrorCodeNames.cpp new file mode 100644 index 0000000000..362529bdf3 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/ErrorCodeNames.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include "ErrorCodeNames.h" +#include KITINCLUDE(ADDON_API_LEVEL, .internal/AddonLib_internal.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +extern "C" +{ + +/*! + * @brief Last error code. + */ +uint32_t KODI_API_lasterror = API_SUCCESS; + +const KODI_API_ErrorTranslator errorTranslator[API_ERR_LASTCODE] = +{ + { API_SUCCESS, "Successful return code" }, + { API_ERR_BUFFER, "Invalid buffer pointer" }, + { API_ERR_COUNT, "Invalid count argument" }, + { API_ERR_TYPE, "Invalid datatype argument" }, + { API_ERR_TAG, "Invalid tag argument" }, + { API_ERR_COMM, "Invalid communicator" }, + { API_ERR_RANK, "Invalid rank" }, + { API_ERR_ROOT, "Invalid root" }, + { API_ERR_GROUP, "Null group passed to function" }, + { API_ERR_OP, "Invalid operation" }, + { API_ERR_TOPOLOGY, "Invalid topology" }, + { API_ERR_DIMS, "Illegal dimension argument" }, + { API_ERR_ARG, "Invalid argument" }, + { API_ERR_UNKNOWN, "Unknown error" }, + { API_ERR_TRUNCATE, "message truncated on receive" }, + { API_ERR_OTHER, "Other error; use Error_string" }, + { API_ERR_INTERN, "internal error code" }, + { API_ERR_IN_STATUS, "Look in status for error value" }, + { API_ERR_PENDING, "Pending request" }, + { API_ERR_REQUEST, "illegal API_request handle" }, + { API_ERR_CONNECTION, "Failed to connect"}, + { API_ERR_VALUE_NOT_AVAILABLE, "Requested value not available" } +}; + +const char* KodiAPI_ErrorCodeToString(uint32_t code) +{ + if (code < API_ERR_LASTCODE) + return errorTranslator[code].errorName; + else + return "Invalid Error code!"; +} + +} /* extern "C" */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/ErrorCodeNames.h b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/ErrorCodeNames.h new file mode 100644 index 0000000000..e7e5c01039 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/ErrorCodeNames.h @@ -0,0 +1,38 @@ +#pragma once +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <stdint.h> + +API_NAMESPACE + +namespace KodiAPI +{ +extern "C" +{ + +extern uint32_t KODI_API_lasterror; + +const char* KodiAPI_ErrorCodeToString(uint32_t code); + +} /* extern "C" */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/InterProcess.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/InterProcess.cpp new file mode 100644 index 0000000000..b81a862035 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/InterProcess.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" + +#include <stdio.h> + +#ifdef _WIN32 // windows + #ifndef _SSIZE_T_DEFINED + typedef intptr_t ssize_t; + #define _SSIZE_T_DEFINED + #endif // !_SSIZE_T_DEFINED + #include "dlfcn-win32.h" +#else + #include <dlfcn.h> // linux+osx +#endif + +extern "C" +{ + +CKODIAddon_InterProcess g_interProcess; + +CKODIAddon_InterProcess::CKODIAddon_InterProcess() + : m_Handle(NULL), + m_Callbacks(NULL), + m_libKODI_addon(NULL) +{ + +} + +CKODIAddon_InterProcess::~CKODIAddon_InterProcess() +{ + Finalize(); +} + +//-- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- + +int CKODIAddon_InterProcess::InitLibAddon(void* hdl) +{ + m_Handle = static_cast<ADDON::AddonCB*>(hdl); + + m_libKODI_addon = dlopen(NULL, RTLD_LAZY); + if (m_libKODI_addon == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + KODI_API_lasterror = API_ERR_OP; + return KODI_API_lasterror; + } + + KODI_register = (_register_level*) + dlsym(m_libKODI_addon, "AddOnLib_Register"); + if (KODI_register == NULL) + { + fprintf(stderr, "Unable to assign function %s\n", dlerror()); + KODI_API_lasterror = API_ERR_CONNECTION; + return KODI_API_lasterror; + } + + KODI_unregister = (_unregister_me*) + dlsym(m_libKODI_addon, "AddOnLib_UnRegister"); + if (KODI_unregister == NULL) + { + fprintf(stderr, "Unable to assign function %s\n", dlerror()); + KODI_API_lasterror = API_ERR_CONNECTION; + return KODI_API_lasterror; + } + + m_Callbacks = KODI_register(m_Handle, 3); + if (m_Callbacks == NULL) + { + KODI_API_lasterror = API_ERR_BUFFER; + return KODI_API_lasterror; + } + + KODI_API_lasterror = API_SUCCESS; + return KODI_API_lasterror; +} + +int CKODIAddon_InterProcess::Finalize() +{ + if (m_libKODI_addon) + { + KODI_unregister(m_Handle, m_Callbacks); + dlclose(m_libKODI_addon); + m_libKODI_addon = NULL; + } + + KODI_API_lasterror = API_SUCCESS; + return KODI_API_lasterror; +} + +void CKODIAddon_InterProcess::Log(const addon_log loglevel, const char* string) +{ + m_Callbacks->addon_log_msg(m_Handle, loglevel, string); +} + +} /* extern "C" */ diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/InterProcess.h b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/InterProcess.h new file mode 100644 index 0000000000..cb5103e535 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/InterProcess.h @@ -0,0 +1,83 @@ +#pragma once +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "../version.h" +#include "kodi/api2/definitions.hpp" + +#include KITINCLUDE(ADDON_API_LEVEL, AddonLib.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, .internal/AddonLib_internal.hpp) + +#include <stdlib.h> +#include <string> + +#ifdef TARGET_WINDOWS +#include <windows.h> +#else +#ifndef __cdecl +#define __cdecl +#endif +#ifndef __declspec +#define __declspec(X) +#endif +#endif + +extern "C" +{ + + using namespace API_NAMESPACE_NAME::KodiAPI; + + namespace ADDON + { + typedef struct AddonCB + { + const char* libBasePath; ///< Never, never change this!!! + void* addonData; + } AddonCB; + } + + class CKODIAddon_InterProcess + { + public: + CKODIAddon_InterProcess(); + virtual ~CKODIAddon_InterProcess(); + + int InitLibAddon(void* hdl); + int Finalize(); + void Log(const addon_log loglevel, const char* string); + + ADDON::AddonCB* m_Handle; + CB_AddOnLib* m_Callbacks; + + protected: + _register_level* KODI_register; + _unregister_me* KODI_unregister; + + private: + void* m_libKODI_addon; + struct cb_array + { + const char* libPath; + }; + }; + + extern CKODIAddon_InterProcess g_interProcess; + +} /* extern "C" */ diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/Makefile b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/Makefile new file mode 100644 index 0000000000..13d571bbbc --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/Makefile @@ -0,0 +1,80 @@ +# WARNING: This Makefile is only be used on Kodi's own build. If you use it +# independent is cmake needed for creation! +# + +### The archiver options: + +AR ?= ar +ARFLAGS ?= ru + +INCLUDES=-I. \ + -I../../../../../ \ + -I../../../../../cores/VideoPlayer/DVDDemuxers \ + -I../../../include/ + +DEFINES+= +CXXFLAGS=-fPIC -std=c++11 +LIBNAME=libkodi.addon.sharedlibrary.api2.a + +### The object files (add further files here): + +OBJS=InterProcess.o \ + AddonLib.o \ + ErrorCodeNames.o \ + addon/AddonLib_Addon_General.o \ + addon/AddonLib_Addon_Network.o \ + addon/AddonLib_Addon_SoundPlay.o \ + addon/AddonLib_Addon_VFSUtils.o \ + audioengine/AddonLib_AudioEngine_General.o \ + audioengine/AddonLib_AudioEngine_Stream.o \ + gui/AddonLib_GUI_General.o \ + gui/AddonLib_GUI_ControlButton.o \ + gui/AddonLib_GUI_ControlEdit.o \ + gui/AddonLib_GUI_ControlFadeLabel.o \ + gui/AddonLib_GUI_ControlImage.o \ + gui/AddonLib_GUI_ControlLabel.o \ + gui/AddonLib_GUI_ControlProgress.o \ + gui/AddonLib_GUI_ControlRadioButton.o \ + gui/AddonLib_GUI_ControlRendering.o \ + gui/AddonLib_GUI_ControlSettingsSlider.o \ + gui/AddonLib_GUI_ControlSlider.o \ + gui/AddonLib_GUI_ControlSpin.o \ + gui/AddonLib_GUI_ControlTextBox.o \ + gui/AddonLib_GUI_DialogExtendedProgress.o \ + gui/AddonLib_GUI_DialogFileBrowser.o \ + gui/AddonLib_GUI_DialogKeyboard.o \ + gui/AddonLib_GUI_DialogNumeric.o \ + gui/AddonLib_GUI_DialogOK.o \ + gui/AddonLib_GUI_DialogProgress.o \ + gui/AddonLib_GUI_DialogSelect.o \ + gui/AddonLib_GUI_DialogTextViewer.o \ + gui/AddonLib_GUI_DialogYesNo.o \ + gui/AddonLib_GUI_ListItem.o \ + gui/AddonLib_GUI_Window.o \ + inputstream/AddonLib_InputStream.o \ + peripheral/AddonLib_Peripheral.o \ + player/AddonLib_Player_InfoTagMusic.o \ + player/AddonLib_Player_InfoTagVideo.o \ + player/AddonLib_Player_Player.o \ + player/AddonLib_Player_PlayList.o \ + pvr/AddonLib_PVR_General.o \ + pvr/AddonLib_PVR_Stream.o \ + pvr/AddonLib_PVR_Transfer.o \ + pvr/AddonLib_PVR_Trigger.o + +### Implicit rules: + +%.o: %.cpp + $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $< + +all: $(LIBNAME) + +### Targets: + +$(LIBNAME): $(OBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) + +CLEAN_FILES = \ + $(LIBNAME) \ + +include ../../../../../../Makefile.include diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_General.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_General.cpp new file mode 100644 index 0000000000..e290279c34 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_General.cpp @@ -0,0 +1,373 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, addon/General.hpp) + +#include <string> +#include <cstring> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace AddOn +{ +namespace General +{ + + bool GetSettingString( + const std::string& settingName, + std::string& settingValue, + bool global) + { + char * buffer = (char*) malloc(1024); + buffer[0] = 0; /* Set the end of string */ + bool ret = g_interProcess.m_Callbacks->General.get_setting(g_interProcess.m_Handle, settingName.c_str(), buffer, global); + if (ret) + settingValue = buffer; + free(buffer); + return ret; + } + + bool GetSettingInt( + const std::string& settingName, + int& settingValue, + bool global) + { + return g_interProcess.m_Callbacks->General.get_setting(g_interProcess.m_Handle, settingName.c_str(), &settingValue, global); + } + + bool GetSettingBoolean( + const std::string& settingName, + bool& settingValue, + bool global) + { + return g_interProcess.m_Callbacks->General.get_setting(g_interProcess.m_Handle, settingName.c_str(), &settingValue, global); + } + + bool GetSettingFloat( + const std::string& settingName, + float& settingValue, + bool global) + { + return g_interProcess.m_Callbacks->General.get_setting(g_interProcess.m_Handle, settingName.c_str(), &settingValue, global); + } + + void OpenSettings() + { + g_interProcess.m_Callbacks->General.open_settings_dialog(g_interProcess.m_Handle); + } + + void QueueFormattedNotification(const queue_msg type, const char *format, ... ) + { + va_list args; + char buffer[16384]; + va_start(args, format); + vsprintf(buffer, format, args); + va_end(args); + g_interProcess.m_Callbacks->General.queue_notification(g_interProcess.m_Handle, type, buffer); + } + + void QueueNotification( + const queue_msg type, + const std::string& aCaption, + const std::string& aDescription, + unsigned int displayTime, + bool withSound, + unsigned int messageTime) + { + g_interProcess.m_Callbacks->General.queue_notification_from_type(g_interProcess.m_Handle, + type, aCaption.c_str(), aDescription.c_str(), + displayTime, withSound, messageTime); + } + + void QueueNotification( + const std::string& aCaption, + const std::string& aDescription) + { + g_interProcess.m_Callbacks->General.queue_notification_with_image(g_interProcess.m_Handle, "", + aCaption.c_str(), aDescription.c_str(), + 5000, false, 1000); + } + + void QueueNotification( + const std::string& aImageFile, + const std::string& aCaption, + const std::string& aDescription, + unsigned int displayTime, + bool withSound, + unsigned int messageTime) + { + g_interProcess.m_Callbacks->General.queue_notification_with_image(g_interProcess.m_Handle, aImageFile.c_str(), + aCaption.c_str(), aDescription.c_str(), + displayTime, withSound, messageTime); + } + + void GetMD5(const std::string& text, std::string& md5) + { + char* md5ret = (char*)malloc(40*sizeof(char)); // md5 size normally 32 bytes + g_interProcess.m_Callbacks->General.get_md5(text.c_str(), *md5ret); + md5 = md5ret; + free(md5ret); + } + + bool UnknownToUTF8( + const std::string& stringSrc, + std::string& utf8StringDst, + bool failOnBadChar) + { + bool ret = false; + char* retString = g_interProcess.m_Callbacks->General.unknown_to_utf8(g_interProcess.m_Handle, stringSrc.c_str(), ret, failOnBadChar); + if (retString != nullptr) + { + if (ret) + utf8StringDst = retString; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, retString); + } + return ret; + } + + std::string GetLocalizedString(uint32_t labelId, const std::string& strDefault) + { + std::string strReturn = strDefault; + char* strMsg = g_interProcess.m_Callbacks->General.get_localized_string(g_interProcess.m_Handle, labelId); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + std::string GetLanguage(lang_formats format, bool region) + { + std::string language; + language.resize(256); + unsigned int size = (unsigned int)language.capacity(); + g_interProcess.m_Callbacks->General.get_language(g_interProcess.m_Handle, language[0], size, format, region); + language.resize(size); + language.shrink_to_fit(); + return language; + } + + std::string GetDVDMenuLanguage() + { + std::string language; + language.resize(16); + unsigned int size = (unsigned int)language.capacity(); + g_interProcess.m_Callbacks->General.get_dvd_menu_language(g_interProcess.m_Handle, language[0], size); + language.resize(size); + language.shrink_to_fit(); + return language; + } + + bool StartServer(eservers typ, bool start, bool wait) + { + return g_interProcess.m_Callbacks->General.start_server(g_interProcess.m_Handle, (int)typ, start, wait); + } + + void AudioSuspend() + { + g_interProcess.m_Callbacks->General.audio_suspend(g_interProcess.m_Handle); + } + + void AudioResume() + { + g_interProcess.m_Callbacks->General.audio_resume(g_interProcess.m_Handle); + } + + float GetVolume(bool percentage) + { + return g_interProcess.m_Callbacks->General.get_volume(g_interProcess.m_Handle, percentage); + } + + void SetVolume(float value, bool isPercentage) + { + g_interProcess.m_Callbacks->General.set_volume(g_interProcess.m_Handle, value, isPercentage); + } + + bool IsMuted() + { + return g_interProcess.m_Callbacks->General.is_muted(g_interProcess.m_Handle); + } + + void ToggleMute() + { + g_interProcess.m_Callbacks->General.toggle_mute(g_interProcess.m_Handle); + } + + void SetMute(bool mute) + { + if (g_interProcess.m_Callbacks->General.is_muted(g_interProcess.m_Handle) != mute) + g_interProcess.m_Callbacks->General.toggle_mute(g_interProcess.m_Handle); + } + + dvd_state GetOpticalDriveState() + { + return (dvd_state)g_interProcess.m_Callbacks->General.get_optical_state(g_interProcess.m_Handle); + } + + bool EjectOpticalDrive() + { + return g_interProcess.m_Callbacks->General.eject_optical_drive(g_interProcess.m_Handle); + } + + void KodiVersion(kodi_version& version) + { + char* compile_name = nullptr; + char* revision = nullptr; + char* tag = nullptr; + char* tag_revision = nullptr; + + g_interProcess.m_Callbacks->General.kodi_version(g_interProcess.m_Handle, compile_name, version.major, version.minor, revision, tag, tag_revision); + if (compile_name != nullptr) + { + version.compile_name = compile_name; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, compile_name); + } + if (revision != nullptr) + { + version.revision = revision; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, revision); + } + if (tag != nullptr) + { + version.tag = tag; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, tag); + } + if (tag_revision != nullptr) + { + version.tag_revision = tag_revision; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, tag_revision); + } + } + + void KodiQuit() + { + g_interProcess.m_Callbacks->General.kodi_quit(g_interProcess.m_Handle); + } + + void HTPCShutdown() + { + g_interProcess.m_Callbacks->General.htpc_shutdown(g_interProcess.m_Handle); + } + + void HTPCRestart() + { + g_interProcess.m_Callbacks->General.htpc_restart(g_interProcess.m_Handle); + } + + void ExecuteScript(const std::string& script) + { + g_interProcess.m_Callbacks->General.execute_script(g_interProcess.m_Handle, script.c_str()); + } + + void ExecuteBuiltin(const std::string& function, bool wait) + { + g_interProcess.m_Callbacks->General.execute_builtin(g_interProcess.m_Handle, function.c_str(), wait); + } + + std::string ExecuteJSONRPC(const std::string& jsonrpccommand) + { + std::string strReturn; + char* strMsg = g_interProcess.m_Callbacks->General.execute_jsonrpc(g_interProcess.m_Handle, jsonrpccommand.c_str()); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + std::string GetRegion(const std::string& id) + { + std::string strReturn; + char* strMsg = g_interProcess.m_Callbacks->General.get_region(g_interProcess.m_Handle, id.c_str()); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + long GetFreeMem() + { + return g_interProcess.m_Callbacks->General.get_free_mem(g_interProcess.m_Handle); + } + + int GetGlobalIdleTime() + { + return g_interProcess.m_Callbacks->General.get_global_idle_time(g_interProcess.m_Handle); + } + + std::string GetAddonInfo(const std::string& id) + { + std::string strReturn; + char* strMsg = g_interProcess.m_Callbacks->General.get_addon_info(g_interProcess.m_Handle, id.c_str()); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + std::string TranslatePath(const std::string& path) + { + std::string strReturn; + char* strMsg = g_interProcess.m_Callbacks->General.translate_path(g_interProcess.m_Handle, path.c_str()); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + std::string TranslateAddonStatus(ADDON_STATUS status) + { + switch (status) + { + case ADDON_STATUS_OK: return "OK"; + case ADDON_STATUS_LOST_CONNECTION: return "Lost connection"; + case ADDON_STATUS_NEED_RESTART: return "Needs restart"; + case ADDON_STATUS_NEED_SETTINGS: return "Needs settngs"; + case ADDON_STATUS_UNKNOWN: return "Unknown"; + case ADDON_STATUS_NEED_SAVEDSETTINGS: return "Needs saved settings"; + case ADDON_STATUS_PERMANENT_FAILURE: return "Permanent failure"; + default: + break; + } + return ""; + } + +} /* namespace General */ +} /* namespace AddOn */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_Network.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_Network.cpp new file mode 100644 index 0000000000..7b7da73200 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_Network.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" + +#include <string> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace AddOn +{ +namespace Network +{ + + bool WakeOnLan(const std::string& mac) + { + return g_interProcess.m_Callbacks->Network.wake_on_lan(g_interProcess.m_Handle, mac.c_str()); + } + + std::string GetIPAddress() + { + std::string ip; + ip.resize(32); + unsigned int size = (unsigned int)ip.capacity(); + g_interProcess.m_Callbacks->Network.get_ip_address(g_interProcess.m_Handle, ip[0], size); + ip.resize(size); + ip.shrink_to_fit(); + return ip; + } + + std::string URLEncode(const std::string& url) + { + std::string retString; + char* string = g_interProcess.m_Callbacks->Network.url_encode(g_interProcess.m_Handle, url.c_str()); + if (string != nullptr) + { + retString = string; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, string); + } + return retString; + } + + bool DNSLookup(const std::string& strHostName, std::string& strIpAddress) + { + bool ret = false; + char* ipAddress = g_interProcess.m_Callbacks->Network.dns_lookup(g_interProcess.m_Handle, strHostName.c_str(), ret); + if (ipAddress != nullptr) + { + strIpAddress = ipAddress; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, ipAddress); + } + return ret; + } + +} /* namespace KodiAPI_Codec */ +} /* namespace AddOn */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_SoundPlay.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_SoundPlay.cpp new file mode 100644 index 0000000000..5ae3ba69d0 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_SoundPlay.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, addon/SoundPlay.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace AddOn +{ + + CSoundPlay::CSoundPlay(const std::string& filename) + : m_PlayHandle(nullptr) + { + m_PlayHandle = g_interProcess.m_Callbacks->Audio.soundplay_get_handle(g_interProcess.m_Handle, filename.c_str()); + if (!m_PlayHandle) + fprintf(stderr, "libKODI_addon-ERROR: CSoundPlay can't get callback table from KODI !!!\n"); + } + + CSoundPlay::~CSoundPlay() + { + if (m_PlayHandle) + g_interProcess.m_Callbacks->Audio.soundplay_release_handle(g_interProcess.m_Handle, m_PlayHandle); + } + + void CSoundPlay::Play() + { + if (m_PlayHandle) + g_interProcess.m_Callbacks->Audio.soundplay_play(g_interProcess.m_Handle, m_PlayHandle); + } + + void CSoundPlay::Stop() + { + if (m_PlayHandle) + g_interProcess.m_Callbacks->Audio.soundplay_stop(g_interProcess.m_Handle, m_PlayHandle); + } + + void CSoundPlay::SetChannel(audio_channel channel) + { + if (m_PlayHandle) + g_interProcess.m_Callbacks->Audio.soundplay_set_channel(g_interProcess.m_Handle, m_PlayHandle, channel); + } + + audio_channel CSoundPlay::GetChannel() + { + if (!m_PlayHandle) + return AUDIO_CH_INVALID; + return (audio_channel)g_interProcess.m_Callbacks->Audio.soundplay_get_channel(g_interProcess.m_Handle, m_PlayHandle); + } + + void CSoundPlay::SetVolume(float volume) + { + if (m_PlayHandle) + g_interProcess.m_Callbacks->Audio.soundplay_set_volume(g_interProcess.m_Handle, m_PlayHandle, volume); + } + + float CSoundPlay::GetVolume() + { + if (!m_PlayHandle) + return 0.0f; + return g_interProcess.m_Callbacks->Audio.soundplay_get_volume(g_interProcess.m_Handle, m_PlayHandle); + } + +} /* namespace AddOn */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_VFSUtils.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_VFSUtils.cpp new file mode 100644 index 0000000000..afe6bddc96 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/addon/AddonLib_Addon_VFSUtils.cpp @@ -0,0 +1,358 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, addon/VFSUtils.hpp) + +#include <cstring> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace AddOn +{ + + CVFSDirEntry::CVFSDirEntry( + const std::string& label, + const std::string& path, + bool bFolder, + int64_t size) + : m_label(label), + m_path(path), + m_bFolder(bFolder), + m_size(size) + { + } + + CVFSDirEntry::CVFSDirEntry(const VFSDirEntry& dirEntry) + : m_label(dirEntry.label ? dirEntry.label : ""), + m_path(dirEntry.path ? dirEntry.path : ""), + m_bFolder(dirEntry.folder), + m_size(dirEntry.size) + { + } + + const std::string& CVFSDirEntry::Label(void) const + { + return m_label; + } + + const std::string& CVFSDirEntry::Path(void) const + { + return m_path; + } + + bool CVFSDirEntry::IsFolder(void) const + { + return m_bFolder; + } + + int64_t CVFSDirEntry::Size(void) const + { + return m_size; + } + + void CVFSDirEntry::SetLabel(const std::string& label) + { + m_label = label; + } + + void CVFSDirEntry::SetPath(const std::string& path) + { + m_path = path; + } + + void CVFSDirEntry::SetFolder(bool bFolder) + { + m_bFolder = bFolder; + } + + void CVFSDirEntry::SetSize(int64_t size) + { + m_size = size; + } + //---------------------------------------------------------------------------- + + + //============================================================================ + CVFSFile::CVFSFile() + : m_pFile(nullptr) + { + + } + + CVFSFile::~CVFSFile() + { + Close(); + } + + bool CVFSFile::OpenFile(const std::string& strFileName, unsigned int flags) + { + Close(); + m_pFile = g_interProcess.m_Callbacks->File.open_file(g_interProcess.m_Handle, strFileName.c_str(), flags); + return m_pFile != nullptr; + } + + bool CVFSFile::OpenFileForWrite(const std::string& strFileName, bool bOverWrite) + { + Close(); + + // Try to open the file. If it fails, check if we need to create the directory first + // This way we avoid checking if the directory exists every time + m_pFile = g_interProcess.m_Callbacks->File.open_file_for_write(g_interProcess.m_Handle, strFileName.c_str(), bOverWrite); + if (!m_pFile) + { + std::string cacheDirectory = KodiAPI::AddOn::VFSUtils::GetDirectoryName(strFileName); + if (g_interProcess.m_Callbacks->Directory.directory_exists(g_interProcess.m_Handle, cacheDirectory.c_str()) || + g_interProcess.m_Callbacks->Directory.create_directory(g_interProcess.m_Handle, cacheDirectory.c_str())) + m_pFile = g_interProcess.m_Callbacks->File.open_file_for_write(g_interProcess.m_Handle, strFileName.c_str(), bOverWrite); + } + return m_pFile != nullptr; + } + + ssize_t CVFSFile::Read(void* lpBuf, size_t uiBufSize) + { + if (!m_pFile) + return 0; + return g_interProcess.m_Callbacks->File.read_file(g_interProcess.m_Handle, m_pFile, lpBuf, uiBufSize); + } + + bool CVFSFile::ReadLine(std::string &strLine) + { + strLine.clear(); + if (!m_pFile) + return false; + // TODO: Read 1024 chars into buffer. If file position advanced that many + // chars, we didn't hit a newline. Otherwise, if file position is 1 or 2 + // past the number of bytes read, we read (and skipped) a newline sequence. + char buffer[1025]; + if (g_interProcess.m_Callbacks->File.read_file_string(g_interProcess.m_Handle, m_pFile, buffer, sizeof(buffer))) + { + strLine = buffer; + return !strLine.empty(); + } + return false; + } + + ssize_t CVFSFile::Write(const void* lpBuf, size_t uiBufSize) + { + if (!m_pFile) + return 0; + return g_interProcess.m_Callbacks->File.write_file(g_interProcess.m_Handle, m_pFile, lpBuf, uiBufSize); + } + + void CVFSFile::Flush() + { + if (!m_pFile) + return; + g_interProcess.m_Callbacks->File.flush_file(g_interProcess.m_Handle, m_pFile); + } + + int64_t CVFSFile::Seek(int64_t iFilePosition, int iWhence) + { + if (!m_pFile) + return 0; + return g_interProcess.m_Callbacks->File.seek_file(g_interProcess.m_Handle, m_pFile, iFilePosition, iWhence); + } + + int CVFSFile::Truncate(int64_t iSize) + { + if (!m_pFile) + return -1; + return g_interProcess.m_Callbacks->File.truncate_file(g_interProcess.m_Handle, m_pFile, iSize); + } + + int64_t CVFSFile::GetPosition() + { + if (!m_pFile) + return -1; + return g_interProcess.m_Callbacks->File.get_file_position(g_interProcess.m_Handle, m_pFile); + } + + int64_t CVFSFile::GetLength() + { + if (!m_pFile) + return 0; + return g_interProcess.m_Callbacks->File.get_file_length(g_interProcess.m_Handle, m_pFile); + } + + void CVFSFile::Close() + { + if (!m_pFile) + return; + g_interProcess.m_Callbacks->File.close_file(g_interProcess.m_Handle, m_pFile); + m_pFile = nullptr; + } + + int CVFSFile::GetChunkSize() + { + if (!m_pFile) + return 0; + return g_interProcess.m_Callbacks->File.get_file_chunk_size(g_interProcess.m_Handle, m_pFile); + } + //---------------------------------------------------------------------------- + + + //============================================================================ + namespace VFSUtils + { + + bool CreateDirectory(const std::string& strPath) + { + return g_interProcess.m_Callbacks->Directory.create_directory(g_interProcess.m_Handle, strPath.c_str()); + } + + bool DirectoryExists(const std::string& strPath) + { + return g_interProcess.m_Callbacks->Directory.directory_exists(g_interProcess.m_Handle, strPath.c_str()); + } + + bool RemoveDirectory(const std::string& strPath) + { + return g_interProcess.m_Callbacks->Directory.remove_directory(g_interProcess.m_Handle, strPath.c_str()); + } + + bool GetDirectory( + const std::string& path, + const std::string& mask, + std::vector<CVFSDirEntry>& items) + { + VFSDirEntry* dir_list = nullptr; + unsigned int num_items = 0; + if (g_interProcess.m_Callbacks->VFS.get_directory(g_interProcess.m_Handle, path.c_str(), mask.c_str(), &dir_list, &num_items)) + { + if (dir_list) + { + for (unsigned int i = 0; i < num_items; ++i) + items.push_back(CVFSDirEntry(dir_list[i])); + + g_interProcess.m_Callbacks->VFS.free_directory(g_interProcess.m_Handle, dir_list, num_items); + } + + return true; + } + return false; + } + + std::string MakeLegalFileName(const std::string& strFileName) + { + std::string strReturn; + char* strLegalFileName = g_interProcess.m_Callbacks->File.make_legal_filename(g_interProcess.m_Handle, strFileName.c_str()); + if (strLegalFileName != nullptr) + { + if (std::strlen(strLegalFileName)) + strReturn = strLegalFileName; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strLegalFileName); + } + return strReturn; + } + + std::string MakeLegalPath(const std::string& strPath) + { + std::string strReturn; + char* strLegalPath = g_interProcess.m_Callbacks->File.make_legal_path(g_interProcess.m_Handle, strPath.c_str()); + if (strLegalPath != nullptr) + { + if (std::strlen(strLegalPath)) + strReturn = strLegalPath; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strLegalPath); + } + return strReturn; + } + + bool FileExists(const std::string& strFileName, bool bUseCache) + { + return g_interProcess.m_Callbacks->File.file_exists(g_interProcess.m_Handle, strFileName.c_str(), bUseCache); + } + + int StatFile(const std::string& strFileName, struct __stat64* buffer) + { + return g_interProcess.m_Callbacks->File.stat_file(g_interProcess.m_Handle, strFileName.c_str(), buffer); + } + + bool DeleteFile(const std::string& strFileName) + { + return g_interProcess.m_Callbacks->File.delete_file(g_interProcess.m_Handle, strFileName.c_str()); + } + + std::string GetFileMD5(const std::string& strPath) + { + std::string strReturn; + char* strMd5 = g_interProcess.m_Callbacks->File.get_file_md5(g_interProcess.m_Handle, strPath.c_str()); + if (strMd5 != nullptr) + { + if (std::strlen(strMd5)) + strReturn = strMd5; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMd5); + } + return strReturn; + } + + std::string GetCacheThumbName(const std::string& strFileName) + { + std::string strReturn; + char* strThumbName = g_interProcess.m_Callbacks->File.get_cache_thumb_name(g_interProcess.m_Handle, strFileName.c_str()); + if (strThumbName != nullptr) + { + if (std::strlen(strThumbName)) + strReturn = strThumbName; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strThumbName); + } + return strReturn; + } + + unsigned int GetChunkSize(unsigned int chunk, unsigned int minimum) + { + if (chunk) + return chunk * ((minimum + chunk - 1) / chunk); + else + return minimum; + } + + std::string GetFileName(const std::string& strFileNameAndPath) + { + /* find the last slash */ + const size_t slash = strFileNameAndPath.find_last_of("/\\"); + return strFileNameAndPath.substr(slash+1); + } + + std::string GetDirectoryName(const std::string &strFilePath) + { + // Will from a full filename return the directory the file resides in. + // Keeps the final slash at end and possible |option=foo options. + + size_t iPosSlash = strFilePath.find_last_of("/\\"); + if (iPosSlash == std::string::npos) + return ""; // No slash, so no path (ignore any options) + + size_t iPosBar = strFilePath.rfind('|'); + if (iPosBar == std::string::npos) + return strFilePath.substr(0, iPosSlash + 1); // Only path + + return strFilePath.substr(0, iPosSlash + 1) + strFilePath.substr(iPosBar); // Path + options + } + + } /* namespace VFSUtils */ + +} /* namespace AddOn */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/audioengine/AddonLib_AudioEngine_General.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/audioengine/AddonLib_AudioEngine_General.cpp new file mode 100644 index 0000000000..695da0403f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/audioengine/AddonLib_AudioEngine_General.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, audioengine/General.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ + +namespace AudioEngine +{ +namespace General +{ + + void AddDSPMenuHook(AE_DSP_MENUHOOK* hook) + { + g_interProcess.m_Callbacks->AudioEngine.add_dsp_menu_hook(g_interProcess.m_Handle, hook); + } + + void RemoveDSPMenuHook(AE_DSP_MENUHOOK* hook) + { + g_interProcess.m_Callbacks->AudioEngine.remove_dsp_menu_hook(g_interProcess.m_Handle, hook); + } + /*\_________________________________________________________________________ + \*/ + void RegisterDSPMode(AE_DSP_MODES::AE_DSP_MODE* mode) + { + g_interProcess.m_Callbacks->AudioEngine.register_dsp_mode(g_interProcess.m_Handle, mode); + } + + void UnregisterDSPMode(AE_DSP_MODES::AE_DSP_MODE* mode) + { + g_interProcess.m_Callbacks->AudioEngine.unregister_dsp_Mode(g_interProcess.m_Handle, mode); + } + /*\_________________________________________________________________________ + \*/ + bool GetCurrentSinkFormat(AudioEngineFormat &SinkFormat) + { + return g_interProcess.m_Callbacks->AudioEngine.get_current_sink_format(g_interProcess.m_Handle, &SinkFormat); + } + +} /* namespace General */ +} /* namespace AudioEngine */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/audioengine/AddonLib_AudioEngine_Stream.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/audioengine/AddonLib_AudioEngine_Stream.cpp new file mode 100644 index 0000000000..cb20cca702 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/audioengine/AddonLib_AudioEngine_Stream.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, audioengine/Stream.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ + +namespace AudioEngine +{ + + CStream::CStream( + AudioEngineFormat Format, + unsigned int Options) + { + m_StreamHandle = g_interProcess.m_Callbacks->AudioEngine.make_stream(g_interProcess.m_Handle, Format, Options); + if (!m_StreamHandle) + fprintf(stderr, "libKODI_audioengine-ERROR: make_stream failed!\n"); + m_planes = g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetChannelCount(g_interProcess.m_Handle, m_StreamHandle); + } + + CStream::~CStream() + { + g_interProcess.m_Callbacks->AudioEngine.free_stream(g_interProcess.m_Handle, m_StreamHandle); + } + + unsigned int CStream::GetSpace() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetSpace(g_interProcess.m_Handle, m_StreamHandle); + } + + unsigned int CStream::AddData(uint8_t* const *Data, unsigned int Offset, unsigned int Frames) + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_AddData(g_interProcess.m_Handle, m_StreamHandle, Data, Offset, Frames); + } + + double CStream::GetDelay() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetDelay(g_interProcess.m_Handle, m_StreamHandle); + } + + bool CStream::IsBuffering() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_IsBuffering(g_interProcess.m_Handle, m_StreamHandle); + } + + double CStream::GetCacheTime() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetCacheTime(g_interProcess.m_Handle, m_StreamHandle); + } + + double CStream::GetCacheTotal() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetCacheTotal(g_interProcess.m_Handle, m_StreamHandle); + } + + void CStream::Pause() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_Pause(g_interProcess.m_Handle, m_StreamHandle); + } + + void CStream::Resume() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_Resume(g_interProcess.m_Handle, m_StreamHandle); + } + + void CStream::Drain(bool Wait) + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_Drain(g_interProcess.m_Handle, m_StreamHandle, Wait); + } + + bool CStream::IsDraining() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_IsDraining(g_interProcess.m_Handle, m_StreamHandle); + } + + bool CStream::IsDrained() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_IsDrained(g_interProcess.m_Handle, m_StreamHandle); + } + + void CStream::Flush() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_Flush(g_interProcess.m_Handle, m_StreamHandle); + } + + float CStream::GetVolume() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetVolume(g_interProcess.m_Handle, m_StreamHandle); + } + + void CStream::SetVolume(float Volume) + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_SetVolume(g_interProcess.m_Handle, m_StreamHandle, Volume); + } + + float CStream::GetAmplification() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetAmplification(g_interProcess.m_Handle, m_StreamHandle); + } + + void CStream::SetAmplification(float Amplify) + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_SetAmplification(g_interProcess.m_Handle, m_StreamHandle, Amplify); + } + + const unsigned int CStream::GetFrameSize() const + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetFrameSize(g_interProcess.m_Handle, m_StreamHandle); + } + + const unsigned int CStream::GetChannelCount() const + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetChannelCount(g_interProcess.m_Handle, m_StreamHandle); + } + + const unsigned int CStream::GetSampleRate() const + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetSampleRate(g_interProcess.m_Handle, m_StreamHandle); + } + + const AEDataFormat CStream::GetDataFormat() const + { + return (AEDataFormat)g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetDataFormat(g_interProcess.m_Handle, m_StreamHandle); + } + + double CStream::GetResampleRatio() + { + return g_interProcess.m_Callbacks->AudioEngineStream.AEStream_GetResampleRatio(g_interProcess.m_Handle, m_StreamHandle); + } + + void CStream::SetResampleRatio(double Ratio) + { + g_interProcess.m_Callbacks->AudioEngineStream.AEStream_SetResampleRatio(g_interProcess.m_Handle, m_StreamHandle, Ratio); + } + +} /* namespace AudioEngine */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/dlfcn-win32.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/dlfcn-win32.cpp new file mode 100644 index 0000000000..127c3e2e5d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/dlfcn-win32.cpp @@ -0,0 +1,262 @@ +/* + * dlfcn-win32 + * Copyright (c) 2007 Ramiro Polla + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <windows.h> +#include <stdio.h> + +#include "dlfcn-win32.h" + +/* Note: + * MSDN says these functions are not thread-safe. We make no efforts to have + * any kind of thread safety. + */ + +/* I have no special reason to have set MAX_GLOBAL_OBJECTS to this value. Any + * comments are welcome. + */ +#define MAX_OBJECTS 255 + +static HMODULE global_objects[MAX_OBJECTS]; + +/* This function adds an object to the list of global objects. + * The implementation is very simple and slow. + * TODO: should failing this function be enough to fail the call to dlopen( )? + */ +static void global_object_add( HMODULE hModule ) +{ + int i; + + for( i = 0 ; i < MAX_OBJECTS ; i++ ) + { + if( !global_objects[i] ) + { + global_objects[i] = hModule; + break; + } + } +} + +static void global_object_rem( HMODULE hModule ) +{ + int i; + + for( i = 0 ; i < MAX_OBJECTS ; i++ ) + { + if( global_objects[i] == hModule ) + { + global_objects[i] = 0; + break; + } + } +} + +/* Argument to last function. Used in dlerror( ) */ +static char last_name[MAX_PATH]; + +static int copy_string( char *dest, int dest_size, const char *src ) +{ + int i = 0; + + if( src && dest ) + { + for( i = 0 ; i < dest_size-1 ; i++ ) + { + if( !src[i] ) + break; + else + dest[i] = src[i]; + } + } + dest[i] = '\0'; + + return i; +} + +void *dlopen( const char *file, int mode ) +{ + HMODULE hModule; + UINT uMode; + + /* Do not let Windows display the critical-error-handler message box */ + uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); + + if( file == 0 ) + { + /* Save NULL pointer for error message */ + _snprintf_s( last_name, MAX_PATH, MAX_PATH, "0x%p", file ); + + /* POSIX says that if the value of file is 0, a handle on a global + * symbol object must be provided. That object must be able to access + * all symbols from the original program file, and any objects loaded + * with the RTLD_GLOBAL flag. + * The return value from GetModuleHandle( ) allows us to retrieve + * symbols only from the original program file. For objects loaded with + * the RTLD_GLOBAL flag, we create our own list later on. + */ + hModule = GetModuleHandle( NULL ); + } + else + { + char lpFileName[MAX_PATH]; + int i; + + /* MSDN says backslashes *must* be used instead of forward slashes. */ + for( i = 0 ; i < sizeof(lpFileName)-1 ; i++ ) + { + if( !file[i] ) + break; + else if( file[i] == '/' ) + lpFileName[i] = '\\'; + else + lpFileName[i] = file[i]; + } + lpFileName[i] = '\0'; + + /* Save file name for error message */ + copy_string( last_name, sizeof(last_name), lpFileName ); + + /* POSIX says the search path is implementation-defined. + * LOAD_WITH_ALTERED_SEARCH_PATH is used to make it behave more closely + * to UNIX's search paths (start with system folders instead of current + * folder). + */ + hModule = LoadLibraryEx( (LPSTR) lpFileName, NULL, + LOAD_WITH_ALTERED_SEARCH_PATH ); + /* If the object was loaded with RTLD_GLOBAL, add it to list of global + * objects, so that its symbols may be retrieved even if the handle for + * the original program file is passed. POSIX says that if the same + * file is specified in multiple invocations, and any of them are + * RTLD_GLOBAL, even if any further invocations use RTLD_LOCAL, the + * symbols will remain global. + */ + + if( hModule && (mode & RTLD_GLOBAL) ) + global_object_add( hModule ); + } + + /* Return to previous state of the error-mode bit flags. */ + SetErrorMode( uMode ); + + return (void *) hModule; +} + +int dlclose( void *handle ) +{ + HMODULE hModule = (HMODULE) handle; + BOOL ret; + + /* Save handle for error message */ + _snprintf_s( last_name, MAX_PATH, MAX_PATH, "0x%p", handle ); + + ret = FreeLibrary( hModule ); + + /* If the object was loaded with RTLD_GLOBAL, remove it from list of global + * objects. + */ + if( ret ) + global_object_rem( hModule ); + + /* dlclose's return value in inverted in relation to FreeLibrary's. */ + ret = !ret; + + return (int) ret; +} + +void *dlsym( void *handle, const char *name ) +{ + FARPROC symbol; + HMODULE myhandle = (HMODULE) handle; + + /* Save symbol name for error message */ + copy_string( last_name, sizeof(last_name), name ); + + symbol = GetProcAddress( myhandle, name ); +#if 0 + if( symbol == NULL ) + { + HMODULE hModule; + + /* If the handle for the original program file is passed, also search + * in all globally loaded objects. + */ + + hModule = GetModuleHandle( NULL ); + + if( hModule == handle ) + { + int i; + + for( i = 0 ; i < MAX_OBJECTS ; i++ ) + { + if( global_objects[i] != 0 ) + { + symbol = GetProcAddress( global_objects[i], name ); + if( symbol != NULL ) + break; + } + } + } + + + CloseHandle( hModule ); + } +#endif + return (void*) symbol; +} + +char *dlerror( void ) +{ + DWORD dwMessageId; + /* POSIX says this function doesn't have to be thread-safe, so we use one + * static buffer. + * MSDN says the buffer cannot be larger than 64K bytes, so we set it to + * the limit. + */ + static char lpBuffer[65535]; + DWORD ret; + + dwMessageId = GetLastError( ); + + if( dwMessageId == 0 ) + return NULL; + + /* Format error message to: + * "<argument to function that failed>": <Windows localized error message> + */ + ret = copy_string( lpBuffer, sizeof(lpBuffer), "\"" ); + ret += copy_string( lpBuffer+ret, sizeof(lpBuffer)-ret, last_name ); + ret += copy_string( lpBuffer+ret, sizeof(lpBuffer)-ret, "\": " ); + ret += FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMessageId, + MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), + lpBuffer+ret, sizeof(lpBuffer)-ret, NULL ); + + if( ret > 1 ) + { + /* POSIX says the string must not have trailing <newline> */ + if( lpBuffer[ret-2] == '\r' && lpBuffer[ret-1] == '\n' ) + lpBuffer[ret-2] = '\0'; + } + + /* POSIX says that invoking dlerror( ) a second time, immediately following + * a prior invocation, shall result in NULL being returned. + */ + SetLastError(0); + + return lpBuffer; +} diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/dlfcn-win32.h b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/dlfcn-win32.h new file mode 100644 index 0000000000..b93a029f29 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/dlfcn-win32.h @@ -0,0 +1,46 @@ +#pragma once +/* + * dlfcn-win32 + * Copyright (c) 2007 Ramiro Polla + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef DLFCN_H +#define DLFCN_H + +/* POSIX says these are implementation-defined. + * To simplify use with Windows API, we treat them the same way. + */ + +#define RTLD_LAZY 0 +#define RTLD_NOW 0 + +#define RTLD_GLOBAL (1 << 1) +#define RTLD_LOCAL (1 << 2) + +/* These two were added in The Open Group Base Specifications Issue 6. + * Note: All other RTLD_* flags in any dlfcn.h are not standard compliant. + */ + +#define RTLD_DEFAULT 0 +#define RTLD_NEXT 0 + +void *dlopen ( const char *file, int mode ); +int dlclose( void *handle ); +void *dlsym ( void *handle, const char *name ); +char *dlerror( void ); + +#endif /* DLFCN-WIN32_H */ diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlButton.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlButton.cpp new file mode 100644 index 0000000000..4e4dd56072 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlButton.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlButton.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlButton::CControlButton(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_Button(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlButton can't create control class from Kodi !!!\n"); + } + + CControlButton::~CControlButton() + { + } + + void CControlButton::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.Button.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlButton::SetEnabled(bool enabled) + { + g_interProcess.m_Callbacks->GUI.Control.Button.SetEnabled(g_interProcess.m_Handle, m_ControlHandle, enabled); + } + + void CControlButton::SetLabel(const std::string& label) + { + g_interProcess.m_Callbacks->GUI.Control.Button.SetLabel(g_interProcess.m_Handle, m_ControlHandle, label.c_str()); + } + + std::string CControlButton::GetLabel() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.Button.GetLabel(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlButton::SetLabel2(const std::string& label) + { + g_interProcess.m_Callbacks->GUI.Control.Button.SetLabel2(g_interProcess.m_Handle, m_ControlHandle, label.c_str()); + } + + std::string CControlButton::GetLabel2() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.Button.GetLabel2(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlEdit.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlEdit.cpp new file mode 100644 index 0000000000..148a8aa87d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlEdit.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlEdit.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlEdit::CControlEdit(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_Edit(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlEdit can't create control class from Kodi !!!\n"); + } + + CControlEdit::~CControlEdit() + { + } + + void CControlEdit::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.Edit.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlEdit::SetEnabled(bool enabled) + { + g_interProcess.m_Callbacks->GUI.Control.Edit.SetEnabled(g_interProcess.m_Handle, m_ControlHandle, enabled); + } + + void CControlEdit::SetLabel(const std::string& label) + { + g_interProcess.m_Callbacks->GUI.Control.Edit.SetLabel(g_interProcess.m_Handle, m_ControlHandle, label.c_str()); + } + + std::string CControlEdit::GetLabel() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.Edit.GetLabel(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlEdit::SetText(const std::string& text) + { + g_interProcess.m_Callbacks->GUI.Control.Edit.SetText(g_interProcess.m_Handle, m_ControlHandle, text.c_str()); + } + + std::string CControlEdit::GetText() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.Edit.GetText(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlEdit::SetCursorPosition(unsigned int iPosition) + { + g_interProcess.m_Callbacks->GUI.Control.Edit.SetCursorPosition(g_interProcess.m_Handle, m_ControlHandle, iPosition); + } + + unsigned int CControlEdit::GetCursorPosition() + { + return g_interProcess.m_Callbacks->GUI.Control.Edit.GetCursorPosition(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlEdit::SetInputType(AddonGUIInputType type, const std::string& heading) + { + g_interProcess.m_Callbacks->GUI.Control.Edit.SetInputType(g_interProcess.m_Handle, m_ControlHandle, type, heading.c_str()); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlFadeLabel.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlFadeLabel.cpp new file mode 100644 index 0000000000..4fd1be9013 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlFadeLabel.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlFadeLabel.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlFadeLabel::CControlFadeLabel(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_FadeLabel(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlFadeLabel can't create control class from Kodi !!!\n"); + } + + CControlFadeLabel::~CControlFadeLabel() + { + } + + void CControlFadeLabel::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.FadeLabel.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlFadeLabel::AddLabel(const std::string& text) + { + g_interProcess.m_Callbacks->GUI.Control.FadeLabel.AddLabel(g_interProcess.m_Handle, m_ControlHandle, text.c_str()); + } + + std::string CControlFadeLabel::GetLabel() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.FadeLabel.GetLabel(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlFadeLabel::SetScrolling(bool scroll) + { + g_interProcess.m_Callbacks->GUI.Control.FadeLabel.SetScrolling(g_interProcess.m_Handle, m_ControlHandle, scroll); + } + + void CControlFadeLabel::Reset() + { + g_interProcess.m_Callbacks->GUI.Control.FadeLabel.Reset(g_interProcess.m_Handle, m_ControlHandle); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlImage.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlImage.cpp new file mode 100644 index 0000000000..d3ef29d56b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlImage.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlImage.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlImage::CControlImage(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_Image(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlImage can't create control class from Kodi !!!\n"); + } + + CControlImage::~CControlImage() + { + } + + void CControlImage::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.Image.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlImage::SetFileName(const std::string& strFileName, const bool useCache) + { + g_interProcess.m_Callbacks->GUI.Control.Image.SetFileName(g_interProcess.m_Handle, m_ControlHandle, strFileName.c_str(), useCache); + } + + void CControlImage::SetColorDiffuse(uint32_t colorDiffuse) + { + g_interProcess.m_Callbacks->GUI.Control.Image.SetColorDiffuse(g_interProcess.m_Handle, m_ControlHandle, colorDiffuse); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlLabel.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlLabel.cpp new file mode 100644 index 0000000000..1797338537 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlLabel.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlLabel.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlLabel::CControlLabel(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_Label(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlLabel can't create control class from Kodi !!!\n"); + } + + CControlLabel::~CControlLabel() + { + } + + void CControlLabel::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.Label.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlLabel::SetLabel(const std::string& text) + { + g_interProcess.m_Callbacks->GUI.Control.Label.SetLabel(g_interProcess.m_Handle, m_ControlHandle, text.c_str()); + } + + std::string CControlLabel::GetLabel() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.Label.GetLabel(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlProgress.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlProgress.cpp new file mode 100644 index 0000000000..9e4c25f2d2 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlProgress.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlProgress.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlProgress::CControlProgress(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_Progress(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlProgress can't create control class from Kodi !!!\n"); + } + + CControlProgress::~CControlProgress() + { + } + + void CControlProgress::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.Progress.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlProgress::SetPercentage(float percent) + { + g_interProcess.m_Callbacks->GUI.Control.Progress.SetPercentage(g_interProcess.m_Handle, m_ControlHandle, percent); + } + + float CControlProgress::GetPercentage() const + { + return g_interProcess.m_Callbacks->GUI.Control.Progress.GetPercentage(g_interProcess.m_Handle, m_ControlHandle); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlRadioButton.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlRadioButton.cpp new file mode 100644 index 0000000000..a5e897fc7c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlRadioButton.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlRadioButton.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlRadioButton::CControlRadioButton(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_RadioButton(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlRadioButton can't create control class from Kodi !!!\n"); + } + + CControlRadioButton::~CControlRadioButton() + { + } + + void CControlRadioButton::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.RadioButton.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlRadioButton::SetEnabled(bool enabled) + { + g_interProcess.m_Callbacks->GUI.Control.RadioButton.SetEnabled(g_interProcess.m_Handle, m_ControlHandle, enabled); + } + + void CControlRadioButton::SetLabel(const std::string& label) + { + g_interProcess.m_Callbacks->GUI.Control.RadioButton.SetLabel(g_interProcess.m_Handle, m_ControlHandle, label.c_str()); + } + + std::string CControlRadioButton::GetLabel() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.RadioButton.GetLabel(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlRadioButton::SetSelected(bool yesNo) + { + g_interProcess.m_Callbacks->GUI.Control.RadioButton.SetSelected(g_interProcess.m_Handle, m_ControlHandle, yesNo); + } + + bool CControlRadioButton::IsSelected() const + { + return g_interProcess.m_Callbacks->GUI.Control.RadioButton.IsSelected(g_interProcess.m_Handle, m_ControlHandle); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlRendering.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlRendering.cpp new file mode 100644 index 0000000000..22e4e211ee --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlRendering.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlRendering.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlRendering::CControlRendering( + CWindow* window, + int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_RenderAddon(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (m_ControlHandle) + g_interProcess.m_Callbacks->GUI.Control.Rendering.SetCallbacks(g_interProcess.m_Handle, m_ControlHandle, this, + OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); + else + fprintf(stderr, "ERROR: CControlRendering can't create control class from Kodi !!!\n"); + } + + CControlRendering::~CControlRendering() + { + g_interProcess.m_Callbacks->GUI.Control.Rendering.Delete(g_interProcess.m_Handle, m_ControlHandle); + } + + /*! + * Kodi to add-on override definition function to use if class becomes used + * independet. + */ + + void CControlRendering::SetIndependentCallbacks( + GUIHANDLE cbhdl, + bool (*CBCreate)(GUIHANDLE cbhdl, + int x, + int y, + int w, + int h, + void* device), + void (*CBRender)(GUIHANDLE cbhdl), + void (*CBStop) (GUIHANDLE cbhdl), + bool (*CBDirty) (GUIHANDLE cbhdl)) + { + if (!cbhdl || + !CBCreate || !CBRender || !CBStop || !CBDirty) + { + fprintf(stderr, "ERROR: CControlRendering - SetIndependentCallbacks called with nullptr !!!\n"); + return; + } + + g_interProcess.m_Callbacks->GUI.Control.Rendering.SetCallbacks(g_interProcess.m_Handle, m_ControlHandle, cbhdl, + CBCreate, CBRender, CBStop, CBDirty); + } + + /*! + * Defined callback functions from Kodi to add-on, for use in parent / child system + * (is private)! + */ + + bool CControlRendering::OnCreateCB(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device) + { + return static_cast<CControlRendering*>(cbhdl)->Create(x, y, w, h, device); + } + + void CControlRendering::OnRenderCB(GUIHANDLE cbhdl) + { + static_cast<CControlRendering*>(cbhdl)->Render(); + } + + void CControlRendering::OnStopCB(GUIHANDLE cbhdl) + { + static_cast<CControlRendering*>(cbhdl)->Stop(); + } + + bool CControlRendering::OnDirtyCB(GUIHANDLE cbhdl) + { + return static_cast<CControlRendering*>(cbhdl)->Dirty(); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSettingsSlider.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSettingsSlider.cpp new file mode 100644 index 0000000000..ccac7e550f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSettingsSlider.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlSettingsSlider.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlSettingsSlider::CControlSettingsSlider(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_SettingsSlider(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlSettingsSlider can't create control class from Kodi !!!\n"); + } + + CControlSettingsSlider::~CControlSettingsSlider() + { + } + + void CControlSettingsSlider::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlSettingsSlider::SetEnabled(bool enabled) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetEnabled(g_interProcess.m_Handle, m_ControlHandle, enabled); + } + + void CControlSettingsSlider::SetText(const std::string& label) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetText(g_interProcess.m_Handle, m_ControlHandle, label.c_str()); + } + + void CControlSettingsSlider::Reset() + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.Reset(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSettingsSlider::SetIntRange(int start, int end) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetIntRange(g_interProcess.m_Handle, m_ControlHandle, start, end); + } + + void CControlSettingsSlider::SetIntValue(int value) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetIntValue(g_interProcess.m_Handle, m_ControlHandle, value); + } + + int CControlSettingsSlider::GetIntValue() const + { + return g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.GetIntValue(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSettingsSlider::SetIntInterval(int interval) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetIntInterval(g_interProcess.m_Handle, m_ControlHandle, interval); + } + + void CControlSettingsSlider::SetPercentage(float percent) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetPercentage(g_interProcess.m_Handle, m_ControlHandle, percent); + } + + float CControlSettingsSlider::GetPercentage() const + { + return g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.GetPercentage(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSettingsSlider::SetFloatRange(float start, float end) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetFloatRange(g_interProcess.m_Handle, m_ControlHandle, start, end); + } + + void CControlSettingsSlider::SetFloatValue(float value) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetFloatValue(g_interProcess.m_Handle, m_ControlHandle, value); + } + + float CControlSettingsSlider::GetFloatValue() const + { + return g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.GetFloatValue(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSettingsSlider::SetFloatInterval(float interval) + { + g_interProcess.m_Callbacks->GUI.Control.SettingsSlider.SetFloatInterval(g_interProcess.m_Handle, m_ControlHandle, interval); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSlider.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSlider.cpp new file mode 100644 index 0000000000..1a2c6de56d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSlider.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlSlider.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlSlider::CControlSlider(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_Slider(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlSlider can't create control class from Kodi !!!\n"); + } + + CControlSlider::~CControlSlider() + { + } + + void CControlSlider::SetVisible(bool yesNo) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetVisible(g_interProcess.m_Handle, m_ControlHandle, yesNo); + } + + void CControlSlider::SetEnabled(bool yesNo) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetEnabled(g_interProcess.m_Handle, m_ControlHandle, yesNo); + } + + std::string CControlSlider::GetDescription() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.Slider.GetDescription(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlSlider::SetIntRange(int start, int end) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetIntRange(g_interProcess.m_Handle, m_ControlHandle, start, end); + } + + void CControlSlider::SetIntValue(int value) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetIntValue(g_interProcess.m_Handle, m_ControlHandle, value); + } + + int CControlSlider::GetIntValue() const + { + return g_interProcess.m_Callbacks->GUI.Control.Slider.GetIntValue(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSlider::SetIntInterval(int interval) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetIntInterval(g_interProcess.m_Handle, m_ControlHandle, interval); + } + + void CControlSlider::SetPercentage(float percent) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetPercentage(g_interProcess.m_Handle, m_ControlHandle, percent); + } + + float CControlSlider::GetPercentage() const + { + return g_interProcess.m_Callbacks->GUI.Control.Slider.GetPercentage(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSlider::SetFloatRange(float start, float end) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetFloatRange(g_interProcess.m_Handle, m_ControlHandle, start, end); + } + + void CControlSlider::SetFloatValue(float value) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetFloatValue(g_interProcess.m_Handle, m_ControlHandle, value); + } + + float CControlSlider::GetFloatValue() const + { + return g_interProcess.m_Callbacks->GUI.Control.Slider.GetFloatValue(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSlider::SetFloatInterval(float interval) + { + g_interProcess.m_Callbacks->GUI.Control.Slider.SetFloatInterval(g_interProcess.m_Handle, m_ControlHandle, interval); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSpin.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSpin.cpp new file mode 100644 index 0000000000..1fa708d7d2 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlSpin.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlSpin.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlSpin::CControlSpin(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_Spin(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlSpin can't create control class from Kodi !!!\n"); + } + + CControlSpin::~CControlSpin() + { + } + + void CControlSpin::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlSpin::SetEnabled(bool enabled) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetEnabled(g_interProcess.m_Handle, m_ControlHandle, enabled); + } + + void CControlSpin::SetText(const std::string& label) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetText(g_interProcess.m_Handle, m_ControlHandle, label.c_str()); + } + + void CControlSpin::Reset() + { + g_interProcess.m_Callbacks->GUI.Control.Spin.Reset(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSpin::SetType(AddonGUISpinControlType type) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetType(g_interProcess.m_Handle, m_ControlHandle, (int)type); + } + + void CControlSpin::AddLabel(const std::string& label, const std::string& value) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.AddStringLabel(g_interProcess.m_Handle, m_ControlHandle, label.c_str(), value.c_str()); + } + + void CControlSpin::AddLabel(const std::string& label, int value) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.AddIntLabel(g_interProcess.m_Handle, m_ControlHandle, label.c_str(), value); + } + + void CControlSpin::SetStringValue(const std::string& value) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetStringValue(g_interProcess.m_Handle, m_ControlHandle, value.c_str()); + } + + std::string CControlSpin::GetStringValue() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.Spin.GetStringValue(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlSpin::SetIntRange(int start, int end) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetIntRange(g_interProcess.m_Handle, m_ControlHandle, start, end); + } + + void CControlSpin::SetIntValue(int value) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetIntValue(g_interProcess.m_Handle, m_ControlHandle, value); + } + + int CControlSpin::GetIntValue() const + { + return g_interProcess.m_Callbacks->GUI.Control.Spin.GetIntValue(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSpin::SetFloatRange(float start, float end) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetFloatRange(g_interProcess.m_Handle, m_ControlHandle, start, end); + } + + void CControlSpin::SetFloatValue(float value) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetFloatValue(g_interProcess.m_Handle, m_ControlHandle, value); + } + + float CControlSpin::GetFloatValue() const + { + return g_interProcess.m_Callbacks->GUI.Control.Spin.GetFloatValue(g_interProcess.m_Handle, m_ControlHandle); + } + + void CControlSpin::SetFloatInterval(float interval) + { + g_interProcess.m_Callbacks->GUI.Control.Spin.SetFloatInterval(g_interProcess.m_Handle, m_ControlHandle, interval); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlTextBox.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlTextBox.cpp new file mode 100644 index 0000000000..178445ac62 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ControlTextBox.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ControlTextBox.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CControlTextBox::CControlTextBox(CWindow* window, int controlId) + : m_Window(window), + m_ControlId(controlId) + { + m_ControlHandle = g_interProcess.m_Callbacks->GUI.Window.GetControl_TextBox(g_interProcess.m_Handle, m_Window->m_WindowHandle, controlId); + if (!m_ControlHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CControlTextBox can't create control class from Kodi !!!\n"); + } + + CControlTextBox::~CControlTextBox() + { + } + + void CControlTextBox::SetVisible(bool visible) + { + g_interProcess.m_Callbacks->GUI.Control.TextBox.SetVisible(g_interProcess.m_Handle, m_ControlHandle, visible); + } + + void CControlTextBox::Reset() + { + g_interProcess.m_Callbacks->GUI.Control.TextBox.Reset(m_ControlHandle, m_ControlHandle); + } + + void CControlTextBox::SetText(const std::string& text) + { + g_interProcess.m_Callbacks->GUI.Control.TextBox.SetText(g_interProcess.m_Handle, m_ControlHandle, text.c_str()); + } + + std::string CControlTextBox::GetText() const + { + std::string text; + text.resize(16384); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Control.TextBox.GetText(g_interProcess.m_Handle, m_ControlHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CControlTextBox::Scroll(unsigned int position) + { + g_interProcess.m_Callbacks->GUI.Control.TextBox.Scroll(g_interProcess.m_Handle, m_ControlHandle, position); + } + + void CControlTextBox::SetAutoScrolling(int delay, int time, int repeat) + { + g_interProcess.m_Callbacks->GUI.Control.TextBox.SetAutoScrolling(g_interProcess.m_Handle, m_ControlHandle, delay, time, repeat); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogContextMenu.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogContextMenu.cpp new file mode 100644 index 0000000000..39183f8054 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogContextMenu.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogContextMenu.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogContextMenu +{ + + int Show( + const std::string& heading, + const std::vector<std::string>& entries) + { + unsigned int size = entries.size(); + const char** cEntries = (const char**)malloc(size*sizeof(const char**)); + for (unsigned int i = 0; i < size; ++i) + { + cEntries[i] = entries[i].c_str(); + } + int ret = g_interProcess.m_Callbacks->GUI.Dialogs.ContextMenu.Open(heading.c_str(), cEntries, size); + free(cEntries); + return ret; + } + +} /* namespace DialogContextMenu */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogExtendedProgress.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogExtendedProgress.cpp new file mode 100644 index 0000000000..ebc5c6ac5a --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogExtendedProgress.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogExtendedProgress.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CDialogExtendedProgress::CDialogExtendedProgress(const std::string& title) + { + m_DialogHandle = g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.New(g_interProcess.m_Handle, title.c_str()); + if (!m_DialogHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CDialogExtendedProgress can't create window class from Kodi !!!\n"); + } + + CDialogExtendedProgress::~CDialogExtendedProgress() + { + if (m_DialogHandle) + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.Delete(g_interProcess.m_Handle, m_DialogHandle); + } + + std::string CDialogExtendedProgress::Title() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.Title(g_interProcess.m_Handle, m_DialogHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CDialogExtendedProgress::SetTitle(const std::string& title) + { + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.SetTitle(g_interProcess.m_Handle, m_DialogHandle, title.c_str()); + } + + std::string CDialogExtendedProgress::Text() const + { + std::string text; + text.resize(1024); + unsigned int size = (unsigned int)text.capacity(); + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.Text(g_interProcess.m_Handle, m_DialogHandle, text[0], size); + text.resize(size); + text.shrink_to_fit(); + return text; + } + + void CDialogExtendedProgress::SetText(const std::string& text) + { + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.SetText(g_interProcess.m_Handle, m_DialogHandle, text.c_str()); + } + + bool CDialogExtendedProgress::IsFinished() const + { + return g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.IsFinished(g_interProcess.m_Handle, m_DialogHandle); + } + + void CDialogExtendedProgress::MarkFinished() + { + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.MarkFinished(g_interProcess.m_Handle, m_DialogHandle); + } + + float CDialogExtendedProgress::Percentage() const + { + return g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.Percentage(g_interProcess.m_Handle, m_DialogHandle); + } + + void CDialogExtendedProgress::SetPercentage(float fPercentage) + { + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.SetPercentage(g_interProcess.m_Handle, m_DialogHandle, fPercentage); + } + + void CDialogExtendedProgress::SetProgress(int currentItem, int itemCount) + { + g_interProcess.m_Callbacks->GUI.Dialogs.ExtendedProgress.SetProgress(g_interProcess.m_Handle, m_DialogHandle, currentItem, itemCount); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogFileBrowser.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogFileBrowser.cpp new file mode 100644 index 0000000000..96ccd8d69c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogFileBrowser.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogFileBrowser.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogFileBrowser +{ + + bool ShowAndGetDirectory( + const std::string& shares, + const std::string& heading, + std::string& path, + bool bWriteOnly) + { + path.resize(1024); + unsigned int size = (unsigned int)path.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ShowAndGetDirectory(shares.c_str(), heading.c_str(), path[0], size, bWriteOnly); + path.resize(size); + path.shrink_to_fit(); + return ret; + } + + bool ShowAndGetFile( + const std::string& shares, + const std::string& mask, + const std::string& heading, + std::string& file, + bool useThumbs, + bool useFileDirectories) + { + file.resize(1024); + unsigned int size = (unsigned int)file.capacity();; + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ShowAndGetFile(shares.c_str(), mask.c_str(), heading.c_str(), file[0], size, useThumbs, useFileDirectories); + file.resize(size); + file.shrink_to_fit(); + return ret; + } + + bool ShowAndGetFileFromDir( + const std::string& directory, + const std::string& mask, + const std::string& heading, + std::string& path, + bool useThumbs, + bool useFileDirectories, + bool singleList) + { + path.resize(1024); + unsigned int size = (unsigned int)path.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ShowAndGetFileFromDir(directory.c_str(), mask.c_str(), heading.c_str(), path[0], size, useThumbs, useFileDirectories, singleList); + path.resize(size); + path.shrink_to_fit(); + return ret; + } + + bool ShowAndGetFileList( + const std::string& shares, + const std::string& mask, + const std::string& heading, + std::vector<std::string> &path, + bool useThumbs, + bool useFileDirectories) + { + char** list; + unsigned int listSize = 0; + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ShowAndGetFileList(shares.c_str(), mask.c_str(), heading.c_str(), list, listSize, useThumbs, useFileDirectories); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + path.push_back(list[i]); + g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ClearList(list, listSize); + } + return ret; + } + + bool ShowAndGetSource( + std::string& path, + bool allowNetworkShares, + const std::string& additionalShare, + const std::string& strType) + { + path.resize(1024); + unsigned int size = (unsigned int)path.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ShowAndGetSource(path[0], size, allowNetworkShares, additionalShare.c_str(), strType.c_str()); + path.resize(size); + path.shrink_to_fit(); + return ret; + } + + bool ShowAndGetImage( + const std::string& shares, + const std::string& heading, + std::string& path) + { + path.resize(1024); + unsigned int size = (unsigned int)path.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ShowAndGetImage(shares.c_str(), heading.c_str(), path[0], size); + path.resize(size); + path.shrink_to_fit(); + return ret; + } + + bool ShowAndGetImageList( + const std::string& shares, + const std::string& heading, + std::vector<std::string> &path) + { + char** list; + unsigned int listSize = 0; + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ShowAndGetImageList(shares.c_str(), heading.c_str(), list, listSize); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + path.push_back(list[i]); + g_interProcess.m_Callbacks->GUI.Dialogs.FileBrowser.ClearList(list, listSize); + } + return ret; + } + +} /* namespace DialogFileBrowser */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogKeyboard.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogKeyboard.cpp new file mode 100644 index 0000000000..88fbdc9c1a --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogKeyboard.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogKeyboard.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogKeyboard +{ + + bool ShowAndGetInput( + std::string& strText, + const std::string& strHeading, + bool allowEmptyResult, + bool hiddenInput, + unsigned int autoCloseMs) + { + strText.resize(1024); + unsigned int size = (unsigned int)strText.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetInputWithHead(strText[0], size, strHeading.c_str(), allowEmptyResult, hiddenInput, autoCloseMs); + strText.resize(size); + strText.shrink_to_fit(); + return ret; + } + + bool ShowAndGetInput( + std::string& strText, + bool allowEmptyResult, + unsigned int autoCloseMs) + { + strText.resize(1024); + unsigned int size = (unsigned int)strText.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetInput(strText[0], size, allowEmptyResult, autoCloseMs); + strText.resize(size); + strText.shrink_to_fit(); + return ret; + } + + bool ShowAndGetNewPassword( + std::string& strNewPassword, + const std::string& strHeading, + bool allowEmptyResult, + unsigned int autoCloseMs) + { + strNewPassword.resize(1024); + unsigned int size = (unsigned int)strNewPassword.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetNewPasswordWithHead(strNewPassword[0], size, strHeading.c_str(), allowEmptyResult, autoCloseMs); + strNewPassword.resize(size); + strNewPassword.shrink_to_fit(); + return ret; + } + + bool ShowAndGetNewPassword( + std::string& strNewPassword, + unsigned int autoCloseMs) + { + strNewPassword.resize(1024); + unsigned int size = (unsigned int)strNewPassword.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetNewPassword(strNewPassword[0], size, autoCloseMs); + strNewPassword.resize(size); + strNewPassword.shrink_to_fit(); + return ret; + } + + bool ShowAndVerifyNewPassword( + std::string& strNewPassword, + const std::string& strHeading, + bool allowEmptyResult, + unsigned int autoCloseMs) + { + strNewPassword.resize(1024); + unsigned int size = (unsigned int)strNewPassword.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetNewPasswordWithHead(strNewPassword[0], size, strHeading.c_str(), allowEmptyResult, autoCloseMs); + strNewPassword.resize(size); + strNewPassword.shrink_to_fit(); + return ret; + } + + bool ShowAndVerifyNewPassword( + std::string& strNewPassword, + unsigned int autoCloseMs) + { + strNewPassword.resize(1024); + unsigned int size = (unsigned int)strNewPassword.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndVerifyNewPassword(strNewPassword[0], size, autoCloseMs); + strNewPassword.resize(size); + strNewPassword.shrink_to_fit(); + return ret; + } + + int ShowAndVerifyPassword( + std::string& strPassword, + const std::string& strHeading, + int iRetries, + unsigned int autoCloseMs) + { + strPassword.resize(1024); + unsigned int size = (unsigned int)strPassword.capacity(); + int ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndVerifyPassword(strPassword[0], size, strHeading.c_str(), iRetries, autoCloseMs); + strPassword.resize(size); + strPassword.shrink_to_fit(); + return ret; + } + + bool ShowAndGetFilter( + std::string& strText, + bool searching, + unsigned int autoCloseMs) + { + strText.resize(1024); + unsigned int size = (unsigned int)strText.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetFilter(strText[0], size, searching, autoCloseMs); + strText.resize(size); + strText.shrink_to_fit(); + return ret; + } + + bool SendTextToActiveKeyboard( + const std::string& aTextString, + bool closeKeyboard) + { + return g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.SendTextToActiveKeyboard(aTextString.c_str(), closeKeyboard); + } + + bool IsKeyboardActivated() + { + return g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.isKeyboardActivated(); + } + +} /* namespace DialogKeyboard */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogNumeric.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogNumeric.cpp new file mode 100644 index 0000000000..1b2e3e4b81 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogNumeric.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogNumeric.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogNumeric +{ + + bool ShowAndVerifyNewPassword( + std::string& strNewPassword) + { + strNewPassword.reserve(1024); + unsigned int size = (unsigned int)strNewPassword.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndVerifyNewPassword(strNewPassword[0], size); + strNewPassword.resize(size); + strNewPassword.shrink_to_fit(); + return ret; + } + + int ShowAndVerifyPassword( + std::string& strPassword, + const std::string& strHeading, + int iRetries) + { + strPassword.resize(1024); + unsigned int size = (unsigned int)strPassword.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndVerifyPassword(strPassword[0], size, strHeading.c_str(), iRetries); + strPassword.resize(size); + strPassword.shrink_to_fit(); + return ret; + } + + bool ShowAndVerifyInput( + std::string& strToVerify, + const std::string& strHeading, + bool bVerifyInput) + { + strToVerify.resize(1024); + unsigned int size = (unsigned int)strToVerify.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndVerifyInput(strToVerify[0], size, strHeading.c_str(), bVerifyInput); + strToVerify.resize(size); + strToVerify.shrink_to_fit(); + return ret; + } + + bool ShowAndGetTime( + tm& time, + const std::string& strHeading) + { + return g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndGetTime(time, strHeading.c_str()); + } + + bool ShowAndGetDate( + tm& date, + const std::string& strHeading) + { + return g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndGetDate(date, strHeading.c_str()); + } + + bool ShowAndGetIPAddress( + std::string& strIPAddress, + const std::string& strHeading) + { + strIPAddress.resize(1024); + unsigned int size = (unsigned int)strIPAddress.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndGetIPAddress(strIPAddress[0], size, strHeading.c_str()); + strIPAddress.resize(size); + strIPAddress.shrink_to_fit(); + return ret; + } + + bool ShowAndGetNumber( + std::string& strInput, + const std::string& strHeading, + unsigned int iAutoCloseTimeoutMs) + { + strInput.resize(1024); + unsigned int size = (unsigned int)strInput.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndGetNumber(strInput[0], size, strHeading.c_str(), iAutoCloseTimeoutMs); + strInput.resize(size); + strInput.shrink_to_fit(); + return ret; + } + + bool ShowAndGetSeconds( + std::string& strTime, + const std::string& strHeading) + { + strTime.resize(1024); + unsigned int size = (unsigned int)strTime.capacity(); + bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Numeric.ShowAndGetSeconds(strTime[0], size, strHeading.c_str()); + strTime.resize(size); + strTime.shrink_to_fit(); + return ret; + } + +} /* namespace DialogNumeric */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogOK.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogOK.cpp new file mode 100644 index 0000000000..5ffe10bd8f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogOK.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogOK.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogOK +{ + + void ShowAndGetInput( + const std::string& heading, + const std::string& text) + { + g_interProcess.m_Callbacks->GUI.Dialogs.OK.ShowAndGetInputSingleText(heading.c_str(), text.c_str()); + } + + void ShowAndGetInput( + const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2) + { + g_interProcess.m_Callbacks->GUI.Dialogs.OK.ShowAndGetInputLineText(heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str()); + } + +} /* namespace DialogOK */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogProgress.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogProgress.cpp new file mode 100644 index 0000000000..222021411f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogProgress.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogProgress.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CDialogProgress::CDialogProgress() + { + m_DialogHandle = g_interProcess.m_Callbacks->GUI.Dialogs.Progress.New(g_interProcess.m_Handle); + if (!m_DialogHandle) + fprintf(stderr, "libKODI_guilib-ERROR: CDialogProgress can't create window class from Kodi !!!\n"); + } + + CDialogProgress::~CDialogProgress() + { + if (m_DialogHandle) + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.Delete(g_interProcess.m_Handle, m_DialogHandle); + } + + void CDialogProgress::Open() + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.Open(g_interProcess.m_Handle, m_DialogHandle); + } + + void CDialogProgress::SetHeading(const std::string& title) + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.SetHeading(g_interProcess.m_Handle, m_DialogHandle, title.c_str()); + } + + void CDialogProgress::SetLine(unsigned int iLine, const std::string& line) + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.SetLine(g_interProcess.m_Handle, m_DialogHandle, iLine, line.c_str()); + } + + void CDialogProgress::SetCanCancel(bool bCanCancel) + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.SetCanCancel(g_interProcess.m_Handle, m_DialogHandle, bCanCancel); + } + + bool CDialogProgress::IsCanceled() const + { + return g_interProcess.m_Callbacks->GUI.Dialogs.Progress.IsCanceled(g_interProcess.m_Handle, m_DialogHandle); + } + + void CDialogProgress::SetPercentage(int iPercentage) + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.SetPercentage(g_interProcess.m_Handle, m_DialogHandle, iPercentage); + } + + int CDialogProgress::GetPercentage() const + { + return g_interProcess.m_Callbacks->GUI.Dialogs.Progress.GetPercentage(g_interProcess.m_Handle, m_DialogHandle); + } + + void CDialogProgress::ShowProgressBar(bool bOnOff) + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.ShowProgressBar(g_interProcess.m_Handle, m_DialogHandle, bOnOff); + } + + void CDialogProgress::SetProgressMax(int iMax) + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.SetProgressMax(g_interProcess.m_Handle, m_DialogHandle, iMax); + } + + void CDialogProgress::SetProgressAdvance(int nSteps) + { + g_interProcess.m_Callbacks->GUI.Dialogs.Progress.SetProgressAdvance(g_interProcess.m_Handle, m_DialogHandle, nSteps); + } + + bool CDialogProgress::Abort() + { + return g_interProcess.m_Callbacks->GUI.Dialogs.Progress.Abort(g_interProcess.m_Handle, m_DialogHandle); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogSelect.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogSelect.cpp new file mode 100644 index 0000000000..dac3f4172b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogSelect.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogSelect.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogSelect +{ + + int Show( + const std::string& heading, + const std::vector<std::string>& entries, + int selected, + bool autoclose) + { + unsigned int size = entries.size(); + const char** cEntries = (const char**)malloc(size*sizeof(const char**)); + for (unsigned int i = 0; i < size; ++i) + { + cEntries[i] = entries[i].c_str(); + } + int ret = g_interProcess.m_Callbacks->GUI.Dialogs.Select.Open(heading.c_str(), cEntries, size, selected, autoclose); + free(cEntries); + return ret; + } + +} /* namespace DialogSelect */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogTextViewer.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogTextViewer.cpp new file mode 100644 index 0000000000..05a5b237ee --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogTextViewer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogTextViewer.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogTextViewer +{ + + void Show( + const std::string& heading, + const std::string& text) + { + g_interProcess.m_Callbacks->GUI.Dialogs.TextViewer.Open(heading.c_str(), text.c_str()); + } + +} /* namespace DialogTextViewer */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogYesNo.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogYesNo.cpp new file mode 100644 index 0000000000..d464d9b7dc --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_DialogYesNo.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/DialogYesNo.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace DialogYesNo +{ + + bool ShowAndGetInput( + const std::string& heading, + const std::string& text, + bool& bCanceled, + const std::string& noLabel, + const std::string& yesLabel) + { + return g_interProcess.m_Callbacks->GUI.Dialogs.YesNo.ShowAndGetInputSingleText(heading.c_str(), text.c_str(), bCanceled, noLabel.c_str(), yesLabel.c_str()); + } + + bool ShowAndGetInput( + const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2, + const std::string& noLabel, + const std::string& yesLabel) + { + return g_interProcess.m_Callbacks->GUI.Dialogs.YesNo.ShowAndGetInputLineText(heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), noLabel.c_str(), yesLabel.c_str()); + } + + bool ShowAndGetInput( + const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2, + bool& bCanceled, + const std::string& noLabel, + const std::string& yesLabel) + { + return g_interProcess.m_Callbacks->GUI.Dialogs.YesNo.ShowAndGetInputLineButtonText(heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), bCanceled, noLabel.c_str(), yesLabel.c_str()); + } + +} /* namespace DialogYesNo */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_General.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_General.cpp new file mode 100644 index 0000000000..fa662ad717 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_General.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/General.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ +namespace General +{ + +void Lock() +{ + g_interProcess.m_Callbacks->GUI.General.Lock(); +} + +void Unlock() +{ + g_interProcess.m_Callbacks->GUI.General.Unlock(); +} + +int GetScreenHeight() +{ + return g_interProcess.m_Callbacks->GUI.General.GetScreenHeight(); +} + +int GetScreenWidth() +{ + return g_interProcess.m_Callbacks->GUI.General.GetScreenWidth(); +} + +int GetVideoResolution() +{ + return g_interProcess.m_Callbacks->GUI.General.GetVideoResolution(); +} + +int GetCurrentWindowDialogId() +{ + return g_interProcess.m_Callbacks->GUI.General.GetCurrentWindowDialogId(); +} + +int GetCurrentWindowId() +{ + return g_interProcess.m_Callbacks->GUI.General.GetCurrentWindowId(); +} + +} /* namespace General */ +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ListItem.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ListItem.cpp new file mode 100644 index 0000000000..bb80e44487 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_ListItem.cpp @@ -0,0 +1,462 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ListItem.hpp) + +#include <cstring> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CListItem::CListItem( + const std::string& label, + const std::string& label2, + const std::string& iconImage, + const std::string& thumbnailImage, + const std::string& path) + { + m_ListItemHandle = g_interProcess.m_Callbacks->GUI.ListItem.Create(g_interProcess.m_Handle, label.c_str(), + label2.c_str(), iconImage.c_str(), + thumbnailImage.c_str(), path.c_str()); + } + + CListItem::CListItem(GUIHANDLE listItemHandle) + { + m_ListItemHandle = listItemHandle; + } + + CListItem::~CListItem() + { + g_interProcess.m_Callbacks->GUI.ListItem.Destroy(g_interProcess.m_Handle, m_ListItemHandle); + } + + std::string CListItem::GetLabel() + { + std::string label; + label.resize(1024); + unsigned int size = (unsigned int)label.capacity(); + g_interProcess.m_Callbacks->GUI.ListItem.GetLabel(g_interProcess.m_Handle, m_ListItemHandle, label[0], size); + label.resize(size); + label.shrink_to_fit(); + return label.c_str(); + } + + void CListItem::SetLabel(const std::string &label) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetLabel(g_interProcess.m_Handle, m_ListItemHandle, label.c_str()); + } + + std::string CListItem::GetLabel2() + { + std::string label; + label.resize(1024); + unsigned int size = (unsigned int)label.capacity(); + g_interProcess.m_Callbacks->GUI.ListItem.GetLabel2(g_interProcess.m_Handle, m_ListItemHandle, label[0], size); + label.resize(size); + label.shrink_to_fit(); + return label.c_str(); + } + + void CListItem::SetLabel2(const std::string &label) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetLabel2(g_interProcess.m_Handle, m_ListItemHandle, label.c_str()); + } + + std::string CListItem::GetIconImage() + { + std::string image; + image.resize(1024); + unsigned int size = (unsigned int)image.capacity(); + g_interProcess.m_Callbacks->GUI.ListItem.GetIconImage(g_interProcess.m_Handle, m_ListItemHandle, image[0], size); + image.resize(size); + image.shrink_to_fit(); + return image.c_str(); + } + + void CListItem::SetIconImage(const std::string &image) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetIconImage(g_interProcess.m_Handle, m_ListItemHandle, image.c_str()); + } + + std::string CListItem::GetOverlayImage() + { + std::string image; + image.resize(1024); + unsigned int size = (unsigned int)image.capacity(); + g_interProcess.m_Callbacks->GUI.ListItem.GetOverlayImage(g_interProcess.m_Handle, m_ListItemHandle, image[0], size); + image.resize(size); + image.shrink_to_fit(); + return image.c_str(); + } + + void CListItem::SetOverlayImage(unsigned int image, bool bOnOff /*= false */) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetOverlayImage(g_interProcess.m_Handle, m_ListItemHandle, image, bOnOff); + } + + void CListItem::SetThumbnailImage(const std::string &image) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetThumbnailImage(g_interProcess.m_Handle, m_ListItemHandle, image.c_str()); + } + + void CListItem::SetArt(const std::string &type, const std::string &url) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetArt(g_interProcess.m_Handle, m_ListItemHandle, type.c_str(), url.c_str()); + } + + std::string CListItem::GetArt(const std::string &type) + { + std::string strReturn; + char* strMsg = g_interProcess.m_Callbacks->GUI.ListItem.GetArt(g_interProcess.m_Handle, m_ListItemHandle, type.c_str()); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + void CListItem::SetArtFallback(const std::string &from, const std::string &to) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetArtFallback(g_interProcess.m_Handle, m_ListItemHandle, from.c_str(), to.c_str()); + } + + bool CListItem::HasArt(const std::string &type) + { + return g_interProcess.m_Callbacks->GUI.ListItem.HasArt(g_interProcess.m_Handle, m_ListItemHandle, type.c_str()); + } + + void CListItem::Select(bool bOnOff) + { + g_interProcess.m_Callbacks->GUI.ListItem.Select(g_interProcess.m_Handle, m_ListItemHandle, bOnOff); + } + + bool CListItem::IsSelected() + { + return g_interProcess.m_Callbacks->GUI.ListItem.IsSelected(g_interProcess.m_Handle, m_ListItemHandle); + } + + bool CListItem::HasIcon() + { + return g_interProcess.m_Callbacks->GUI.ListItem.HasIcon(g_interProcess.m_Handle, m_ListItemHandle); + } + + bool CListItem::HasOverlay() + { + return g_interProcess.m_Callbacks->GUI.ListItem.HasOverlay(g_interProcess.m_Handle, m_ListItemHandle); + } + + bool CListItem::IsFileItem() + { + return g_interProcess.m_Callbacks->GUI.ListItem.IsFileItem(g_interProcess.m_Handle, m_ListItemHandle); + } + + bool CListItem::IsFolder() + { + return g_interProcess.m_Callbacks->GUI.ListItem.IsFolder(g_interProcess.m_Handle, m_ListItemHandle); + } + + void CListItem::SetProperty(const std::string &key, const std::string &value) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetProperty(g_interProcess.m_Handle, m_ListItemHandle, key.c_str(), value.c_str()); + } + + std::string CListItem::GetProperty(const std::string &key) + { + std::string property; + property.resize(1024); + unsigned int size = (unsigned int)property.capacity(); + g_interProcess.m_Callbacks->GUI.ListItem.GetProperty(g_interProcess.m_Handle, m_ListItemHandle, key.c_str(), property[0], size); + property.resize(size); + property.shrink_to_fit(); + return property; + } + + void CListItem::ClearProperty(const std::string &key) + { + g_interProcess.m_Callbacks->GUI.ListItem.ClearProperty(g_interProcess.m_Handle, m_ListItemHandle, key.c_str()); + } + + void CListItem::ClearProperties() + { + g_interProcess.m_Callbacks->GUI.ListItem.ClearProperties(g_interProcess.m_Handle, m_ListItemHandle); + } + + bool CListItem::HasProperties() + { + return g_interProcess.m_Callbacks->GUI.ListItem.HasProperties(g_interProcess.m_Handle, m_ListItemHandle); + } + + bool CListItem::HasProperty(const std::string &key) + { + return g_interProcess.m_Callbacks->GUI.ListItem.HasProperty(g_interProcess.m_Handle, m_ListItemHandle, key.c_str()); + } + + void CListItem::SetPath(const std::string &path) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetPath(g_interProcess.m_Handle, m_ListItemHandle, path.c_str()); + } + + std::string CListItem::GetPath() + { + std::string strReturn; + char* strMsg = g_interProcess.m_Callbacks->GUI.ListItem.GetPath(g_interProcess.m_Handle, m_ListItemHandle); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + int CListItem::GetDuration() const + { + return g_interProcess.m_Callbacks->GUI.ListItem.GetDuration(g_interProcess.m_Handle, m_ListItemHandle); + } + + void CListItem::SetSubtitles(const std::vector<std::string>& subtitleFiles) + { + unsigned int size = subtitleFiles.size(); + if (size == 0) + return; + + const char** subtitles = (const char**)malloc(size); + for (unsigned int i = 0; i < size; ++i) + subtitles[i] = subtitleFiles[i].c_str(); + + g_interProcess.m_Callbacks->GUI.ListItem.SetSubtitles(g_interProcess.m_Handle, m_ListItemHandle, subtitles, size); + free(subtitles); + } + + void CListItem::SetMimeType(const std::string& mimetype) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetMimeType(g_interProcess.m_Handle, m_ListItemHandle, mimetype.c_str()); + } + + void CListItem::SetContentLookup(bool enable) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetContentLookup(g_interProcess.m_Handle, m_ListItemHandle, enable); + } + + void CListItem::AddContextMenuItems(const std::vector<std::pair<std::string, std::string> >& items, bool replaceItems) + { + const char*** entries = nullptr; + unsigned int size = items.size(); + if (size != 0) + { + entries = (const char***)malloc(size*sizeof(const char***)); + for (unsigned int i = 0; i < size; ++i) + { + entries[i][0] = items.at(i).first.c_str(); + entries[i][1] = items.at(i).second.c_str(); + } + } + + g_interProcess.m_Callbacks->GUI.ListItem.AddContextMenuItems(g_interProcess.m_Handle, m_ListItemHandle, entries, size, replaceItems); + if (entries) + free(entries); + } + + void CListItem::AddStreamInfo(const std::string& cType, const std::vector<std::pair<std::string, std::string> >& dictionary) + { + const char*** entries = nullptr; + unsigned int size = dictionary.size(); + if (size == 0) + return; + + entries = (const char***)malloc(size*sizeof(const char***)); + for (unsigned int i = 0; i < size; ++i) + { + entries[i][0] = dictionary.at(i).first.c_str(); + entries[i][1] = dictionary.at(i).second.c_str(); + } + + g_interProcess.m_Callbacks->GUI.ListItem.AddStreamInfo(g_interProcess.m_Handle, m_ListItemHandle, cType.c_str(), entries, size); + free(entries); + } + + void CListItem::SetMusicInfo_BOOL(ADDON_MusicInfoTag type, bool value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetMusicInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(bool)); + } + + void CListItem::SetMusicInfo_INT(ADDON_MusicInfoTag type, int value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetMusicInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(int)); + } + + void CListItem::SetMusicInfo_UINT(ADDON_MusicInfoTag type, unsigned int value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetMusicInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(unsigned int)); + } + + void CListItem::SetMusicInfo_FLOAT(ADDON_MusicInfoTag type, float value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetMusicInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(float)); + } + + void CListItem::SetMusicInfo_STRING(ADDON_MusicInfoTag type, std::string value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetMusicInfo(g_interProcess.m_Handle, m_ListItemHandle, type, (void*)value.c_str(), sizeof(const char*)); + } + + void CListItem::SetMusicInfo_STRING_LIST(ADDON_MusicInfoTag type, std::vector<std::string> values) + { + unsigned int size = values.size(); + if (type == 0 || size == 0) + return; + + const char** entries = (const char**)malloc(size*sizeof(const char**)); + for (unsigned int i = 0; i < size; ++i) + entries[i] = values[i].c_str(); + + g_interProcess.m_Callbacks->GUI.ListItem.SetMusicInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &entries, size); + free(entries); + } + + void CListItem::SetVideoInfo_BOOL(ADDON_VideoInfoTag type, bool value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(bool)); + } + + void CListItem::SetVideoInfo_INT(ADDON_VideoInfoTag type, int value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(int)); + } + + void CListItem::SetVideoInfo_UINT(ADDON_VideoInfoTag type, unsigned int value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(unsigned int)); + } + + void CListItem::SetVideoInfo_FLOAT(ADDON_VideoInfoTag type, float value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(float)); + } + + void CListItem::SetVideoInfo_STRING(ADDON_VideoInfoTag type, std::string value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, type, (void*)value.c_str(), sizeof(const char*)); + } + + void CListItem::SetVideoInfo_STRING_LIST(ADDON_VideoInfoTag type, std::vector<std::string> values) + { + unsigned int size = values.size(); + if (type == 0 || size == 0) + return; + + const char** entries = (const char**)malloc(size*sizeof(const char**)); + for (unsigned int i = 0; i < size; ++i) + entries[i] = values[i].c_str(); + + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, type, (void*)entries, size); + free(entries); + } + + void CListItem::SetVideoInfo_Resume(ADDON_VideoInfoTag_Resume &resume) + { + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, ADDON_VideoInfoTag_resume_DATA, &resume, sizeof(ADDON_VideoInfoTag_resume_DATA)); + } + + void CListItem::SetVideoInfo_Cast(std::vector<ADDON_VideoInfoTag_Cast> &cast) + { + unsigned int size = cast.size(); + if (size == 0) + return; + + ADDON_VideoInfoTag_cast_DATA_STRUCT** entries = (ADDON_VideoInfoTag_cast_DATA_STRUCT**)malloc(size*sizeof(ADDON_VideoInfoTag_cast_DATA_STRUCT**)); + for (unsigned int i = 0; i < size; ++i) + { + entries[i] = (ADDON_VideoInfoTag_cast_DATA_STRUCT*)malloc(sizeof(ADDON_VideoInfoTag_cast_DATA_STRUCT*)); + entries[i]->name = cast[i].name.c_str(); + entries[i]->role = cast[i].role.c_str(); + entries[i]->order = cast[i].order; + entries[i]->thumbnail = cast[i].thumbnail.c_str(); + } + + g_interProcess.m_Callbacks->GUI.ListItem.SetVideoInfo(g_interProcess.m_Handle, m_ListItemHandle, ADDON_VideoInfoTag_cast_DATA_LIST, (void*)entries, size); + free(entries); + } + + void CListItem::SetPictureInfo_BOOL(ADDON_PictureInfoTag type, bool value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetPictureInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(bool)); + } + + void CListItem::SetPictureInfo_INT(ADDON_PictureInfoTag type, int value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetPictureInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(int)); + } + + void CListItem::SetPictureInfo_UINT(ADDON_PictureInfoTag type, unsigned int value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetPictureInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(unsigned int)); + } + + void CListItem::SetPictureInfo_FLOAT(ADDON_PictureInfoTag type, float value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetPictureInfo(g_interProcess.m_Handle, m_ListItemHandle, type, &value, sizeof(float)); + } + + void CListItem::SetPictureInfo_STRING(ADDON_PictureInfoTag type, std::string value) + { + if (type != 0) + g_interProcess.m_Callbacks->GUI.ListItem.SetPictureInfo(g_interProcess.m_Handle, m_ListItemHandle, type, (void*)value.c_str(), sizeof(const char*)); + } + + void CListItem::SetPictureInfo_STRING_LIST(ADDON_PictureInfoTag type, std::vector<std::string> values) + { + unsigned int size = values.size(); + if (type == 0 || size == 0) + return; + + const char** entries = (const char**)malloc(size*sizeof(const char**)); + for (unsigned int i = 0; i < size; ++i) + entries[i] = values[i].c_str(); + + g_interProcess.m_Callbacks->GUI.ListItem.SetPictureInfo(g_interProcess.m_Handle, m_ListItemHandle, type, (void*)entries, size); + free(entries); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_Window.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_Window.cpp new file mode 100644 index 0000000000..19ba0198a4 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/gui/AddonLib_GUI_Window.cpp @@ -0,0 +1,249 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/Window.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, gui/ListItem.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ +namespace GUI +{ + + CWindow::CWindow( + const std::string& xmlFilename, + const std::string& defaultSkin, + bool forceFallback, + bool asDialog) + { + m_WindowHandle = g_interProcess.m_Callbacks->GUI.Window.New(g_interProcess.m_Handle, xmlFilename.c_str(), + defaultSkin.c_str(), forceFallback, asDialog); + if (!m_WindowHandle) + fprintf(stderr, "libKODI_gui-ERROR: cGUIWindow can't create window class from Kodi !!!\n"); + + g_interProcess.m_Callbacks->GUI.Window.SetCallbacks(g_interProcess.m_Handle, m_WindowHandle, this, + OnInitCB, OnClickCB, OnFocusCB, OnActionCB); + } + + CWindow::~CWindow() + { + if (m_WindowHandle) + g_interProcess.m_Callbacks->GUI.Window.Delete(g_interProcess.m_Handle, m_WindowHandle); + } + + bool CWindow::Show() + { + return g_interProcess.m_Callbacks->GUI.Window.Show(g_interProcess.m_Handle, m_WindowHandle); + } + + void CWindow::Close() + { + g_interProcess.m_Callbacks->GUI.Window.Close(g_interProcess.m_Handle, m_WindowHandle); + } + + void CWindow::DoModal() + { + g_interProcess.m_Callbacks->GUI.Window.DoModal(g_interProcess.m_Handle, m_WindowHandle); + } + + bool CWindow::SetFocusId(int iControlId) + { + return g_interProcess.m_Callbacks->GUI.Window.SetFocusId(g_interProcess.m_Handle, m_WindowHandle, iControlId); + } + + int CWindow::GetFocusId() + { + return g_interProcess.m_Callbacks->GUI.Window.GetFocusId(g_interProcess.m_Handle, m_WindowHandle); + } + + void CWindow::SetProperty(const std::string& key, const std::string& value) + { + g_interProcess.m_Callbacks->GUI.Window.SetProperty(g_interProcess.m_Handle, m_WindowHandle, key.c_str(), value.c_str()); + } + + void CWindow::SetPropertyInt(const std::string& key, int value) + { + g_interProcess.m_Callbacks->GUI.Window.SetPropertyInt(g_interProcess.m_Handle, m_WindowHandle, key.c_str(), value); + } + + void CWindow::SetPropertyBool(const std::string& key, bool value) + { + g_interProcess.m_Callbacks->GUI.Window.SetPropertyBool(g_interProcess.m_Handle, m_WindowHandle, key.c_str(), value); + } + + void CWindow::SetPropertyDouble(const std::string& key, double value) + { + g_interProcess.m_Callbacks->GUI.Window.SetPropertyDouble(g_interProcess.m_Handle, m_WindowHandle, key.c_str(), value); + } + + std::string CWindow::GetProperty(const std::string& key) const + { + std::string label; + label.resize(1024); + unsigned int size = (unsigned int)label.capacity(); + g_interProcess.m_Callbacks->GUI.Window.GetProperty(g_interProcess.m_Handle, m_WindowHandle, key.c_str(), label[0], size); + label.resize(size); + label.shrink_to_fit(); + return label.c_str(); + } + + int CWindow::GetPropertyInt(const std::string& key) const + { + return g_interProcess.m_Callbacks->GUI.Window.GetPropertyInt(g_interProcess.m_Handle, m_WindowHandle, key.c_str()); + } + + bool CWindow::GetPropertyBool(const std::string& key) const + { + return g_interProcess.m_Callbacks->GUI.Window.GetPropertyBool(g_interProcess.m_Handle, m_WindowHandle, key.c_str()); + } + + double CWindow::GetPropertyDouble(const std::string& key) const + { + return g_interProcess.m_Callbacks->GUI.Window.GetPropertyDouble(g_interProcess.m_Handle, m_WindowHandle, key.c_str()); + } + + void CWindow::ClearProperties() + { + g_interProcess.m_Callbacks->GUI.Window.ClearProperties(g_interProcess.m_Handle, m_WindowHandle); + } + + void CWindow::ClearProperty(const std::string& key) + { + g_interProcess.m_Callbacks->GUI.Window.ClearProperty(g_interProcess.m_Handle, m_WindowHandle, key.c_str()); + } + + int CWindow::GetListSize() + { + return g_interProcess.m_Callbacks->GUI.Window.GetListSize(g_interProcess.m_Handle, m_WindowHandle); + } + + void CWindow::ClearList() + { + g_interProcess.m_Callbacks->GUI.Window.ClearList(g_interProcess.m_Handle, m_WindowHandle); + } + + CListItem* CWindow::AddStringItem(const std::string& name, int itemPosition) + { + GUIHANDLE handle = g_interProcess.m_Callbacks->GUI.Window.AddStringItem(g_interProcess.m_Handle, m_WindowHandle, name.c_str(), itemPosition); + if (handle) + return new CListItem(handle); + + fprintf(stderr, "libKODI_gui-ERROR: cGUIWindow Failed to get control on list ṕosition %i !!!\n", itemPosition); + return nullptr; + } + + void CWindow::AddItem(CListItem *item, int itemPosition) + { + g_interProcess.m_Callbacks->GUI.Window.AddItem(g_interProcess.m_Handle, m_WindowHandle, item->m_ListItemHandle, itemPosition); + } + + void CWindow::RemoveItem(int itemPosition) + { + g_interProcess.m_Callbacks->GUI.Window.RemoveItem(g_interProcess.m_Handle, m_WindowHandle, itemPosition); + } + + void CWindow::RemoveItem(CListItem* item) + { + g_interProcess.m_Callbacks->GUI.Window.RemoveItemFile(g_interProcess.m_Handle, m_WindowHandle, item->m_ListItemHandle); + } + + CListItem* CWindow::GetListItem(int listPos) + { + GUIHANDLE handle = g_interProcess.m_Callbacks->GUI.Window.GetListItem(g_interProcess.m_Handle, m_WindowHandle, listPos); + if (handle) + return new CListItem(handle); + + fprintf(stderr, "libKODI_gui-ERROR: cGUIWindow Failed to get control on list ṕosition %i !!!\n", listPos); + return nullptr; + } + + void CWindow::SetCurrentListPosition(int listPos) + { + g_interProcess.m_Callbacks->GUI.Window.SetCurrentListPosition(g_interProcess.m_Handle, m_WindowHandle, listPos); + } + + int CWindow::GetCurrentListPosition() + { + return g_interProcess.m_Callbacks->GUI.Window.GetCurrentListPosition(g_interProcess.m_Handle, m_WindowHandle); + } + + void CWindow::SetControlLabel(int controlId, const std::string& label) + { + g_interProcess.m_Callbacks->GUI.Window.SetControlLabel(g_interProcess.m_Handle, m_WindowHandle, controlId, label.c_str()); + } + + void CWindow::MarkDirtyRegion() + { + g_interProcess.m_Callbacks->GUI.Window.MarkDirtyRegion(g_interProcess.m_Handle, m_WindowHandle); + } + + /*! + * Kodi to add-on override definition function to use if class becomes used + * independet. + */ + void CWindow::SetIndependentCallbacks( + GUIHANDLE cbhdl, + bool (*CBOnInit) (GUIHANDLE cbhdl), + bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), + bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), + bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId)) + { + if (!cbhdl || + !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction) + { + fprintf(stderr, "libKODI_gui-ERROR: SetIndependentCallbacks called with nullptr !!!\n"); + return; + } + + g_interProcess.m_Callbacks->GUI.Window.SetCallbacks(g_interProcess.m_Handle, m_WindowHandle, cbhdl, + CBOnInit, CBOnFocus, CBOnClick, CBOnAction); + } + + /*! + * Defined callback functions from Kodi to add-on, for use in parent / child system + * (is private)! + */ + + bool CWindow::OnInitCB(GUIHANDLE cbhdl) + { + return static_cast<CWindow*>(cbhdl)->OnInit(); + } + + bool CWindow::OnClickCB(GUIHANDLE cbhdl, int controlId) + { + return static_cast<CWindow*>(cbhdl)->OnClick(controlId); + } + + bool CWindow::OnFocusCB(GUIHANDLE cbhdl, int controlId) + { + return static_cast<CWindow*>(cbhdl)->OnFocus(controlId); + } + + bool CWindow::OnActionCB(GUIHANDLE cbhdl, int actionId) + { + return static_cast<CWindow*>(cbhdl)->OnAction(actionId); + } + +} /* namespace GUI */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/inputstream/AddonLib_InputStream.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/inputstream/AddonLib_InputStream.cpp new file mode 100644 index 0000000000..fb2e3d4c4d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/inputstream/AddonLib_InputStream.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, inputstream/InputStream.hpp) + +#include <string> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace InputStream +{ + + kodi_codec GetCodecByName(const std::string &strCodecName) + { + kodi_codec codec; + g_interProcess.m_Callbacks->InputStream.get_codec_by_name(g_interProcess.m_Handle, strCodecName.c_str(), &codec); + return codec; + } + + DemuxPacket* AllocateDemuxPacket(int iDataSize) + { + return g_interProcess.m_Callbacks->InputStream.allocate_demux_packet(g_interProcess.m_Handle, iDataSize); + } + + void FreeDemuxPacket(DemuxPacket* pPacket) + { + g_interProcess.m_Callbacks->InputStream.free_demux_packet(g_interProcess.m_Handle, pPacket); + } + +} /* namespace InputStream */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/kodi-addon-sharedlibrary-api2-config.cmake.in b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/kodi-addon-sharedlibrary-api2-config.cmake.in new file mode 100644 index 0000000000..b8e756ba1b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/kodi-addon-sharedlibrary-api2-config.cmake.in @@ -0,0 +1,35 @@ +# - kodi-addon-sharedlibrary config mode +# +# Defines the following variables: +# kodi-addon-sharedlibrary_FOUND - true +# kodi-addon-sharedlibrary_API_LEVEL - detected api level +# kodi-addon-sharedlibrary_VERSION - version of the dev kit library found, e.g. 2.0.0 +# kodi-addon-sharedlibrary_INCLUDE_DIRS - header directories with which to compile +# kodi-addon-sharedlibrary_LINKER_FLAGS - flags that must be passed to the linker +# kodi-addon-sharedlibrary_LIBRARIES - names of the libraries with which to link +# kodi-addon-sharedlibrary_LIBRARY_DIRS - directories in which the libraries are situated +# +# propagate these properties from one build system to the other +set (kodi-addon-sharedlibrary_API_LEVEL "2") +set (kodi-addon-sharedlibrary_VERSION "2.0.0") +set (kodi-addon-sharedlibrary_INCLUDE_DIRS @prefix@/include) +set (kodi-addon-sharedlibrary_LIBRARY_DIRS "") +set (kodi-addon-sharedlibrary_LINKER_FLAGS "") +set (kodi-addon-sharedlibrary_CONFIG_VARS "") +set (exec_prefix @exec_prefix@) + +# libraries come from the build tree where this file was generated +if(WIN32) + set (kodi-addon-sharedlibrary_LIBRARY "@libdir@/kodi.addon.sharedlibrary.api2.lib") +else(WIN32) + set (kodi-addon-sharedlibrary_LIBRARY "-L@libdir@ -lkodi.addon.sharedlibrary.api2") +endif(WIN32) +set (kodi-addon-sharedlibrary_LIBRARIES ${kodi-addon-sharedlibrary_LIBRARY}) +mark_as_advanced (kodi-addon-sharedlibrary_LIBRARY) + +# add the library as a target, so that other things in the project including +# this file may depend on it and get rebuild if this library changes. +add_library (kodi-addon-sharedlibrary UNKNOWN IMPORTED) +set_property (TARGET kodi-addon-sharedlibrary PROPERTY IMPORTED_LOCATION "${kodi-addon-sharedlibrary_LIBRARY}") +add_definitions(-DAPI_LEVELS_ACTIVE) +add_definitions(-DUSE_KODI_API_LEVEL=${kodi-addon-sharedlibrary_API_LEVEL}) diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/kodi-addon-sharedlibrary-api2.pc.in b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/kodi-addon-sharedlibrary-api2.pc.in new file mode 100644 index 0000000000..6170cc0a9b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/kodi-addon-sharedlibrary-api2.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +libdir=@libdir@ +includedir=@includedir@ +CXX=@CXX@ +CC=@CC@ +DEPENDENCIES= + +Name: kodi-addon-sharedlibrary-api2 +Description: Kodi add-on API 2 development kit for shared libraries +Version: 2.0.0 +Libs: -L${libdir} -lkodi.addon.sharedlibrary.api2 +Cflags: -I${includedir} @CXXFLAGS@ diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/peripheral/AddonLib_Peripheral.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/peripheral/AddonLib_Peripheral.cpp new file mode 100644 index 0000000000..815f976e7c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/peripheral/AddonLib_Peripheral.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, peripheral/Peripheral.hpp) + +#include <string> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace Peripheral +{ + + void TriggerScan(void) + { + g_interProcess.m_Callbacks->Peripheral.trigger_scan(g_interProcess.m_Handle); + } + + void RefreshButtonMaps(const std::string& deviceName, const std::string& controllerId) + { + g_interProcess.m_Callbacks->Peripheral.refresh_button_maps(g_interProcess.m_Handle, deviceName.c_str(), controllerId.c_str()); + } + +} /* namespace Peripheral */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_InfoTagMusic.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_InfoTagMusic.cpp new file mode 100644 index 0000000000..c1e74a40db --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_InfoTagMusic.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, player/InfoTagMusic.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, player/Player.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ + +namespace Player +{ + + CInfoTagMusic::CInfoTagMusic(CPlayer* player) + { + if (!player || !player->m_ControlHandle) + { + return; + } + + AddonInfoTagMusic infoTag; + if (g_interProcess.m_Callbacks->AddonInfoTagMusic.GetFromPlayer(g_interProcess.m_Handle, player, &infoTag)) + { + TransferInfoTag(infoTag); + g_interProcess.m_Callbacks->AddonInfoTagMusic.Release(g_interProcess.m_Handle, &infoTag); + } + } + + CInfoTagMusic::~CInfoTagMusic() + { + } + + const std::string& CInfoTagMusic::GetURL() const + { + return m_url; + } + + const std::string& CInfoTagMusic::GetTitle() const + { + return m_title; + } + + const std::string& CInfoTagMusic::GetArtist() const + { + return m_artist; + } + + const std::string& CInfoTagMusic::GetAlbum() const + { + return m_album; + } + + const std::string& CInfoTagMusic::GetAlbumArtist() const + { + return m_albumArtist; + } + + const std::string& CInfoTagMusic::GetGenre() const + { + return m_genre; + } + + int CInfoTagMusic::GetDuration() const + { + return m_duration; + } + + int CInfoTagMusic::GetTrack() const + { + return m_tracks; + } + + int CInfoTagMusic::GetDisc() const + { + return m_disc; + } + + const std::string& CInfoTagMusic::GetReleaseDate() const + { + return m_releaseDate; + } + + int CInfoTagMusic::GetListeners() const + { + return m_listener; + } + + int CInfoTagMusic::GetPlayCount() const + { + return m_playCount; + } + + const std::string& CInfoTagMusic::GetLastPlayed() const + { + return m_lastPlayed; + } + + const std::string& CInfoTagMusic::GetComment() const + { + return m_comment; + } + + const std::string& CInfoTagMusic::GetLyrics() const + { + return m_lyrics; + } + + void CInfoTagMusic::TransferInfoTag(AddonInfoTagMusic& infoTag) + { + m_url = infoTag.m_url; + m_title = infoTag.m_title; + m_artist = infoTag.m_artist; + m_album = infoTag.m_album; + m_albumArtist = infoTag.m_albumArtist; + m_genre = infoTag.m_genre; + m_duration = infoTag.m_duration; + m_tracks = infoTag.m_tracks; + m_disc = infoTag.m_disc; + m_releaseDate = infoTag.m_releaseDate; + m_listener = infoTag.m_listener; + m_playCount = infoTag.m_playCount; + m_lastPlayed = infoTag.m_lastPlayed; + m_comment = infoTag.m_comment; + m_lyrics = infoTag.m_lyrics; + } + + +} /* namespace Player */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_InfoTagVideo.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_InfoTagVideo.cpp new file mode 100644 index 0000000000..3aa976d915 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_InfoTagVideo.cpp @@ -0,0 +1,204 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, player/InfoTagVideo.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, player/Player.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ + +namespace Player +{ + + CInfoTagVideo::CInfoTagVideo(CPlayer* player) + { + if (!player || !player->m_ControlHandle) + { + return; + } + + AddonInfoTagVideo infoTag; + if (g_interProcess.m_Callbacks->AddonInfoTagVideo.GetFromPlayer(g_interProcess.m_Handle, player, &infoTag)) + { + TransferInfoTag(infoTag); + g_interProcess.m_Callbacks->AddonInfoTagVideo.Release(g_interProcess.m_Handle, &infoTag); + } + } + + CInfoTagVideo::~CInfoTagVideo() + { + } + + const std::string& CInfoTagVideo::GetDirector() const + { + return m_director; + } + + const std::string& CInfoTagVideo::GetWritingCredits() const + { + return m_writingCredits; + } + + const std::string& CInfoTagVideo::GetGenre() const + { + return m_genre; + } + + const std::string& CInfoTagVideo::GetCountry() const + { + return m_country; + } + + const std::string& CInfoTagVideo::GetTagLine() const + { + return m_tagLine; + } + + const std::string& CInfoTagVideo::GetPlotOutline() const + { + return m_plotOutline; + } + + const std::string& CInfoTagVideo::GetPlot() const + { + return m_plot; + } + + const std::string& CInfoTagVideo::GetTrailer() const + { + return m_trailer; + } + + const std::string& CInfoTagVideo::GetPictureURL() const + { + return m_pictureURL; + } + + const std::string& CInfoTagVideo::GetTitle() const + { + return m_title; + } + + const std::string& CInfoTagVideo::GetVotes() const + { + return m_votes; + } + + const std::string& CInfoTagVideo::GetCast() const + { + return m_cast; + } + + const std::string& CInfoTagVideo::GetFile() const + { + return m_file; + } + + const std::string& CInfoTagVideo::GetPath() const + { + return m_path; + } + + const std::string& CInfoTagVideo::GetIMDBNumber() const + { + return m_IMDBNumber; + } + + const std::string& CInfoTagVideo::GetMPAARating() const + { + return m_MPAARating; + } + + int CInfoTagVideo::GetYear() const + { + return m_year; + } + + double CInfoTagVideo::GetRating() const + { + return m_rating; + } + + int CInfoTagVideo::GetPlayCount() const + { + return m_playCount; + } + + const std::string& CInfoTagVideo::GetLastPlayed() const + { + return m_lastPlayed; + } + + const std::string& CInfoTagVideo::GetOriginalTitle() const + { + return m_originalTitle; + } + + const std::string& CInfoTagVideo::GetPremiered() const + { + return m_premiered; + } + + const std::string& CInfoTagVideo::GetFirstAired() const + { + return m_firstAired; + } + + unsigned int CInfoTagVideo::GetDuration() const + { + return m_duration; + } + + void CInfoTagVideo::TransferInfoTag(AddonInfoTagVideo& infoTag) + { + m_director = infoTag.m_director; + m_writingCredits = infoTag.m_writingCredits; + m_genre = infoTag.m_genre; + m_country = infoTag.m_country; + m_tagLine = infoTag.m_tagLine; + m_plotOutline = infoTag.m_plotOutline; + m_plot = infoTag.m_plot; + m_trailer = infoTag.m_trailer; + m_pictureURL = infoTag.m_pictureURL; + m_title = infoTag.m_title; + m_votes = infoTag.m_votes; + m_cast = infoTag.m_cast; + m_file = infoTag.m_file; + m_path = infoTag.m_path; + m_IMDBNumber = infoTag.m_IMDBNumber; + m_MPAARating = infoTag.m_MPAARating; + m_year = infoTag.m_year; + m_rating = infoTag.m_rating; + m_playCount = infoTag.m_playCount; + m_lastPlayed = infoTag.m_lastPlayed; + m_originalTitle = infoTag.m_originalTitle; + m_premiered = infoTag.m_premiered; + m_firstAired = infoTag.m_firstAired; + m_duration = infoTag.m_duration; + } + + +} /* namespace Player */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_PlayList.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_PlayList.cpp new file mode 100644 index 0000000000..08b5501184 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_PlayList.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, gui/ListItem.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, player/PlayList.hpp) + +API_NAMESPACE + +namespace KodiAPI +{ + +namespace Player +{ + + CPlayList::CPlayList(AddonPlayListType playlist) + : m_ControlHandle(nullptr), + m_playlist(playlist) + { + m_ControlHandle = g_interProcess.m_Callbacks->AddonPlayList.New(g_interProcess.m_Handle, playlist); + if (!m_ControlHandle) + fprintf(stderr, "ERROR: CPlayList can't create control class from Kodi !!!\n"); + } + + CPlayList::~CPlayList() + { + g_interProcess.m_Callbacks->AddonPlayList.Delete(g_interProcess.m_Handle, m_ControlHandle); + } + + AddonPlayListType CPlayList::GetPlayListType() const + { + return m_playlist; + } + + bool CPlayList::LoadPlaylist(const std::string& filename) + { + return g_interProcess.m_Callbacks->AddonPlayList.LoadPlaylist(g_interProcess.m_Handle, m_ControlHandle, filename.c_str(), m_playlist); + } + + void CPlayList::AddItem(const std::string& url, int index) + { + g_interProcess.m_Callbacks->AddonPlayList.AddItemURL(g_interProcess.m_Handle, m_ControlHandle, url.c_str(), index); + } + + void CPlayList::AddItem(const API_NAMESPACE_NAME::KodiAPI::GUI::CListItem* listitem, int index) + { + g_interProcess.m_Callbacks->AddonPlayList.AddItemList(g_interProcess.m_Handle, m_ControlHandle, listitem->GetListItemHandle(), index); + } + + void CPlayList::RemoveItem(const std::string& url) + { + g_interProcess.m_Callbacks->AddonPlayList.RemoveItem(g_interProcess.m_Handle, m_ControlHandle, url.c_str()); + } + + void CPlayList::ClearList() + { + g_interProcess.m_Callbacks->AddonPlayList.ClearList(g_interProcess.m_Handle, m_ControlHandle); + } + + int CPlayList::GetListSize() + { + return g_interProcess.m_Callbacks->AddonPlayList.GetListSize(g_interProcess.m_Handle, m_ControlHandle); + } + + int CPlayList::GetListPosition() + { + return g_interProcess.m_Callbacks->AddonPlayList.GetListPosition(g_interProcess.m_Handle, m_ControlHandle); + } + + void CPlayList::Shuffle(bool shuffle) + { + g_interProcess.m_Callbacks->AddonPlayList.Shuffle(g_interProcess.m_Handle, m_ControlHandle, shuffle); + } + + GUI::CListItem* CPlayList::operator [](long i) + { + return static_cast<GUI::CListItem*>(g_interProcess.m_Callbacks->AddonPlayList.GetItem(g_interProcess.m_Handle, m_ControlHandle, i)); + } + +} /* namespace Player */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_Player.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_Player.cpp new file mode 100644 index 0000000000..bcaa6f4783 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/player/AddonLib_Player_Player.cpp @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, player/Player.hpp) + +#include <cstring> + +using namespace API_NAMESPACE_NAME::KodiAPI::GUI; + +API_NAMESPACE + +namespace KodiAPI +{ + +namespace Player +{ + CPlayer::CPlayer() + { + m_ControlHandle = g_interProcess.m_Callbacks->AddonPlayer.New(g_interProcess.m_Handle); + if (!m_ControlHandle) + fprintf(stderr, "ERROR: CPlayer can't create control class from Kodi !!!\n"); + } + + CPlayer::~CPlayer() + { + g_interProcess.m_Callbacks->AddonPlayer.Delete(g_interProcess.m_Handle, m_ControlHandle); + } + + std::string CPlayer::GetSupportedMedia(AddonPlayListType mediaType) + { + std::string strReturn; + char* strMsg = g_interProcess.m_Callbacks->AddonPlayer.GetSupportedMedia(g_interProcess.m_Handle, mediaType); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + strReturn = strMsg; + g_interProcess.m_Callbacks->free_string(g_interProcess.m_Handle, strMsg); + } + return strReturn; + } + + bool CPlayer::Play(const std::string& item, bool windowed) + { + return g_interProcess.m_Callbacks->AddonPlayer.PlayFile(g_interProcess.m_Handle, m_ControlHandle, item.c_str(), windowed); + } + + bool CPlayer::Play(const CListItem *listitem, bool windowed) + { + return g_interProcess.m_Callbacks->AddonPlayer.PlayFileItem(g_interProcess.m_Handle, m_ControlHandle, listitem->GetListItemHandle(), windowed); + } + + bool CPlayer::Play(const CPlayList *list, bool windowed, int startpos) + { + return g_interProcess.m_Callbacks->AddonPlayer.PlayList(g_interProcess.m_Handle, m_ControlHandle, list->GetListHandle(), list->GetListType(), windowed, startpos); + } + + void CPlayer::Stop() + { + g_interProcess.m_Callbacks->AddonPlayer.Stop(g_interProcess.m_Handle, m_ControlHandle); + } + + void CPlayer::Pause() + { + g_interProcess.m_Callbacks->AddonPlayer.Pause(g_interProcess.m_Handle, m_ControlHandle); + } + + void CPlayer::PlayNext() + { + g_interProcess.m_Callbacks->AddonPlayer.PlayNext(g_interProcess.m_Handle, m_ControlHandle); + } + + void CPlayer::PlayPrevious() + { + g_interProcess.m_Callbacks->AddonPlayer.PlayPrevious(g_interProcess.m_Handle, m_ControlHandle); + } + + void CPlayer::PlaySelected(int selected) + { + g_interProcess.m_Callbacks->AddonPlayer.PlaySelected(g_interProcess.m_Handle, m_ControlHandle, selected); + } + + bool CPlayer::IsPlaying() + { + return g_interProcess.m_Callbacks->AddonPlayer.IsPlaying(g_interProcess.m_Handle, m_ControlHandle); + } + + bool CPlayer::IsPlayingAudio() + { + return g_interProcess.m_Callbacks->AddonPlayer.IsPlayingAudio(g_interProcess.m_Handle, m_ControlHandle); + } + + bool CPlayer::IsPlayingVideo() + { + return g_interProcess.m_Callbacks->AddonPlayer.IsPlayingVideo(g_interProcess.m_Handle, m_ControlHandle); + } + + bool CPlayer::IsPlayingRDS() + { + return g_interProcess.m_Callbacks->AddonPlayer.IsPlayingRDS(g_interProcess.m_Handle, m_ControlHandle); + } + + bool CPlayer::GetPlayingFile(std::string& file) + { + file.resize(1024); + unsigned int size = (unsigned int)file.capacity(); + bool ret = g_interProcess.m_Callbacks->AddonPlayer.GetPlayingFile(g_interProcess.m_Handle, m_ControlHandle, file[0], size); + file.resize(size); + file.shrink_to_fit(); + return ret; + } + + double CPlayer::GetTotalTime() + { + return g_interProcess.m_Callbacks->AddonPlayer.GetTotalTime(g_interProcess.m_Handle, m_ControlHandle); + } + + double CPlayer::GetTime() + { + return g_interProcess.m_Callbacks->AddonPlayer.GetTime(g_interProcess.m_Handle, m_ControlHandle); + } + + void CPlayer::SeekTime(double seekTime) + { + g_interProcess.m_Callbacks->AddonPlayer.SeekTime(g_interProcess.m_Handle, m_ControlHandle, seekTime); + } + + bool CPlayer::GetAvailableAudioStreams(std::vector<std::string> &streams) + { + char** list; + unsigned int listSize = 0; + bool ret = g_interProcess.m_Callbacks->AddonPlayer.GetAvailableAudioStreams(g_interProcess.m_Handle, m_ControlHandle, list, listSize); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + streams.push_back(list[i]); + g_interProcess.m_Callbacks->AddonPlayer.ClearList(list, listSize); + } + return ret; + } + + void CPlayer::SetAudioStream(int iStream) + { + g_interProcess.m_Callbacks->AddonPlayer.SetAudioStream(g_interProcess.m_Handle, m_ControlHandle, iStream); + } + + bool CPlayer::GetAvailableSubtitleStreams(std::vector<std::string> &streams) + { + char** list; + unsigned int listSize = 0; + bool ret = g_interProcess.m_Callbacks->AddonPlayer.GetAvailableSubtitleStreams(g_interProcess.m_Handle, m_ControlHandle, list, listSize); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + streams.push_back(list[i]); + g_interProcess.m_Callbacks->AddonPlayer.ClearList(list, listSize); + } + return ret; + } + + void CPlayer::SetSubtitleStream(int iStream) + { + g_interProcess.m_Callbacks->AddonPlayer.SetSubtitleStream(g_interProcess.m_Handle, m_ControlHandle, iStream); + } + + void CPlayer::ShowSubtitles(bool bVisible) + { + g_interProcess.m_Callbacks->AddonPlayer.ShowSubtitles(g_interProcess.m_Handle, m_ControlHandle, bVisible); + } + + bool CPlayer::GetCurrentSubtitleName(std::string& name) + { + name.resize(1024); + unsigned int size = (unsigned int)name.capacity(); + bool ret = g_interProcess.m_Callbacks->AddonPlayer.GetCurrentSubtitleName(g_interProcess.m_Handle, m_ControlHandle, name[0], size); + name.resize(size); + name.shrink_to_fit(); + return ret; + } + + void CPlayer::AddSubtitle(const std::string& subPath) + { + g_interProcess.m_Callbacks->AddonPlayer.AddSubtitle(g_interProcess.m_Handle, m_ControlHandle, subPath.c_str()); + } + +} /* namespace Player */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_General.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_General.cpp new file mode 100644 index 0000000000..484a3f797d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_General.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, pvr/General.hpp) + +#include <string> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace PVR +{ +namespace General +{ + + void AddMenuHook(PVR_MENUHOOK* hook) + { + g_interProcess.m_Callbacks->PVR.add_menu_hook(g_interProcess.m_Handle, hook); + } + + void Recording(const std::string& strRecordingName, const std::string& strFileName, bool bOn) + { + g_interProcess.m_Callbacks->PVR.recording(g_interProcess.m_Handle, strRecordingName.c_str(), strFileName.c_str(), bOn); + } + + void ConnectionStateChange(const std::string& strConnectionString, PVR_CONNECTION_STATE newState, const std::string& strMessage) + { + g_interProcess.m_Callbacks->PVR.connection_state_change(g_interProcess.m_Handle, strConnectionString.c_str(), newState, strMessage.c_str()); + } + + void EpgEventStateChange(EPG_TAG *tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState) + { + g_interProcess.m_Callbacks->PVR.epg_event_state_change(g_interProcess.m_Handle, tag, iUniqueChannelId, newState); + } + +} /* namespace General */ +} /* namespace PVR */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Stream.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Stream.cpp new file mode 100644 index 0000000000..f76349dade --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Stream.cpp @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#define API_LEVELS_ACTIVE 1 +#include <time.h> +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, AddonLib.hpp) +#include KITINCLUDE(ADDON_API_LEVEL, pvr/StreamUtils.hpp) + +#include <string> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace PVR +{ + + CPVRStream::CPVRStream() + { + Clear(); + } + + CPVRStream::CPVRStream(const CPVRStream &other) + { + memcpy(this, &other, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + } + + CPVRStream& CPVRStream::operator=(const CPVRStream &other) + { + memcpy(this, &other, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + return *this; + } + + bool CPVRStream::operator==(const CPVRStream &other) const + { + return iPID == other.iPID && iCodecId == other.iCodecId; + } + + bool CPVRStream::operator<(const CPVRStream &other) const + { + if (iCodecType == API_NAMESPACE_NAME::KodiAPI::KODI_CODEC_TYPE_VIDEO) + return true; + else if (other.iCodecType != API_NAMESPACE_NAME::KodiAPI::KODI_CODEC_TYPE_VIDEO) + return iPID < other.iPID; + else + return false; + } + + bool CPVRStream::IsCleared() const + { + return iCodecId == KODI_INVALID_CODEC_ID && + iCodecType == API_NAMESPACE_NAME::KodiAPI::KODI_CODEC_TYPE_UNKNOWN; + } + + void CPVRStream::Clear() + { + memset(this, 0, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + iCodecId = KODI_INVALID_CODEC_ID; + iCodecType = API_NAMESPACE_NAME::KodiAPI::KODI_CODEC_TYPE_UNKNOWN; + } + + /*\___________________________________________________________________________ + \*/ + + CStreamProperties::CStreamProperties(void) + { + // make sure the vector won't have to resize itself later + m_streamVector = new stream_vector(); + m_streamVector->reserve(PVR_STREAM_MAX_STREAMS); + } + + CStreamProperties::~CStreamProperties(void) + { + delete m_streamVector; + } + + void CStreamProperties::Clear(void) + { + m_streamVector->clear(); + m_streamIndex.clear(); + } + + int CStreamProperties::GetStreamId(unsigned int iPID) const + { + std::map<unsigned int, int>::const_iterator it = m_streamIndex.find(iPID); + if (it != m_streamIndex.end()) + return it->second; + + return -1; + } + + CPVRStream* CStreamProperties::GetStreamById(unsigned int iPID) const + { + int position = GetStreamId(iPID); + return position != -1 ? &m_streamVector->at(position) : NULL; + } + + void CStreamProperties::GetStreamData(unsigned int iPID, CPVRStream* stream) + { + CPVRStream *foundStream = GetStreamById(iPID); + if (foundStream) + *stream = *foundStream; + else + { + stream->iSubtitleInfo = -1; + stream->iPID = iPID; + } + } + + bool CStreamProperties::GetProperties(PVR_STREAM_PROPERTIES* props) + { + unsigned int i = 0; + for (stream_vector::const_iterator it = m_streamVector->begin(); + it != m_streamVector->end(); ++it, ++i) + { + memcpy(&props->stream[i], &(*it), sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + } + + props->iStreamCount = m_streamVector->size(); + return (props->iStreamCount > 0); + } + + void CStreamProperties::UpdateStreams(stream_vector &newStreams) + { + // sort the new streams + std::sort(newStreams.begin(), newStreams.end()); + + // ensure we never have more than PVR_STREAMS_MAX_STREAMS streams + if (newStreams.size() > PVR_STREAM_MAX_STREAMS) + { + while (newStreams.size() > PVR_STREAM_MAX_STREAMS) + newStreams.pop_back(); + + KodiAPI::Log(ADDON_LOG_ERROR, "%s - max amount of streams reached", __FUNCTION__); + } + + stream_vector::iterator newStreamPosition; + for (stream_vector::iterator it = m_streamVector->begin(); it != m_streamVector->end(); ++it) + { + newStreamPosition = std::find(newStreams.begin(), newStreams.end(), *it); + + // if the current stream no longer exists we clear it, otherwise we + // copy it and remove it from newStreams + if (newStreamPosition == newStreams.end()) + it->Clear(); + else + { + *it = *newStreamPosition; + newStreams.erase(newStreamPosition); + } + } + + // replace cleared streams with new streams + for (stream_vector::iterator it = m_streamVector->begin(); + it != m_streamVector->end() && !newStreams.empty(); ++it) + { + if (it->IsCleared()) + { + *it = newStreams.front(); + newStreams.erase(newStreams.begin()); + } + } + + // append any remaining new streams + m_streamVector->insert(m_streamVector->end(), newStreams.begin(), newStreams.end()); + + // remove trailing cleared streams + while (m_streamVector->back().IsCleared()) + m_streamVector->pop_back(); + + // update the index + UpdateIndex(); + } + + /** + * Updates the stream index + */ + void CStreamProperties::UpdateIndex() + { + m_streamIndex.clear(); + + int i = 0; + for (stream_vector::const_iterator it = m_streamVector->begin(); it != m_streamVector->end(); ++it, ++i) + m_streamIndex[it->iPID] = i; + } + + +} /* namespace PVR */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Transfer.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Transfer.cpp new file mode 100644 index 0000000000..b49e234dc6 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Transfer.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, pvr/Transfer.hpp) + +#include <string> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace PVR +{ +namespace Transfer +{ + + void EpgEntry(const ADDON_HANDLE handle, const EPG_TAG* entry) + { + g_interProcess.m_Callbacks->PVR.transfer_epg_entry(g_interProcess.m_Handle, handle, entry); + } + + void ChannelEntry(const ADDON_HANDLE handle, const PVR_CHANNEL* entry) + { + g_interProcess.m_Callbacks->PVR.transfer_channel_entry(g_interProcess.m_Handle, handle, entry); + } + + void TimerEntry(const ADDON_HANDLE handle, const PVR_TIMER* entry) + { + g_interProcess.m_Callbacks->PVR.transfer_timer_entry(g_interProcess.m_Handle, handle, entry); + } + + void RecordingEntry(const ADDON_HANDLE handle, const PVR_RECORDING* entry) + { + g_interProcess.m_Callbacks->PVR.transfer_recording_entry(g_interProcess.m_Handle, handle, entry); + } + + void ChannelGroup(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP* entry) + { + g_interProcess.m_Callbacks->PVR.transfer_channel_group(g_interProcess.m_Handle, handle, entry); + } + + void ChannelGroupMember(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER* entry) + { + g_interProcess.m_Callbacks->PVR.transfer_channel_group_member(g_interProcess.m_Handle, handle, entry); + } + +} /* namespace Transfer */ +} /* namespace PVR */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Trigger.cpp b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Trigger.cpp new file mode 100644 index 0000000000..bed5e4c6ef --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/kodi-addon-sharedlibrary/pvr/AddonLib_PVR_Trigger.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016 Team KODI + * http://kodi.tv + * + * 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, 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 KODI; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "InterProcess.h" +#include KITINCLUDE(ADDON_API_LEVEL, pvr/Trigger.hpp) + +#include <string> +#include <stdarg.h> + +API_NAMESPACE + +namespace KodiAPI +{ +namespace PVR +{ +namespace Trigger +{ + + void TimerUpdate(void) + { + g_interProcess.m_Callbacks->PVR.trigger_timer_update(g_interProcess.m_Handle); + } + + void RecordingUpdate(void) + { + g_interProcess.m_Callbacks->PVR.trigger_recording_update(g_interProcess.m_Handle); + } + + void ChannelUpdate(void) + { + g_interProcess.m_Callbacks->PVR.trigger_channel_update(g_interProcess.m_Handle); + } + + void EpgUpdate(unsigned int iChannelUid) + { + g_interProcess.m_Callbacks->PVR.trigger_epg_update(g_interProcess.m_Handle, iChannelUid); + } + + void ChannelGroupsUpdate(void) + { + g_interProcess.m_Callbacks->PVR.trigger_channel_groups_update(g_interProcess.m_Handle); + } + +} /* namespace Trigger */ +} /* namespace PVR */ +} /* namespace KodiAPI */ + +END_NAMESPACE() diff --git a/xbmc/addons/kodi-addon-dev-kit/src/api2/version.h b/xbmc/addons/kodi-addon-dev-kit/src/api2/version.h new file mode 100644 index 0000000000..67c30e5fef --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/src/api2/version.h @@ -0,0 +1,10 @@ +#pragma once + +/* + * Addon <-> Kodi interface system API level and version. Used on level + * parts and inside Kodi. + * + * Used this way to have easy compatible on all OS systems. + */ +#define ADDON_API_LEVEL 2 +#define ADDON_API_VERSION "2.0.0" diff --git a/xbmc/addons/kodi-addon-dev-kit/tools/rename-apilevel-number.py b/xbmc/addons/kodi-addon-dev-kit/tools/rename-apilevel-number.py new file mode 100755 index 0000000000..9c64154e50 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/tools/rename-apilevel-number.py @@ -0,0 +1,73 @@ +#!/usr/bin/python + +# +# Copyright (C) 2016 Team KODI +# http://kodi.tv +# +# 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, 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 KODI; see the file COPYING. If not, see +# <http://www.gnu.org/licenses/>. +# +# + +from optparse import OptionParser +import os, sys + +# cannot be loaded as a module +if __name__ != "__main__": + sys.stderr.write('This file cannot be loaded as a module!') + sys.exit() + +# parse command-line options +disc = """ +This utility rename the string 'api*' with new defined level number on all +files with path defined header source. + +Is to have on a API level change all doxygen related documentation comments +with right number. + +Example: +./rename-apilevel-number.py --source=../include/kodi/api3 --old_level=2 --new_level=3 +""" + +parser = OptionParser(description=disc) +parser.add_option('--source', dest='source', metavar='DIR', + help='the source folder where changes becomes done [required]') +parser.add_option('--old_level', dest='old_level', metavar='NUMBER', + help='old level number which becomes changes [required]') +parser.add_option('--new_level', dest='new_level', metavar='NUMBER', + help='new level number which becomes used [required]') +(options, args) = parser.parse_args() + +# the header option is required +if options.source is None or options.old_level is None or options.new_level is None: + parser.print_help(sys.stdout) + sys.exit() + +def replace_word(infile,old_word,new_word): + if not os.path.isfile(infile): + print ("Error on replace_word, not a regular file: " + infile) + sys.exit(1) + + f1=open(infile,'r').read() + f2=open(infile,'w') + m=f1.replace(old_word,new_word) + f2.write(m) + +print 'Renaming on all files in "' + options.source + '" the text from "api' + options.old_level + '" to "api' + options.new_level + '"' + +from os.path import join, getsize +for root, dirs, files in os.walk(options.source): + for file in files: + print root + '/' + file + replace_word(root + '/' + file, 'api' + options.old_level, 'api' + options.new_level) |