Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 1f2195038b87b91e7102d213eacdb51f > files > 5

kdepim-4.4.11.1-5.fc15.src.rpm

diff -Nur kdepim-4.4.11.1/cmake/modules/FindAssuan2.cmake kdepim-4.4.11.1-kleopatra-libassuan2/cmake/modules/FindAssuan2.cmake
--- kdepim-4.4.11.1/cmake/modules/FindAssuan2.cmake	1970-01-01 01:00:00.000000000 +0100
+++ kdepim-4.4.11.1-kleopatra-libassuan2/cmake/modules/FindAssuan2.cmake	2011-06-13 19:55:16.000000000 +0200
@@ -0,0 +1,251 @@
+# - Try to find the assuan v2 library
+
+# Variables set:
+#  ASSUAN2_{INCLUDES,FOUND,LIBRARIES} will be set for each of the above
+
+# do away with crappy condition repetition on else/endfoo
+set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS_assuan2_saved ${CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS} )
+set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
+
+#if this is built-in, please replace, if it isn't, export into a MacroToBool.cmake of it's own
+macro( macro_bool_to_bool FOUND_VAR )
+  foreach( _current_VAR ${ARGN} )
+    if ( ${FOUND_VAR} )
+      set( ${_current_VAR} TRUE )
+    else()
+      set( ${_current_VAR} FALSE )
+    endif()
+  endforeach()
+endmacro()
+
+include (MacroEnsureVersion)
+
+message( STATUS "In FindAssuan2.cmake" )
+
+if ( WIN32 )
+
+  # On Windows, we don't have a libassuan-config script, so we need to
+  # look for the stuff ourselves:
+
+  # in cmake, AND and OR have the same precedence, there's no
+  # subexpressions, and expressions are evaluated short-circuit'ed
+  # IOW: CMake if() suxx.
+  set( _seem_to_have_cached_assuan2 false )
+  if ( ASSUAN2_INCLUDES )
+    if ( ASSUAN2_VANILLA_LIBRARIES )#OR ASSUAN2_QT_LIBRARIES OR ASSUAN2_GLIB_LIBRARIES )
+      set( _seem_to_have_cached_assuan2 true )
+    endif()
+  endif()
+
+  if ( _seem_to_have_cached_assuan2 )
+
+    macro_bool_to_bool( ASSUAN2_VANILLA_LIBRARIES  ASSUAN2_VANILLA_FOUND )
+    # this would have been preferred:
+    #set( ASSUAN2_*_FOUND macro_bool_to_bool(ASSUAN2_*_LIBRARIES) )
+
+    if ( ASSUAN2_VANILLA_FOUND ) #OR ASSUAN2_GLIB_FOUND OR ASSUAN2_QT_FOUND )
+      set( ASSUAN2_FOUND true )
+    else()
+      set( ASSUAN2_FOUND false )
+    endif()
+
+  else()
+
+    set( ASSUAN2_FOUND         false )
+    set( ASSUAN2_VANILLA_FOUND false )
+    #set( ASSUAN2_GLIB_FOUND    false )
+    #set( ASSUAN2_QT_FOUND      false )
+
+    find_path( ASSUAN2_INCLUDES assuan.h
+      ${CMAKE_INCLUDE_PATH}
+      ${CMAKE_INSTALL_PREFIX}/include
+    )
+
+    find_library( _assuan2_library NAMES assuan assuan0 assuan2 libassuan libassuan0 libassuan2
+      PATHS 
+        ${CMAKE_LIBRARY_PATH}
+        ${CMAKE_INSTALL_PREFIX}/lib
+    )
+
+    find_library( _gpg_error_library     NAMES gpg-error libgpg-error gpg-error-0 libgpg-error-0
+      PATHS 
+        ${CMAKE_LIBRARY_PATH}
+        ${CMAKE_INSTALL_PREFIX}/lib
+    )
+
+    set( ASSUAN2_INCLUDES ${ASSUAN2_INCLUDES} )
+
+    if ( _assuan2_library AND _gpg_error_library )
+      set( ASSUAN2_LIBRARIES ${_assuan2_library} ${_gpg_error_library} ws2_32 )
+      set( ASSUAN2_FOUND             true )
+    endif()
+
+  endif()
+
+  macro_bool_to_01( ASSUAN2_FOUND HAVE_ASSUAN2 )
+
+else() # not WIN32
+
+  # On *nix, we have the libassuan-config script which can tell us all we
+  # need to know:
+
+  # see WIN32 case for an explanation of what this does:
+  set( _seem_to_have_cached_assuan2 false )
+  if ( ASSUAN2_INCLUDES AND ASSUAN2_LIBRARIES )
+    set( _seem_to_have_cached_assuan2 true )
+  endif()
+
+  if ( _seem_to_have_cached_assuan2 )
+
+    set( ASSUAN2_FOUND true )
+
+  else()
+
+    set( ASSUAN2_FOUND         false )
+
+    find_program( _ASSUAN2CONFIG_EXECUTABLE NAMES libassuan-config )
+
+    # if libassuan-config has been found
+    if ( _ASSUAN2CONFIG_EXECUTABLE )
+      
+      message( STATUS "Found libassuan-config at ${_ASSUAN2CONFIG_EXECUTABLE}" )
+
+      exec_program( ${_ASSUAN2CONFIG_EXECUTABLE} ARGS --version OUTPUT_VARIABLE ASSUAN2_VERSION )
+
+      set( _ASSUAN2_MIN_VERSION "2.0.0" )
+      macro_ensure_version( ${_ASSUAN2_MIN_VERSION} ${ASSUAN2_VERSION} _ASSUAN2_INSTALLED_VERSION_OK )
+
+      if ( NOT _ASSUAN2_INSTALLED_VERSION_OK )
+
+        message( STATUS "The installed version of assuan is too old: ${ASSUAN2_VERSION} (required: >= ${_ASSUAN2_MIN_VERSION})" )
+
+      else()
+
+        message( STATUS "Found assuan v${ASSUAN2_VERSION}" )
+
+        exec_program( ${_ASSUAN2CONFIG_EXECUTABLE} ARGS --libs OUTPUT_VARIABLE _assuan2_config_libs RETURN_VALUE _ret )
+	if ( _ret )
+	  set( _assuan2_config_libs )
+	endif()
+
+        # append -lgpg-error to the list of libraries, if necessary
+        if ( _assuan2_config_libs AND NOT _assuan2_config_libs MATCHES "lgpg-error" )
+          set( _assuan2_config_libs "${_assuan2_config_libs} -lgpg-error" )
+        endif()
+
+        if ( _assuan2_config_libs )
+
+          exec_program( ${_ASSUAN2CONFIG_EXECUTABLE} ARGS --cflags OUTPUT_VARIABLE _ASSUAN2_CFLAGS )
+
+          if ( _ASSUAN2_CFLAGS )
+            string( REGEX REPLACE "(\r?\n)+$" " " _ASSUAN2_CFLAGS  "${_ASSUAN2_CFLAGS}" )
+            string( REGEX REPLACE " *-I"      ";" ASSUAN2_INCLUDES "${_ASSUAN2_CFLAGS}" )
+          endif()
+
+          if ( _assuan2_config_libs )
+
+            set( _assuan2_library_dirs )
+            set( _assuan2_library_names )
+
+            string( REGEX REPLACE " +" ";" _assuan2_config_libs "${_assuan2_config_libs}" )
+
+            foreach( _flag ${_assuan2_config_libs} )
+              if ( "${_flag}" MATCHES "^-L" )
+                string( REGEX REPLACE "^-L" "" _dir "${_flag}" )
+                file( TO_CMAKE_PATH "${_dir}" _dir )
+                set( _assuan2_library_dirs ${_assuan2_library_dirs} "${_dir}" )
+              elseif( "${_flag}" MATCHES "^-l" )
+                string( REGEX REPLACE "^-l" "" _name "${_flag}" )
+                set( _assuan2_library_names ${_assuan2_library_names} "${_name}" )
+              endif()
+            endforeach()
+
+            set( ASSUAN2_FOUND true )
+
+            foreach( _name ${_assuan2_library_names} )
+              set( _assuan2_${_name}_lib )
+
+              # if -L options were given, look only there
+              if ( _assuan2_library_dirs )
+                find_library( _assuan2_${_name}_lib NAMES ${_name} PATHS ${_assuan2_library_dirs} NO_DEFAULT_PATH )
+              endif()
+
+              # if not found there, look in system directories
+              if ( NOT _assuan2_${_name}_lib )
+                find_library( _assuan2_${_name}_lib NAMES ${_name} )
+              endif()
+
+              # if still not found, then the whole flavour isn't found
+              if ( NOT _assuan2_${_name}_lib )
+                if ( ASSUAN2_FOUND )
+                  set( ASSUAN2_FOUND false )
+                  set( _not_found_reason "dependant library ${_name} wasn't found" )
+                endif()
+              endif()
+
+              set( ASSUAN2_LIBRARIES ${ASSUAN2_LIBRARIES} "${_assuan2_${_name}_lib}" )
+            endforeach()
+
+            #check_c_library_exists_explicit( assuan         assuan_check_version "${_ASSUAN2_CFLAGS}" "${ASSUAN2_LIBRARIES}"         ASSUAN2_FOUND         )
+            if ( ASSUAN2_FOUND )
+              message( STATUS " Checking whether assuan is usable...yes" )
+            else()
+              message( STATUS " Checking whether assuan is usable...no" )
+              message( STATUS "  (${_not_found_reason})" )
+            endif()
+          endif()
+
+          # ensure that they are cached
+          set( ASSUAN2_INCLUDES  ${ASSUAN2_INCLUDES}  )
+          set( ASSUAN2_LIBRARIES ${ASSUAN2_LIBRARIES} )
+
+        endif()
+
+      endif()
+
+    endif()
+
+  endif()
+
+  macro_bool_to_01( ASSUAN2_FOUND         HAVE_ASSUAN2         )
+
+endif() # WIN32 | Unix
+
+
+if ( NOT Assuan2_FIND_QUIETLY )
+
+  if ( ASSUAN2_FOUND )
+    message( STATUS "Usable assuan found." )
+    message( STATUS " Includes:  ${ASSUAN2_INCLUDES}" )
+    message( STATUS " Libraries: ${ASSUAN2_LIBRARIES}" )
+  else()
+    message( STATUS "No usable assuan found." )
+  endif()
+
+  macro_bool_to_bool( Assuan2_FIND_REQUIRED _req )
+
+  if ( WIN32 )
+    set( _assuan2_homepage "http://www.gpg4win.org" )
+  else()
+    set( _assuan2_homepage "http://www.gnupg.org/related_software/libassuan" )
+  endif()
+
+  macro_log_feature(
+    ASSUAN2_FOUND
+    "assuan2"
+    "Assuan v2 IPC library"
+    ${_assuan2_homepage}
+    ${_req}
+    "${_ASSUAN2_MIN_VERSION} or greater"
+    "Needed for Kleopatra to act as the GnuPG UI Server"
+  )
+
+else()
+
+  if ( Assuan2_FIND_REQUIRED AND NOT ASSUAN2_FOUND )
+    message( FATAL_ERROR "" )
+  endif()
+
+endif()
+
+set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS_assuan2_saved )
diff -Nur kdepim-4.4.11.1/kleopatra/CMakeLists.txt kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/CMakeLists.txt
--- kdepim-4.4.11.1/kleopatra/CMakeLists.txt	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/CMakeLists.txt	2011-06-13 23:51:44.000000000 +0200
@@ -28,7 +28,11 @@
   ${QGPGME_INCLUDES}
   ${GPGME_INCLUDES} )
 if (USABLE_ASSUAN_FOUND)
