[git] GPGME - branch, gpgmepp, updated. gpgme-1.6.0-24-g8347f3d

by Andre Heinecke cvs at cvs.gnupg.org
Tue Mar 8 15:38:08 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, gpgmepp has been updated
       via  8347f3d5fc3e476aa767fbbaf09a1310a6154280 (commit)
       via  58ed9c17f00f420035ecc6973a6c6ed948757a9a (commit)
      from  a06603d75e80aba58df58f9a41770c56b6a1f0b8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8347f3d5fc3e476aa767fbbaf09a1310a6154280
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Mar 8 14:33:15 2016 +0100

    Add qgpgme as qt language binding
    
    * configure.ac: Add version defines. Check for qt if neccessary.
    * lang/README: Mention qt
    * lang/cpp/src/GpgmeppConfig.cmake.in.in: Remove comment. Find qgpgme.
    * lang/qt/src/Makefile.am: New. Build qgpgme.
    * lang/qt/README,
     lang/qt/src/Makefile.am,
     lang/qt/src/QGpgmeConfig.cmake.in.in,
     lang/qt/src/QGpgmeConfigVersion.cmake.in,
     lang/qt/src/dataprovider.cpp,
     lang/qt/src/dataprovider.h,
     lang/qt/src/qgpgme_export.h,
     m4/qt.m4: New.
    * lang/cpp/src/GpgmeppConfig.cmake.in.in,
     lang/cpp/src/Makefile.am: Fix generated config file.
    
    --
    For now this is just the dataprovider which was part of the
    KF5 Gpgmepp QGpgme variant. This is very thin but a useful
    class which is used downstream.

diff --git a/configure.ac b/configure.ac
index c3a46ae..9dd02e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,10 @@ LIBGPGMEPP_LT_CURRENT=3
 LIBGPGMEPP_LT_AGE=0
 LIBGPGMEPP_LT_REVISION=0
 
+LIBQGPGME_LT_CURRENT=1
+LIBQGPGME_LT_AGE=0
+LIBQGPGME_LT_REVISION=0
+
 # If the API is changed in an incompatible way: increment the next counter.
 GPGME_CONFIG_API_VERSION=1
 ##############################################
@@ -111,6 +115,9 @@ AC_SUBST(LIBGPGME_LT_REVISION)
 AC_SUBST(LIBGPGMEPP_LT_CURRENT)
 AC_SUBST(LIBGPGMEPP_LT_AGE)
 AC_SUBST(LIBGPGMEPP_LT_REVISION)
+AC_SUBST(LIBQGPGME_LT_CURRENT)
+AC_SUBST(LIBQGPGME_LT_AGE)
+AC_SUBST(LIBQGPGME_LT_REVISION)
 
 AC_SUBST(PACKAGE)
 AC_SUBST(VERSION)
@@ -153,8 +160,8 @@ have_w32_system=no
 have_w64_system=no
 build_w32_glib=no
 build_w32_qt=no
-available_languages="cpp cl"
-default_languages="cpp cl"
+available_languages="cpp cl qt"
+default_languages="cpp cl qt"
 case "${host}" in
     x86_64-*mingw32*)
         have_w64_system=yes
@@ -259,6 +266,24 @@ for language in $enabled_languages; do
        AC_MSG_ERROR([unsupported language binding specified])
     fi
 done
+# Check that if qt is enabled cpp also is enabled
+LIST_MEMBER("qt", $enabled_languages)
+if test "$found" = "1"; then
+   LIST_MEMBER("cpp", $enabled_languages)
+   if test "$found" = "0"; then
+      AC_MSG_ERROR([qt binding depends on cpp language binding])
+   fi
+   FIND_QT
+   if test "$have_qt5_libs" != "yes"; then
+       AC_MSG_ERROR([[
+   ***
+   *** Qt5 (Qt5Core) is required for qt binding.
+   ***]])
+   fi
+   # Make sure that qt comes after cpp
+   enabled_languages=`echo $enabled_languages | sed 's/qt//'`
+   enabled_languages=`echo $enabled_languages qt`
+fi
 AC_SUBST(ENABLED_LANGUAGES, $enabled_languages)
 
 #
@@ -650,6 +675,9 @@ AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
 AC_CONFIG_FILES(lang/cpp/Makefile lang/cpp/src/Makefile)
 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfig.cmake.in)
 AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfigVersion.cmake)
+AC_CONFIG_FILES(lang/qt/Makefile lang/qt/src/Makefile)
+AC_CONFIG_FILES(lang/qt/src/QGpgmeConfig.cmake.in)
+AC_CONFIG_FILES(lang/qt/src/QGpgmeConfigVersion.cmake)
 AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
 AC_OUTPUT
 
diff --git a/lang/README b/lang/README
index 5745029..e1c04f2 100644
--- a/lang/README
+++ b/lang/README
@@ -11,3 +11,4 @@ Directory	Language
 
 cl		Common Lisp
 cpp     C++
+qt      Qt-Framework API
diff --git a/lang/cpp/src/GpgmeppConfig.cmake.in.in b/lang/cpp/src/GpgmeppConfig.cmake.in.in
index 4b5b905..51218c6 100644
--- a/lang/cpp/src/GpgmeppConfig.cmake.in.in
+++ b/lang/cpp/src/GpgmeppConfig.cmake.in.in
@@ -37,7 +37,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
 set(_targetsDefined)
 set(_targetsNotDefined)
 set(_expectedTargets)
-foreach(_expectedTarget KF5::Gpgmepp KF5::QGpgme)
+foreach(_expectedTarget KF5::Gpgmepp Gpgmepp)
   list(APPEND _expectedTargets ${_expectedTarget})
   if(NOT TARGET ${_expectedTarget})
     list(APPEND _targetsNotDefined ${_expectedTarget})
@@ -69,18 +69,10 @@ add_library(Gpgmepp SHARED IMPORTED)
 
 set_target_properties(Gpgmepp PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/gpgme++"
-  INTERFACE_LINK_LIBRARIES "@libdir@/libgpgme.dll.a;@LIBASSUAN_LIBS@;@GPG_ERROR_LIBS@"
+  INTERFACE_LINK_LIBRARIES "@resolved_libdir@/libgpgme at libsuffix@;@LIBASSUAN_LIBS@;@GPG_ERROR_LIBS@"
+  IMPORTED_LOCATION "@resolved_libdir@/libgpgmepp at libsuffix@"
 )
 
-# Create imported target QGpgme
-#add_library(QGpgme SHARED IMPORTED)
-
-#set_target_properties(KF5::QGpgme PROPERTIES
-#   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/qgpgme"
-   #  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX} TODO"
-#  INTERFACE_LINK_LIBRARIES "Qt5::Core"
-#)
-
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
   message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
 endif()
@@ -107,9 +99,10 @@ but not all the files it references.
 endforeach()
 unset(_IMPORT_CHECK_TARGETS)
 
-# This file does not depend on other imported targets which have
-# been exported from the same project but in a separate export set.
-
 # Commands beyond this point should not need to know the version.
 set(CMAKE_IMPORT_FILE_VERSION)
 cmake_policy(POP)
