From 543d6c2a73f5db018c6813d4a6bf46707298d070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Thu, 12 Sep 2013 01:16:43 +0200 Subject: [PATCH] Add support for gphoto 2.5 --- config.h.in | 2 ++ configure.in | 4 ++++ kipi-plugins/configure.in.in | 4 ++++ kipi-plugins/kameraklient/gpcamera.cpp | 13 ++++++++++- kipi-plugins/kameraklient/gpiface.cpp | 7 ++++++ kipi-plugins/kameraklient/gpstatus.cpp | 30 +++++++++++++++++++++++--- kipi-plugins/kameraklient/gpstatus.h | 8 +++++++ 7 files changed, 64 insertions(+), 4 deletions(-) diff --git a/config.h.in b/config.h.in index ca7e5ff..898e37f 100644 --- a/config.h.in +++ b/config.h.in @@ -150,6 +150,8 @@ #define HAVE_BOOLEAN #endif +/* Defined if compiling with gphoto >= 2.5 */ +#under HAVE_GPHOTO2_5 /* diff --git a/configure.in b/configure.in index 0a7fadd..54f2542 100644 --- a/configure.in +++ b/configure.in @@ -368,6 +368,10 @@ if test "x$build_gphoto" != "xno"; then LIB_GPHOTO="`$GPHOTO_CONFIG --libs` `$GPHOTO_PORT_CONFIG --libs`" AC_SUBST(LIB_GPHOTO) have_gphoto=yes + AC_CHECK_LIB(gphoto2_port, gp_port_info_get_name, have_gphoto2_5=yes, have_gphoto2_5=no) + if test "x$have_gphoto2_5" != "xno"; then + AC_DEFINE(HAVE_GPHOTO2_5, 1, [have gphoto 2.5]) + fi else AC_MSG_WARN([gPhoto2 not found, some plugins will not be compiled.]) fi diff --git a/kipi-plugins/configure.in.in b/kipi-plugins/configure.in.in index 3103327..7dc03ec 100644 --- a/kipi-plugins/configure.in.in +++ b/kipi-plugins/configure.in.in @@ -292,6 +292,10 @@ if test "x$build_gphoto" != "xno"; then LIB_GPHOTO="`$GPHOTO_CONFIG --libs` `$GPHOTO_PORT_CONFIG --libs`" AC_SUBST(LIB_GPHOTO) have_gphoto=yes + AC_CHECK_LIB(gphoto2_port, gp_port_info_get_name, have_gphoto2_5=yes, have_gphoto2_5=no) + if test "x$have_gphoto2_5" != "xno"; then + AC_DEFINE(HAVE_GPHOTO2_5, 1, [have gphoto 2.5]) + fi else AC_MSG_WARN([gPhoto2 not found, some plugins will not be compiled.]) fi diff --git a/kipi-plugins/kameraklient/gpcamera.cpp b/kipi-plugins/kameraklient/gpcamera.cpp index 351c222..22cc20b 100644 --- a/kipi-plugins/kameraklient/gpcamera.cpp +++ b/kipi-plugins/kameraklient/gpcamera.cpp @@ -36,6 +36,7 @@ extern "C" { #include "gpstatus.h" #include "gpcamera.h" #include "cameralist.h" +#include "config.h" namespace KIPIKameraKlientPlugin { @@ -436,7 +437,11 @@ int GPCamera::uploadItem(const TQString& folder, const TQString& itemName, const status = 0; } status = new GPStatus; - if (gp_camera_folder_put_file(d->camera, folder.latin1(), cfile, status->context) != GP_OK) { + if (gp_camera_folder_put_file(d->camera, TQFile::encodeName( folder ), +# ifdef HAVE_GPHOTO2_5 + TQFile::encodeName( localFile ), GP_FILE_TYPE_NORMAL, +# endif + cfile, status->context) != GP_OK) { gp_file_unref(cfile); delete status; status = 0; @@ -530,7 +535,13 @@ void GPCamera::getSupportedPorts(TQStringList& plist) { int numPorts = gp_port_info_list_count( list ); for (int i = 0; i < numPorts; i++) { gp_port_info_list_get_info( list, i, &info ); +# ifdef HAVE_GPHOTO2_5 + char *xpath; + gp_port_info_get_path (info, &xpath); + plist.append(xpath); +# else plist.append(info.path); +# endif } gp_port_info_list_free( list ); } diff --git a/kipi-plugins/kameraklient/gpiface.cpp b/kipi-plugins/kameraklient/gpiface.cpp index 3c2eeb6..b20ff32 100644 --- a/kipi-plugins/kameraklient/gpiface.cpp +++ b/kipi-plugins/kameraklient/gpiface.cpp @@ -32,6 +32,7 @@ extern "C" // Local #include "gpiface.h" +#include "config.h" namespace KIPIKameraKlientPlugin { @@ -114,7 +115,13 @@ void GPIface::getSupportedPorts(TQStringList& plist) { int numPorts = gp_port_info_list_count( list ); for (int i = 0; i < numPorts; i++) { gp_port_info_list_get_info( list, i, &info ); +# ifdef HAVE_GPHOTO2_5 + char *xpath; + gp_port_info_get_path( info, &xpath ); + plist.append( xpath ); +# else plist.append( info.path ); +# endif } gp_port_info_list_free( list ); } diff --git a/kipi-plugins/kameraklient/gpstatus.cpp b/kipi-plugins/kameraklient/gpstatus.cpp index 61b22a6..0beb39c 100644 --- a/kipi-plugins/kameraklient/gpstatus.cpp +++ b/kipi-plugins/kameraklient/gpstatus.cpp @@ -52,37 +52,61 @@ GPContextFeedback GPStatus::cancel_func(GPContext *, void *) { return (cancel ? GP_CONTEXT_FEEDBACK_CANCEL : GP_CONTEXT_FEEDBACK_OK); } -void GPStatus::error_func(GPContext *, const char *format, va_list args, void *) { +void GPStatus::error_func(GPContext *, +# ifdef HAVE_GPHOTO2_5 + const char *buf, +# else + const char *format, va_list args, +# endif + void *) { +# ifndef HAVE_GPHOTO2_5 char buf[4096] = ""; int nSize = vsnprintf( buf, 4096, format, args ); if(nSize > 4094) { nSize = 4094; } buf[nSize] = '\0'; +# endif TQString error; error = error.fromLocal8Bit(buf); GPMessages::gpMessagesWrapper()->emit errorMessage(error); } -void GPStatus::status_func (GPContext *, const char *format, va_list args, void *) { +void GPStatus::status_func (GPContext *, +# ifdef HAVE_GPHOTO2_5 + const char *buf, +# else + const char *format, va_list args, +# endif + void *) { +# ifndef HAVE_GPHOTO2_5 char buf[4096] = ""; int nSize = vsnprintf( buf, 4096, format, args ); if(nSize > 4094) { nSize = 4094; } buf[nSize] = '\0'; +# endif TQString status; status = status.fromLocal8Bit(buf); GPMessages::gpMessagesWrapper()->emit statusChanged(status); } -unsigned int GPStatus::progress_start_func(GPContext *, float _target, const char *format, va_list args, void *) { +unsigned int GPStatus::progress_start_func(GPContext *, float _target, +# ifdef HAVE_GPHOTO2_5 + const char *buf, +# else + const char *format, va_list args, +# endif + void *) { +# ifndef HAVE_GPHOTO2_5 char buf[4096] = ""; int nSize = vsnprintf( buf, 4096, format, args ); if(nSize > 4094) { nSize = 4094; } buf[nSize] = '\0'; +# endif TQString prog; prog = prog.fromLocal8Bit(buf); target = _target; diff --git a/kipi-plugins/kameraklient/gpstatus.h b/kipi-plugins/kameraklient/gpstatus.h index 324cae5..c85207a 100644 --- a/kipi-plugins/kameraklient/gpstatus.h +++ b/kipi-plugins/kameraklient/gpstatus.h @@ -30,6 +30,8 @@ extern "C" { #include } +#include "config.h" + namespace KIPIKameraKlientPlugin { @@ -49,9 +51,15 @@ class GPStatus : public TQObject { private: static GPContextFeedback cancel_func(GPContext *context, void *data); +# ifdef HAVE_GPHOTO2_5 + static void error_func(GPContext *context, const char *error, void *data); + static void status_func(GPContext *context, const char *status, void *data); + static unsigned int progress_start_func (GPContext *context, float totalsize, const char *status, void *data); +# else static void error_func(GPContext *context, const char *format, va_list args, void *data); static void status_func(GPContext *context, const char *format, va_list args, void *data); static unsigned int progress_start_func (GPContext *context, float target, const char *format, va_list args, void *data); +# endif static void progress_update_func (GPContext *context, unsigned int id, float current, void *data); static void progress_stop_func(GPContext *context, unsigned int id, void *data); static float target;