mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-18 20:40:43 +01:00
Make libarchive optional, disable loading scripts from archives if it's not present.
This commit is contained in:
parent
33ad8249b0
commit
472ab04e97
@ -58,7 +58,7 @@ pkg_check_modules(USBMUXD libusbmuxd)
|
||||
pkg_check_modules(LIBMTP libmtp>=1.0)
|
||||
pkg_check_modules(INDICATEQT indicate-qt)
|
||||
pkg_check_modules(QJSON QJson)
|
||||
pkg_check_modules(ARCHIVE REQUIRED libarchive)
|
||||
pkg_check_modules(ARCHIVE libarchive)
|
||||
|
||||
if (WIN32)
|
||||
find_package(ZLIB REQUIRED)
|
||||
@ -177,6 +177,10 @@ if(ENABLE_LIBTUNEPIMP AND TUNEPIMP_LIBRARIES AND TUNEPIMP_INCLUDE_DIRS)
|
||||
set(HAVE_LIBTUNEPIMP ON)
|
||||
endif(ENABLE_LIBTUNEPIMP AND TUNEPIMP_LIBRARIES AND TUNEPIMP_INCLUDE_DIRS)
|
||||
|
||||
if(ARCHIVE_FOUND)
|
||||
set(HAVE_LIBARCHIVE ON)
|
||||
endif(ARCHIVE_FOUND)
|
||||
|
||||
if(ENABLE_SCRIPTING_PYTHON AND PYTHONLIBS_FOUND AND PYQT_SIP_DIR)
|
||||
set(HAVE_SCRIPTING_PYTHON ON)
|
||||
endif(ENABLE_SCRIPTING_PYTHON AND PYTHONLIBS_FOUND AND PYQT_SIP_DIR)
|
||||
@ -301,6 +305,7 @@ summary_add("Gnome sound menu integration" HAVE_LIBINDICATE)
|
||||
summary_add("Wiimote support" ENABLE_WIIMOTEDEV)
|
||||
summary_add("Visualisations" ENABLE_VISUALISATIONS)
|
||||
summary_add("Last.fm support" HAVE_LIBLASTFM)
|
||||
summary_add("Scripting support: loading archives" HAVE_LIBARCHIVE)
|
||||
summary_add("Scripting support: Python" HAVE_SCRIPTING_PYTHON)
|
||||
summary_add("(Mac OS X) Sparkle integration" HAVE_SPARKLE)
|
||||
summary_add("MusicBrainz support" HAVE_LIBTUNEPIMP)
|
||||
|
@ -874,7 +874,6 @@ target_link_libraries(clementine_lib
|
||||
${QTSINGLECOREAPPLICATION_LIBRARIES}
|
||||
${QTIOCOMPRESSOR_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${ARCHIVE_LIBRARIES}
|
||||
dl
|
||||
z
|
||||
)
|
||||
@ -899,6 +898,10 @@ if(HAVE_GIO)
|
||||
target_link_libraries(clementine_lib ${GIO_LIBRARIES})
|
||||
endif(HAVE_GIO)
|
||||
|
||||
if(HAVE_LIBARCHIVE)
|
||||
target_link_libraries(clementine_lib ${ARCHIVE_LIBRARIES})
|
||||
endif(HAVE_LIBARCHIVE)
|
||||
|
||||
if(HAVE_IMOBILEDEVICE)
|
||||
target_link_libraries(clementine_lib
|
||||
${IMOBILEDEVICE_LIBRARIES}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#cmakedefine HAVE_DBUS
|
||||
#cmakedefine HAVE_GIO
|
||||
#cmakedefine HAVE_IMOBILEDEVICE
|
||||
#cmakedefine HAVE_LIBARCHIVE
|
||||
#cmakedefine HAVE_LIBGPOD
|
||||
#cmakedefine HAVE_LIBINDICATE
|
||||
#cmakedefine HAVE_LIBLASTFM
|
||||
|
@ -15,13 +15,17 @@
|
||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "scriptarchive.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
# include <archive.h>
|
||||
# include <archive_entry.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
namespace {
|
||||
// Read callbacks for libarchive
|
||||
struct IODeviceReadState {
|
||||
@ -43,6 +47,7 @@ namespace {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif // HAVE_LIBARCHIVE
|
||||
|
||||
bool ScriptArchive::Load(const QString& filename) {
|
||||
QFile file(filename);
|
||||
@ -54,6 +59,7 @@ bool ScriptArchive::Load(const QString& filename) {
|
||||
}
|
||||
|
||||
bool ScriptArchive::Load(QIODevice* device) {
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
archive* a = archive_read_new();
|
||||
archive_read_support_compression_gzip(a);
|
||||
archive_read_support_format_tar(a);
|
||||
@ -74,4 +80,7 @@ bool ScriptArchive::Load(QIODevice* device) {
|
||||
archive_read_finish(a);
|
||||
|
||||
return true;
|
||||
#else // HAVE_LIBARCHIVE
|
||||
return false;
|
||||
#endif // HAVE_LIBARCHIVE
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user