Add support for gphoto 2.5

pull/1/head
Slávek Banko 11 years ago
parent 5b03c2a0af
commit 543d6c2a73

@ -150,6 +150,8 @@
#define HAVE_BOOLEAN #define HAVE_BOOLEAN
#endif #endif
/* Defined if compiling with gphoto >= 2.5 */
#under HAVE_GPHOTO2_5
/* /*

@ -368,6 +368,10 @@ if test "x$build_gphoto" != "xno"; then
LIB_GPHOTO="`$GPHOTO_CONFIG --libs` `$GPHOTO_PORT_CONFIG --libs`" LIB_GPHOTO="`$GPHOTO_CONFIG --libs` `$GPHOTO_PORT_CONFIG --libs`"
AC_SUBST(LIB_GPHOTO) AC_SUBST(LIB_GPHOTO)
have_gphoto=yes 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 else
AC_MSG_WARN([gPhoto2 not found, some plugins will not be compiled.]) AC_MSG_WARN([gPhoto2 not found, some plugins will not be compiled.])
fi fi

@ -292,6 +292,10 @@ if test "x$build_gphoto" != "xno"; then
LIB_GPHOTO="`$GPHOTO_CONFIG --libs` `$GPHOTO_PORT_CONFIG --libs`" LIB_GPHOTO="`$GPHOTO_CONFIG --libs` `$GPHOTO_PORT_CONFIG --libs`"
AC_SUBST(LIB_GPHOTO) AC_SUBST(LIB_GPHOTO)
have_gphoto=yes 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 else
AC_MSG_WARN([gPhoto2 not found, some plugins will not be compiled.]) AC_MSG_WARN([gPhoto2 not found, some plugins will not be compiled.])
fi fi

@ -36,6 +36,7 @@ extern "C" {
#include "gpstatus.h" #include "gpstatus.h"
#include "gpcamera.h" #include "gpcamera.h"
#include "cameralist.h" #include "cameralist.h"
#include "config.h"
namespace KIPIKameraKlientPlugin namespace KIPIKameraKlientPlugin
{ {
@ -436,7 +437,11 @@ int GPCamera::uploadItem(const TQString& folder, const TQString& itemName, const
status = 0; status = 0;
} }
status = new GPStatus; 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); gp_file_unref(cfile);
delete status; delete status;
status = 0; status = 0;
@ -530,7 +535,13 @@ void GPCamera::getSupportedPorts(TQStringList& plist) {
int numPorts = gp_port_info_list_count( list ); int numPorts = gp_port_info_list_count( list );
for (int i = 0; i < numPorts; i++) { for (int i = 0; i < numPorts; i++) {
gp_port_info_list_get_info( list, i, &info ); 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); plist.append(info.path);
# endif
} }
gp_port_info_list_free( list ); gp_port_info_list_free( list );
} }

@ -32,6 +32,7 @@ extern "C"
// Local // Local
#include "gpiface.h" #include "gpiface.h"
#include "config.h"
namespace KIPIKameraKlientPlugin namespace KIPIKameraKlientPlugin
{ {
@ -114,7 +115,13 @@ void GPIface::getSupportedPorts(TQStringList& plist) {
int numPorts = gp_port_info_list_count( list ); int numPorts = gp_port_info_list_count( list );
for (int i = 0; i < numPorts; i++) { for (int i = 0; i < numPorts; i++) {
gp_port_info_list_get_info( list, i, &info ); 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 ); plist.append( info.path );
# endif
} }
gp_port_info_list_free( list ); gp_port_info_list_free( list );
} }

@ -52,37 +52,61 @@ GPContextFeedback GPStatus::cancel_func(GPContext *, void *) {
return (cancel ? GP_CONTEXT_FEEDBACK_CANCEL : GP_CONTEXT_FEEDBACK_OK); 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] = ""; char buf[4096] = "";
int nSize = vsnprintf( buf, 4096, format, args ); int nSize = vsnprintf( buf, 4096, format, args );
if(nSize > 4094) { if(nSize > 4094) {
nSize = 4094; nSize = 4094;
} }
buf[nSize] = '\0'; buf[nSize] = '\0';
# endif
TQString error; TQString error;
error = error.fromLocal8Bit(buf); error = error.fromLocal8Bit(buf);
GPMessages::gpMessagesWrapper()->emit errorMessage(error); 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] = ""; char buf[4096] = "";
int nSize = vsnprintf( buf, 4096, format, args ); int nSize = vsnprintf( buf, 4096, format, args );
if(nSize > 4094) { if(nSize > 4094) {
nSize = 4094; nSize = 4094;
} }
buf[nSize] = '\0'; buf[nSize] = '\0';
# endif
TQString status; TQString status;
status = status.fromLocal8Bit(buf); status = status.fromLocal8Bit(buf);
GPMessages::gpMessagesWrapper()->emit statusChanged(status); 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] = ""; char buf[4096] = "";
int nSize = vsnprintf( buf, 4096, format, args ); int nSize = vsnprintf( buf, 4096, format, args );
if(nSize > 4094) { if(nSize > 4094) {
nSize = 4094; nSize = 4094;
} }
buf[nSize] = '\0'; buf[nSize] = '\0';
# endif
TQString prog; TQString prog;
prog = prog.fromLocal8Bit(buf); prog = prog.fromLocal8Bit(buf);
target = _target; target = _target;

@ -30,6 +30,8 @@ extern "C" {
#include <gphoto2.h> #include <gphoto2.h>
} }
#include "config.h"
namespace KIPIKameraKlientPlugin namespace KIPIKameraKlientPlugin
{ {
@ -49,9 +51,15 @@ class GPStatus : public TQObject {
private: private:
static GPContextFeedback cancel_func(GPContext *context, void *data); 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 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 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); 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_update_func (GPContext *context, unsigned int id, float current, void *data);
static void progress_stop_func(GPContext *context, unsigned int id, void *data); static void progress_stop_func(GPContext *context, unsigned int id, void *data);
static float target; static float target;

Loading…
Cancel
Save