4 commits - cmake/modules conversion/kabcconversion.cpp tests/calendaringtest.cpp tests/calendaringtest.h tests/formattest.cpp tests/formattest.h tests/kcalconversiontest.cpp tests/kcalconversiontest.h tests/mimeobjecttest.cpp tests/mimeobjecttest.h tests/timezonetest.cpp tests/timezonetest.h

Christian Mollekopf mollekopf at kolabsys.com
Wed Apr 10 01:38:38 CEST 2013


 cmake/modules/SWIGUtils.cmake |   58 +++++++++++++++++++++++++++++++-----------
 conversion/kabcconversion.cpp |   17 ++++++++++--
 tests/calendaringtest.cpp     |    8 +++++
 tests/calendaringtest.h       |    1 
 tests/formattest.cpp          |    5 +++
 tests/formattest.h            |    2 +
 tests/kcalconversiontest.cpp  |    4 ++
 tests/kcalconversiontest.h    |    1 
 tests/mimeobjecttest.cpp      |    6 ++++
 tests/mimeobjecttest.h        |    1 
 tests/timezonetest.cpp        |    6 ++++
 tests/timezonetest.h          |    5 +++
 12 files changed, 96 insertions(+), 18 deletions(-)

New commits:
commit a268479ab1fba7dba13117a54dde692f61d7010a
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed Apr 10 01:38:24 2013 +0200

    Deal with corrupted images better.
    
    * Try to set the mimetype if available, otherwise fallback to autodetection.
    * Don't set an error if we fail to load the image.
    
    By degrading image problems to a warning, we still get the contact displayed in Kontact even if we fail to load the image.
    
    The proper fix would be to classify the error and let the application decide what to do.

diff --git a/conversion/kabcconversion.cpp b/conversion/kabcconversion.cpp
index 6ab7185..16bda4e 100644
--- a/conversion/kabcconversion.cpp
+++ b/conversion/kabcconversion.cpp
@@ -21,6 +21,7 @@
 #include <kcalcore/freebusyurlstore.h>
 #include <kdebug.h>
 #include <qbuffer.h>
+#include <qimagereader.h>
 #include "kolabformat/errorhandler.h"
 
 
