Blob Blame History Raw
From d0aed7c6a251a7dd49975c26085c555da332cf1a Mon Sep 17 00:00:00 2001
From: Marcus Meissner <marcus@beiboot.suse.de>
Date: Tue, 24 Jul 2012 17:54:17 +0200
Subject: [PATCH] support both libgphoto2 2.5.0 and 2.4.0

---
 CMakeLists.txt                           |   34 ++++++++++++++++++++----------
 digikam/utils/config-digikam.h.cmake     |    3 +++
 utilities/cameragui/devices/gpcamera.cpp |   15 +++++++++++++
 3 Dateien geändert, 41 Zeilen hinzugefügt(+), 11 Zeilen entfernt(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dfc7f16..51fb603 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -329,6 +329,24 @@ IF (NOT WIN32 AND HAVE_GPHOTO2)
     MACRO_OPTIONAL_FIND_PACKAGE(USB)
 ENDIF (NOT WIN32 AND HAVE_GPHOTO2)
 
+IF(GPHOTO2_FOUND)
+    EXEC_PROGRAM(gphoto2-config ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GPHOTO2_VERSION)
+    STRING(REPLACE "libgphoto2" "" GPHOTO2_VERSION "${GPHOTO2_VERSION}")
+    MACRO_ENSURE_VERSION("2.4.0" "${GPHOTO2_VERSION}" VERSION_GPHOTO2)
+    IF(VERSION_GPHOTO2 AND LIBUSB_FOUND)
+        SET(GPHOTO2_FOUND true)
+    ELSE(VERSION_GPHOTO2 AND LIBUSB_FOUND)
+        SET(GPHOTO2_FOUND false)
+    ENDIF(VERSION_GPHOTO2 AND LIBUSB_FOUND)
+    MACRO_ENSURE_VERSION("2.5.0" "${GPHOTO2_VERSION}" VERSION_GPHOTO25)
+    IF(VERSION_GPHOTO25)
+        SET(HAVE_GPHOTO25 1)
+    ELSE(VERSION_GPHOTO25)
+        SET(HAVE_GPHOTO25 0)
+    ENDIF(VERSION_GPHOTO25)
+ENDIF(GPHOTO2_FOUND)
+
+
 MACRO_OPTIONAL_FIND_PACKAGE(KdepimLibs)
 MACRO_BOOL_TO_01(KDEPIMLIBS_FOUND HAVE_KDEPIMLIBS)
 
@@ -378,6 +396,8 @@ MACRO_OPTIONAL_FIND_PACKAGE(Doxygen)
 
 CONFIGURE_FILE(digikam/utils/config-digikam.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/digikam/utils/config-digikam.h)
 
+
+
 # ==================================================================================================
 # Log messages
 
@@ -428,18 +448,10 @@ ENDIF(CLAPACK_FOUND)
 # ================================================================
 
 IF(GPHOTO2_FOUND)
-    EXEC_PROGRAM(gphoto2-config ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GPHOTO2_VERSION)
-    STRING(REPLACE "libgphoto2" "" GPHOTO2_VERSION "${GPHOTO2_VERSION}")
-    MACRO_ENSURE_VERSION("2.4.0" "${GPHOTO2_VERSION}" VERSION_GPHOTO2)
-    IF(VERSION_GPHOTO2 AND LIBUSB_FOUND)
-        SET(GPHOTO2_FOUND true)
-    ELSE(VERSION_GPHOTO2 AND LIBUSB_FOUND)
-        SET(GPHOTO2_FOUND false)
-    ENDIF(VERSION_GPHOTO2 AND LIBUSB_FOUND)
-ENDIF(GPHOTO2_FOUND)
-
-IF(GPHOTO2_FOUND)
     MESSAGE(STATUS " libgphoto2 and libusb libraries found.... YES (optional)")
+    IF(HAVE_GPHOTO25)
+    MESSAGE(STATUS " libgphoto2 2.5 library found............. YES (optional)")
+    endIF(HAVE_GPHOTO25)
 ELSE(GPHOTO2_FOUND)
     MESSAGE(STATUS " libgphoto2 and libusb libraries found.... NO  (optional)")
     MESSAGE(STATUS "")
diff --git a/digikam/utils/config-digikam.h.cmake b/digikam/utils/config-digikam.h.cmake
index d886499..4c1c6d3 100644
--- a/digikam/utils/config-digikam.h.cmake
+++ b/digikam/utils/config-digikam.h.cmake
@@ -45,6 +45,9 @@
 /* Define to 1 if GPhoto2 shared library is installed */
 #cmakedefine HAVE_GPHOTO2 1
 
+/* Define to 1 if libgphoto2 2.5 shared library is installed */
+#cmakedefine HAVE_GPHOTO25 1
+
 /* Define to 1 if thumbnails database is used */
 #cmakedefine USE_THUMBS_DB 1
 
diff --git a/utilities/cameragui/devices/gpcamera.cpp b/utilities/cameragui/devices/gpcamera.cpp
index 22e873a..a98e0a2 100644
--- a/utilities/cameragui/devices/gpcamera.cpp
+++ b/utilities/cameragui/devices/gpcamera.cpp
@@ -1329,10 +1329,19 @@ bool GPCamera::uploadItem(const QString& folder, const QString& itemName, const
     d->status = 0;
     d->status = new GPStatus;
 
+#ifdef HAVE_GPHOTO25
     errorCode = gp_camera_folder_put_file(d->camera,
                                           QFile::encodeName(folder).constData(),
+                                          QFile::encodeName(itemName),
+                                          GP_FILE_TYPE_NORMAL,
                                           cfile,
                                           d->status->context);
+#else
+    errorCode = gp_camera_folder_put_file(d->camera,
+                                          QFile::encodeName(folder).constData(),
+                                          cfile,
+                                          d->status->context);
+#endif
 
     if (errorCode != GP_OK)
     {
@@ -1651,7 +1660,13 @@ void GPCamera::getSupportedPorts(QStringList& plist)
         for (int i = 0 ; i < numPorts ; ++i)
         {
             gp_port_info_list_get_info(list, i, &info);
+#ifdef HAVE_GPHOTO25
+	    char *xpath;
+            gp_port_info_get_name (info, &xpath);
+            plist.append(xpath);
+#else
             plist.append(info.path);
+#endif
         }
     }
 
-- 
1.7.10.4