+
+get_filename_component(QGpgme_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+# Pull in QGpgme for compatibility with KF5 variant.
+find_package(QGpgme CONFIG)
diff --git a/lang/cpp/src/Makefile.am b/lang/cpp/src/Makefile.am
index a9b7ef4..e56b818 100644
--- a/lang/cpp/src/Makefile.am
+++ b/lang/cpp/src/Makefile.am
@@ -62,8 +62,16 @@ libgpgmepp_la_LIBADD = ../../../src/libgpgme.la @LIBASSUAN_LIBS@
 libgpgmepp_la_LDFLAGS = -version-info \
     @LIBGPGMEPP_LT_CURRENT@:@LIBGPGMEPP_LT_REVISION@:@LIBGPGMEPP_LT_AGE@
 
+if HAVE_W32_SYSTEM
+libsuffix=.dll.a
+else
+libsuffix=.so
+endif
+
 GpgmeppConfig.cmake: GpgmeppConfig.cmake.in
 	sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" > "$@"
+	sed -e 's|[@]libsuffix@|$(libsuffix)|g' < "$@" > "$@".2
+	mv "$@".2 "$@"
 
 install-cmake-files: GpgmeppConfig.cmake GpgmeppConfigVersion.cmake
 	-$(INSTALL) -d $(DESTDIR)$(libdir)/cmake/Gpgmepp
diff --git a/lang/qt/Makefile.am b/lang/qt/Makefile.am
new file mode 100644
index 0000000..7fbaca8
--- /dev/null
+++ b/lang/qt/Makefile.am
@@ -0,0 +1,23 @@
+# Makefile.am for GPGMEPP.
+# Copyright (C) 2016 Intevation GmbH
+#
+# This file is part of GPGMEPP.
+#
+# GPGME-CL is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GPGME-CL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA
+
+SUBDIRS = src
+
+EXTRA_DIST = README
diff --git a/lang/qt/README b/lang/qt/README
new file mode 100644
index 0000000..6aeb876
--- /dev/null
+++ b/lang/qt/README
@@ -0,0 +1,27 @@
+Qt API bindings/wrapper for gpgme
+----------------------------------------
+Based on KF5gpgmepp QGpgme
+
+QGpgme is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+QGpgme is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with GPGME++; see the file COPYING.LIB.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+Overview
+--------
+QGpgme provides Qt API bindings around Gpgmepp. It depends on Gpgmepp.
+
+Currently this is a very thin library that only provides a QByteArray
+and QIODevice dataprovider. But might be extended in the future with
+code that is currently part of KDE's libkleopatra. To provide an easy
+to use API for Qt Applications.
diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
new file mode 100644
index 0000000..54d0530
--- /dev/null
+++ b/lang/qt/src/Makefile.am
@@ -0,0 +1,67 @@
+# Makefile.am for GPGMEPP.
+# Copyright (C) 2016 Intevation GmbH
+#
+# This file is part of GPGMEPP.
+#
+# GPGME-CL is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GPGME-CL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA
+lib_LTLIBRARIES = libqgpgme.la
+EXTRA_DIST = QGpgmeConfig.cmake.in.in QGpgmeConfigVersion.cmake.in
+
+qgpgme_sources = \
+    dataprovider.cpp
+
+qgpgme_headers = \
+    dataprovider.h qgpgme_export.h
+
+qgpgmeincludedir = $(includedir)/qgpgme
+qgpgmeinclude_HEADERS = $(qgpgme_headers)
+
+libqgpgme_la_SOURCES = $(qgpgme_sources) $(qgpgme_headers)
+
+AM_CPPFLAGS = @GPGME_QT_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \
+              -DBUILDING_QGPGME -I$(top_srcdir)/lang/cpp/src
+
+libqgpgme_la_LIBADD = ../../cpp/src/libgpgmepp.la ../../../src/libgpgme.la \
+                       @LIBASSUAN_LIBS@ @GPGME_QT_LIBS@
+libqgpgme_la_LDFLAGS = -version-info \
+    @LIBQGPGME_LT_CURRENT@:@LIBQGPGME_LT_REVISION@:@LIBQGPGME_LT_AGE@
+
+if HAVE_W32_SYSTEM
+libsuffix=.dll.a
+else
+libsuffix=.so
+endif
+
+QGpgmeConfig.cmake: QGpgmeConfig.cmake.in
+	sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" > "$@"
+	sed -e 's|[@]libsuffix@|$(libsuffix)|g' < "$@" > "$@".2
+	mv "$@".2 "$@"
+
+install-cmake-files: QGpgmeConfig.cmake QGpgmeConfigVersion.cmake
+	-$(INSTALL) -d $(DESTDIR)$(libdir)/cmake/Gpgmepp
+	$(INSTALL) QGpgmeConfig.cmake \
+        $(DESTDIR)$(libdir)/cmake/Gpgmepp/QGpgmeConfig.cmake
+	$(INSTALL) QGpgmeConfigVersion.cmake \
+        $(DESTDIR)$(libdir)/cmake/Gpgmepp/QGpgmeConfigVersion.cmake
+
+uninstall-cmake-files:
+	-rm $(DESTDIR)$(libdir)/cmake/Gpgmepp/QGpgmeConfigVersion.cmake
+	-rm $(DESTDIR)$(libdir)/cmake/Gpgmepp/QGpgmeConfig.cmake
+	-rmdir $(DESTDIR)$(libdir)/cmake/Gpgmepp/
+
+install-data-local: install-cmake-files
+
+uninstall-local: uninstall-cmake-files
diff --git a/lang/cpp/src/GpgmeppConfig.cmake.in.in b/lang/qt/src/QGpgmeConfig.cmake.in.in
similarity index 84%
copy from lang/cpp/src/GpgmeppConfig.cmake.in.in
copy to lang/qt/src/QGpgmeConfig.cmake.in.in
index 4b5b905..36ee920 100644
--- a/lang/cpp/src/GpgmeppConfig.cmake.in.in
+++ b/lang/qt/src/QGpgmeConfig.cmake.in.in
@@ -1,7 +1,7 @@
-# CMake Config file for GPGMEPP.
+# CMake Config file for QGPGME.
 # Copyright (C) 2016 Intevation GmbH
 #
-# This file is part of GPGMEPP.
+# This file is part of GPGME.
 #
 # GPGME-CL is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
 set(_targetsDefined)
 set(_targetsNotDefined)
 set(_expectedTargets)
-foreach(_expectedTarget KF5::Gpgmepp KF5::QGpgme)
+foreach(_expectedTarget QGpgme KF5::QGpgme)
   list(APPEND _expectedTargets ${_expectedTarget})
   if(NOT TARGET ${_expectedTarget})
     list(APPEND _targetsNotDefined ${_expectedTarget})
@@ -64,22 +64,14 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
 get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
 get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
 
-# Create imported target Gpgmepp
-add_library(Gpgmepp SHARED IMPORTED)
-
-set_target_properties(Gpgmepp PROPERTIES
-  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/gpgme++"
-  INTERFACE_LINK_LIBRARIES "@libdir@/libgpgme.dll.a;@LIBASSUAN_LIBS@;@GPG_ERROR_LIBS@"
-)
-
 # Create imported target QGpgme
-#add_library(QGpgme SHARED IMPORTED)
+add_library(QGpgme SHARED IMPORTED)
 
-#set_target_properties(KF5::QGpgme PROPERTIES
-#   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/qgpgme"
-   #  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX} TODO"
-#  INTERFACE_LINK_LIBRARIES "Qt5::Core"
-#)
+set_target_properties(QGpgme PROPERTIES
+  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/qgpgme"
+  INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt5::Core"
+  IMPORTED_LOCATION "@resolved_libdir@/libqgpgme at libsuffix@"
+)
 
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
   message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
diff --git a/lang/qt/src/QGpgmeConfigVersion.cmake.in b/lang/qt/src/QGpgmeConfigVersion.cmake.in
new file mode 100644
index 0000000..04a12cb
--- /dev/null
+++ b/lang/qt/src/QGpgmeConfigVersion.cmake.in
@@ -0,0 +1,31 @@
+# CMake Version file for QGPGME.
+# Copyright (C) 2016 Intevation GmbH
+#
+# This file is part of GPGME.
+#
+# GPGME-CL is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GPGME-CL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA
+
+# based on a generated file from cmake.
+set(PACKAGE_VERSION "@LIBQGPGME_LT_CURRENT at .@LIBQGPGME_LT_AGE at .@LIBQGPGME_LT_REVISION at .@BUILD_REVISION@")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/lang/qt/src/dataprovider.cpp b/lang/qt/src/dataprovider.cpp
new file mode 100644
index 0000000..8893877
--- /dev/null
+++ b/lang/qt/src/dataprovider.cpp
@@ -0,0 +1,281 @@
+/* dataprovider.cpp
+   Copyright (C) 2004 Klar�vdalens Datakonsult AB
+
+   This file is part of QGPGME.
+
+   QGPGME is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   QGPGME is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with QGPGME; see the file COPYING.LIB.  If not, write to the
+   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA. */
+
+// -*- c++ -*-
+
+#include <dataprovider.h>
+
+#include <error.h>
+
+#include <QIODevice>
+#include <QProcess>
+
+#include <cstdio>
+#include <cstring>
+#include <cassert>
+
+using namespace QGpgME;
+using namespace GpgME;
+
+//
+//
+// QByteArrayDataProvider
+//
+//
+
+static bool resizeAndInit(QByteArray &ba, size_t newSize)
+{
+    const size_t oldSize = ba.size();
+    ba.resize(newSize);
+    const bool ok = (newSize == static_cast<size_t>(ba.size()));
+    if (ok) {
+        memset(ba.data() + oldSize, 0, newSize - oldSize);
+    }
+    return ok;
+}
+
+QByteArrayDataProvider::QByteArrayDataProvider()
+    : GpgME::DataProvider(), mOff(0) {}
+
+QByteArrayDataProvider::QByteArrayDataProvider(const QByteArray &initialData)
+    : GpgME::DataProvider(), mArray(initialData), mOff(0) {}
+
+QByteArrayDataProvider::~QByteArrayDataProvider() {}
+
+ssize_t QByteArrayDataProvider::read(void *buffer, size_t bufSize)
+{
+#ifndef NDEBUG
+    //qDebug( "QByteArrayDataProvider::read( %p, %d )", buffer, bufSize );
+#endif
+    if (bufSize == 0) {
+        return 0;
+    }
+    if (!buffer) {
+        Error::setSystemError(GPG_ERR_EINVAL);
+        return -1;
+    }
+    if (mOff >= mArray.size()) {
+        return 0; // EOF
+    }
+    size_t amount = qMin(bufSize, static_cast<size_t>(mArray.size() - mOff));
+    assert(amount > 0);
+    memcpy(buffer, mArray.data() + mOff, amount);
+    mOff += amount;
+    return amount;
+}
+
+ssize_t QByteArrayDataProvider::write(const void *buffer, size_t bufSize)
+{
+#ifndef NDEBUG
+    //qDebug( "QByteArrayDataProvider::write( %p, %lu )", buffer, static_cast<unsigned long>( bufSize ) );
+#endif
+    if (bufSize == 0) {
+        return 0;
+    }
+    if (!buffer) {
+        Error::setSystemError(GPG_ERR_EINVAL);
+        return -1;
+    }
+    if (mOff >= mArray.size()) {
+        resizeAndInit(mArray, mOff + bufSize);
+    }
+    if (mOff >= mArray.size()) {
+        Error::setSystemError(GPG_ERR_EIO);
+        return -1;
+    }
+    assert(bufSize <= static_cast<size_t>(mArray.size()) - mOff);
+    memcpy(mArray.data() + mOff, buffer, bufSize);
+    mOff += bufSize;
+    return bufSize;
+}
+
+off_t QByteArrayDataProvider::seek(off_t offset, int whence)
+{
+#ifndef NDEBUG
+    //qDebug( "QByteArrayDataProvider::seek( %d, %d )", int(offset), whence );
+#endif
+    int newOffset = mOff;
+    switch (whence) {
+    case SEEK_SET:
+        newOffset = offset;
+        break;
+    case SEEK_CUR:
+        newOffset += offset;
+        break;
+    case SEEK_END:
+        newOffset = mArray.size() + offset;
+        break;
+    default:
+        Error::setSystemError(GPG_ERR_EINVAL);
+        return (off_t) - 1;
+    }
+    return mOff = newOffset;
+}
+
+void QByteArrayDataProvider::release()
+{
+#ifndef NDEBUG
+    //qDebug( "QByteArrayDataProvider::release()" );
+#endif
+    mArray = QByteArray();
+}
+
+//
+//
+// QIODeviceDataProvider
+//
+//
+
+QIODeviceDataProvider::QIODeviceDataProvider(const boost::shared_ptr<QIODevice> &io)
+    : GpgME::DataProvider(),
+      mIO(io),
+      mErrorOccurred(false),
+      mHaveQProcess(qobject_cast<QProcess *>(io.get()))
+{
+    assert(mIO);
+}
+
+QIODeviceDataProvider::~QIODeviceDataProvider() {}
+
+bool QIODeviceDataProvider::isSupported(Operation op) const
+{
+    const QProcess *const proc = qobject_cast<QProcess *>(mIO.get());
+    bool canRead = true;
+    if (proc) {
+        canRead = proc->readChannel() == QProcess::StandardOutput;
+    }
+
+    switch (op) {
+    case Read:    return mIO->isReadable() && canRead;
+    case Write:   return mIO->isWritable();
+    case Seek:    return !mIO->isSequential();
+    case Release: return true;
+    default:      return false;
+    }
+}
+
+static qint64 blocking_read(const boost::shared_ptr<QIODevice> &io, char *buffer, qint64 maxSize)
+{
+    while (!io->bytesAvailable()) {
+        if (!io->waitForReadyRead(-1)) {
+            if (const QProcess *const p = qobject_cast<QProcess *>(io.get())) {
+                if (p->error() == QProcess::UnknownError &&
+                        p->exitStatus() == QProcess::NormalExit &&
+                        p->exitCode() == 0) {
+                    return 0;
+                } else {
+                    Error::setSystemError(GPG_ERR_EIO);
+                    return -1;
+                }
+            } else {
+                return 0; // assume EOF (loses error cases :/ )
+            }
+        }
+    }
+    return io->read(buffer, maxSize);
+}
+
+ssize_t QIODeviceDataProvider::read(void *buffer, size_t bufSize)
+{
+#ifndef NDEBUG
+    //qDebug( "QIODeviceDataProvider::read( %p, %lu )", buffer, bufSize );
+#endif
+    if (bufSize == 0) {
+        return 0;
+    }
+    if (!buffer) {
+        Error::setSystemError(GPG_ERR_EINVAL);
+        return -1;
+    }
+    const qint64 numRead = mHaveQProcess
+                           ? blocking_read(mIO, static_cast<char *>(buffer), bufSize)
+                           : mIO->read(static_cast<char *>(buffer), bufSize);
+
+    //workaround: some QIODevices (known example: QProcess) might not return 0 (EOF), but immediately -1 when finished. If no
+    //errno is set, gpgme doesn't detect the error and loops forever. So return 0 on the very first -1 in case errno is 0
+
+    ssize_t rc = numRead;
+    if (numRead < 0 && !Error::hasSystemError()) {
+        if (mErrorOccurred) {
+            Error::setSystemError(GPG_ERR_EIO);
+        } else {
+            rc = 0;
+        }
+    }
+    if (numRead < 0) {
+        mErrorOccurred = true;
+    }
+    return rc;
+}
+
+ssize_t QIODeviceDataProvider::write(const void *buffer, size_t bufSize)
+{
+#ifndef NDEBUG
+    //qDebug( "QIODeviceDataProvider::write( %p, %lu )", buffer, static_cast<unsigned long>( bufSize ) );
+#endif
+    if (bufSize == 0) {
+        return 0;
+    }
+    if (!buffer) {
+        Error::setSystemError(GPG_ERR_EINVAL);
+        return -1;
+    }
+
+    return mIO->write(static_cast<const char *>(buffer), bufSize);
+}
+
+off_t QIODeviceDataProvider::seek(off_t offset, int whence)
+{
+#ifndef NDEBUG
+    //qDebug( "QIODeviceDataProvider::seek( %d, %d )", int(offset), whence );
+#endif
+    if (mIO->isSequential()) {
+        Error::setSystemError(GPG_ERR_ESPIPE);
+        return (off_t) - 1;
+    }
+    qint64 newOffset = mIO->pos();
+    switch (whence) {
+    case SEEK_SET:
+        newOffset = offset;
+        break;
+    case SEEK_CUR:
+        newOffset += offset;
+        break;
+    case SEEK_END:
+        newOffset = mIO->size() + offset;
+        break;
+    default:
+        Error::setSystemError(GPG_ERR_EINVAL);
+        return (off_t) - 1;
+    }
+    if (!mIO->seek(newOffset)) {
+        Error::setSystemError(GPG_ERR_EINVAL);
+        return (off_t) - 1;
+    }
+    return newOffset;
+}
+
+void QIODeviceDataProvider::release()
+{
+#ifndef NDEBUG
+    //qDebug( "QIODeviceDataProvider::release()" );
+#endif
+    mIO->close();
+}
diff --git a/lang/qt/src/dataprovider.h b/lang/qt/src/dataprovider.h
new file mode 100644
index 0000000..8bc0c85
--- /dev/null
+++ b/lang/qt/src/dataprovider.h
@@ -0,0 +1,104 @@
+/* dataprovider.h
+   Copyright (C) 2004 Klarälvdalens Datakonsult AB
+
+   This file is part of QGPGME.
+
+   QGPGME is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   QGPGME is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with QGPGME; see the file COPYING.LIB.  If not, write to the
+   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA. */
+
+// -*- c++ -*-
+#ifndef __QGPGME_DATAPROVIDER_H__
+#define __QGPGME_DATAPROVIDER_H__
+
+#include "qgpgme_export.h"
+#include <interfaces/dataprovider.h>
+
+#include <QtCore/QByteArray>
+
+#include <boost/shared_ptr.hpp>
+
+class QIODevice;
+
+namespace QGpgME
+{
+
+class QGPGME_EXPORT QByteArrayDataProvider : public GpgME::DataProvider
+{
+public:
+    QByteArrayDataProvider();
+    explicit QByteArrayDataProvider(const QByteArray &initialData);
+    ~QByteArrayDataProvider();
+
+    const QByteArray &data() const
+    {
+        return mArray;
+    }
+
+private:
+    // these shall only be accessed through the dataprovider
+    // interface, where they're public:
+    /*! \reimp */
+    bool isSupported(Operation) const
+    {
+        return true;
+    }
+    /*! \reimp */
+    ssize_t read(void *buffer, size_t bufSize);
+    /*! \reimp */
+    ssize_t write(const void *buffer, size_t bufSize);
+    /*! \reimp */
+    off_t seek(off_t offset, int whence);
+    /*! \reimp */
+    void release();
+
+private:
+    QByteArray mArray;
+    off_t mOff;
+};
+
+class QGPGME_EXPORT QIODeviceDataProvider : public GpgME::DataProvider
+{
+public:
+    explicit QIODeviceDataProvider(const boost::shared_ptr<QIODevice> &initialData);
+    ~QIODeviceDataProvider();
+
+    const boost::shared_ptr<QIODevice> &ioDevice() const
+    {
+        return mIO;
+    }
+
+private:
+    // these shall only be accessed through the dataprovider
+    // interface, where they're public:
+    /*! \reimp */
+    bool isSupported(Operation) const;
+    /*! \reimp */
+    ssize_t read(void *buffer, size_t bufSize);
+    /*! \reimp */
+    ssize_t write(const void *buffer, size_t bufSize);
+    /*! \reimp */
+    off_t seek(off_t offset, int whence);
+    /*! \reimp */
+    void release();
+
+private:
+    const boost::shared_ptr<QIODevice> mIO;
+    bool mErrorOccurred : 1;
+    bool mHaveQProcess  : 1;
+};
+
+} // namespace QGpgME
+
+#endif
diff --git a/lang/qt/src/qgpgme_export.h b/lang/qt/src/qgpgme_export.h
new file mode 100644
index 0000000..40630d5
--- /dev/null
+++ b/lang/qt/src/qgpgme_export.h
@@ -0,0 +1,53 @@
+
+#ifndef QGPGME_EXPORT_H
+#define QGPGME_EXPORT_H
+
+#ifdef QGPGME_STATIC_DEFINE
+#  define QGPGME_EXPORT
+#  define QGPGME_NO_EXPORT
+#else
+#  ifndef QGPGME_EXPORT
+#    ifdef BUILDING_QGPGME
+        /* We are building this library */
+#      ifdef WIN32
+#       define QGPGME_EXPORT __declspec(dllexport)
+#      else
+#       define QGPGME_EXPORT __attribute__((visibility("default")))
+#      endif
+#    else
+        /* We are using this library */
+#      ifdef WIN32
+#       define QGPGME_EXPORT __declspec(dllimport)
+#      else
+#       define QGPGME_EXPORT __attribute__((visibility("default")))
+#      endif
+#    endif
+#  endif
+
+#  ifndef QGPGME_NO_EXPORT
+#    ifdef WIN32
+#     define QGPGME_NO_EXPORT
+#    else
+#     define QGPGME_NO_EXPORT __attribute__((visibility("hidden")))
+#    endif
+#  endif
+#endif
+
+#ifndef QGPGME_DEPRECATED
+#  define QGPGME_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef QGPGME_DEPRECATED_EXPORT
+#  define QGPGME_DEPRECATED_EXPORT QGPGME_EXPORT QGPGME_DEPRECATED
+#endif
+
+#ifndef QGPGME_DEPRECATED_NO_EXPORT
+#  define QGPGME_DEPRECATED_NO_EXPORT QGPGME_NO_EXPORT QGPGME_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define QGPGME_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/m4/qt.m4 b/m4/qt.m4
new file mode 100644
index 0000000..80e2245
--- /dev/null
+++ b/m4/qt.m4
@@ -0,0 +1,51 @@
+dnl qt.m4
+dnl Copyright (C) 2016 Intevation GmbH
+dnl
+dnl This file is part of gpgme and is provided under the same license as gpgme
+
+dnl Autoconf macro to find either Qt4 or Qt5
+dnl
+dnl sets GPGME_QT_LIBS and GPGME_QT_CFLAGS
+dnl
+dnl if QT5 was found have_qt5_libs is set to yes
+
+AC_DEFUN([FIND_QT],
+[
+  have_qt5_libs="no";
+
+  PKG_CHECK_MODULES(GPGME_QT,
+                    Qt5Core >= 5.0.0,
+                    [have_qt5_libs="yes"],
+                    [have_qt5_libs="no"])
+
+  if "$PKG_CONFIG" --variable qt_config Qt5Core | grep -q "reduce_relocations"; then
+    GPGME_QT_CFLAGS="$GPGME_QT_CFLAGS -fpic"
+  fi
+  if test "$have_qt5_libs" = "yes"; then
+    AC_CHECK_TOOL(MOC, moc)
+    AC_MSG_CHECKING([moc version])
+    mocversion=`$MOC -v 2>&1`
+    mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"`
+    if test x"$mocversiongrep" != x"$mocversion"; then
+      AC_MSG_RESULT([no])
+      # moc was not the qt5 one, try with moc-qt5
+      AC_CHECK_TOOL(MOC2, moc-qt5)
+      mocversion=`$MOC2 -v 2>&1`
+      mocversiongrep=`echo $mocversion | grep "Qt 5\|moc-qt5 5\|moc 5"`
+      if test x"$mocversiongrep" != x"$mocversion"; then
+        AC_CHECK_TOOL(QTCHOOSER, qtchooser)
+        qt5tooldir=`QT_SELECT=qt5 qtchooser -print-env | grep QTTOOLDIR | cut -d '=' -f 2 | cut -d \" -f 2`
+        mocversion=`$qt5tooldir/moc -v 2>&1`
+        mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"`
+        if test x"$mocversiongrep" != x"$mocversion"; then
+          # no valid moc found
+          have_qt5_libs="no";
+        else
+          MOC=$qt5tooldir/moc
+        fi
+      else
+        MOC=$MOC2
+      fi
+    fi
+  fi
+])

commit 58ed9c17f00f420035ecc6973a6c6ed948757a9a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Mar 3 12:46:53 2016 +0100

    Remove obsolete w32-qt code
    
    * configure.ac (w32-qt): Remove option and Qt checks.
    * src/Makefile.am: Remove BUILD_W32_QT handling.
    * src/kdpipeiodevice.cpp,
     src/kdpipeiodevice.h,
     src/kdpipeiodevice.moc,
     src/w32-qt-io.cpp: Removed.
    
    --
    This code was intended for Kleopatra but Kleopatra is not using
    it anymore. QGpgme/dataprovider is a better replacement for this.

diff --git a/configure.ac b/configure.ac
index 5aad9f4..c3a46ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,20 +180,9 @@ case "${host}" in
 	AC_ARG_ENABLE(w32-glib,
 	    AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]),
 	    		   build_w32_glib=$enableval)