@@ -357,13 +358,23 @@ std::string fromPicture(const KABC::Picture &pic, std::string &mimetype)
 
 KABC::Picture toPicture(const std::string &data, const std::string &mimetype) {
     QImage img;
-    if (!img.loadFromData( QByteArray::fromRawData(data.data(), data.size()) )) {
-        Error() << "failed to load picture";
+    bool ret = false;
+    QByteArray type(mimetype.data(), mimetype.size());
+    type = type.split('/').last(); // extract "jpeg" from "image/jpeg"
+    if (QImageReader::supportedImageFormats().contains(type)) {
+        ret = img.loadFromData(QByteArray::fromRawData(data.data(), data.size()), type.constData());
+    } else {
+        ret = img.loadFromData(QByteArray::fromRawData(data.data(), data.size()));
+    }
+    if (!ret) {
+        Warning() << "failed to load picture";
+        return KABC::Picture();
     }
     
     KABC::Picture logo(img);
     if (logo.isEmpty()) {
-        Error() << "failed to read picture";
+        Warning() << "failed to read picture";
+        return KABC::Picture();
     }
     logo.setType(fromStdString(mimetype));
     return logo;


commit 40c160a7ab65811dd587d629c52a94dfcf65521f
Merge: a901368 b378a2a
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Tue Apr 9 22:43:44 2013 +0200

    Merge branch 'php'



commit a901368b47767853a7f8b3898d00fd89bec664a7
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Tue Apr 9 19:45:08 2013 +0200

    Abort tests early which required ktimezoned if not available.

diff --git a/tests/calendaringtest.cpp b/tests/calendaringtest.cpp
index d1ed07e..8938be5 100644
--- a/tests/calendaringtest.cpp
+++ b/tests/calendaringtest.cpp
@@ -19,9 +19,10 @@
 #include "calendaringtest.h"
 
 #include <QTest>
+#include <ksystemtimezone.h>
 #include <kolabevent.h>
 #include <iostream>
-#include "calendaring/calendaring.h"
+#include <calendaring/calendaring.h>
 #include <calendaring/event.h>
 #include <calendaring/datetimeutils.h>
 
@@ -41,6 +42,11 @@ void compareEvents(const std::vector<Kolab::Event> &list1, const std::vector<Kol
     }
 }
 
+void CalendaringTest::initTestCase()
+{
+    QVERIFY2(KSystemTimeZones::isTimeZoneDaemonAvailable(), "Timezone support is required for this test. Either use libcalendaring or make sure KTimeZoned is available");
+}
+
 void CalendaringTest::testCalendaringEvent()
 {
     Kolab::Event event;
diff --git a/tests/calendaringtest.h b/tests/calendaringtest.h
index af05d22..43ff5cc 100644
--- a/tests/calendaringtest.h
+++ b/tests/calendaringtest.h
@@ -24,6 +24,7 @@ class CalendaringTest: public QObject
 {
     Q_OBJECT
 private slots:
+    void initTestCase();
 
     void testCalendaringEvent();
     
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 3c05eb0..ad836aa 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -24,6 +24,7 @@
 #include <qtemporaryfile.h>
 #include <QBuffer>
 #include <kdebug.h>
+#include <ksystemtimezone.h>
 #include <kolabcontainers.h>
 #include <kolabformat.h>
 
@@ -75,6 +76,10 @@ static bool compareMimeMessage( const KMime::Message::Ptr &msg, const KMime::Mes
     return true;
 }
 
+void FormatTest::initTestCase()
+{
+    QVERIFY2(KSystemTimeZones::isTimeZoneDaemonAvailable(), "Timezone support is required for this test. Either use libcalendaring or make sure KTimeZoned is available");
+}
 
 void FormatTest::testIncidence_data()
 {
diff --git a/tests/formattest.h b/tests/formattest.h
index 8097bfc..c69c261 100644
--- a/tests/formattest.h
+++ b/tests/formattest.h
@@ -49,6 +49,8 @@ class FormatTest: public QObject
 {
     Q_OBJECT
 private slots:
+
+    void initTestCase();
     
     void testIncidence_data();
     void testIncidence();
diff --git a/tests/kcalconversiontest.cpp b/tests/kcalconversiontest.cpp
index 23698dd..67c7806 100644
--- a/tests/kcalconversiontest.cpp
+++ b/tests/kcalconversiontest.cpp
@@ -53,6 +53,10 @@ void compareAttendeesVectors(const KCalCore::Attendee::List &list, const KCalCor
     }
 }
 
+void KCalConversionTest::initTestCase()
+{
+    QVERIFY2(KSystemTimeZones::isTimeZoneDaemonAvailable(), "Timezone support is required for this test. Either use libcalendaring or make sure KTimeZoned is available");
+}
 
 void KCalConversionTest::testDate_data()
 {
diff --git a/tests/kcalconversiontest.h b/tests/kcalconversiontest.h
index c58042d..4b7378b 100644
--- a/tests/kcalconversiontest.h
+++ b/tests/kcalconversiontest.h
@@ -25,6 +25,7 @@ class KCalConversionTest : public QObject
 {
   Q_OBJECT
   private slots:
+    void initTestCase();
 
     void testDate_data();
     void testDate();
diff --git a/tests/mimeobjecttest.cpp b/tests/mimeobjecttest.cpp
index 0d5d42a..48c2bb7 100644
--- a/tests/mimeobjecttest.cpp
+++ b/tests/mimeobjecttest.cpp
@@ -23,6 +23,12 @@
 #include <fstream>
 #include <sstream>
 #include <QString>
+#include <ksystemtimezone.h>
+
+void MIMEObjectTest::initTestCase()
+{
+    QVERIFY2(KSystemTimeZones::isTimeZoneDaemonAvailable(), "Timezone support is required for this test. Either use libcalendaring or make sure KTimeZoned is available");
+}
 
 void MIMEObjectTest::testEvent(){
 
diff --git a/tests/mimeobjecttest.h b/tests/mimeobjecttest.h
index badb4c5..a060d40 100644
--- a/tests/mimeobjecttest.h
+++ b/tests/mimeobjecttest.h
@@ -24,6 +24,7 @@ class MIMEObjectTest: public QObject
     Q_OBJECT
 
 private slots:
+    void initTestCase();
     void testEvent();
     void testJournal(); 
     void testNote();
diff --git a/tests/timezonetest.cpp b/tests/timezonetest.cpp
index 7a0878e..35aae7c 100644
--- a/tests/timezonetest.cpp
+++ b/tests/timezonetest.cpp
@@ -28,6 +28,7 @@
 #include <kdebug.h>
 #include <kcalcore/event.h>
 #include <kcalcore/icalformat.h>
+#include <ksystemtimezone.h>
 
 // void icuFoo()
 // {
@@ -52,6 +53,11 @@
 // 
 // }
 
+void TimezoneTest::initTestCase()
+{
+    QVERIFY2(KSystemTimeZones::isTimeZoneDaemonAvailable(), "Timezone support is required for this test. Either use libcalendaring or make sure KTimeZoned is available");
+}
+
 void TimezoneTest::testFromName()
 {
     TimezoneConverter converter;
diff --git a/tests/timezonetest.h b/tests/timezonetest.h
index 7d76969..efaaddc 100644
--- a/tests/timezonetest.h
+++ b/tests/timezonetest.h
@@ -23,6 +23,11 @@ class TimezoneTest: public QObject
 {
     Q_OBJECT
 private slots:
+    /**
+     * If this unittest fails, many others will follow.
+     */
+    void initTestCase();
+
     void testFromName();
     void testFromHardcodedList_data();
     void testFromHardcodedList();


commit b378a2aae963007a83be3e2ce03bb202aac6a503
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Feb 28 22:03:45 2013 +0100

    Patch by C. Giboudeaux
    
    - Replace the FindPHP4.cmake usage since we need PHP >= 5.3.
    - Fix the kolabformat installation. By default it now installs in the extensions directory defined when building php.
    This can be overwritten by manually setting PHP_INSTALL_DIR when running Make.

diff --git a/cmake/modules/SWIGUtils.cmake b/cmake/modules/SWIGUtils.cmake
index bb78348..136e697 100644
--- a/cmake/modules/SWIGUtils.cmake
+++ b/cmake/modules/SWIGUtils.cmake
@@ -25,28 +25,57 @@ macro (generatePHPBindings MODULE_NAME INTERFACE_FILE)
     endif()
     set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers -Wno-undef" )
 
-    find_package(PHP4 5.3 REQUIRED)
+    # Try to find PHP5
+    find_path(PHP_INCLUDE_DIR NAMES main/php.h PATH_SUFFIXES php php5)
+    find_program(PHP_EXECUTABLE NAMES php)
+
+    # Libkolab needs PHP >= 5.3
+    set(PHP_MIN_VERSION 50300)
+
+    # Find where to install the extension files if it's not defined
+    if(NOT DEFINED PHP_INSTALL_DIR)
+        find_program(PHP_CONFIG_EXECUTABLE NAMES php-config)
+        if(PHP_CONFIG_EXECUTABLE)
+            execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --extension-dir
+                OUTPUT_VARIABLE _php_extensions_dir
+                )
+            string(REGEX REPLACE "\n" "" _php_extensions_dir "${_php_extensions_dir}")
+            set(PHP_INSTALL_DIR ${_php_extensions_dir} CACHE STRING "Install directory for PHP bindings.")
+        else()
+            set(PHP_INSTALL_DIR ${LIB_INSTALL_DIR}/extensions)
+        endif()
+    endif()
+
+    if(PHP_INCLUDE_DIR AND PHP_EXECUTABLE)
+        file(READ ${PHP_INCLUDE_DIR}/main/php_version.h PHP_VERSION_CONTENT)
+        string(REGEX MATCH "#define PHP_VERSION_ID[ ]*[0-9]*\n" _PHP_VERSION_ID_MATCH ${PHP_VERSION_CONTENT})
+        if(_PHP_VERSION_ID_MATCH)
+            string(REGEX REPLACE "#define PHP_VERSION_ID[ ]*([0-9]*)\n" "\\1" PHP_VERSION_ID ${_PHP_VERSION_ID_MATCH})
+        endif()
+
+        # Include the needed PHP5 subdirs
+        set(PHP_INCLUDE_DIRS ${PHP_INCLUDE_DIR} ${PHP_INCLUDE_DIR}/main ${PHP_INCLUDE_DIR}/TSRM ${PHP_INCLUDE_DIR}/Zend )
+    endif()
 
-    if (PHP4_FOUND)
-        include_directories(${PHP4_INCLUDE_PATH})
+    if(NOT PHP_VERSION_ID VERSION_LESS ${PHP_MIN_VERSION})
+        include_directories(${PHP_INCLUDE_DIRS})
         add_library(${MODULE_NAME}_phpbindings SHARED ${KOLAB_SWIG_PHP_SOURCE_FILE})
         target_link_libraries(${MODULE_NAME}_phpbindings kolab)
-        SET_TARGET_PROPERTIES(${MODULE_NAME}_phpbindings PROPERTIES OUTPUT_NAME ${MODULE_NAME})
-        SET_TARGET_PROPERTIES(${MODULE_NAME}_phpbindings PROPERTIES PREFIX "")
+        set_target_properties(${MODULE_NAME}_phpbindings PROPERTIES OUTPUT_NAME ${MODULE_NAME})
+        set_target_properties(${MODULE_NAME}_phpbindings PROPERTIES PREFIX "")
 
-    #     configure_file(test.php ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
-
-        set(PHP_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/phpbindings" CACHE STRING "Install directory for php bindings.")
+        #     configure_file(test.php ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
 
         install(TARGETS ${MODULE_NAME}_phpbindings LIBRARY DESTINATION ${PHP_INSTALL_DIR})
-
-        install( FILES
+        install(FILES
             ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.php
             DESTINATION ${PHP_INSTALL_DIR}
-        )
-    else(PHP4_FOUND)
+            )
+
+    else()
         message(WARNING "not building php bindings because php was not found")
-    endif (PHP4_FOUND)
+    endif()
+
 endmacro()
 
 
@@ -98,4 +127,5 @@ macro(generatePythonBindings MODULE_NAME INTERFACE_FILE)
         DESTINATION ${PYTHON_INSTALL_DIR}/kolab
     )
 
-endmacro()
\ No newline at end of file
+endmacro()
+





More information about the commits mailing list