-   include_directories(${ASSUAN_INCLUDES})
+  if (ASSUAN2_FOUND)
+    include_directories(${ASSUAN2_INCLUDES})
+  else (ASSUAN2_FOUND)
+    include_directories(${ASSUAN_INCLUDES})
+  endif(ASSUAN2_FOUND)
 endif(USABLE_ASSUAN_FOUND)
 add_definitions ( -DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS -D_ASSUAN_ONLY_GPG_ERRORS -DQT_STL )
 remove_definitions ( -DQT_NO_STL )
@@ -84,11 +88,15 @@
     selftest/uiservercheck.cpp
     )
 
-  if ( WIN32 )
-    set( _kleopatra_uiserver_extra_libs ${ASSUAN_VANILLA_LIBRARIES} )
-  else ( WIN32 )
-    set( _kleopatra_uiserver_extra_libs ${ASSUAN_PTHREAD_LIBRARIES} )
-  endif( WIN32 )
+  if ( ASSUAN2_FOUND )
+    set( _kleopatra_uiserver_extra_libs ${ASSUAN2_LIBRARIES} )
+  else ( ASSUAN2_FOUND )
+    if ( WIN32 )
+      set( _kleopatra_uiserver_extra_libs ${ASSUAN_VANILLA_LIBRARIES} )
+    else ( WIN32 )
+      set( _kleopatra_uiserver_extra_libs ${ASSUAN_PTHREAD_LIBRARIES} )
+    endif( WIN32 )
+  endif ( ASSUAN2_FOUND )
 
   if ( HAVE_GPG_ERR_SOURCE_KLEO )
     add_definitions( -DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_KLEO )
diff -Nur kdepim-4.4.11.1/kleopatra/config-kleopatra.h.cmake kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/config-kleopatra.h.cmake
--- kdepim-4.4.11.1/kleopatra/config-kleopatra.h.cmake	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/config-kleopatra.h.cmake	2011-06-13 19:59:47.000000000 +0200
@@ -1,6 +1,10 @@
 /* Define to 1 if you have a recent enough libassuan */
 #cmakedefine HAVE_USABLE_ASSUAN 1
 
+/* Define to 1 if you have libassuan v2 */
+#cmakedefine HAVE_ASSUAN2 1
+
+#ifndef HAVE_ASSUAN2
 /* Define to 1 if your libassuan has the assuan_fd_t type  */
 #cmakedefine HAVE_ASSUAN_FD_T 1
 
