From c6324fa767ddce5991b60fbc083ed657d97f5890 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 14 Jul 2021 21:33:42 +0300 Subject: [PATCH] kamera: require Gphoto2 v2.5+ Signed-off-by: Ivailo Monev --- kamera/CMakeLists.txt | 21 +------ kamera/ConfigureChecks.cmake | 49 ---------------- kamera/config-kamera.h.cmake | 8 --- kamera/kcontrol/kameradevice.cpp | 10 +--- kamera/kioslave/kamera.cpp | 97 +------------------------------- 5 files changed, 4 insertions(+), 181 deletions(-) delete mode 100644 kamera/ConfigureChecks.cmake delete mode 100644 kamera/config-kamera.h.cmake diff --git a/kamera/CMakeLists.txt b/kamera/CMakeLists.txt index 5001b857..93c58062 100644 --- a/kamera/CMakeLists.txt +++ b/kamera/CMakeLists.txt @@ -9,32 +9,13 @@ include(KDE4Defaults) include(MacroLibrary) include(MacroOptionalAddSubdirectory) -find_package(Gphoto2) +find_package(Gphoto2 2.5) set_package_properties(Gphoto2 PROPERTIES URL "http://heanet.dl.sourceforge.net/sourceforge/gphoto" PURPOSE "Required to build kamera" TYPE REQUIRED ) -cmake_reset_check_state() -set(CMAKE_REQUIRED_INCLUDES "${GPHOTO2_INCLUDE_DIR}") -set(CMAKE_REQUIRED_LIBRARIES "${GPHOTO2_LIBRARIES}") -check_symbol_exists(gp_port_info_get_name "gphoto2/gphoto2.h" HAVE_GPHOTO2_5) -cmake_reset_check_state() - -if(HAVE_GPHOTO2_5) - message(STATUS "Detected libgphoto2 2.5.0 or newer") -else() - message(STATUS "Detected libgphoto2 2.4 or older") -endif() - -include(ConfigureChecks.cmake) - -configure_file( - config-kamera.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config-kamera.h -) - add_definitions( ${QT_DEFINITIONS} ${KDE4_DEFINITIONS} diff --git a/kamera/ConfigureChecks.cmake b/kamera/ConfigureChecks.cmake deleted file mode 100644 index 12873771..00000000 --- a/kamera/ConfigureChecks.cmake +++ /dev/null @@ -1,49 +0,0 @@ -include(CheckCXXSourceCompiles) - -set(VA_COPY_TEST_SOURCE -" -#include -#include -void f (int i, ...) { -va_list args1, args2; -va_start (args1, i); -va_copy (args2, args1); -if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) - exit (1); -va_end (args1); va_end (args2); -} -int main() { - f (0, 42); - return 0; -} -") - -set(__VA_COPY_TEST_SOURCE -" -#include -#include -void f (int i, ...) { -va_list args1, args2; -va_start (args1, i); -__va_copy (args2, args1); -if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) - exit (1); -va_end (args1); va_end (args2); -} -int main() { - f (0, 42); - return 0; -} -") - -check_cxx_source_compiles("${VA_COPY_TEST_SOURCE}" HAVE_VA_COPY) -if(HAVE_VA_COPY) - set(VA_COPY va_copy CACHE STRING "va_copy function") -else(HAVE_VA_COPY) - check_cxx_source_compiles("${__VA_COPY_TEST_SOURCE}" HAVE___VA_COPY) - if(HAVE___VA_COPY) - set(VA_COPY __va_copy CACHE STRING "__va_copy function") - else(HAVE___VA_COPY) - message(FATAL_ERROR "Either va_copy or __va_copy must be present. Please check your libc.") - endif(HAVE___VA_COPY) -endif(HAVE_VA_COPY) diff --git a/kamera/config-kamera.h.cmake b/kamera/config-kamera.h.cmake deleted file mode 100644 index 95a6a5da..00000000 --- a/kamera/config-kamera.h.cmake +++ /dev/null @@ -1,8 +0,0 @@ -/* Define if we have va_copy */ -#cmakedefine HAVE_VA_COPY 1 - -/* Define if we have __va_copy */ -#cmakedefine HAVE___VA_COPY 1 - -/* Define if we have gp_port_info_get_name (trigger for 2.5) */ -#cmakedefine HAVE_GPHOTO2_5 1 diff --git a/kamera/kcontrol/kameradevice.cpp b/kamera/kcontrol/kameradevice.cpp index a55eddc5..9648f338 100644 --- a/kamera/kcontrol/kameradevice.cpp +++ b/kamera/kcontrol/kameradevice.cpp @@ -35,8 +35,6 @@ #include #include -#include "config-kamera.h" - extern "C" { #include } @@ -386,17 +384,11 @@ KameraDeviceSelectDialog::KameraDeviceSelectDialog(QWidget *parent, KCamera *dev } for (int i = 0; i < gphoto_ports; i++) { if (gp_port_info_list_get_info(list, i, &info) >= 0) { -#ifdef HAVE_GPHOTO2_5 char *xpath; - gp_port_info_get_path (info, &xpath); + gp_port_info_get_path(info, &xpath); if (strncmp(xpath, "serial:", 7) == 0) { m_serialPortCombo->addItem(QString::fromLocal8Bit(xpath).mid(7)); } -#else - if (strncmp(info.path, "serial:", 7) == 0) { - m_serialPortCombo->addItem(QString::fromLocal8Bit(info.path).mid(7)); - } -#endif } } gp_port_info_list_free(list); diff --git a/kamera/kioslave/kamera.cpp b/kamera/kioslave/kamera.cpp index 3f343009..153959bd 100644 --- a/kamera/kioslave/kamera.cpp +++ b/kamera/kioslave/kamera.cpp @@ -46,8 +46,6 @@ #include #include -#include "config-kamera.h" - #include "kamera.h" #define tocstr(x) ((x).toLocal8Bit()) @@ -60,13 +58,8 @@ extern "C" { Q_DECL_EXPORT int kdemain(int argc, char **argv); -#ifdef HAVE_GPHOTO2_5 static void frontendCameraStatus(GPContext *context, const char *status, void *data); static unsigned int frontendProgressStart(GPContext *context, float totalsize, const char *status, void *data); -#else - static void frontendCameraStatus(GPContext *context, const char *format, va_list args, void *data); - static unsigned int frontendProgressStart(GPContext *context, float totalsize, const char *format, va_list args, void *data); -#endif static void frontendProgressUpdate(GPContext *context, unsigned int id, float current, void *data); } @@ -993,103 +986,17 @@ void frontendProgressUpdate(GPContext * /*context*/, unsigned int /*id*/, float } } -unsigned int frontendProgressStart(GPContext * /*context*/, float totalsize, -#ifdef HAVE_GPHOTO2_5 - const char *status, -#else - const char *format, va_list args, -#endif - void *data) +unsigned int frontendProgressStart(GPContext * /*context*/, float totalsize, const char *status, void *data) { KameraProtocol *object = (KameraProtocol*)data; -#ifndef HAVE_GPHOTO2_5 - char *status; - - /* We must copy the va_list to walk it twice, or all hell - * breaks loose on non-i386 platforms. - */ -#if defined(HAVE_VA_COPY) || defined(HAVE___VA_COPY) - va_list xvalist; -# ifdef HAVE_VA_COPY - va_copy(xvalist, args); -# elif HAVE___VA_COPY - __va_copy(xvalist, args); -# endif - int size=vsnprintf(NULL, 0, format, xvalist); - if (size<=0) { - return GP_OK; // vsnprintf is broken, better don't do anything. - } - - status=new char[size+1]; -# ifdef HAVE_VA_COPY - va_copy(xvalist, args); -# elif HAVE___VA_COPY - __va_copy(xvalist, args); -# endif - vsnprintf(status, size+1, format, xvalist); -#else - /* We cannot copy the va_list, so make sure we - * walk it just _once_. - */ - status=new char[300]; - vsnprintf(status, 300, format, args); -#endif - object->infoMessage(QString::fromLocal8Bit(status)); - delete [] status; -#else - /* libgphoto2 2.5 has resolved this already, no need for print */ - object->infoMessage(QString::fromLocal8Bit(status)); -#endif object->totalSize((KIO::filesize_t)totalsize); // hack: call slot directly return GP_OK; } // this callback function is activated on every status message from gphoto2 -static void frontendCameraStatus(GPContext * /*context*/, -#ifdef HAVE_GPHOTO2_5 - const char *status, -#else - const char *format, va_list args, -#endif - void *data) +static void frontendCameraStatus(GPContext * /*context*/, const char *status, void *data) { KameraProtocol *object = (KameraProtocol*)data; -#ifndef HAVE_GPHOTO2_5 - char *status; - - /* We must copy the va_list to walk it twice, or all hell - * breaks loose on non-i386 platforms. - */ -#if defined(HAVE_VA_COPY) || defined(HAVE___VA_COPY) - va_list xvalist; -# ifdef HAVE_VA_COPY - va_copy(xvalist, args); -# elif HAVE___VA_COPY - __va_copy(xvalist, args); -# endif - int size=vsnprintf(NULL, 0, format, xvalist); - if (size<=0) { - return; // vsnprintf is broken, better don't do anything. - } - - status=new char[size+1]; -# ifdef HAVE_VA_COPY - va_copy(xvalist, args); -# elif HAVE___VA_COPY - __va_copy(xvalist, args); -# endif - vsnprintf(status, size+1, format, xvalist); -#else - /* We cannot copy the va_list, so make sure we - * walk it just _once_. - */ - status=new char[300]; - vsnprintf(status, 300, format, args); -#endif object->infoMessage(QString::fromLocal8Bit(status)); - delete [] status; -#else - object->infoMessage(QString::fromLocal8Bit(status)); -#endif }