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
#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`"
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

@ -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

@ -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 );
}

@ -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 );
}

@ -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;

@ -30,6 +30,8 @@ extern "C" {
#include <gphoto2.h>
}
#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;

Loading…
Cancel
Save