@@ -13,6 +17,7 @@
 /* Define to 1 if your libassuan has the assuan_sock_get_nonce function */
 #cmakedefine HAVE_ASSUAN_SOCK_GET_NONCE 1
 
+#endif
 /* Define to 1 if you build libkleopatraclient */
 #cmakedefine HAVE_KLEOPATRACLIENT_LIBRARY 1
 
diff -Nur kdepim-4.4.11.1/kleopatra/ConfigureChecks.cmake kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/ConfigureChecks.cmake
--- kdepim-4.4.11.1/kleopatra/ConfigureChecks.cmake	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/ConfigureChecks.cmake	2011-06-13 19:59:47.000000000 +0200
@@ -1,21 +1,30 @@
 # assuan configure checks
 include(CheckFunctionExists)
 
-macro_optional_find_package(Assuan)
+macro_optional_find_package(Assuan2)
+if ( ASSUAN2_FOUND )
+  set ( ASSUAN_SUFFIX "2" )
+else ( ASSUAN2_FOUND )
+  macro_optional_find_package(Assuan)
+  set ( ASSUAN_SUFFIX )
+endif ( ASSUAN2_FOUND )
 
 set( USABLE_ASSUAN_FOUND false )
 
-if ( ASSUAN_FOUND )
+if ( ASSUAN${ASSUAN_SUFFIX}_FOUND )
 
-  set( CMAKE_REQUIRED_INCLUDES ${ASSUAN_INCLUDES} )
+  set( CMAKE_REQUIRED_INCLUDES ${ASSUAN${ASSUAN_SUFFIX}_INCLUDES} )
 
-  if ( WIN32 AND ASSUAN_VANILLA_FOUND )
+  if ( ASSUAN2_FOUND )
+    set( CMAKE_REQUIRED_LIBRARIES ${ASSUAN2_LIBRARIES} )
+    set( USABLE_ASSUAN_FOUND true )
+  elseif ( WIN32 AND ASSUAN_VANILLA_FOUND )
     set( CMAKE_REQUIRED_LIBRARIES ${ASSUAN_VANILLA_LIBRARIES} )
     set( USABLE_ASSUAN_FOUND true )
   elseif( NOT WIN32 AND ASSUAN_PTHREAD_FOUND )
     set( CMAKE_REQUIRED_LIBRARIES ${ASSUAN_PTHREAD_LIBRARIES} )
     set( USABLE_ASSUAN_FOUND true )
-  endif( WIN32 AND ASSUAN_VANILLA_FOUND )
+  endif( ASSUAN2_FOUND )
 
   # TODO: this workaround will be removed as soon as we find better solution
   if(MINGW)
@@ -24,7 +33,7 @@
     set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${KDEWIN32_INCLUDE_DIR}/msvc)
   endif(MINGW)
 
-endif( ASSUAN_FOUND )
+endif( ASSUAN${ASSUAN_SUFFIX}_FOUND )
 
 if ( USABLE_ASSUAN_FOUND )
   # check if assuan.h can be compiled standalone (it couldn't, on
@@ -46,7 +55,7 @@
 
 endif( USABLE_ASSUAN_FOUND )
 
-if ( USABLE_ASSUAN_FOUND )
+if ( USABLE_ASSUAN_FOUND AND NOT ASSUAN2_FOUND )
 
   # check if assuan has assuan_fd_t
   check_cxx_source_compiles("
@@ -82,6 +91,10 @@
         "
     HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT )
 
+endif( USABLE_ASSUAN_FOUND AND NOT ASSUAN2_FOUND )
+
+if ( USABLE_ASSUAN_FOUND )
+
   # check if gpg-error already has GPG_ERR_SOURCE_KLEO
   check_cxx_source_compiles("
         #include <gpg-error.h>
@@ -90,6 +103,10 @@
         "
     HAVE_GPG_ERR_SOURCE_KLEO )
 
+endif ( USABLE_ASSUAN_FOUND )
+
+if ( USABLE_ASSUAN_FOUND AND NOT ASSUAN2_FOUND )
+
   # check if assuan has assuan_sock_get_nonce (via assuan_sock_nonce_t)
   # function_exists runs into linking errors - libassuan is static,
   # and assuan_sock_get_nonce drags in stuff that needs linking
@@ -105,7 +122,7 @@
     set( USABLE_ASSUAN_FOUND false )
   endif ( WIN32 AND NOT HAVE_ASSUAN_SOCK_GET_NONCE )  
 
-endif ( USABLE_ASSUAN_FOUND )
+endif ( USABLE_ASSUAN_FOUND AND NOT ASSUAN2_FOUND )
 
 if ( USABLE_ASSUAN_FOUND )
   message( STATUS "Usable assuan found for Kleopatra" )
@@ -113,6 +130,8 @@
   message( STATUS "NO usable assuan found for Kleopatra" )
 endif ( USABLE_ASSUAN_FOUND )
 
+if ( NOT ASSUAN2_FOUND )
+
 #
 # Check that libassuan (which is built statically) can be linked into a DSO
 # (e.g. on amd64, this requires it to be compiled with -fPIC).
@@ -120,13 +139,15 @@
 
 set ( ASSUAN_LINKABLE_TO_DSO false )
 
+endif ( NOT ASSUAN2_FOUND )
+
 OPTION( BUILD_libkleopatraclient "Build directory kleopatra/libkleopatraclient" ${USABLE_ASSUAN_FOUND} )
 
 if ( NOT USABLE_ASSUAN_FOUND )
   set( BUILD_libkleopatraclient false )
 endif ( NOT USABLE_ASSUAN_FOUND )
 
-if ( BUILD_libkleopatraclient )
+if ( BUILD_libkleopatraclient AND NOT ASSUAN2_FOUND )
 
   message( STATUS "Checking whether libassuan can be linked against from DSO's" )
 
@@ -148,10 +169,15 @@
   endif ( ASSUAN_LINKABLE_TO_DSO )
   endif ( YUP )
 
-endif ( BUILD_libkleopatraclient )
+endif ( BUILD_libkleopatraclient AND NOT ASSUAN2_FOUND )
 
 macro_bool_to_01( USABLE_ASSUAN_FOUND  HAVE_USABLE_ASSUAN )
+macro_bool_to_01( ASSUAN2_FOUND HAVE_ASSUAN2 )
+if ( ASSUAN2_FOUND )
+macro_bool_to_01( USABLE_ASSUAN_FOUND  HAVE_KLEOPATRACLIENT_LIBRARY )
+else ( ASSUAN2_FOUND )
 macro_bool_to_01( ASSUAN_LINKABLE_TO_DSO HAVE_KLEOPATRACLIENT_LIBRARY )
+endif ( ASSUAN2_FOUND )
 
 set(CMAKE_REQUIRED_INCLUDES)
 set(CMAKE_REQUIRED_LIBRARIES)