-
-	# Check disabled, because the qt-dev packages in gpg4win do
-	# not provide any support for cross compilation.
-	# PKG_CHECK_MODULES(QT4_CORE, QtCore)
-
-	# Use it like this:
-	# ./configure --enable-w32-qt QT4_CORE_CFLAGS="..." QT4_CORE_LIBS="..."
-	AC_SUBST(QT4_CORE_CFLAGS)
-	AC_SUBST(QT4_CORE_LIBS)
-	AC_ARG_ENABLE(w32-qt,
-	    AC_HELP_STRING([--enable-w32-qt], [build GPGME Qt for W32]),
-	    		   build_w32_qt=$enableval)
-        ;;
+       ;;
     *)
+
 	AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
 	if test "$have_pthread" = yes; then
 	  AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
@@ -239,7 +228,6 @@ fi
 AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)
 
 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
-AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
 
 AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 698c632..951fc00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,12 +41,6 @@ else
 ltlib_gpgme_glib =
 endif
 
-if BUILD_W32_QT
-ltlib_gpgme_qt = libgpgme-qt.la
-else
-ltlib_gpgme_qt =
-endif
-
 lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib) $(ltlib_gpgme_qt) \
 	$(ltlib_gpgme_pthread)
 
@@ -110,23 +104,9 @@ if BUILD_W32_GLIB
 libgpgme_glib_la_SOURCES = $(main_sources) ath.h ath.c w32-glib-io.c
 endif
 
-if BUILD_W32_QT
-libgpgme_qt_la_SOURCES = $(main_sources) ath.h ath.c w32-qt-io.cpp \
-	kdpipeiodevice.h kdpipeiodevice.cpp kdpipeiodevice.moc
-# FIXME: Add extra depedency: moc_kdpipeiodevice.cpp
-
-# These are built sources (normally).
-# moc_kdpipeiodevice.cpp: kdpipeiodevice.h
-#	$(MOC4) -o $@ $<
-#
-# kdpipeiodevice.moc: kdpipeiodevice.cpp
-#	$(MOC4) -o $@ $<
-endif
-
-# We use a global CFLAGS and CPPFLAGS setting for all library
+# We use a global CFLAGS setting for all library
 # versions, because then every object file is only compiled once.
-AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ @QT4_CORE_CFLAGS@
-AM_CFLAGS = @LIBASSUAN_CFLAGS@ @GLIB_CFLAGS@ @QT4_CORE_CFLAGS@
+AM_CFLAGS = @LIBASSUAN_CFLAGS@ @GLIB_CFLAGS@
 
 gpgme_tool_SOURCES = gpgme-tool.c argparse.c argparse.h
 gpgme_tool_LDADD = libgpgme.la @LIBASSUAN_LIBS@
@@ -202,15 +182,6 @@ libgpgme_glib_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
 	@GPG_ERROR_LIBS@ @GLIB_LIBS@
 endif
 
-if BUILD_W32_QT
-libgpgme_qt_la_LDFLAGS = $(no_undefined) \
-	$(export_symbols) $(libgpgme_version_script_cmd) -version-info \
-	@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
-libgpgme_qt_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps)
-libgpgme_qt_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \
-	@GPG_ERROR_LIBS@ @QT4_CORE_LIBS@
-endif
-
 install-data-local: install-def-file
 
 uninstall-local: uninstall-def-file