diff -Nur kdepim-4.4.11.1/kleopatra/libkleopatraclient/CMakeLists.txt kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/CMakeLists.txt
--- kdepim-4.4.11.1/kleopatra/libkleopatraclient/CMakeLists.txt	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/CMakeLists.txt	2011-06-13 23:45:59.000000000 +0200
@@ -1,4 +1,4 @@
-set( libkleopatraclient_version "0.2.1" )
+set( libkleopatraclient_version "0.3.0" )
 set( libkleopatraclient_soversion "0" )
 
 add_subdirectory( core )
diff -Nur kdepim-4.4.11.1/kleopatra/libkleopatraclient/core/CMakeLists.txt kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/core/CMakeLists.txt
--- kdepim-4.4.11.1/kleopatra/libkleopatraclient/core/CMakeLists.txt	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/core/CMakeLists.txt	2011-06-13 19:59:47.000000000 +0200
@@ -1,4 +1,8 @@
+if ( ASSUAN2_FOUND )
+include_directories( ${ASSUAN2_INCLUDES} ${CMAKE_SOURCE_DIR}/kleopatra )
+else ( ASSUAN2_FOUND )
 include_directories( ${ASSUAN_INCLUDES} ${CMAKE_SOURCE_DIR}/kleopatra )
+endif ( ASSUAN2_FOUND )
 
 add_definitions( -D_ASSUAN_ONLY_GPG_ERRORS -DQT_NO_CAST_FROM_ASCII -DQT_NO_KEYWORDS -DQT_NO_CAST_TO_ASCII )
 
@@ -27,9 +31,17 @@
 
 
 if ( WIN32 )
+if ( ASSUAN2_FOUND )
+  target_link_libraries( kleopatraclientcore ${QT_QTCORE_LIBRARY} ${ASSUAN2_LIBRARIES} ws2_32 )
+else ( ASSUAN2_FOUND )
   target_link_libraries( kleopatraclientcore ${QT_QTCORE_LIBRARY} ${ASSUAN_VANILLA_LIBRARIES} ws2_32 )
+endif ( ASSUAN2_FOUND )
 else ( WIN32 )
+if ( ASSUAN2_FOUND )
+  target_link_libraries( kleopatraclientcore ${QT_QTCORE_LIBRARY} ${ASSUAN2_LIBRARIES} )
+else ( ASSUAN2_FOUND )
   target_link_libraries( kleopatraclientcore ${QT_QTCORE_LIBRARY} ${ASSUAN_PTHREAD_LIBRARIES} )
+endif ( ASSUAN2_FOUND )
 endif ( WIN32 )
 
 install(
diff -Nur kdepim-4.4.11.1/kleopatra/libkleopatraclient/core/command.cpp kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/core/command.cpp
--- kdepim-4.4.11.1/kleopatra/libkleopatraclient/core/command.cpp	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/core/command.cpp	2011-06-13 19:59:47.000000000 +0200
@@ -279,23 +279,51 @@
 // here comes the ugly part
 //
 
+#ifdef HAVE_ASSUAN2
+static void my_assuan_release( assuan_context_t ctx ) {
+    if ( ctx )
+        assuan_release( ctx );
+}
+#endif
+
 typedef shared_ptr< remove_pointer<assuan_context_t>::type > AssuanContextBase;
 namespace {
     struct AssuanClientContext : AssuanContextBase {
         AssuanClientContext() : AssuanContextBase() {}
+#ifndef HAVE_ASSUAN2
         explicit AssuanClientContext( assuan_context_t ctx ) : AssuanContextBase( ctx, &assuan_disconnect ) {}
         void reset( assuan_context_t ctx=0 ) { AssuanContextBase::reset( ctx, &assuan_disconnect ); }
+#else
+        explicit AssuanClientContext( assuan_context_t ctx ) : AssuanContextBase( ctx, &my_assuan_release ) {}
+        void reset( assuan_context_t ctx=0 ) { AssuanContextBase::reset( ctx, &my_assuan_release ); }
+#endif
     };
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t
+#else
+static gpg_error_t
+#endif
 my_assuan_transact( const AssuanClientContext & ctx,
                     const char *command,
+#ifndef HAVE_ASSUAN2
                     assuan_error_t (*data_cb)( void *, const void *, size_t )=0,
+#else
+                    gpg_error_t (*data_cb)( void *, const void *, size_t )=0,
+#endif
                     void * data_cb_arg=0,
+#ifndef HAVE_ASSUAN2
                     assuan_error_t (*inquire_cb)( void *, const char * )=0,
+#else
+                    gpg_error_t (*inquire_cb)( void *, const char * )=0,
+#endif
                     void * inquire_cb_arg=0,
+#ifndef HAVE_ASSUAN2
                     assuan_error_t (*status_cb)( void *, const char * )=0,
+#else
+                    gpg_error_t (*status_cb)( void *, const char * )=0,
+#endif
                     void * status_cb_arg=0)
 {
     return assuan_transact( ctx.get(), command, data_cb, data_cb_arg, inquire_cb, inquire_cb_arg, status_cb, status_cb_arg );
@@ -337,26 +365,42 @@
     return Command::tr("start_uiserver: not yet implemented");
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t getinfo_pid_cb( void * opaque, const void * buffer, size_t length ) {
+#else
+static gpg_error_t getinfo_pid_cb( void * opaque, const void * buffer, size_t length ) {
+#endif
     qint64 & pid = *static_cast<qint64*>( opaque );
     pid = QByteArray( static_cast<const char*>( buffer ), length ).toLongLong();
     return 0;
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t command_data_cb( void * opaque, const void * buffer, size_t length ) {
+#else
+static gpg_error_t command_data_cb( void * opaque, const void * buffer, size_t length ) {
+#endif
     QByteArray & ba = *static_cast<QByteArray*>( opaque );
     ba.append( QByteArray( static_cast<const char*>(buffer), length ) );
     return 0;
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t send_option( const AssuanClientContext & ctx, const char * name, const QVariant & value ) {
+#else
+static gpg_error_t send_option( const AssuanClientContext & ctx, const char * name, const QVariant & value ) {
+#endif
     if ( value.isValid() )
         return my_assuan_transact( ctx, QString().sprintf( "OPTION %s=%s", name, value.toString().toUtf8().constData() ).toUtf8().constData() );
     else
         return my_assuan_transact( ctx, QString().sprintf( "OPTION %s", name ).toUtf8().constData() );
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t send_file( const AssuanClientContext & ctx, const QString & file ) {
+#else
+static gpg_error_t send_file( const AssuanClientContext & ctx, const QString & file ) {
+#endif
     return my_assuan_transact( ctx, QString().sprintf( "FILE %s", hexencode( QFile::encodeName( file ) ).constData() ).toUtf8().constData() );
 }
 
@@ -373,21 +417,50 @@
 
     out.canceled = false;
 
+#ifndef HAVE_ASSUAN2
     assuan_error_t err = 0;
+#else
+    if ( out.serverLocation.isEmpty() )
+        out.serverLocation = default_socket_name();
+#endif
 
+#ifndef HAVE_ASSUAN2
     assuan_context_t naked_ctx = 0;
+#endif
     AssuanClientContext ctx;
+#ifdef HAVE_ASSUAN2
+    gpg_error_t err = 0;
+#endif
 
+#ifndef HAVE_ASSUAN2
     if ( out.serverLocation.isEmpty() )
         out.serverLocation = default_socket_name();
 
+#endif
     const QString socketName = out.serverLocation;
     if ( socketName.isEmpty() ) {
         out.errorString = tr("Invalid socket name!");
         goto leave;
     }
 
+#ifndef HAVE_ASSUAN2
     err = assuan_socket_connect( &naked_ctx, QFile::encodeName( socketName ).constData(), -1 );
+#else
+    {
+        assuan_context_t naked_ctx = 0;
+        err = assuan_new( &naked_ctx );
+        if ( err ) {
+            out.errorString = tr( "Could not allocate resources to connect to Kleopatra UI server at %1: %2" )
+                .arg( socketName, to_error_string( err ) );
+            goto leave;
+        }
+
+        ctx.reset( naked_ctx );
+    }
+
+
+    err = assuan_socket_connect( ctx.get(), QFile::encodeName( socketName ).constData(), -1, 0 );
+#endif
     if ( err ) {
         qDebug( "UI server not running, starting it" );
         
@@ -400,7 +473,11 @@
         // give it a bit of time to start up and try a couple of times
         for ( int i = 0 ; err && i < 20 ; ++i ) {
             msleep( 500 );
+#ifndef HAVE_ASSUAN2
             err = assuan_socket_connect( &naked_ctx, QFile::encodeName( socketName ).constData(), -1 );
+#else
+            err = assuan_socket_connect( ctx.get(), QFile::encodeName( socketName ).constData(), -1, 0 );
+#endif
         }
     }
 
@@ -410,9 +487,11 @@
         goto leave;
     }
 
+#ifndef HAVE_ASSUAN2
     ctx.reset( naked_ctx );
     naked_ctx = 0;
 
+#endif
     out.serverPid = -1;
     err = my_assuan_transact( ctx, "GETINFO pid", &getinfo_pid_cb, &out.serverPid );
     if ( err || out.serverPid <= 0 ) {
diff -Nur kdepim-4.4.11.1/kleopatra/libkleopatraclient/core/initialization.cpp kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/core/initialization.cpp
--- kdepim-4.4.11.1/kleopatra/libkleopatraclient/core/initialization.cpp	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/libkleopatraclient/core/initialization.cpp	2011-06-13 19:59:47.000000000 +0200
@@ -29,7 +29,11 @@
 using namespace KLEOPATRACLIENT_NAMESPACE;
 
 Initialization::Initialization() {
+#ifndef HAVE_ASSUAN2
     assuan_set_assuan_err_source( GPG_ERR_SOURCE_DEFAULT );
+#else
+    assuan_set_gpg_err_source( GPG_ERR_SOURCE_DEFAULT );
+#endif
 }
 
 Initialization::~Initialization() {
diff -Nur kdepim-4.4.11.1/kleopatra/tests/CMakeLists.txt kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/tests/CMakeLists.txt
--- kdepim-4.4.11.1/kleopatra/tests/CMakeLists.txt	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/tests/CMakeLists.txt	2011-06-13 23:50:06.000000000 +0200
@@ -60,7 +60,12 @@
     kde4_add_executable(test_uiserver TEST ${test_uiserver_SRCS})
   endif(WIN32)
 
-  target_link_libraries(test_uiserver ${KDE4_KDECORE_LIBS} )
+  if ( ASSUAN2_FOUND )
+    target_link_libraries(test_uiserver ${KDE4_KDECORE_LIBS} ${ASSUAN2_LIBRARIES})
+  else ( ASSUAN2_FOUND )
+    target_link_libraries(test_uiserver ${KDE4_KDECORE_LIBS} ${ASSUAN_LIBRARIES})
+  endif ( ASSUAN2_FOUND )
+
   if(WIN32)
 	 target_link_libraries(test_uiserver ${ASSUAN_VANILLA_LIBRARIES} ${QGPGME_LIBRARIES} ws2_32)
   else(WIN32)
diff -Nur kdepim-4.4.11.1/kleopatra/tests/test_uiserver.cpp kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/tests/test_uiserver.cpp
--- kdepim-4.4.11.1/kleopatra/tests/test_uiserver.cpp	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/tests/test_uiserver.cpp	2011-06-13 20:03:26.000000000 +0200
@@ -89,17 +89,29 @@
     exit( 1 );
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t data( void * void_ctx, const void * buffer, size_t len ) {
+#else
+static gpg_error_t data( void * void_ctx, const void * buffer, size_t len ) {
+#endif
     (void)void_ctx; (void)buffer; (void)len;
     return 0; // ### implement me
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t status( void * void_ctx, const char * line ) {
+#else
+static gpg_error_t status( void * void_ctx, const char * line ) {
+#endif
     (void)void_ctx; (void)line;
     return 0;
 }
 
+#ifndef HAVE_ASSUAN2
 static assuan_error_t inquire( void * void_ctx, const char * keyword ) {
+#else
+static gpg_error_t inquire( void * void_ctx, const char * keyword ) {
+#endif
     assuan_context_t ctx = (assuan_context_t)void_ctx;
     assert( ctx );
     const std::map<std::string,std::string>::const_iterator it = inquireData.find( keyword );
@@ -121,7 +133,11 @@
 
     const Kleo::WSAStarter _wsastarter;
 
+#ifndef HAVE_ASSUAN2
     assuan_set_assuan_err_source( GPG_ERR_SOURCE_DEFAULT );
+#else
+    assuan_set_gpg_err_source( GPG_ERR_SOURCE_DEFAULT );
+#endif
 
     if ( argc < 3 )
         usage(); // need socket and command, at least
@@ -185,8 +201,18 @@
 
     assuan_context_t ctx = 0;
 
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_socket_connect_ext( &ctx, socket, -1, ASSUAN_CONNECT_FLAGS ) ) {
         qDebug( "%s", Exception( err, "assuan_socket_connect_ext" ).what() );
+#else
+    if ( const gpg_error_t err = assuan_new( &ctx ) ) {
+        qDebug( "%s", Exception( err, "assuan_new" ).what() );
+        return 1;
+    }
+
+    if ( const gpg_error_t err = assuan_socket_connect( ctx, socket, -1, ASSUAN_CONNECT_FLAGS ) ) {
+        qDebug( "%s", Exception( err, "assuan_socket_connect" ).what() );
+#endif
         return 1;
     }
 
@@ -279,7 +305,11 @@
         return 1;
     }
 
+#ifndef HAVE_ASSUAN2
     assuan_disconnect( ctx );
+#else
+    assuan_release( ctx );
+#endif
 
     return 0;
 }
diff -Nur kdepim-4.4.11.1/kleopatra/uiserver/assuancommand.h kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/assuancommand.h
--- kdepim-4.4.11.1/kleopatra/uiserver/assuancommand.h	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/assuancommand.h	2011-06-13 19:59:47.000000000 +0200
@@ -39,6 +39,10 @@
 #include <gpgme++/global.h>
 #include <gpgme++/error.h>
 
+#ifdef HAVE_ASSUAN2
+#include <gpg-error.h>
+
+#endif
 #include <kmime/kmime_header_parsing.h>
 
 #include <qwindowdefs.h> // for WId
@@ -329,16 +333,28 @@
         virtual boost::shared_ptr<AssuanCommand> create() const = 0;
         virtual const char * name() const = 0;
 
+#ifndef HAVE_ASSUAN2
         typedef int(*_Handler)( assuan_context_s*, char *);
+#else
+        typedef gpg_error_t(*_Handler)( assuan_context_s*, char *);
+#endif
         virtual _Handler _handler() const = 0;
     protected:
+#ifndef HAVE_ASSUAN2
         static int _handle( assuan_context_s*, char *, const char * );
+#else
+        static gpg_error_t _handle( assuan_context_s*, char *, const char * );
+#endif
     };
 
     template <typename Command>
     class GenericAssuanCommandFactory : public AssuanCommandFactory {
         /* reimp */ AssuanCommandFactory::_Handler _handler() const { return &GenericAssuanCommandFactory::_handle; }
+#ifndef HAVE_ASSUAN2
         static int _handle( assuan_context_s* _ctx, char * _line ) {
+#else
+        static gpg_error_t _handle( assuan_context_s* _ctx, char * _line ) {
+#endif
             return AssuanCommandFactory::_handle( _ctx, _line, Command::staticName() );
         }
         /* reimp */ boost::shared_ptr<AssuanCommand> create() const { return make(); }
diff -Nur kdepim-4.4.11.1/kleopatra/uiserver/assuanserverconnection.cpp kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/assuanserverconnection.cpp
--- kdepim-4.4.11.1/kleopatra/uiserver/assuanserverconnection.cpp	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/assuanserverconnection.cpp	2011-06-13 19:59:47.000000000 +0200
@@ -116,13 +116,28 @@
 static const int FOR_READING = 0;
 static const unsigned int MAX_ACTIVE_FDS = 32;
 
+#ifdef HAVE_ASSUAN2
+static void my_assuan_release( assuan_context_t ctx ) {
+    if ( ctx )
+        assuan_release( ctx );
+}
+
+#endif
 // shared_ptr for assuan_context_t w/ deleter enforced to assuan_deinit_server:
 typedef shared_ptr< remove_pointer<assuan_context_t>::type > AssuanContextBase;
 struct AssuanContext : AssuanContextBase {
     AssuanContext() : AssuanContextBase() {}
+#ifndef HAVE_ASSUAN2
     explicit AssuanContext( assuan_context_t ctx ) : AssuanContextBase( ctx, &assuan_deinit_server ) {}
+#else
+    explicit AssuanContext( assuan_context_t ctx ) : AssuanContextBase( ctx, &my_assuan_release ) {}
+#endif
 
+#ifndef HAVE_ASSUAN2
     void reset( assuan_context_t ctx=0 ) { AssuanContextBase::reset( ctx, &assuan_deinit_server ); }
+#else
+    void reset( assuan_context_t ctx=0 ) { AssuanContextBase::reset( ctx, &my_assuan_release ); }
+#endif
 };
 
 static inline gpg_error_t assuan_process_done_msg( assuan_context_t ctx, gpg_error_t err, const char * err_msg ) {
@@ -240,7 +255,12 @@
 public Q_SLOTS:
     void slotReadActivity( int ) {
         assert( ctx );
+#ifndef HAVE_ASSUAN2
         if ( const int err = assuan_process_next( ctx.get() ) ) {
+#else
+        int done = false;
+        if ( const int err = assuan_process_next( ctx.get(), &done ) || done ) {
+#endif
             //if ( err == -1 || gpg_err_code(err) == GPG_ERR_EOF ) {
                 topHalfDeletion();
                 if ( nohupedCommands.empty() )
@@ -296,15 +316,27 @@
     }
 
 private:
+#ifndef HAVE_ASSUAN2
     static void reset_handler( assuan_context_t ctx_ ) {
+#else
+    static gpg_error_t reset_handler( assuan_context_t ctx_, char * ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
 
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
 
         conn.reset();
+#ifdef HAVE_ASSUAN2
+
+        return 0;
+#endif
     }
 
+#ifndef HAVE_ASSUAN2
     static int option_handler( assuan_context_t ctx_, const char * key, const char * value ) {
+#else
+    static gpg_error_t option_handler( assuan_context_t ctx_, const char * key, const char * value ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
 
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
@@ -317,7 +349,11 @@
         //return gpg_error( GPG_ERR_UNKNOWN_OPTION );
     }
 
+#ifndef HAVE_ASSUAN2
     static int session_handler( assuan_context_t ctx_, char * line ) {
+#else
+    static gpg_error_t session_handler( assuan_context_t ctx_, char * line ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
 
@@ -344,7 +380,11 @@
         return assuan_process_done( ctx_, 0 );
     }
 
+#ifndef HAVE_ASSUAN2
     static int capabilities_handler( assuan_context_t ctx_, char * line ) {
+#else
+    static gpg_error_t capabilities_handler( assuan_context_t ctx_, char * line ) {
+#endif
         if ( !QByteArray( line ).trimmed().isEmpty() ) {
             static const QString errorString = i18n("CAPABILITIES does not take arguments");
             return assuan_process_done_msg( ctx_, gpg_error( GPG_ERR_ASS_PARAMETER ), errorString );
@@ -357,7 +397,11 @@
         return assuan_process_done( ctx_, assuan_send_data( ctx_, capabilities, sizeof capabilities - 1 ) );
     }
 
+#ifndef HAVE_ASSUAN2
     static int getinfo_handler( assuan_context_t ctx_, char * line ) {
+#else
+    static gpg_error_t getinfo_handler( assuan_context_t ctx_, char * line ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
 
@@ -386,7 +430,11 @@
         return assuan_process_done( ctx_, assuan_send_data( ctx_, ba.constData(), ba.size() ) );
     }
 
+#ifndef HAVE_ASSUAN2
     static int start_keymanager_handler( assuan_context_t ctx_, char * line ) {
+#else
+    static gpg_error_t start_keymanager_handler( assuan_context_t ctx_, char * line ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
 
@@ -400,7 +448,11 @@
         return assuan_process_done( ctx_, 0 );
     }
 
+#ifndef HAVE_ASSUAN2
     static int start_confdialog_handler( assuan_context_t ctx_, char * line ) {
+#else
+    static gpg_error_t start_confdialog_handler( assuan_context_t ctx_, char * line ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
 
@@ -418,7 +470,11 @@
 
     // format: TAG (FD|FD=\d+|FILE=...)
     template <bool in, typename T_memptr>
+#ifndef HAVE_ASSUAN2
     static int IO_handler( assuan_context_t ctx_, char * line_, T_memptr which ) {
+#else
+    static gpg_error_t IO_handler( assuan_context_t ctx_, char * line_, T_memptr which ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
 
@@ -498,19 +554,35 @@
 
     }
 
+#ifndef HAVE_ASSUAN2
     static int input_handler( assuan_context_t ctx, char * line ) {
+#else
+    static gpg_error_t input_handler( assuan_context_t ctx, char * line ) {
+#endif
         return IO_handler<true>( ctx, line, &Private::inputs );
     }
 
+#ifndef HAVE_ASSUAN2
     static int output_handler( assuan_context_t ctx, char * line ) {
+#else
+    static gpg_error_t output_handler( assuan_context_t ctx, char * line ) {
+#endif
         return IO_handler<false>( ctx, line, &Private::outputs );
     }
 
+#ifndef HAVE_ASSUAN2
     static int message_handler( assuan_context_t ctx, char * line ) {
+#else
+    static gpg_error_t message_handler( assuan_context_t ctx, char * line ) {
+#endif
         return IO_handler<true>( ctx, line, &Private::messages );
     }
 
+#ifndef HAVE_ASSUAN2
     static int file_handler( assuan_context_t ctx_, char * line ) {
+#else
+    static gpg_error_t file_handler( assuan_context_t ctx_, char * line ) {
+#endif
         assert( assuan_get_pointer( ctx_ ) );
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx_ ) );
 
@@ -572,7 +644,11 @@
     }
 
     template <typename T_memptr, typename T_memptr2>
+#ifndef HAVE_ASSUAN2
     static int recipient_sender_handler( T_memptr mp, T_memptr2 info, assuan_context_t ctx, char * line, bool sender=false ) {
+#else
+    static gpg_error_t recipient_sender_handler( T_memptr mp, T_memptr2 info, assuan_context_t ctx, char * line, bool sender=false ) {
+#endif
         assert( assuan_get_pointer( ctx ) );
         AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx ) );
 
@@ -656,11 +732,19 @@
         return assuan_process_done( ctx, 0 );
     }
 
+#ifndef HAVE_ASSUAN2
     static int recipient_handler( assuan_context_t ctx, char * line ) {
+#else
+    static gpg_error_t recipient_handler( assuan_context_t ctx, char * line ) {
+#endif
         return recipient_sender_handler( &Private::recipients, &Private::informativeRecipients, ctx, line );
     }
 
+#ifndef HAVE_ASSUAN2
     static int sender_handler( assuan_context_t ctx, char * line ) {
+#else
+    static gpg_error_t sender_handler( assuan_context_t ctx, char * line ) {
+#endif
         return recipient_sender_handler( &Private::senders, &Private::informativeSenders, ctx, line, true );
     }
 
@@ -792,11 +876,23 @@
     if ( fd == ASSUAN_INVALID_FD )
         throw Exception( gpg_error( GPG_ERR_INV_ARG ), "pre-assuan_init_socket_server_ext" );
 
+#ifndef HAVE_ASSUAN2
     assuan_context_t naked_ctx = 0;
     if ( const gpg_error_t err = assuan_init_socket_server_ext( &naked_ctx, fd, INIT_SOCKET_FLAGS ) )
+#else
+    {
+        assuan_context_t naked_ctx = 0;
+        if ( const gpg_error_t err = assuan_new( &naked_ctx ) )
+            throw Exception( err, "assuan_new" );
+        ctx.reset( naked_ctx );
+    }
+    if ( const gpg_error_t err = assuan_init_socket_server( ctx.get(), fd, INIT_SOCKET_FLAGS ) )
+#endif
         throw Exception( err, "assuan_init_socket_server_ext" );
 
+#ifndef HAVE_ASSUAN2
     ctx.reset( naked_ctx ); naked_ctx = 0;
+#endif
 
     // for callbacks, associate the context with this connection:
     assuan_set_pointer( ctx.get(), this );
@@ -824,34 +920,82 @@
 
 
     // register our INPUT/OUTPUT/MESSGAE/FILE handlers:
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "INPUT",  input_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "INPUT",  input_handler, "" ) )
+#endif
         throw Exception( err, "register \"INPUT\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "MESSAGE",  message_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "MESSAGE",  message_handler, "" ) )
+#endif
         throw Exception( err, "register \"MESSAGE\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "OUTPUT", output_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "OUTPUT", output_handler, "" ) )
+#endif
         throw Exception( err, "register \"OUTPUT\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "FILE", file_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "FILE", file_handler, "" ) )
+#endif
         throw Exception( err, "register \"FILE\" handler" );
 
 
     // register user-defined commands:
     Q_FOREACH( shared_ptr<AssuanCommandFactory> fac, factories )
+#ifndef HAVE_ASSUAN2
         if ( const gpg_error_t err = assuan_register_command( ctx.get(), fac->name(), fac->_handler() ) )
+#else
+        if ( const gpg_error_t err = assuan_register_command( ctx.get(), fac->name(), fac->_handler(), "" ) )
+#endif
             throw Exception( err, std::string( "register \"" ) + fac->name() + "\" handler" );
 
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "GETINFO", getinfo_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "GETINFO", getinfo_handler, "" ) )
+#endif
         throw Exception( err, "register \"GETINFO\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "START_KEYMANAGER", start_keymanager_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "START_KEYMANAGER", start_keymanager_handler, "" ) )
+#endif
         throw Exception( err, "register \"START_KEYMANAGER\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "START_CONFDIALOG", start_confdialog_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "START_CONFDIALOG", start_confdialog_handler, "" ) )
+#endif
         throw Exception( err, "register \"START_CONFDIALOG\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "RECIPIENT", recipient_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "RECIPIENT", recipient_handler, "" ) )
+#endif
         throw Exception( err, "register \"RECIPIENT\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "SENDER", sender_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "SENDER", sender_handler, "" ) )
+#endif
         throw Exception( err, "register \"SENDER\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "SESSION", session_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "SESSION", session_handler, "" ) )
+#endif
         throw Exception( err, "register \"SESSION\" handler" );
+#ifndef HAVE_ASSUAN2
     if ( const gpg_error_t err = assuan_register_command( ctx.get(), "CAPABILITIES", capabilities_handler ) )
+#else
+    if ( const gpg_error_t err = assuan_register_command( ctx.get(), "CAPABILITIES", capabilities_handler, "" ) )
+#endif
         throw Exception( err, "register \"CAPABILITIES\" handler" );
 
     assuan_set_hello_line( ctx.get(), "GPG UI server (Kleopatra/" KLEOPATRA_VERSION_STRING ") ready to serve" );
@@ -904,10 +1048,10 @@
     Q_OBJECT
 public:
 
-#ifdef HAVE_ASSUAN_INQUIRE_EXT
+#if defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_INQUIRE_EXT)
     explicit InquiryHandler( const char * keyword_, QObject * p=0 )
         : QObject( p ),
-# ifndef HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT
+# if !defined(HAVE_ASSUAN2) && !defined(HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT)
           buffer( 0 ),
           buflen( 0 ),
 # endif
@@ -916,8 +1060,12 @@
 
     }
 
-# ifdef HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT
+# if defined(HAVE_ASSUAN2) || defined(HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT)
+#  ifndef HAVE_ASSUAN2
     static int handler( void * cb_data, int rc, unsigned char * buffer, size_t buflen )
+#  else
+    static gpg_error_t handler( void * cb_data, gpg_error_t rc, unsigned char * buffer, size_t buflen )
+#  endif
     {
         assert( cb_data );
         InquiryHandler * this_ = static_cast<InquiryHandler*>(cb_data);
@@ -939,13 +1087,13 @@
 # endif
 
 private:
-# ifndef HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT
+#if !defined(HAVE_ASSUAN2) && !defined(HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT)
     friend class ::Kleo::AssuanCommand;
     unsigned char * buffer;
     size_t buflen;
-# endif
+#endif
     const char * keyword;
-#endif // HAVE_ASSUAN_INQUIRE_EXT
+#endif // defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_INQUIRE_EXT)
 
 Q_SIGNALS:
     void signal( int rc, const QByteArray & data, const QByteArray & keyword );
@@ -1157,11 +1305,11 @@
     if ( d->nohup )
         return makeError( GPG_ERR_INV_OP );
 
-#ifdef HAVE_ASSUAN_INQUIRE_EXT
+#if defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_INQUIRE_EXT)
     std::auto_ptr<InquiryHandler> ih( new InquiryHandler( keyword, receiver ) );
     receiver->connect( ih.get(), SIGNAL(signal(int,QByteArray,QByteArray)), slot );
     if ( const gpg_error_t err = assuan_inquire_ext( d->ctx.get(), keyword,
-# ifndef HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT
+# if !defined(HAVE_ASSUAN2) && !defined(HAVE_NEW_STYLE_ASSUAN_INQUIRE_EXT)
                                                      &ih->buffer, &ih->buflen,
 # endif
                                                      maxSize, InquiryHandler::handler, ih.get() ) )
@@ -1170,7 +1318,7 @@
     return 0;
 #else
     return makeError( GPG_ERR_NOT_SUPPORTED ); // libassuan too old
-#endif // HAVE_ASSUAN_INQUIRE_EXT
+#endif // defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_INQUIRE_EXT)
 }
 
 void AssuanCommand::done( const GpgME::Error& err, const QString & details ) {
@@ -1262,7 +1410,11 @@
     return d->senders;
 }
 
+#ifndef HAVE_ASSUAN2
 int AssuanCommandFactory::_handle( assuan_context_t ctx, char * line, const char * commandName ) {
+#else
+gpg_error_t AssuanCommandFactory::_handle( assuan_context_t ctx, char * line, const char * commandName ) {
+#endif
     assert( assuan_get_pointer( ctx ) );
     AssuanServerConnection::Private & conn = *static_cast<AssuanServerConnection::Private*>( assuan_get_pointer( ctx ) );
 
diff -Nur kdepim-4.4.11.1/kleopatra/uiserver/uiserver.cpp kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/uiserver.cpp
--- kdepim-4.4.11.1/kleopatra/uiserver/uiserver.cpp	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/uiserver.cpp	2011-06-13 20:09:29.000000000 +0200
@@ -73,15 +73,28 @@
       actualSocketName(),
       cryptoCommandsEnabled( false )
 {
+#ifndef HAVE_ASSUAN2
     assuan_set_assuan_err_source( GPG_ERR_SOURCE_DEFAULT );
+#else
+    assuan_set_gpg_err_source( GPG_ERR_SOURCE_DEFAULT );
+    assuan_sock_init();
+#endif
 }
 
 bool UiServer::Private::isStaleAssuanSocket( const QString& fileName )
 {
     assuan_context_t ctx = 0;
+#ifndef HAVE_ASSUAN2
     const bool error = assuan_socket_connect_ext( &ctx, QFile::encodeName( fileName ).constData(), -1, 0 );
+#else
+    const bool error = assuan_new( &ctx ) || assuan_socket_connect( ctx, QFile::encodeName( fileName ).constData(), ASSUAN_INVALID_PID, 0 );
+#endif
     if ( !error )
+#ifndef HAVE_ASSUAN2
         assuan_disconnect( ctx );
+#else
+        assuan_release( ctx );
+#endif
     return error;
 }
 
@@ -166,7 +179,7 @@
 void UiServer::Private::incomingConnection( int fd ) {
     try {
         qDebug( "UiServer: client connect on fd %d", fd );
-#ifdef HAVE_ASSUAN_SOCK_GET_NONCE
+#if defined(HAVE_ASSUAN_SOCK_GET_NONCE) || defined(HAVE_ASSUAN2)
         if ( assuan_sock_check_nonce( (assuan_fd_t)fd, &nonce ) ) {
             qDebug( "UiServer: nonce check failed" );
             assuan_sock_close( (assuan_fd_t)fd );
diff -Nur kdepim-4.4.11.1/kleopatra/uiserver/uiserver_unix.cpp kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/uiserver_unix.cpp
--- kdepim-4.4.11.1/kleopatra/uiserver/uiserver_unix.cpp	2011-04-20 22:03:31.000000000 +0200
+++ kdepim-4.4.11.1-kleopatra-libassuan2/kleopatra/uiserver/uiserver_unix.cpp	2011-06-13 20:10:47.000000000 +0200
@@ -61,7 +61,7 @@
 
 void UiServer::Private::doMakeListeningSocket( const QByteArray & encodedFileName ) {
     // Create a Unix Domain Socket:
-#ifdef HAVE_ASSUAN_SOCK_GET_NONCE
+#if defined(HAVE_ASSUAN2) || HAVE_ASSUAN_SOCK_GET_NONCE
     const assuan_fd_t sock = assuan_sock_new( AF_UNIX, SOCK_STREAM, 0 );
 #else
     const assuan_fd_t sock = ::socket( AF_UNIX, SOCK_STREAM, 0 );
@@ -75,7 +75,7 @@
         std::memset( &sa, 0, sizeof(sa) );
         sa.sun_family = AF_UNIX;
         std::strncpy( sa.sun_path, encodedFileName.constData(), sizeof( sa.sun_path ) - 1 );
-#ifdef HAVE_ASSUAN_SOCK_GET_NONCE
+#if defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_SOCK_GET_NONCE)
         if ( assuan_sock_bind( sock, (struct sockaddr*)&sa, sizeof( sa ) ) )
 #else
         if ( ::bind( sock, (struct sockaddr*)&sa, sizeof( sa ) ) )
@@ -84,9 +84,9 @@
 
         // ### TODO: permissions?
 
-#ifdef HAVE_ASSUAN_SOCK_GET_NONCE
+#if defined(HAVE_ASSUAN2) || defined(HAVE_ASSUAN_SOCK_GET_NONCE)
         if ( assuan_sock_get_nonce( (struct sockaddr*)&sa, sizeof( sa ), &nonce ) )
-            throw_<std::runtime_error>( i18n("Could not get socket nonce: %1", systemErrorString() ) );
+            throw_<std::runtime_error>( i18n("Couldn't get socket nonce: %1", systemErrorString() ) );
 #endif
 
         // Listen