diff --git a/src/kdpipeiodevice.cpp b/src/kdpipeiodevice.cpp
deleted file mode 100644
index 5661790..0000000
--- a/src/kdpipeiodevice.cpp
+++ /dev/null
@@ -1,951 +0,0 @@
-/*
-  Copyright (C) 2007 Klarälvdalens Datakonsult AB
-
-  KDPipeIODevice is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Library General Public
-  License as published by the Free Software Foundation; either
-  version 2 of the License, or (at your option) any later version.
-
-  KDPipeIODevice is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU Library General Public License for more details.
-
-  You should have received a copy of the GNU Library General Public License
-  along with KDPipeIODevice; see the file COPYING.LIB.  If not, write to the
-  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-*/
-
-#include "kdpipeiodevice.h"
-
-#include <QtCore>
-
-#include <cassert>
-#include <memory>
-#include <algorithm>
-
-#ifdef Q_OS_WIN32
-# ifndef NOMINMAX
-#  define NOMINMAX
-# endif
-# include <windows.h>
-# include <io.h>
-#else
-# include <unistd.h>
-# include <errno.h>
-#endif
-
-using namespace _gpgme_;
-
-#ifndef KDAB_CHECK_THIS
-# define KDAB_CHECK_CTOR (void)1
-# define KDAB_CHECK_DTOR KDAB_CHECK_CTOR
-# define KDAB_CHECK_THIS KDAB_CHECK_CTOR
-#endif
-
-#define LOCKED( d ) const QMutexLocker locker( &d->mutex )
-#define synchronized( d ) if ( int i = 0 ) {} else for ( const QMutexLocker locker( &d->mutex ) ; !i ; ++i )
-
-const unsigned int BUFFER_SIZE = 4096;
-const bool ALLOW_QIODEVICE_BUFFERING = true;
-
-// comment to get trace output:
-//#define qDebug if(1){}else qDebug
-
-namespace {
-class Reader : public QThread {
-    Q_OBJECT
-public:
-    Reader( int fd, Qt::HANDLE handle );
-    ~Reader();
-
-    qint64 readData( char * data, qint64 maxSize );
-
-    unsigned int bytesInBuffer() const {
-        return ( wptr + sizeof buffer - rptr ) % sizeof buffer ;
-    }
-
-    bool bufferFull() const {
-        return bytesInBuffer() == sizeof buffer - 1;
-    }
-
-    bool bufferEmpty() const {
-	return bytesInBuffer() == 0;
-    }
-
-    bool bufferContains( char ch ) {
-	const unsigned int bib = bytesInBuffer();
-	for ( unsigned int i = rptr ; i < rptr + bib ; ++i )
-	    if ( buffer[i%sizeof buffer] == ch )
-		return true;
-	return false;
-    }
-        
-    void notifyReadyRead();
-
-Q_SIGNALS:
-    void readyRead();
-
-protected:
-    /* reimp */ void run();
-
-private:
-    int fd;
-    Qt::HANDLE handle;
-public:
-    QMutex mutex;
-    QWaitCondition waitForCancelCondition;
-    QWaitCondition bufferNotFullCondition;
-    QWaitCondition bufferNotEmptyCondition;
-    QWaitCondition hasStarted;
-    QWaitCondition readyReadSentCondition;
-    QWaitCondition blockedConsumerIsDoneCondition;
-    bool cancel;
-    bool eof;
-    bool error;
-    bool eofShortCut;
-    int errorCode;
-    bool isReading;
-    bool consumerBlocksOnUs;
-   
-private:
-    unsigned int rptr, wptr;
-    char buffer[BUFFER_SIZE+1]; // need to keep one byte free to detect empty state
-};
-
-
-Reader::Reader( int fd_, Qt::HANDLE handle_ )
-    : QThread(),
-      fd( fd_ ),
-      handle( handle_ ),
-      mutex(),
-      bufferNotFullCondition(),
-      bufferNotEmptyCondition(),
-      hasStarted(),
-      cancel( false ),
-      eof( false ),
-      error( false ),
-      eofShortCut( false ),
-      errorCode( 0 ),
-      isReading( false ),
-      consumerBlocksOnUs( false ),
-      rptr( 0 ), wptr( 0 )
-{
-    
-}
-
-Reader::~Reader() {}
-
-
-class Writer : public QThread {
-    Q_OBJECT
-public:
-    Writer( int fd, Qt::HANDLE handle );
-    ~Writer();
-
-    qint64 writeData( const char * data, qint64 size );
-
-    unsigned int bytesInBuffer() const { return numBytesInBuffer; }
-
-    bool bufferFull() const {
-        return numBytesInBuffer == sizeof buffer;
-    }
-
-    bool bufferEmpty() const {
-	return numBytesInBuffer == 0;
-    }
-
-Q_SIGNALS:
-    void bytesWritten( qint64 );
-
-protected:
-    /* reimp */ void run();
-
-private:
-    int fd;
-    Qt::HANDLE handle;
-public:
-    QMutex mutex;
-    QWaitCondition bufferEmptyCondition;
-    QWaitCondition bufferNotEmptyCondition;
-    QWaitCondition hasStarted;
-    bool cancel;
-    bool error;
-    int errorCode;
-private:
-    unsigned int numBytesInBuffer;
-    char buffer[BUFFER_SIZE];
-};
-}
-
-Writer::Writer( int fd_, Qt::HANDLE handle_ )
-    : QThread(),
-      fd( fd_ ),
-      handle( handle_ ),
-      mutex(),
-      bufferEmptyCondition(),
-      bufferNotEmptyCondition(),
-      hasStarted(),
-      cancel( false ),
-      error( false ),
-      errorCode( 0 ),
-      numBytesInBuffer( 0 )
-{
-
-}
-
-Writer::~Writer() {}
-
-
-class KDPipeIODevice::Private : public QObject {
-Q_OBJECT
-    friend class ::KDPipeIODevice;
-    KDPipeIODevice * const q;
-public:
-    explicit Private( KDPipeIODevice * qq );
-    ~Private();
-
-    bool doOpen( int, Qt::HANDLE, OpenMode );
-    bool startReaderThread(); 
-    bool startWriterThread(); 
-    void stopThreads();
-
-public Q_SLOTS:
-    void emitReadyRead();
- 
-private:
-    int fd;
-    Qt::HANDLE handle;
-    Reader * reader;
-    Writer * writer;
-    bool triedToStartReader;
-    bool triedToStartWriter;
-};
-
-KDPipeIODevice::Private::Private( KDPipeIODevice * qq )
-    : QObject( qq ), q( qq ),
-      fd( -1 ),
-      handle( 0 ),
-      reader( 0 ),
-      writer( 0 ),
-      triedToStartReader( false ), triedToStartWriter( false ) 
-{
-
-}
-
-KDPipeIODevice::Private::~Private() {
-    qDebug( "KDPipeIODevice::~Private(): Destroying %p", q );
-}
-
-KDPipeIODevice::KDPipeIODevice( QObject * p )
-    : QIODevice( p ), d( new Private( this ) )
-{
-    KDAB_CHECK_CTOR;
-}
-
-KDPipeIODevice::KDPipeIODevice( int fd, OpenMode mode, QObject * p )
-    : QIODevice( p ), d( new Private( this ) )
-{
-    KDAB_CHECK_CTOR;
-    open( fd, mode );
-}
-
-KDPipeIODevice::KDPipeIODevice( Qt::HANDLE handle, OpenMode mode, QObject * p )
-    : QIODevice( p ), d( new Private( this ) )
-{
-    KDAB_CHECK_CTOR;
-    open( handle, mode );
-}
-
-KDPipeIODevice::~KDPipeIODevice() { KDAB_CHECK_DTOR;
-    if ( isOpen() )
-	close();
-    delete d; d = 0;
-}
-
-
-bool KDPipeIODevice::open( int fd, OpenMode mode ) { KDAB_CHECK_THIS;
-
-#ifdef Q_OS_WIN32
-    return d->doOpen( fd, (HANDLE)_get_osfhandle( fd ), mode );
-#else
-    return d->doOpen( fd, 0, mode );
-#endif
-
-}
-
-bool KDPipeIODevice::open( Qt::HANDLE h, OpenMode mode ) { KDAB_CHECK_THIS;
-
-#ifdef Q_OS_WIN32
-    return d->doOpen( -1, h, mode );
-#else
-    Q_UNUSED( h );
-    Q_UNUSED( mode );
-    assert( !"KDPipeIODevice::open( Qt::HANDLE, OpenMode ) should never be called except on Windows." );
-#endif
-
-}
-
-bool KDPipeIODevice::Private::startReaderThread()
-{
-   if ( triedToStartReader )
-       return true;
-   triedToStartReader = true;    
-   if ( reader && !reader->isRunning() && !reader->isFinished() ) {
-       qDebug("KDPipeIODevice::Private::startReaderThread(): locking reader (CONSUMER THREAD)" );
-       LOCKED( reader );
-       qDebug("KDPipeIODevice::Private::startReaderThread(): locked reader (CONSUMER THREAD)" );
-       reader->start( QThread::HighestPriority );
-       qDebug("KDPipeIODevice::Private::startReaderThread(): waiting for hasStarted (CONSUMER THREAD)" );
-       const bool hasStarted = reader->hasStarted.wait( &reader->mutex, 1000 );
-       qDebug("KDPipeIODevice::Private::startReaderThread(): returned from hasStarted (CONSUMER THREAD)" );
-
-       return hasStarted;
-   }
-   return true;
-}
-
-bool KDPipeIODevice::Private::startWriterThread()
-{
-   if ( triedToStartWriter )
-       return true;
-   triedToStartWriter = true;    
-   if ( writer && !writer->isRunning() && !writer->isFinished() ) {
-       LOCKED( writer );
-       
-       writer->start( QThread::HighestPriority );
-       if ( !writer->hasStarted.wait( &writer->mutex, 1000 ) )
-            return false;
-   }
-   return true;
-}
-
-void KDPipeIODevice::Private::emitReadyRead()
-{
-    QPointer<Private> thisPointer( this );
-    qDebug( "KDPipeIODevice::Private::emitReadyRead %p", this );
-
-    emit q->readyRead();
-
-    if ( !thisPointer )
-        return;
-
-    bool mustNotify = false;
-
-    if ( reader ) {
-        qDebug( "KDPipeIODevice::Private::emitReadyRead %p: locking reader (CONSUMER THREAD)", this );
-        synchronized( reader ) {
-            qDebug( "KDPipeIODevice::Private::emitReadyRead %p: locked reader (CONSUMER THREAD)", this );
-            reader->readyReadSentCondition.wakeAll();
-            mustNotify = !reader->bufferEmpty() && reader->isReading;
-            qDebug( "KDPipeIODevice::emitReadyRead %p: bufferEmpty: %d reader in ReadFile: %d", this, reader->bufferEmpty(), reader->isReading );
-        }
-    }
-    if ( mustNotify )
-        QTimer::singleShot( 100, this, SLOT( emitReadyRead() ) );  
-    qDebug( "KDPipeIODevice::Private::emitReadyRead %p leaving", this );
-
-}
-
-bool KDPipeIODevice::Private::doOpen( int fd_, Qt::HANDLE handle_, OpenMode mode_ ) {
-
-    if ( q->isOpen() )
-	return false;
-
-#ifdef Q_OS_WIN32
-    if ( !handle_ )
-	return false;
-#else
-    if ( fd_ < 0 )
-	return false;
-#endif
-
-    if ( !(mode_ & ReadWrite) )
-	return false; // need to have at least read -or- write
-
-
-    std::auto_ptr<Reader> reader_;
-    std::auto_ptr<Writer> writer_;
-
-    if ( mode_ & ReadOnly ) {
-	reader_.reset( new Reader( fd_, handle_ ) );
-        qDebug( "KDPipeIODevice::doOpen (%p): created reader (%p) for fd %d", this, reader_.get(), fd_ ); 
-	connect( reader_.get(), SIGNAL(readyRead()), this, SLOT(emitReadyRead()), 
-Qt::QueuedConnection );
-    }
-    if ( mode_ & WriteOnly ) {
-	writer_.reset( new Writer( fd_, handle_ ) );
-        qDebug( "KDPipeIODevice::doOpen (%p): created writer (%p) for fd %d", this, writer_.get(), fd_ ); 
-        connect( writer_.get(), SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)), 
-Qt::QueuedConnection );
-    }
-
-    // commit to *this:
-    fd = fd_;
-    handle = handle_;
-    reader = reader_.release();
-    writer = writer_.release();
-
-    q->setOpenMode( mode_|Unbuffered );
-    return true;
-}
-
-int KDPipeIODevice::descriptor() const { KDAB_CHECK_THIS;
-    return d->fd;
-}
-
-
-Qt::HANDLE KDPipeIODevice::handle() const { KDAB_CHECK_THIS;
-    return d->handle;
-}
-
-qint64 KDPipeIODevice::bytesAvailable() const { KDAB_CHECK_THIS;
-    const qint64 base = QIODevice::bytesAvailable();
-    if ( !d->triedToStartReader ) {
-         d->startReaderThread();
-         return base;
-    }
-    if ( d->reader )
-	synchronized( d->reader ) {
-            const qint64 inBuffer = d->reader->bytesInBuffer();     
-            return base + inBuffer;
-       }
-    return base;
-}
-
-qint64 KDPipeIODevice::bytesToWrite() const { KDAB_CHECK_THIS;
-    d->startWriterThread();
-    const qint64 base = QIODevice::bytesToWrite();
-    if ( d->writer )
-	synchronized( d->writer ) return base + d->writer->bytesInBuffer();
-    return base;
-}
-
-bool KDPipeIODevice::canReadLine() const { KDAB_CHECK_THIS;
-    d->startReaderThread();
-   if ( QIODevice::canReadLine() )
-	return true;
-    if ( d->reader )
-	synchronized( d->reader ) return d->reader->bufferContains( '\n' );
-    return true;
-}
-
-bool KDPipeIODevice::isSequential() const {
-    return true;
-}
-
-bool KDPipeIODevice::atEnd() const { KDAB_CHECK_THIS;
-    d->startReaderThread();
-    if ( !QIODevice::atEnd() ) {
-	qDebug( "%p: KDPipeIODevice::atEnd returns false since QIODevice::atEnd does (with bytesAvailable=%ld)", this, static_cast<long>(bytesAvailable()) );
-	return false;
-    }
-    if ( !isOpen() )
-	return true;
-    if ( d->reader->eofShortCut )
-	return true;
-    LOCKED( d->reader );
-    const bool eof = ( d->reader->error || d->reader->eof ) && d->reader->bufferEmpty();
-    if ( !eof ) {
-	if ( !d->reader->error && !d->reader->eof )
-	    qDebug( "%p: KDPipeIODevice::atEnd returns false since !reader->error && !reader->eof", this );
-	if ( !d->reader->bufferEmpty() )
-	    qDebug( "%p: KDPipeIODevice::atEnd returns false since !reader->bufferEmpty()", this );
-    }
-    return eof;
-}
-
-bool KDPipeIODevice::waitForBytesWritten( int msecs ) { KDAB_CHECK_THIS;
-    d->startWriterThread();
-    Writer * const w = d->writer;
-    if ( !w )
-	return true;
-    LOCKED( w );
-    qDebug( "KDPipeIODevice::waitForBytesWritten (%p,w=%p): entered locked area", this, w 
-); 
-    return w->bufferEmpty() || w->error || w->bufferEmptyCondition.wait( &w->mutex, msecs ) ;
-}
-
-bool KDPipeIODevice::waitForReadyRead( int msecs ) { KDAB_CHECK_THIS;
-    qDebug( "KDPipeIODEvice::waitForReadyRead()(%p)", this);
-    d->startReaderThread();
-    if ( ALLOW_QIODEVICE_BUFFERING ) {
-	if ( bytesAvailable() > 0 )
-	    return true;
-    }
-    Reader * const r = d->reader;
-    if ( !r || r->eofShortCut )
-	return true;
-    LOCKED( r );
-    if ( r->bytesInBuffer() != 0 || r->eof || r->error )
-        return true;
-
-    return msecs >= 0 ? r->bufferNotEmptyCondition.wait( &r->mutex, msecs ) : r->bufferNotEmptyCondition.wait( &r->mutex );
-}
-
-template <typename T>
-class TemporaryValue {
-public:
-   TemporaryValue( T& var_, const T& tv ) : var( var_ ), oldValue( var_ ) { var = tv; }
-   ~TemporaryValue() { var = oldValue; }
-private:   
-   T& var;
-   const T oldValue;
-}; 
-
-
-bool KDPipeIODevice::readWouldBlock() const
-{
-   d->startReaderThread();
-   LOCKED( d->reader );
-   return d->reader->bufferEmpty() && !d->reader->eof && !d->reader->error;
-}  
-
-bool KDPipeIODevice::writeWouldBlock() const
-{
-   d->startWriterThread();
-   LOCKED( d->writer );
-   return !d->writer->bufferEmpty() && !d->writer->error;
-}  
-
-
-qint64 KDPipeIODevice::readData( char * data, qint64 maxSize ) { KDAB_CHECK_THIS;
-    qDebug( "%p: KDPipeIODevice::readData: data=%p, maxSize=%lld", this, data, maxSize );
-    d->startReaderThread();
-    Reader * const r = d->reader;
-
-    assert( r );
-
-
-    //assert( r->isRunning() ); // wrong (might be eof, error)
-    assert( data || maxSize == 0 );
-    assert( maxSize >= 0 );
-
-    if ( r->eofShortCut ) {
-	qDebug( "%p: KDPipeIODevice::readData: hit eofShortCut, returning 0", this );
-	return 0;
-    }
-
-    if ( maxSize < 0 )
-	maxSize = 0;
-
-    if ( ALLOW_QIODEVICE_BUFFERING ) {
-	if ( bytesAvailable() > 0 )
-	    maxSize = std::min( maxSize, bytesAvailable() ); // don't block
-    }
-    qDebug( "%p: KDPipeIODevice::readData: try to lock reader (CONSUMER THREAD)", this );
-    LOCKED( r );
-    qDebug( "%p: KDPipeIODevice::readData: locked reader (CONSUMER THREAD)", this );
-
-    r->readyReadSentCondition.wakeAll();
-    if ( /* maxSize > 0 && */ r->bufferEmpty() &&  !r->error && !r->eof ) { // ### block on maxSize == 0?
-	qDebug( "%p: KDPipeIODevice::readData: waiting for bufferNotEmptyCondition (CONSUMER THREAD)", this );
-        const TemporaryValue<bool> tmp( d->reader->consumerBlocksOnUs, true );
-	r->bufferNotEmptyCondition.wait( &r->mutex );
-        r->blockedConsumerIsDoneCondition.wakeAll();
-	qDebug( "%p: KDPipeIODevice::readData: woke up from bufferNotEmptyCondition (CONSUMER THREAD)", this ); 
-    }
-
-    if ( r->bufferEmpty() ) {
-	qDebug( "%p: KDPipeIODevice::readData: got empty buffer, signal eof", this );
-	// woken with an empty buffer must mean either EOF or error:
-	assert( r->eof || r->error );
-	r->eofShortCut = true;
-	return r->eof ? 0 : -1 ;
-    }
-
-    qDebug( "%p: KDPipeIODevice::readData: got bufferNotEmptyCondition, trying to read %lld bytes", this, maxSize );
-    const qint64 bytesRead = r->readData( data, maxSize );
-    qDebug( "%p: KDPipeIODevice::readData: read %lld bytes", this, bytesRead );
-    qDebug( "%p (fd=%d): KDPipeIODevice::readData: %s", this, d->fd, data );
- 
-    return bytesRead;
-}
-
-qint64 Reader::readData( char * data, qint64 maxSize ) {
-    qint64 numRead = rptr < wptr ? wptr - rptr : sizeof buffer - rptr ;
-    if ( numRead > maxSize )
-	numRead = maxSize;
-
-    qDebug( "%p: KDPipeIODevice::readData: data=%p, maxSize=%lld; rptr=%u, wptr=%u (bytesInBuffer=%u); -> numRead=%lld", this,
-	    data, maxSize, rptr, wptr, bytesInBuffer(), numRead );
-
-    std::memcpy( data, buffer + rptr, numRead );
-
-    rptr = ( rptr + numRead ) % sizeof buffer ;
-
-    if ( !bufferFull() ) {
-	qDebug( "%p: KDPipeIODevice::readData: signal bufferNotFullCondition", this );
-	bufferNotFullCondition.wakeAll();
-    }
-
-    return numRead;
-}
-
-qint64 KDPipeIODevice::writeData( const char * data, qint64 size ) { KDAB_CHECK_THIS;
-    d->startWriterThread();
-    Writer * const w = d->writer;
-
-    assert( w );
-    assert( w->error || w->isRunning() );
-    assert( data || size == 0 );
-    assert( size >= 0 );
-
-    LOCKED( w );
-
-    while ( !w->error && !w->bufferEmpty() ) { 
-	qDebug( "%p: KDPipeIODevice::writeData: wait for empty buffer", this );
-	w->bufferEmptyCondition.wait( &w->mutex );
-	qDebug( "%p: KDPipeIODevice::writeData: empty buffer signaled", this );
-
-    }
-    if ( w->error )
-	return -1;
-
-    assert( w->bufferEmpty() );
-
-    return w->writeData( data, size );
-}
-
-qint64 Writer::writeData( const char * data, qint64 size ) {
-    assert( bufferEmpty() );
-
-    if ( size > static_cast<qint64>( sizeof buffer ) )
-	size = sizeof buffer;
-
-    std::memcpy( buffer, data, size );
-    
-    numBytesInBuffer = size;
-
-    if ( !bufferEmpty() ) {
-	bufferNotEmptyCondition.wakeAll();
-    }
-   return size;
-}
-
-void KDPipeIODevice::Private::stopThreads()
-{
-    if ( triedToStartWriter )
-    {
-        if ( writer && q->bytesToWrite() > 0 )
-	    q->waitForBytesWritten( -1 );
-
-        assert( q->bytesToWrite() == 0 );
-    }
-    if ( Reader * & r = reader ) {
-        disconnect( r, SIGNAL( readyRead() ), this, SLOT( emitReadyRead() ) ); 
-	synchronized( r ) {
-	    // tell thread to cancel:
-	    r->cancel = true;
-	    // and wake it, so it can terminate:
-            r->waitForCancelCondition.wakeAll();
-	    r->bufferNotFullCondition.wakeAll();
-            r->readyReadSentCondition.wakeAll();
-      	}
-    }
-    if ( Writer * & w = writer ) {
-	synchronized( w ) {
-	    // tell thread to cancel:
-	    w->cancel = true;
-	    // and wake it, so it can terminate:
-	    w->bufferNotEmptyCondition.wakeAll();
-	}
-    }
-}
-
-void KDPipeIODevice::close() { KDAB_CHECK_THIS;
-    qDebug( "KDPipeIODevice::close(%p)", this );
-    if ( !isOpen() )
-	return;
-
-    // tell clients we're about to close:
-    emit aboutToClose();
-    d->stopThreads();
-
-#define waitAndDelete( t ) if ( t ) { t->wait(); QThread* const t2 = t; t = 0; delete t2; }
-    qDebug( "KPipeIODevice::close(%p): wait and closing writer %p", this, d->writer );
-    waitAndDelete( d->writer );
-    qDebug( "KPipeIODevice::close(%p): wait and closing reader %p", this, d->reader );
-    if ( d->reader ) {
-        LOCKED( d->reader );
-        d->reader->readyReadSentCondition.wakeAll();
-    }
-    waitAndDelete( d->reader );
-#undef waitAndDelete
-#ifdef Q_OS_WIN32
-    if ( d->fd != -1 )
-        _close( d->fd );
-    else
-        CloseHandle( d->handle );
-#else
-    ::close( d->fd );
-#endif
-
-    setOpenMode( NotOpen );
-    d->fd = -1;
-    d->handle = 0;
-}
-
-void Reader::run() {
-
-    LOCKED( this );
-
-    // too bad QThread doesn't have that itself; a signal isn't enough
-    hasStarted.wakeAll();
-
-    qDebug( "%p: Reader::run: started", this );
-
-    while ( true ) {
-        if ( !cancel && ( eof || error ) ) {
-            //notify the client until the buffer is empty and then once 
-            //again so he receives eof/error. After that, wait for him 
-            //to cancel 
-            const bool wasEmpty = bufferEmpty();
-	    qDebug( "%p: Reader::run: received eof(%d) or error(%d), waking everyone", this, eof, error );
-            notifyReadyRead();
-            if ( !cancel && wasEmpty ) 
-                waitForCancelCondition.wait( &mutex );
-        } else if ( !cancel && !bufferFull() && !bufferEmpty() ) {
-	    qDebug( "%p: Reader::run: buffer no longer empty, waking everyone", this );
-            notifyReadyRead();
-        } 
- 
-        while ( !cancel && !error && bufferFull() ) {
-            notifyReadyRead();
-            if ( !cancel && bufferFull() ) {
-                qDebug( "%p: Reader::run: buffer is full, going to sleep", this );
-	        bufferNotFullCondition.wait( &mutex );
-	    }
-        }
-        
-	if ( cancel ) {
-            qDebug( "%p: Reader::run: detected cancel", this );
-	    goto leave;
-	}
-
-        if ( !eof && !error ) {
-            if ( rptr == wptr ) // optimize for larger chunks in case the buffer is empty
-	        rptr = wptr = 0;
-
-            unsigned int numBytes = ( rptr + sizeof buffer - wptr - 1 ) % sizeof buffer;
-	    if ( numBytes > sizeof buffer - wptr )
-	        numBytes = sizeof buffer - wptr;
-
-	    qDebug( "%p: Reader::run: rptr=%d, wptr=%d -> numBytes=%d", this, rptr, wptr, numBytes );
-
-	    assert( numBytes > 0 );
-
-	    qDebug( "%p: Reader::run: trying to read %d bytes", this, numBytes );
-#ifdef Q_OS_WIN32
-            isReading = true;
-	    mutex.unlock();
-            DWORD numRead;
-	    const bool ok = ReadFile( handle, buffer + wptr, numBytes, &numRead, 0 );
-	    mutex.lock();
-            isReading = false;
-	    if ( ok ) {
-                if ( numRead == 0 ) {
-                    qDebug( "%p: Reader::run: got eof (numRead==0)", this );
-                    eof = true;
-                } 
-            } else { // !ok
-	        errorCode = static_cast<int>( GetLastError() );
-	        if ( errorCode == ERROR_BROKEN_PIPE ) {
-                    assert( numRead == 0 );
-                    qDebug( "%p: Reader::run: got eof (broken pipe)", this );
-		    eof = true;
-	        } else {
-                    assert( numRead == 0 );
-		    qDebug( "%p: Reader::run: got error: %s (%d)", this, strerror( errorCode ), errorCode );
-		    error = true;
-	        }
-	    }
-#else
-	    qint64 numRead;
-	    mutex.unlock();
-	    do {
-	        numRead = ::read( fd, buffer + wptr, numBytes );
-	    } while ( numRead == -1 && errno == EINTR );
-	    mutex.lock();
-
-	    if ( numRead < 0 ) {
-	        errorCode = errno;
-	        error = true;
-	        qDebug( "%p: Reader::run: got error: %d", this, errorCode );
-            } else if ( numRead == 0 ) {
-	        qDebug( "%p: Reader::run: eof detected", this );  
-                eof = true;
-            }
-#endif
-	    qDebug( "%p: Reader::run: read %ld bytes", this, static_cast<long>(numRead) );
-	    qDebug( "%p: Reader::run(fd=%d): %s", this, fd, buffer );
-
-	    if ( numRead > 0 ) {
-	        qDebug( "%p: Reader::run: buffer before: rptr=%4d, wptr=%4d", this, rptr, wptr );
-	        wptr = ( wptr + numRead ) % sizeof buffer;
-	        qDebug( "%p: Reader::run: buffer after:  rptr=%4d, wptr=%4d", this, rptr, wptr );
-            }
-        }
-    }
- leave:
-    qDebug( "%p: Reader::run: terminated", this );
-}
-
-void Reader::notifyReadyRead()
-{
-    qDebug( "notifyReadyRead: %d bytes available", bytesInBuffer() );
-    assert( !cancel );
-
-    if ( consumerBlocksOnUs ) {
-        bufferNotEmptyCondition.wakeAll();
-        blockedConsumerIsDoneCondition.wait( &mutex );
-        return;
-    }
-    qDebug( "notifyReadyRead: emit signal" );
-    emit readyRead();
-    readyReadSentCondition.wait( &mutex );
-    qDebug( "notifyReadyRead: returning from waiting, leave" );
-}
-
-void Writer::run() {
-
-    LOCKED( this );
-
-    // too bad QThread doesn't have that itself; a signal isn't enough
-    hasStarted.wakeAll();
-
-    qDebug( "%p: Writer::run: started", this );
-
-    while ( true ) {
-
-	while ( !cancel && bufferEmpty() ) {
-	    qDebug( "%p: Writer::run: buffer is empty, wake bufferEmptyCond listeners", this );
-            bufferEmptyCondition.wakeAll();
-            emit bytesWritten( 0 );
-	    qDebug( "%p: Writer::run: buffer is empty, going to sleep", this );
-            bufferNotEmptyCondition.wait( &mutex );
-	    qDebug( "%p: Writer::run: woke up", this );
-	}
-
-	if ( cancel ) {
-	    qDebug( "%p: Writer::run: detected cancel", this );
-	    goto leave;
-	}
-
-	assert( numBytesInBuffer > 0 );
-
-	qDebug( "%p: Writer::run: Trying to write %u bytes", this, numBytesInBuffer );
-	qint64 totalWritten = 0;
-	do {  
-            mutex.unlock();
-#ifdef Q_OS_WIN32
-            DWORD numWritten;
-            qDebug( "%p (fd=%d): Writer::run: buffer before WriteFile (numBytes=%lld): %s:", this, fd, numBytesInBuffer, buffer ); 
-            qDebug( "%p (fd=%d): Writer::run: Going into WriteFile", this, fd );
-	    if ( !WriteFile( handle, buffer + totalWritten, numBytesInBuffer - totalWritten, &numWritten, 0 ) ) {
-		mutex.lock();
-		errorCode = static_cast<int>( GetLastError() );
-		qDebug( "%p: Writer::run: got error code: %d", this, errorCode );
-		error = true;
-                goto leave;
-	    }
-#else
-	    qint64 numWritten;
-	    do {
-		numWritten = ::write( fd, buffer + totalWritten, numBytesInBuffer - totalWritten );
-	    } while ( numWritten == -1 && errno == EINTR );
-
-	    if ( numWritten < 0 ) {
-	        mutex.lock();
-		errorCode = errno;
-		qDebug( "%p: Writer::run: got error code: %d", this, errorCode );
-		error = true;
-                goto leave;
-	    }
-#endif
-            qDebug( "%p (fd=%d): Writer::run: buffer after WriteFile (numBytes=%u): %s:", this, fd, numBytesInBuffer, buffer );
-	    totalWritten += numWritten;
-            mutex.lock();
-	} while ( totalWritten < numBytesInBuffer );
-
-	qDebug( "%p: Writer::run: wrote %lld bytes", this, totalWritten );
-
-	numBytesInBuffer = 0;
-
-	qDebug( "%p: Writer::run: buffer is empty, wake bufferEmptyCond listeners", this );
-	bufferEmptyCondition.wakeAll();
-	emit bytesWritten( totalWritten );
-    }
- leave:
-    qDebug( "%p: Writer::run: terminating", this );
-    numBytesInBuffer = 0;
-    qDebug( "%p: Writer::run: buffer is empty, wake bufferEmptyCond listeners", this );
-    bufferEmptyCondition.wakeAll();
-    emit bytesWritten( 0 );
-}
-
-// static 
-std::pair<KDPipeIODevice*,KDPipeIODevice*> KDPipeIODevice::makePairOfConnectedPipes() {
-    KDPipeIODevice * read = 0;
-    KDPipeIODevice * write = 0;
-#ifdef Q_OS_WIN32
-    HANDLE rh;
-    HANDLE wh;
-    SECURITY_ATTRIBUTES sa;
-    memset( &sa, 0, sizeof(sa) );
-    sa.nLength = sizeof(sa);
-    sa.bInheritHandle = TRUE;
-	if ( CreatePipe( &rh, &wh, &sa, BUFFER_SIZE ) ) {
-	read = new KDPipeIODevice;
-	read->open( rh, ReadOnly );
-	write = new KDPipeIODevice;
-	write->open( wh, WriteOnly );
-    }
-#else
-    int fds[2];
-    if ( pipe( fds ) == 0 ) {
-	read = new KDPipeIODevice;
-	read->open( fds[0], ReadOnly );
-	write = new KDPipeIODevice;
-	write->open( fds[1], WriteOnly );
-    }
-#endif
-    return std::make_pair( read, write );
-}
-
-#ifdef KDAB_DEFINE_CHECKS
-KDAB_DEFINE_CHECKS( KDPipeIODevice ) {
-    if ( !isOpen() ) {
-	assert( openMode() == NotOpen );
-	assert( !d->reader );
-	assert( !d->writer );
-#ifdef Q_OS_WIN32
-	assert( !d->handle );
-#else
-	assert( d->fd < 0 );
-#endif
-    } else {
-	assert( openMode() != NotOpen );
-	assert( openMode() & ReadWrite );
-	if ( openMode() & ReadOnly ) {
-	    assert( d->reader );
-	    synchronized( d->reader )
-		assert( d->reader->eof || d->reader->error || d->reader->isRunning() );
-	}
-	if ( openMode() & WriteOnly ) {
-	    assert( d->writer );
-	    synchronized( d->writer )
-		assert( d->writer->error || d->writer->isRunning() );
-	}
-#ifdef Q_OS_WIN32
-	assert( d->handle );
-#else
-	assert( d->fd >= 0 );
-#endif
-    }
-}
-#endif // KDAB_DEFINE_CHECKS
-
-#include "moc_kdpipeiodevice.cpp"
-#include "kdpipeiodevice.moc"
diff --git a/src/kdpipeiodevice.h b/src/kdpipeiodevice.h
deleted file mode 100644
index 8da6af6..0000000
--- a/src/kdpipeiodevice.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-  Copyright (C) 2007 Klarälvdalens Datakonsult AB
-
-  KDPipeIODevice is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Library General Public
-  License as published by the Free Software Foundation; either
-  version 2 of the License, or (at your option) any later version.
-
-  KDPipeIODevice is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU Library General Public License for more details.
-
-  You should have received a copy of the GNU Library General Public License
-  along with KDPipeIODevice; see the file COPYING.LIB.  If not, write to the
-  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-*/
-
-#ifndef __KDTOOLSCORE_KDPIPEIODEVICE_H__
-#define __KDTOOLSCORE_KDPIPEIODEVICE_H__
-
-#include <QIODevice>
-
-#include <utility>
-
-//#include "checker.h"
-
-namespace _gpgme_ {
-
-class KDPipeIODevice : public QIODevice {
-    Q_OBJECT
-    //KDAB_MAKE_CHECKABLE( KDPipeIODevice )
-public:
-    explicit KDPipeIODevice( QObject * parent=0 );
-    explicit KDPipeIODevice( int fd, OpenMode=ReadOnly, QObject * parent=0 );
-    explicit KDPipeIODevice( Qt::HANDLE handle, OpenMode=ReadOnly, QObject * parent=0 );
-    ~KDPipeIODevice();
-
-    static std::pair<KDPipeIODevice*, KDPipeIODevice*> makePairOfConnectedPipes();
-
-    bool open( int fd, OpenMode mode=ReadOnly );
-    bool open( Qt::HANDLE handle, OpenMode mode=ReadOnly );
-
-    Qt::HANDLE handle() const;
-    int descriptor() const;
-
-    bool readWouldBlock() const;
-    bool writeWouldBlock() const;
-
-    /* reimp */ qint64 bytesAvailable() const;
-    /* reimp */ qint64 bytesToWrite() const;
-    /* reimp */ bool canReadLine() const;
-    /* reimp */ void close();
-    /* reimp */ bool isSequential() const;
-    /* reimp */ bool atEnd() const;
-
-    /* reimp */ bool waitForBytesWritten( int msecs );
-    /* reimp */ bool waitForReadyRead( int msecs );
-
-protected:
-    /* reimp */ qint64 readData( char * data, qint64 maxSize );
-    /* reimp */ qint64 writeData( const char * data, qint64 maxSize );
-
-private:
-    class Private;
-    Private * d;
-};
-
-} /* namespace _gpgme_ */
-
-#endif /* __KDTOOLSCORE_KDPIPEIODEVICE_H__ */
-
diff --git a/src/kdpipeiodevice.moc b/src/kdpipeiodevice.moc
deleted file mode 100644
index 457f371..0000000
--- a/src/kdpipeiodevice.moc
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-** Meta object code from reading C++ file 'kdpipeiodevice.cpp'
-**
-** Created: Tue Oct 2 19:30:13 2007
-**      by: The Qt Meta Object Compiler version 59 (Qt 4.3.1)
-**
-** WARNING! All changes made in this file will be lost!
-*****************************************************************************/
-
-#if !defined(Q_MOC_OUTPUT_REVISION)
-#error "The header file 'kdpipeiodevice.cpp' doesn't include <QObject>."
-#elif Q_MOC_OUTPUT_REVISION != 59
-#error "This file was generated using the moc from 4.3.1. It"
-#error "cannot be used with the include files from this version of Qt."
-#error "(The moc has changed too much.)"
-#endif
-
-static const uint qt_meta_data_Reader[] = {
-
- // content:
-       1,       // revision
-       0,       // classname
-       0,    0, // classinfo
-       1,   10, // methods
-       0,    0, // properties
-       0,    0, // enums/sets
-
- // signals: signature, parameters, type, tag, flags
-       8,    7,    7,    7, 0x05,
-
-       0        // eod
-};
-
-static const char qt_meta_stringdata_Reader[] = {
-    "Reader\0\0readyRead()\0"
-};
-
-const QMetaObject Reader::staticMetaObject = {
-    { &QThread::staticMetaObject, qt_meta_stringdata_Reader,
-      qt_meta_data_Reader, 0 }
-};
-
-const QMetaObject *Reader::metaObject() const
-{
-    return &staticMetaObject;
-}
-
-void *Reader::qt_metacast(const char *_clname)
-{
-    if (!_clname) return 0;
-    if (!strcmp(_clname, qt_meta_stringdata_Reader))
-	return static_cast<void*>(const_cast< Reader*>(this));
-    return QThread::qt_metacast(_clname);
-}
-
-int Reader::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
-{
-    _id = QThread::qt_metacall(_c, _id, _a);
-    if (_id < 0)
-        return _id;
-    if (_c == QMetaObject::InvokeMetaMethod) {
-        switch (_id) {
-        case 0: readyRead(); break;
-        }
-        _id -= 1;
-    }
-    return _id;
-}
-
-// SIGNAL 0
-void Reader::readyRead()
-{
-    QMetaObject::activate(this, &staticMetaObject, 0, 0);
-}
-static const uint qt_meta_data_Writer[] = {
-
- // content:
-       1,       // revision
-       0,       // classname
-       0,    0, // classinfo
-       1,   10, // methods
-       0,    0, // properties
-       0,    0, // enums/sets
-
- // signals: signature, parameters, type, tag, flags
-       8,    7,    7,    7, 0x05,
-
-       0        // eod
-};
-
-static const char qt_meta_stringdata_Writer[] = {
-    "Writer\0\0bytesWritten(qint64)\0"
-};
-
-const QMetaObject Writer::staticMetaObject = {
-    { &QThread::staticMetaObject, qt_meta_stringdata_Writer,
-      qt_meta_data_Writer, 0 }
-};
-
-const QMetaObject *Writer::metaObject() const
-{
-    return &staticMetaObject;
-}
-
-void *Writer::qt_metacast(const char *_clname)
-{
-    if (!_clname) return 0;
-    if (!strcmp(_clname, qt_meta_stringdata_Writer))
-	return static_cast<void*>(const_cast< Writer*>(this));
-    return QThread::qt_metacast(_clname);
-}
-
-int Writer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
-{
-    _id = QThread::qt_metacall(_c, _id, _a);
-    if (_id < 0)
-        return _id;
-    if (_c == QMetaObject::InvokeMetaMethod) {
-        switch (_id) {
-        case 0: bytesWritten((*reinterpret_cast< qint64(*)>(_a[1]))); break;
-        }
-        _id -= 1;
-    }
-    return _id;
-}
-
-// SIGNAL 0
-void Writer::bytesWritten(qint64 _t1)
-{
-    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
-    QMetaObject::activate(this, &staticMetaObject, 0, _a);
-}
-static const uint qt_meta_data_KDPipeIODevice__Private[] = {
-
- // content:
-       1,       // revision
-       0,       // classname
-       0,    0, // classinfo
-       1,   10, // methods
-       0,    0, // properties
-       0,    0, // enums/sets
-
- // slots: signature, parameters, type, tag, flags
-      25,   24,   24,   24, 0x0a,
-
-       0        // eod
-};
-
-static const char qt_meta_stringdata_KDPipeIODevice__Private[] = {
-    "KDPipeIODevice::Private\0\0emitReadyRead()\0"
-};
-
-const QMetaObject KDPipeIODevice::Private::staticMetaObject = {
-    { &QObject::staticMetaObject, qt_meta_stringdata_KDPipeIODevice__Private,
-      qt_meta_data_KDPipeIODevice__Private, 0 }
-};
-
-const QMetaObject *KDPipeIODevice::Private::metaObject() const
-{
-    return &staticMetaObject;
-}
-
-void *KDPipeIODevice::Private::qt_metacast(const char *_clname)
-{
-    if (!_clname) return 0;
-    if (!strcmp(_clname, qt_meta_stringdata_KDPipeIODevice__Private))
-	return static_cast<void*>(const_cast< Private*>(this));
-    return QObject::qt_metacast(_clname);
-}
-
-int KDPipeIODevice::Private::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
-{
-    _id = QObject::qt_metacall(_c, _id, _a);
-    if (_id < 0)
-        return _id;
-    if (_c == QMetaObject::InvokeMetaMethod) {
-        switch (_id) {
-        case 0: emitReadyRead(); break;
-        }
-        _id -= 1;
-    }
-    return _id;
-}
diff --git a/src/w32-qt-io.cpp b/src/w32-qt-io.cpp
deleted file mode 100644
index 44655ec..0000000
--- a/src/w32-qt-io.cpp
+++ /dev/null
@@ -1,700 +0,0 @@
-/* w32-qt-io.c - W32 Glib I/O functions
-   Copyright (C) 2000 Werner Koch (dd9jn)
-   Copyright (C) 2001, 2002, 2004, 2005, 2007 g10 Code GmbH
-
-   This file is part of GPGME.
-
-   GPGME is free software; you can redistribute it and/or modify it
-   under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of
-   the License, or (at your option) any later version.
-
-   GPGME is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <windows.h>
-#include <io.h>
-
-#include "kdpipeiodevice.h"
-
-extern "C"
-{
-#include "util.h"
-#include "priv-io.h"
-#include "sema.h"
-#include "debug.h"
-}
-
-#ifndef O_BINARY
-#ifdef _O_BINARY
-#define O_BINARY	_O_BINARY
-#else
-#define O_BINARY	0
-#endif
-#endif
-
-using _gpgme_::KDPipeIODevice;
-
-
-/* This file is an ugly hack to get GPGME working with Qt on Windows
-   targets.  On Windows, you can not select() on file descriptors.
-
-   The only way to check if there is something to read is to read
-   something.  This means that GPGME can not let Qt check for data
-   without letting Qt also handle the data on Windows targets.
-
-   The ugly consequence is that we need to work on QIODevices in
-   GPGME, creating a Qt dependency.  Also, we need to export an
-   interface for the application to get at GPGME's QIODevices.  There
-   is no good way to abstract all this with callbacks, because the
-   whole thing is also interconnected with the creation of pipes and
-   child processes.
-
-   The following rule applies only to this I/O backend:
-
-   * ALL operations must use the user defined event loop.  GPGME can
-   not anymore provide its own event loop.  This is mostly a sanity
-   requirement: Although we have in theory all information we need to
-   make the GPGME W32 code for select still work, it would be a big
-   complication and require changes throughout GPGME.
-
-   Eventually, we probably have to bite the bullet and make some
-   really nice callback interfaces to let the user control all this at
-   a per-context level.  */
-
-#define MAX_SLAFD 1024
-
-struct DeviceEntry {
-  DeviceEntry() : iodev( 0 ), refCount( 1 ), blocking( true ) {}
-    KDPipeIODevice* iodev;
-    bool blocking;
-    mutable int refCount;
-    void ref() const { ++refCount; }
-    int unref() const { assert( refCount > 0 ); return --refCount; }
-};
-
-DeviceEntry* iodevice_table[MAX_SLAFD];
-
-
-static KDPipeIODevice *
-find_channel (int fd, int create)
-{
-  assert( fd < MAX_SLAFD );
-  if (fd < 0 || fd >= MAX_SLAFD)
-    return NULL;
-
-  if (create && !iodevice_table[fd])
-  {
-    DeviceEntry* entry = new DeviceEntry;
-    entry->iodev = new KDPipeIODevice
-      (fd, QIODevice::ReadWrite|QIODevice::Unbuffered);
-    iodevice_table[fd] = entry;
-  }
-  return iodevice_table[fd] ? iodevice_table[fd]->iodev : 0;
-}
-
-/* Write the printable version of FD to the buffer BUF of length
-   BUFLEN.  The printable version is the representation on the command
-   line that the child process expects.  */
-int
-_gpgme_io_fd2str (char *buf, int buflen, int fd)
-{
-  return snprintf (buf, buflen, "%d", (long)_get_osfhandle( fd ) );
-}
-
-
-void
-_gpgme_io_subsystem_init (void)
-{
-}
-
-
-static struct
-{
-  _gpgme_close_notify_handler_t handler;
-  void *value;
-} notify_table[MAX_SLAFD];
-
-
-int
-_gpgme_io_read (int fd, void *buffer, size_t count)
-{
-  int saved_errno = 0;
-  qint64 nread;
-  KDPipeIODevice *chan;
-  TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_read", fd,
-	      "buffer=%p, count=%u", buffer, count);
-
-  chan = find_channel (fd, 0);
-  if (!chan)
-    {
-      TRACE_LOG ("no channel registered");
-      errno = EINVAL;
-      return TRACE_SYSRES (-1);
-    }
-  TRACE_LOG1 ("channel %p", chan);
-  if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->readWouldBlock() ) {
-      errno = EAGAIN;
-      return TRACE_SYSRES( -1 );
-  }
-
-  nread = chan->read ((char *) buffer, count);
-  if (nread < 0)
-    {
-      TRACE_LOG1 ("err %s", qPrintable (chan->errorString ()));
-      saved_errno = EIO;
-      nread = -1;
-    }
-
-  TRACE_LOGBUF ((char *) buffer, nread);
-
-  errno = saved_errno;
-  return TRACE_SYSRES (nread);
-}
-
-
-int
-_gpgme_io_write (int fd, const void *buffer, size_t count)
-{
-  qint64 nwritten;
-  KDPipeIODevice *chan;
-  TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd,
-	      "buffer=%p, count=%u", buffer, count);
-  TRACE_LOGBUF ((char *) buffer, count);
-
-  chan = find_channel (fd, 0);
-  if (!chan)
-    {
-      TRACE_LOG ("fd %d: no channel registered");
-      errno = EINVAL;
-      return -1;
-    }
-
-  if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->writeWouldBlock() )
-  {
-      errno = EAGAIN;
-      return TRACE_SYSRES( -1 );
-  }
-  nwritten = chan->write ((char *) buffer, count);
-
-  if (nwritten < 0)
-    {
-      nwritten = -1;
-      errno = EIO;
-      return TRACE_SYSRES(-1);
-    }
-  errno = 0;
-  return TRACE_SYSRES (nwritten);
-}
-
-
-int
-_gpgme_io_pipe (int filedes[2], int inherit_idx)
-{
-  KDPipeIODevice *chan;
-  TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_pipe", filedes,
-	      "inherit_idx=%i (GPGME uses it for %s)",
-	      inherit_idx, inherit_idx ? "reading" : "writing");
-
-#define PIPEBUF_SIZE  4096
-  if (_pipe (filedes, PIPEBUF_SIZE, O_NOINHERIT | O_BINARY) == -1)
-    return TRACE_SYSRES (-1);
-
-  /* Make one end inheritable. */
-  if (inherit_idx == 0)
-    {
-      int new_read;
-
-      new_read = _dup (filedes[0]);
-      _close (filedes[0]);
-      filedes[0] = new_read;
-
-      if (new_read < 0)
-	{
-	  _close (filedes[1]);
-	  return TRACE_SYSRES (-1);
-	}
-    }
-  else if (inherit_idx == 1)
-    {
-      int new_write;
-
-      new_write = _dup (filedes[1]);
-      _close (filedes[1]);
-      filedes[1] = new_write;
-
-      if (new_write < 0)
-	{
-	  _close (filedes[0]);
-	  return TRACE_SYSRES (-1);
-	}
-    }
-
-  /* Now we have a pipe with the right end inheritable.  The other end
-     should have a giochannel.  */
-
-  chan = find_channel (filedes[1 - inherit_idx], 1);
-
-  if (!chan)
-    {
-      int saved_errno = errno;
-      _close (filedes[0]);
-      _close (filedes[1]);
-      errno = saved_errno;
-      return TRACE_SYSRES (-1);
-    }
-
-  return TRACE_SUC5 ("read=0x%x/%p, write=0x%x/%p, channel=%p",
-	  filedes[0], (HANDLE) _get_osfhandle (filedes[0]),
-	  filedes[1], (HANDLE) _get_osfhandle (filedes[1]),
-	  chan);
-}
-
-int
-_gpgme_io_close (int fd)
-{
-  KDPipeIODevice *chan;
-  TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd);
-
-  if (fd < 0 || fd >= MAX_SLAFD)
-    {
-      errno = EBADF;
-      return TRACE_SYSRES (-1);
-    }
-
-  /* First call the notify handler.  */
-  if (notify_table[fd].handler)
-    {
-      notify_table[fd].handler (fd, notify_table[fd].value);
-      notify_table[fd].handler = NULL;
-      notify_table[fd].value = NULL;
-    }
-
-  /* Then do the close.  */
-
-  DeviceEntry* const entry = iodevice_table[fd];
-  if ( entry ) {
-      if ( entry->unref() == 0 ) {
-          entry->iodev->close();
-          delete entry->iodev;
-          delete entry;
-          iodevice_table[fd] = 0;
-      }
-  } else {
-      _close( fd );
-  }
-
-
-
-  return 0;
-}
-
-
-int
-_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
-			    void *value)
-{
-  TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd,
-	      "close_handler=%p/%p", handler, value);
-
-  assert (fd != -1);
-
-  if (fd < 0 || fd >= (int) DIM (notify_table))
-    {
-      errno = EINVAL;
-      return TRACE_SYSRES (-1);
-    }
-  notify_table[fd].handler = handler;
-  notify_table[fd].value = value;
-  return TRACE_SYSRES (0);
-}
-
-
-int
-_gpgme_io_set_nonblocking (int fd)
-{
-  DeviceEntry* const entry = iodevice_table[fd];
-  assert( entry );
-  entry->blocking = false;
-  TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
-  return TRACE_SYSRES (0);
-}
-
-
-static char *
-build_commandline (char **argv)
-{
-  int i;
-  int n = 0;
-  char *buf;
-  char *p;
-
-  /* We have to quote some things because under Windows the program
-     parses the commandline and does some unquoting.  We enclose the
-     whole argument in double-quotes, and escape literal double-quotes
-     as well as backslashes with a backslash.  We end up with a
-     trailing space at the end of the line, but that is harmless.  */
-  for (i = 0; argv[i]; i++)
-    {
-      p = argv[i];
-      /* The leading double-quote.  */
-      n++;
-      while (*p)
-      {
-	  /* An extra one for each literal that must be escaped.  */
-	  if (*p == '\\' || *p == '"')
-	    n++;
-	  n++;
-	  p++;
-	}
-      /* The trailing double-quote and the delimiter.  */
-      n += 2;
-    }
-  /* And a trailing zero.  */
-  n++;
-
-  buf = p = (char *) malloc (n);
-  if (!buf)
-    return NULL;
-  for (i = 0; argv[i]; i++)
-    {
-      char *argvp = argv[i];
-
-      *(p++) = '"';
-      while (*argvp)
-	{
-	  if (*argvp == '\\' || *argvp == '"')
-	    *(p++) = '\\';
-	  *(p++) = *(argvp++);
-	}
-      *(p++) = '"';
-      *(p++) = ' ';
-    }
-  *(p++) = 0;
-
-  return buf;
-}
-
-
-int
-_gpgme_io_spawn (const char *path, char * const argv[], unsigned int flags,
-		 struct spawn_fd_item_s *fd_list,
-		 void (*atfork) (void *opaque, int reserved),
-		 void *atforkvalue, pid_t *r_pid)
-{
-  SECURITY_ATTRIBUTES sec_attr;
-  PROCESS_INFORMATION pi =
-    {
-      NULL,      /* returns process handle */
-      0,         /* returns primary thread handle */
-      0,         /* returns pid */
-      0         /* returns tid */
-    };
-  STARTUPINFO si;
-  int cr_flags = CREATE_DEFAULT_ERROR_MODE
-    | GetPriorityClass (GetCurrentProcess ());
-  int i;
-  char **args;
-  char *arg_string;
-  /* FIXME.  */
-  int debug_me = 0;
-  int tmp_fd;
-  char *tmp_name;
-
-  TRACE_BEG1 (DEBUG_SYSIO, "_gpgme_io_spawn", path,
-	      "path=%s", path);
-  i = 0;
-  while (argv[i])
-    {
-      TRACE_LOG2 ("argv[%2i] = %s", i, argv[i]);
-      i++;
-    }
-
-  /* We do not inherit any handles by default, and just insert those
-     handles we want the child to have afterwards.  But some handle
-     values occur on the command line, and we need to move
-     stdin/out/err to the right location.  So we use a wrapper program
-     which gets the information from a temporary file.  */
-  if (_gpgme_mkstemp (&tmp_fd, &tmp_name) < 0)
-    {
-      TRACE_LOG1 ("_gpgme_mkstemp failed: %s", strerror (errno));
-      return TRACE_SYSRES (-1);
-    }
-  TRACE_LOG1 ("tmp_name = %s", tmp_name);
-
-  args = (char **) calloc (2 + i + 1, sizeof (*args));
-  args[0] = (char *) _gpgme_get_w32spawn_path ();
-  args[1] = tmp_name;
-  args[2] = const_cast<char *>(path);
-  memcpy (&args[3], &argv[1], i * sizeof (*args));
-
-  memset (&sec_attr, 0, sizeof sec_attr);
-  sec_attr.nLength = sizeof sec_attr;
-  sec_attr.bInheritHandle = FALSE;
-
-  arg_string = build_commandline (args);
-  free (args);
-  if (!arg_string)
-    {
-      close (tmp_fd);
-      DeleteFile (tmp_name);
-      return TRACE_SYSRES (-1);
-    }
-
-  memset (&si, 0, sizeof si);
-  si.cb = sizeof (si);
-  si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
-  si.wShowWindow = debug_me ? SW_SHOW : SW_HIDE;
-  si.hStdInput = INVALID_HANDLE_VALUE;
-  si.hStdOutput = INVALID_HANDLE_VALUE;
-  si.hStdError = INVALID_HANDLE_VALUE;
-
-  cr_flags |= CREATE_SUSPENDED;
-  if ((flags & IOSPAWN_FLAG_DETACHED))
-    cr_flags |= DETACHED_PROCESS;
-  if (!CreateProcessA (_gpgme_get_w32spawn_path (),
-		       arg_string,
-		       &sec_attr,     /* process security attributes */
-		       &sec_attr,     /* thread security attributes */
-		       FALSE,         /* inherit handles */
-		       cr_flags,      /* creation flags */
-		       NULL,          /* environment */
-		       NULL,          /* use current drive/directory */
-		       &si,           /* startup information */
-		       &pi))          /* returns process information */
-    {
-      TRACE_LOG1 ("CreateProcess failed: ec=%d", (int) GetLastError ());
-      free (arg_string);
-      close (tmp_fd);
-      DeleteFile (tmp_name);
-
-      /* FIXME: Should translate the error code.  */
-      errno = EIO;
-      return TRACE_SYSRES (-1);
-    }
-
-  free (arg_string);
-
-  if (flags & IOSPAWN_FLAG_ALLOW_SET_FG)
-    _gpgme_allow_set_foreground_window ((pid_t)pi.dwProcessId);
-
-  /* Insert the inherited handles.  */
-  for (i = 0; fd_list[i].fd != -1; i++)
-    {
-      HANDLE hd;
-
-      if (!DuplicateHandle (GetCurrentProcess(),
-			    (HANDLE) _get_osfhandle (fd_list[i].fd),
-			    pi.hProcess, &hd, 0, TRUE, DUPLICATE_SAME_ACCESS))
-	{
-	  TRACE_LOG1 ("DuplicateHandle failed: ec=%d", (int) GetLastError ());
-	  TerminateProcess (pi.hProcess, 0);
-	  /* Just in case TerminateProcess didn't work, let the
-	     process fail on its own.  */
-	  ResumeThread (pi.hThread);
-	  CloseHandle (pi.hThread);
-	  CloseHandle (pi.hProcess);
-
-	  close (tmp_fd);
-	  DeleteFile (tmp_name);
-
-	  /* FIXME: Should translate the error code.  */
-	  errno = EIO;
-	  return TRACE_SYSRES (-1);
-        }
-      /* Return the child name of this handle.  */
-      fd_list[i].peer_name = (int) hd;
-    }
-
-  /* Write the handle translation information to the temporary
-     file.  */
-  {
-    /* Hold roughly MAX_TRANS quadruplets of 64 bit numbers in hex
-       notation: "0xFEDCBA9876543210" with an extra white space after
-       every quadruplet.  10*(19*4 + 1) - 1 = 769.  This plans ahead
-       for a time when a HANDLE is 64 bit.  */
-#define BUFFER_MAX 800
-    char line[BUFFER_MAX + 1];
-    int res;
-    int written;
-    size_t len;
-
-    if ((flags & IOSPAWN_FLAG_ALLOW_SET_FG))
-      strcpy (line, "~1 \n");
-    else
-      strcpy (line, "\n");
-    for (i = 0; fd_list[i].fd != -1; i++)
-      {
-	/* Strip the newline.  */
-	len = strlen (line) - 1;
-
-	/* Format is: Local name, stdin/stdout/stderr, peer name, argv idx.  */
-	snprintf (&line[len], BUFFER_MAX - len, "0x%x %d 0x%x %d  \n",
-		  fd_list[i].fd, fd_list[i].dup_to,
-		  fd_list[i].peer_name, fd_list[i].arg_loc);
-	/* Rather safe than sorry.  */
-	line[BUFFER_MAX - 1] = '\n';
-	line[BUFFER_MAX] = '\0';
-      }
-    len = strlen (line);
-    written = 0;
-    do
-      {
-	res = write (tmp_fd, &line[written], len - written);
-	if (res > 0)
-	  written += res;
-      }
-    while (res > 0 || (res < 0 && errno == EAGAIN));
-  }
-  close (tmp_fd);
-  /* The temporary file is deleted by the gpgme-w32spawn process
-     (hopefully).  */
-
-  TRACE_LOG4 ("CreateProcess ready: hProcess=%p, hThread=%p, "
-	      "dwProcessID=%d, dwThreadId=%d",
-	      pi.hProcess, pi.hThread,
-	      (int) pi.dwProcessId, (int) pi.dwThreadId);
-
-  if (r_pid)
-    *r_pid = (pid_t)pi.dwProcessId;
-
-  if (ResumeThread (pi.hThread) < 0)
-    TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ());
-
-  if (!CloseHandle (pi.hThread))
-    TRACE_LOG1 ("CloseHandle of thread failed: ec=%d",
-		(int) GetLastError ());
-
-  TRACE_LOG1 ("process=%p", pi.hProcess);
-
-  /* We don't need to wait for the process.  */
-  if (!CloseHandle (pi.hProcess))
-    TRACE_LOG1 ("CloseHandle of process failed: ec=%d",
-		(int) GetLastError ());
-
-  for (i = 0; fd_list[i].fd != -1; i++)
-    _gpgme_io_close (fd_list[i].fd);
-
-  for (i = 0; fd_list[i].fd != -1; i++)
-    if (fd_list[i].dup_to == -1)
-      TRACE_LOG3 ("fd[%i] = 0x%x -> 0x%x", i, fd_list[i].fd,
-		  fd_list[i].peer_name);
-    else
-      TRACE_LOG4 ("fd[%i] = 0x%x -> 0x%x (std%s)", i, fd_list[i].fd,
-		  fd_list[i].peer_name, (fd_list[i].dup_to == 0) ? "in" :
-		  ((fd_list[i].dup_to == 1) ? "out" : "err"));
-
-  return TRACE_SYSRES (0);
-}
-
-
-/* Select on the list of fds.  Returns: -1 = error, 0 = timeout or
-   nothing to select, > 0 = number of signaled fds.  */
-int
-_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
-{
-  /* Use a 1s timeout.  */
-
-  void *dbg_help = NULL;
-  TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds,
-	      "nfds=%u, nonblock=%u", nfds, nonblock);
-
-  int count = 0;
-
-  TRACE_SEQ (dbg_help, "select on [ ");
-  for (int i = 0; i < nfds; i++)
-    {
-      if (fds[i].fd == -1)
-        {
-          fds[i].signaled = 0;
-	}
-      else if (fds[i].for_read )
-      {
-          KDPipeIODevice * const chan = find_channel (fds[i].fd, 0);
-          assert (chan);
-          if ( nonblock )
-              fds[i].signaled = chan->readWouldBlock() ? 0 : 1;
-          else
-              fds[i].signaled = chan->waitForReadyRead( 1000 ) ? 1 : 0;
-	  TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd);
-          if ( fds[i].signaled )
-              count++;
-        }
-      else if (fds[i].for_write)
-        {
-          const KDPipeIODevice * const chan = find_channel (fds[i].fd, 0);
-          assert (chan);
-          fds[i].signaled = nonblock ? ( chan->writeWouldBlock() ? 0 : 1 ) : 1;
-          TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd);
-          if ( fds[i].signaled )
-              count++;
-        }
-    }
-  TRACE_END (dbg_help, "]");
-
-  return TRACE_SYSRES (count);
-}
-
-
-/* Look up the qiodevice for file descriptor FD.  */
-extern "C"
-void *
-gpgme_get_fdptr (int fd)
-{
-  return find_channel (fd, 0);
-}
-
-
-/* Obsolete compatibility interface.  */
-extern "C"
-void *
-gpgme_get_giochannel (int fd)
-{
-  return NULL;
-}
-
-
-int
-_gpgme_io_dup (int fd)
-{
-    assert( iodevice_table[fd] );
-    iodevice_table[fd]->ref();
-    return fd;
-}
-
-
-extern "C"
-int
-_gpgme_io_socket (int domain, int type, int proto)
-{
-  errno = EIO;
-  return -1;
-}
-
-
-extern "C"
-int
-_gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)
-{
-  errno = EIO;
-  return -1;
-}

-----------------------------------------------------------------------

Summary of changes:
 configure.ac                                       |  48 +-
 lang/README                                        |   1 +
 lang/cpp/src/GpgmeppConfig.cmake.in.in             |  21 +-
 lang/cpp/src/Makefile.am                           |   8 +
 lang/{cpp => qt}/Makefile.am                       |   0
 lang/qt/README                                     |  27 +
 lang/qt/src/Makefile.am                            |  67 ++
 .../src/QGpgmeConfig.cmake.in.in}                  |  26 +-
 .../src/QGpgmeConfigVersion.cmake.in}              |   6 +-
 lang/qt/src/dataprovider.cpp                       | 281 ++++++
 lang/qt/src/dataprovider.h                         | 104 +++
 lang/qt/src/qgpgme_export.h                        |  53 ++
 m4/qt.m4                                           |  51 ++
 src/Makefile.am                                    |  33 +-
 src/kdpipeiodevice.cpp                             | 951 ---------------------
 src/kdpipeiodevice.h                               |  73 --
 src/kdpipeiodevice.moc                             | 183 ----
 src/w32-qt-io.cpp                                  | 700 ---------------
 18 files changed, 645 insertions(+), 1988 deletions(-)
 copy lang/{cpp => qt}/Makefile.am (100%)
 create mode 100644 lang/qt/README
 create mode 100644 lang/qt/src/Makefile.am
 copy lang/{cpp/src/GpgmeppConfig.cmake.in.in => qt/src/QGpgmeConfig.cmake.in.in} (84%)
 copy lang/{cpp/src/GpgmeppConfigVersion.cmake.in => qt/src/QGpgmeConfigVersion.cmake.in} (85%)
 create mode 100644 lang/qt/src/dataprovider.cpp
 create mode 100644 lang/qt/src/dataprovider.h
 create mode 100644 lang/qt/src/qgpgme_export.h
 create mode 100644 m4/qt.m4
 delete mode 100644 src/kdpipeiodevice.cpp
 delete mode 100644 src/kdpipeiodevice.h
 delete mode 100644 src/kdpipeiodevice.moc
 delete mode 100644 src/w32-qt-io.cpp


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list