rev 5022 - in trunk/packages/kdepim/debian: . patches

Sune Vuorela pusling-guest at alioth.debian.org
Sat Dec 2 02:20:07 CET 2006


Author: pusling-guest
Date: 2006-12-02 02:19:11 +0100 (Sat, 02 Dec 2006)
New Revision: 5022

Added:
   trunk/packages/kdepim/debian/patches/25_new_kpilot_patch.diff
   trunk/packages/kdepim/debian/patches/26_fix_kpilot_build.diff
Removed:
   trunk/packages/kdepim/debian/patches/25_fix_kpilot_feature_pull_thx_vanrijn.diff
Modified:
   trunk/packages/kdepim/debian/changelog
Log:
Enabling conduits, updating patch from upstream


Modified: trunk/packages/kdepim/debian/changelog
===================================================================
--- trunk/packages/kdepim/debian/changelog	2006-12-01 20:51:41 UTC (rev 5021)
+++ trunk/packages/kdepim/debian/changelog	2006-12-02 01:19:11 UTC (rev 5022)
@@ -1,3 +1,11 @@
+kdepim (4:3.5.5.dfsg.1-3) unstable; urgency=low
+
+  +++ Changes by Sune Vuorela
+
+  * Reenabling more conduits in kpilot. New patch 25 and patch 26 added
+
+ -- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org>  Sat,  2 Dec 2006 02:00:38 +0100
+
 kdepim (4:3.5.5.dfsg.1-2) unstable; urgency=medium
 
   * This release is dedicated to Rembrandt van Rijn for his fast response
@@ -3,5 +11,5 @@
     fixing KPilot. Many thanks.
 
-  +++ Changes by Sune Vuorela:
+  +++ Changes by Sune Vuorela
 
   * Added 18_optimize_splitAddressInternal.diff to fix lock up on weird

Deleted: trunk/packages/kdepim/debian/patches/25_fix_kpilot_feature_pull_thx_vanrijn.diff

Added: trunk/packages/kdepim/debian/patches/25_new_kpilot_patch.diff
===================================================================
--- trunk/packages/kdepim/debian/patches/25_new_kpilot_patch.diff	2006-12-01 20:51:41 UTC (rev 5021)
+++ trunk/packages/kdepim/debian/patches/25_new_kpilot_patch.diff	2006-12-02 01:19:11 UTC (rev 5022)
@@ -0,0 +1,24680 @@
+diff -pruN kpilot/AUTHORS /home/pusling/kpilot/kdepim-3.5.5+/kpilot/AUTHORS
+--- kpilot/AUTHORS	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/AUTHORS	2006-11-26 23:53:25.000000000 +0100
+@@ -3,6 +3,7 @@ active development by a worldwide group 
+ Adriaan de Groot and Reinhold Kainhofe are currently the maintainers.
+ 
+ 
++o Jason 'vanRijn' Kasper is prime motivator in 2006.
+ o The vcal and todo conduit were originally written by Preston Brown.
+ o The popclient conduit was written by Michael Kropfberger.
+ o The null conduit and KNotes conduit were written by Adriaan de Groot.
+@@ -25,4 +26,4 @@ http://www.kpilot.org/
+ -- Adriaan de Groot January 20th 2002
+ -- Reinhold Kainhofer, April 5th 2003
+ -- Adriaan de Groot, March 4th 2004
+-
++-- Adriaan de Groot, November 18th 2006
+diff -pruN kpilot/ChangeLog /home/pusling/kpilot/kdepim-3.5.5+/kpilot/ChangeLog
+--- kpilot/ChangeLog	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/ChangeLog	2006-11-19 22:21:12.000000000 +0100
+@@ -8,11 +8,38 @@ TODO: Figure out why archived records ar
+ 	               record->isDeleted() is false, on sync, but it is modified and
+ 	               updated on the pc, although that does not change anything.
+ 
++TODO: store map of pilot-id <-> uid elsewhere (not in the .vcf file)
++TODO: don't make ActionQueue auto-delete the actions in it.
+ TODO: provide template-based, interpreted databases much like the
+-  AppInfo classes now have.
++      AppInfo classes now have.
+ TODO: give the knotes conduit a decent test mode.
+ TODO: only re-write a local database if it is changed.
+-TODO: move set-category code from subclasses into PilotRecordBase.
++
++2006-10-24  Jason 'vanRijn' Kasper
++* Getting rid of FastSync.  The only difference between it and HotSync was
++  that HotSync did a Backup and FastSync did not.  Having a third
++  permutation because of not having a way to set it in the Backup settings
++  seems wrong.  Also, if one of them is to go, I think that HotSync is much
++  more recognizable and widely used than FastSync.  
++* Allowing finer-grained control around when database backups are done.
++  This is so that users can choose when they want a backup to be done.
++  The problem I need to solve for myself is that since I'm now syncing
++  between 2 PCs, I need a full sync to be done whenever I switch.  But I
++  do not EVER want an automatic backup to be done.  Currently, this is not
++  possible.  Fixing it.  =:)  This will also allow for schedule backups to
++  be done, which is also of interest to me.
++
++2006-01-30  Adriaan de Groot
++* Updated pilot-link to today's CVS, with one change - use of pl_socklen_t
++  in inet.c changed back to socklen_t.
++* Added --loop to kpilotTest to repeatedly run the same action. Only
++  works for --list right now.
++
++2006-01-23  Adriaan de Groot
++* Gosh, where to begin. KPilot moved SVN repositories, changed build
++  systems, had the guts of the device link class refactored, bumped the
++  plugin API version again, and tons more. The commit logs are probably
++  the most useful source of information about what's changed.
+ 
+ 2005-08-18  Adriaan de Groot
+ * Found out that the PilotAppCategory constructor that takes
+diff -pruN kpilot/cmake/modules/FindMal.cmake /home/pusling/kpilot/kdepim-3.5.5+/kpilot/cmake/modules/FindMal.cmake
+--- kpilot/cmake/modules/FindMal.cmake	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/cmake/modules/FindMal.cmake	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,37 @@
++set(CMAKE_INCLUDE_PATH "${MAL_BASE}/include")
++FIND_PATH(MAL_INCLUDE_DIR libmal.h 
++	/usr/include
++	/usr/include/libmal
++	/usr/local/include
++	/usr/local/include/libmal
++)
++set(CMAKE_LIBRARY_PATH "${MAL_BASE}/lib")
++FIND_LIBRARY(MAL_LIBRARY mal 
++	/usr/lib
++	/usr/lib/libmal
++	/usr/local/lib
++	/usr/local/lib/libmal
++)
++
++IF (NOT MAL_INCLUDE_DIR)
++	MESSAGE(STATUS "Could not find libmal.h")
++ELSE (NOT MAL_INCLUDE_DIR)
++	MESSAGE(STATUS "Found libmal.h in ${MAL_INCLUDE_DIR}")
++ENDIF (NOT MAL_INCLUDE_DIR)
++
++IF (NOT MAL_LIBRARY)
++	MESSAGE(STATUS "Could not find libmal")
++ELSE (NOT MAL_LIBRARY)
++	MESSAGE(STATUS "Found libmal in ${MAL_LIBRARY}")
++ENDIF (NOT MAL_LIBRARY)
++
++IF (MAL_INCLUDE_DIR AND MAL_LIBRARY)
++	SET(MAL_FOUND TRUE)
++ENDIF (MAL_INCLUDE_DIR AND MAL_LIBRARY)
++
++IF (MAL_FOUND)
++	MESSAGE(STATUS "Found mal: ${MAL_LIBRARY}")
++ELSE (MAL_FOUND)
++	MESSAGE(STATUS "Couldn't find mal. Won't be able to build malconduit")
++ENDIF (MAL_FOUND)
++
+diff -pruN kpilot/cmake/modules/FindPilotlink.cmake /home/pusling/kpilot/kdepim-3.5.5+/kpilot/cmake/modules/FindPilotlink.cmake
+--- kpilot/cmake/modules/FindPilotlink.cmake	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/cmake/modules/FindPilotlink.cmake	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,37 @@
++set(CMAKE_INCLUDE_PATH "${PILOTLINK_BASE}/include")
++FIND_PATH(PILOTLINK_INCLUDE_DIR pi-dlp.h 
++	/usr/include
++	/usr/include/libpisock
++	/usr/local/include
++	)
++set(CMAKE_LIBRARY_PATH "${PILOTLINK_BASE}/lib")
++FIND_LIBRARY(PILOTLINK_LIBRARY pisock 
++	/usr/lib
++	/usr/local/lib
++	)
++
++IF (NOT PILOTLINK_INCLUDE_DIR)
++	MESSAGE(STATUS "Could not find pi-dlp.h")
++ELSE (NOT PILOTLINK_INCLUDE_DIR)
++	MESSAGE(STATUS "Found pi-dlp.h in ${PILOTLINK_INCLUDE_DIR}")
++ENDIF (NOT PILOTLINK_INCLUDE_DIR)
++
++IF (NOT PILOTLINK_LIBRARY)
++	MESSAGE(STATUS "Could not find libpisock")
++ELSE (NOT PILOTLINK_LIBRARY)
++	MESSAGE(STATUS "Found libpisock in ${PILOTLINK_LIBRARY}")
++ENDIF (NOT PILOTLINK_LIBRARY)
++
++IF (PILOTLINK_INCLUDE_DIR AND PILOTLINK_LIBRARY)
++	SET(PILOTLINK_FOUND TRUE)
++ENDIF (PILOTLINK_INCLUDE_DIR AND PILOTLINK_LIBRARY)
++
++IF (PILOTLINK_FOUND)
++	MESSAGE(STATUS "Found pilot-link: ${PILOTLINK_LIBRARY}")
++ELSE (PILOTLINK_FOUND)
++	IF (Pilotlink_FIND_REQUIRED)
++		MESSAGE(STATUS "KPilot requires pilot-link 0.12.1 or later. Pilot-link is available from pilot-link.org and is packaged by most distributions. Remember to install the development package with the compilation headers as well.")
++		MESSAGE(FATAL_ERROR "Could not find pilot-link.")
++	ENDIF (Pilotlink_FIND_REQUIRED)
++ENDIF (PILOTLINK_FOUND)
++
+diff -pruN kpilot/cmake/modules/KPilotCustom.cmake /home/pusling/kpilot/kdepim-3.5.5+/kpilot/cmake/modules/KPilotCustom.cmake
+--- kpilot/cmake/modules/KPilotCustom.cmake	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/cmake/modules/KPilotCustom.cmake	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,53 @@
++MACRO(KDE3_INSTALL_ICONS_CUSTOM _theme)
++   ADD_CUSTOM_TARGET(install_icons )
++   SET_TARGET_PROPERTIES(install_icons PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake )
++   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "# icon installations rules\n")
++   FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "SET(CMAKE_BACKWARDS_COMPATIBILITY \"2.2\") \n")
++
++   FILE(GLOB _icons *.png)
++   FOREACH(_current_ICON ${_icons} )
++      STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\1" _size "${_current_ICON}")
++      STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\2" _group "${_current_ICON}")
++      STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\3" _name "${_current_ICON}")
++
++      SET(_icon_GROUP "unknown")
++
++      IF(${_group} STREQUAL "mime")
++         SET(_icon_GROUP  "mimetypes")
++      ENDIF(${_group} STREQUAL "mime")
++
++      IF(${_group} STREQUAL "filesys")
++         SET(_icon_GROUP  "filesystems")
++      ENDIF(${_group} STREQUAL "filesys")
++
++      IF(${_group} STREQUAL "device")
++         SET(_icon_GROUP  "devices")
++      ENDIF(${_group} STREQUAL "device")
++
++      IF(${_group} STREQUAL "app")
++         SET(_icon_GROUP  "apps")
++      ENDIF(${_group} STREQUAL "app")
++
++      IF(${_group} STREQUAL "action")
++         SET(_icon_GROUP  "actions")
++      ENDIF(${_group} STREQUAL "action")
++
++      IF( NOT ${_icon_GROUP} STREQUAL "unknown")
++#        message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name}" )
++         SET(_ICON_INSTALL_NAME ${CMAKE_INSTALL_PREFIX}/share/icons/${_theme}/${_size}x${_size}/${_icon_GROUP}/${_name})
++         FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "message(STATUS \"Installing ${_ICON_INSTALL_NAME}\") \n")
++         FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake "CONFIGURE_FILE( ${_current_ICON} ${_ICON_INSTALL_NAME} COPYONLY) \n")
++      ELSE( NOT ${_icon_GROUP} STREQUAL "unknown")
++         message(STATUS "icon: ${_current_ICON} doesn't fit naming conventions. ignoring." )
++      ENDIF( NOT ${_icon_GROUP} STREQUAL "unknown")
++
++   ENDFOREACH (_current_ICON)
++ENDMACRO(KDE3_INSTALL_ICONS_CUSTOM)
++
++
++MACRO(KPILOT_RPATH _thing)
++	set_target_properties(${_thing} PROPERTIES 
++		INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib;${KDE3_DIR}/lib;${PILOTLINK_LIBRARY}
++		INSTALL_RPATH_USE_LINK_PATH true
++	)
++ENDMACRO(KPILOT_RPATH _thing)
+diff -pruN kpilot/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/CMakeLists.txt
+--- kpilot/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,64 @@
++project(kpilot)
++
++# Search our own cmake modules path first
++set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
++
++# Need 2.4.3 for its KDE3 support
++cmake_minimum_required(VERSION 2.4.3)
++
++CONFIGURE_FILE(
++  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
++  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
++  IMMEDIATE @ONLY)
++
++ADD_CUSTOM_TARGET(uninstall
++  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
++
++# Disallow in-source build
++STRING(COMPARE EQUAL "${kpilot_SOURCE_DIR}" "${kpilot_BINARY_DIR}" insource)
++if(insource)
++	MESSAGE(FATAL_ERROR 
++		"KPilot requires an out of source build. Please create a separate build
++directory and run 'cmake path_to_kpilot [options]' there."
++	)
++endif(insource)
++
++find_package(Qt3 REQUIRED) # find and setup Qt3 for this project
++find_package(KDE3 REQUIRED) # find and setup KDE3 for this project
++find_package(Pilotlink REQUIRED)
++find_package(Mal) # see if mal is available, but it's not required
++
++add_definitions(
++	${QT_DEFINITIONS}
++	${KDE3_DEFINITIONS}
++	-DQT_THREAD_SUPPORT
++)
++
++# Get the kde3 dir. This is a bit tricky, i'm not sure how well
++# this works on other systems.
++STRING(REPLACE "/lib" "" KDE3_DIR ${KDE3_LIB_DIR})
++
++# TODO: INSTALL PREFIX. RIGHT NOW EVERYTHING IS INSTALLED IN $KDEDIR
++if(NOT CMAKE_INSTALL_PREFIX)
++	set(CMAKE_INSTALL_PREFIX ${KDE3_DIR})
++endif(NOT CMAKE_INSTALL_PREFIX)
++set(KDE3_KCFG_DIR ${CMAKE_INSTALL_PREFIX}/share/config.kcfg)
++set(KDE3_SERVICETYPES_DIR ${CMAKE_INSTALL_PREFIX}/share/servicetypes)
++set(KDE3_SERVICES_DIR ${CMAKE_INSTALL_PREFIX}/share/services)
++set(KDE3_XDG_APPS_DIR ${CMAKE_INSTALL_PREFIX}/share/applications/kde)
++set(KDE3_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
++set(KDE3_PLUGIN_INSTALL_DIR ${KDE3_LIB_INSTALL_DIR}/kde3)
++
++# tell cmake where to search for libraries:
++link_directories(${KDE3_LIB_DIR})
++
++# tell cmake where to search for Qt/KDE headers:
++include_directories(${PILOTLINK_INCLUDE_DIR} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR})
++
++# include custom macros
++INCLUDE(${CMAKE_SOURCE_DIR}/cmake/modules/KPilotCustom.cmake)
++
++# tell cmake to process CMakeLists.txt in that subdirectory
++add_subdirectory(lib)
++add_subdirectory(kpilot)
++add_subdirectory(conduits)
+diff -pruN kpilot/cmake_uninstall.cmake.in /home/pusling/kpilot/kdepim-3.5.5+/kpilot/cmake_uninstall.cmake.in
+--- kpilot/cmake_uninstall.cmake.in	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/cmake_uninstall.cmake.in	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,23 @@
++IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
++  MESSAGE(FATAL_ERROR "Cannot find install manifest: 
++\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
++ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
++
++FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
++STRING(REGEX REPLACE "\n" ";" files "${files}")
++FOREACH(file ${files})
++  MESSAGE(STATUS "Uninstalling \"${file}\"")
++  IF(EXISTS "${file}")
++    EXEC_PROGRAM(
++      "@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
++      OUTPUT_VARIABLE rm_out
++      RETURN_VALUE rm_retval
++      )
++    IF("${rm_retval}" STREQUAL 0)
++    ELSE("${rm_retval}" STREQUAL 0)
++      MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
++    ENDIF("${rm_retval}" STREQUAL 0)
++  ELSE(EXISTS "${file}")
++    MESSAGE(STATUS "File \"${file}\" does not exist.")
++  ENDIF(EXISTS "${file}")
++ENDFOREACH(file)
+diff -pruN kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc
+--- kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -40,6 +40,7 @@
+ #include <kabc/stdaddressbook.h>
+ #include <kabc/resourcefile.h>
+ #include <kio/netaccess.h>
++#include <ksavefile.h>
+ 
+ #include <pilotSerialDatabase.h>
+ #include <pilotLocalDatabase.h>
+@@ -56,8 +57,7 @@
+ //
+ extern "C"
+ {
+-long version_conduit_address = KPILOT_PLUGIN_API;
+-const char *id_conduit_address="$Id: abbrowser-conduit.cc 450360 2005-08-17 23:55:06Z adridg $";
++unsigned long version_conduit_address = Pilot::PLUGIN_API;
+ }
+ 
+ 
+@@ -86,7 +86,7 @@ static inline void _setPhoneNumber(Addre
+ 
+ 
+ 
+-AbbrowserConduit::AbbrowserConduit(KPilotDeviceLink * o, const char *n, const QStringList & a):
++AbbrowserConduit::AbbrowserConduit(KPilotLink * o, const char *n, const QStringList & a):
+ 		ConduitAction(o, n, a),
+ 		fAddressAppInfo(0L),
+ 		addresseeMap(),
+@@ -95,9 +95,6 @@ AbbrowserConduit::AbbrowserConduit(KPilo
+ 		ticket(0L)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<id_conduit_address<<endl;
+-#endif
+ 	fConduitName=i18n("Addressbook");
+ }
+ 
+@@ -167,6 +164,7 @@ bool AbbrowserConduit::_prepare()
+ 
+ 	readConfig();
+ 	syncedIds.clear();
++	pilotindex = 0;
+ 
+ 	return true;
+ }
+@@ -182,20 +180,26 @@ void AbbrowserConduit::readConfig()
+ 	SyncAction::ConflictResolution res = (SyncAction::ConflictResolution)AbbrowserSettings::conflictResolution();
+ 	setConflictResolution(res);
+ 
+-#ifdef DEBUG
+ 	DEBUGCONDUIT << fname
+-		<< ": Settings "
++		<< ": Reading addressbook "
++		<< ( AbbrowserSettings::addressbookType() == AbbrowserSettings::eAbookFile ?
++			AbbrowserSettings::fileName() : CSL1("Standard") )
++		<< endl;
++	DEBUGCONDUIT << fname
++		<< ": "
+ 		<< " fConflictResolution=" << getConflictResolution()
++		<< " fArchive=" << AbbrowserSettings::archiveDeleted()
++		<< " fFirstTime=" << isFirstSync()
++		<< endl;
++	DEBUGCONDUIT << fname
++		<< ": "
+ 		<< " fPilotStreetHome=" << AbbrowserSettings::pilotStreet()
+ 		<< " fPilotFaxHome=" << AbbrowserSettings::pilotFax()
+-		<< " fArchive=" << AbbrowserSettings::archiveDeleted()
+ 		<< " eCustom[0]=" << AbbrowserSettings::custom0()
+ 		<< " eCustom[1]=" << AbbrowserSettings::custom1()
+ 		<< " eCustom[2]=" << AbbrowserSettings::custom2()
+ 		<< " eCustom[3]=" << AbbrowserSettings::custom3()
+-		<< " fFirstTime=" << isFirstSync()
+ 		<< endl;
+-#endif
+ }
+ 
+ 
+@@ -382,8 +386,8 @@ void AbbrowserConduit::_getAppInfo()
+ void AbbrowserConduit::_setAppInfo()
+ {
+ 	FUNCTIONSETUP;
+-	if (fDatabase) fAddressAppInfo->write(fDatabase);
+-	if (fLocalDatabase) fAddressAppInfo->write(fLocalDatabase);
++	if (fDatabase) fAddressAppInfo->writeTo(fDatabase);
++	if (fLocalDatabase) fAddressAppInfo->writeTo(fLocalDatabase);
+ }
+ 
+ int AbbrowserConduit::getCustom(const int index)
+@@ -703,9 +707,6 @@ void AbbrowserConduit::showAdresses(Addr
+ /* virtual */ bool AbbrowserConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << id_conduit_address << endl;
+-#endif
+ 
+ 	_prepare();
+ 
+@@ -717,11 +718,20 @@ void AbbrowserConduit::showAdresses(Addr
+ 	}
+ 	setFirstSync( retrieved );
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": First sync now " << isFirstSync() << endl;
+-#endif
+-
+ 	_getAppInfo();
++
++	// Local block
++	{
++		QString dbpath = fLocalDatabase->dbPathName();
++		DEBUGCONDUIT << fname << ": Local database path " << dbpath << endl;
++	}
++
++	if ( syncMode().isTest() )
++	{
++		QTimer::singleShot(0, this, SLOT(slotTestRecord()));
++		return true;
++	}
++
+ 	if(!_loadAddressBook())
+ 	{
+ 		emit logError(i18n("Unable to open the addressbook."));
+@@ -738,7 +748,6 @@ void AbbrowserConduit::showAdresses(Addr
+ 
+ 	// perform syncing from palm to abbrowser
+ 	// iterate through all records in palm pilot
+-	pilotindex = 0;
+ 
+ #ifdef DEBUG
+ 	DEBUGCONDUIT << fname << ": fullsync=" << isFullSync() << ", firstSync=" <<    isFirstSync() << endl;
+@@ -1059,10 +1068,27 @@ void AbbrowserConduit::slotCleanup()
+ 		fLocalDatabase->resetSyncFlags();
+ 		fLocalDatabase->cleanup();
+ 	}
++
++	// Write out the sync maps
++	QString syncFile = fLocalDatabase->dbPathName() + CSL1(".sync");
++	DEBUGCONDUIT << fname << ": Writing sync map to " << syncFile << endl;
++	KSaveFile map( syncFile );
++	if ( map.status() == 0 )
++	{
++		DEBUGCONDUIT << fname << ": Writing sync map ..." << endl;
++		(*map.dataStream()) << addresseeMap ;
++		map.close();
++	}
++	// This also picks up errors from map.close()
++	if ( map.status() != 0 )
++	{
++		kdWarning() << k_funcinfo << ": Could not make backup of sync map." << endl;
++	}
++
+ 	KPILOT_DELETE(fDatabase);
+ 	KPILOT_DELETE(fLocalDatabase);
+ 	_saveAddressBook();
+-	emit syncDone(this);
++	delayDone();
+ }
+ 
+ 
+@@ -1874,7 +1900,7 @@ void AbbrowserConduit::_copy(Addressee &
+ 
+ 
+ 	int cat = fromPiAddr->category();
+-	QString category = fAddressAppInfo->category(cat);
++	QString category = fAddressAppInfo->categoryName(cat);
+ 	_setCategory(toAbEntry, category);
+ #ifdef DEBUG
+ 	showAddressee(toAbEntry);
+@@ -2266,3 +2292,24 @@ Addressee AbbrowserConduit::_findMatch(c
+ 	return Addressee();
+ }
+ 
++void AbbrowserConduit::slotTestRecord()
++{
++	FUNCTIONSETUP;
++
++	// Get a record and interpret it as an address.
++	PilotRecord *r = fDatabase->readRecordByIndex( pilotindex );
++	if (!r)
++	{
++		delayDone();
++		return;
++	}
++	PilotAddress a(fAddressAppInfo,r);
++	KPILOT_DELETE(r);
++
++	// Process this record.
++	showPilotAddress(&a);
++
++	// Schedule more work.
++	++pilotindex;
++	QTimer::singleShot(0, this, SLOT(slotTestRecord()));
++}
+diff -pruN kpilot/conduits/abbrowserconduit/abbrowser-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/abbrowser-conduit.h
+--- kpilot/conduits/abbrowserconduit/abbrowser-conduit.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/abbrowser-conduit.h	2006-11-19 22:21:12.000000000 +0100
+@@ -56,7 +56,7 @@ class AbbrowserConduit : public ConduitA
+ {
+ Q_OBJECT
+ public:
+-	AbbrowserConduit(KPilotDeviceLink *o,const char *n = 0L,
++	AbbrowserConduit(KPilotLink *o,const char *n = 0L,
+ 		const QStringList &a = QStringList() );
+ 	virtual ~AbbrowserConduit();
+ 
+@@ -72,6 +72,8 @@ protected slots:
+ 	void slotDeleteUnsyncedHHRecords();
+ 	void slotCleanup();
+ 
++	void slotTestRecord();
++
+ private:
+ 
+ 	/********************************************************/
+diff -pruN kpilot/conduits/abbrowserconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/CMakeLists.txt
+--- kpilot/conduits/abbrowserconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,40 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_abbrowser_SRCS
++	resolutionDialog.cc
++	abbrowser-factory.cc
++	abbrowser-setup.cc 
++	abbrowser-conduit.cc
++)
++
++set(conduit_abbrowser_UIS
++	resolutionDialog_base.ui
++	kaddressbookConduit.ui
++)
++
++set(conduit_abbrowser_KCFGS
++	abbrowserSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_abbrowser_SRCS ${conduit_abbrowser_KCFGS})
++kde3_add_ui_files(conduit_abbrowser_SRCS ${conduit_abbrowser_UIS})
++kde3_automoc(${conduit_abbrowser_SRCS})
++add_library(conduit_address SHARED ${conduit_abbrowser_SRCS})
++target_link_libraries(conduit_address kabc_file)
++set_target_properties(conduit_address PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_address)
++
++install(
++	TARGETS conduit_address
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES abbrowser_conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
+diff -pruN kpilot/conduits/abbrowserconduit/kaddressbookConduit.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/kaddressbookConduit.ui
+--- kpilot/conduits/abbrowserconduit/kaddressbookConduit.ui	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/kaddressbookConduit.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -738,9 +738,9 @@
+     <tabstop>fFax</tabstop>
+ </tabstops>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/abbrowserconduit/resolutionDialog.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/resolutionDialog.cc
+--- kpilot/conduits/abbrowserconduit/resolutionDialog.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/resolutionDialog.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -171,8 +171,8 @@ void ResolutionCheckListItem::updateText
+  *
+  *****************************************************************/
+ 
+-ResolutionDlg::ResolutionDlg( QWidget* parent, KPilotDeviceLink*fH,
+-	QString caption, QString helpText, ResolutionTable*tab) :
++ResolutionDlg::ResolutionDlg( QWidget* parent, KPilotLink*fH,
++	const QString &caption, const QString &helpText, ResolutionTable*tab) :
+ 	KDialogBase( parent, "ResolutionDlg", false, caption, Apply|Cancel, Apply),
+ 	tickleTimer(0L),
+ 	fHandle(fH),
+diff -pruN kpilot/conduits/abbrowserconduit/resolutionDialog.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/resolutionDialog.h
+--- kpilot/conduits/abbrowserconduit/resolutionDialog.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/abbrowserconduit/resolutionDialog.h	2006-11-19 22:21:12.000000000 +0100
+@@ -29,7 +29,7 @@
+ */
+ 
+ #include <kdialogbase.h>
+-class KPilotDeviceLink;
++class KPilotLink;
+ class QTimer;
+ class QListView;
+ class ResolutionDialogBase;
+@@ -42,7 +42,11 @@ class ResolutionDlg : public KDialogBase
+     Q_OBJECT
+ 
+ public:
+-	ResolutionDlg( QWidget* parent=0, KPilotDeviceLink*fH=0L, QString caption=QString::null, QString helpText=QString::null, ResolutionTable*tab=0L );
++	ResolutionDlg( QWidget* parent=0, 
++		KPilotLink*fH=0L, 
++		const QString &caption=QString(), 
++		const QString &helpText=QString(), 
++		ResolutionTable *tab=0L );
+ 	~ResolutionDlg();
+ 
+ public slots:
+@@ -57,10 +61,10 @@ protected:
+ 	void adjustButtons(ResolutionTable*tab);
+ 
+ 	QTimer* tickleTimer;
+-	KPilotDeviceLink* fHandle;
++	KPilotLink* fHandle;
+ 	ResolutionTable*fTable;
+ 
+ 	ResolutionDialogBase*fWidget;
+ };
+ 
+-#endif // MYDIALOG_H
++#endif // RESOLUTIONDIALOG_H
+diff -pruN kpilot/conduits/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/CMakeLists.txt
+--- kpilot/conduits/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,26 @@
++include_directories(
++	${CMAKE_BINARY_DIR}/lib
++	${CMAKE_SOURCE_DIR}/lib
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++add_subdirectory(abbrowserconduit)
++# add_subdirectory(docconduit)
++add_subdirectory(knotes)
++add_subdirectory(memofileconduit)
++add_subdirectory(notepadconduit)
++add_subdirectory(null)
++add_subdirectory(popmail)
++add_subdirectory(sysinfoconduit)
++add_subdirectory(timeconduit)
++add_subdirectory(vcalconduit)
++
++# MAL seems to be broken, or the MAL API has changed somewhat
++# since the last time that the conduit was compiled by the development
++# team. Since we don't use the conduit it is disabled. 
++IF (MAL_FOUND)
++	# add_subdirectory(malconduit)
++	MESSAGE(STATUS "Although mal was found, the malconduit will not be compiled since it is unmaintained")
++ELSE (MAL_FOUND)
++	MESSAGE(STATUS "Couldn't find mal. Won't be able to build malconduit")
++ENDIF (MAL_FOUND)
+diff -pruN kpilot/conduits/docconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/CMakeLists.txt
+--- kpilot/conduits/docconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,60 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_doc_SRCS
++	makedoc9.cc 
++	pilotDOCHead.cc 
++	pilotDOCEntry.cc 
++	pilotDOCBookmark.cc 
++	DOC-converter.cc
++	kpalmdoc_dlg.cc 
++	kpalmdoc.cpp
++	doc-factory.cc
++	doc-setup.cc
++	doc-conduit.cc
++	doc-conflictdialog.cc
++)
++
++set(conduit_doc_UIS
++	kpalmdoc_dlgbase.ui
++)
++
++set(conduit_doc_KCFGS
++	docconduitSettings.kcfgc
++	kpalmdocSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_doc_SRCS ${conduit_doc_KCFGS})
++kde3_add_ui_files(conduit_doc_SRCS ${conduit_doc_UIS})
++kde3_automoc(${conduit_doc_SRCS})
++add_library(conduit_doc SHARED ${conduit_doc_SRCS})
++
++kpilot_rpath(conduit_doc)
++
++set_target_properties(
++	conduit_doc PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_doc)
++
++install(
++	TARGETS conduit_doc
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES doc_conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
++
++install(
++	FILES docconduit.kcfg kpalmdoc.kcfg DESTINATION ${KDE3_KCFG_DIR}
++)
++
++install(
++	FILES kpalmdoc.upd 
++	DESTINATION ${CMAKE_INSTALL_PREFIX}/share/apps/kconf_update
++)
++
++add_subdirectory(Icons)
+diff -pruN kpilot/conduits/docconduit/doc-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conduit.cc
+--- kpilot/conduits/docconduit/doc-conduit.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -56,8 +56,7 @@
+ // the modules are that make up a binary distribution.
+ extern "C"
+ {
+-long version_conduit_doc = KPILOT_PLUGIN_API;
+-const char *id_conduit_doc = "$Id: doc-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
++unsigned long version_conduit_doc = Pilot::PLUGIN_API;
+ }
+ 
+ QString dirToString(eSyncDirectionEnum dir) {
+@@ -78,13 +77,10 @@ QString dirToString(eSyncDirectionEnum d
+  *********************************************************************/
+ 
+ 
+-DOCConduit::DOCConduit(KPilotDeviceLink * o,
++DOCConduit::DOCConduit(KPilotLink * o,
+ 	const char *n, const QStringList & a):ConduitAction(o, n, a)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<id_conduit_doc<<endl;
+-#endif
+ 	fConduitName=i18n("DOC");
+ }
+ 
+@@ -269,9 +265,6 @@ QString DOCConduit::constructTXTFileName
+ /* virtual */ bool DOCConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<"Conduit version: "<<id_conduit_doc<<endl;
+-#endif
+ 
+ 	readConfig();
+ 	dbnr=0;
+@@ -330,7 +323,7 @@ bool DOCConduit::doSync(docSyncInfo &sin
+ 	// instance which points either to a local database or a database on the handheld.
+ 	PilotDatabase *database = preSyncAction(sinfo);
+ 
+-	if (database && ( !database->isDBOpen() ) ) {
++	if (database && ( !database->isOpen() ) ) {
+ #ifdef DEBUG
+ 		DEBUGCONDUIT<<"Database "<<sinfo.dbinfo.name<<" does not yet exist. Creating it:"<<endl;
+ #endif
+@@ -342,7 +335,7 @@ bool DOCConduit::doSync(docSyncInfo &sin
+ 		}
+ 	}
+ 
+-	if (database && database->isDBOpen()) {
++	if (database && database->isOpen()) {
+ 		DOCConverter docconverter;
+ 		connect(&docconverter, SIGNAL(logError(const QString &)), SIGNAL(logError(const QString &)));
+ 		connect(&docconverter, SIGNAL(logMessage(const QString &)), SIGNAL(logMessage(const QString &)));
+@@ -720,7 +713,7 @@ bool DOCConduit::needsSync(docSyncInfo &
+ 
+ 		if (QFile::exists(sinfo.txtfilename)) sinfo.fPCStatus=eStatNew;
+ 		else sinfo.fPCStatus=eStatDoesntExist;
+-		if (docdb && docdb->isDBOpen()) sinfo.fPalmStatus=eStatNew;
++		if (docdb && docdb->isOpen()) sinfo.fPalmStatus=eStatNew;
+ 		else sinfo.fPalmStatus=eStatDoesntExist;
+ 		KPILOT_DELETE(docdb);
+ 
+@@ -771,7 +764,7 @@ bool DOCConduit::needsSync(docSyncInfo &
+ #endif
+ 	}
+ 
+-	if (!docdb || !docdb->isDBOpen()) sinfo.fPalmStatus=eStatDeleted;
++	if (!docdb || !docdb->isOpen()) sinfo.fPalmStatus=eStatDeleted;
+ 	else if (hhTextChanged(docdb)) {
+ #ifdef DEBUG
+ 		DEBUGCONDUIT<<"Handheld side has changed!"<<endl;
+diff -pruN kpilot/conduits/docconduit/doc_conduit.desktop /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/doc_conduit.desktop
+--- kpilot/conduits/docconduit/doc_conduit.desktop	2006-10-01 19:30:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/doc_conduit.desktop	2006-10-15 07:31:57.000000000 +0200
+@@ -17,7 +17,7 @@ Comment[fr]=Ajoute des fichiers texte à
+ Comment[hu]=Szöveges fájlok hozzáadása a kézi számítógéphez, DOC-olvasók számára.
+ Comment[is]=Bætir textaskrám, sem hægt er að lesa í DOC lesara, við lófatölvuna þína.
+ Comment[it]=Aggiunge file di testo al tuo Pilot, adatti per lettori DOC.
+-Comment[ja]=テキストファイルを DOC リーダに適した形式でハンドヘルドに追加します。
++Comment[ja]=テキストファイルを DOC リーダーに適した形式でハンドヘルドに追加します。
+ Comment[km]=បន្ថែម​ឯកសារ​អត្ថបទ​ទៅ​ឧបករណ៍​យួរ​ដៃ​របស់​អ្នក (សមស្រប​សម្រាប់​កម្មវិធី​អាន DOC) ។
+ Comment[lt]=Prideda teksto bylas prie Jūsų nešiojamos knygelės, tinka DOC skaityklėms.
+ Comment[ms]=Menambah fail teks ke komputer telapak, sesuai dengan pembaca DOC.
+diff -pruN kpilot/conduits/docconduit/doc-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conduit.h
+--- kpilot/conduits/docconduit/doc-conduit.h	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conduit.h	2006-11-26 23:53:25.000000000 +0100
+@@ -59,7 +59,7 @@ public:
+ 	eSyncDirectionEnum eSyncDirection;
+ 
+ public:
+-	DOCConduit(KPilotDeviceLink * o,
++	DOCConduit(KPilotLink * o,
+ 		const char *n = 0L, const QStringList & a = QStringList());
+ 	 virtual ~ DOCConduit();
+ 
+diff -pruN kpilot/conduits/docconduit/doc-conflictdialog.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conflictdialog.cc
+--- kpilot/conduits/docconduit/doc-conflictdialog.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conflictdialog.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -39,7 +39,7 @@
+ #include <qscrollview.h>
+ 
+ 
+-ResolutionDialog::ResolutionDialog( QWidget* parent, const QString& caption, syncInfoList*sinfo, KPilotDeviceLink*lnk )
++ResolutionDialog::ResolutionDialog( QWidget* parent, const QString& caption, syncInfoList*sinfo, KPilotLink*lnk )
+     : KDialogBase( parent, "resolutionDialog", true, caption, KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true), tickleTimer(0L), fHandle(lnk) {
+ 	FUNCTIONSETUP;
+ 	syncInfo=sinfo;
+diff -pruN kpilot/conduits/docconduit/doc-conflictdialog.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conflictdialog.h
+--- kpilot/conduits/docconduit/doc-conflictdialog.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/doc-conflictdialog.h	2006-11-26 23:53:25.000000000 +0100
+@@ -39,7 +39,7 @@ class QGroupBox;
+ class QLabel;
+ class QPushButton;
+ class QTimer;
+-class KPilotDeviceLink;
++class KPilotLink;
+ 
+ 
+ typedef struct conflictEntry {
+@@ -56,7 +56,7 @@ class ResolutionDialog : public KDialogB
+ 	Q_OBJECT
+ 
+ public:
+-	ResolutionDialog( QWidget* parent=0, const QString& caption=i18n("Resolution Dialog"), syncInfoList*sinfo=0L, KPilotDeviceLink*lnk=0L);
++	ResolutionDialog( QWidget* parent=0, const QString& caption=i18n("Resolution Dialog"), syncInfoList*sinfo=0L, KPilotLink*lnk=0L);
+ 	~ResolutionDialog();
+ 
+ 	bool hasConflicts;
+@@ -64,7 +64,7 @@ public slots:
+ 	void _tickle();
+ protected:
+ 	QTimer* tickleTimer;
+-	KPilotDeviceLink* fHandle;
++	KPilotLink* fHandle;
+ 
+ protected:
+ 	QGroupBox* resolutionGroupBox;
+diff -pruN kpilot/conduits/docconduit/DOC-converter.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/DOC-converter.cc
+--- kpilot/conduits/docconduit/DOC-converter.cc	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/DOC-converter.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -45,10 +45,6 @@
+ 
+ 
+ 
+-// Something to allow us to check what revision
+-// the modules are that make up a binary distribution.
+-const char *doc_converter_id = "$Id: DOC-converter.cc 476284 2005-11-01 01:48:20Z thiago $";
+-
+ #define min(a,b) (a<b)?(a):(b)
+ 
+ 
+@@ -154,7 +150,6 @@ DOCConverter::DOCConverter(QObject *pare
+ 	docdb=0L;
+ 	eSortBookmarks=eSortNone;
+ 	fBookmarks.setAutoDelete( TRUE );
+-	(void) doc_converter_id;
+ }
+ 
+ 
+@@ -441,7 +436,7 @@ bool DOCConverter::convertTXTtoPDB() {
+ 	}
+ #endif
+ 
+-	if (!docdb->isDBOpen()) {
++	if (!docdb->isOpen()) {
+ 		emit logError(i18n("Unable to open palm doc database %1").arg(docdb->dbPathName()) );
+ 		return false;
+ 	}
+diff -pruN kpilot/conduits/docconduit/doc-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/doc-factory.cc
+--- kpilot/conduits/docconduit/doc-factory.cc	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/doc-factory.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -101,7 +101,7 @@ DOCConduitFactory::~DOCConduitFactory()
+ 	}
+ 	if (qstrcmp(c, "SyncAction") == 0)
+ 	{
+-		KPilotDeviceLink * d = dynamic_cast < KPilotDeviceLink * >(p);
++		KPilotLink * d = dynamic_cast < KPilotLink * >(p);
+ 		if (d)
+ 		{
+ 			return new DOCConduit(d, n, a);
+@@ -109,7 +109,7 @@ DOCConduitFactory::~DOCConduitFactory()
+ 		else
+ 		{
+ 			kdError() << k_funcinfo
+-				<<": Couldn't cast parent to KPilotDeviceLink" <<endl;
++				<<": Couldn't cast parent to KPilotLink" <<endl;
+ 			return 0L;
+ 		}
+ 	}
+diff -pruN kpilot/conduits/docconduit/doc-setupdialog.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/doc-setupdialog.ui
+--- kpilot/conduits/docconduit/doc-setupdialog.ui	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/doc-setupdialog.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -549,12 +549,9 @@
+     <tabstop>RadioButton1</tabstop>
+ </tabstops>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/docconduit/Icons/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/Icons/CMakeLists.txt
+--- kpilot/conduits/docconduit/Icons/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/Icons/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,3 @@
++
++kde3_install_icons_custom( hicolor )
++
+diff -pruN kpilot/conduits/docconduit/kpalmdoc_dlgbase.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/kpalmdoc_dlgbase.ui
+--- kpilot/conduits/docconduit/kpalmdoc_dlgbase.ui	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/kpalmdoc_dlgbase.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -427,14 +427,9 @@
+     </connection>
+ </connections>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/docconduit/kpalmdoc_dlg.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/kpalmdoc_dlg.cc
+--- kpilot/conduits/docconduit/kpalmdoc_dlg.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/kpalmdoc_dlg.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -459,7 +459,7 @@ bool ConverterDlg::convertTXTtoPDB(QStri
+ 		PilotLocalDatabase*pdbdb=new PilotLocalDatabase(pdbdir, QFileInfo(pdbfile).baseName(), false);
+ 		if (pdbdb)
+ 		{
+-			if (!pdbdb->isDBOpen())
++			if (!pdbdb->isOpen())
+ 			{
+ #ifdef DEBUG
+ 				DEBUGCONDUIT<<pdbfile<<" does not yet exist. Creating it"<<endl;
+@@ -468,7 +468,7 @@ bool ConverterDlg::convertTXTtoPDB(QStri
+ 				}
+ 			}
+ 
+-			if (pdbdb->isDBOpen())
++			if (pdbdb->isOpen())
+ 			{
+ 				conv->setPDB(pdbdb);
+ 				conv->setTXTpath(txtdir, txtfile);
+@@ -504,7 +504,7 @@ bool ConverterDlg::convertPDBtoTXT(QStri
+ 		PilotLocalDatabase*pdbdb=new PilotLocalDatabase(pdbdir, QFileInfo(pdbfile).baseName(), false);
+ 		if (pdbdb)
+ 		{
+-			if (pdbdb->isDBOpen())
++			if (pdbdb->isOpen())
+ 			{
+ 				conv->setPDB(pdbdb);
+ 				conv->setTXTpath(txtdir, txtfile);
+diff -pruN kpilot/conduits/docconduit/pilotDOCBookmark.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCBookmark.cc
+--- kpilot/conduits/docconduit/pilotDOCBookmark.cc	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCBookmark.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -31,12 +31,7 @@
+ 
+ 
+ 
+-static const char *pilotDOCBookmark_id =
+-	"$Id: pilotDOCBookmark.cc 476284 2005-11-01 01:48:20Z thiago $";
+-
+-
+-
+-PilotDOCBookmark::PilotDOCBookmark():PilotAppCategory(), pos(0)
++PilotDOCBookmark::PilotDOCBookmark():PilotRecordBase(), pos(0)
+ {
+ 	FUNCTIONSETUP;
+ 	memset(&bookmarkName[0], 0, 16);
+@@ -46,21 +41,21 @@ PilotDOCBookmark::PilotDOCBookmark():Pil
+ 
+ /* initialize the entry from another one. If rec==NULL, this constructor does the same as PilotDOCBookmark()
+ */
+-PilotDOCBookmark::PilotDOCBookmark(PilotRecord * rec):PilotAppCategory(rec)
++PilotDOCBookmark::PilotDOCBookmark(PilotRecord * rec):PilotRecordBase(rec)
+ {
+ 	if (rec)
+ 	{
+-		strncpy(&bookmarkName[0], (char *) rec->data(), 16);
++		const pi_buffer_t *b = rec->buffer();
++		unsigned int offset = 0;
++		dlp<char *>::read(b,offset,bookmarkName,16);
+ 		bookmarkName[16]='\0';
+-		pos = get_long(&rec->data()[16]);// << 8 + (rec->getData())[17];
++		pos = dlp<long>::read(b,offset);
+ 	}
+-	(void) pilotDOCBookmark_id;
+ }
+ 
+ 
+ 
+-PilotDOCBookmark::
+-PilotDOCBookmark(const PilotDOCBookmark & e):PilotAppCategory(e)
++PilotDOCBookmark::PilotDOCBookmark(const PilotDOCBookmark & e):PilotRecordBase(e)
+ {
+ 	FUNCTIONSETUP;
+ 	*this = e;
+@@ -81,15 +76,12 @@ PilotDOCBookmark & PilotDOCBookmark::ope
+ 
+ 
+ 
+-void *PilotDOCBookmark::pack_(void *buf, int *len)
++PilotRecord *PilotDOCBookmark::pack() const
+ {
+-	char *tmp = (char *) buf;
+-
+-//  buf=malloc(16*sizeof(char)+sizeof(long int));
+-	strncpy(tmp, &bookmarkName[0], 16);
+-	//*(long int *) (tmp + 16) = pos;
+-	set_long(tmp + 16, pos);
+-	*len = 20;
+-	return buf;
++	pi_buffer_t *b = pi_buffer_new( 16 + dlp<long>::size );
++	pi_buffer_append(b, bookmarkName, 16);
++	b->data[16] = 0;
++	dlp<long>::append(b,pos);
++	PilotRecord* rec =  new PilotRecord(b, this);
++	return rec;
+ }
+-
+diff -pruN kpilot/conduits/docconduit/pilotDOCBookmark.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCBookmark.h
+--- kpilot/conduits/docconduit/pilotDOCBookmark.h	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCBookmark.h	2006-11-26 23:53:25.000000000 +0100
+@@ -18,7 +18,7 @@
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ ** MA 02110-1301, USA.
+ */
+ 
+@@ -28,11 +28,11 @@
+ #ifndef _KPILOT_PILOTDOCBOOKMARK_H
+ #define _KPILOT_PILOTDOCBOOKMARK_H
+ 
+-#include <pilotAppCategory.h>
++#include <pilotRecord.h>
+ class PilotRecord;
+ 
+ 
+-class PilotDOCBookmark:public PilotAppCategory {
++class PilotDOCBookmark:public PilotRecordBase {
+ public:
+ 	PilotDOCBookmark();
+ 	PilotDOCBookmark(PilotRecord * rec);
+@@ -40,9 +40,7 @@ public:
+ 	~PilotDOCBookmark() {};
+ 	PilotDOCBookmark & operator=(const PilotDOCBookmark & e);
+ 
+-protected:
+-	void *pack_(void *, int *);
+-	void unpack(const void *, int = 0) {}
++	PilotRecord *pack() const;
+ 
+ public:
+ 	char bookmarkName[17];
+diff -pruN kpilot/conduits/docconduit/pilotDOCEntry.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCEntry.cc
+--- kpilot/conduits/docconduit/pilotDOCEntry.cc	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCEntry.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -31,12 +31,10 @@
+ 
+ 
+ 
+-static const char *pilotDOCEntry_id =
+-	"$Id: pilotDOCEntry.cc 476284 2005-11-01 01:48:20Z thiago $";
+ const int PilotDOCEntry::TEXT_SIZE = 4096;
+ 
+ 
+-PilotDOCEntry::PilotDOCEntry():PilotAppCategory()
++PilotDOCEntry::PilotDOCEntry():PilotRecordBase()
+ {
+ 	FUNCTIONSETUP;
+ 	compress = false;
+@@ -46,16 +44,15 @@ PilotDOCEntry::PilotDOCEntry():PilotAppC
+ 
+ /* initialize the entry from another one. If rec==NULL, this constructor does the same as PilotDOCEntry()
+ */
+-PilotDOCEntry::PilotDOCEntry(PilotRecord * rec, bool compressed):PilotAppCategory(rec)
++PilotDOCEntry::PilotDOCEntry(PilotRecord * rec, bool compressed):PilotRecordBase(rec)
+ {
+ 	if (rec) fText.setText((unsigned char *) rec->data(), rec->size(), compressed);
+ 	compress = compressed;
+-	(void) pilotDOCEntry_id;
+ }
+ 
+ 
+ 
+-PilotDOCEntry::PilotDOCEntry(const PilotDOCEntry & e):PilotAppCategory(e)
++PilotDOCEntry::PilotDOCEntry(const PilotDOCEntry & e):PilotRecordBase(e)
+ {
+ 	FUNCTIONSETUP;
+ 	// See PilotDateEntry::operator = for details
+@@ -77,24 +74,19 @@ PilotDOCEntry & PilotDOCEntry::operator 
+ 
+ 
+ 
+-void *PilotDOCEntry::pack_(void *buf, int *len)
++
++PilotRecord *PilotDOCEntry::pack()
+ {
+-//      int len;
+-	if (compress)
+-	{
+-		*len = fText.Compress();
+-	}
+-	else
+-	{
+-		*len = fText.Decompress();
+-	}
+-	if (len > 0)
++	int len = compress ? fText.Compress() : fText.Decompress();
++
++	if (len<0)
+ 	{
+-//              char*out=new char[len];
+-		memcpy(buf, (const char *) fText.text(), *len);
+-		return buf;
++		return 0L;
+ 	}
+-	return 0L;
+-}
+-
+ 
++	pi_buffer_t *b = pi_buffer_new( len + 4 ); // +4 for safety
++	memcpy( b->data, (const char *) fText.text(), len );
++	b->used = len;
++	PilotRecord* rec =  new PilotRecord(b, this);
++	return rec;
++}
+diff -pruN kpilot/conduits/docconduit/pilotDOCEntry.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCEntry.h
+--- kpilot/conduits/docconduit/pilotDOCEntry.h	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCEntry.h	2006-11-26 23:53:25.000000000 +0100
+@@ -18,7 +18,7 @@
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ ** MA 02110-1301, USA.
+ */
+ 
+@@ -28,14 +28,14 @@
+ #ifndef _KPILOT_PILOTDOCENTRY_H
+ #define _KPILOT_PILOTDOCENTRY_H
+ 
+-#include <pilotAppCategory.h>
++#include <pilotRecord.h>
+ #include "makedoc9.h"
+ 
+ 
+ class PilotRecord;
+ 
+ 
+-class PilotDOCEntry:public PilotAppCategory {
++class PilotDOCEntry:public PilotRecordBase {
+ private:
+ 	bool compress;
+ 	tBuf fText;
+@@ -64,10 +64,7 @@ public:
+ 		compress = compressed;
+ 	};
+ 
+-protected:
+-	void *pack_(void *, int *);
+-	void unpack(const void *, int = 0) {
+-	}
++	PilotRecord *pack(); // Not const because it can change the compression
+ };
+ 
+ 
+diff -pruN kpilot/conduits/docconduit/pilotDOCHead.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCHead.cc
+--- kpilot/conduits/docconduit/pilotDOCHead.cc	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCHead.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -32,31 +32,34 @@
+ 
+ 
+ 
+-static const char *pilotDOCHead_id =
+-	"$Id: pilotDOCHead.cc 476284 2005-11-01 01:48:20Z thiago $";
+ const int PilotDOCHead::textRecordSize = 4096;
+ 
+-
+-
+-PilotDOCHead::PilotDOCHead():PilotAppCategory(),
++PilotDOCHead::PilotDOCHead():PilotRecordBase(),
+ version(0),
+ spare(0), storyLen(0), numRecords(0), recordSize(textRecordSize), position(0)
+ {
+ 	FUNCTIONSETUP;
+-	(void) pilotDOCHead_id;
+ }
+ 
+ 
+ 
+ /* initialize the entry from another one. If rec==NULL, this constructor does the same as PilotDOCHead()
+ */
+-PilotDOCHead::PilotDOCHead(PilotRecord * rec):PilotAppCategory(rec)
++PilotDOCHead::PilotDOCHead(PilotRecord * rec):PilotRecordBase(rec)
+ {
+-	unpack((const void *) rec->data());
++	const unsigned char *b = (const unsigned char *) rec->data();
++	unsigned int offset = 0;
++
++	version = dlp<short>::read(b,offset);
++	spare = dlp<short>::read(b,offset);
++	storyLen = dlp<long>::read(b,offset);
++	numRecords = dlp<short>::read(b,offset);
++	recordSize = dlp<short>::read(b,offset);
++	position = dlp<long>::read(b,offset);
+ }
+ 
+ 
+-PilotDOCHead::PilotDOCHead(const PilotDOCHead & e):PilotAppCategory(e)
++PilotDOCHead::PilotDOCHead(const PilotDOCHead & e):PilotRecordBase(e)
+ {
+ 	FUNCTIONSETUP;
+ 	*this = e;
+@@ -80,40 +83,19 @@ PilotDOCHead & PilotDOCHead::operator =(
+ 
+ 
+ 
+-void *PilotDOCHead::pack_(void *buf, int *len)
+-{
+-	char *tmp = (char *) buf;
+-
+-	*len = 16;
+-	set_short(tmp, version);
+-	tmp+=2;
+-	set_short(tmp, spare);
+-	tmp+=2;
+-	set_long(tmp, storyLen);
+-	tmp+=4;
+-	set_short(tmp, numRecords);
+-	tmp+=2;
+-	set_short(tmp, recordSize);
+-	tmp+=2;
+-	set_short(tmp, position);
+-	return buf;
+-}
+-
+ 
+-void PilotDOCHead::unpack(const void *buf, int)
++PilotRecord *PilotDOCHead::pack() const
+ {
+-	char *tmp = (char *) buf;
++	pi_buffer_t *b = pi_buffer_new(16);
++
++	dlp<short>::append(b,version);
++	dlp<short>::append(b,spare);
++	dlp<long>::append(b,storyLen);
++	dlp<short>::append(b,numRecords);
++	dlp<short>::append(b,recordSize);
++	dlp<long>::append(b,position);
+ 
+-	version = get_short(tmp);
+-	tmp+=2;
+-	spare = get_short(tmp);
+-	tmp+=2;
+-	storyLen = get_long(tmp);
+-	tmp+=4;
+-	numRecords = get_short(tmp);
+-	tmp+=2;
+-	recordSize = get_short(tmp);
+-	tmp+=2;
+-	position = get_long(tmp);
++	PilotRecord *rec =  new PilotRecord(b, this);
++	return rec;
+ }
+ 
+diff -pruN kpilot/conduits/docconduit/pilotDOCHead.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCHead.h
+--- kpilot/conduits/docconduit/pilotDOCHead.h	2005-11-08 23:33:38.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/docconduit/pilotDOCHead.h	2006-11-26 23:53:25.000000000 +0100
+@@ -18,7 +18,7 @@
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ ** MA 02110-1301, USA.
+ */
+ 
+@@ -28,12 +28,12 @@
+ #ifndef _KPILOT_PILOTDOCHEAD_H
+ #define _KPILOT_PILOTDOCHEAD_H
+ 
+-#include <pilotAppCategory.h>
++#include <pilotRecord.h>
+ 
+ class PilotRecord;
+ 
+ 
+-class PilotDOCHead:public PilotAppCategory {
++class PilotDOCHead:public PilotRecordBase {
+  private:
+ 	static const int textRecordSize;
+ 
+@@ -45,17 +45,15 @@ class PilotDOCHead:public PilotAppCatego
+ 	int recordSize;
+ 	long int position;
+ 
++	PilotRecord *pack() const;
++
+  public:
+ 	 PilotDOCHead();
+ 	 PilotDOCHead(PilotRecord * rec);
+ 	 PilotDOCHead(const PilotDOCHead & e);
+-	~PilotDOCHead() {
+-	} PilotDOCHead & operator=(const PilotDOCHead & e);
+-
++	~PilotDOCHead() { }
+ 
+- protected:
+-	void *pack_(void *, int *);
+-	void unpack(const void *, int = 0);
++	PilotDOCHead & operator=(const PilotDOCHead & e);
+ };
+ 
+ 
+diff -pruN kpilot/conduits/knotes/knotes-action.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/knotes/knotes-action.cc
+--- kpilot/conduits/knotes/knotes-action.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/knotes/knotes-action.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -57,8 +57,7 @@
+ extern "C"
+ {
+ 
+-long version_conduit_knotes = KPILOT_PLUGIN_API;
+-const char *id_conduit_knotes = "$Id: knotes-action.cc 437980 2005-07-23 19:53:57Z kainhofe $" ;
++unsigned long version_conduit_knotes = Pilot::PLUGIN_API;
+ 
+ }
+ 
+@@ -183,7 +182,7 @@ public:
+ 
+ 
+ 
+-KNotesAction::KNotesAction(KPilotDeviceLink *o,
++KNotesAction::KNotesAction(KPilotLink *o,
+ 	const char *n, const QStringList &a) :
+ 	ConduitAction(o,n ? n : "knotes-conduit",a),
+ 	fP(new KNotesActionPrivate)
+@@ -361,7 +360,6 @@ void KNotesAction::listNotes()
+ 			listNotes(); // Debugging
+ 			fActionStatus = MemosToKNotes;
+ 			break;
+-		case SyncAction::SyncMode::eFastSync:
+ 		case SyncAction::SyncMode::eHotSync:
+ 		case SyncAction::SyncMode::eFullSync:
+ 		case SyncAction::SyncMode::eCopyPCToHH:
+@@ -396,7 +394,6 @@ void KNotesAction::listNotes()
+ 				// Impossible!
+ 				fActionStatus = Done;
+ 				break;
+-			case SyncAction::SyncMode::eFastSync:
+ 			case SyncAction::SyncMode::eHotSync:
+ 			case SyncAction::SyncMode::eFullSync:
+ 				fActionStatus = MemosToKNotes;
+diff -pruN kpilot/conduits/knotes/knotes-action.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/knotes/knotes-action.h
+--- kpilot/conduits/knotes/knotes-action.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/knotes/knotes-action.h	2006-11-26 23:53:25.000000000 +0100
+@@ -28,7 +28,7 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include "plugin.h"
++#include <plugin.h>
+ 
+ 
+ class NoteAndMemo;
+@@ -39,7 +39,7 @@ class KNotesAction : public ConduitActio
+ Q_OBJECT
+ public:
+ 	KNotesAction(
+-		KPilotDeviceLink *o,
++		KPilotLink *o,
+ 		const char *n = 0L,
+ 		const QStringList &a = QStringList() );
+ 	virtual ~KNotesAction();
+diff -pruN kpilot/conduits/knotes/knotes-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/knotes/knotes-factory.cc
+--- kpilot/conduits/knotes/knotes-factory.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/knotes/knotes-factory.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -114,7 +114,7 @@ KNotesConduitFactory::~KNotesConduitFact
+ 	else
+ 	if (qstrcmp(c,"SyncAction")==0)
+ 	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
++		KPilotLink *d = dynamic_cast<KPilotLink *>(p);
+ 
+ 		if (d)
+ 		{
+diff -pruN kpilot/conduits/Makefile.am /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/Makefile.am
+--- kpilot/conduits/Makefile.am	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/Makefile.am	2006-11-26 23:53:25.000000000 +0100
+@@ -1,7 +1,4 @@
+ ###
+-### The todo conduit is deprecated -- well, it has moved to
+-### vcalconduit where it shares most of the code with the vcalconduit.
+-###
+ ### The NULL conduit is a neat programming example, but shouldn't be
+ ### installed on user systems.
+ ###
+@@ -10,30 +7,14 @@ if include_malconduit
+ MAL_SUBDIR = malconduit
+ endif
+ 
+-if include_abc
+-ABC_SUBDIR = abbrowserconduit vcalconduit
+-endif
+-
+-if include_perl
+-PERL_SUBDIR = perlconduit
+-endif
+-
+-if include_python
+-PYTHON_SUBDIR = pythonconduit
+-endif
+-
+-if include_notepad
+-NOTEPAD_SUBDIR = notepadconduit
+-endif
+-
+ SUBDIRS = \
+-          docconduit \
+           knotes \
+           popmail \
+           timeconduit \
+           sysinfoconduit \
+ 	  memofileconduit \
+-          $(MAL_SUBDIR) $(ABC_SUBDIR) $(NOTEPAD_SUBDIR)
++	  notepadconduit \
++	  abbrowserconduit vcalconduit
+ 
+ ###
+ ### Subdirs you might have for experimental purposes:
+@@ -41,7 +22,4 @@ SUBDIRS = \
+ ###	null             - a conduit that just logs a single message.
+ ###	$(PERL_SUBDIR)   - fires off a perl interpreter in a thread.
+ ###	$(PYTHON_SUBDIR) - starts a python interpreter in a thread.
+-###	notepadconduit   - a conduit to save notepad drawings as pngs.
+ ###
+-
+-
+diff -pruN kpilot/conduits/malconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/malconduit/CMakeLists.txt
+--- kpilot/conduits/malconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/malconduit/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,46 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++	${MAL_INCLUDE_DIR}
++)
++
++set(conduit_mal_SRCS
++	mal-factory.cc 
++	mal-setup.cc 
++	mal-conduit.cc 
++)
++
++set(conduit_mal_UIS
++	mal-setup_dialog.ui
++)
++
++set(conduit_mal_KCFGS
++	malconduitSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_mal_SRCS ${conduit_mal_KCFGS})
++kde3_add_ui_files(conduit_mal_SRCS ${conduit_mal_UIS})
++kde3_automoc(${conduit_mal_SRCS})
++add_library(conduit_mal SHARED ${conduit_mal_SRCS})
++
++kpilot_rpath(conduit_mal)
++
++set_target_properties(
++	conduit_mal PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_mal)
++
++install(
++	TARGETS conduit_mal
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES mal_conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
++
++install(
++	FILES malconduit.kcfg DESTINATION ${KDE3_KCFG_DIR}
++)
++
+diff -pruN kpilot/conduits/malconduit/mal-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/malconduit/mal-conduit.cc
+--- kpilot/conduits/malconduit/mal-conduit.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/malconduit/mal-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -44,12 +44,6 @@
+ #include "malconduitSettings.h"
+ 
+ 
+-// Something to allow us to check what revision
+-// the modules are that make up a binary distribution.
+-const char *MAL_conduit_id =
+-	"$Id: mal-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+-
+ static MALConduit *conduitInstance=0L;
+ 
+ int malconduit_logf(const char *, ...) __attribute__ ((format (printf, 1, 2)));
+@@ -113,7 +107,7 @@ static int32 cbItem (void */*out*/,
+ #endif
+ 
+  
+-MALConduit::MALConduit(KPilotDeviceLink * o,
++MALConduit::MALConduit(KPilotLink * o,
+ 	const char *n, 
+ 	const QStringList & a) :
+ 	ConduitAction(o, n, a)
+@@ -124,9 +118,6 @@ MALConduit::MALConduit(KPilotDeviceLink 
+ 	register_printErrorHook(malconduit_logf);
+ #endif
+ 	conduitInstance=this;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<MAL_conduit_id<<endl;
+-#endif
+ 	fConduitName=i18n("MAL");
+ }
+ 
+@@ -192,7 +183,6 @@ bool MALConduit::skip() 
+ /* virtual */ bool MALConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-	DEBUGCONDUIT<<MAL_conduit_id<<endl;
+ 
+ 	readConfig();
+ 	
+@@ -213,10 +203,6 @@ bool MALConduit::skip() 
+ 		return false;
+ 	}
+ 
+-#ifndef LIBMAL20
+-	pInfo->lowres = 1;
+-#endif
+-
+ 	QString proxyServer( MALConduitSettings::proxyServer() );
+ 	int proxyPort( MALConduitSettings::proxyPort() );
+ 	QString syncMessage;
+diff -pruN kpilot/conduits/malconduit/mal-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/malconduit/mal-conduit.h
+--- kpilot/conduits/malconduit/mal-conduit.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/malconduit/mal-conduit.h	2006-11-26 23:53:25.000000000 +0100
+@@ -40,7 +40,7 @@ class MALConduit : public ConduitAction
+ Q_OBJECT
+ public:
+ 	MALConduit(
+-		KPilotDeviceLink *o,
++		KPilotLink *o,
+ 		const char *n = 0L,
+ 		const QStringList &a = QStringList() );
+ 	virtual ~MALConduit();
+diff -pruN kpilot/conduits/malconduit/mal-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/malconduit/mal-factory.cc
+--- kpilot/conduits/malconduit/mal-factory.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/malconduit/mal-factory.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -121,7 +121,7 @@ MALConduitFactory::~MALConduitFactory()
+ 
+ 	if (qstrcmp(c,"SyncAction")==0)
+ 	{ 
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
++		KPilotLink *d = dynamic_cast<KPilotLink *>(p);
+ 
+ 		if (d)
+ 		{
+@@ -130,7 +130,7 @@ MALConduitFactory::~MALConduitFactory()
+ 		else
+ 		{
+ 			kdError() << k_funcinfo
+-				<< ": Couldn't cast parent to KPilotDeviceLink"
++				<< ": Couldn't cast parent to KPilotLink"
+ 				<< endl;
+ 			return 0L;
+ 		}
+diff -pruN kpilot/conduits/malconduit/mal-setup_dialog.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/malconduit/mal-setup_dialog.ui
+--- kpilot/conduits/malconduit/mal-setup_dialog.ui	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/malconduit/mal-setup_dialog.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -627,8 +627,8 @@
+     <tabstop>tabWidget</tabstop>
+ </tabstops>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>knuminput.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">knuminput.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/memofileconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/CMakeLists.txt
+--- kpilot/conduits/memofileconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,40 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_memofile_SRCS
++	memofile-factory.cc
++	memofile.cc
++	memofiles.cc
++	memofile-conduit.cc
++)
++
++set(conduit_memofile_UIS
++	setup_base.ui
++)
++
++set(conduit_memofile_KCFGS
++	memofileSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_memofile_SRCS ${conduit_memofile_KCFGS})
++kde3_add_ui_files(conduit_memofile_SRCS ${conduit_memofile_UIS})
++kde3_automoc(${conduit_memofile_SRCS})
++add_library(conduit_memofile SHARED ${conduit_memofile_SRCS})
++
++set_target_properties(
++	conduit_memofile PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_memofile)
++
++install(
++	TARGETS conduit_memofile
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES memofile-conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
+diff -pruN kpilot/conduits/memofileconduit/memofile.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile.cc
+--- kpilot/conduits/memofileconduit/memofile.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,13 +28,10 @@
+ #include "memofile.h"
+ 
+ Memofile::Memofile(PilotMemo * memo, QString categoryName, QString fileName, QString baseDirectory) :
+-		PilotMemo(memo->text()), _categoryName(categoryName), _filename(fileName),  _baseDirectory(baseDirectory)
++		PilotMemo(memo,memo->text()), _categoryName(categoryName), _filename(fileName),  _baseDirectory(baseDirectory)
+ {
+ 	_lastModified = 0;
+ 	_size = 0;
+-	setAttributes(memo->attributes());
+-	PilotAppCategory::setCategory(memo->category());
+-	setID(memo->id());
+ 	_modified = _modifiedByPalm = false;
+ }
+ 
+@@ -44,7 +41,7 @@ Memofile::Memofile(recordid_t id, int ca
+ 		_filename(fileName),_baseDirectory(baseDirectory)
+ {
+ 	setID(id);
+-	PilotAppCategory::setCategory(category);
++	PilotRecordBase::setCategory(category);
+ 	_lastModified = lastModifiedTime;
+ 	_size = size;
+ 	_modified = _modifiedByPalm = false;
+@@ -56,7 +53,7 @@ Memofile::Memofile(int category, QString
+ {
+ 	setID(0);
+ 	_new = true;
+-	PilotAppCategory::setCategory(category);
++	PilotRecordBase::setCategory(category);
+ 	_modified = true;
+ 	_modifiedByPalm = false;
+ 	_lastModified = 0;
+diff -pruN kpilot/conduits/memofileconduit/memofile-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-conduit.cc
+--- kpilot/conduits/memofileconduit/memofile-conduit.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -29,13 +29,6 @@
+ 
+ #include "options.h"
+ 
+-// Something to allow us to check what revision
+-// the modules are that make up a binary distribution.
+-//
+-//
+-static const char *memofile_conduit_id=
+-    "$Id: memofile-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ // Only include what we really need:
+ // First UNIX system stuff, then std C++,
+ // then Qt, then KDE, then local includes.
+@@ -55,7 +48,7 @@ static const char *memofile_conduit_id=
+ #include <kconfig.h>
+ #include <kdebug.h>
+ 
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ #include "pilotSerialDatabase.h"
+ #include "memofile-factory.h"
+ #include "memofile-conduit.h"
+@@ -65,7 +58,7 @@ static const char *memofile_conduit_id=
+ /**
+  * Our workhorse.  This is the main driver for the conduit.
+  */
+-MemofileConduit::MemofileConduit(KPilotDeviceLink *d,
++MemofileConduit::MemofileConduit(KPilotLink *d,
+                                  const char *n,
+                                  const QStringList &l) :
+ 		ConduitAction(d,n,l),
+@@ -74,9 +67,6 @@ MemofileConduit::MemofileConduit(KPilotD
+ 		_memofiles(0L)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<memofile_conduit_id<<endl;
+-#endif
+ 	fConduitName=i18n("Memofile");
+ 	fMemoList.setAutoDelete(true);
+ }
+@@ -195,7 +185,7 @@ bool MemofileConduit::setAppInfo()
+ 
+ 	fCategories = map;
+ 
+-	for (int i = 0; i < PILOT_CATEGORY_MAX; i++)
++	for (unsigned int i = 0; i < Pilot::CATEGORY_COUNT; i++)
+ 	{
+ 		if (fCategories.contains(i)) {
+ 			QString name = fCategories[i].left(16);
+@@ -272,9 +262,9 @@ bool MemofileConduit::loadPilotCategorie
+ 	int _category_id=0;
+ 	int _category_num=0;
+ 
+-	for (int i = 0; i < PILOT_CATEGORY_MAX; i++)
++	for (unsigned int i = 0; i < Pilot::CATEGORY_COUNT; i++)
+ 	{
+-		_category_name = fMemoAppInfo->category(i);
++		_category_name = fMemoAppInfo->categoryName(i);
+ 		if (!_category_name.isEmpty())
+ 		{
+ 			_category_name = Memofiles::sanitizeName( _category_name );
+@@ -504,8 +494,8 @@ void MemofileConduit::deleteUnsyncedHHRe
+ 	FUNCTIONSETUP;
+ 	if ( syncMode()==SyncMode::eCopyPCToHH )
+ 	{
+-		RecordIDList ids=fDatabase->idList();
+-		RecordIDList::iterator it;
++		Pilot::RecordIDList ids=fDatabase->idList();
++		Pilot::RecordIDList::iterator it;
+ 		for ( it = ids.begin(); it != ids.end(); ++it )
+ 		{
+ 			if (!_memofiles->find(*it))
+diff -pruN kpilot/conduits/memofileconduit/memofile-conduit.desktop /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-conduit.desktop
+--- kpilot/conduits/memofileconduit/memofile-conduit.desktop	2006-10-01 19:30:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-conduit.desktop	2006-10-11 07:33:54.000000000 +0200
+@@ -47,7 +47,7 @@ Comment[el]=Αυτός ο σύνδεσμ
+ Comment[es]=Este conducto sincroniza las notas de su agenda electrónica con el directorio local.
+ Comment[et]=See kanal sünkroniseerib pihuarvutis ja arvutis olevad memod.
+ Comment[eu]=Kanal honek zure agendako oharrak direktorio lokal batekin sinkronizatzen ditu.
+-Comment[fa]=این لوله، memo‌های دستی خود را با یک فهرست راهنمای محلی همگام‌سازی کنید.
++Comment[fa]=این لوله، memo‌های دستی خود را با یک فهرست راهنمای محلی همگام‌سازی می‌کند.
+ Comment[fi]=Tämä yhdyskäytävä synkronoi taskutietokoneen muistiot paikalliseen kansioon.
+ Comment[fr]=Ce canal synchronise les mémos du Palm avec ceux de KDE.
+ Comment[hu]=Ezzel a csatolóval egy kézi számítógép memóit lehet szinkronizálni a helyi címjegyzékkel.
+diff -pruN kpilot/conduits/memofileconduit/memofile-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-conduit.h
+--- kpilot/conduits/memofileconduit/memofile-conduit.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-conduit.h	2006-11-19 22:21:12.000000000 +0100
+@@ -38,7 +38,7 @@ class MemofileConduit : public ConduitAc
+ {
+ Q_OBJECT
+ public:
+-	MemofileConduit(KPilotDeviceLink *,
++	MemofileConduit(KPilotLink *,
+ 		const char *name=0L,
+ 		const QStringList &args = QStringList());
+ 	virtual ~MemofileConduit();
+diff -pruN kpilot/conduits/memofileconduit/memofile-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-factory.cc
+--- kpilot/conduits/memofileconduit/memofile-factory.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-factory.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -39,20 +39,10 @@
+ 
+ #include "setup_base.h"
+ #include "memofile-conduit.h"
+-#include "memofile-factory.moc"
+ #include "memofileSettings.h"
+ #include "uiDialog.h"
+ 
+-
+-extern "C"
+-{
+-
+-void *init_conduit_memofile()
+-{
+-	return new MemofileConduitFactory;
+-}
+-
+-}
++#include "pluginfactory.h"
+ 
+ class MemofileConduitConfig : public ConduitConfigBase
+ {
+@@ -70,7 +60,18 @@ MemofileConduitConfig::MemofileConduitCo
+ {
+ 	FUNCTIONSETUP;
+ 	fConduitName = i18n("Memofile");
+-	UIDialog::addAboutPage(fConfigWidget->tabWidget,MemofileConduitFactory::about());
++	KAboutData *about = new KAboutData("MemofileConduit",
++		I18N_NOOP("Memofile Conduit for KPilot"),
++		KPILOT_VERSION,
++		I18N_NOOP("Configures the Memofile Conduit for KPilot"),
++		KAboutData::License_GPL,
++		"(C) 2004, Jason 'vanRijn' Kasper");
++	about->addAuthor("Jason 'vanRijn' Kasper",
++		I18N_NOOP("Primary Author"),
++		"vR at movingparts.net",
++		"http://www.cs.kun.nl/~adridg/kpilot");
++
++	UIDialog::addAboutPage(fConfigWidget->tabWidget,about);
+ 	fWidget=fConfigWidget;
+ 	QObject::connect(fConfigWidget->fDirectory,SIGNAL(textChanged(const QString&)),
+ 		this,SLOT(modified()));
+@@ -116,77 +117,17 @@ MemofileConduitConfig::MemofileConduitCo
+ 	unmodified();
+ }
+ 
+-KAboutData *MemofileConduitFactory::fAbout = 0L;
+-MemofileConduitFactory::MemofileConduitFactory(QObject *p, const char *n) :
+-	KLibFactory(p,n)
+-{
+-	FUNCTIONSETUP;
+ 
+-	fInstance = new KInstance("Memofileconduit");
+-	fAbout = new KAboutData("MemofileConduit",
+-		I18N_NOOP("Memofile Conduit for KPilot"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Configures the Memofile Conduit for KPilot"),
+-		KAboutData::License_GPL,
+-		"(C) 2004, Jason 'vanRijn' Kasper");
+-	fAbout->addAuthor("Jason 'vanRijn' Kasper",
+-		I18N_NOOP("Primary Author"),
+-		"vR at movingparts.net",
+-		"http://www.cs.kun.nl/~adridg/kpilot");
+-}
+ 
+-MemofileConduitFactory::~MemofileConduitFactory()
++extern "C"
+ {
+-	FUNCTIONSETUP;
+ 
+-	KPILOT_DELETE(fInstance);
+-	KPILOT_DELETE(fAbout);
+-}
+-
+-/* virtual */ QObject *MemofileConduitFactory::createObject( QObject *p,
+-	const char *n,
+-	const char *c,
+-	const QStringList &a)
++void *init_conduit_memofile()
+ {
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< c
+-		<< endl;
+-#endif
++	return new ConduitFactory<MemofileConduitConfig,MemofileConduit>(0,"memofileconduit");
++}
+ 
+-	if (qstrcmp(c,"ConduitConfigBase")==0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(p);
+-		if (w)
+-		{
+-			return new MemofileConduitConfig(w);
+-		}
+-		else
+-		{
+-			return 0L;
+-		}
+-	}
+-	else if (qstrcmp(c,"SyncAction")==0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
+-
+-		if (d)
+-		{
+-			return new MemofileConduit(d,n,a);
+-		}
+-		else
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast to KPilotDeviceLink"
+-				<< endl;
+-			return 0L;
+-		}
+-	}
++unsigned long version_conduit_memofile = Pilot::PLUGIN_API;
+ 
+-	return 0L;
+ }
+ 
+-
+diff -pruN kpilot/conduits/memofileconduit/memofile-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-factory.h
+--- kpilot/conduits/memofileconduit/memofile-factory.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/memofile-factory.h	2006-11-19 22:21:12.000000000 +0100
+@@ -29,33 +29,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include <klibloader.h>
+-
+-#include "plugin.h"
+-
+-class MemofileWidget;
+-class KInstance;
+-class KAboutData;
+-
+-class MemofileConduitFactory : public KLibFactory
+-{
+-Q_OBJECT
+-
+-public:
+-	MemofileConduitFactory(QObject * = 0L,const char * = 0L);
+-	virtual ~MemofileConduitFactory();
+-
+-	static KAboutData *about() { return fAbout; } ;
+-
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() );
+-private:
+-	KInstance *fInstance;
+-	static KAboutData *fAbout;
+-} ;
+ 
+ extern "C"
+ {
+diff -pruN kpilot/conduits/memofileconduit/setup_base.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/memofileconduit/setup_base.ui
+--- kpilot/conduits/memofileconduit/setup_base.ui	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/memofileconduit/setup_base.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -135,9 +135,9 @@ the Memofile-conduit settings.</comment>
+     <tabstop>tabWidget</tabstop>
+ </tabstops>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/notepadconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/notepadconduit/CMakeLists.txt
+--- kpilot/conduits/notepadconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/notepadconduit/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,38 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_notepad_SRCS
++	notepad-factory.cc
++	notepad-conduit.cc
++)
++
++set(conduit_notepad_UIS
++	notepad-setup.ui
++)
++
++set(conduit_notepad_KCFGS
++	notepadconduit.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_notepad_SRCS ${conduit_notepad_KCFGS})
++kde3_add_ui_files(conduit_notepad_SRCS ${conduit_notepad_UIS})
++kde3_automoc(${conduit_notepad_SRCS})
++add_library(conduit_notepad SHARED ${conduit_notepad_SRCS})
++
++set_target_properties(
++	conduit_notepad PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_notepad)
++
++install(
++	TARGETS conduit_notepad
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES notepad-conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
+diff -pruN kpilot/conduits/notepadconduit/notepad-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-conduit.cc
+--- kpilot/conduits/notepadconduit/notepad-conduit.cc	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -2,7 +2,7 @@
+ **
+ ** Copyright (C) 2004 by Adriaan de Groot, Joern Ahrens
+ **
+-** The code for NotepadActionThread::unpackNotePad was taken from 
++** The code for NotepadActionThread::unpackNotePad was taken from
+ ** Angus Ainslies read-notepad.c, which is part of pilot-link.
+ ** NotepadActionThread::saveImage is also based on read-notepad.c.
+ **
+@@ -49,22 +49,16 @@
+ 
+ extern "C"
+ {
+-long version_conduit_notepad = KPILOT_PLUGIN_API;
+-const char *id_conduit_notepad =
+-	"$Id: notepad-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
++unsigned long version_conduit_notepad = Pilot::PLUGIN_API;
+ }
+ 
+-NotepadConduit::NotepadConduit(KPilotDeviceLink *d,	const char *n,
+-	const QStringList &args) :	ConduitAction(d, n, args)
++NotepadConduit::NotepadConduit(KPilotLink *d, const char *n,
++	const QStringList &args) : ConduitAction(d, n, args)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_conduit_notepad << endl;
+-#endif
+ 	fConduitName=i18n("Notepad");
+ 	thread = 0L;
+ 
+-	(void) id_conduit_notepad;
+ }
+ 
+ NotepadConduit::~NotepadConduit()
+@@ -75,7 +69,7 @@ NotepadConduit::~NotepadConduit()
+ /* virtual */ bool NotepadConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-	
++
+ #ifdef DEBUG
+ 	DEBUGCONDUIT << fname << ": In exec() @" << (unsigned long) this << endl;
+ #endif
+@@ -87,13 +81,13 @@ NotepadConduit::~NotepadConduit()
+ 		return false;
+ 	}
+ 	else {
+-		thread = new NotepadActionThread(this, pilotSocket());
++		thread = new NotepadActionThread(this, deviceLink());
+ 		thread->start();
+ 		// tickle is disabled due to crashs during sync
+ 		// -> PADP TX "unexpected package"
+ //		startTickle();
+ 	}
+-	
++
+ 	return true;
+ }
+ 
+@@ -113,7 +107,7 @@ bool NotepadConduit::event(QEvent *e)
+ 		delete thread;
+ 		return true;
+ 	}
+-	else 
++	else
+ 		return ConduitAction::event(e);
+ }
+ 
+@@ -121,8 +115,8 @@ bool NotepadConduit::event(QEvent *e)
+ // NotepadActionThread
+ //-----------------------------------------------------------------------------
+ 
+-NotepadActionThread::NotepadActionThread(QObject *parent, int pilotSocket) :
+-	fParent(parent), fPilotSocket(pilotSocket), notSaved(0), saved(0)
++NotepadActionThread::NotepadActionThread(QObject *parent, KPilotLink *link) :
++	fParent(parent), fLink(link), notSaved(0), saved(0)
+ {
+ 	FUNCTIONSETUP;
+ }
+@@ -131,7 +125,7 @@ void NotepadActionThread::run()
+ {
+ 	FUNCTIONSETUP;
+ 
+-	PilotSerialDatabase *db = new PilotSerialDatabase(fPilotSocket, "npadDB");
++	PilotDatabase *db = fLink->database( CSL1("npadDB") );
+ 
+ 	int n = db->recordCount();
+ 
+@@ -140,11 +134,14 @@ void NotepadActionThread::run()
+ 		QValueList<recordid_t> vl = db->idList();
+ 		QValueList<recordid_t>::iterator it;
+ 		struct NotePad a;
+-		for ( it = vl.begin(); it != vl.end(); ++it ) {
++		for ( it = vl.begin(); it != vl.end(); ++it )
++		{
+ 			PilotRecord *pr = db->readRecordById(*it);
+-			if(pr) {
+-				unpack_NotePad(&a, (unsigned char*)pr->getData(), pr->size());
++			if(pr)
++			{
++				unpack_NotePad(&a, (unsigned char*)pr->data(), pr->size());
+ 				saveImage(&a);
++				free_NotePad(&a);
+ 			}
+ 		}
+ 	}
+@@ -152,69 +149,112 @@ void NotepadActionThread::run()
+ 	QApplication::postEvent(fParent, new QEvent(QEvent::User));
+ }
+ 
++static void saveImageFromBITS(QImage &image, struct NotePad *n, unsigned int width)
++{
++	FUNCTIONSETUP;
++	image.setColor(0, qRgb(0xaa, 0xc1 ,0x91));
++	image.setColor(1, qRgb(0x30, 0x36, 0x29));
++
++	int x = 0;
++	int y = 0;
++	int pos = 0;
++	for(unsigned int i=0; i<n->body.dataLen/2; ++i)
++	{
++		for(int j=0; j<n->data[i].repeat; ++j)
++		{
++			for(int k=0; k<8; ++k)
++			{
++				y = pos / width;
++				x = pos % width ;
++
++				image.setPixel( x, y,
++					(n->data[i].data & 1<<(7-k)) ? 1 : 0 );
++				++pos;
++			}
++		}
++	}
++}
++
++static void saveImageFromUNCOMPRESSED(QImage &image, struct NotePad *n, unsigned int width)
++{
++	FUNCTIONSETUP;
++
++	image.setColor(0, qRgb(0xaa, 0xc1 ,0x91));
++	image.setColor(1, qRgb(0x30, 0x36, 0x29));
++
++	unsigned int pos = 0;
++	unsigned int x,y;
++
++	for (unsigned int i=0; i<n->body.dataLen / 2; ++i)
++	{
++		for (unsigned int k=0; k<8; ++k)
++		{
++			y = pos / width;
++			x = pos % width ;
++
++			image.setPixel( x, y,
++				(n->data[i].repeat & 1<<(7-k)) ? 1 : 0 );
++			++pos;
++		}
++
++		for (unsigned int k=0; k<8; ++k)
++		{
++			y = pos / width;
++			x = pos % width ;
++
++			image.setPixel( x, y,
++				(n->data[i].data & 1<<(7-k)) ? 1 : 0 );
++			++pos;
++		}
++	}
++}
++
+ void NotepadActionThread::saveImage(struct NotePad *n)
+ {
+ 	FUNCTIONSETUP;
+-	
+-    int width = n->body.width + 8;    
+-    int height = n->body.height;
+-	
+-    QImage image(width, height, 8, 2);
+-    
+-    if(n->body.dataType == NOTEPAD_DATA_BITS)
+-    {
+-        image.setColor(0, qRgb(0xaa, 0xc1 ,0x91));
+-        image.setColor(1, qRgb(0x30, 0x36, 0x29));
+-
+-        int x = 0;  
+-        int y = 0;
+-        int pos = 0;
+-        for(int i=0; i<n->body.dataLen/2; ++i)
+-        {
+-            for(int j=0; j<n->data[i].repeat; ++j)
+-            {
+-                for(int k=0; k<8; ++k)
+-                {
+-				    y = pos / width;
+-				    x = pos % width ;
+-        
+-				    if(n->data[i].data & 1<<(7-k))
+-				        image.setPixel(x,y,1);
+-				    else
+-                        image.setPixel(x,y,0);
+-                    ++pos;
+-                }
+-	       }
+-        }      
+-    }
+-    else if(n->body.dataType == NOTEPAD_DATA_PNG)
+-    {
+-        image.loadFromData((uchar*)(n->data), n->body.dataLen);
+-    }
+-    else
+-    {
+-        // Unknown data type
+-#ifdef DEBUG
+-    DEBUGCONDUIT << fname << ": Unknown data type: " << n->body.dataType << endl;
+-#endif        
+-        return;
+-    }
+-	
+-    QString filename(n->name);
+-    if(filename.isEmpty())
+-    {
+-        filename.sprintf("%4d-%02d-%02d_%02d-%02d-%02d",
+-                        n->changeDate.year,
+-                        n->changeDate.month,
+-                        n->changeDate.day,
+-                        n->changeDate.hour,
+-                        n->changeDate.min,
+-                        n->changeDate.sec);
+-                
+-    }
+-    QString imgname = QString("%1/%2.png").arg(NotepadConduitSettings::outputDirectory()).arg(filename);
+-    
+-    
++
++	// Width needs adjusting, based on whether it's low res (+8)
++	// or a hi-res notepad image.
++	int width = n->body.width + ( n->body.width > 160 ? 16 : 8 );
++	int height = n->body.height;
++
++
++	QImage image(width, height, 8, 2);
++
++	switch (n->body.dataType)
++	{
++	case NOTEPAD_DATA_BITS :
++		saveImageFromBITS( image,n,width );
++		break;
++	case NOTEPAD_DATA_UNCOMPRESSED :
++		saveImageFromUNCOMPRESSED( image,n,width );
++		break;
++	case NOTEPAD_DATA_PNG :
++		image.loadFromData((uchar*)(n->data), n->body.dataLen);
++		break;
++	default :
++		// Unknown data type
++		kdWarning() << k_funcinfo << ": Unknown data type: "
++			<< n->body.dataType << endl;
++		return;
++
++		// TODO: Post a warning to the UI
++	}
++
++	QString filename(n->name);
++	if(filename.isEmpty())
++	{
++		filename.sprintf("%4d-%02d-%02d_%02d-%02d-%02d",
++			n->changeDate.year,
++			n->changeDate.month,
++			n->changeDate.day,
++			n->changeDate.hour,
++			n->changeDate.min,
++			n->changeDate.sec);
++	}
++	QString imgname = QString("%1/%2.png").arg(NotepadConduitSettings::outputDirectory()).arg(filename);
++
++
+ #ifdef DEBUG
+ 	DEBUGCONDUIT << fname << ": Notepad " << imgname << endl;
+ #endif
+diff -pruN kpilot/conduits/notepadconduit/notepad-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-conduit.h
+--- kpilot/conduits/notepadconduit/notepad-conduit.h	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-conduit.h	2006-11-26 23:53:25.000000000 +0100
+@@ -4,7 +4,7 @@
+ **
+ ** Copyright (C) 2004 by Adriaan de Groot, Joern Ahrens, Angus Ainslie
+ **
+-** The code for NotepadActionThread::unpackNotePad was taken from 
++** The code for NotepadActionThread::unpackNotePad was taken from
+ ** Angus Ainslies read-notepad.c, which is part of pilot-link.
+ ** NotepadActionThread::saveImage is also based on read-notepad.c.
+ **
+@@ -42,15 +42,15 @@ class NotepadActionThread;
+ class NotepadConduit : public ConduitAction
+ {
+ public:
+-	NotepadConduit(KPilotDeviceLink *,
++	NotepadConduit(KPilotLink *,
+ 		const char *name=0L,
+ 		const QStringList &args = QStringList());
+ 	virtual ~NotepadConduit();
+ 	virtual bool event(QEvent *e);
+-	
++
+ protected:
+ 	virtual bool exec();           // From ConduitAction
+-	
++
+ private:
+ 	NotepadActionThread *thread;
+ };
+@@ -62,15 +62,16 @@ private:
+ class NotepadActionThread : public QThread
+ {
+ public:
+-	NotepadActionThread(QObject *parent, int pilotSocket);
++	NotepadActionThread(QObject *parent, KPilotLink *link);
+ 
+ 	virtual void run();
+ 	int	getFailed() { return notSaved; }
+ 	int getSaved() { return saved; }
+-		
++
+ private:
+ 	QObject *fParent;
+-	int fPilotSocket;
++	KPilotLink *fLink;
++
+ 	/**
+ 	 * counts how many notepads couldn't be saved during the sync
+ 	 */
+@@ -79,8 +80,14 @@ private:
+ 	 * counts how many files a saved during the sync
+ 	 */
+ 	int saved;
+-	
++
+ 	int unpackNotePad(struct NotePad *a, unsigned char *buffer, int len);
++
++	/**
++	* Saves a single NotePad structure to disk, using the name in
++	* the Note @p n, or if no name is specified, using the
++	* timestamp in the note.
++	*/
+ 	void saveImage(struct NotePad *n);
+ };
+ 
+diff -pruN kpilot/conduits/notepadconduit/notepad-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-factory.cc
+--- kpilot/conduits/notepadconduit/notepad-factory.cc	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-factory.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -36,24 +36,14 @@
+ #include <qlineedit.h>
+ 
+ #include "uiDialog.h"
++#include "pluginfactory.h"
+ 
+ #include "notepad-conduit.h"     // Conduit action
+ #include "notepad-setup.h"
+-#include "notepad-factory.moc"
+ #include "notepadconduit.h"     // Settings class
+ 
+-extern "C"
+-{
+-
+-void *init_conduit_notepad()
+-{
+-	return new NotepadConduitFactory;
+-}
+-
+-}
+-
+ //----------------------------------------------------------------------------
+-// Conduit Confuguration
++// Conduit Configuration
+ //----------------------------------------------------------------------------
+ class NotepadConduitConfig : public ConduitConfigBase
+ {
+@@ -62,26 +52,47 @@ public:
+ 	virtual void commit();
+ 	virtual void load();
+ 	static ConduitConfigBase *create(QWidget *p, const char *n)
+-	{ 
+-		return new NotepadConduitConfig(p, n); 
++	{
++		return new NotepadConduitConfig(p, n);
+ 	};
+-	
++
+ protected:
+ 	NotepadWidget *fConfigWidget;
+ } ;
+ 
++static KAboutData *createAbout()
++{
++	FUNCTIONSETUP;
++
++	KAboutData *fAbout = new KAboutData("NotepadConduit",
++		I18N_NOOP("Saves notepads to png files"),
++		KPILOT_VERSION,
++		I18N_NOOP("Configures the Notepad Conduit for KPilot"),
++		KAboutData::License_LGPL,
++		"(C) 2004, Joern Ahrens");
++	fAbout->addAuthor("Joern Ahrens",
++		I18N_NOOP("Primary Author"),
++		"kde at jokele.de",
++		"http://www.jokele.de/");
++	fAbout->addCredit("Adriaan de Groot");
++	fAbout->addCredit("Angus Ainslies",
++		I18N_NOOP("Notepad conduit is based on Angus' read-notepad, part of pilot-link" ));
++	return fAbout;
++}
++
++
+ NotepadConduitConfig::NotepadConduitConfig(QWidget *p, const char *n) :
+ 	ConduitConfigBase(p, n),
+ 	fConfigWidget(new NotepadWidget(p))
+ {
+ 	FUNCTIONSETUP;
+-	
++
+ 	fConduitName = i18n("Notepad");
+-	UIDialog::addAboutPage(fConfigWidget->tabWidget, NotepadConduitFactory::about());
++	UIDialog::addAboutPage(fConfigWidget->tabWidget, createAbout());
+ 	fWidget=fConfigWidget;
+ 	QObject::connect(fConfigWidget->fOutputDirectory, SIGNAL(textChanged(const QString&)),
+ 		this, SLOT(modified()));
+-	fConfigWidget->fOutputDirectory->setMode(KFile::Directory | 
++	fConfigWidget->fOutputDirectory->setMode(KFile::Directory |
+ 											KFile::LocalOnly);
+ }
+ 
+@@ -96,85 +107,19 @@ NotepadConduitConfig::NotepadConduitConf
+ /* virtual */ void NotepadConduitConfig::load()
+ {
+ 	FUNCTIONSETUP;
+-	
++
+ 	NotepadConduitSettings::self()->readConfig();
+ 	fConfigWidget->fOutputDirectory->setURL(NotepadConduitSettings::outputDirectory());
+ 	fModified=false;
+ }
+ 
+-//----------------------------------------------------------------------------
+-// Conduit Factory
+-//----------------------------------------------------------------------------
+-KAboutData *NotepadConduitFactory::fAbout = 0L;
+-
+-NotepadConduitFactory::NotepadConduitFactory(QObject *p, const char *n) :
+-	KLibFactory(p,n)
++extern "C"
+ {
+-	FUNCTIONSETUP;
+-
+-	fInstance = new KInstance("notepadconduit");
+-	fAbout = new KAboutData("NotepadConduit",
+-		I18N_NOOP("Saves notepads to png files"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Configures the Notepad Conduit for KPilot"),
+-		KAboutData::License_LGPL,
+-		"(C) 2004, Joern Ahrens");
+-	fAbout->addAuthor("Joern Ahrens",
+-		I18N_NOOP("Primary Author"),
+-		"kde at jokele.de",
+-		"http://www.jokele.de/");
+-	fAbout->addCredit("Adriaan de Groot");
+-	fAbout->addCredit("Angus Ainslies", 
+-		I18N_NOOP("Notepad conduit is based on Angus' read-notepad, part of pilot-link" ));
+-}
+ 
+-NotepadConduitFactory::~NotepadConduitFactory()
++void *init_conduit_notepad()
+ {
+-	FUNCTIONSETUP;
+-
+-	KPILOT_DELETE(fInstance);
+-	KPILOT_DELETE(fAbout);
++	return new ConduitFactory<NotepadConduitConfig,NotepadConduit>(0,"abbrowserconduit");
+ }
+ 
+-/* virtual */ QObject *NotepadConduitFactory::createObject( QObject *parent,
+-	const char *name, const char *className, const QStringList &args)
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< className
+-		<< endl;
+-#endif
+-
+-	if(qstrcmp(className, "ConduitConfigBase") == 0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(parent);
+-		if (w) {
+-			return new NotepadConduitConfig(w);
+-		}
+-		else {
+-			return 0L;
+-		}
+-	}
+-
+-	if(qstrcmp(className, "SyncAction") == 0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(parent);
+-
+-		if (d) {
+-			return new NotepadConduit(d, name, args);
+-		}
+-		else {
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast to KPilotDeviceLink"
+-				<< endl;
+-			return 0L;
+-		}
+-	}
+-
+-	return 0L;
+ }
+ 
+-
+diff -pruN kpilot/conduits/notepadconduit/notepad-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-factory.h
+--- kpilot/conduits/notepadconduit/notepad-factory.h	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-factory.h	2006-11-26 23:53:25.000000000 +0100
+@@ -28,31 +28,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include <klibloader.h>
+-
+-class KInstance;
+-class KAboutData;
+-
+-class NotepadConduitFactory : public KLibFactory
+-{
+-Q_OBJECT
+-
+-public:
+-	NotepadConduitFactory(QObject * = 0L, const char * = 0L);
+-	virtual ~NotepadConduitFactory();
+-
+-	static KAboutData *about() { return fAbout; } ;
+-
+-protected:
+-	virtual QObject* createObject(QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList());
+-private:
+-	KInstance *fInstance;
+-	static KAboutData *fAbout;
+-} ;
+-
+ extern "C"
+ {
+ 
+diff -pruN kpilot/conduits/notepadconduit/notepad-setup.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-setup.ui
+--- kpilot/conduits/notepadconduit/notepad-setup.ui	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/notepadconduit/notepad-setup.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -71,9 +71,9 @@
+     </grid>
+ </widget>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/null/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/null/CMakeLists.txt
+--- kpilot/conduits/null/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/null/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,38 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_null_SRCS
++	null-conduit.cc
++	null-factory.cc
++)
++
++set(conduit_null_UIS
++	setup_base.ui
++)
++
++set(conduit_null_KCFGS
++	nullSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_null_SRCS ${conduit_null_KCFGS})
++kde3_add_ui_files(conduit_null_SRCS ${conduit_null_UIS})
++kde3_automoc(${conduit_null_SRCS})
++add_library(conduit_null SHARED ${conduit_null_SRCS})
++
++set_target_properties(
++	conduit_null PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_null)
++
++install(
++	TARGETS conduit_null
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES null-conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
+diff -pruN kpilot/conduits/null/null-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/null/null-conduit.cc
+--- kpilot/conduits/null/null-conduit.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/null/null-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -33,13 +33,6 @@
+ 
+ #include "options.h"
+ 
+-// Something to allow us to check what revision
+-// the modules are that make up a binary distribution.
+-//
+-//
+-static const char *null_conduit_id=
+-	"$Id: null-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ // Only include what we really need:
+ // First UNIX system stuff, then std C++,
+ // then Qt, then KDE, then local includes.
+@@ -59,16 +52,14 @@ static const char *null_conduit_id=
+ // simple constructor and destructor.
+ //
+ //
+-NullConduit::NullConduit(KPilotDeviceLink *d,
++NullConduit::NullConduit(KPilotLink *d,
+ 	const char *n,
+ 	const QStringList &l) :
+ 	ConduitAction(d,n,l),
+-	fDatabase(0L)
++	fDatabase(0L),
++	fFailImmediately( l.contains( CSL1("--fail") ))
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<null_conduit_id<<endl;
+-#endif
+ 	fConduitName=i18n("Null");
+ }
+ 
+@@ -81,13 +72,12 @@ NullConduit::~NullConduit()
+ /* virtual */ bool NullConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-	DEBUGCONDUIT<<null_conduit_id<<endl;
+ 
+-	if ( NullConduitSettings::failImmediately() )
++	DEBUGCONDUIT << fname << ": Mode " << syncMode().name() << endl;
++
++	if ( fFailImmediately )
+ 	{
+-#ifdef DEBUG
+ 		DEBUGCONDUIT << fname << ": Config says to fail now." << endl;
+-#endif
+ 		emit logError(i18n("NULL conduit is programmed to fail."));
+ 		return false;
+ 	}
+@@ -98,12 +88,10 @@ NullConduit::~NullConduit()
+ 		addSyncLogEntry(m);
+ 	}
+ 
+-#ifdef DEBUG
+ 	DEBUGCONDUIT << fname
+ 		<< ": Message from null-conduit: "
+ 		<< m
+ 		<< endl;
+-#endif
+ 
+ 	emit syncDone(this);
+ 	return true;
+diff -pruN kpilot/conduits/null/null-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/null/null-conduit.h
+--- kpilot/conduits/null/null-conduit.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/null/null-conduit.h	2006-11-19 22:21:12.000000000 +0100
+@@ -35,10 +35,21 @@
+ class PilotRecord;
+ class PilotDatabase;
+ 
++/**
++ * The conduit Null does nothing. Almost nothing, anyway.
++ * It writes a single log message to the sync log and then
++ * completes successfully. For debugging purposes it can
++ * also simulate failure, but that is a very specialized
++ * case available only programmatically.
++ */
+ class NullConduit : public ConduitAction
+ {
+ public:
+-	NullConduit(KPilotDeviceLink *,
++	/** Constructor. Special case is if @p contains
++	 *  @c --fail as an argument to the conduit, then
++	 *  the conduit will fail instead of trivially succeeding.
++	 */
++	NullConduit(KPilotLink *,
+ 		const char *name=0L,
+ 		const QStringList &args = QStringList());
+ 	virtual ~NullConduit();
+@@ -48,6 +59,7 @@ protected:
+ 
+ protected:
+ 	PilotDatabase *fDatabase;
++	bool fFailImmediately;
+ };
+ 
+ #endif
+diff -pruN kpilot/conduits/null/nullconduit.kcfg /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/null/nullconduit.kcfg
+--- kpilot/conduits/null/nullconduit.kcfg	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/null/nullconduit.kcfg	2006-11-19 22:21:12.000000000 +0100
+@@ -5,18 +5,9 @@
+       http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+   <kcfgfile name="kpilotrc"/> 
+   <group name="Null-conduit">
+-		<entry name="FailImmediately" key="FailNow" type="Bool">
+-        <label>Whether the conduit should immediately bail out with an error</label>
+-        <default>false</default>
+-    </entry>
+     <entry name="LogMessage" type="String">
+-        <label>The error message if the null conduit is supposed to fail</label>
+-        <default>KPilot was here.</default>
++      <label>The error message if the null conduit is supposed to fail</label>
++      <default>KPilot was here.</default>
+     </entry>
+-		<entry name="Databases" type="StringList">
+-				<label>Databases that are skipped on sync</label>
+-				<default></default>
+-		</entry>
+   </group>
+-	
+ </kcfg>
+diff -pruN kpilot/conduits/null/null-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/null/null-factory.cc
+--- kpilot/conduits/null/null-factory.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/null/null-factory.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -62,7 +62,7 @@ NullConduitConfig::NullConduitConfig(QWi
+ {
+ 	FUNCTIONSETUP;
+ 	fConduitName = i18n("Null");
+-		fAbout = new KAboutData("nullConduit",
++	fAbout = new KAboutData("nullConduit",
+ 		I18N_NOOP("Null Conduit for KPilot"),
+ 		KPILOT_VERSION,
+ 		I18N_NOOP("Configures the Null Conduit for KPilot"),
+@@ -77,10 +77,6 @@ NullConduitConfig::NullConduitConfig(QWi
+ 	fWidget=fConfigWidget;
+ 	QObject::connect(fConfigWidget->fLogMessage,SIGNAL(textChanged(const QString&)),
+ 		this,SLOT(modified()));
+-	QObject::connect(fConfigWidget->fDatabases,SIGNAL(textChanged(const QString&)),
+-		this,SLOT(modified()));
+-	QObject::connect(fConfigWidget->fFailImmediately,SIGNAL(toggled(bool)),
+-		this,SLOT(modified()));
+ }
+ 
+ /* virtual */ void NullConduitConfig::commit()
+@@ -92,15 +88,9 @@ NullConduitConfig::NullConduitConfig(QWi
+ 		<< ": Message="
+ 		<< fConfigWidget->fLogMessage->text()
+ 		<< endl;
+-	DEBUGCONDUIT << fname
+-		<< ": Databases="
+-		<< fConfigWidget->fDatabases->text()
+-		<< endl;
+ #endif
+ 
+ 	NullConduitSettings::setLogMessage( fConfigWidget->fLogMessage->text() );
+-	NullConduitSettings::setDatabases( fConfigWidget->fDatabases->text() );
+-	NullConduitSettings::setFailImmediately( fConfigWidget->fFailImmediately->isChecked());
+ 	NullConduitSettings::self()->writeConfig();
+ 	unmodified();
+ }
+@@ -111,18 +101,11 @@ NullConduitConfig::NullConduitConfig(QWi
+ 	NullConduitSettings::self()->readConfig();
+ 
+ 	fConfigWidget->fLogMessage->setText( NullConduitSettings::logMessage() );
+-	fConfigWidget->fDatabases->setText( NullConduitSettings::databases().join(",") );
+-	fConfigWidget->fFailImmediately->setChecked( NullConduitSettings::failImmediately() );
+-
+ #ifdef DEBUG
+ 	DEBUGCONDUIT << fname
+ 		<< ": Read Message="
+ 		<< fConfigWidget->fLogMessage->text()
+ 		<< endl;
+-	DEBUGCONDUIT << fname
+-		<< ": Read Database="
+-		<< fConfigWidget->fDatabases->text()
+-		<< endl;
+ #endif
+ 
+ 	unmodified();
+@@ -133,6 +116,7 @@ NullConduitConfig::NullConduitConfig(QWi
+ extern "C"
+ {
+ 
++unsigned long version_conduit_null = Pilot::PLUGIN_API;
+ void *init_conduit_null()
+ {
+ 	return new ConduitFactory<NullConduitConfig,NullConduit>(0,"nullconduit");
+diff -pruN kpilot/conduits/null/setup_base.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/null/setup_base.ui
+--- kpilot/conduits/null/setup_base.ui	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/null/setup_base.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -1,4 +1,4 @@
+-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
++<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+ <class>NullWidget</class>
+ <comment>A tabWidget for configuring
+ the Null-conduit settings.</comment>
+@@ -99,25 +99,6 @@ the Null-conduit settings.</comment>
+                             <cstring>fLogMessage</cstring>
+                         </property>
+                     </widget>
+-                    <widget class="QLabel" row="1" column="0">
+-                        <property name="name">
+-                            <cstring>TextLabel2_2</cstring>
+-                        </property>
+-                        <property name="text">
+-                            <string>&amp;Databases:</string>
+-                        </property>
+-                        <property name="buddy" stdset="0">
+-                            <cstring>fDatabases</cstring>
+-                        </property>
+-                    </widget>
+-                    <widget class="QLineEdit" row="1" column="1">
+-                        <property name="name">
+-                            <cstring>fDatabases</cstring>
+-                        </property>
+-                        <property name="whatsThis" stdset="0">
+-                            <string>&lt;qt&gt;The Null-conduit can be attached to several databases, effectively preventing them from Syncing. Enter the database names here.&lt;/qt&gt;</string>
+-                        </property>
+-                    </widget>
+                     <spacer row="3" column="1">
+                         <property name="name">
+                             <cstring>Spacer4</cstring>
+@@ -135,17 +116,6 @@ the Null-conduit settings.</comment>
+                             </size>
+                         </property>
+                     </spacer>
+-                    <widget class="QCheckBox" row="2" column="1">
+-                        <property name="name">
+-                            <cstring>fFailImmediately</cstring>
+-                        </property>
+-                        <property name="text">
+-                            <string>Simulate failure</string>
+-                        </property>
+-                        <property name="whatsThis" stdset="0">
+-                            <string>Force the conduit to simulate a failure to perform the HotSync.</string>
+-                        </property>
+-                    </widget>
+                 </grid>
+             </widget>
+         </widget>
+diff -pruN kpilot/conduits/perlconduit/Makefile.am /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/Makefile.am
+--- kpilot/conduits/perlconduit/Makefile.am	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/Makefile.am	1970-01-01 01:00:00.000000000 +0100
+@@ -1,15 +0,0 @@
+-INCLUDES= $(PISOCK_INCLUDE) $(PERL_CFLAGS) -I$(top_srcdir)/kpilot/lib $(all_includes)
+-
+-METASOURCES = AUTO
+-
+-servicedir = $(kde_servicesdir)
+-service_DATA = perl-conduit.desktop
+-
+-kde_module_LTLIBRARIES = conduit_perl.la
+-
+-
+-conduit_perl_la_SOURCES = perlconduit.kcfgc perl-setup.ui \
+-	perl-conduit.cc perl-factory.cc
+-conduit_perl_la_LDFLAGS = -module $(KDE_PLUGIN) $(PERL_LDFLAGS) $(all_libraries)
+-conduit_perl_la_LIBADD = ../../lib/libkpilot.la $(LIB_KDEUI)
+-
+diff -pruN kpilot/conduits/perlconduit/perl-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-conduit.cc
+--- kpilot/conduits/perlconduit/perl-conduit.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-conduit.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,188 +0,0 @@
+-/* KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file is part of the Perl conduit, a conduit for KPilot that
+-** is intended to showcase how to use perl code inside a conduit.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-/*
+-** This file is based on the perlembed examples, from
+-** http://search.cpan.org/dist/perl/pod/perlembed.pod
+-*/
+-
+-#ifdef DEBUG
+-#undef DEBUG
+-#define DEBUG (1)
+-#else
+-#define DEBUG (1)
+-#endif
+-
+-#include "options.h"
+-
+-
+-#include "perl-conduit.h"  // The Conduit action
+-#include "perlconduit.h"   // The settings class
+-
+-#include <qthread.h>
+-#include <qapplication.h>
+-
+-#include <EXTERN.h>
+-#include <perl.h>
+-
+-extern "C"
+-{
+-long version_conduit_perl = KPILOT_PLUGIN_API;
+-const char *id_conduit_perl =
+-	"$Id: perl-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-}
+-
+-/* From the cvs log mailing list:
+-Am Dienstag, 13. April 2004 22:26 schrieb Adriaan de Groot:
+-> On Tuesday 13 April 2004 20:53, Reinhold Kainhofer wrote:
+-> > rename fPerl to my_perl to make it compile again...
+->
+-> Note that the renaming is needed because perl 5.8 is a brain-dead abortion,
+-> and the code works fine with perl 5.6.
+-*/
+-class PerlThread : public QThread
+-{
+-public:
+-	PerlThread(QObject *parent,
+-		const QString &pilotPath,
+-		int fd) : fParent(parent),
+-		fPath(pilotPath),fSocket(fd) { } ;
+-	virtual void run();
+-
+-	QString result() const { return fResult; } ;
+-
+-protected:
+-	QObject *fParent;
+-	PerlInterpreter *my_perl;
+-	QString fPath;
+-	int fSocket;
+-
+-	QString fResult;
+-} ;
+-
+-
+-PerlConduit::PerlConduit(KPilotDeviceLink *d,
+-	const char *n,
+-	const QStringList &l) :
+-	ConduitAction(d,n,l)
+-{
+-	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_conduit_perl << endl;
+-#endif
+-	fConduitName=i18n("Perl");
+-
+-	(void) id_conduit_perl;
+-}
+-
+-PerlConduit::~PerlConduit()
+-{
+-	FUNCTIONSETUP;
+-}
+-
+-/* virtual */ bool PerlConduit::exec()
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": In exec() @" << (unsigned long) this << endl;
+-#endif
+-
+-	fThread = new PerlThread(this,
+-		fHandle->pilotPath(),
+-		/* fHandle-> */pilotSocket()) ;
+-	fThread->start();
+-	startTickle();
+-	return true;
+-}
+-
+-/* virtual */ bool PerlConduit::event(QEvent *e)
+-{
+-	FUNCTIONSETUP;
+-
+-	if (e->type() == QEvent::User)
+-	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Perl thread done." << endl;
+-#endif
+-		QString r;
+-		addSyncLogEntry(i18n("Perl returned %1.").arg(fThread->result()));
+-		stopTickle();
+-		delayDone();
+-		return true;
+-	}
+-	else return ConduitAction::event(e);
+-}
+-
+-static const char *perl_args[] = { "", "-e", "0" } ;
+-
+-void PerlThread::run()
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Thread starting." << endl;
+-#endif
+-
+-	my_perl = perl_alloc();
+-	perl_construct(my_perl);
+-	perl_parse(my_perl, NULL, 3, const_cast<char **>(perl_args), NULL);
+-	perl_run(my_perl);
+-
+-	eval_pv( (CSL1("%kpilot=(") +
+-		CSL1("device=>\"%1\",").arg(fPath) +
+-		CSL1("socket=%1,").arg(fSocket) +
+-		// Add more data here in same style, don't forget " and ,
+-		CSL1("version=%1);").arg(KPILOT_PLUGIN_API)).latin1(),
+-		TRUE);
+-
+-	eval_pv(PerlConduitSettings::expression().latin1(),TRUE);
+-
+-	SV *retval = get_sv("a",FALSE);
+-	if (retval)
+-	{
+-		fResult.setNum(SvIV(retval));
+-	}
+-	else
+-	{
+-		fResult = i18n("No value");
+-	}
+-
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Thread woken with " << fResult << endl;
+-#endif
+-
+-
+-	perl_destruct(my_perl);
+-	perl_free(my_perl);
+-
+-	QApplication::postEvent(fParent,new QEvent(QEvent::User));
+-}
+-
+diff -pruN kpilot/conduits/perlconduit/perl-conduit.desktop /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-conduit.desktop
+--- kpilot/conduits/perlconduit/perl-conduit.desktop	2006-10-01 19:30:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-conduit.desktop	1970-01-01 01:00:00.000000000 +0100
+@@ -1,92 +0,0 @@
+-[Desktop Entry]
+-Encoding=UTF-8
+-Type=Service
+-Name=Perl (Sample)
+-Name[be]=Perl (прыклад)
+-Name[br]=Perl (Skouer)
+-Name[bs]=Perl (primjer)
+-Name[ca]=Perl (Mostra)
+-Name[cs]=Perl (příklad)
+-Name[da]=Perl (eksempel)
+-Name[de]=Perl (Beispiel)
+-Name[el]=Perl (Παράδειγμα)
+-Name[es]=Perl (Ejemplo)
+-Name[et]=Perl (näidis)
+-Name[eu]=Perl (adibidea)
+-Name[fa]=Perl (نمونه)
+-Name[fi]=Perl (esimerkki)
+-Name[fr]=Perl (exemple)
+-Name[ga]=Perl (Sampla)
+-Name[gl]=Perl (Mostra)
+-Name[he]=Perl (דוגמה)
+-Name[hu]=Perl (példa)
+-Name[is]=Perl (Dæmi)
+-Name[it]=Perl (esempio)
+-Name[ja]=Perl (サンプル)
+-Name[km]=Perl (សាមញ្ញ)
+-Name[lt]=Perl (pavyzdys)
+-Name[ms]=Perl (Sampel)
+-Name[nb]=Perl (prøve)
+-Name[nds]=Perl (Bispeel)
+-Name[nl]=Perl (voorbeeld)
+-Name[nn]=Perl (prøve)
+-Name[pl]=Perl (Przykład)
+-Name[pt]=Perl (Exemplo)
+-Name[pt_BR]=Perl (exemplo)
+-Name[ru]=Perl (пример)
+-Name[se]=Perl (geahččaleapmi)
+-Name[sk]=Perl (Ukážka)
+-Name[sl]=Perl (primer)
+-Name[sr]=Perl (пример)
+-Name[sr at Latn]=Perl (primer)
+-Name[sv]=Perl (exempel)
+-Name[ta]=பர்ல்(மாதிரி)
+-Name[tg]=Perl (намуна)
+-Name[tr]=Perl (Örnek)
+-Name[uk]=Perl (зразок)
+-Name[zh_CN]=Perl (例子)
+-Name[zh_TW]=Perl (範例)
+-Comment=This sample conduit runs a Perl interpreter.
+-Comment[bg]=Пример за изпълнение на интерпретатора на Perl
+-Comment[bs]=Ovaj conduit poziva Perl interpreter.
+-Comment[ca]=Aquest conducte de mostra executa un intèrpret Perl.
+-Comment[cs]=Toto propojení spustí interpret Perlu.
+-Comment[da]=Denne eksempel-kanal kører en Perl-fortolker.
+-Comment[de]=Diese Erweiterung (Conduit) startet einen Perl Interpreter
+-Comment[el]=Αυτός το παράδειγμα συνδέσμου εκτελεί ένα μεταγλωττιστή της Perl.
+-Comment[es]=Este conducto de ejemplo ejecuta un intérprete de Perl
+-Comment[et]=See näidiskanal käivitab Perli interpretaatori.
+-Comment[eu]=Adibide honek Perl interpretatzaile bat exekutatzen du.
+-Comment[fa]=این لولۀ نمونه، یک مفسر Perlرا اجرا می‌کند.
+-Comment[fi]=Tämä esimerkkiyhdyskäytävä suorittaa Perl-tulkkia.
+-Comment[fr]=Cet exemple de canal lance un interpréteur Perl.
+-Comment[ga]=Ritheann an seoladán samplach seo léirmhínitheoir Perl.
+-Comment[hu]=Ez a mintacsatoló a Perl-értelmezőt futtatja
+-Comment[is]=Þessi sýnishornarás keyrir Perl túlk.
+-Comment[it]=Questo conduit avvia un interprete Perl.
+-Comment[ja]=このサンプルコンジットは Perl インタープリタを実行します。
+-Comment[km]=បំពង់​គំរូ​នេះ​រត់​កម្មវិធី​បកប្រែ Perl ។
+-Comment[lt]=Šis pavyzdinis kanalas vykdo Perl interpretatorių.
+-Comment[ms]=Saluran sampel ini menjalankan pentafsir Perl. 
+-Comment[nb]=Denne kanalen kjører en Perl tolker.
+-Comment[nds]=Disse Bispeelkanaal start en Perl-Interpreter
+-Comment[nl]=Dit voorbeeld-conduit start een Perl-interpreteerder.
+-Comment[nn]=Denne kanalen køyrer ein Perl-tolkar.
+-Comment[pl]=Ten przykładowy łącznik uruchamia interpreter Perla.
+-Comment[pt]=Esta conduta exemplo corre um interpretador de Perl.
+-Comment[pt_BR]=Este conduíte de exemplo executa um interpretador Perl.
+-Comment[ru]=Канал запуска скриптов Perl.
+-Comment[sk]=Táto ukážková spojka spúšťa interpreter Perl.
+-Comment[sl]=Ta preprost veznik poganja tolmač za Perl.
+-Comment[sr]=Овај пример провода покреће интерпретатор Perl-а.
+-Comment[sr at Latn]=Ovaj primer provoda pokreće interpretator Perl-a.
+-Comment[sv]=Den här exempelkanalen kör en Perl-tolk.
+-Comment[ta]=இந்த மாதிரி காப்புக் குழாய் பர்ல் மொழிப்பெயர்ப்பில் ஓடுகிறது
+-Comment[tg]=Канали ба кор андозии ҳуруфотҳои Perl.
+-Comment[tr]=Bu bileşen, bir Perl yorumlayıcısını çalıştırır.
+-Comment[uk]=Цей акведук запускає інтерпретатор Perl.
+-Comment[zh_CN]=此示例管道运行 Perl 解释器。
+-Comment[zh_TW]=此範例執行 Perl 直譯器。
+-Implemented=file
+-ServiceTypes=KPilotConduit
+-X-KDE-Library=conduit_perl
+diff -pruN kpilot/conduits/perlconduit/perl-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-conduit.h
+--- kpilot/conduits/perlconduit/perl-conduit.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-conduit.h	1970-01-01 01:00:00.000000000 +0100
+@@ -1,53 +0,0 @@
+-#ifndef _PERL_PERL_CONDUIT_H
+-#define _PERL_PERL_CONDUIT_H
+-/* perl-conduit.h			KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file is part of the Perl conduit, a conduit for KPilot that
+-** runs a Perl interpreter in the context of  HotSync. The Perl
+-** interpreter can do what it likes. It probably use standard
+-** CPAN modules to talk to the Pilot.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "plugin.h"
+-
+-class PerlThread;
+-
+-class PerlConduit : public ConduitAction
+-{
+-public:
+-	PerlConduit(KPilotDeviceLink *,
+-		const char *name=0L,
+-		const QStringList &args = QStringList());
+-	virtual ~PerlConduit();
+-
+-protected:
+-	virtual bool exec();           // From ConduitAction
+-	virtual bool event(QEvent *e); // From QObject
+-
+-	PerlThread *fThread;           // A QThread subclass for the interpreter
+-};
+-
+-#endif
+diff -pruN kpilot/conduits/perlconduit/perlconduit.kcfg /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perlconduit.kcfg
+--- kpilot/conduits/perlconduit/perlconduit.kcfg	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perlconduit.kcfg	1970-01-01 01:00:00.000000000 +0100
+@@ -1,14 +0,0 @@
+-<?xml version="1.0" encoding="UTF-8"?>
+-<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+-      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+-      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+-  <kcfgfile name="kpilotrc"/> 
+-  <group name="Perl-conduit">
+-    <entry name="Expression" type="String">
+-        <label>A Perl expression to evaluate during a HotSync. The value of $a is added to the sync log.</label>
+-        <default>$a=17;</default>
+-    </entry>
+-  </group>
+-	
+-</kcfg>
+diff -pruN kpilot/conduits/perlconduit/perlconduit.kcfgc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perlconduit.kcfgc
+--- kpilot/conduits/perlconduit/perlconduit.kcfgc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perlconduit.kcfgc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,7 +0,0 @@
+-File=perlconduit.kcfg
+-ClassName= PerlConduitSettings
+-Singleton=true
+-ItemAccessors=true
+-Mutators=true
+-GlobalEnums=true
+-SetUserTexts=true
+diff -pruN kpilot/conduits/perlconduit/perl-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-factory.cc
+--- kpilot/conduits/perlconduit/perl-factory.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-factory.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,169 +0,0 @@
+-/* KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file defines the factory for the perl-conduit plugin.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "options.h"
+-
+-#include <kconfig.h>
+-#include <kinstance.h>
+-#include <kaboutdata.h>
+-#include <qtextedit.h>
+-
+-#include "uiDialog.h"
+-
+-#include "perl-conduit.h"     // Conduit action
+-#include "perl-setup.h"
+-#include "perl-factory.moc"
+-#include "perlconduit.h"     // Settings class
+-
+-extern "C"
+-{
+-
+-void *init_conduit_perl()
+-{
+-	return new PerlConduitFactory;
+-}
+-
+-}
+-
+-class PerlConduitConfig : public ConduitConfigBase
+-{
+-public:
+-	PerlConduitConfig(QWidget *parent=0L, const char *n=0L);
+-	virtual void commit();
+-	virtual void load();
+-	static ConduitConfigBase *create(QWidget *p,const char *n)
+-		{ return new PerlConduitConfig(p,n); } ;
+-protected:
+-	PerlWidget *fConfigWidget;
+-} ;
+-
+-PerlConduitConfig::PerlConduitConfig(QWidget *p, const char *n) :
+-	ConduitConfigBase(p,n),
+-	fConfigWidget(new PerlWidget(p))
+-{
+-	FUNCTIONSETUP;
+-	fConduitName = i18n("Perl");
+-	UIDialog::addAboutPage(fConfigWidget->tabWidget,PerlConduitFactory::about());
+-	fWidget=fConfigWidget;
+-	QObject::connect(fConfigWidget->fExpression,SIGNAL(textChanged()),
+-		this,SLOT(modified()));
+-}
+-
+-/* virtual */ void PerlConduitConfig::commit()
+-{
+-	FUNCTIONSETUP;
+-
+-	PerlConduitSettings::setExpression( fConfigWidget->fExpression->text() );
+-	PerlConduitSettings::self()->writeConfig();
+-}
+-
+-/* virtual */ void PerlConduitConfig::load()
+-{
+-	FUNCTIONSETUP;
+-	PerlConduitSettings::self()->readConfig();
+-
+-	fConfigWidget->fExpression->setText( PerlConduitSettings::expression() );
+-
+-	fModified=false;
+-}
+-
+-KAboutData *PerlConduitFactory::fAbout = 0L;
+-PerlConduitFactory::PerlConduitFactory(QObject *p, const char *n) :
+-	KLibFactory(p,n)
+-{
+-	FUNCTIONSETUP;
+-
+-	fInstance = new KInstance("perlconduit");
+-	fAbout = new KAboutData("perlConduit",
+-		I18N_NOOP("Perl Conduit for KPilot"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Configures the Perl Conduit for KPilot"),
+-		KAboutData::License_LGPL,
+-		"(C) 2004, Adriaan de Groot");
+-	fAbout->addAuthor("Adriaan de Groot",
+-		I18N_NOOP("Primary Author"),
+-		"groot at kde.org",
+-		"http://www.cs.kun.nl/~adridg/");
+-}
+-
+-PerlConduitFactory::~PerlConduitFactory()
+-{
+-	FUNCTIONSETUP;
+-
+-	KPILOT_DELETE(fInstance);
+-	KPILOT_DELETE(fAbout);
+-}
+-
+-/* virtual */ QObject *PerlConduitFactory::createObject( QObject *p,
+-	const char *n,
+-	const char *c,
+-	const QStringList &a)
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< c
+-		<< endl;
+-#endif
+-
+-	if (qstrcmp(c,"ConduitConfigBase")==0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(p);
+-		if (w)
+-		{
+-			return new PerlConduitConfig(w);
+-		}
+-		else
+-		{
+-			return 0L;
+-		}
+-	}
+-
+-	if (qstrcmp(c,"SyncAction")==0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
+-
+-		if (d)
+-		{
+-			return new PerlConduit(d,n,a);
+-		}
+-		else
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast to KPilotDeviceLink"
+-				<< endl;
+-			return 0L;
+-		}
+-	}
+-
+-	return 0L;
+-}
+-
+-
+diff -pruN kpilot/conduits/perlconduit/perl-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-factory.h
+--- kpilot/conduits/perlconduit/perl-factory.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-factory.h	1970-01-01 01:00:00.000000000 +0100
+@@ -1,63 +0,0 @@
+-#ifndef _KPILOT_PERL_FACTORY_H
+-#define _KPILOT_PERL_FACTORY_H
+-/* perl-factory.h                       KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file defines the factory for the perl-conduit plugin.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include <klibloader.h>
+-
+-class KInstance;
+-class KAboutData;
+-
+-class PerlConduitFactory : public KLibFactory
+-{
+-Q_OBJECT
+-
+-public:
+-	PerlConduitFactory(QObject * = 0L,const char * = 0L);
+-	virtual ~PerlConduitFactory();
+-
+-	static KAboutData *about() { return fAbout; } ;
+-
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() );
+-private:
+-	KInstance *fInstance;
+-	static KAboutData *fAbout;
+-} ;
+-
+-extern "C"
+-{
+-
+-void *init_conduit_perl();
+-
+-}
+-
+-#endif
+diff -pruN kpilot/conduits/perlconduit/perl-setup.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-setup.ui
+--- kpilot/conduits/perlconduit/perl-setup.ui	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/perlconduit/perl-setup.ui	1970-01-01 01:00:00.000000000 +0100
+@@ -1,95 +0,0 @@
+-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+-<class>PerlWidget</class>
+-<comment>A tabWidget for configuring
+-the Perl-conduit settings.</comment>
+-<author>Adriaan de Groot</author>
+-<widget class="QWidget">
+-    <property name="name">
+-        <cstring>Form1</cstring>
+-    </property>
+-    <property name="geometry">
+-        <rect>
+-            <x>0</x>
+-            <y>0</y>
+-            <width>367</width>
+-            <height>248</height>
+-        </rect>
+-    </property>
+-    <property name="sizePolicy">
+-        <sizepolicy>
+-            <hsizetype>5</hsizetype>
+-            <vsizetype>5</vsizetype>
+-            <horstretch>0</horstretch>
+-            <verstretch>0</verstretch>
+-        </sizepolicy>
+-    </property>
+-    <property name="baseSize">
+-        <size>
+-            <width>570</width>
+-            <height>270</height>
+-        </size>
+-    </property>
+-    <property name="caption">
+-        <string>Perl-Conduit Options</string>
+-    </property>
+-    <property name="layoutMargin" stdset="0">
+-    </property>
+-    <property name="layoutSpacing" stdset="0">
+-    </property>
+-    <grid>
+-        <property name="name">
+-            <cstring>unnamed</cstring>
+-        </property>
+-        <property name="margin">
+-            <number>0</number>
+-        </property>
+-        <property name="spacing">
+-            <number>6</number>
+-        </property>
+-        <widget class="QTabWidget" row="0" column="0">
+-            <property name="name">
+-                <cstring>tabWidget</cstring>
+-            </property>
+-            <widget class="QWidget">
+-                <property name="name">
+-                    <cstring>Widget2</cstring>
+-                </property>
+-                <attribute name="title">
+-                    <string>General</string>
+-                </attribute>
+-                <grid>
+-                    <property name="name">
+-                        <cstring>unnamed</cstring>
+-                    </property>
+-                    <widget class="QTextEdit" row="1" column="0">
+-                        <property name="name">
+-                            <cstring>fExpression</cstring>
+-                        </property>
+-                        <property name="text">
+-                            <string>$a = 17;</string>
+-                        </property>
+-                        <property name="whatsThis" stdset="0">
+-                            <string>&lt;qt&gt;Enter the Perl expression to be evaluated during a HotSync here.&lt;/qt&gt;</string>
+-                        </property>
+-                    </widget>
+-                    <widget class="QLabel" row="0" column="0">
+-                        <property name="name">
+-                            <cstring>TextLabel1_2</cstring>
+-                        </property>
+-                        <property name="text">
+-                            <string>&amp;Perl expression:</string>
+-                        </property>
+-                        <property name="buddy" stdset="0">
+-                            <cstring>fExpression</cstring>
+-                        </property>
+-                    </widget>
+-                </grid>
+-            </widget>
+-        </widget>
+-    </grid>
+-</widget>
+-<tabstops>
+-    <tabstop>tabWidget</tabstop>
+-</tabstops>
+-<layoutdefaults spacing="6" margin="11"/>
+-</UI>
+diff -pruN kpilot/conduits/popmail/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/popmail/CMakeLists.txt
+--- kpilot/conduits/popmail/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/popmail/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,39 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_popmail_SRCS
++	popmail-factory.cc
++	popmail-conduit.cc
++	setupDialog.cc
++)
++
++set(conduit_popmail_UIS
++	setup-dialog.ui
++)
++
++set(conduit_popmail_KCFGS
++	popmailSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_popmail_SRCS ${conduit_popmail_KCFGS})
++kde3_add_ui_files(conduit_popmail_SRCS ${conduit_popmail_UIS})
++kde3_automoc(${conduit_popmail_SRCS})
++add_library(conduit_popmail SHARED ${conduit_popmail_SRCS})
++
++set_target_properties(
++	conduit_popmail PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_popmail)
++
++install(
++	TARGETS conduit_popmail
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES popmail-conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
+diff -pruN kpilot/conduits/popmail/popmail-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/popmail/popmail-conduit.cc
+--- kpilot/conduits/popmail/popmail-conduit.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/popmail/popmail-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -37,9 +37,7 @@
+ extern "C"
+ {
+ 
+-long version_conduit_popmail = KPILOT_PLUGIN_API;
+-const char *id_conduit_popmail =
+-	"$Id: popmail-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
++unsigned long version_conduit_popmail = Pilot::PLUGIN_API;
+ 
+ }
+ 
+@@ -74,36 +72,19 @@ const char *id_conduit_popmail =
+ #include <dcopclient.h>
+ #include <ktempfile.h>
+ 
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ #include "pilotSerialDatabase.h"
+ 
+ #include "popmailSettings.h"
+ #include "setupDialog.h"
+ 
+-#if 0
+-static void reset_Mail(struct Mail *t)
+-{
+-      t->to = 0;
+-      t->from = 0;
+-      t->cc = 0;
+-      t->bcc = 0;
+-      t->subject = 0;
+-      t->replyTo = 0;
+-      t->sentTo = 0;
+-      t->body = 0;
+-      t->dated = 0;
+-}
+-#endif
+ 
+-PopMailConduit::PopMailConduit(KPilotDeviceLink *d,
++PopMailConduit::PopMailConduit(KPilotLink *d,
+ 	const char *n,
+ 	const QStringList &l) :
+ 	ConduitAction(d,n,l)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_conduit_popmail << endl;
+-#endif
+ 	fConduitName=i18n("KMail");
+ }
+ 
+@@ -119,11 +100,9 @@ void PopMailConduit::doSync()
+ 	int sent_count=0;
+ 	int mode=MailConduitSettings::syncOutgoing();
+ 
+-#ifdef DEBUG
+ 	DEBUGCONDUIT << fname
+ 		<< ": Outgoing mail disposition "
+ 		<< mode << endl;
+-#endif
+ 
+ 	if(mode)
+ 	{
+@@ -168,13 +147,11 @@ int PopMailConduit::sendPendingMail(int 
+ 	}
+ 	else
+ 	{
+-#ifdef DEBUG
+ 		DEBUGCONDUIT << fname
+ 			<< ": Sent "
+ 			<< count
+ 			<< " messages"
+ 			<< endl;
+-#endif
+ 	}
+ 
+ 	return count;
+@@ -230,21 +207,17 @@ int PopMailConduit::sendViaKMail()
+ 
+ 	while (PilotRecord *pilotRec = fDatabase->readNextRecInCategory(1))
+ 	{
+-#ifdef DEBUG
+ 		DEBUGCONDUIT << fname
+ 			<< ": Reading "
+ 			<< count + 1
+ 			<< "th message"
+ 			<< endl;
+-#endif
+ 
+ 		if (pilotRec->isDeleted() || pilotRec->isArchived())
+ 		{
+-#ifdef DEBUG
+ 			DEBUGCONDUIT << fname
+ 				<< ": Skipping record."
+ 				<< endl;
+-#endif
+ 			continue;
+ 		}
+ 
+@@ -279,7 +252,7 @@ int PopMailConduit::sendViaKMail()
+ 		}
+ 
+ 		unpack_Mail(&theMail,
+-			(unsigned char*)pilotRec->getData(),
++			(unsigned char*)pilotRec->data(),
+ 			pilotRec->size());
+ 		writeMessageToFile(sendf, theMail);
+ 
+@@ -288,11 +261,11 @@ int PopMailConduit::sendViaKMail()
+ 		QCString returnType;
+ 		QDataStream arg(data,IO_WriteOnly);
+ 
+-		arg << kmailOutboxName << t.name();
++		arg << kmailOutboxName << t.name() << CSL1("N") ;
+ 
+ 		if (!dcopptr->call("kmail",
+ 			"KMailIface",
+-			"dcopAddMessage(QString,QString)",
++			"dcopAddMessage(QString,QString,QString)",
+ 			data,
+ 			returnType,
+ 			returnValue,
+@@ -308,14 +281,12 @@ int PopMailConduit::sendViaKMail()
+ 			continue;
+ 		}
+ 
+-#ifdef DEBUG
+ 		DEBUGCONDUIT << fname
+ 			<< ": DCOP call returned "
+ 			<< returnType
+ 			<< " of "
+ 			<< (const char *)returnValue
+ 			<< endl;
+-#endif
+ 
+ 		// Mark it as filed...
+ 		pilotRec->setCategory(3);
+@@ -328,19 +299,6 @@ int PopMailConduit::sendViaKMail()
+ 		count++;
+ 	}
+ 
+-#if 0
+-	if ((count > 0)  && sendImmediate)
+-	{
+-		QByteArray data;
+-		if (dcopptr->send("kmail","KMailIface","sendQueued",data))
+-		{
+-			kdWarning() << k_funcinfo
+-				<< ": Could not flush queue."
+-				<< endl;
+-		}
+-	}
+-#endif
+-
+ 	return count;
+ }
+ 
+@@ -368,16 +326,12 @@ void PopMailConduit::writeMessageToFile(
+ 	mailPipe << "\r\n";
+ 
+ 
+-#ifdef DEBUG
+ 	DEBUGCONDUIT << fname << ": To: " << theMail.to << endl;
+-#endif
+ 
+ 
+ 	if(theMail.body)
+ 	{
+-#ifdef DEBUG
+ 		DEBUGCONDUIT << fname << ": Sent body." << endl;
+-#endif
+ 		mailPipe << theMail.body << "\r\n";
+ 	}
+ 
+@@ -385,9 +339,7 @@ void PopMailConduit::writeMessageToFile(
+ 	QString signature = MailConduitSettings::signature();
+ 	if(!signature.isEmpty())
+ 	{
+-#ifdef DEBUG
+ 		DEBUGCONDUIT << fname << ": Reading signature" << endl;
+-#endif
+ 
+ 		QFile f(signature);
+ 		if ( f.open(IO_ReadOnly) )
+@@ -403,9 +355,7 @@ void PopMailConduit::writeMessageToFile(
+ 	}
+ 	mailPipe << "\r\n";
+ 
+-#ifdef DEBUG
+ 	DEBUGCONDUIT << fname << ": Done" << endl;
+-#endif
+ }
+ 
+ 
+@@ -415,19 +365,15 @@ void PopMailConduit::writeMessageToFile(
+ 
+ 	QString outbox = getKMailOutbox();
+ 
+-#ifdef DEBUG
+ 	DEBUGCONDUIT << fname
+ 		<< ": KMail's outbox is "
+ 		<< outbox
+ 		<< endl;
+-#endif
+ }
+ 
+ /* virtual */ bool PopMailConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-	DEBUGCONDUIT << id_conduit_popmail << endl;
+-
+ 
+ 	if (syncMode().isTest())
+ 	{
+@@ -439,10 +385,9 @@ void PopMailConduit::writeMessageToFile(
+ 	}
+ 	else
+ 	{
+-		fDatabase=new PilotSerialDatabase(pilotSocket(),
+-			CSL1("MailDB"));
++		fDatabase = deviceLink()->database( CSL1("MailDB") );
+ 
+-		if (!fDatabase || !fDatabase->isDBOpen())
++		if (!fDatabase || !fDatabase->isOpen())
+ 		{
+ 			emit logError(i18n("Unable to open mail database on handheld"));
+ 			KPILOT_DELETE(fDatabase);
+diff -pruN kpilot/conduits/popmail/popmail-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/popmail/popmail-conduit.h
+--- kpilot/conduits/popmail/popmail-conduit.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/popmail/popmail-conduit.h	2006-11-19 22:21:12.000000000 +0100
+@@ -44,7 +44,7 @@ class PilotDatabase;
+ class PopMailConduit : public ConduitAction
+ {
+ public:
+-	PopMailConduit(KPilotDeviceLink *d,
++	PopMailConduit(KPilotLink *d,
+ 		const char *n=0L,
+ 		const QStringList &l=QStringList());
+ 	virtual ~PopMailConduit();
+diff -pruN kpilot/conduits/popmail/popmail-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/popmail/popmail-factory.cc
+--- kpilot/conduits/popmail/popmail-factory.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/popmail/popmail-factory.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -1,6 +1,7 @@
+ /* KPilot
+ **
+ ** Copyright (C) 2001 by Dan Pilone
++** Copyright (C) 2006 by Adriaan de Groot <groot at kde.org>
+ **
+ ** This file defines the factory for the popmail-conduit plugin.
+ */
+@@ -28,16 +29,10 @@
+ 
+ #include "options.h"
+ 
+-#include <qtabwidget.h>
+-#include <qlineedit.h>
+-
+-#include <kconfig.h>
+-#include <kinstance.h>
+-#include <kaboutdata.h>
+ 
+ #include "setupDialog.h"
+ #include "popmail-conduit.h"
+-#include "popmail-factory.moc"
++#include "pluginfactory.h"
+ 
+ 
+ extern "C"
+@@ -45,96 +40,8 @@ extern "C"
+ 
+ void *init_conduit_popmail()
+ {
+-	return new PopMailConduitFactory;
+-}
+-
+-}
+-
+-
+-KAboutData *PopMailConduitFactory::fAbout = 0L;
+-PopMailConduitFactory::PopMailConduitFactory(QObject *p, const char *n) :
+-	KLibFactory(p,n)
+-{
+-	FUNCTIONSETUP;
+-
+-	fInstance = new KInstance("popmailconduit");
+-	fAbout = new KAboutData("popmailConduit",
+-		I18N_NOOP("Mail Conduit for KPilot"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Configures the Mail Conduit for KPilot"),
+-		KAboutData::License_GPL,
+-		"(C) 2001, Dan Pilone, Michael Kropfberger, Adriaan de Groot");
+-	fAbout->addAuthor("Adriaan de Groot",
+-		I18N_NOOP("Maintainer"),
+-		"groot at kde.org",
+-		"http://www.cs.kun.nl/~adridg/kpilot");
+-	fAbout->addAuthor("Dan Pilone",
+-		I18N_NOOP("Original Author"));
+-	fAbout->addCredit("Michael Kropfberger",
+-		I18N_NOOP("POP3 code"));
+-	fAbout->addCredit("Marko Gr&ouml;nroos",
+-		I18N_NOOP("SMTP support and redesign"),
+-		"magi at iki.fi",
+-		"http://www/iki.fi/magi/");
++	return new ConduitFactory<PopMailWidgetConfig,PopMailConduit>;
+ }
+ 
+-PopMailConduitFactory::~PopMailConduitFactory()
+-{
+-	FUNCTIONSETUP;
+-
+-	KPILOT_DELETE(fInstance);
+-	KPILOT_DELETE(fAbout);
+-}
+-
+-/* virtual */ QObject *PopMailConduitFactory::createObject( QObject *p,
+-	const char *n,
+-	const char *c,
+-	const QStringList &a)
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< c
+-		<< endl;
+-#endif
+-
+-	if (qstrcmp(c,"ConduitConfigBase")==0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(p);
+-
+-		if (w)
+-		{
+-			return new PopMailWidgetConfig(w,n);
+-		}
+-		else
+-		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname
+-				<< ": Couldn't cast parent to widget."
+-				<< endl;
+-#endif
+-			return 0L;
+-		}
+-	}
+-
+-	if (qstrcmp(c,"SyncAction")==0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
+-
+-		if (d)
+-		{
+-			return new PopMailConduit(d,n,a);
+-		}
+-		else
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast to KPilotDeviceLink"
+-				<< endl;
+-			return 0L;
+-		}
+-	}
+-	return 0L;
+ }
+ 
+diff -pruN kpilot/conduits/popmail/popmail-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/popmail/popmail-factory.h
+--- kpilot/conduits/popmail/popmail-factory.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/popmail/popmail-factory.h	2006-11-19 22:21:12.000000000 +0100
+@@ -28,30 +28,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include <klibloader.h>
+-
+-class KInstance;
+-class KAboutData;
+-
+-class PopMailConduitFactory : public KLibFactory
+-{
+-Q_OBJECT
+-
+-public:
+-	PopMailConduitFactory(QObject * = 0L,const char * = 0L);
+-	virtual ~PopMailConduitFactory();
+-
+-	static KAboutData *about() { return fAbout; } ;
+-
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() );
+-private:
+-	KInstance *fInstance;
+-	static KAboutData *fAbout;
+-}  ;
+ 
+ extern "C"
+ {
+diff -pruN kpilot/conduits/popmail/setupDialog.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/popmail/setupDialog.cc
+--- kpilot/conduits/popmail/setupDialog.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/popmail/setupDialog.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -29,12 +29,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-// This is an old trick so you can determine what revisions
+-// make up a binary distribution.
+-//
+-//
+-static const char *setupDialog_id=
+-	"$Id: setupDialog.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+ 
+ #include "options.h"
+ 
+@@ -46,6 +40,7 @@ static const char *setupDialog_id=
+ #include <kconfig.h>
+ #include <kstandarddirs.h>
+ #include <klineedit.h>
++#include <kaboutdata.h>
+ 
+ #include <qcheckbox.h>
+ #include <qdir.h>
+@@ -70,7 +65,26 @@ PopMailWidgetConfig::PopMailWidgetConfig
+ {
+ 	FUNCTIONSETUP;
+ 	fConduitName = i18n("KMail");
+-	UIDialog::addAboutPage(fConfigWidget->fTabWidget,PopMailConduitFactory::about());
++	KAboutData *fAbout = new KAboutData("popmailConduit",
++		I18N_NOOP("Mail Conduit for KPilot"),
++		KPILOT_VERSION,
++		I18N_NOOP("Configures the Mail Conduit for KPilot"),
++		KAboutData::License_GPL,
++		"(C) 2001, Dan Pilone, Michael Kropfberger, Adriaan de Groot");
++	fAbout->addAuthor("Adriaan de Groot",
++		I18N_NOOP("Maintainer"),
++		"groot at kde.org",
++		"http://www.kpilot.org/");
++	fAbout->addAuthor("Dan Pilone",
++		I18N_NOOP("Original Author"));
++	fAbout->addCredit("Michael Kropfberger",
++		I18N_NOOP("POP3 code"));
++	fAbout->addCredit("Marko Gr&ouml;nroos",
++		I18N_NOOP("SMTP support and redesign"),
++		"magi at iki.fi",
++		"http://www.iki.fi/magi/");
++
++	UIDialog::addAboutPage(fConfigWidget->fTabWidget,fAbout);
+ 	fWidget=fConfigWidget;
+ 
+ #define CM(a,b) connect(fConfigWidget->a,b,this,SLOT(modified()));
+@@ -82,7 +96,6 @@ PopMailWidgetConfig::PopMailWidgetConfig
+ 	connect(fConfigWidget->fSendMode,SIGNAL(activated(int)),
+ 		this,SLOT(toggleSendMode(int)));
+ 
+-	(void) setupDialog_id;
+ }
+ 
+ void PopMailWidgetConfig::commit()
+diff -pruN kpilot/conduits/popmail/setup-dialog.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/popmail/setup-dialog.ui
+--- kpilot/conduits/popmail/setup-dialog.ui	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/popmail/setup-dialog.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -133,9 +133,9 @@
+     </grid>
+ </widget>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/pythonconduit/Makefile.am /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/Makefile.am
+--- kpilot/conduits/pythonconduit/Makefile.am	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/Makefile.am	1970-01-01 01:00:00.000000000 +0100
+@@ -1,15 +0,0 @@
+-INCLUDES= $(PISOCK_INCLUDE) $(PERL_CFLAGS) -I$(top_srcdir)/kpilot/lib $(all_includes)
+-
+-METASOURCES = AUTO
+-
+-servicedir = $(kde_servicesdir)
+-service_DATA = python-conduit.desktop
+-
+-kde_module_LTLIBRARIES = conduit_python.la
+-
+-
+-conduit_python_la_SOURCES = pythonconduit.kcfgc python-setup.ui \
+-	python-conduit.cc python-factory.cc
+-conduit_python_la_LDFLAGS = -module $(KDE_PLUGIN)  $(all_libraries)
+-conduit_python_la_LIBADD = ../../lib/libkpilot.la $(LIB_KDEUI)
+-
+diff -pruN kpilot/conduits/pythonconduit/python-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-conduit.cc
+--- kpilot/conduits/pythonconduit/python-conduit.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-conduit.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,138 +0,0 @@
+-/* KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file is part of the Python conduit, a conduit for KPilot that
+-** is intended to showcase how to use python code inside a conduit.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "options.h"
+-
+-#include <Python.h>
+-
+-#include "python-conduit.h"  // The Conduit action
+-#include "pythonconduit.h"   // The settings class
+-
+-#include <qthread.h>
+-#include <qapplication.h>
+-
+-extern "C"
+-{
+-long version_conduit_python = KPILOT_PLUGIN_API;
+-const char *id_conduit_python =
+-	"$Id: python-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-}
+-
+-
+-class PythonThread : public QThread
+-{
+-public:
+-	PythonThread(QObject *parent) : fParent(parent) { } ;
+-	virtual void run();
+-
+-	QString result() const { return fResult; } ;
+-
+-protected:
+-	QObject *fParent;
+-	QString fResult;
+-} ;
+-
+-
+-PythonConduit::PythonConduit(KPilotDeviceLink *d,
+-	const char *n,
+-	const QStringList &l) :
+-	ConduitAction(d,n,l)
+-{
+-	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_conduit_python << endl;
+-#endif
+-	fConduitName=i18n("Python");
+-
+-	(void) id_conduit_python;
+-}
+-
+-PythonConduit::~PythonConduit()
+-{
+-	FUNCTIONSETUP;
+-}
+-
+-/* virtual */ bool PythonConduit::exec()
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": In exec() @" << (unsigned long) this << endl;
+-#endif
+-
+-	fThread = new PythonThread(this) ;
+-	fThread->start();
+-	startTickle();
+-	return true;
+-}
+-
+-/* virtual */ bool PythonConduit::event(QEvent *e)
+-{
+-	FUNCTIONSETUP;
+-
+-	if (e->type() == QEvent::User)
+-	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Python thread done." << endl;
+-#endif
+-		QString r;
+-		addSyncLogEntry(i18n("Python returned %1.").arg(fThread->result()));
+-		stopTickle();
+-		delayDone();
+-		return true;
+-	}
+-	else return ConduitAction::event(e);
+-}
+-
+-
+-void PythonThread::run()
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Thread starting." << endl;
+-#endif
+-
+-	PyObject *pName,*pArgs,*pValue;
+-	int i;
+-
+-	Py_Initialize();
+-	pName = PyString_FromString("KPilot");
+-// TODO: This doesn't compile with my python2.3-dev (debian sid)
+-//	pModule = PyImport_Import(pName);
+-	Py_DECREF(pName);
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Thread done with " << endl;
+-#endif
+-
+-
+-	QApplication::postEvent(fParent,new QEvent(QEvent::User));
+-}
+-
+diff -pruN kpilot/conduits/pythonconduit/python-conduit.desktop /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-conduit.desktop
+--- kpilot/conduits/pythonconduit/python-conduit.desktop	2006-10-01 19:30:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-conduit.desktop	1970-01-01 01:00:00.000000000 +0100
+@@ -1,92 +0,0 @@
+-[Desktop Entry]
+-Encoding=UTF-8
+-Type=Service
+-Name=Python (Sample)
+-Name[be]=Python (прыклад)
+-Name[br]=Python (Skoeur)
+-Name[bs]=Python (primjer)
+-Name[ca]=Python (Mostra)
+-Name[cs]=Python (příklad)
+-Name[da]=Python (eksempel)
+-Name[de]=Python (Beispiel)
+-Name[el]=Python (Παράδειγμα)
+-Name[es]=Python (Ejemplo)
+-Name[et]=Python (näidis)
+-Name[eu]=Python (adibidea)
+-Name[fa]=Python (نمونه)
+-Name[fi]=Python (esimerkki)
+-Name[fr]=Python (exemple)
+-Name[ga]=Python (Sampla)
+-Name[gl]=Python (Mostra)
+-Name[he]=Python (דוגמה)
+-Name[hu]=Python (példa)
+-Name[is]=Python (Dæmi)
+-Name[it]=Python (esempio)
+-Name[ja]=Python (サンプル)
+-Name[km]=Python (សាមញ្ញ)
+-Name[lt]=Python (Pavyzdys)
+-Name[ms]=Python (Sampel)
+-Name[nb]=Python (prøve)
+-Name[nds]=Python (Bispeel)
+-Name[nl]=Python (voorbeeld)
+-Name[nn]=Python (prøve)
+-Name[pl]=Python (Przykład)
+-Name[pt]=Python (Exemplo)
+-Name[pt_BR]=Python (exemplo)
+-Name[ru]=Python (пример)
+-Name[se]=Python (geahččaleapmi)
+-Name[sk]=Python (Ukážka)
+-Name[sl]=Python (primer)
+-Name[sr]=Python (пример)
+-Name[sr at Latn]=Python (primer)
+-Name[sv]=Python (exempel)
+-Name[ta]=பைத்தன்(மாதிரி)
+-Name[tg]=Python (намуна)
+-Name[tr]=Python (Örnek)
+-Name[uk]=Python (зразок)
+-Name[zh_CN]=Python (例子)
+-Name[zh_TW]=Python (範例)
+-Comment=This sample conduit runs a Python interpreter.
+-Comment[bg]=Пример за изпълнение на интерпретатора на Python
+-Comment[bs]=Ovaj conduit pozivan Python interpreter.
+-Comment[ca]=Aquest conducte de mostra executa un intèrpret Python.
+-Comment[cs]=Toto propojení spustí interpret Pythonu.
+-Comment[da]=Denne eksempel-kanal kører en Python-fortolker.
+-Comment[de]=Diese Erweiterung (Conduit) startet einen Python-Interpreter
+-Comment[el]=Αυτός το παράδειγμα συνδέσμου εκτελεί ένα μεταγλωττιστή της Python.
+-Comment[es]=Este conducto de ejemplo ejecuta un intérprete de Python
+-Comment[et]=See näidiskanal käivitab Pythoni interpretaatori.
+-Comment[eu]=Adibide honek Python interpretatzaile bat exekutatzen du.
+-Comment[fa]=این لولۀ نمونه، یک مفسر Python را اجرا می‌کند.
+-Comment[fi]=Tämä esimerkkiyhdyskäytävä suorittaa Python-tulkkia.
+-Comment[fr]=Cet exemple de canal lance un interpréteur Python.
+-Comment[ga]=Ritheann an seoladán samplach seo léirmhínitheoir Python.
+-Comment[hu]=Ez a mintacsatoló a Python-értelmezőt futtatja
+-Comment[is]=Þessi sýnishornarás keyrir Python túlk.
+-Comment[it]=Questo conduit avvia un interprete Phython.
+-Comment[ja]=このサンプルコンジットは Python インタープリタを実行します。
+-Comment[km]=បំពង់​គំរូ​នេះ​រត់​កម្មវិធី​បកប្រែ Python ។
+-Comment[lt]=Šis pavyzdinis kanalas vykdo Python interpretatorių.
+-Comment[ms]=Sampel saluran ini menjalankan pentafsir Python.
+-Comment[nb]=Denne prøvekanalen kjører en Python tolker.
+-Comment[nds]=Disse Bispeelkanaal start en Python-Interpreter
+-Comment[nl]=Dit voorbeeld-conduit start een Python-interpreteerder.
+-Comment[nn]=Denne prøvekanalen køyrer en Python-tolkar.
+-Comment[pl]=Ten przykładowy łącznik uruchamia interpreter Pythona.
+-Comment[pt]=Esta conduta exemplo corre um interpretador de Python.
+-Comment[pt_BR]=Este conduíte de exemplo executa um interpretador Python.
+-Comment[ru]=Канал запуска скриптов Python.
+-Comment[sk]=Táto ukážková spojka spúšťa interpreter Python.
+-Comment[sl]=Ta preprost veznik poganja tolmač za Python.
+-Comment[sr]=Овај пример провода стартује интерпретатор Python-а.
+-Comment[sr at Latn]=Ovaj primer provoda startuje interpretator Python-a.
+-Comment[sv]=Den här exempelkanalen kör en Python-tolk.
+-Comment[ta]=இந்த மாதிரி காப்புக் குழாய் பைத்தன் மொழிப்பெயர்ப்பில் ஓடுகிறது
+-Comment[tg]=Канали ба кор андозии ҳуруфотҳои Python
+-Comment[tr]=Bu bileşen, bir Python yorumlayıcısını çalıştırır.
+-Comment[uk]=Цей акведук запускає інтерпретатор Python.
+-Comment[zh_CN]=此示例管道运行 Python 解释器。
+-Comment[zh_TW]=此範例執行 Python 直譯器。
+-Implemented=file
+-ServiceTypes=KPilotConduit
+-X-KDE-Library=conduit_python
+diff -pruN kpilot/conduits/pythonconduit/python-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-conduit.h
+--- kpilot/conduits/pythonconduit/python-conduit.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-conduit.h	1970-01-01 01:00:00.000000000 +0100
+@@ -1,53 +0,0 @@
+-#ifndef _PYTHON_PYTHON_CONDUIT_H
+-#define _PYTHON_PYTHON_CONDUIT_H
+-/* python-conduit.h			KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file is part of the Python conduit, a conduit for KPilot that
+-** runs a Python interpreter in the context of  HotSync. The Python
+-** interpreter can do what it likes. This is probably most useful
+-** in the context of using jpilot-python conduits.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "plugin.h"
+-
+-class PythonThread;
+-
+-class PythonConduit : public ConduitAction
+-{
+-public:
+-	PythonConduit(KPilotDeviceLink *,
+-		const char *name=0L,
+-		const QStringList &args = QStringList());
+-	virtual ~PythonConduit();
+-
+-protected:
+-	virtual bool exec();           // From ConduitAction
+-	virtual bool event(QEvent *e); // From QObject
+-
+-	PythonThread *fThread;           // A QThread subclass for the interpreter
+-};
+-
+-#endif
+diff -pruN kpilot/conduits/pythonconduit/pythonconduit.kcfg /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/pythonconduit.kcfg
+--- kpilot/conduits/pythonconduit/pythonconduit.kcfg	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/pythonconduit.kcfg	1970-01-01 01:00:00.000000000 +0100
+@@ -1,14 +0,0 @@
+-<?xml version="1.0" encoding="UTF-8"?>
+-<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+-      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+-      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+-  <kcfgfile name="kpilotrc"/> 
+-  <group name="Python-conduit">
+-    <entry name="Expression" type="String">
+-        <label>A Python expression to evaluate during a HotSync. The value of $a is added to the sync log.</label>
+-        <default>a=17;</default>
+-    </entry>
+-  </group>
+-	
+-</kcfg>
+diff -pruN kpilot/conduits/pythonconduit/pythonconduit.kcfgc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/pythonconduit.kcfgc
+--- kpilot/conduits/pythonconduit/pythonconduit.kcfgc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/pythonconduit.kcfgc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,7 +0,0 @@
+-File=pythonconduit.kcfg
+-ClassName= PythonConduitSettings
+-Singleton=true
+-ItemAccessors=true
+-Mutators=true
+-GlobalEnums=true
+-SetUserTexts=true
+diff -pruN kpilot/conduits/pythonconduit/python-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-factory.cc
+--- kpilot/conduits/pythonconduit/python-factory.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-factory.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,167 +0,0 @@
+-/* KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file defines the factory for the python-conduit plugin.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "options.h"
+-
+-#include <kconfig.h>
+-#include <kinstance.h>
+-#include <kaboutdata.h>
+-#include <qtextedit.h>
+-
+-#include "uiDialog.h"
+-
+-#include "python-conduit.h"     // Conduit action
+-#include "python-setup.h"
+-#include "python-factory.moc"
+-#include "pythonconduit.h"     // Settings class
+-
+-extern "C"
+-{
+-
+-void *init_conduit_python()
+-{
+-	return new PythonConduitFactory;
+-}
+-
+-}
+-
+-class PythonConduitConfig : public ConduitConfigBase
+-{
+-public:
+-	PythonConduitConfig(QWidget *parent=0L, const char *n=0L);
+-	virtual void commit();
+-	virtual void load();
+-protected:
+-	PythonWidget *fConfigWidget;
+-} ;
+-
+-PythonConduitConfig::PythonConduitConfig(QWidget *p, const char *n) :
+-	ConduitConfigBase(p,n),
+-	fConfigWidget(new PythonWidget(p))
+-{
+-	FUNCTIONSETUP;
+-	fConduitName = i18n("Python");
+-	UIDialog::addAboutPage(fConfigWidget->tabWidget,PythonConduitFactory::about());
+-	fWidget=fConfigWidget;
+-	QObject::connect(fConfigWidget->fExpression,SIGNAL(textChanged()),
+-		this,SLOT(modified()));
+-}
+-
+-/* virtual */ void PythonConduitConfig::commit()
+-{
+-	FUNCTIONSETUP;
+-
+-	PythonConduitSettings::setExpression( fConfigWidget->fExpression->text() );
+-	PythonConduitSettings::self()->writeConfig();
+-}
+-
+-/* virtual */ void PythonConduitConfig::load()
+-{
+-	FUNCTIONSETUP;
+-	PythonConduitSettings::self()->readConfig();
+-
+-	fConfigWidget->fExpression->setText( PythonConduitSettings::expression() );
+-
+-	fModified=false;
+-}
+-
+-KAboutData *PythonConduitFactory::fAbout = 0L;
+-PythonConduitFactory::PythonConduitFactory(QObject *p, const char *n) :
+-	KLibFactory(p,n)
+-{
+-	FUNCTIONSETUP;
+-
+-	fInstance = new KInstance("pythonconduit");
+-	fAbout = new KAboutData("pythonConduit",
+-		I18N_NOOP("Python Conduit for KPilot"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Configures the Python Conduit for KPilot"),
+-		KAboutData::License_LGPL,
+-		"(C) 2004, Adriaan de Groot");
+-	fAbout->addAuthor("Adriaan de Groot",
+-		I18N_NOOP("Primary Author"),
+-		"groot at kde.org",
+-		"http://www.cs.kun.nl/~adridg/");
+-}
+-
+-PythonConduitFactory::~PythonConduitFactory()
+-{
+-	FUNCTIONSETUP;
+-
+-	KPILOT_DELETE(fInstance);
+-	KPILOT_DELETE(fAbout);
+-}
+-
+-/* virtual */ QObject *PythonConduitFactory::createObject( QObject *p,
+-	const char *n,
+-	const char *c,
+-	const QStringList &a)
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< c
+-		<< endl;
+-#endif
+-
+-	if (qstrcmp(c,"ConduitConfigBase")==0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(p);
+-		if (w)
+-		{
+-			return new PythonConduitConfig(w);
+-		}
+-		else
+-		{
+-			return 0L;
+-		}
+-	}
+-
+-	if (qstrcmp(c,"SyncAction")==0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
+-
+-		if (d)
+-		{
+-			return new PythonConduit(d,n,a);
+-		}
+-		else
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast to KPilotDeviceLink"
+-				<< endl;
+-			return 0L;
+-		}
+-	}
+-
+-	return 0L;
+-}
+-
+-
+diff -pruN kpilot/conduits/pythonconduit/python-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-factory.h
+--- kpilot/conduits/pythonconduit/python-factory.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-factory.h	1970-01-01 01:00:00.000000000 +0100
+@@ -1,65 +0,0 @@
+-#ifndef _KPILOT_PYTHON_FACTORY_H
+-#define _KPILOT_PYTHON_FACTORY_H
+-/* python-factory.h                       KPilot
+-**
+-** Copyright (C) 2004 by Adriaan de Groot
+-**
+-** This file defines the factory for the python-conduit plugin.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include <klibloader.h>
+-
+-#include "plugin.h"
+-
+-class KInstance;
+-class KAboutData;
+-
+-class PythonConduitFactory : public KLibFactory
+-{
+-Q_OBJECT
+-
+-public:
+-	PythonConduitFactory(QObject * = 0L,const char * = 0L);
+-	virtual ~PythonConduitFactory();
+-
+-	static KAboutData *about() { return fAbout; } ;
+-
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() );
+-private:
+-	KInstance *fInstance;
+-	static KAboutData *fAbout;
+-} ;
+-
+-extern "C"
+-{
+-
+-void *init_conduit_python();
+-
+-}
+-
+-#endif
+diff -pruN kpilot/conduits/pythonconduit/python-setup.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-setup.ui
+--- kpilot/conduits/pythonconduit/python-setup.ui	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/pythonconduit/python-setup.ui	1970-01-01 01:00:00.000000000 +0100
+@@ -1,95 +0,0 @@
+-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+-<class>PythonWidget</class>
+-<comment>A tabWidget for configuring
+-the Python-conduit settings.</comment>
+-<author>Adriaan de Groot</author>
+-<widget class="QWidget">
+-    <property name="name">
+-        <cstring>Form1</cstring>
+-    </property>
+-    <property name="geometry">
+-        <rect>
+-            <x>0</x>
+-            <y>0</y>
+-            <width>342</width>
+-            <height>169</height>
+-        </rect>
+-    </property>
+-    <property name="sizePolicy">
+-        <sizepolicy>
+-            <hsizetype>5</hsizetype>
+-            <vsizetype>5</vsizetype>
+-            <horstretch>0</horstretch>
+-            <verstretch>0</verstretch>
+-        </sizepolicy>
+-    </property>
+-    <property name="baseSize">
+-        <size>
+-            <width>570</width>
+-            <height>270</height>
+-        </size>
+-    </property>
+-    <property name="caption">
+-        <string>Python-Conduit Options</string>
+-    </property>
+-    <property name="layoutMargin" stdset="0">
+-    </property>
+-    <property name="layoutSpacing" stdset="0">
+-    </property>
+-    <grid>
+-        <property name="name">
+-            <cstring>unnamed</cstring>
+-        </property>
+-        <property name="margin">
+-            <number>0</number>
+-        </property>
+-        <property name="spacing">
+-            <number>6</number>
+-        </property>
+-        <widget class="QTabWidget" row="0" column="0">
+-            <property name="name">
+-                <cstring>tabWidget</cstring>
+-            </property>
+-            <widget class="QWidget">
+-                <property name="name">
+-                    <cstring>Widget2</cstring>
+-                </property>
+-                <attribute name="title">
+-                    <string>General</string>
+-                </attribute>
+-                <grid>
+-                    <property name="name">
+-                        <cstring>unnamed</cstring>
+-                    </property>
+-                    <widget class="QLabel" row="0" column="0">
+-                        <property name="name">
+-                            <cstring>TextLabel1_2</cstring>
+-                        </property>
+-                        <property name="text">
+-                            <string>&amp;Python expression:</string>
+-                        </property>
+-                        <property name="buddy" stdset="0">
+-                            <cstring>fExpression</cstring>
+-                        </property>
+-                    </widget>
+-                    <widget class="QTextEdit" row="1" column="0">
+-                        <property name="name">
+-                            <cstring>fExpression</cstring>
+-                        </property>
+-                        <property name="text">
+-                            <string>$a = 17;</string>
+-                        </property>
+-                        <property name="whatsThis" stdset="0">
+-                            <string>&lt;qt&gt;Enter the Python expression to be evaluated during a HotSync here.&lt;/qt&gt;</string>
+-                        </property>
+-                    </widget>
+-                </grid>
+-            </widget>
+-        </widget>
+-    </grid>
+-</widget>
+-<tabstops>
+-    <tabstop>tabWidget</tabstop>
+-</tabstops>
+-<layoutdefaults spacing="6" margin="11"/>
+-</UI>
+diff -pruN kpilot/conduits/recordconduit/factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/recordconduit/factory.cc
+--- kpilot/conduits/recordconduit/factory.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/recordconduit/factory.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,145 @@
++/* KPilot
++**
++** Copyright (C) 2005 by Adriaan de Groot
++**
++** This file defines the factory for the recordconduit plugin.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "options.h"
++
++#include <qtabwidget.h>
++#include <qlineedit.h>
++#include <qcheckbox.h>
++
++#include <kconfig.h>
++#include <kinstance.h>
++#include <kaboutdata.h>
++
++#include "uiDialog.h"
++#include "pluginfactory.h"
++#include "pilotDatabase.h"
++#include "recordConduit.h"
++
++#include "setup_base.h"
++#include "factory.h"
++#include "settings.h"
++
++
++class ConduitConfig : public ConduitConfigBase
++{
++public:
++	ConduitConfig(QWidget *parent=0L, const char *n=0L);
++	virtual void commit();
++	virtual void load();
++protected:
++	RecordWidget *fConfigWidget;
++	KAboutData *fAbout;
++} ;
++
++ConduitConfig::ConduitConfig(QWidget *p, const char *n) :
++	ConduitConfigBase(p,n),
++	fConfigWidget(new RecordWidget(p))
++{
++	FUNCTIONSETUP;
++	fConduitName = TODO_I18N("Record Conduit");
++		fAbout = new KAboutData("recordConduit",
++		I18N_NOOP("Record Conduit for KPilot"),
++		KPILOT_VERSION,
++		I18N_NOOP("Configures the Record Conduit for KPilot"),
++		KAboutData::License_GPL,
++		"(C) 2005, Adriaan de Groot");
++	fAbout->addAuthor("Adriaan de Groot",
++		I18N_NOOP("Primary Author"),
++		"groot at kde.org",
++		"http://people.fruitsalad.org/adridg/");
++
++	UIDialog::addAboutPage(fConfigWidget->tabWidget,fAbout);
++	fWidget=fConfigWidget;
++	QObject::connect(fConfigWidget->fLogMessage,SIGNAL(textChanged(const QString&)),
++		this,SLOT(modified()));
++	QObject::connect(fConfigWidget->fDatabases,SIGNAL(textChanged(const QString&)),
++		this,SLOT(modified()));
++	QObject::connect(fConfigWidget->fFailImmediately,SIGNAL(toggled(bool)),
++		this,SLOT(modified()));
++}
++
++/* virtual */ void ConduitConfig::commit()
++{
++	FUNCTIONSETUP;
++
++#ifdef DEBUG
++	DEBUGCONDUIT << fname
++		<< ": Message="
++		<< fConfigWidget->fLogMessage->text()
++		<< endl;
++	DEBUGCONDUIT << fname
++		<< ": Databases="
++		<< fConfigWidget->fDatabases->text()
++		<< endl;
++#endif
++
++	ConduitSettings::setLogMessage( fConfigWidget->fLogMessage->text() );
++	ConduitSettings::setDatabases( fConfigWidget->fDatabases->text() );
++	ConduitSettings::setFailImmediately( fConfigWidget->fFailImmediately->isChecked());
++	ConduitSettings::self()->writeConfig();
++	unmodified();
++}
++
++/* virtual */ void ConduitConfig::load()
++{
++	FUNCTIONSETUP;
++	ConduitSettings::self()->readConfig();
++
++	fConfigWidget->fLogMessage->setText( ConduitSettings::logMessage() );
++	fConfigWidget->fDatabases->setText( ConduitSettings::databases().join(",") );
++	fConfigWidget->fFailImmediately->setChecked( ConduitSettings::failImmediately() );
++
++#ifdef DEBUG
++	DEBUGCONDUIT << fname
++		<< ": Read Message="
++		<< fConfigWidget->fLogMessage->text()
++		<< endl;
++	DEBUGCONDUIT << fname
++		<< ": Read Database="
++		<< fConfigWidget->fDatabases->text()
++		<< endl;
++#endif
++
++	unmodified();
++}
++
++typedef PilotDatabase PilotDatabaseContainer;
++
++typedef RecordConduit<PilotRecord, PilotDatabaseContainer, PilotRecord, PilotAppInfoBase, NullMapper<PilotRecord> > RecordAction;
++
++extern "C"
++{
++
++void *init_conduit_record()
++{
++	return new ConduitFactory<ConduitConfig,RecordAction>(0,"recordconduit");
++}
++
++}
++
+diff -pruN kpilot/conduits/recordconduit/factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/recordconduit/factory.h
+--- kpilot/conduits/recordconduit/factory.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/recordconduit/factory.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,40 @@
++#ifndef KPILOT_RECORD_FACTORY_H
++#define KPILOT_RECORD_FACTORY_H
++/* factory.h                       KPilot
++**
++** Copyright (C) 2005 by Adriaan de Groot
++**
++** This is the factory for the recordconduit, which uses the
++** template class RecordConduit for demonstration purposes.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++
++extern "C"
++{
++
++void *init_conduit_record();
++
++}
++
++#endif
+diff -pruN kpilot/conduits/recordconduit/Makefile.am /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/recordconduit/Makefile.am
+--- kpilot/conduits/recordconduit/Makefile.am	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/recordconduit/Makefile.am	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,15 @@
++INCLUDES= $(PISOCK_INCLUDE) -I$(top_srcdir)/kpilot/lib $(all_includes)
++
++METASOURCES = AUTO
++
++servicedir = $(kde_servicesdir)
++service_DATA = record-conduit.desktop
++
++kde_module_LTLIBRARIES = conduit_record.la
++
++
++conduit_record_la_SOURCES = settings.kcfgc setup_base.ui factory.cc
++conduit_record_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
++conduit_record_la_LIBADD = ../../lib/libkpilot.la $(LIB_KDEUI)
++
++kde_kcfg_DATA = settings.kcfg
+diff -pruN kpilot/conduits/recordconduit/record-conduit.desktop /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/recordconduit/record-conduit.desktop
+--- kpilot/conduits/recordconduit/record-conduit.desktop	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/recordconduit/record-conduit.desktop	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,45 @@
++[Desktop Entry]
++Encoding=UTF-8
++Type=Service
++Name=Records (Experimental)
++Comment=This conduit does nothing.
++Comment[bg]=Това нещо прави нищо
++Comment[bs]=Ovaj conduit ne radi ništa.
++Comment[ca]=Aquest conducte no fa res.
++Comment[cs]=Toto propojení nedělá nic.
++Comment[cy]=Nid yw'r cwndid yma yn gwneud unrhyw beth.
++Comment[da]=Denne conduit gør ingenting.
++Comment[de]=Dieser Abgleich (Conduit) ist ohne Funktion
++Comment[el]=Αυτός ο σύνδεσμος δεν κάνει τίποτα.
++Comment[et]=See kanal ei tee mitte kui midagi.
++Comment[fi]=Tämä yhdyskäytävä ei tee mitään.
++Comment[fr]=Ce canal ne fait rien.
++Comment[ga]=Ní dhéanann an seoladán seo faic.
++Comment[hi]=यह कन्ड्यूइट कुछ नहीं करता है.
++Comment[hu]=Ez a csatoló üres, csak tesztelési célokat szolgál
++Comment[is]=Þessi rás gerir ekkert
++Comment[it]=Questo conduit non fa nulla.
++Comment[ja]=このコンジットは未知です。
++Comment[lt]=Šis kanalas nieko neatlieka.
++Comment[nb]=Denne kanalen gjør ingenting.
++Comment[nl]=Dit conduit doet niets.
++Comment[nn]=Denne koplinga gjer ingenting.
++Comment[pl]=Ten łącznik nic nie robi.
++Comment[pt]=Esta conduta não faz nada.
++Comment[pt_BR]=Este conduíte não faz coisa alguma.
++Comment[ro]=Această conductă nu face nimic.
++Comment[ru]=Канал, который ничего не делает.
++Comment[sk]=Táto spojka nič nerobí.
++Comment[sl]=Ta veznik ne počne ničesar.
++Comment[sr]=Овај провод не ради ништа.
++Comment[sr at Latn]=Ovaj provod ne radi ništa.
++Comment[sv]=Den här kanalen gör ingenting.
++Comment[ta]=இந்த காப்புக் குழாய் ஒன்றும் செய்யாது
++Comment[tg]=Канале, ки дар ҳолати шурӯъ нест.
++Comment[tr]=Bu kanal herhangi bir işlem yapmaz.
++Comment[uk]=Цей акведук нічого не робить.
++Comment[xx]=xxThis conduit does nothing.xx
++Comment[zh_CN]=此管道不做任何事。
++Implemented=file
++ServiceTypes=KPilotConduit
++X-KDE-Library=conduit_record
+diff -pruN kpilot/conduits/recordconduit/settings.kcfg /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/recordconduit/settings.kcfg
+--- kpilot/conduits/recordconduit/settings.kcfg	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/recordconduit/settings.kcfg	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,22 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
++      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
++      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
++      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
++  <kcfgfile name="kpilotrc"/>
++  <group name="RecordConduit">
++		<entry name="FailImmediately" key="FailNow" type="Bool">
++        <label>Whether the conduit should immediately bail out with an error</label>
++        <default>false</default>
++    </entry>
++    <entry name="LogMessage" type="String">
++        <label>The error message if the null conduit is supposed to fail</label>
++        <default>KPilot was here.</default>
++    </entry>
++		<entry name="Databases" type="StringList">
++				<label>Databases that are skipped on sync</label>
++				<default></default>
++		</entry>
++  </group>
++
++</kcfg>
+diff -pruN kpilot/conduits/recordconduit/settings.kcfgc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/recordconduit/settings.kcfgc
+--- kpilot/conduits/recordconduit/settings.kcfgc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/recordconduit/settings.kcfgc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,7 @@
++File=settings.kcfg
++ClassName= ConduitSettings
++Singleton=true
++ItemAccessors=true
++Mutators=true
++GlobalEnums=true
++SetUserTexts=true
+diff -pruN kpilot/conduits/recordconduit/setup_base.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/recordconduit/setup_base.ui
+--- kpilot/conduits/recordconduit/setup_base.ui	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/recordconduit/setup_base.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,158 @@
++<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
++<class>RecordWidget</class>
++<comment>A tabWidget for configuring
++the Record-conduit settings.</comment>
++<author>Adriaan de Groot</author>
++<widget class="QWidget">
++    <property name="name">
++        <cstring>Form1</cstring>
++    </property>
++    <property name="geometry">
++        <rect>
++            <x>0</x>
++            <y>0</y>
++            <width>342</width>
++            <height>163</height>
++        </rect>
++    </property>
++    <property name="sizePolicy">
++        <sizepolicy>
++            <hsizetype>5</hsizetype>
++            <vsizetype>5</vsizetype>
++            <horstretch>0</horstretch>
++            <verstretch>0</verstretch>
++        </sizepolicy>
++    </property>
++    <property name="baseSize">
++        <size>
++            <width>570</width>
++            <height>270</height>
++        </size>
++    </property>
++    <property name="caption">
++        <string>Null-Conduit Options</string>
++    </property>
++    <property name="layoutMargin" stdset="0">
++    </property>
++    <property name="layoutSpacing" stdset="0">
++    </property>
++    <grid>
++        <property name="name">
++            <cstring>unnamed</cstring>
++        </property>
++        <property name="margin">
++            <number>0</number>
++        </property>
++        <property name="spacing">
++            <number>6</number>
++        </property>
++        <widget class="QTabWidget" row="0" column="0">
++            <property name="name">
++                <cstring>tabWidget</cstring>
++            </property>
++            <property name="sizePolicy">
++                <sizepolicy>
++                    <hsizetype>7</hsizetype>
++                    <vsizetype>7</vsizetype>
++                    <horstretch>0</horstretch>
++                    <verstretch>0</verstretch>
++                </sizepolicy>
++            </property>
++            <property name="layoutMargin" stdset="0">
++            </property>
++            <widget class="QWidget">
++                <property name="name">
++                    <cstring>Widget2</cstring>
++                </property>
++                <attribute name="title">
++                    <string>General</string>
++                </attribute>
++                <grid>
++                    <property name="name">
++                        <cstring>unnamed</cstring>
++                    </property>
++                    <property name="margin">
++                        <number>11</number>
++                    </property>
++                    <property name="spacing">
++                        <number>6</number>
++                    </property>
++                    <widget class="QLineEdit" row="0" column="1">
++                        <property name="name">
++                            <cstring>fLogMessage</cstring>
++                        </property>
++                        <property name="text">
++                            <string>KPilot was here.</string>
++                        </property>
++                        <property name="whatsThis" stdset="0">
++                            <string>&lt;qt&gt;Enter the message to add to the Sync Log on your Pilot here.&lt;/qt&gt;</string>
++                        </property>
++                    </widget>
++                    <widget class="QLabel" row="0" column="0">
++                        <property name="name">
++                            <cstring>TextLabel1_2</cstring>
++                        </property>
++                        <property name="text">
++                            <string>&amp;Log message:</string>
++                        </property>
++                        <property name="buddy" stdset="0">
++                            <cstring>fLogMessage</cstring>
++                        </property>
++                    </widget>
++                    <widget class="QLabel" row="1" column="0">
++                        <property name="name">
++                            <cstring>TextLabel2_2</cstring>
++                        </property>
++                        <property name="text">
++                            <string>&amp;Databases:</string>
++                        </property>
++                        <property name="buddy" stdset="0">
++                            <cstring>fDatabases</cstring>
++                        </property>
++                    </widget>
++                    <widget class="QLineEdit" row="1" column="1">
++                        <property name="name">
++                            <cstring>fDatabases</cstring>
++                        </property>
++                        <property name="whatsThis" stdset="0">
++                            <string>&lt;qt&gt;The Null-conduit can be attached to several databases, effectively preventing them from Syncing. Enter the database names here.&lt;/qt&gt;</string>
++                        </property>
++                    </widget>
++                    <spacer row="3" column="1">
++                        <property name="name">
++                            <cstring>Spacer4</cstring>
++                        </property>
++                        <property name="orientation">
++                            <enum>Vertical</enum>
++                        </property>
++                        <property name="sizeType">
++                            <enum>Expanding</enum>
++                        </property>
++                        <property name="sizeHint">
++                            <size>
++                                <width>20</width>
++                                <height>20</height>
++                            </size>
++                        </property>
++                    </spacer>
++                    <widget class="QCheckBox" row="2" column="1">
++                        <property name="name">
++                            <cstring>fFailImmediately</cstring>
++                        </property>
++                        <property name="text">
++                            <string>Simulate failure</string>
++                        </property>
++                        <property name="whatsThis" stdset="0">
++                            <string>Force the conduit to simulate a failure to perform the HotSync.</string>
++                        </property>
++                    </widget>
++                </grid>
++            </widget>
++        </widget>
++    </grid>
++</widget>
++<tabstops>
++    <tabstop>tabWidget</tabstop>
++</tabstops>
++<layoutdefaults spacing="6" margin="11"/>
++</UI>
+diff -pruN kpilot/conduits/sysinfoconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/CMakeLists.txt
+--- kpilot/conduits/sysinfoconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,53 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_sysinfo_SRCS
++	sysinfo-setup.cc
++	sysinfo-factory.cc
++	sysinfo-conduit.cc
++)
++
++set(conduit_sysinfo_UIS
++	sysinfo-setup_dialog.ui
++)
++
++set(conduit_sysinfo_KCFGS
++	sysinfoSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_sysinfo_SRCS ${conduit_sysinfo_KCFGS})
++kde3_add_ui_files(conduit_sysinfo_SRCS ${conduit_sysinfo_UIS})
++kde3_automoc(${conduit_sysinfo_SRCS})
++add_library(conduit_sysinfo SHARED ${conduit_sysinfo_SRCS})
++
++set_target_properties(
++	conduit_sysinfo PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_sysinfo)
++
++install(
++	TARGETS conduit_sysinfo
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES sysinfo_conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
++
++install(
++	FILES sysinfoSettings.kcfgc DESTINATION ${KDE3_KCFG_DIR}
++)
++
++install(
++	FILES Template.html DESTINATION ${CMAKE_INSTALL_PREFIX}/share
++)
++
++install(
++	FILES Template.txt 
++	DESTINATION ${CMAKE_INSTALL_PREFIX}/share/apps/kpilot/sysinfoconduit
++)
++
+diff -pruN kpilot/conduits/sysinfoconduit/sysinfo-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-conduit.cc
+--- kpilot/conduits/sysinfoconduit/sysinfo-conduit.cc	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -148,23 +148,18 @@ const QString SysInfoConduit::defaultpag
+ extern "C"
+ {
+ 
+-long version_conduit_sysinfo = KPILOT_PLUGIN_API;
+-const char *id_conduit_sysinfo =
+-	"$Id: sysinfo-conduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
++unsigned long version_conduit_sysinfo = Pilot::PLUGIN_API;
+ 
+ }
+ 
+ 
+ 
+-SysInfoConduit::SysInfoConduit(KPilotDeviceLink * o,
++SysInfoConduit::SysInfoConduit(KPilotLink * o,
+ 	const char *n,
+ 	const QStringList & a) :
+ 	ConduitAction(o, n, a)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<id_conduit_sysinfo<<endl;
+-#endif
+ 	fConduitName=i18n("System Information");
+ }
+ 
+@@ -198,9 +193,6 @@ void SysInfoConduit::readConfig()
+ /* virtual */ bool SysInfoConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << id_conduit_sysinfo<<endl;
+-#endif
+ 
+ 	readConfig();
+ 
+@@ -213,7 +205,7 @@ void SysInfoConduit::hardwareInfo()
+ 	FUNCTIONSETUP;
+ 	if (fHardwareInfo) {
+ 		QString unknown = i18n("unknown");
+-		
++
+ 		/* Retrieve values for
+ 		* - #deviceid#
+ 		* - #devicename#
+@@ -221,17 +213,10 @@ void SysInfoConduit::hardwareInfo()
+ 		* - #manufactorer#
+ 		* - #devicetype#
+ 		*/
+-		KPilotSysInfo *sysinfo = fHandle->getSysInfo();
+-		if (sysinfo)
+-		{
+-			fValues[CSL1("deviceid")] = QString::fromLatin1(sysinfo->getProductID());
+-		}
+-		else
+-		{
+-			fValues[CSL1("deviceid")] = unknown;
+-		}
+-		
+-		KPilotCard *device = fHandle->getCardInfo();
++		KPilotSysInfo sysinfo = fHandle->getSysInfo();
++		fValues[CSL1("deviceid")] = QString::fromLatin1(sysinfo.getProductID());
++
++		const KPilotCard *device = fHandle->getCardInfo();
+ 		if (device)
+ 		{
+ 			fValues[CSL1("devicename")] = QString::fromLatin1(device->getCardName());
+@@ -244,9 +229,9 @@ void SysInfoConduit::hardwareInfo()
+ 			fValues[CSL1("devicemodel")] = unknown;
+ 			fValues[CSL1("manufacturer")] = unknown;
+ 		}
+-		
++
+ 		fValues[CSL1("devicetype")] = unknown;
+-		
++
+ 		KPILOT_DELETE(device);
+ 		keepParts.append(CSL1("hardware"));
+ 	} else removeParts.append(CSL1("hardware"));
+@@ -261,14 +246,14 @@ void SysInfoConduit::userInfo()
+ 		 * - #username#
+ 		 * - #uid#
+ 		 */
+-		KPilotUser*user=fHandle->getPilotUser();
+-		fValues[CSL1("username")] = user->getUserName();
+-		if (user->getPasswordLength()>0)
++		KPilotUser user=fHandle->getPilotUser();
++		fValues[CSL1("username")] = user.getUserName();
++		if (user.getPasswordLength()>0)
+ 			fValues[CSL1("pw")] = i18n("Password set");
+ 		else
+ 			fValues[CSL1("pw")] = i18n("No password set");
+-		fValues[CSL1("uid")] = QString::number(user->getUserID());
+-		fValues[CSL1("viewerid")] = QString::number(user->getViewerID());
++		fValues[CSL1("uid")] = QString::number(user.getUserID());
++		fValues[CSL1("viewerid")] = QString::number(user.getViewerID());
+ 		keepParts.append(CSL1("user"));
+ 	} else removeParts.append(CSL1("user"));
+ 	QTimer::singleShot(0, this, SLOT(memoryInfo()));
+@@ -283,10 +268,13 @@ void SysInfoConduit::memoryInfo()
+ 		 * - #totalmem#
+ 		 * - #freemem#
+ 		 */
+-		KPilotCard*device = fHandle->getCardInfo();
+-		fValues[CSL1("rom")] =  QString::number(device->getRomSize()/1024);
+-		fValues[CSL1("totalmem")] =  QString::number(device->getRamSize()/1024);
+-		fValues[CSL1("freemem")] =  QString::number(device->getRamFree()/1024);
++		const KPilotCard *device = fHandle->getCardInfo();
++		if (device)
++		{
++			fValues[CSL1("rom")] =  QString::number(device->getRomSize()/1024);
++			fValues[CSL1("totalmem")] =  QString::number(device->getRamSize()/1024);
++			fValues[CSL1("freemem")] =  QString::number(device->getRamFree()/1024);
++		}
+ 		keepParts.append(CSL1("memory"));
+ 	} else removeParts.append(CSL1("memory"));
+ 	QTimer::singleShot(0, this, SLOT(storageInfo()));
+@@ -299,7 +287,7 @@ void SysInfoConduit::storageInfo()
+ 		/* Retrieve values for
+ 		 * - $cards$
+ 		 */
+-		KPilotCard*device = fHandle->getCardInfo(1);
++		const KPilotCard *device = fHandle->getCardInfo(1);
+ 		if (device) {
+ 			fValues[CSL1("cards")] = CSL1("%1 (%2, %3 kB of %3 kB free)")
+ 				.arg(QString::fromLatin1(device->getCardName()))
+@@ -322,7 +310,7 @@ void SysInfoConduit::dbListInfo()
+ 		/* Retrieve values for
+ 		 * - #dblist(structure)#
+ 		 */
+-		dblist=fHandle->getDBList();
++		dblist=deviceLink()->getDBList();
+ 		keepParts.append(CSL1("dblist"));
+ 	} else removeParts.append(CSL1("dblist"));
+ 	QTimer::singleShot(0, this, SLOT(recNumberInfo()));
+@@ -338,28 +326,28 @@ void SysInfoConduit::recNumberInfo()
+ 		 * - #todos#
+ 		 * - #memos#
+ 		 */
+-		PilotDatabase*fDatabase;
++		PilotDatabase *fDatabase = 0L;
+ 		QString ERROR = CSL1("ERROR");
+ 		fValues[CSL1("addresses")] = ERROR;
+ 		fValues[CSL1("events")] = ERROR;
+ 		fValues[CSL1("todos")] = ERROR;
+ 		fValues[CSL1("memos")] = ERROR;
+-		fDatabase = new PilotSerialDatabase(pilotSocket(), CSL1("AddressDB"));
++		fDatabase = deviceLink()->database(CSL1("AddressDB"));
+ 		if (fDatabase) {
+ 			fValues[CSL1("addresses")] = QString::number(fDatabase->recordCount());
+ 			KPILOT_DELETE(fDatabase);
+ 		}
+-		fDatabase = new PilotSerialDatabase(pilotSocket(), CSL1("DatebookDB"));
++		fDatabase = deviceLink()->database(CSL1("DatebookDB"));
+ 		if (fDatabase) {
+ 			fValues[CSL1("events")] = QString::number(fDatabase->recordCount());
+ 			KPILOT_DELETE(fDatabase);
+ 		}
+-		fDatabase = new PilotSerialDatabase(pilotSocket(), CSL1("ToDoDB"));
++		fDatabase = deviceLink()->database(CSL1("ToDoDB"));
+ 		if (fDatabase) {
+ 			fValues[CSL1("todos")] = QString::number(fDatabase->recordCount());
+ 			KPILOT_DELETE(fDatabase);
+ 		}
+-		fDatabase = new PilotSerialDatabase(pilotSocket(), CSL1("MemoDB"));
++		fDatabase = deviceLink()->database(CSL1("MemoDB"));
+ 		if (fDatabase) {
+ 			fValues[CSL1("memos")] = QString::number(fDatabase->recordCount());
+ 			KPILOT_DELETE(fDatabase);
+@@ -378,15 +366,15 @@ void SysInfoConduit::syncInfo()
+ 		 * - #lastsuccsync#
+ 		 * - #lastsyncpc#
+ 		 */
+-		KPilotUser*user=fHandle->getPilotUser();
+-		time_t lastsync = user->getLastSyncDate();
++		KPilotUser user = deviceLink()->getPilotUser();
++		time_t lastsync = user.getLastSyncDate();
+ 		QDateTime qlastsync;
+ 		qlastsync.setTime_t(lastsync);
+ 		fValues[CSL1("lastsync")] = qlastsync.toString(Qt::LocalDate);
+-		lastsync = user->getLastSuccessfulSyncDate();
++		lastsync = user.getLastSuccessfulSyncDate();
+ 		qlastsync.setTime_t(lastsync);
+ 		fValues[CSL1("lastsuccsync")] = qlastsync.toString(Qt::LocalDate);
+-		fValues[CSL1("lastsyncpc")] = QString::number(user->getLastSyncPC());
++		fValues[CSL1("lastsyncpc")] = QString::number(user.getLastSyncPC());
+ 		keepParts.append(CSL1("sync"));
+ 	} else removeParts.append(CSL1("sync"));
+ 	QTimer::singleShot(0, this, SLOT(pcVersionInfo()));
+@@ -448,7 +436,8 @@ void SysInfoConduit::palmVersionInfo()
+ 			.arg(fHandle->getSysInfo()->getMinorVersion())
+ 			.arg(fHandle->getSysInfo()->getCompatMajorVersion())
+ 			.arg(fHandle->getSysInfo()->getCompatMinorVersion());*/
+-		fValues[CSL1("palmos")] = CSL1("PalmOS %1.%2").arg(fHandle->majorVersion()).arg(fHandle->minorVersion());
++		KPilotSysInfo i = deviceLink()->getSysInfo();
++		fValues[CSL1("palmos")] = CSL1("PalmOS %1.%2").arg(i.getMajorVersion()).arg(i.getMinorVersion());
+ 
+ 		keepParts.append(CSL1("palmversion"));
+ 	} else removeParts.append(CSL1("palmversion"));
+@@ -535,8 +524,8 @@ void SysInfoConduit::writeFile()
+ 	while (re.search(output)>=0){
+ 		QString dbstring;
+ 		QString subpatt=re.cap(1);
+-		DBInfo*dbi;
+-		for (dbi=dblist.first(); dbi; dbi=dblist.next() ) {
++		for (DBInfoList::ConstIterator i = dblist.begin(); i != dblist.end(); ++i ) {
++			DBInfo dbi = *i;
+ 			QString newpatt(subpatt);
+ 			char tmpchr[5];
+ 			::memset(&tmpchr[0], 0, 5);
+@@ -552,21 +541,21 @@ void SysInfoConduit::writeFile()
+ 			 * %8 .. modifyDate
+ 			 * %9 .. backupDate
+ 			 */
+-			newpatt.replace(CSL1("%0"), QString::fromLatin1(dbi->name));
+-			set_long(&tmpchr[0],dbi->type);
++			newpatt.replace(CSL1("%0"), QString::fromLatin1(dbi.name));
++			set_long(&tmpchr[0],dbi.type);
+ 			newpatt.replace(CSL1("%1"), QString::fromLatin1(tmpchr));
+-			set_long(&tmpchr[0],dbi->creator);
++			set_long(&tmpchr[0],dbi.creator);
+ 			newpatt.replace(CSL1("%2"), QString::fromLatin1(tmpchr));
+-			newpatt.replace(CSL1("%3"), QString::number(dbi->index));
+-			newpatt.replace(CSL1("%4"), QString::number(dbi->flags));
+-			newpatt.replace(CSL1("%5"), QString::number(dbi->miscFlags));
+-			newpatt.replace(CSL1("%6"), QString::number(dbi->version));
++			newpatt.replace(CSL1("%3"), QString::number(dbi.index));
++			newpatt.replace(CSL1("%4"), QString::number(dbi.flags));
++			newpatt.replace(CSL1("%5"), QString::number(dbi.miscFlags));
++			newpatt.replace(CSL1("%6"), QString::number(dbi.version));
+ 			QDateTime tm;
+-			tm.setTime_t(dbi->createDate);
++			tm.setTime_t(dbi.createDate);
+ 			newpatt.replace(CSL1("%7"), tm.toString(Qt::LocalDate));
+-			tm.setTime_t(dbi->modifyDate);
++			tm.setTime_t(dbi.modifyDate);
+ 			newpatt.replace(CSL1("%8"), tm.toString(Qt::LocalDate));
+-			tm.setTime_t(dbi->backupDate);
++			tm.setTime_t(dbi.backupDate);
+ 			newpatt.replace(CSL1("%9"), tm.toString(Qt::LocalDate));
+ 
+ 			dbstring.append(newpatt);
+diff -pruN kpilot/conduits/sysinfoconduit/sysinfo-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-conduit.h
+--- kpilot/conduits/sysinfoconduit/sysinfo-conduit.h	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-conduit.h	2006-11-19 22:21:12.000000000 +0100
+@@ -35,7 +35,7 @@ class SysInfoConduit : public ConduitAct
+ 	Q_OBJECT
+ public:
+ 	SysInfoConduit(
+-		KPilotDeviceLink *o,
++		KPilotLink *o,
+ 		const char *n = 0L,
+ 		const QStringList &a = QStringList() );
+ 	virtual ~SysInfoConduit();
+@@ -70,7 +70,7 @@ private:
+ 		eOutputTemplate
+ 	} fOutputType;
+ 
+-	QPtrList<DBInfo> dblist;
++	DBInfoList dblist;
+ 	QStringList removeParts;
+ 	QStringList keepParts;
+ 	static const QString defaultpage;
+diff -pruN kpilot/conduits/sysinfoconduit/sysinfo-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-factory.cc
+--- kpilot/conduits/sysinfoconduit/sysinfo-factory.cc	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-factory.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -27,100 +27,17 @@
+ */
+ 
+ #include "options.h"
+-
+-#include <kapplication.h>
+-#include <kinstance.h>
+-#include <kaboutdata.h>
++#include "pluginfactory.h"
+ 
+ #include "sysinfo-conduit.h"
+ #include "sysinfo-setup.h"
+ 
+-#include "sysinfo-factory.moc"
+-
+-
+ extern "C"
+ {
+ 
+ void *init_conduit_sysinfo()
+ {
+-	return new SysInfoConduitFactory;
+-}
+-
+-}
+-
+-
+-// A number of static variables
+-KAboutData *SysInfoConduitFactory::fAbout = 0L;
+-
+-
+-SysInfoConduitFactory::SysInfoConduitFactory(QObject *p, const char *n) :
+-	KLibFactory(p,n)
+-{
+-	FUNCTIONSETUP;
+-
+-	fInstance = new KInstance("SysInfoConduit");
+-	fAbout = new KAboutData("SysInfoConduit",
+-		I18N_NOOP("KPilot System Information conduit"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Retrieves System, Hardware, and User Info from the Handheld and stores them to a file."),
+-		KAboutData::License_GPL,
+-		"(C) 2003, Reinhold Kainhofer");
+-	fAbout->addAuthor("Reinhold Kainhofer",
+-		I18N_NOOP("Primary Author"), "reinhold at kainhofer.com", "http://reinhold.kainhofer.com/");
++	return new ConduitFactory<SysInfoWidgetConfig,SysInfoConduit>;
+ }
+ 
+-SysInfoConduitFactory::~SysInfoConduitFactory()
+-{
+-	FUNCTIONSETUP;
+-
+-	KPILOT_DELETE(fInstance);
+-	KPILOT_DELETE(fAbout);
+ }
+-
+-/* virtual */ QObject *SysInfoConduitFactory::createObject( QObject *p,
+-	const char *n,
+-	const char *c,
+-	const QStringList &a)
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< c
+-		<< endl;
+-#endif
+-
+-	if (qstrcmp(c,"ConduitConfigBase")==0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(p);
+-		if (w)
+-		{
+-			return new SysInfoWidgetConfig(w,"ConduitConfigBase");
+-		}
+-		else
+-		{
+-			return 0L;
+-		}
+-	}
+-	else
+-	if (qstrcmp(c,"SyncAction")==0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
+-
+-		if (d)
+-		{
+-			return new SysInfoConduit(d,n,a);
+-		}
+-		else
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast parent to KPilotDeviceLink"
+-				<< endl;
+-			return 0L;
+-		}
+-	}
+-
+-	return 0L;
+-}
+-
+diff -pruN kpilot/conduits/sysinfoconduit/sysinfo-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-factory.h
+--- kpilot/conduits/sysinfoconduit/sysinfo-factory.h	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-factory.h	2006-11-19 22:21:12.000000000 +0100
+@@ -28,31 +28,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include <klibloader.h>
+-
+-class KInstance;
+-class KAboutData;
+-
+-class SysInfoConduitFactory : public KLibFactory
+-{
+-	Q_OBJECT
+-
+-public:
+-	SysInfoConduitFactory(QObject * = 0L,const char * = 0L);
+-	virtual ~SysInfoConduitFactory();
+-
+-	static KAboutData *about() { return fAbout; } ;
+-
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() );
+-private:
+-	KInstance *fInstance;
+-	static KAboutData *fAbout;
+-} ;
+-
+ extern "C"
+ {
+ 	void *init_libsysinfoconduit();
+diff -pruN kpilot/conduits/sysinfoconduit/sysinfo-setup.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-setup.cc
+--- kpilot/conduits/sysinfoconduit/sysinfo-setup.cc	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-setup.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -33,6 +33,8 @@
+ #include <qcheckbox.h>
+ #include <qbuttongroup.h>
+ #include <qlistview.h>
++
++#include <kaboutdata.h>
+ #include <kapplication.h>
+ #include <kurlrequester.h>
+ 
+@@ -89,7 +91,17 @@ SysInfoWidgetConfig::SysInfoWidgetConfig
+ 	fConfigWidget(new SysInfoWidget(w))
+ {
+ 	FUNCTIONSETUP;
+-	UIDialog::addAboutPage(fConfigWidget->tabWidget,SysInfoConduitFactory::about());
++
++	KAboutData *fAbout = new KAboutData("SysInfoConduit",
++		I18N_NOOP("KPilot System Information conduit"),
++		KPILOT_VERSION,
++		I18N_NOOP("Retrieves System, Hardware, and User Info from the Handheld and stores them to a file."),
++		KAboutData::License_GPL,
++		"(C) 2003, Reinhold Kainhofer");
++	fAbout->addAuthor("Reinhold Kainhofer",
++		I18N_NOOP("Primary Author"), "reinhold at kainhofer.com", "http://reinhold.kainhofer.com/");
++
++	UIDialog::addAboutPage(fConfigWidget->tabWidget,fAbout);
+ 	fWidget=fConfigWidget;
+ 
+ 	QObject::connect(fConfigWidget->fOutputFile,SIGNAL(textChanged(const QString&)),
+@@ -121,7 +133,7 @@ void SysInfoWidgetConfig::commit()
+ 			<< (ci->isOn() ? " on" : " off") << endl;
+ #endif
+ 		int index=ci->text(PART_KEY).toInt();
+-		if (0<=index && index<=10) 
++		if (0<=index && index<=10)
+ 		{
+ 			const sysinfoEntry_t *p = sysinfoEntries+index;
+ 			p->mutator(ci->isOn());
+diff -pruN kpilot/conduits/sysinfoconduit/sysinfo-setup_dialog.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-setup_dialog.ui
+--- kpilot/conduits/sysinfoconduit/sysinfo-setup_dialog.ui	2005-09-10 10:24:36.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/sysinfoconduit/sysinfo-setup_dialog.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -206,12 +206,9 @@
+     <tabstop>tabWidget</tabstop>
+ </tabstops>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/timeconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/timeconduit/CMakeLists.txt
+--- kpilot/conduits/timeconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/timeconduit/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,40 @@
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_time_SRCS
++	time-conduit.cc
++	time-factory.cc
++	time-setup.cc
++)
++
++set(conduit_time_UIS
++	time-setup_dialog.ui
++)
++
++set(conduit_time_KCFGS
++	timeConduitSettings.kcfgc
++)
++
++kde3_add_kcfg_files(conduit_time_SRCS ${conduit_time_KCFGS})
++kde3_add_ui_files(conduit_time_SRCS ${conduit_time_UIS})
++kde3_automoc(${conduit_time_SRCS})
++add_library(conduit_time SHARED ${conduit_time_SRCS})
++
++kpilot_rpath(conduit_time)
++
++set_target_properties(
++	conduit_time PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_time)
++
++install(
++	TARGETS conduit_time
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++install(
++	FILES time_conduit.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
+diff -pruN kpilot/conduits/timeconduit/time-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/timeconduit/time-conduit.cc
+--- kpilot/conduits/timeconduit/time-conduit.cc	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/timeconduit/time-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -29,6 +29,8 @@
+ 
+ #include <time.h>
+ 
++#include <pilotSysInfo.h>
++
+ #include <kconfig.h>
+ #include <kdebug.h>
+ 
+@@ -41,22 +43,17 @@
+ // the modules are that make up a binary distribution.
+ extern "C"
+ {
+-long version_conduit_time = KPILOT_PLUGIN_API ;
+-const char *id_conduit_time =
+-	"$Id: time-conduit.cc 450654 2005-08-18 18:37:23Z kainhofe $";
++unsigned long version_conduit_time = Pilot::PLUGIN_API ;
+ }
+ 
+ 
+ 
+-TimeConduit::TimeConduit(KPilotDeviceLink * o,
++TimeConduit::TimeConduit(KPilotLink * o,
+ 	const char *n,
+ 	const QStringList & a) :
+ 	ConduitAction(o, n, a)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<id_conduit_time<<endl;
+-#endif
+ 	fConduitName=i18n("Time");
+ }
+ 
+@@ -79,7 +76,6 @@ void TimeConduit::readConfig()
+ /* virtual */ bool TimeConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-	DEBUGCONDUIT<<id_conduit_time<<endl;
+ 
+ 	readConfig();
+ 
+@@ -103,9 +99,9 @@ void TimeConduit::syncHHfromPC()
+ 	FUNCTIONSETUP;
+ 	time_t ltime;
+ 	time(&ltime);
+-	QDateTime time=QDateTime::currentDateTime();
+ 
+-	long int major=fHandle->majorVersion(), minor=fHandle->minorVersion();
++	long int major=fHandle->getSysInfo().getMajorVersion(), 
++		 minor=fHandle->getSysInfo().getMinorVersion();
+ 
+ 	if (major==3 && (minor==25 || minor==30))
+ 	{
+@@ -113,9 +109,13 @@ void TimeConduit::syncHHfromPC()
+ 		return;
+ 	}
+ 
+-	fHandle->setTime(ltime);
+-#ifdef DEBUG
+-	time.setTime_t(ltime);
+-	DEBUGCONDUIT<<fname<<": synced time "<<time.toString()<<" to the handheld"<<endl;
+-#endif
++	int sd = pilotSocket();
++	if ( sd > 0 )
++	{
++		dlp_SetSysDateTime( sd, ltime );
++	}
++	else
++	{
++		kdWarning() << k_funcinfo << ": Link is not a real device." << endl;
++	}
+ }
+diff -pruN kpilot/conduits/timeconduit/time-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/timeconduit/time-conduit.h
+--- kpilot/conduits/timeconduit/time-conduit.h	2005-09-10 10:24:37.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/timeconduit/time-conduit.h	2006-11-26 23:53:25.000000000 +0100
+@@ -34,7 +34,7 @@ class TimeConduit : public ConduitAction
+ {
+ public:
+ 	TimeConduit(
+-		KPilotDeviceLink *o,
++		KPilotLink *o,
+ 		const char *n = 0L,
+ 		const QStringList &a = QStringList() );
+ 	virtual ~TimeConduit();
+diff -pruN kpilot/conduits/vcalconduit/cleanupstate.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/cleanupstate.cc
+--- kpilot/conduits/vcalconduit/cleanupstate.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/cleanupstate.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,132 @@
++/* KPilot
++**
++** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
++**
++** This file is the implementation of the CleanUpState.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <options.h>
++
++#include <kio/netaccess.h>
++#include <qfile.h>
++
++#include "pilotDatabase.h"
++
++#include "vcal-conduitbase.h"
++#include "vcalconduitSettings.h"
++#include "cleanupstate.h"
++
++
++CleanUpState::CleanUpState()
++{
++	fState = eCleanUp;
++}
++
++CleanUpState::~CleanUpState()
++{
++}
++
++void CleanUpState::startSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Starting CleanUpState." << endl;
++
++	vccb->addLogMessage( i18n( "Cleaning up ..." ) );
++	vccb->postSync();
++
++	if ( vccb->database() )
++	{
++		vccb->database()->resetSyncFlags();
++		vccb->database()->cleanup();
++	}
++	if ( vccb->localDatabase() )
++	{
++		vccb->localDatabase()->resetSyncFlags();
++		vccb->localDatabase()->cleanup();
++	}
++
++	KCal::Calendar *fCalendar = vccb->calendar();
++	QString fCalendarFile = vccb->calendarFile();
++
++	if ( fCalendar )
++	{
++		KURL kurl( vccb->config()->calendarFile() );
++		switch( vccb->config()->calendarType() )
++		{
++		case VCalConduitSettings::eCalendarLocal:
++			dynamic_cast<KCal::CalendarLocal*>(fCalendar)->save( fCalendarFile );
++			if(!kurl.isLocalFile())
++			{
++				if( !KIO::NetAccess::upload( fCalendarFile
++					, vccb->config()->calendarFile(), 0L) )
++				{
++					vccb->addLogError( i18n( "An error occurred while uploading"
++						" \"%1\". You can try to upload "
++						"the temporary local file \"%2\" manually.")
++						.arg(vccb->config()->calendarFile()).arg(fCalendarFile));
++				}
++				else {
++					KIO::NetAccess::removeTempFile( fCalendarFile );
++				}
++				QFile backup( fCalendarFile + CSL1( "~" ) );
++				backup.remove();
++			}
++			break;
++		case VCalConduitSettings::eCalendarResource:
++			fCalendar->save();
++			break;
++		default:
++			break;
++		}
++		fCalendar->close();
++	}
++
++	vccb->setHasNextRecord( false );
++}
++
++void CleanUpState::handleRecord( ConduitAction * )
++{
++	FUNCTIONSETUP;
++}
++
++void CleanUpState::finishSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Finished CleanUpState." << endl;
++	vccb->setState( 0L );
++}
+diff -pruN kpilot/conduits/vcalconduit/cleanupstate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/cleanupstate.h
+--- kpilot/conduits/vcalconduit/cleanupstate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/cleanupstate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,49 @@
++#ifndef _KPILOT_CLEANUPSTATE_H
++#define _KPILOT_CLEANUPSTATE_H
++/* cleanupstate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the cleanupstate for vcal-conduitbase.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "conduitstate.h"
++
++class ConduitAction;
++
++/**
++ * State to Cleanup after all sync actions are finished. @see vcal-conduitstate.h
++ */
++class CleanUpState : public ConduitState
++{
++public:
++	CleanUpState();
++	virtual ~CleanUpState();
++
++	virtual void startSync( ConduitAction* );
++	virtual void handleRecord( ConduitAction* );
++	virtual void finishSync( ConduitAction* );
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/CMakeLists.txt
+--- kpilot/conduits/vcalconduit/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,68 @@
++set(conduit_LIBS kcal)
++
++include_directories(
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++set(conduit_SHARED
++	vcal-setupbase.cc
++	vcal-conduitbase.cc
++	teststate.cc
++	initstate.cc
++	pctohhstate.cc
++	hhtopcstate.cc
++	cleanupstate.cc
++	deleteunsyncedpcstate.cc
++	deleteunsyncedhhstate.cc
++)
++
++kde3_add_kcfg_files(conduit_SHARED vcalconduitSettings.kcfgc)
++kde3_add_ui_files(conduit_SHARED korganizerConduit.ui)
++	
++set(conduit_vcal_SRCS
++	${conduit_SHARED}
++	vcal-conduit.cc
++	vcal-factory.cc
++	vcal-setup.cc
++)
++
++kde3_automoc(${conduit_vcal_SRCS})
++add_library(conduit_vcal SHARED ${conduit_vcal_SRCS})
++target_link_libraries(conduit_vcal kcal)
++
++set(conduit_todo_SRCS
++	${conduit_SHARED}
++	todo-factory.cc
++	todo-setup.cc
++	todo-conduit.cc
++)
++
++kde3_automoc(${conduit_todo_SRCS})
++add_library(conduit_todo SHARED ${conduit_todo_SRCS})
++target_link_libraries(conduit_todo kcal)
++
++set_target_properties(
++	conduit_vcal PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++set_target_properties(
++	conduit_todo PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
++	PREFIX ""
++)
++
++kde3_install_libtool_file(conduit_vcal)
++
++install(
++	TARGETS conduit_vcal conduit_todo
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++)
++
++kde3_install_libtool_file(conduit_todo)
++
++install(
++	FILES vcal-conduit.desktop todo-conduit.desktop 
++	DESTINATION ${KDE3_SERVICES_DIR}
++)
+diff -pruN kpilot/conduits/vcalconduit/conduitstate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/conduitstate.h
+--- kpilot/conduits/vcalconduit/conduitstate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/conduitstate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,86 @@
++#ifndef _KPILOT_CONDUITSTATE_H
++#define _KPILOT_CONDUITSTATE_H
++/* vcal-conduitstate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the vcal-conduitstate.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "plugin.h"
++
++/**
++ * This class defines the current state of the vcal-conduitbase. Subclasses of
++ * this class can do the things that are needed, in methods defined here, for 
++ * the state that they define.
++ */
++class ConduitState
++{
++public:
++	enum state_t {
++		eTest,
++		eInit,
++		ePCToHH,
++		eHHToPC,
++		eDeleteUnsyncedHH,
++		eDeleteUnsyncedPC,
++		eCleanUp
++	};
++
++protected:
++	state_t fState;
++	bool fStarted;
++
++public:
++	ConduitState(){ fState = eInit; fStarted = false; };
++	virtual ~ConduitState() {};
++
++	/**
++	 * Prepare for a sync in the current state. Don't forget to set fState to 
++	 * true in this method. Otherwise the state won't handle records.
++	 */
++	virtual void startSync( ConduitAction * ) = 0;
++	
++	/**
++	 * Sync the next record in row.
++	 */
++	virtual void handleRecord( ConduitAction * ) = 0;
++
++	/**
++	 * Clean up after all records are synced and enter next state.
++	 */
++	virtual void finishSync( ConduitAction * ) = 0;
++
++	/**
++	 * Returns the state type.
++	 */
++	state_t state() { return fState; };
++
++	/**
++	 * Returns wether or not this state has started.
++	 */
++	bool started() { return fStarted; };
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/deleteunsyncedhhstate.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedhhstate.cc
+--- kpilot/conduits/vcalconduit/deleteunsyncedhhstate.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedhhstate.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,115 @@
++/* KPilot
++**
++** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
++**
++** This file is the implementation of the DeleteUnsyncedHHState.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <options.h>
++#include <plugin.h>
++
++#include "pilotDatabase.h"
++#include "pilotRecord.h"
++
++#include "vcal-conduitbase.h"
++#include "deleteunsyncedhhstate.h"
++#include "deleteunsyncedpcstate.h"
++#include "cleanupstate.h"
++
++DeleteUnsyncedHHState::DeleteUnsyncedHHState()
++{
++	fState = eDeleteUnsyncedHH;
++}
++
++DeleteUnsyncedHHState::~DeleteUnsyncedHHState()
++{
++}
++
++void DeleteUnsyncedHHState::startSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Starting DeleteUnsyncedHHState." << endl;
++	
++	fPilotIndex = 0;
++	fNextState = new DeleteUnsyncedPCState();
++	
++	vccb->setHasNextRecord( true );
++	fStarted = true;
++}
++
++void DeleteUnsyncedHHState::handleRecord( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	PilotRecord *r = vccb->localDatabase()->readRecordByIndex( fPilotIndex++ );
++	// if either we don't have a record, or if we're copying everything
++	// from the handheld to the pc, then we don't have anything to do
++	// here.  the latter is because if we're copying HH->PC, then by
++	// definition, we will have everything from the HH on the PC and
++	// therefore can't possibly have anything that needs to be deleted
++	// from it.
++	if ( !r
++		|| ( vccb->syncMode().mode() == ConduitAction::SyncMode::eCopyHHToPC ) )
++	{
++		vccb->setHasNextRecord( false );
++		return;
++	}
++
++	KCal::Incidence *e = vccb->privateBase()->findIncidence( r->id() );
++	if ( !e )
++	{
++		DEBUGCONDUIT << "Didn't find incidence with id = " << r->id()
++			<< ", deleting it" << endl;
++		vccb->deletePalmRecord( NULL, r );
++	}
++
++	KPILOT_DELETE( r );
++}
++
++void DeleteUnsyncedHHState::finishSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Finishing DeleteUnsyncedHHState." << endl;
++	vccb->setState( fNextState );
++}
+diff -pruN kpilot/conduits/vcalconduit/deleteunsyncedhhstate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedhhstate.h
+--- kpilot/conduits/vcalconduit/deleteunsyncedhhstate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedhhstate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,53 @@
++#ifndef _KPILOT_DUSHHSTATE_H
++#define _KPILOT_DUSHHSTATE_H
++/* deleteunsyncedhhstate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the deleteunsyncedpcstate for vcal-conduitbase.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "conduitstate.h"
++
++class VCalConduitBase;
++
++/**
++ * State to handle delete unsynced pc records. @see vcal-conduitstate.h
++ */
++class DeleteUnsyncedHHState : public ConduitState
++{
++private:
++	ConduitState *fNextState;
++	int fPilotIndex;
++
++public:
++	DeleteUnsyncedHHState();
++	virtual ~DeleteUnsyncedHHState();
++
++	virtual void startSync( ConduitAction* );
++	virtual void handleRecord( ConduitAction* );
++	virtual void finishSync( ConduitAction* );
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/deleteunsyncedpcstate.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedpcstate.cc
+--- kpilot/conduits/vcalconduit/deleteunsyncedpcstate.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedpcstate.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,135 @@
++/* KPilot
++**
++** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
++**
++** This file is the implementation of the DeleteUnsyncedPCState.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <options.h>
++#include <plugin.h>
++
++#include "pilotDatabase.h"
++#include "pilotRecord.h"
++
++#include "vcal-conduitbase.h"
++#include "deleteunsyncedpcstate.h"
++#include "cleanupstate.h"
++
++DeleteUnsyncedPCState::DeleteUnsyncedPCState()
++{
++	fState = eDeleteUnsyncedPC;
++}
++
++DeleteUnsyncedPCState::~DeleteUnsyncedPCState()
++{
++}
++
++void DeleteUnsyncedPCState::startSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Starting DeleteUnsyncedPCState." << endl;
++	
++	fPilotIndex = 0;
++	fNextState = new CleanUpState();
++	
++	vccb->setHasNextRecord( true );
++	fStarted = true;
++}
++
++void DeleteUnsyncedPCState::handleRecord( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	KCal::Incidence *e = 0L;
++	e = vccb->privateBase()->getNextIncidence();
++
++	// if we don't have a record, then we can't do anything.  also, if
++	// we're copying everything from the PC to our handheld, then we're
++	// guaranteed not to have anything extra on our PC that's not on
++	// our handheld that needs to get deleted, so we can return in that
++	// case too...
++
++	if( !e || ( vccb->syncMode().mode() == ConduitAction::SyncMode::eCopyPCToHH ) )
++	{
++		vccb->setHasNextRecord( false );
++		return;
++	}
++
++
++	// try to find the corresponding index on the palm.  if we can't
++	// find it, then we have a pc record that needs to be deleted.
++	recordid_t id = e->pilotId();
++	
++	PilotRecord *s = 0L;
++
++	if( id > 0 )
++	{
++		s = vccb->database()->readRecordById( id );
++	}
++
++	// if we either have a pc record with no palm id or if we can't
++	// find a palm record that matches, then we need to delete this PC
++	// record.
++	if ( id <=0 || !s )
++	{
++#ifdef DEBUG
++		DEBUGCONDUIT << fname << ": found PC entry with pilotID: [" << id 
++			<< "], Description: [" << e->summary() 
++			<< "], Time: ["<< e->dtStart().toString() << "] until: ["
++			<< e->dtEnd().toString() << "]. Can't find it on Palm, "
++			<< "so I'm deleting it from the local calendar." << endl;
++#endif
++		vccb->privateBase()->removeIncidence(e);
++	}
++
++	KPILOT_DELETE( s );
++
++}
++
++void DeleteUnsyncedPCState::finishSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Finishing DeleteUnsyncedPCState." << endl;
++	vccb->setState( fNextState );
++}
+diff -pruN kpilot/conduits/vcalconduit/deleteunsyncedpcstate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedpcstate.h
+--- kpilot/conduits/vcalconduit/deleteunsyncedpcstate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/deleteunsyncedpcstate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,53 @@
++#ifndef _KPILOT_DUSPCSTATE_H
++#define _KPILOT_DUSPCSTATE_H
++/* deleteunsyncedpcstate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the deleteunsyncedpcstate for vcal-conduitbase.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "conduitstate.h"
++
++class VCalConduitBase;
++
++/**
++ * State to handle delete unsynced pc records. @see vcal-conduitstate.h
++ */
++class DeleteUnsyncedPCState : public ConduitState
++{
++private:
++	ConduitState *fNextState;
++	int fPilotIndex;
++
++public:
++	DeleteUnsyncedPCState();
++	virtual ~DeleteUnsyncedPCState();
++
++	virtual void startSync( ConduitAction* );
++	virtual void handleRecord( ConduitAction* );
++	virtual void finishSync( ConduitAction* );
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/hhtopcstate.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/hhtopcstate.cc
+--- kpilot/conduits/vcalconduit/hhtopcstate.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/hhtopcstate.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,249 @@
++/* KPilot
++**
++** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
++**
++** This file is the implementation of the HHtoPCState
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <options.h>
++
++#include "pilotDatabase.h"
++#include "pilotRecord.h"
++
++#include "vcalconduitSettings.h"
++#include "vcal-conduitbase.h"
++#include "hhtopcstate.h"
++#include "pctohhstate.h"
++#include "cleanupstate.h"
++
++HHToPCState::HHToPCState()
++{
++	fState = eHHToPC;
++	fPilotindex = 0;
++}
++
++HHToPCState::~HHToPCState()
++{
++}
++
++void HHToPCState::startSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Starting HHToPCState." << endl;
++
++	if ( vccb->syncMode() == ConduitAction::SyncMode::eCopyHHToPC )
++	{
++		fNextState = new CleanUpState();
++	}
++	else
++	{
++		fNextState = new PCToHHState();
++	}
++
++	fStarted = true;
++	vccb->setHasNextRecord( true );
++}
++
++void HHToPCState::handleRecord( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	PilotRecord *r;
++	PilotRecord *s = 0L;
++
++	if ( vccb->isFullSync() )
++	{
++		r = vccb->database()->readRecordByIndex( fPilotindex++ );
++	}
++	else
++	{
++		r = vccb->database()->readNextModifiedRec();
++	}
++
++	if (!r)
++	{
++		vccb->privateBase()->updateIncidences();
++		vccb->setHasNextRecord( false );
++		return;
++	}
++
++	// let subclasses do something with the record before we try to sync
++	vccb->preRecord( r );
++
++	bool archiveRecord = ( r->isArchived() );
++	s = vccb->database()->readRecordById( r->id() );
++	
++	if ( !s || vccb->isFirstSync() )
++	{
++#ifdef DEBUG
++		if ( r->id() > 0 && !s )
++		{
++			DEBUGCONDUIT << "-------------------------------------------------";
++			DEBUGCONDUIT << "--------------------------" << endl;
++			DEBUGCONDUIT << fname << ": Could not read palm record with ID ";
++			DEBUGCONDUIT << r->id() << endl;
++		}
++#endif
++		if ( !r->isDeleted() 
++			|| ( vccb->config()->syncArchived() && archiveRecord ) )
++		{
++			KCal::Incidence *e = vccb->addRecord( r );
++			if ( vccb->config()->syncArchived() && archiveRecord )  {
++				e->setSyncStatus( KCal::Incidence::SYNCDEL );
++			}
++		}
++	}
++	else
++	{
++		if ( r->isDeleted() )
++		{
++			if ( vccb->config()->syncArchived() && archiveRecord )
++			{
++				vccb->changeRecord( r, s );
++			}
++			else
++			{
++				vccb->deleteRecord( r, s );
++			}
++		}
++		else
++		{
++			vccb->changeRecord( r, s );
++		}
++	}
++
++	KPILOT_DELETE(r);
++	KPILOT_DELETE(s);
++}
++
++void HHToPCState::finishSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Finished HHToPCState." << endl;
++	vccb->setState( fNextState );
++}
++
++/*
++void VCalConduitBase::slotPalmRecToPC()
++{
++	FUNCTIONSETUP;
++
++	PilotRecord *r;
++	if (isFullSync())
++	{
++		r = fDatabase->readRecordByIndex(pilotindex++);
++	}
++	else
++	{
++		r = fDatabase->readNextModifiedRec();
++	}
++	PilotRecord *s = 0L;
++
++	if (!r)
++	{
++		fP->updateIncidences();
++		if ( syncMode()==SyncMode::eCopyHHToPC )
++		{
++			emit logMessage(i18n("Cleaning up ..."));
++			QTimer::singleShot(0, this, SLOT(cleanup()));
++			return;
++		}
++		else
++		{
++			emit logMessage(i18n("Copying records to Pilot ..."));
++			QTimer::singleShot(0 ,this,SLOT(slotPCRecToPalm()));
++			return;
++		}
++	}
++
++	// let subclasses do something with the record before we try to sync
++	preRecord(r);
++
++//	DEBUGCONDUIT<<fname<<": Event: "<<e->dtStart()<<" until "<<e->dtEnd()<<endl;
++//	DEBUGCONDUIT<<fname<<": Time: "<<e->dtStart()<<" until "<<e->dtEnd()<<endl;
++	bool archiveRecord=(r->isArchived());
++
++	s = fLocalDatabase->readRecordById(r->id());
++	if (!s || isFirstSync())
++	{
++#ifdef DEBUG
++		if (r->id()>0 && !s)
++		{
++			DEBUGCONDUIT<<"---------------------------------------------------------------------------"<<endl;
++			DEBUGCONDUIT<< fname<<": Could not read palm record with ID "<<r->id()<<endl;
++		}
++#endif
++		if (!r->isDeleted() || (config()->syncArchived() && archiveRecord))
++		{
++			KCal::Incidence*e=addRecord(r);
++			if (config()->syncArchived() && archiveRecord)  {
++				e->setSyncStatus(KCal::Incidence::SYNCDEL);
++			}
++		}
++	}
++	else
++	{
++		if (r->isDeleted())
++		{
++			if (config()->syncArchived() && archiveRecord)
++			{
++				changeRecord(r,s);
++			}
++			else
++			{
++				deleteRecord(r,s);
++			}
++		}
++		else
++		{
++			changeRecord(r,s);
++		}
++	}
++
++	KPILOT_DELETE(r);
++	KPILOT_DELETE(s);
++
++	QTimer::singleShot(0,this,SLOT(slotPalmRecToPC()));
++}
++*/
+diff -pruN kpilot/conduits/vcalconduit/hhtopcstate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/hhtopcstate.h
+--- kpilot/conduits/vcalconduit/hhtopcstate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/hhtopcstate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,55 @@
++#ifndef _KPILOT_HHTOPCSTATE_H
++#define _KPILOT_HHTOPCSTATE_H
++/* hhtopcstate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the teststate for vcal-conduitbase.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <libkcal/calendarlocal.h>
++
++#include "conduitstate.h"
++
++class VCalConduitBase;
++
++/**
++ * State to test the vcal-conduit. @see vcal-conduitstate.h
++ */
++class HHToPCState : public ConduitState
++{
++private:
++	ConduitState *fNextState;
++	int fPilotindex;
++
++public:
++	HHToPCState();
++	virtual ~HHToPCState();
++
++	virtual void startSync( ConduitAction* );
++	virtual void handleRecord( ConduitAction* );
++	virtual void finishSync( ConduitAction* );
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/initstate.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/initstate.cc
+--- kpilot/conduits/vcalconduit/initstate.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/initstate.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,109 @@
++/* KPilot
++**
++** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
++**
++** This file is the implementation of the InitState.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <options.h>
++#include <plugin.h>
++
++#include "vcal-conduitbase.h"
++#include "initstate.h"
++#include "teststate.h"
++#include "pctohhstate.h"
++#include "hhtopcstate.h"
++
++InitState::InitState()
++{
++	fState = eInit;
++}
++
++InitState::~InitState()
++{
++}
++
++void InitState::startSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Starting InitState." << endl;
++
++	vccb->addLogMessage( i18n( "Initializing conduit ..." ) );
++	vccb->preSync();
++
++	if ( vccb->syncMode().isTest() )
++	{
++		fNextState = new TestState();
++	}
++	else
++	{
++		switch( vccb->syncMode().mode() )
++		{
++		case ConduitAction::SyncMode::eCopyPCToHH:
++			// TODO: Clear the palm and backup database??? Or just add the
++			// new items ignore the Palm->PC side and leave the existing items
++			// on the palm?
++			fNextState = new PCToHHState();
++			break;
++		case ConduitAction::SyncMode::eCopyHHToPC:
++			// TODO: Clear the backup database and the calendar, update fP
++			//       or just add the palm items and leave the PC ones there????
++			fNextState = new HHToPCState();
++			break;
++		default:
++			fNextState = new HHToPCState();
++			break;
++		}
++	}
++
++	fStarted = true;
++	vccb->setHasNextRecord( false );
++}
++
++void InitState::handleRecord( ConduitAction *vccb )
++{
++	FUNCTIONSETUP;
++	Q_UNUSED(vccb);
++}
++
++void InitState::finishSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Finished InitState." << endl;
++	vccb->setState( fNextState );
++}
+diff -pruN kpilot/conduits/vcalconduit/initstate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/initstate.h
+--- kpilot/conduits/vcalconduit/initstate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/initstate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,52 @@
++#ifndef _KPILOT_INITSTATE_H
++#define _KPILOT_INITSTATE_H
++/* initstate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the teststate for vcal-conduitbase.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "conduitstate.h"
++
++class VCalConduitBase;
++
++/**
++ * State to test the vcal-conduit. @see vcal-conduitstate.h
++ */
++class InitState : public ConduitState
++{
++private:
++	ConduitState *fNextState;
++
++public:
++	InitState();
++	virtual ~InitState();
++
++	virtual void startSync( ConduitAction *vccb );
++	virtual void handleRecord( ConduitAction *vccb );
++	virtual void finishSync( ConduitAction *vccb );
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/korganizerConduit.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/korganizerConduit.ui
+--- kpilot/conduits/vcalconduit/korganizerConduit.ui	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/korganizerConduit.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -267,9 +267,9 @@ be saved in the calendar on the PC.</str
+     <tabstop>tabWidget</tabstop>
+ </tabstops>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kurlrequester.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++    <include location="global" impldecl="in implementation">kurlrequester.h</include>
++    <include location="global" impldecl="in implementation">klineedit.h</include>
++    <include location="global" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/conduits/vcalconduit/Makefile.am /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/Makefile.am
+--- kpilot/conduits/vcalconduit/Makefile.am	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/Makefile.am	2006-11-19 22:21:12.000000000 +0100
+@@ -16,9 +16,10 @@ noinst_LTLIBRARIES = libvcalconduit_shar
+ 
+ libvcalconduit_shared_la_SOURCES = vcalconduitSettings.kcfgc \
+ 	korganizerConduit.ui \
+-	vcal-factorybase.cc \
+ 	vcal-setupbase.cc \
+-	vcal-conduitbase.cc
++	vcal-conduitbase.cc \
++	cleanupstate.cc deleteunsyncedhhstate.cc deleteunsyncedpcstate.cc \
++	hhtopcstate.cc initstate.cc pctohhstate.cc teststate.cc
+ 
+ conduit_vcal_la_SOURCES = vcal-conduit.cc vcal-factory.cc vcal-setup.cc
+ conduit_vcal_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+diff -pruN kpilot/conduits/vcalconduit/pctohhstate.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/pctohhstate.cc
+--- kpilot/conduits/vcalconduit/pctohhstate.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/pctohhstate.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,156 @@
++/* KPilot
++**
++** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
++**
++** This file is the implementation of the PCToHHState.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <options.h>
++
++#include "pilotDatabase.h"
++#include "pilotRecord.h"
++
++#include "vcal-conduitbase.h"
++#include "pctohhstate.h"
++#include "cleanupstate.h"
++#include "deleteunsyncedhhstate.h"
++
++PCToHHState::PCToHHState()
++{
++	fState = ePCToHH;
++}
++
++PCToHHState::~PCToHHState()
++{
++}
++
++void PCToHHState::startSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++	
++	DEBUGCONDUIT << fname << ": Starting PCToHHState." << endl;
++
++	// if we are asked to copy HH to PC, we shouldn't look for deleted records
++	// on the Palm, since we've just copied them all.  =:)  Otherwise, look for
++	// data on the palm that shouldn't be there and delete it if we find it....
++	if ( vccb->syncMode() == ConduitAction::SyncMode::eCopyHHToPC )
++	{
++		fNextState = new CleanUpState();
++	}
++	else
++	{
++		fNextState = new DeleteUnsyncedHHState();
++	}
++
++	vccb->addLogMessage( i18n( "Copying records to Pilot ..." ) );
++
++	fStarted = true;
++	vccb->setHasNextRecord( true );
++}
++
++void PCToHHState::handleRecord( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	KCal::Incidence *e = 0L;
++
++	if( vccb->isFullSync() )
++	{
++		e = vccb->privateBase()->getNextIncidence();
++	}
++	else
++	{
++		e = vccb->privateBase()->getNextModifiedIncidence();
++	}
++
++	// No more incidences to sync
++	if( !e )
++	{
++		vccb->setHasNextRecord( false );
++		return;
++	}
++	
++	// let subclasses do something with the event
++	vccb->preIncidence( e );
++
++	// find the corresponding index on the palm and sync. If there is none, 
++	// create it.
++	recordid_t id = e->pilotId();
++	
++	DEBUGCONDUIT << fname << ": found PC entry with pilotID " << id <<endl;
++	DEBUGCONDUIT << fname << ": Description: " << e->summary() << endl;
++	DEBUGCONDUIT << fname << ": Time: "<< e->dtStart().toString() << " until "
++		<< e->dtEnd().toString() << endl;
++
++	PilotRecord *s = 0L;
++
++	if( id > 0 && ( s = vccb->database()->readRecordById( id ) ) )
++	{
++		if( e->syncStatus() == KCal::Incidence::SYNCDEL )
++		{
++			vccb->deletePalmRecord( e, s );
++		}
++		else
++		{
++			vccb->changePalmRecord( e, s );
++		}
++
++		KPILOT_DELETE( s );
++	} else {
++#ifdef DEBUG
++		if (id > 0 )
++		{
++			DEBUGCONDUIT << "-------------------------------------------------"
++				<< "--------------------------" << endl;
++			DEBUGCONDUIT << fname << ": Could not read palm record with ID "
++				<< id << endl;
++		}
++#endif
++		vccb->addPalmRecord( e );
++	}
++}
++
++void PCToHHState::finishSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++	
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Finished PCToHHState." << endl;
++	vccb->setState( fNextState );
++}
+diff -pruN kpilot/conduits/vcalconduit/pctohhstate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/pctohhstate.h
+--- kpilot/conduits/vcalconduit/pctohhstate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/pctohhstate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,54 @@
++#ifndef _KPILOT_PCTOHHSTATE_H
++#define _KPILOT_PCTOHHSTATE_H
++/* pctohhstate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the pctohhstate for vcal-conduitbase.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "conduitstate.h"
++
++class VCalConduitBase;
++
++/**
++ * State that handles copying of records from pc to handheld. 
++ * @see vcal-conduitstate.h
++ */
++class PCToHHState : public ConduitState
++{
++private:
++	ConduitState *fNextState;
++	int fPilotindex;
++
++public:
++	PCToHHState();
++	virtual ~PCToHHState();
++
++	virtual void startSync( ConduitAction* );
++	virtual void handleRecord( ConduitAction* );
++	virtual void finishSync( ConduitAction* );
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/teststate.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/teststate.cc
+--- kpilot/conduits/vcalconduit/teststate.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/teststate.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,127 @@
++/* KPilot
++**
++** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
++**
++** This file is the implementation of the TestState.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <options.h>
++
++#include <qdatetime.h>
++#include <qfile.h>
++
++#include "pilotSerialDatabase.h"
++#include "pilotLocalDatabase.h"
++#include "pilotDateEntry.h"
++
++#include "teststate.h"
++#include "vcal-conduitbase.h"
++
++TestState::TestState() : fCalendar( QString::null )
++{
++	fState = eTest;
++}
++
++TestState::~TestState()
++{
++	FUNCTIONSETUP;
++}
++
++void TestState::startSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++	
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++	
++	DEBUGCONDUIT << fname << ": Starting teststate." << endl;
++
++	vccb->setHasNextRecord( true );
++	fPilotindex = 0;
++	fStarted = true;
++}
++
++void TestState::handleRecord( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": Handling record " << fPilotindex << endl;
++
++	PilotRecord *record = vccb->readRecordByIndex( fPilotindex );
++	
++	if( record )
++	{
++		KCal::Incidence *i = vccb->incidenceFromRecord( record );
++		fCalendar.addIncidence( i );
++	
++		KPILOT_DELETE(record);
++	
++		// Schedule more work.
++		++fPilotindex;
++	}
++	else
++	{
++		vccb->setHasNextRecord( false );
++	}
++}
++
++void TestState::finishSync( ConduitAction *ca )
++{
++	FUNCTIONSETUP;
++	
++	VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca);
++	if( !vccb )
++	{
++		return;
++	}
++
++	DEBUGCONDUIT << fname << ": finishing teststate." << endl;
++
++	// No more records present on the device so lets dump the
++	// readed records in a file.
++	QFile f( CSL1("dump.ics") );
++	if( !f.exists() )
++	{
++		f.open( IO_WriteOnly );
++		f.close();
++	}
++
++	if( !fCalendar.save( CSL1("dump.ics") ) )
++	{
++		DEBUGCONDUIT << fname << ": Can't save calendar file." << endl;
++	}
++
++	fCalendar.close();
++
++	vccb->setState( 0L );
++}
+diff -pruN kpilot/conduits/vcalconduit/teststate.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/teststate.h
+--- kpilot/conduits/vcalconduit/teststate.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/teststate.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,55 @@
++#ifndef _KPILOT_TESTSTATE_H
++#define _KPILOT_TESTSTATE_H
++/* teststate.h                       KPilot
++**
++** Copyright (C) 2006 Bertjan Broeksema
++**
++** This file defines the teststate for vcal-conduitbase.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 General Public License for more details.
++**
++** You should have received a copy of the GNU General Public License
++** along with this program in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include <libkcal/calendarlocal.h>
++
++#include "conduitstate.h"
++
++class VCalConduitBase;
++
++/**
++ * State to test the vcal-conduit. @see vcal-conduitstate.h
++ */
++class TestState : public ConduitState
++{
++private:
++	KCal::CalendarLocal fCalendar;
++	int fPilotindex;
++
++public:
++	TestState();
++	virtual ~TestState();
++
++	virtual void startSync( ConduitAction* );
++	virtual void handleRecord( ConduitAction* );
++	virtual void finishSync( ConduitAction* );
++};
++
++#endif
+diff -pruN kpilot/conduits/vcalconduit/todo-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-conduit.cc
+--- kpilot/conduits/vcalconduit/todo-conduit.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -52,10 +52,7 @@
+ 
+ extern "C"
+ {
+-long version_conduit_todo = KPILOT_PLUGIN_API;
+-
+-const char *id_conduit_todo = "$Id: todo-conduit.cc 450417 2005-08-18 06:07:11Z vanrijn $";
+-
++unsigned long version_conduit_todo = Pilot::PLUGIN_API;
+ }
+ 
+ 
+@@ -82,7 +79,12 @@ int TodoConduitPrivate::updateIncidences
+ void TodoConduitPrivate::removeIncidence(KCal::Incidence *e)
+ {
+ 	fAllTodos.remove(static_cast<KCal::Todo*>(e));
++	if (!fCalendar) return;
+ 	fCalendar->deleteTodo(static_cast<KCal::Todo*>(e));
++	// now just in case we're in the middle of reading through our list
++	// and we delete something, set reading to false so we start at the
++	// top again next time and don't have problems with our iterator
++	reading = false;
+ }
+ 
+ 
+@@ -100,7 +102,7 @@ KCal::Incidence *TodoConduitPrivate::fin
+ 
+ 
+ 
+-KCal::Incidence *TodoConduitPrivate::findIncidence(PilotAppCategory*tosearch)
++KCal::Incidence *TodoConduitPrivate::findIncidence(PilotRecordBase *tosearch)
+ {
+ 	PilotTodoEntry*entry=dynamic_cast<PilotTodoEntry*>(tosearch);
+ 	if (!entry) return 0L;
+@@ -169,17 +171,13 @@ KCal::Incidence *TodoConduitPrivate::get
+  *                          TodoConduit class                               *
+  ****************************************************************************/
+ 
+-TodoConduit::TodoConduit(KPilotDeviceLink *d,
++TodoConduit::TodoConduit(KPilotLink *d,
+ 	const char *n,
+-	const QStringList &a) : VCalConduitBase(d,n,a)
++	const QStringList &a) : VCalConduitBase(d,n,a),
++	fTodoAppInfo( 0L )
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_conduit_todo << endl;
+-#endif
+ 	fConduitName=i18n("To-do");
+-
+-        (void) id_conduit_todo;
+ }
+ 
+ 
+@@ -195,7 +193,13 @@ void TodoConduit::_setAppInfo()
+ {
+ 	FUNCTIONSETUP;
+ 	// get the address application header information
+-	fTodoAppInfo->write(fDatabase);
++
++	if( fTodoAppInfo )
++		DEBUGCONDUIT << fname << ": fTodoAppInfo not null" << endl;
++	if( fDatabase )
++		DEBUGCONDUIT << fname << ": fDatabase not null" << endl;
++
++	fTodoAppInfo->writeTo(fDatabase);
+ }
+ 
+ void TodoConduit::_getAppInfo()
+@@ -203,6 +207,7 @@ void TodoConduit::_getAppInfo()
+ 	FUNCTIONSETUP;
+ 	// get the address application header information
+ 
++	KPILOT_DELETE( fTodoAppInfo );
+ 	fTodoAppInfo = new PilotToDoInfo(fDatabase);
+ 
+ #ifdef DEBUG
+@@ -212,7 +217,7 @@ void TodoConduit::_getAppInfo()
+ 
+ 
+ 
+-const QString TodoConduit::getTitle(PilotAppCategory*de)
++const QString TodoConduit::getTitle(PilotRecordBase *de)
+ {
+ 	PilotTodoEntry*d=dynamic_cast<PilotTodoEntry*>(de);
+ 	if (d) return QString(d->getDescription());
+@@ -237,7 +242,12 @@ void TodoConduit::readConfig()
+ #endif
+ }
+ 
+-
++void TodoConduit::preSync()
++{
++	FUNCTIONSETUP;
++	VCalConduitBase::preSync();
++	_getAppInfo();
++}
+ 
+ void TodoConduit::postSync()
+ {
+@@ -251,7 +261,7 @@ void TodoConduit::postSync()
+ 
+ 
+ 
+-PilotRecord*TodoConduit::recordFromIncidence(PilotAppCategory*de, const KCal::Incidence*e)
++PilotRecord*TodoConduit::recordFromIncidence(PilotRecordBase *de, const KCal::Incidence*e)
+ {
+ 	// don't need to check for null pointers here, the recordFromIncidence(PTE*, KCal::Todo*) will do that.
+ 	PilotTodoEntry *tde = dynamic_cast<PilotTodoEntry*>(de);
+@@ -313,7 +323,7 @@ void TodoConduit::preRecord(PilotRecord*
+ 	FUNCTIONSETUP;
+ 	if (!categoriesSynced && r)
+ 	{
+-		const PilotAppCategory*de=newPilotEntry(r);
++		const PilotRecordBase *de=newPilotEntry(r);
+ 		KCal::Incidence *e = fP->findIncidence(r->id());
+ 		setCategory(dynamic_cast<KCal::Todo*>(e), dynamic_cast<const PilotTodoEntry*>(de));
+ 	}
+@@ -335,14 +345,13 @@ void TodoConduit::setCategory(PilotTodoE
+  */
+ QString TodoConduit::_getCat(const QStringList cats, const QString curr) const
+ {
+-	int j;
+ 	if (cats.size()<1) return QString::null;
+ 	if (cats.contains(curr)) return curr;
+ 	for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it )
+ 	{
+-		for (j=1; j<PILOT_CATEGORY_MAX; j++)
++		for (unsigned int j=1; j<Pilot::CATEGORY_COUNT; j++)
+ 		{
+-			QString catName = fTodoAppInfo->category(j);
++			QString catName = fTodoAppInfo->categoryName(j);
+ 			if (!(*it).isEmpty() && !(*it).compare( catName ) )
+ 			{
+ 				return catName;
+@@ -352,14 +361,14 @@ QString TodoConduit::_getCat(const QStri
+ 	// If we have a free label, return the first possible cat
+ 	//
+ 	// FIXME: Clearly buggy, but I don't know how or why
+-	QString lastName = fTodoAppInfo->category(PILOT_CATEGORY_MAX-1);
++	QString lastName = fTodoAppInfo->categoryName(Pilot::CATEGORY_COUNT-1);
+ 	if (lastName.isEmpty()) return cats.first();
+ 	return QString::null;
+ }
+ 
+ 
+ 
+-KCal::Incidence *TodoConduit::incidenceFromRecord(KCal::Incidence *e, const PilotAppCategory *de)
++KCal::Incidence *TodoConduit::incidenceFromRecord(KCal::Incidence *e, const PilotRecordBase *de)
+ {
+ 	return dynamic_cast<KCal::Incidence*>(incidenceFromRecord(dynamic_cast<KCal::Todo*>(e), dynamic_cast<const PilotTodoEntry*>(de)));
+ }
+@@ -430,25 +439,35 @@ void TodoConduit::setCategory(KCal::Todo
+ 	if (!e || !de) return;
+ 	QStringList cats=e->categories();
+ 	int cat=de->category();
+-	if (0<cat && cat<PILOT_CATEGORY_MAX)
++	if (0<cat && cat<Pilot::CATEGORY_COUNT)
+ 	{
+-		QString newcat=fTodoAppInfo->category(cat);
++		QString newcat=fTodoAppInfo->categoryName(cat);
+ 		if (!cats.contains(newcat))
+ 		{
+ 			// if this event only has one category associated with it, then we can
+ 			// safely assume that what we should be doing here is changing it to match
+ 			// the palm.  if there's already more than one category in the event, however, we
+-			// won't cause data loss--we'll just append what the palm has to the 
++			// won't cause data loss--we'll just append what the palm has to the
+ 			// event's categories
+ 			if (cats.count() <=1) cats.clear();
+-			
++
+ 			cats.append( newcat );
+ 			e->setCategories(cats);
+ 		}
+ 	}
+ }
+ 
+-VCalConduitSettings *TodoConduit::config()
+-{
+-  return ToDoConduitFactory::config();
++static VCalConduitSettings *config_vcal = 0L;
++
++VCalConduitSettings *TodoConduit::theConfig() {
++	if (!config_vcal)
++	{
++		config_vcal = new VCalConduitSettings(CSL1("Calendar"));
++	}
++
++	return config_vcal;
++}
++
++VCalConduitSettings *TodoConduit::config() {
++	return theConfig();
+ }
+diff -pruN kpilot/conduits/vcalconduit/todo-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-conduit.h
+--- kpilot/conduits/vcalconduit/todo-conduit.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-conduit.h	2006-11-26 23:53:25.000000000 +0100
+@@ -37,10 +37,8 @@
+ #include <pilotTodoEntry.h>
+ #include "vcal-conduitbase.h"
+ 
+-class PilotRecord;
+ class PilotSerialDatabase;
+ class PilotLocalDatabase;
+-class PilotTodoEntry;
+ 
+ class TodoConduitPrivate : public VCalConduitPrivateBase
+ {
+@@ -55,7 +53,7 @@ public:
+ 	virtual void addIncidence(KCal::Incidence*);
+ 	virtual void removeIncidence(KCal::Incidence *);
+ 	virtual KCal::Incidence *findIncidence(recordid_t);
+-	virtual KCal::Incidence *findIncidence(PilotAppCategory*tosearch);
++	virtual KCal::Incidence *findIncidence(PilotRecordBase *tosearch);
+ 	virtual KCal::Incidence *getNextIncidence();
+ 	virtual KCal::Incidence *getNextModifiedIncidence();
+ 	virtual int count() {return fAllTodos.count();};
+@@ -67,16 +65,16 @@ class TodoConduit : public VCalConduitBa
+ {
+ Q_OBJECT
+ public:
+-	TodoConduit(KPilotDeviceLink *,
++	TodoConduit(KPilotLink *,
+ 		const char *name=0L,
+ 		const QStringList &args = QStringList());
+ 	virtual ~TodoConduit();
+ 
+ protected:
+-	virtual const QString getTitle(PilotAppCategory*de);
++	virtual const QString getTitle(PilotRecordBase *de);
+ 
+ 	virtual const QString dbname() { return CSL1("ToDoDB"); };
+-	virtual void preSync() {_getAppInfo(); };
++	virtual void preSync();
+ 	virtual VCalConduitPrivateBase* newVCalPrivate(KCal::Calendar *fCalendar) {
+ 		return new TodoConduitPrivate(fCalendar);
+ 	};
+@@ -87,7 +85,7 @@ protected:
+ 	virtual void postSync();
+ 	QString _getCat(const QStringList cats, const QString curr) const;
+ 
+-	virtual PilotAppCategory*newPilotEntry(PilotRecord*r) {
++	virtual PilotTodoEntry *newPilotEntry(PilotRecord*r) {
+ 		FUNCTIONSETUP;
+ 		if (r) return new PilotTodoEntry(*(fTodoAppInfo->info()), r);
+ 		else return new PilotTodoEntry(*(fTodoAppInfo->info()));
+@@ -96,12 +94,14 @@ protected:
+ 
+ 	virtual void preRecord(PilotRecord*r);
+ 	virtual VCalConduitSettings *config();
++public:
++	static VCalConduitSettings *theConfig();
+ 
+ protected:
+ 
+-	PilotRecord *recordFromIncidence(PilotAppCategory*de, const KCal::Incidence*e);
++	PilotRecord *recordFromIncidence(PilotRecordBase *de, const KCal::Incidence*e);
+ 	PilotRecord *recordFromTodo(PilotTodoEntry*de, const KCal::Todo*e);
+-	KCal::Incidence *incidenceFromRecord(KCal::Incidence *, const PilotAppCategory *);
++	KCal::Incidence *incidenceFromRecord(KCal::Incidence *, const PilotRecordBase *);
+ 	KCal::Todo *incidenceFromRecord(KCal::Todo *, const PilotTodoEntry *);
+ 
+ 	void setCategory(PilotTodoEntry*de, const KCal::Todo*todo);
+diff -pruN kpilot/conduits/vcalconduit/todo-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-factory.cc
+--- kpilot/conduits/vcalconduit/todo-factory.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-factory.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -29,118 +29,18 @@
+ 
+ #include "options.h"
+ 
+-#include <kaboutdata.h>
++#include "pluginfactory.h"
+ 
+ #include "todo-setup.h"
+ #include "todo-conduit.h"
+-#include "todo-factory.moc"
+-#include "vcalconduitSettings.h"
+ 
+ extern "C"
+ {
+ 
+ void *init_conduit_todo()
+ {
+-	return new ToDoConduitFactory;
++	return new ConduitFactory<ToDoWidgetSetup,TodoConduit>;
+ }
+ 
+ }
+ 
+-VCalConduitSettings* ToDoConduitFactory::fConfig=0L;
+-
+-ToDoConduitFactory::ToDoConduitFactory(QObject *p, const char *n) :
+-	VCalConduitFactoryBase(p,n)
+-{
+-	FUNCTIONSETUP;
+-
+-	fInstance = new KInstance("todoconduit");
+-	fAbout = new KAboutData("todoConduit",
+-		I18N_NOOP("To-do Conduit for KPilot"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Configures the To-do Conduit for KPilot"),
+-		KAboutData::License_GPL,
+-		"(C) 2001, Adriaan de Groot\n(C) 2002-2003, Reinhold Kainhofer");
+-	fAbout->addAuthor("Dan Pilone",
+-		I18N_NOOP("Original Author"));
+-	fAbout->addAuthor("Preston Brown",
+-		I18N_NOOP("Original Author"));
+-	fAbout->addAuthor("Herwin-Jan Steehouwer",
+-		I18N_NOOP("Original Author"));
+-	fAbout->addAuthor("Adriaan de Groot",
+-		I18N_NOOP("Maintainer"),
+-		"groot at kde.org",
+-		"http://www.cs.kun.nl/~adridg/kpilot");
+-	fAbout->addAuthor("Reinhold Kainhofer",
+-		I18N_NOOP("Maintainer"),
+-		"reinhold at kainhofer.com",
+-		"http://reinhold.kainhofer.com/Linux/");
+-}
+-
+-ToDoConduitFactory::~ToDoConduitFactory()
+-{
+-	FUNCTIONSETUP;
+-
+-	KPILOT_DELETE(fInstance);
+-	KPILOT_DELETE(fAbout);
+-}
+-
+-VCalConduitSettings* ToDoConduitFactory::config()
+-{
+-	if (!fConfig) {
+- 		fConfig = new VCalConduitSettings( CSL1("ToDo") );
+- 		if (fConfig) fConfig->readConfig();
+-	}
+-	return fConfig;
+-}
+-
+-/* virtual */ QObject *ToDoConduitFactory::createObject( QObject *p,
+-	const char *n,
+-	const char *c,
+-	const QStringList &a)
+-{
+-	FUNCTIONSETUP;
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< c
+-		<< endl;
+-#endif
+-
+-	if (qstrcmp(c,"ConduitConfigBase")==0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(p);
+-
+-		if (w)
+-		{
+-			return new ToDoWidgetSetup(w,n);
+-		}
+-		else
+-		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname
+-				<< ": Couldn't cast parent to widget."
+-				<< endl;
+-#endif
+-			return 0L;
+-		}
+-	}
+-	else
+-	if (qstrcmp(c,"SyncAction")==0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
+-
+-		if (d)
+-		{
+-			return new TodoConduit(d,n,a);
+-		}
+-		else
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast to KPilotDeviceLink."
+-				<< endl;
+-		}
+-	}
+-
+-	return 0L;
+-}
+diff -pruN kpilot/conduits/vcalconduit/todo-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-factory.h
+--- kpilot/conduits/vcalconduit/todo-factory.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-factory.h	2006-11-19 22:21:12.000000000 +0100
+@@ -30,29 +30,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include "vcal-factorybase.h"
+-
+-class KInstance;
+-
+-class ToDoConduitFactory : public VCalConduitFactoryBase
+-{
+-    Q_OBJECT
+-
+-public:
+-	ToDoConduitFactory(QObject * = 0L,const char * = 0L);
+-	virtual ~ToDoConduitFactory();
+-	static VCalConduitSettings*config();
+-
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() );
+-private:
+-	KInstance *fInstance;
+-	static VCalConduitSettings*fConfig;
+-};
+-
+ extern "C"
+ {
+ 
+diff -pruN kpilot/conduits/vcalconduit/todo-setup.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-setup.cc
+--- kpilot/conduits/vcalconduit/todo-setup.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/todo-setup.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -30,9 +30,10 @@
+ #include "options.h"
+ 
+ #include <qbuttongroup.h>
++#include <kaboutdata.h>
+ 
+ #include "korganizerConduit.h"
+-#include "todo-factory.h"
++#include "todo-conduit.h"
+ #include "todo-setup.h"
+ 
+ #include "uiDialog.h"
+@@ -43,7 +44,28 @@ ToDoWidgetSetup::ToDoWidgetSetup(QWidget
+ {
+ 	FUNCTIONSETUP;
+ 	fConduitName = i18n("To-do");
+-	UIDialog::addAboutPage(fConfigWidget->tabWidget,VCalConduitFactoryBase::about());
++	KAboutData *fAbout = new KAboutData("todoConduit",
++		I18N_NOOP("To-do Conduit for KPilot"),
++		KPILOT_VERSION,
++		I18N_NOOP("Configures the To-do Conduit for KPilot"),
++		KAboutData::License_GPL,
++		"(C) 2001, Adriaan de Groot\n(C) 2002-2003, Reinhold Kainhofer");
++	fAbout->addAuthor("Dan Pilone",
++		I18N_NOOP("Original Author"));
++	fAbout->addAuthor("Preston Brown",
++		I18N_NOOP("Original Author"));
++	fAbout->addAuthor("Herwin-Jan Steehouwer",
++		I18N_NOOP("Original Author"));
++	fAbout->addAuthor("Adriaan de Groot",
++		I18N_NOOP("Maintainer"),
++		"groot at kde.org",
++		"http://www.cs.kun.nl/~adridg/kpilot");
++	fAbout->addAuthor("Reinhold Kainhofer",
++		I18N_NOOP("Maintainer"),
++		"reinhold at kainhofer.com",
++		"http://reinhold.kainhofer.com/Linux/");
++
++	UIDialog::addAboutPage(fConfigWidget->tabWidget,fAbout);
+ 
+ 	fConfigWidget->fSyncDestination->setTitle(i18n("To-do Destination"));
+ }
+@@ -58,8 +80,8 @@ ToDoWidgetSetup::~ToDoWidgetSetup()
+ 	return new ToDoWidgetSetup(w,n);
+ }
+ 
+-VCalConduitSettings*ToDoWidgetSetup::config() 
++VCalConduitSettings*ToDoWidgetSetup::config()
+ {
+-  return ToDoConduitFactory::config(); 
++  return TodoConduit::theConfig();
+ }
+ 
+diff -pruN kpilot/conduits/vcalconduit/vcal-conduitbase.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduitbase.cc
+--- kpilot/conduits/vcalconduit/vcal-conduitbase.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduitbase.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -5,6 +5,7 @@
+ **
+ ** Contributions:
+ **    Copyright (c) 2001 David Jarvie <software at astrojar.org.uk>
++**    Copyright (C) 2006 by Bertjan Broeksema <b.broeksema at gmail.com>
+ **
+ ** This file defines the vcal-conduit plugin.
+ */
+@@ -30,8 +31,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-static const char *vcalconduitbase_id = "$Id: vcal-conduitbase.cc 450417 2005-08-18 06:07:11Z vanrijn $";
+-
+ #include <options.h>
+ 
+ #include <qtimer.h>
+@@ -52,20 +51,20 @@ static const char *vcalconduitbase_id = 
+ #include "vcal-conduitbase.moc"
+ #include "vcalconduitSettings.h"
+ 
+-
+ #ifndef LIBKCAL_IS_VERSION
+ #warning "Using an old version of libkcal with timezone bug."
+ #define LIBKCAL_IS_VERSION(a,b,c) (0)
+ #endif
+ 
++#include "conduitstate.h"
++#include "initstate.h"
+ 
+ 
+ /****************************************************************************
+- *                          VCalConduitBase class                               *
++ *                          VCalConduitBase class                           *
+  ****************************************************************************/
+ 
+-
+-VCalConduitBase::VCalConduitBase(KPilotDeviceLink *d,
++VCalConduitBase::VCalConduitBase(KPilotLink *d,
+ 	const char *n,
+ 	const QStringList &a) :
+ 	ConduitAction(d,n,a),
+@@ -73,78 +72,93 @@ VCalConduitBase::VCalConduitBase(KPilotD
+ 	fP(0L)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<vcalconduitbase_id<<endl;
+-#endif
+-}
+-
+ 
++	fState = new InitState();
++}
+ 
+ VCalConduitBase::~VCalConduitBase()
+ {
+ 	FUNCTIONSETUP;
+ 
+ 	KPILOT_DELETE(fP);
++	KPILOT_DELETE(fState);
+ 	KPILOT_DELETE(fCalendar);
++	KPILOT_DELETE(fDatabase);
++	KPILOT_DELETE(fLocalDatabase);
+ }
+ 
+ 
+-/* There are several different scenarios for a record on the Palm and its PC counterpart
+-	N means a new record, M flags a modified record, D a deleted and - an unmodified record
+-	first is the Palm record, second the corresponding PC record
+-	(-,-)...unchanged, just sync if first time or full sync
+-	(N,-)...no rec matching the Palm ID in the backupDB/calendar yet => add KCal::Event
+-	(M,-)...record is in backupDB, unchanged in calendar => modify in calendar and in backupDB
+-	(D,-)...deleted on Palm, exists in backupDB and calendar => just delete from calendar and backupDB
+-	(-,N)...no or invalid pilotID set for the KCal::Event => just add to palm and backupDB
+-	(-,M)...valid PilotID set => just modify on Palm
+-	(-,D)...Record in backupDB, but not in calendar => delete from Palm and backupDB
+-	(N,N)...Can't find out (the two records are not correlated in any way, they just have the same data!!
+-	(M,M),(M,L),(L,M)...(Record exists on Palm and the Event has the ID) CONFLICT, ask the user what to do
+-		or use a config setting
+-	(L,L)...already deleted on both, no need to do anything.
+-
++/*
++	There are several different scenarios for a record on the Palm and its PC
++	counterpart. N means a new record, M flags a modified record, D a deleted
++	and - an unmodified record. First is the Palm record, second the
++	corresponding PC record:
++	(-,-) unchanged, just sync if first time or full sync
++	(N,-) no rec matching the Palm ID in the backupDB/calendar yet => add
++	      KCal::Event
++	(M,-) record is in backupDB, unchanged in calendar => modify in calendar and
++	      in backupDB
++	(D,-) deleted on Palm, exists in backupDB and calendar => just delete from
++	      calendar and backupDB
++	(-,N) no or invalid pilotID set for the KCal::Event => just add to palm and
++	      backupDB
++	(-,M) valid PilotID set => just modify on Palm
++	(-,D) Record in backupDB, but not in calendar => delete from Palm and
++	      backupDB
++	(N,N) Can't find out (the two records are not correlated in any way, they
++	      just have the same data!!
++	(M,M),(M,L),(L,M) (Record exists on Palm and the Event has the ID) CONFLICT,
++	      ask the user what to do or use a config setting
++	(L,L) already deleted on both, no need to do anything.
+ 
+ 	The sync process is as follows (for a fast sync):
+-	1) slotPalmRecToPC goes through all records on Palm (just the modified one are necessary), find it
+-		in the backupDB. The following handles ([NMD],*)
+-		a) if it doesn't exist and was not deleted, add it to the calendar and the backupDB
+-		b) if it exists and was not deleted,
+-			A) if it is unchanged in the calendar, just modify in the calendar
+-		c) if it exists and was deleted, delete it from the calendar if necessary
+-	2) slotEvent goes through all KCale::Events in the calendar (just modified, this is the modification
+-		time is later than the last sync time). This handles (-,N),(-,M)
+-		a) if it does not have a pilotID, add it to the palm and backupDB, store the PalmID
++	1) HHToPCState goes through all records on Palm (just the modified one
++	   are necessary), find it in the backupDB. The following handles ([NMD],*)
++		a) if it doesn't exist and was not deleted, add it to the calendar and
++		   the backupDB
++		b) if it exists, is unchanged in the calendar and was not deleted,
++		   just modify in the calendar
++		c) if it exists and was deleted, delete it from the calendar if
++		   necessary
++	2) PCToHHState goes through all KCale::Events in the calendar (just
++	   modified, this is the modification time is later than the last sync time
++		). This handles (-,N),(-,M)
++		a) if it does not have a pilotID, add it to the palm and backupDB,
++		   store the PalmID
+ 		b) if it has a valid pilotID, update the Palm record and the backup
+-	3) finally, deleteRecord goes through all records (which don't have the deleted flag) of the backup db
+-		and if one does not exist in the Calendar, it was deleted there, so delete it from the Palm, too.
+-		This handles the last remaining case of (-,D)
+-
+-
+-In addition to the fast sync, where the last sync was done with this very PC and calendar file,
+-there are two special cases: a full and a first sync.
+--) a full sync goes through all records, not just the modified ones. The pilotID setting of the calendar
+-	records is used to determine if the record already exists. if yes, the record is just modified
+--) a first sync completely ignores the pilotID setting of the calendar events. All records are added,
+-	so there might be duplicates. The add function for the calendar should check if a similar record already
+-	exists, but this is not done yet.
+-
+-
+--) a full sync is done if
+-	a) there is a backupdb and a calendar, but the PC id number changed
+-	b) it was explicitly requested by pressing the full sync button in KPilot
+-	c) the setting "always full sync" was selected in the configuration dlg
+--) a first sync is done if
+-	a) either the calendar or the backup DB does not exist.
+-	b) the calendar and the backup DB exists, but the sync is done for a different User name
+-	c) it was explicitly requested in KPilot
+-
++	3) DeletedUnsyncedHHState goes through all palm records (which don't
++	   have the deleted flag) of the palm db and if one does not exist in the
++	   Calendar, it was deleted there, so delete it from the Palm and backup,
++	   too. This handles the case of (-,D)
++	4) DeletedUnsyncedPCState goes through all KCal::Events in the calendar and
++	   looks for a corresponding event in the palm database. If it does not
++	   exist, that means that it was deleted on the palm, so we need to also
++	   delete it from the local calendar.  This handles the case of (D,-).
++
++	In addition to the fast sync, where the last sync was done with this very
++	PC and calendar file, there are two special cases: a full and a first sync.
++	-) a full sync goes through all records, not just the modified ones. The
++	   pilotID setting of the calendar records is used to determine if the
++	   record already exists. if yes, the record is just modified.
++	-) a first sync completely ignores the pilotID setting of the calendar
++	   events. All records are added, so there might be duplicates. The add
++	   function for the calendar should check if a similar record already
++	   exists, but this is not done yet.
++
++	-) a full sync is done if
++	   a) there is a backupdb and a calendar, but the PC id number changed
++	   b) it was explicitly requested by pressing the full sync button in KPilot
++	   c) the setting "always full sync" was selected in the configuration dlg
++	-) a first sync is done if
++	   a) either the calendar or the backup DB does not exist.
++	   b) the calendar and the backup DB exists, but the sync is done for a
++	      different User name
++	   c) it was explicitly requested in KPilot
+ */
+ 
+ /* virtual */ bool VCalConduitBase::exec()
+ {
+ 	FUNCTIONSETUP;
+-	DEBUGCONDUIT<<vcalconduitbase_id<<endl;
+ 
+ 	readConfig();
+ 
+@@ -154,56 +168,64 @@ there are two special cases: a full and 
+ 
+ 	// TODO: Check Full sync and First sync
+ 	bool retrieved = false;
+-	if (!openCalendar() ) goto error;
+-	if (!openDatabases(dbname(), &retrieved) ) goto error;
++	if ( !openDatabases( dbname(), &retrieved ) ) goto error;
+ 	setFirstSync( retrieved );
+-	preSync();
+ 
++	// If we are in testmode we don't need the local calendar. Else a
++	// calendar *must* be opened, we want to sync something don't we?
++	if (!syncMode().isTest() && !openCalendar() ) goto error;
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<fname<<": fullsync="<<isFullSync()<<", firstSync="<<isFirstSync()<<endl;
+-	DEBUGCONDUIT<<fname<<": syncAction=" << syncMode().name() <<
+-		", conflictResolution = "<<getConflictResolution()<<", archive = "<<config()->syncArchived()<<endl;
+-#endif
+-
+-	pilotindex=0;
+-	switch (syncMode().mode())
+-	{
+-	case SyncMode::eCopyPCToHH:
+-		// TODO: Clear the palm and backup database??? Or just add the new items ignore
+-		// the Palm->PC side and leave the existing items on the palm?
+-		emit logMessage(i18n("Copying records to Pilot ..."));
+-		QTimer::singleShot(0, this, SLOT(slotPCRecToPalm()));
+-		break;
+-	case SyncMode::eCopyHHToPC:
+-		// TODO: Clear the backup database and the calendar, update fP
+-		//       or just add the palm items and leave the PC ones there????
+-	default:
+-		emit logMessage(i18n("Copying records to PC ..."));
+-		QTimer::singleShot(0, this, SLOT(slotPalmRecToPC()));
+-	}
++	// Start processing the sync
++	QTimer::singleShot(0, this, SLOT(slotProcess()));
+ 	return true;
+ 
+ error:
+-
+-	emit logError(i18n("Could not open the calendar databases."));
++	emit logError( i18n( "Could not open the calendar databases." ) );
+ 
+ 	KPILOT_DELETE(fCalendar);
+ 	KPILOT_DELETE(fP);
++	KPILOT_DELETE(fState);
+ 	return false;
+ }
+ 
++void VCalConduitBase::slotProcess() {
++	FUNCTIONSETUP;
+ 
++	// start the current state if necessary
++	if( fState && !fState->started() ) {
++		fState->startSync( this );
++	}
++
++	// Process next record if applicable
++	if( hasNextRecord )
++	{
++		fState->handleRecord( this );
++		QTimer::singleShot( 0, this, SLOT( slotProcess() ) );
++	}
++	// Else finish the current state if there is one
++	else if( fState )
++	{
++		fState->finishSync( this );
++		QTimer::singleShot( 0, this, SLOT( slotProcess() ) );
++	}
++	// No state so sync is finished
++	else
++	{
++		DEBUGCONDUIT << fname << ": Sync finished." << endl;
++		delayDone();
++	}
++}
+ 
+ /* virtual */ void VCalConduitBase::readConfig()
+ {
+ 	config()->readConfig();
+-	SyncAction::ConflictResolution res=(SyncAction::ConflictResolution)(config()->conflictResolution());
+-	setConflictResolution(res);
++	SyncAction::ConflictResolution res = (SyncAction::ConflictResolution)
++		(config()->conflictResolution());
++	setConflictResolution( res );
+ }
+ 
+ #ifdef DEBUG
+-static void listResources(KCal::CalendarResources *p)
++static void listResources( KCal::CalendarResources *p )
+ {
+ 	FUNCTIONSETUP;
+ 	KCal::CalendarResourceManager *manager = p->resourceManager();
+@@ -222,71 +244,64 @@ static void listResources(KCal::Calendar
+ 	FUNCTIONSETUP;
+ 
+ 	KConfig korgcfg( locate( "config", CSL1("korganizerrc") ) );
++
+ 	// this part taken from adcalendarbase.cpp:
+ 	korgcfg.setGroup( "Time & Date" );
+ 	QString tz(korgcfg.readEntry( "TimeZoneId" ) );
+-#ifdef DEBUG
++
+ 	DEBUGCONDUIT << fname << ": KOrganizer's time zone = " << tz << endl;
+-#endif
+ 
+ 	// Need a subclass ptr. for the ResourceCalendar methods
+ 	KCal::CalendarResources *rescal = 0L;
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Got calendar type " << config()->calendarType() << endl;
+-#endif
++	DEBUGCONDUIT << fname << ": Got calendar type " << config()->calendarType()
++		<< endl;
+ 
+ 	switch(config()->calendarType())
+ 	{
+ 		case VCalConduitSettings::eCalendarLocal:
+ 		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname
+-				<< "Using CalendarLocal, file="
++			DEBUGCONDUIT << fname << "Using CalendarLocal, file = "
+ 				<< config()->calendarFile() << endl;
+-#endif
+-			if (config()->calendarFile().isEmpty() )
++
++			if ( config()->calendarFile().isEmpty() )
+ 			{
+-#ifdef DEBUG
+-				DEBUGCONDUIT << fname
+-					<< "Empty calendar file name."
+-					<< endl;
+-#endif
+-				emit logError(i18n("You selected to sync with the a iCalendar file, "
+-						"but did not give a filename. Please select a valid file name in "
+-						"the conduit's configuration dialog"));
++				DEBUGCONDUIT << fname << "Empty calendar file name." << endl;
++
++				emit logError( i18n( "You selected to sync with an iCalendar"
++						" file, but did not give a filename. Please select a"
++						" valid file name in the conduit's configuration"
++						" dialog" ) );
+ 				return false;
+ 			}
+ 
+-			fCalendar = new KCal::CalendarLocal(tz);
+-			if ( !fCalendar)
++			fCalendar = new KCal::CalendarLocal( tz );
++			if ( !fCalendar )
+ 			{
+ 				kdWarning() << k_funcinfo
+ 					<< "Cannot initialize calendar object for file "
+ 					<< config()->calendarFile() << endl;
+ 				return false;
+ 			}
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname
+-				<< "Calendar's timezone: "
++
++			DEBUGCONDUIT << fname << "Calendar's timezone: "
+ 				<< fCalendar->timeZoneId() << endl;
+-			DEBUGCONDUIT << fname
+-				<< "Calendar is local time: "
++			DEBUGCONDUIT << fname << "Calendar is local time: "
+ 				<< fCalendar->isLocalTime() << endl;
+-#endif
++
+ 			emit logMessage( fCalendar->isLocalTime() ?
+-				i18n("Using local time zone: %1").arg(tz) :
+-				i18n("Using non-local time zone: %1").arg(tz) );
++				i18n( "Using local time zone: %1" ).arg( tz ) :
++				i18n( "Using non-local time zone: %1" ).arg( tz ) );
+ 
+-			KURL kurl(config()->calendarFile());
+-			if(!KIO::NetAccess::download(config()->calendarFile(), fCalendarFile, 0L) &&
+-				!kurl.isLocalFile())
++			KURL kurl( config()->calendarFile() );
++			if( !KIO::NetAccess::download( config()->calendarFile(),
++				fCalendarFile, 0L ) && !kurl.isLocalFile() )
+ 			{
+-				emit logError(i18n("You chose to sync with the file \"%1\", which "
+-							"cannot be opened. Please make sure to supply a "
+-							"valid file name in the conduit's configuration dialog. "
+-							"Aborting the conduit.").arg(config()->calendarFile()));
+-				KIO::NetAccess::removeTempFile(fCalendarFile);
++				emit logError(i18n( "You chose to sync with the file \"%1\", which "
++					"cannot be opened. Please make sure to supply a "
++					"valid file name in the conduit's configuration dialog. "
++					"Aborting the conduit." ).arg( config()->calendarFile() ) );
++				KIO::NetAccess::removeTempFile( fCalendarFile );
+ 				return false;
+ 			}
+ 
+@@ -294,41 +309,34 @@ static void listResources(KCal::Calendar
+ 			// the calendar is initialized, so nothing more to do...
+ 			if (!dynamic_cast<KCal::CalendarLocal*>(fCalendar)->load(fCalendarFile) )
+ 			{
+-#ifdef DEBUG
+-				DEBUGCONDUIT << fname
+-					<< "Calendar file "
+-					<< fCalendarFile
+-					<< " could not be opened. "
+-					   "Will create a new one"
+-					<< endl;
+-#endif
++				DEBUGCONDUIT << fname << "Calendar file " << fCalendarFile
++					<< " could not be opened. Will create a new one" << endl;
++
+ 				// Try to create empty file. if it fails,
+ 				// no valid file name was given.
+ 				QFile fl(fCalendarFile);
+ 				if (!fl.open(IO_WriteOnly | IO_Append))
+ 				{
+-#ifdef DEBUG
+-					DEBUGCONDUIT << fname
+-						<< "Invalid calendar file name "
++					DEBUGCONDUIT << fname << "Invalid calendar file name "
+ 						<< fCalendarFile << endl;
+-#endif
+-					emit logError(i18n("You chose to sync with the file \"%1\", which "
+-							"cannot be opened or created. Please make sure to supply a "
+-							"valid file name in the conduit's configuration dialog. "
+-							"Aborting the conduit.").arg(config()->calendarFile()));
++
++					emit logError( i18n( "You chose to sync with the file \"%1\", which "
++						"cannot be opened or created. Please make sure to supply a "
++						"valid file name in the conduit's configuration dialog. "
++						"Aborting the conduit." ).arg( config()->calendarFile() ) );
+ 					return false;
+ 				}
+ 				fl.close();
+ 				setFirstSync( true );
+ 			}
+-			addSyncLogEntry(i18n("Syncing with file \"%1\"").arg(config()->calendarFile()));
++			addSyncLogEntry( i18n( "Syncing with file \"%1\"" )
++				.arg( config()->calendarFile() ) );
+ 			break;
+ 		}
+ 
+ 		case VCalConduitSettings::eCalendarResource:
+-#ifdef DEBUG
+ 			DEBUGCONDUIT << "Using CalendarResource!" << endl;
+-#endif
++
+ 			rescal = new KCal::CalendarResources( tz );
+ #ifdef DEBUG
+ 			listResources(rescal);
+@@ -336,39 +344,42 @@ static void listResources(KCal::Calendar
+ 			fCalendar = rescal;
+ 			if ( !fCalendar)
+ 			{
+-				kdWarning() << k_funcinfo << "Cannot initialize calendar "<<
+-					"object for ResourceCalendar"<<endl;
++				kdWarning() << k_funcinfo << "Cannot initialize calendar " <<
++					"object for ResourceCalendar" << endl;
+ 				return false;
+ 			}
++
+ #if LIBKCAL_IS_VERSION(1,1,0)
+ 			rescal->readConfig();
+ 			rescal->load();
+ #else
+ #warning "Timezone bug is present."
+ #endif
+-			addSyncLogEntry(i18n("Syncing with standard calendar resource."));
++			addSyncLogEntry( i18n( "Syncing with standard calendar resource." ) );
+ 			emit logMessage( fCalendar->isLocalTime() ?
+-				i18n("Using local time zone: %1").arg(tz) :
+-				i18n("Using non-local time zone: %1").arg(tz) );
++				i18n( "Using local time zone: %1" ).arg( tz ) :
++				i18n( "Using non-local time zone: %1" ).arg( tz ) );
+ 			break;
+ 		default:
+ 			break;
+-
+ 	}
+ 
+-	if (!fCalendar)
++	if ( !fCalendar )
+ 	{
+-		kdWarning() <<k_funcinfo << "Unable to initialize calendar object. Please check the conduit's setup."<<endl;
+-		emit logError(i18n("Unable to initialize the calendar object. Please check the conduit's setup"));
++		kdWarning() <<k_funcinfo << "Unable to initialize calendar object."
++			<< " Please check the conduit's setup." << endl;
++		emit logError( i18n( "Unable to initialize the calendar object. Please"
++			" check the conduit's setup") );
+ 		return false;
+ 	}
+-	fP = newVCalPrivate(fCalendar);
+-	if (!fP)
++	fP = newVCalPrivate( fCalendar );
++	if ( !fP )
+ 	{
+ 		return false;
+ 	}
+ 	fP->updateIncidences();
+-	if (fP->count()<1)
++
++	if ( fP->count() < 1 )
+ 	{
+ 		setFirstSync( true );
+ 	}
+@@ -376,303 +387,59 @@ static void listResources(KCal::Calendar
+ 	return true;
+ }
+ 
+-
+-
+-void VCalConduitBase::slotPalmRecToPC()
+-{
+-	FUNCTIONSETUP;
+-
+-	PilotRecord *r;
+-	if (isFullSync())
+-	{
+-		r = fDatabase->readRecordByIndex(pilotindex++);
+-	}
+-	else
+-	{
+-		r = fDatabase->readNextModifiedRec();
+-	}
+-	PilotRecord *s = 0L;
+-
+-	if (!r)
+-	{
+-		fP->updateIncidences();
+-		if ( syncMode()==SyncMode::eCopyHHToPC )
+-		{
+-			emit logMessage(i18n("Cleaning up ..."));
+-			QTimer::singleShot(0, this, SLOT(cleanup()));
+-			return;
+-		}
+-		else
+-		{
+-			emit logMessage(i18n("Copying records to Pilot ..."));
+-			QTimer::singleShot(0 ,this,SLOT(slotPCRecToPalm()));
+-			return;
+-		}
+-	}
+-
+-	// let subclasses do something with the record before we try to sync
+-	preRecord(r);
+-
+-//	DEBUGCONDUIT<<fname<<": Event: "<<e->dtStart()<<" until "<<e->dtEnd()<<endl;
+-//	DEBUGCONDUIT<<fname<<": Time: "<<e->dtStart()<<" until "<<e->dtEnd()<<endl;
+-	bool archiveRecord=(r->isArchived());
+-
+-	s = fLocalDatabase->readRecordById(r->id());
+-	if (!s || isFirstSync())
+-	{
+-#ifdef DEBUG
+-		if (r->id()>0 && !s)
+-		{
+-			DEBUGCONDUIT<<"---------------------------------------------------------------------------"<<endl;
+-			DEBUGCONDUIT<< fname<<": Could not read palm record with ID "<<r->id()<<endl;
+-		}
+-#endif
+-		if (!r->isDeleted() || (config()->syncArchived() && archiveRecord))
+-		{
+-			KCal::Incidence*e=addRecord(r);
+-			if (config()->syncArchived() && archiveRecord)  {
+-				e->setSyncStatus(KCal::Incidence::SYNCDEL);
+-			}
+-		}
+-	}
+-	else
+-	{
+-		if (r->isDeleted())
+-		{
+-			if (config()->syncArchived() && archiveRecord)
+-			{
+-				changeRecord(r,s);
+-			}
+-			else
+-			{
+-				deleteRecord(r,s);
+-			}
+-		}
+-		else
+-		{
+-			changeRecord(r,s);
+-		}
+-	}
+-
+-	KPILOT_DELETE(r);
+-	KPILOT_DELETE(s);
+-
+-	QTimer::singleShot(0,this,SLOT(slotPalmRecToPC()));
+-}
+-
+-
+-void VCalConduitBase::slotPCRecToPalm()
+-{
+-	FUNCTIONSETUP;
+-	KCal::Incidence*e=0L;
+-	if (isFullSync()) e=fP->getNextIncidence();
+-	else e=fP->getNextModifiedIncidence();
+-
+-	if (!e)
+-	{
+-		pilotindex=0;
+-		// if we are asked to copy HH to PC, we shouldn't look for deleted records
+-		// on the Palm, since we've just copied them all.  =:)  Otherwise, look for
+-		// data on the palm that shouldn't be there and delete it if we find it....
+-		if ( syncMode()==SyncMode::eCopyHHToPC )
+-		{
+-			QTimer::singleShot(0, this, SLOT(cleanup()));
+-		}
+-		else
+-		{
+-			QTimer::singleShot(0,this,SLOT(slotDeletedIncidence()));
+-		}
+-		return;
+-	}
+-
+-	// let subclasses do something with the event
+-	preIncidence(e);
+-
+-	// find the corresponding index on the palm and sync. If there is none, create it.
+-	recordid_t ix=e->pilotId();
+-#ifdef DEBUG
+-		DEBUGCONDUIT<<fname<<": found PC entry with pilotID "<<ix<<endl;
+-		DEBUGCONDUIT<<fname<<": Description: "<<e->summary()<<endl;
+-		DEBUGCONDUIT<<fname<<": Time: "<<e->dtStart().toString()<<" until "<<e->dtEnd().toString()<<endl;
+-#endif
+-	PilotRecord *s=0L;
+-	if (ix>0 && (s=fDatabase->readRecordById(ix)))
+-	{
+-		if (e->syncStatus()==KCal::Incidence::SYNCDEL)
+-		{
+-			deletePalmRecord(e, s);
+-		}
+-		else
+-		{
+-			changePalmRecord(e, s);
+-		}
+-		KPILOT_DELETE(s);
+-	} else {
+-#ifdef DEBUG
+-		if (ix>0)
+-		{
+-			DEBUGCONDUIT<<"---------------------------------------------------------------------------"<<endl;
+-			DEBUGCONDUIT<< fname<<": Could not read palm record with ID "<<ix<<endl;
+-		}
+-#endif
+-		addPalmRecord(e);
+-	}
+-	QTimer::singleShot(0, this, SLOT(slotPCRecToPalm()));
+-}
+-
+-
+-void VCalConduitBase::slotDeletedIncidence()
+-{
+-	FUNCTIONSETUP;
+-
+-	PilotRecord *r = fLocalDatabase->readRecordByIndex(pilotindex++);
+-	if (!r || (syncMode()==SyncMode::eCopyHHToPC) )
+-	{
+-		QTimer::singleShot(0 ,this,SLOT(cleanup()));
+-		return;
+-	}
+-
+-	KCal::Incidence *e = fP->findIncidence(r->id());
+-	if (!e)
+-	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT<<"didn't find incidence with id="<<r->id()<<", deleting it"<<endl;
+-#endif
+-		// entry was deleted from Calendar, so delete it from the palm
+-//		PilotRecord*s=fLocalDatabase->readRecordById(r->id());
+-//		if (s)
+-//		{
+-//			// delete the record from the palm
+-//			s->setDeleted();
+-////			s->setAttrib(s->getAttrib() & ~dlpRecAttrDeleted & ~dlpRecAttrDirty);
+-//			fDatabase->writeRecord(s);
+-//			KPILOT_DELETE(s);
+-//		}
+-		deletePalmRecord(NULL, r);
+-//		r->setDeleted();
+-////		r->setAttrib(r->getAttrib() & ~dlpRecAttrDeleted & ~dlpRecAttrDirty);
+-//		fLocalDatabase->writeRecord(r);
+-//		fDatabase->writeRecord(r);
+-	}
+-
+-	KPILOT_DELETE(r);
+-	QTimer::singleShot(0,this,SLOT(slotDeletedIncidence()));
+-}
+-
+-
+-void VCalConduitBase::cleanup()
+-{
+-	FUNCTIONSETUP;
+-	postSync();
+-
+-	if (fDatabase)
+-	{
+-		fDatabase->resetSyncFlags();
+-		fDatabase->cleanup();
+-	}
+-	if (fLocalDatabase)
+-	{
+-		fLocalDatabase->resetSyncFlags();
+-		fLocalDatabase->cleanup();
+-	}
+-	KPILOT_DELETE(fDatabase);
+-	KPILOT_DELETE(fLocalDatabase);
+-	if (fCalendar)
+-	{
+-		KURL kurl(config()->calendarFile());
+-		switch(config()->calendarType())
+-		{
+-			case VCalConduitSettings::eCalendarLocal:
+-				dynamic_cast<KCal::CalendarLocal*>(fCalendar)->save(fCalendarFile);
+-				if(!kurl.isLocalFile())
+-				{
+-					if(!KIO::NetAccess::upload(fCalendarFile, config()->calendarFile(), 0L)) {
+-						emit logError(i18n("An error occurred while uploading \"%1\". You can try to upload "
+-							"the temporary local file \"%2\" manually.")
+-							.arg(config()->calendarFile()).arg(fCalendarFile));
+-					}
+-					else {
+-						KIO::NetAccess::removeTempFile(fCalendarFile);
+-					}
+-					QFile backup(fCalendarFile + CSL1("~"));
+-					backup.remove();
+-				}
+-				break;
+-			case VCalConduitSettings::eCalendarResource:
+-				fCalendar->save();
+-				break;
+-			default:
+-				break;
+-		}
+-		fCalendar->close();
+-	}
+-	KPILOT_DELETE(fCalendar);
+-	KPILOT_DELETE(fP);
+-
+-	emit syncDone(this);
+-}
+-
+-
+-
+-void VCalConduitBase::postSync()
+-{
+-	FUNCTIONSETUP;
+-}
+-
+-
+-KCal::Incidence* VCalConduitBase::addRecord(PilotRecord *r)
++KCal::Incidence* VCalConduitBase::addRecord( PilotRecord *r )
+ {
+ 	FUNCTIONSETUP;
+ 
+-	recordid_t id=fLocalDatabase->writeRecord(r);
++	recordid_t id = fLocalDatabase->writeRecord( r );
+ #ifdef DEBUG
+-	DEBUGCONDUIT<<fname<<": Pilot Record ID="<<r->id()<<", backup ID="<<id<<endl;
++	DEBUGCONDUIT<<fname<<": Pilot Record ID = " << r->id() << ", backup ID = "
++		<< id << endl;
+ #else
+ 	Q_UNUSED(id);
+ #endif
+ 
+-	PilotAppCategory *de=newPilotEntry(r);
+-	KCal::Incidence*e =0L;
++	PilotRecordBase *de = newPilotEntry( r );
++	KCal::Incidence*e = 0L;
+ 
+-	if (de)
++	if ( de )
+ 	{
+-		e=fP->findIncidence(r->id());
+-		if (!e)
++		e = fP->findIncidence( r->id() );
++		if ( !e )
+ 		{
+ 			// no corresponding entry found, so create, copy and insert it.
+-			e=newIncidence();
+-			incidenceFromRecord(e,de);
+-			fP->addIncidence(e);
++			e = newIncidence();
++			incidenceFromRecord( e, de );
++			fP->addIncidence( e );
+ 		}
+ 		else
+ 		{
+ 			// similar entry found, so just copy, no need to insert again
+-			incidenceFromRecord(e,de);
++			incidenceFromRecord( e, de );
+ 		}
+ 	}
+-	KPILOT_DELETE(de);
++	KPILOT_DELETE( de );
+ 	return e;
+ }
+ 
+-// return how to resolve conflicts. for now PalmOverrides=0=false, PCOverrides=1=true, Ask=2-> ask the user using a messagebox
+-int VCalConduitBase::resolveConflict(KCal::Incidence*e, PilotAppCategory*de) {
+-	if (getConflictResolution()==SyncAction::eAskUser)
++int VCalConduitBase::resolveConflict( KCal::Incidence *e, PilotRecordBase *de ) {
++	if ( getConflictResolution() == SyncAction::eAskUser )
+ 	{
+ 		// TODO: This is messed up!!!
+-		QString query = i18n("The following item was modified "
+-			"both on the Handheld and on your PC:\nPC entry:\n\t");
++		QString query = i18n( "The following item was modified "
++			"both on the Handheld and on your PC:\nPC entry:\n\t" );
+ 		query += e->summary();
+-		query += i18n("\nHandheld entry:\n\t");
+-		query += getTitle(de);
+-		query += i18n("\n\nWhich entry do you want to keep? It will "
+-			"overwrite the other entry.");
++		query += i18n( "\nHandheld entry:\n\t" );
++		query += getTitle( de );
++		query += i18n( "\n\nWhich entry do you want to keep? It will "
++			"overwrite the other entry." );
+ 
+ 		return KMessageBox::No == questionYesNo(
+ 			query,
+-			i18n("Conflicting Entries"),
++			i18n( "Conflicting Entries" ),
+ 			QString::null,
+ 			0 /* Never timeout */,
+-			i18n("Handheld"), i18n("PC"));
++			i18n( "Handheld" ), i18n( "PC" ));
+ 	}
+ 	return getConflictResolution();
+ }
+@@ -681,41 +448,43 @@ KCal::Incidence*VCalConduitBase::changeR
+ {
+ 	FUNCTIONSETUP;
+ 
+-	PilotAppCategory*de=newPilotEntry(r);
+-	KCal::Incidence *e = fP->findIncidence(r->id());
+-#ifdef DEBUG
+-	DEBUGCONDUIT<<fname<<": Pilot Record ID: ["<<r->id() << "]" <<endl;
+-#endif
++	PilotRecordBase *de = newPilotEntry( r );
++	KCal::Incidence *e = fP->findIncidence( r->id() );
++
++	DEBUGCONDUIT << fname << ": Pilot Record ID: [" << r->id() << "]" << endl;
+ 
+-	if (e && de)
++	if ( e && de )
+ 	{
+ 		// TODO: check for conflict, and if there is one, ask for resolution
+-		if ( (e->syncStatus()!=KCal::Incidence::SYNCNONE) && (r->isDirty() ) )
++		if ( ( e->syncStatus() != KCal::Incidence::SYNCNONE )
++			&& r->isModified() )
+ 		{
+ 			// TODO: I have not yet found a way to complete ignore an item
+-			if (resolveConflict(e, de))
++			if (resolveConflict( e, de ) )
+ 			{
+ 				// PC record takes precedence:
+-				KPILOT_DELETE(de);
++				KPILOT_DELETE( de );
+ 				return e;
+ 			}
+ 		}
+ 		// no conflict or conflict resolution says, Palm overwrites, so do it:
+-		incidenceFromRecord(e,de);
+-		e->setSyncStatus(KCal::Incidence::SYNCNONE);
+-		fLocalDatabase->writeRecord(r);
++		incidenceFromRecord( e, de );
++		e->setSyncStatus( KCal::Incidence::SYNCNONE );
++		fLocalDatabase->writeRecord( r );
+ 	}
+ 	else
+ 	{
+-		kdWarning() << k_funcinfo << ": While changing record -- not found in iCalendar" << endl;
+-		addRecord(r);
++		kdWarning() << k_funcinfo
++			<< ": While changing record -- not found in iCalendar" << endl;
++		addRecord( r );
+ 	}
+-	KPILOT_DELETE(de);
++
++	KPILOT_DELETE( de );
+ 	return e;
+ }
+ 
+ 
+-KCal::Incidence*VCalConduitBase::deleteRecord(PilotRecord *r, PilotRecord *)
++KCal::Incidence*VCalConduitBase::deleteRecord( PilotRecord *r, PilotRecord * )
+ {
+ 	FUNCTIONSETUP;
+ 
+@@ -725,84 +494,80 @@ KCal::Incidence*VCalConduitBase::deleteR
+ 		// RemoveEvent also takes it out of the calendar.
+ 		fP->removeIncidence(e);
+ 	}
+-	fLocalDatabase->writeRecord(r);
++	fLocalDatabase->writeRecord( r );
+ 	return NULL;
+ }
+ 
+ 
+-void VCalConduitBase::addPalmRecord(KCal::Incidence*e)
++void VCalConduitBase::addPalmRecord( KCal::Incidence *e )
+ {
+ 	FUNCTIONSETUP;
+ 
+-	PilotAppCategory*de=newPilotEntry(NULL);
+-	updateIncidenceOnPalm(e, de);
+-	KPILOT_DELETE(de);
++	PilotRecordBase *de = newPilotEntry( 0L );
++	updateIncidenceOnPalm( e, de );
++	KPILOT_DELETE( de );
+ }
+ 
+ 
+ void VCalConduitBase::changePalmRecord(KCal::Incidence*e, PilotRecord*s)
+ {
+-	PilotAppCategory*de=newPilotEntry(s);
+-	updateIncidenceOnPalm(e, de);
+-	KPILOT_DELETE(de);
++	PilotRecordBase *de = newPilotEntry( s );
++	updateIncidenceOnPalm( e, de );
++	KPILOT_DELETE( de );
+ }
+ 
+ 
+-void VCalConduitBase::deletePalmRecord(KCal::Incidence*e, PilotRecord*s)
++void VCalConduitBase::deletePalmRecord( KCal::Incidence *e, PilotRecord *s )
+ {
+ 	FUNCTIONSETUP;
+-	if (s)
++	if ( s )
+ 	{
+-#ifdef DEBUG
+ 		DEBUGCONDUIT << fname << ": deleting record " << s->id() << endl;
+-#endif
+ 		s->setDeleted();
+-		fDatabase->writeRecord(s);
+-		fLocalDatabase->writeRecord(s);
++		fDatabase->writeRecord( s );
++		fLocalDatabase->writeRecord( s );
+ 	}
+ 	else
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": could not find record to delete (" << e->pilotId() << ")" << endl;
+-#endif
++		DEBUGCONDUIT << fname << ": could not find record to delete (";
++		DEBUGCONDUIT << e->pilotId() << ")" << endl;
+ 	}
+ 
+ 	Q_UNUSED(e);
+ }
+ 
+-
+ /* I have to use a pointer to an existing PilotDateEntry so that I can handle
+    new records as well (and to prevent some crashes concerning the validity
+    domain of the PilotRecord*r). In syncEvent this PilotDateEntry is created. */
+-void VCalConduitBase::updateIncidenceOnPalm(KCal::Incidence*e, PilotAppCategory*de)
++void VCalConduitBase::updateIncidenceOnPalm( KCal::Incidence *e,
++	PilotRecordBase *de )
+ {
+ 	FUNCTIONSETUP;
+-	if (!de || !e ) {
+-#ifdef DEBUG
+-		DEBUGCONDUIT<<fname<<": NULL event given... Skipping it"<<endl;
+-#endif
++	if ( !de || !e ) {
++		DEBUGCONDUIT << fname << ": NULL event given... Skipping it" << endl;
+ 		return;
+ 	}
+-	if (e->syncStatus()==KCal::Incidence::SYNCDEL)
++
++	if ( e->syncStatus() == KCal::Incidence::SYNCDEL )
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT<<fname<<": don't write deleted incidence "<<e->summary()<<" to the palm"<<endl;
+-#endif
++		DEBUGCONDUIT << fname << ": don't write deleted incidence "
++			<< e->summary() << " to the palm" << endl;
+ 		return;
+ 	}
+-	PilotRecord*r=recordFromIncidence(de, e);
++
++	PilotRecord *r = recordFromIncidence( de, e );
+ 
+ 	// TODO: Check for conflict!
+-	if (r)
++	if ( r )
+ 	{
+ 		recordid_t id=fDatabase->writeRecord(r);
+ 		r->setID(id);
+ //		r->setAttrib(r->getAttrib() & ~dlpRecAttrDeleted);
+-		fLocalDatabase->writeRecord(r);
++		fLocalDatabase->writeRecord( r );
+ //		fDatabase->writeRecord(r);
+-		e->setPilotId(id);
+-		e->setSyncStatus(KCal::Incidence::SYNCNONE);
+-		KPILOT_DELETE(r);
++		e->setPilotId( id );
++		e->setSyncStatus( KCal::Incidence::SYNCNONE );
++		KPILOT_DELETE( r );
+ 	}
+ }
+ 
+@@ -811,4 +576,25 @@ const QString VCalConduitBase::dbname()
+     return QString::null;
+ }
+ 
++PilotRecord *VCalConduitBase::readRecordByIndex( int index )
++{
++	FUNCTIONSETUP;
++	return fDatabase->readRecordByIndex( index );
++}
++
++KCal::Incidence *VCalConduitBase::incidenceFromRecord( PilotRecord *r )
++{
++	FUNCTIONSETUP;
++	PilotRecordBase *pac = newPilotEntry( r );
++	KCal::Incidence *i = newIncidence();
++	incidenceFromRecord( i, pac );
++
++	KPILOT_DELETE( pac );
++	return i;
++}
+ 
++void VCalConduitBase::setState( ConduitState *s )
++{
++	KPILOT_DELETE( fState );
++	fState = s;
++};
+diff -pruN kpilot/conduits/vcalconduit/vcal-conduitbase.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduitbase.h
+--- kpilot/conduits/vcalconduit/vcal-conduitbase.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduitbase.h	2006-11-26 23:53:25.000000000 +0100
+@@ -29,8 +29,13 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include <plugin.h>
+ 
++#include <qstring.h>
++
++#include <libkcal/calendarlocal.h>
++
++#include <plugin.h>
++#include <pilotRecord.h>
+ 
+ namespace KCal
+ {
+@@ -38,12 +43,11 @@ class Calendar;
+ class Incidence;
+ }
+ 
+-class PilotRecord;
+ class PilotSerialDatabase;
+ class PilotLocalDatabase;
+-class PilotAppCategory;
+ class VCalConduitSettings;
+ 
++class ConduitState;
+ 
+ class VCalConduitPrivateBase
+ {
+@@ -51,95 +55,148 @@ protected:
+ 	bool reading;
+ 	KCal::Calendar *fCalendar;
+ public:
+-	VCalConduitPrivateBase(KCal::Calendar *buddy):fCalendar(buddy) { reading=false;};
+-
+-	virtual int updateIncidences()=0;
+-	virtual void addIncidence(KCal::Incidence*)=0;
+-	virtual void removeIncidence(KCal::Incidence *)=0;
+-	virtual KCal::Incidence *findIncidence(recordid_t)=0;
+-	virtual KCal::Incidence *findIncidence(PilotAppCategory*tosearch)=0;
+-	virtual KCal::Incidence *getNextIncidence()=0;
+-	virtual KCal::Incidence *getNextModifiedIncidence()=0;
++	VCalConduitPrivateBase(KCal::Calendar *buddy) : fCalendar(buddy)
++	{
++		reading = false;
++	};
++
++	virtual ~VCalConduitPrivateBase() { } ;
++
++	virtual int updateIncidences() = 0;
++	virtual void addIncidence(KCal::Incidence*) = 0;
++	virtual void removeIncidence(KCal::Incidence*) = 0;
++	virtual KCal::Incidence *findIncidence(recordid_t) = 0;
++	virtual KCal::Incidence *findIncidence(PilotRecordBase *tosearch) = 0;
++	virtual KCal::Incidence *getNextIncidence() = 0;
++	virtual KCal::Incidence *getNextModifiedIncidence() = 0;
+ 	virtual int count()=0;
+ } ;
+ 
+-
+-
+ class VCalConduitBase : public ConduitAction
+ {
+         Q_OBJECT
+ public:
+-	VCalConduitBase(KPilotDeviceLink *,
+-		const char *name=0L,
++	VCalConduitBase(KPilotLink *,
++		const char *name = 0L,
+ 		const QStringList &args = QStringList());
+ 	virtual ~VCalConduitBase();
+ 
++/*********************************************************************
++                D A T A   M E M B E R S ,   S E T T I N G S
++ *********************************************************************/
+ protected:
++	KCal::Calendar *fCalendar;
++	QString fCalendarFile;
++	VCalConduitPrivateBase *fP;
++	ConduitState *fState;
++	bool hasNextRecord;
++
++	virtual const QString dbname() = 0;
++	virtual const QString getTitle(PilotRecordBase *de) = 0;
++	virtual void readConfig();
++
+ 	virtual bool exec();
+ 
+ protected slots:
+ 	/**
+-	* This function is called to sync modified records from the Pilot to KOrganizer.
+-	*/
+-	void slotPalmRecToPC();
+-	/**
+-	* This function goes the other way around: KOrganizer -> Pilot.
+-	*/
+-	void slotPCRecToPalm();
+-	void slotDeletedIncidence();
+-	void cleanup();
+-
+-
+-protected:
+-
+-	virtual int resolveConflict(KCal::Incidence*e, PilotAppCategory*de);
+-
+-	// add, change or delete events from the calendar
+-	virtual KCal::Incidence* addRecord(PilotRecord *);
+-	virtual KCal::Incidence* changeRecord(PilotRecord *,PilotRecord *);
+-	virtual KCal::Incidence* deleteRecord(PilotRecord *,PilotRecord *);
++	 * This slot is used to execute the actions applicable to this conduit. What
++	 * happens in this method is defined by the state the conduit has at the
++	 * moment that this method is called. For more information about the actions
++	 * that are executed, look at the classes that are implementing ConduitState.
++	 */
++	void slotProcess();
+ 
+-	// add, change or delete records from the palm
+-	virtual void addPalmRecord(KCal::Incidence*e);
+-	virtual void changePalmRecord(KCal::Incidence*e, PilotRecord*s);
+-	virtual void deletePalmRecord(KCal::Incidence*e, PilotRecord*s);
+-
+-	virtual void updateIncidenceOnPalm(KCal::Incidence*e, PilotAppCategory*de);
+-
+-	virtual void readConfig();
+-	virtual bool openCalendar();
++public:
++	// Maybe it's better to make this methods public in ConduitAction. They need
++	// to be public so that the state classes can access them.
++	const SyncMode &syncMode() const { return ConduitAction::syncMode(); };
++	bool isFullSync() const { return ConduitAction::isFullSync(); };
++	bool isFirstSync() const { return ConduitAction::isFirstSync(); };
+ 
+-	// THESE NEED TO BE IMPLEMENTED BY CHILD CLASSES!!!!
++	/**
++	 * Method used by state classes to indicatie if there are more records to
++	 * deal with.
++	 */
++	void setHasNextRecord( bool b) { hasNextRecord = b; };
+ 
+-	// create events from Palm records or vice versa
+-	virtual PilotRecord*recordFromIncidence(PilotAppCategory*de, const KCal::Incidence*e)=0;
+-	virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *e, const PilotAppCategory *de)=0;
++	/**
++	 * Change the current state of the conduit. The state that the conduit has
++	 * at the moment of the call will be deleted. The last state *must* set the
++	 * state to 0L when finished.
++	 */
++	void setState( ConduitState *s );
+ 
+-	virtual PilotAppCategory*newPilotEntry(PilotRecord*r)=0;
+-	virtual KCal::Incidence*newIncidence()=0;
++	/**
++	 * Returns the privatebase, that is used to for accessing the local calendar.
++	 */
++	VCalConduitPrivateBase *privateBase() const { return fP; };
+ 
++	/**
++	 * Returns the record at index from the palm or 0L if there is no record at
++	 * index.
++	 */
++	PilotRecord *readRecordByIndex( int index );
+ 
+-	// general settings, implemented by child classes for the conduits
+-	virtual const QString dbname() = 0;
++	/**
++	 * Returns a KCal::Incidence constructed from PilotRecord r. If r is 0L the
++	 * it will return a KCal::Incidence that is empty.
++	 */
++	KCal::Incidence *incidenceFromRecord( PilotRecord *r );
++
++	virtual void preIncidence( KCal::Incidence* ) {};
++
++	// Getters
++	KCal::Calendar *calendar() const { return fCalendar; };
++	QString calendarFile() const { return fCalendarFile; };
++
++	virtual VCalConduitSettings *config() = 0;
++	virtual PilotDatabase *database() const { return fDatabase; };
++	virtual PilotDatabase *localDatabase() const { return fLocalDatabase; };
+ 
+-	virtual const QString getTitle(PilotAppCategory*de)=0;
++	// add, change or delete records from the palm
++	virtual void addPalmRecord( KCal::Incidence *e );
++	virtual void changePalmRecord( KCal::Incidence *e, PilotRecord *s );
++	virtual void deletePalmRecord( KCal::Incidence *e, PilotRecord *s );
+ 
+-	// THESE *CAN* BE IMPLEMTED BY CHILD CLASSES
+-	// execute something at the beginning or end of the sync.
+-	virtual void preSync(){};
+-	virtual void postSync();
+-	virtual void preRecord(PilotRecord*){};
+-	virtual void preIncidence(KCal::Incidence *){};
++	// add, change or delete events from the calendar
++	virtual KCal::Incidence* changeRecord( PilotRecord*, PilotRecord* );
++	virtual KCal::Incidence* deleteRecord( PilotRecord*, PilotRecord* );
++	virtual KCal::Incidence* addRecord( PilotRecord * );
++
++/*********************************************************************
++          P R E -   A N D   P O S T S Y N C   F U N C T I O N S
++ *********************************************************************/
++	virtual void preSync() {};
++	virtual void postSync() {};
++	virtual void preRecord(PilotRecord*) {};
+ 
+ protected:
+-	KCal::Calendar *fCalendar;
+-	int pilotindex;
+-	QString fCalendarFile;
++	virtual void updateIncidenceOnPalm(KCal::Incidence *e, PilotRecordBase *de);
+ 
+-protected:
+-	virtual VCalConduitSettings *config()=0;
+-	VCalConduitPrivateBase*fP;
+-	virtual VCalConduitPrivateBase* newVCalPrivate(KCal::Calendar *fCalendar)=0;
++/*********************************************************************
++                 	S Y N C   F U N C T I O N S
++               for creating events from Palm records or vice versa
++ *********************************************************************/
++	virtual PilotRecord *recordFromIncidence(PilotRecordBase *de,
++		const KCal::Incidence *e) = 0;
++	virtual PilotRecordBase *newPilotEntry(PilotRecord *r) = 0;
++
++	virtual KCal::Incidence *newIncidence() = 0;
++	virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *e,
++		const PilotRecordBase *de) = 0;
++
++/*********************************************************************
++                M I S C   F U N C T I O N S
++ *********************************************************************/
++	/**
++     * Return how to resolve conflicts. For now
++	 * PalmOverrides=0=false,
++	 * PCOverrides=1=true,
++	 * Ask=2-> ask the user using a messagebox
++	 */
++	virtual int resolveConflict(KCal::Incidence *e, PilotRecordBase *de);
++	virtual bool openCalendar();
++	virtual VCalConduitPrivateBase *newVCalPrivate(KCal::Calendar *fCalendar) = 0;
+ } ;
+ 
+ #endif
+diff -pruN kpilot/conduits/vcalconduit/vcal-conduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduit.cc
+--- kpilot/conduits/vcalconduit/vcal-conduit.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,20 +28,24 @@
+ */
+ 
+ #include "options.h"
+-#include <qtextcodec.h>
+ #include <libkcal/calendar.h>
+ #include <libkcal/recurrence.h>
++
+ #define Recurrence_t KCal::Recurrence
+ #include <pilotDateEntry.h>
+ #include <pilotDatabase.h>
++
+ #include "vcal-conduit.moc"
+-#include "vcal-factory.h"
++#include "vcalconduitSettings.h"
++
++// Include for testpurposes
++#include <libkcal/calendarlocal.h>
++#include <libkcal/vcalformat.h>
+ 
+ extern "C"
+ {
+ 
+-long version_conduit_vcal = KPILOT_PLUGIN_API;
+-const char *id_conduit_vcal = "$Id: vcal-conduit.cc 450417 2005-08-18 06:07:11Z vanrijn $";
++unsigned long version_conduit_vcal = Pilot::PLUGIN_API;
+ 
+ }
+ 
+@@ -76,6 +80,10 @@ void VCalConduitPrivate::removeIncidence
+ 	fAllEvents.remove(dynamic_cast<KCal::Event*>(e));
+ 	if (!fCalendar) return;
+ 	fCalendar->deleteEvent(dynamic_cast<KCal::Event*>(e));
++	// now just in case we're in the middle of reading through our list
++	// and we delete something, set reading to false so we start at the
++	// top again next time and don't have problems with our iterator
++	reading = false;
+ }
+ 
+ 
+@@ -89,7 +97,7 @@ KCal::Incidence *VCalConduitPrivate::fin
+ 	return 0L;
+ }
+ 
+-KCal::Incidence *VCalConduitPrivate::findIncidence(PilotAppCategory*tosearch)
++KCal::Incidence *VCalConduitPrivate::findIncidence(PilotRecordBase *tosearch)
+ {
+ 	PilotDateEntry*entry=dynamic_cast<PilotDateEntry*>(tosearch);
+ 	if (!entry) return 0L;
+@@ -158,16 +166,12 @@ KCal::Incidence *VCalConduitPrivate::get
+  *                          VCalConduit class                               *
+  ****************************************************************************/
+ 
+-VCalConduit::VCalConduit(KPilotDeviceLink *d,
++VCalConduit::VCalConduit(KPilotLink *d,
+ 	const char *n,
+ 	const QStringList &a) : VCalConduitBase(d,n,a)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_conduit_vcal << endl;
+-#endif
+ 	fConduitName=i18n("Calendar");
+-	(void) id_conduit_vcal;
+ }
+ 
+ 
+@@ -185,8 +189,8 @@ void VCalConduit::_getAppInfo()
+ 	FUNCTIONSETUP;
+ 	// get the address application header information
+ 	unsigned char *buffer =
+-		new unsigned char[PilotRecord::APP_BUFFER_SIZE];
+-	int appLen = fDatabase->readAppBlock(buffer,PilotRecord::APP_BUFFER_SIZE);
++		new unsigned char[Pilot::MAX_APPINFO_SIZE];
++	int appLen = fDatabase->readAppBlock(buffer,Pilot::MAX_APPINFO_SIZE);
+ 
+ 	unpack_AppointmentAppInfo(&fAppointmentAppInfo, buffer, appLen);
+ 	delete[]buffer;
+@@ -206,7 +210,7 @@ void VCalConduit::_getAppInfo()
+ 
+ }
+ 
+-const QString VCalConduit::getTitle(PilotAppCategory*de)
++const QString VCalConduit::getTitle(PilotRecordBase *de)
+ {
+ 	PilotDateEntry*d=dynamic_cast<PilotDateEntry*>(de);
+ 	if (d) return QString(d->getDescription());
+@@ -215,7 +219,7 @@ const QString VCalConduit::getTitle(Pilo
+ 
+ 
+ 
+-PilotRecord*VCalConduit::recordFromIncidence(PilotAppCategory*de, const KCal::Incidence*e)
++PilotRecord*VCalConduit::recordFromIncidence(PilotRecordBase *de, const KCal::Incidence*e)
+ {
+ 	FUNCTIONSETUP;
+ 	if (!de || !e)
+@@ -247,13 +251,14 @@ PilotRecord*VCalConduit::recordFromIncid
+ 	setExceptions(de, e);
+ 	de->setDescription(e->summary());
+ 	de->setNote(e->description());
++	de->setLocation(e->location());
+ 	setCategory(de, e);
+ DEBUGCONDUIT<<"-------- "<<e->summary()<<endl;
+ 	return de->pack();
+ }
+ 
+ 
+-KCal::Incidence *VCalConduit::incidenceFromRecord(KCal::Incidence *e, const PilotAppCategory *de)
++KCal::Incidence *VCalConduit::incidenceFromRecord(KCal::Incidence *e, const PilotRecordBase  *de)
+ {
+ 	return dynamic_cast<KCal::Incidence*>(incidenceFromRecord(dynamic_cast<KCal::Event*>(e), dynamic_cast<const PilotDateEntry*>(de)));
+ }
+@@ -292,6 +297,7 @@ KCal::Event *VCalConduit::incidenceFromR
+ 		DEBUGCONDUIT<<fname<<": DESCRIPTION: "<<de->getDescription()<<"  ---------------------------------------------------"<<endl;
+ #endif
+ 	e->setDescription(de->getNote());
++	e->setLocation(de->getLocation());
+ 
+ 	// used by e.g. Agendus and Datebk
+ 	setCategory(e, de);
+@@ -744,14 +750,12 @@ void VCalConduit::setCategory(PilotDateE
+ 
+ QString VCalConduit::_getCat(const QStringList cats, const QString curr) const
+ {
+-	int j;
+ 	if (cats.size()<1) return QString::null;
+ 	if (cats.contains(curr)) return curr;
+ 	for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it ) {
+-		for (j=1; j<PILOT_CATEGORY_MAX; j++)
++		for (unsigned int j=1; j<Pilot::CATEGORY_COUNT; j++)
+ 		{
+-			QString catName = PilotAppCategory::codec()->
+-        toUnicode(fAppointmentAppInfo.category.name[j]);
++			QString catName = Pilot::fromPilot(fAppointmentAppInfo.category.name[j]);
+ 			if (!(*it).isEmpty() && !(*it).compare( catName ) )
+ 			{
+ 				return catName;
+@@ -759,7 +763,7 @@ QString VCalConduit::_getCat(const QStri
+ 		}
+ 	}
+ 	// If we have a free label, return the first possible cat
+-	QString lastName(QString::fromLatin1(fAppointmentAppInfo.category.name[PILOT_CATEGORY_MAX-1]));
++	QString lastName(QString::fromLatin1(fAppointmentAppInfo.category.name[Pilot::CATEGORY_COUNT-1]));
+ 	if (lastName.isEmpty()) return cats.first();
+ 	return QString::null;
+ }
+@@ -769,18 +773,18 @@ void VCalConduit::setCategory(KCal::Even
+ 	if (!e || !de) return;
+ 	QStringList cats=e->categories();
+ 	int cat=de->category();
+-	if (0<cat && cat<PILOT_CATEGORY_MAX)
++	if (0<cat && cat<Pilot::CATEGORY_COUNT)
+ 	{
+-		QString newcat=PilotAppCategory::codec()->toUnicode(fAppointmentAppInfo.category.name[cat]);
++		QString newcat=Pilot::fromPilot(fAppointmentAppInfo.category.name[cat]);
+ 		if (!cats.contains(newcat))
+ 		{
+ 			// if this event only has one category associated with it, then we can
+ 			// safely assume that what we should be doing here is changing it to match
+ 			// the palm.  if there's already more than one category in the event, however, we
+-			// won't cause data loss--we'll just append what the palm has to the 
++			// won't cause data loss--we'll just append what the palm has to the
+ 			// event's categories
+ 			if (cats.count() <=1) cats.clear();
+-			
++
+ 			cats.append( newcat );
+ 			e->setCategories(cats);
+ 		}
+@@ -788,17 +792,31 @@ void VCalConduit::setCategory(KCal::Even
+ }
+ 
+ 
+-PilotAppCategory*VCalConduit::newPilotEntry(PilotRecord*r)
++PilotRecordBase * VCalConduit::newPilotEntry(PilotRecord*r)
+ {
+ 	if (r) return new PilotDateEntry(fAppointmentAppInfo,r);
+ 	else return new PilotDateEntry(fAppointmentAppInfo);
+ }
+ 
+-KCal::Incidence*VCalConduit::newIncidence()
++KCal::Incidence* VCalConduit::newIncidence()
+ {
+   return new KCal::Event;
+ }
+ 
++static VCalConduitSettings *config_vcal = 0L;
++
++VCalConduitSettings *VCalConduit::theConfig() {
++	if (!config_vcal)
++	{
++		config_vcal = new VCalConduitSettings(CSL1("Calendar"));
++	}
++
++	return config_vcal;
++}
++
+ VCalConduitSettings *VCalConduit::config() {
+-  return VCalConduitFactory::config();
++	return theConfig();
+ }
++
++
++
+diff -pruN kpilot/conduits/vcalconduit/vcal-conduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduit.h
+--- kpilot/conduits/vcalconduit/vcal-conduit.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-conduit.h	2006-11-26 23:53:25.000000000 +0100
+@@ -52,9 +52,11 @@ public:
+ 	virtual void addIncidence(KCal::Incidence*);
+ 	virtual void removeIncidence(KCal::Incidence *);
+ 	virtual KCal::Incidence *findIncidence(recordid_t);
+-	/** Find the incidence based on tosearch's description and date information. Returns 0L if no incidence could be found.
++	/**
++	 * Find the incidence based on tosearch's description and date information.
++	 * Returns 0L if no incidence could be found.
+ 	 */
+-	virtual KCal::Incidence *findIncidence(PilotAppCategory*tosearch);
++	virtual KCal::Incidence *findIncidence(PilotRecordBase *tosearch);
+ 	virtual KCal::Incidence *getNextIncidence();
+ 	virtual KCal::Incidence *getNextModifiedIncidence();
+ 	virtual int count() {return fAllEvents.count();};
+@@ -66,7 +68,7 @@ class VCalConduit : public VCalConduitBa
+ {
+ Q_OBJECT
+ public:
+-	VCalConduit(KPilotDeviceLink *,
++	VCalConduit(KPilotLink *,
+ 		const char *name=0L,
+ 		const QStringList &args = QStringList());
+ 	virtual ~VCalConduit();
+@@ -81,18 +83,20 @@ protected:
+ 	void _setAppInfo();
+ 	QString _getCat(const QStringList cats, const QString curr) const;
+ 
+-	virtual PilotAppCategory*newPilotEntry(PilotRecord*r);
++	virtual PilotRecordBase *newPilotEntry(PilotRecord*r);
+ 	virtual KCal::Incidence*newIncidence();
+-	virtual const QString getTitle(PilotAppCategory*de);
++	virtual const QString getTitle(PilotRecordBase *de);
+ 	virtual VCalConduitSettings *config();
++public:
++	static VCalConduitSettings *theConfig();
+ 
+ protected:
+-	virtual PilotRecord *recordFromIncidence(PilotAppCategory*de, const KCal::Incidence*e);
++	virtual PilotRecord *recordFromIncidence(PilotRecordBase *de, const KCal::Incidence*e);
+ 	virtual PilotRecord *recordFromIncidence(PilotDateEntry*de, const KCal::Event*e);
+-	virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *, const PilotAppCategory *);
++	virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *,
++		const PilotRecordBase  *);
+ 	virtual KCal::Event *incidenceFromRecord(KCal::Event *, const PilotDateEntry *);
+ 
+-
+ 	void setStartEndTimes(KCal::Event *,const PilotDateEntry *);
+ 	void setAlarms(KCal::Event *,const PilotDateEntry *);
+ 	void setRecurrence(KCal::Event *,const PilotDateEntry *);
+@@ -106,7 +110,6 @@ protected:
+ 	void setCategory(PilotDateEntry *, const KCal::Event *);
+ 	void setCategory(KCal::Event *, const PilotDateEntry *);
+ 	struct AppointmentAppInfo fAppointmentAppInfo;
+-
+-} ;
++};
+ 
+ #endif
+diff -pruN kpilot/conduits/vcalconduit/vcal-factorybase.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factorybase.cc
+--- kpilot/conduits/vcalconduit/vcal-factorybase.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factorybase.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,41 +0,0 @@
+-/* vcal-factory.cc                      KPilot
+-**
+-** Copyright (C) 2002-2003 Reinhold Kainhofer
+-** Copyright (C) 2001 by Dan Pilone
+-**
+-** This file defines the factory for the vcal-conduit plugin.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 General Public License for more details.
+-**
+-** You should have received a copy of the GNU General Public License
+-** along with this program in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-#include <kaboutdata.h>
+-
+-#include "vcal-factorybase.moc"
+-#include "options.h"
+-
+-KAboutData *VCalConduitFactoryBase::fAbout = 0L;
+-
+-
+-VCalConduitFactoryBase::~VCalConduitFactoryBase()
+-{
+-	KPILOT_DELETE(fAbout);
+-}
+-
+diff -pruN kpilot/conduits/vcalconduit/vcal-factorybase.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factorybase.h
+--- kpilot/conduits/vcalconduit/vcal-factorybase.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factorybase.h	2006-11-19 22:21:12.000000000 +0100
+@@ -30,7 +30,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include <klibloader.h>
+ 
+ #define RES_PALMOVERRIDES 0
+ #define RES_PCOVERRIDES 1
+@@ -41,24 +40,5 @@
+ #define SYNC_FULL 2
+ #define SYNC_MAX SYNC_FULL
+ 
+-class KAboutData;
+-class VCalConduitSettings;
+-
+-class VCalConduitFactoryBase : public KLibFactory
+-{
+-  Q_OBJECT
+-
+-public:
+-	VCalConduitFactoryBase(QObject * p= 0L,const char * n= 0L):KLibFactory(p,n){};
+-	virtual ~VCalConduitFactoryBase();
+-	static KAboutData *about() { return fAbout; };
+-
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() )=0;
+-	static KAboutData *fAbout;
+-};
+ 
+ #endif
+diff -pruN kpilot/conduits/vcalconduit/vcal-factory.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factory.cc
+--- kpilot/conduits/vcalconduit/vcal-factory.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factory.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -31,120 +31,20 @@
+ 
+ #include <kaboutdata.h>
+ 
++#include "pluginfactory.h"
++
+ #include "vcal-setup.h"
+ #include "vcal-conduit.h"
+-#include "vcal-factory.moc"
+-#include "vcalconduitSettings.h"
+ 
+ extern "C"
+ {
+ 
+ void *init_conduit_vcal()
+ {
+-	return new VCalConduitFactory;
+-}
+-
+-}
+-
+-
+-VCalConduitSettings* VCalConduitFactory::fConfig=0L;
+-
+-VCalConduitFactory::VCalConduitFactory(QObject *p, const char *n) :
+-	VCalConduitFactoryBase(p,n)
+-{
+-	FUNCTIONSETUP;
+-
+-	fInstance = new KInstance("vcalconduit");
+-	fAbout = new KAboutData("vcalConduit",
+-		I18N_NOOP("VCal Conduit for KPilot"),
+-		KPILOT_VERSION,
+-		I18N_NOOP("Configures the VCal Conduit for KPilot"),
+-		KAboutData::License_GPL,
+-		"(C) 2001, Adriaan de Groot\n(C) 2002-2003, Reinhold Kainhofer");
+-	fAbout->addAuthor("Adriaan de Groot",
+-		I18N_NOOP("Maintainer"),
+-		"groot at kde.org",
+-		"http://www.cs.kun.nl/~adridg/kpilot");
+-	fAbout->addAuthor("Reinhold Kainhofer",
+-		I18N_NOOP("Maintainer"),
+-		"reinhold at kainhofer.com",
+-		"http://reinhold.kainhofer.com/Linux/");
+-	fAbout->addAuthor("Dan Pilone",
+-		I18N_NOOP("Original Author"));
+-	fAbout->addAuthor("Preston Brown",
+-		I18N_NOOP("Original Author"));
+-	fAbout->addAuthor("Herwin-Jan Steehouwer",
+-		I18N_NOOP("Original Author"));
+-	fAbout->addCredit("Cornelius Schumacher",
+-		I18N_NOOP("iCalendar port"));
+-	fAbout->addCredit("Philipp Hullmann",
+-		I18N_NOOP("Bugfixer"));
+-}
+-
+-VCalConduitFactory::~VCalConduitFactory()
+-{
+-	FUNCTIONSETUP;
+-
+-	KPILOT_DELETE(fInstance);
++	return new ConduitFactory<VCalWidgetSetup,VCalConduit>;
+ }
+ 
+-VCalConduitSettings* VCalConduitFactory::config()
+-{
+-	if (!fConfig) {
+-		fConfig = new VCalConduitSettings(CSL1("Calendar"));
+-		if (fConfig) fConfig->readConfig();
+-	}
+-	return fConfig;
+ }
+ 
+-/* virtual */ QObject *VCalConduitFactory::createObject( QObject *p,
+-	const char *n,
+-	const char *c,
+-	const QStringList &a)
+-{
+-	FUNCTIONSETUP;
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Creating object of class "
+-		<< c
+-		<< endl;
+-#endif
+-
+-	if (qstrcmp(c,"ConduitConfigBase")==0)
+-	{
+-		QWidget *w = dynamic_cast<QWidget *>(p);
+-
+-		if (w)
+-		{
+-			return new VCalWidgetSetup(w,n);
+-		}
+-		else
+-		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname
+-				<< ": Couldn't cast parent to widget."
+-				<< endl;
+-#endif
+-			return 0L;
+-		}
+-	}
+-	else
+-	if (qstrcmp(c,"SyncAction")==0)
+-	{
+-		KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
+-
+-		if (d)
+-		{
+-			return new VCalConduit(d,n,a);
+-		}
+-		else
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Couldn't cast to KPilotDeviceLink."
+-				<< endl;
+-		}
+-	}
+ 
+-	return 0L;
+-}
+diff -pruN kpilot/conduits/vcalconduit/vcal-factory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factory.h
+--- kpilot/conduits/vcalconduit/vcal-factory.h	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-factory.h	2006-11-19 22:21:12.000000000 +0100
+@@ -30,30 +30,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-#include "vcal-factorybase.h"
+-
+-class KInstance;
+-class KAboutData;
+-class VCalConduitSettings;
+-
+-class VCalConduitFactory : public VCalConduitFactoryBase
+-{
+-    Q_OBJECT
+-
+-public:
+-	VCalConduitFactory(QObject * = 0L,const char * = 0L);
+-	virtual ~VCalConduitFactory();
+-	static VCalConduitSettings*config();
+-	
+-protected:
+-	virtual QObject* createObject( QObject* parent = 0,
+-		const char* name = 0,
+-		const char* classname = "QObject",
+-		const QStringList &args = QStringList() );
+-private:
+-	KInstance *fInstance;
+-	static VCalConduitSettings*fConfig;
+-};
+ 
+ extern "C"
+ {
+diff -pruN kpilot/conduits/vcalconduit/vcal-setup.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-setup.cc
+--- kpilot/conduits/vcalconduit/vcal-setup.cc	2005-09-10 10:24:38.000000000 +0200
++++ kdepim-3.5.5+/kpilot/conduits/vcalconduit/vcal-setup.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -30,10 +30,10 @@
+ #include "options.h"
+ 
+ #include <qbuttongroup.h>
+-#include <klocale.h>
++#include <kaboutdata.h>
+ 
+ #include "korganizerConduit.h"
+-#include "vcal-factory.h"
++#include "vcal-conduit.h"
+ #include "vcal-setup.h"
+ 
+ #include "uiDialog.h"
+@@ -41,7 +41,32 @@
+ VCalWidgetSetup::VCalWidgetSetup(QWidget *w, const char *n) :
+ 	VCalWidgetSetupBase(w,n)
+ {
+-	UIDialog::addAboutPage(fConfigWidget->tabWidget, VCalConduitFactoryBase::about());
++	KAboutData *fAbout = new KAboutData("vcalConduit",
++		I18N_NOOP("VCal Conduit for KPilot"),
++		KPILOT_VERSION,
++		I18N_NOOP("Configures the VCal Conduit for KPilot"),
++		KAboutData::License_GPL,
++		"(C) 2001, Adriaan de Groot\n(C) 2002-2003, Reinhold Kainhofer");
++	fAbout->addAuthor("Adriaan de Groot",
++		I18N_NOOP("Maintainer"),
++		"groot at kde.org",
++		"http://www.kpilot.org/");
++	fAbout->addAuthor("Reinhold Kainhofer",
++		I18N_NOOP("Maintainer"),
++		"reinhold at kainhofer.com",
++		"http://reinhold.kainhofer.com/Linux/");
++	fAbout->addAuthor("Dan Pilone",
++		I18N_NOOP("Original Author"));
++	fAbout->addAuthor("Preston Brown",
++		I18N_NOOP("Original Author"));
++	fAbout->addAuthor("Herwin-Jan Steehouwer",
++		I18N_NOOP("Original Author"));
++	fAbout->addCredit("Cornelius Schumacher",
++		I18N_NOOP("iCalendar port"));
++	fAbout->addCredit("Philipp Hullmann",
++		I18N_NOOP("Bugfixer"));
++
++	UIDialog::addAboutPage(fConfigWidget->tabWidget, fAbout);
+ 	fConfigWidget->fSyncDestination->setTitle(i18n("Calendar Destination"));
+ 	fConduitName=i18n("Calendar");
+ 
+@@ -51,4 +76,4 @@ VCalWidgetSetup::VCalWidgetSetup(QWidget
+ {
+ 	return new VCalWidgetSetup(w,n);
+ }
+-VCalConduitSettings*VCalWidgetSetup::config() { return VCalConduitFactory::config(); }
++VCalConduitSettings*VCalWidgetSetup::config() { return VCalConduit::theConfig(); }
+diff -pruN kpilot/config.h.cmake /home/pusling/kpilot/kdepim-3.5.5+/kpilot/config.h.cmake
+--- kpilot/config.h.cmake	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/config.h.cmake	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,19 @@
++#cmakedefine HAVE_STDINT_H
++#cmakedefine HAVE_ALLOCA_H
++#cmakedefine HAVE_SYS_TIME_H
++#cmakedefine HAVE_SYS_STAT_H
++#cmakedefine HAVE_CFSETSPEED
++#cmakedefine HAVE_STRDUP
++#cmakedefine HAVE_SETENV
++#cmakedefine HAVE_UNSETENV
++#cmakedefine HAVE_USLEEP
++#cmakedefine HAVE_RANDOM
++#cmakedefine HAVE_PUTENV
++#cmakedefine HAVE_SETEUID
++#cmakedefine HAVE_MKSTEMPS
++#cmakedefine HAVE_MKSTEMP
++#cmakedefine HAVE_MKDTEMP
++#cmakedefine HAVE_REVOKE
++#cmakedefine HAVE_STRLCPY
++#cmakedefine HAVE_STRLCAT
++#cmakedefine HAVE_INET_ATON
+diff -pruN kpilot/configure /home/pusling/kpilot/kdepim-3.5.5+/kpilot/configure
+--- kpilot/configure	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/configure	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,120 @@
++#!/bin/sh
++
++# simple configure script for user-friendliness
++
++# file to put output into for cmake to read in...
++OUTFILE=$(dirname $0)/CMakeOptions.txt
++
++usage()
++{
++echo "
++
++Hi there.  You can use this script to configure parameters used by cmake.
++Currently, understood parameters are as follows:
++
++  --prefix=PREFIX         install architecture-independent files in PREFIX
++  --enable-debug=ARG      enables debug symbols (yes|no) default=no
++  --with-pilot-link=PATH  set prefix for pilot-link files [default=check]
++  --with-mal=PATH         set path for libmal files [default=check]
++
++More obscure options:
++
++  --with-pilot-link-includes=PATH set include directory for pilot-link
++  --with-pilot-link-lib=PATH      set full path to libpisock.so
++
++"
++}
++
++getvalue()
++{
++	KEY="$1"
++	# use dynamic variable...
++	eval VAL='$'$KEY
++
++	ECHO="$2"
++	
++	if test -n "$VAL"
++	then
++		CMAKE_FLAGS="${CMAKE_FLAGS}-D${KEY}=${VAL} "
++		if [ "$ECHO" = "y" ]
++		then
++			echo "$KEY=\"$VAL\""
++		fi
++	fi
++
++}
++
++outputvalues()
++{
++
++# only include what we're passed
++CMAKE_FLAGS=""
++
++getvalue CMAKE_INSTALL_PREFIX y
++getvalue CMAKE_BUILD_TYPE y
++getvalue PILOTLINK_BASE y
++getvalue MAL_BASE y
++getvalue PILOTLINK_INCLUDE_DIR y
++getvalue PILOTLINK_LIBRARY y
++
++echo "CMAKE_FLAGS=$CMAKE_FLAGS"
++}
++
++while test -n "$1"
++do
++	case "$1" in
++		--prefix=*)
++			CMAKE_INSTALL_PREFIX=$(echo $1 | cut -d "=" -f2)
++			;;
++		--enable-debug*)
++			T=$(echo $1 | cut -d "=" -f2 | tr '[A-Z]' '[a-z]')
++			if [ "$T" = "--enable-debug" ] || [ "$T" = "yes" ] || [ "$T" = "full" ]
++			then
++				_T="debug"
++			else
++				# um, what is the non-debug flag??
++				_T="normal"
++			fi
++			CMAKE_BUILD_TYPE=$_T
++			;;
++		--with-pilot-link-includes=*)
++			PILOTLINK_INCLUDE_DIR=$(echo $1 | cut -d = -f2)
++			;;
++		--with-pilot-link-lib=*)
++			PILOTLINK_LIBRARY=$(echo $1 | cut -d = -f2)
++			;;
++		--with-pilot-link=*)
++			PILOTLINK_BASE=$(echo $1 | cut -d "=" -f2)
++			;;
++		--with-mal=*)
++			MAL_BASE=$(echo $1 | cut -d "=" -f2)
++			;;
++		*)
++			usage
++			exit
++			;;
++	esac
++
++	shift
++
++done
++
++echo "
++Thanks.  Here are the values I will be using...
++
++$(outputvalues)
++
++To compile KPilot, now run GNU make, like so:
++"
++
++if uname -s | grep BSD > /dev/null 2>&1 ; then
++	echo "    gmake"
++else
++	echo "    make"
++fi
++echo ""
++
++outputvalues > $OUTFILE
++
++cp Makefile.cmake Makefile
++
+diff -pruN kpilot/configure.in.bot /home/pusling/kpilot/kdepim-3.5.5+/kpilot/configure.in.bot
+--- kpilot/configure.in.bot	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/configure.in.bot	2006-11-19 22:21:12.000000000 +0100
+@@ -1,14 +1,16 @@
+ if test "$HAVE_PISOCK" = "0" ; then
+ 	echo ""
+-	echo "You're missing the pisock library for kpilot."
++	echo "You're missing a compatible version of pilot-link for kpilot."
+ 	echo ""
+ 	all_tests=bad
+ else
+ 	if test "x$HAVE_BAD_PISOCK" = "xYES" ; then
+ 		echo ""
+-		echo "You have a version of pilot-link < 0.11.8."
+-		echo "This version is deprecated and KPilot will soon stop"
+-		echo "working with it."
++		echo "You have a version of pilot-link < 0.12.1."
++		echo "This version is old and is known to cause problems"
++		echo "with KPilot.  Please compile KPilot with "
++		echo "pilot-link version 0.12.1 or greater."
+ 		echo ""
++		all_tests=bad
+ 	fi
+ fi
+diff -pruN kpilot/configure.in.in /home/pusling/kpilot/kdepim-3.5.5+/kpilot/configure.in.in
+--- kpilot/configure.in.in	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/configure.in.in	2006-11-19 22:21:12.000000000 +0100
+@@ -129,15 +129,13 @@ if test "$HAVE_PISOCK" = "1" ; then
+ 	#include <pi-version.h>
+ 	int main()
+ 	{ if (PILOT_LINK_VERSION==0) {
+-	    if ((PILOT_LINK_MAJOR==9) && (PILOT_LINK_MINOR>=5)) return (0);
+-	    if ((PILOT_LINK_MAJOR==10) || (PILOT_LINK_MAJOR==11)) return (0);
+-	    if ((PILOT_LINK_MAJOR==12)) return(0);
++            if ((PILOT_LINK_MAJOR==12) && (PILOT_LINK_MINOR>=1)) return (0);
+ 	  }
+ 	  return (1);
+ 	}
+ 	]
+ 	,
+-	[AC_MSG_RESULT([pilot-link version >= 0.9.5 found])],
++	[AC_MSG_RESULT([pilot-link version >= 0.12.0 found])],
+ 	[AC_MSG_RESULT([Your version of pilot-link won't work with KPilot])]
+ 	HAVE_PISOCK="0"
+ 	,
+@@ -145,25 +143,6 @@ if test "$HAVE_PISOCK" = "1" ; then
+ 	HAVE_PISOCK="0"
+ 	])
+ fi
+-if test "$HAVE_PISOCK" = "1" ; then
+-	AC_MSG_CHECKING([deprecated pilot-link version])
+-	AC_TRY_RUN([
+-	#include <pi-version.h>
+-	int main()
+-	{ if (PILOT_LINK_VERSION==0) {
+-	    if ((PILOT_LINK_MAJOR<11)) return (0);
+-	    if ((PILOT_LINK_MAJOR==11) && (PILOT_LINK_MINOR<8)) return (0);
+-	  }
+-	  return (1);
+-	}
+-	]
+-	,
+-	[AC_MSG_RESULT([yes])
+-	HAVE_BAD_PISOCK=YES
+-	],
+-	[AC_MSG_RESULT([no])]
+-	)
+-fi
+ 
+ if test "x$with_pilot_link" = "xCHECK" ; then
+ 
+diff -pruN kpilot/Documentation/ConduitProgrammingTutorial/index.tex /home/pusling/kpilot/kdepim-3.5.5+/kpilot/Documentation/ConduitProgrammingTutorial/index.tex
+--- kpilot/Documentation/ConduitProgrammingTutorial/index.tex	2005-11-08 23:33:41.000000000 +0100
++++ kdepim-3.5.5+/kpilot/Documentation/ConduitProgrammingTutorial/index.tex	2006-11-19 22:21:12.000000000 +0100
+@@ -742,7 +742,7 @@ database to not dirty.
+ \item\code{virtual int resetDBIndex()} ... Resets next record index to beginning
+ \item\code{virtual int cleanup()} ... Purges all Archived/Deleted records 
+ from Palm Pilot database
+-\item\code{bool isDBOpen()} ... Returns false if the database could not be 
++\item\code{bool isOpen()} ... Returns false if the database could not be 
+ opened, e.g. no connection to the handheld or file could not be created.
+ \item\code{virtual QString dbPathName()} ... Returns some sensible human-readable 
+ identifier for the database. Serial databases get Pilot:, local databases 
+@@ -1322,14 +1322,14 @@ bool DOCConduit::doSync(docSyncInfo &sin
+   // instance which points either to a local database or a database on the handheld.
+   PilotDatabase *database = preSyncAction(sinfo);
+ 
+-  if (database && ( !database->isDBOpen() ) ) {
++  if (database && ( !database->isOpen() ) ) {
+     DEBUGCONDUIT<<"Database "<<sinfo.dbinfo.name<<" does not yet exist. Creating it:"<<endl;
+     if (!database->createDatabase(dbcreator(), dbtype()) ) {
+       DEBUGCONDUIT<<"Failed"<<endl;
+     }
+   }
+ 
+-  if (database && database->isDBOpen()) {
++  if (database && database->isOpen()) {
+     DOCConverter docconverter;
+     connect(&docconverter, SIGNAL(logError(const QString &)), SIGNAL(logError(const QString &)));
+     connect(&docconverter, SIGNAL(logMessage(const QString &)), SIGNAL(logMessage(const QString &)));
+@@ -1424,7 +1424,7 @@ bool DOCConduit::needsSync(docSyncInfo &
+ 
+     if (QFile::exists(sinfo.docfilename)) sinfo.fPCStatus=eStatNew;
+     else sinfo.fPCStatus=eStatDoesntExist;
+-    if (docdb && docdb->isDBOpen()) sinfo.fPalmStatus=eStatNew;
++    if (docdb && docdb->isOpen()) sinfo.fPalmStatus=eStatNew;
+     else sinfo.fPalmStatus=eStatDoesntExist;
+     KPILOT_DELETE(docdb);
+     
+@@ -1452,7 +1452,7 @@ bool DOCConduit::needsSync(docSyncInfo &
+   } else {
+     DEBUGCONDUIT<<"PC side has NOT changed!"<<endl;
+   }
+-  if (!docdb || !docdb->isDBOpen()) sinfo.fPalmStatus=eStatDeleted;
++  if (!docdb || !docdb->isOpen()) sinfo.fPalmStatus=eStatDeleted;
+   else {
+     PilotRecord *firstRec = docdb->readRecordByIndex(0);
+     PilotDOCHead docHeader(firstRec);
+diff -pruN kpilot/Documentation/HOWTO-CODE.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/Documentation/HOWTO-CODE.txt
+--- kpilot/Documentation/HOWTO-CODE.txt	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/Documentation/HOWTO-CODE.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -13,7 +13,7 @@ KPilot works, see HOWTO-CONDUIT.txt)
+ C++ Source Code
+ ===============
+ 
+-There are coding guidelines for KDE somewhere. I think they say 
++There are coding guidelines for KDE somewhere. I think they say
+ indent with 4 spaces, { on same line, } on separate line. I disagree,
+ so code I write -- and code I maintain -- slowly mutates to
+ 
+@@ -27,7 +27,7 @@ so code I write -- and code I maintain -
+ Whether or not anyone else follows is irrelevant, and I do try to
+ avoid gratuitous reformatting. Honest.
+ 
+-What I might do every now and then to get stuff "into shape" (and 
++What I might do every now and then to get stuff "into shape" (and
+ I'd really appreciate it if you did so too before sending me patches)
+ is the following horrible invocation of indent:
+ 
+@@ -72,16 +72,40 @@ unfortunately, kpilotOptions.h is _KPILO
+ because the filename and the class don't always match up and not
+ every file contains a class of interest.
+ 
+-[I'm going to try to wrap all the #includes with the right #ifndef
+-to reduce the number of includes (for the preprocessor) and speed
+-up compilation just a little bit.] -- This paragraph has become 
+-irrelevant since I found out that sensible C compilers (ie. gcc)
+-have support to handle multiple inclusion efficiently, without even
+-opening a header file more than once. It *does* mean that the #ifndef
+-needs to move to the top of the .h file, but that's no real problem.
+-
+ 
++DEBUG Output
++============
+ 
++There are macros defined in options.h (which every source file
++should include) that provide some uniform debugging output.
++These are:
++
++	* FUNCTIONSETUP - Use this at the beginning of every function
++	  (or those that are vaguely interesting). This will print out
++	  a call trace indicator when debugging is on. It also defines
++	  a local symbol fname for use with DEBUG* below.
++	* FUNCTIONSETUPL(level) - Use this at the beginning of a function.
++	  It is like FUNCTIONSETUP but only prints if the debug level
++	  is at least @p level. This avoids excessive debug output from
++	  common functions.
++
++For regular debugging output, use one of the three DEBUG* macros:
++
++	* DEBUGLIBRARY in code in lib/
++	* DEBUGKPILOT in code in kpilot/
++	* DEBUGCONDUIT in code in conduits/
++
++This sends the debug output to the appropriate debug area. A typical
++debug output stream looks like this:
++
++	DEBUGKPILOT << fname << ": "
++		<< actual debug info
++		<< endl;
++
++Here, DEBUGKPILOT depends on what bit of code is being debugged; fname
++is defined by FUNCTIONSETUP and takes care of proper indentation for
++the call trace, the colon is for consistency and the actual debug
++info can be whatever you want.
+ 
+ 	Adriaan de Groot
+ 	March 5th 2001
+diff -pruN kpilot/Documentation/merge-into-svn.sh /home/pusling/kpilot/kdepim-3.5.5+/kpilot/Documentation/merge-into-svn.sh
+--- kpilot/Documentation/merge-into-svn.sh	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/Documentation/merge-into-svn.sh	2006-11-28 06:07:17.000000000 +0100
+@@ -0,0 +1,165 @@
++#!/bin/bash
++COPYTO=$1
++
++if [ "x$COPYTO" = "x" ] || [ ! -d "$COPYTO" ]
++then
++  echo "$(basename $0) <directory to merge to>"
++  exit 1
++fi
++
++STARTDIR=$(pwd)
++
++COPYFILES=""
++DELFILES=""
++NEWFILES=""
++
++function isversioned {
++  F=$1
++  svn info $F 2>&1 | grep Checksum > /dev/null
++  rc=$?
++  if [ $rc -eq 0 ]
++  then
++    echo 1
++  else
++    echo 0
++  fi
++}
++
++function checkCopy {
++
++echo "[-] Checking for files that need to be copied to: [$COPYTO]..."
++echo "-----------------------------------------------------"
++
++# first pass is to copy all files we care about from current to destination
++for f in $(find . | egrep -vi \
++"aap|build-|\.svn|\.libs|Makefile$|Makefile.in|~$|\.la$")
++do
++if [ -f $f ]; then
++  F=$(printf "%-60s\n" $f)
++  C=$(sum -r $f)
++  O=$(sum -r $COPYTO/$f 2>/dev/null)
++  if [ "$C" = "$O" ] ; then
++    S="SAME"
++  elif [ ! -f $COPYTO/$f ]; then
++    S="NEW"
++  else
++    S="DIFF"
++  fi
++
++  if [ "$S" != "SAME" ]; then
++    echo "file: [$F], status: [$S]"
++    if [ "$S" = "DIFF" ]; then
++      COPY="y"
++    elif [ "$S" = "NEW" ] ; then
++      V=$(isversioned $f)
++      if [ "$V" -eq 0 ]; then
++        echo " - new file, but not versioned, so ignoring."
++	COPY="n"
++      elif [ "$V" -eq 1 ]; then
++        echo -n " - new file.  versioned. copy this one? (Y/N) -> "
++        read ANS
++        ANS=$(echo $ANS | tr '[A-Z]' '[a-z]')
++        if [ "$ANS" = "y" ]; then
++          COPY="y"
++	  NEWFILES="$NEWFILES $f"
++        else
++          COPY="n"
++        fi
++      fi
++    fi
++    if [ "$COPY" = "y" ]; then
++      echo "  - copying this file..."
++      COPYFILES="$COPYFILES $f"
++    else 
++      echo "  - not copying it..."
++    fi
++  fi
++fi
++done
++}
++
++function checkDelete {
++
++echo "[-] Checking for files that should be deleted from: [$COPYTO] ..."
++echo "-----------------------------------------------------"
++
++# now see if there's anything that was in dest, but is not in new and
++# remove it
++cd $COPYTO
++for f in $(find . | egrep -vi \
++"aap|build|.svn|.libs|Makefile|~$|lib/pilot-link|.la$|.deps|.moc$|.lo$|\.o$")
++do
++if [ -f $f ]; then
++  F=$(printf "%-60s\n" $f)
++  if [ ! -f $STARTDIR/$f ] ; then
++    V=$(isversioned $f)
++    if [ "$V" -eq 1 ]; then
++      echo -n " - file: [$F] looks like it's been deleted. should I remove it?  (Y/N) -> "
++      read ANS
++      ANS=$(echo $ANS | tr '[A-Z]' '[a-z]')
++      if [ "$ANS" = "y" ]; then
++        echo "  - okay, I'll remove this one..."
++        DELFILES="$DELFILES $f"
++      fi
++    fi
++  fi
++fi
++done
++}
++
++checkCopy
++checkDelete
++
++cd "$STARTDIR"
++
++echo "okay, here are the files that I'll copy:"
++for f in $(echo $COPYFILES)
++do
++  echo " - $f"
++done
++
++echo "and here are the files that I'll do an svn remove on:"
++for f in $(echo $DELFILES)
++do
++  echo " - $f"
++done
++
++echo "and here are the files that I'll do an svn add on:"
++for f in $(echo $NEWFILES)
++do
++  echo " - $f"
++done
++
++echo -n "Okay to proceed? (y/n) -> "
++read ANS
++ANS=$(echo $ANS | tr '[A-Z]' '[a-z]')
++if [ "$ANS" != "y" ]; then
++  echo "  - okay, stopping."
++  exit
++fi
++
++cd "$STARTDIR"
++
++echo "okay, copying..."
++for f in $(echo $COPYFILES)
++do
++  cp --parents -v "$f" "$COPYTO"
++done
++
++cd "$COPYTO"
++
++echo "doing svn remove..."
++for f in $(echo $DELFILES)
++do
++  echo " - $f"
++  svn remove "$f"
++done
++
++cd "$COPYTO"
++
++echo "doing svn add..."
++for f in $(echo $NEWFILES)
++do
++  echo " - $f"
++  svn add "$f"
++done
+diff -pruN kpilot/Documentation/patch-standalone /home/pusling/kpilot/kdepim-3.5.5+/kpilot/Documentation/patch-standalone
+--- kpilot/Documentation/patch-standalone	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/Documentation/patch-standalone	1970-01-01 01:00:00.000000000 +0100
+@@ -1,55 +0,0 @@
+-Index: conduits/vcalconduit/Makefile.am
+-===================================================================
+-RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/Makefile.am,v
+-retrieving revision 1.51
+-diff -u -3 -p -r1.51 Makefile.am
+---- conduits/vcalconduit/Makefile.am	9 Jan 2005 18:57:11 -0000	1.51
+-+++ conduits/vcalconduit/Makefile.am	23 Apr 2005 20:05:31 -0000
+-@@ -21,16 +21,14 @@ libvcalconduit_shared_la_SOURCES = vcalc
+- 	vcal-conduitbase.cc
+- 
+- conduit_vcal_la_SOURCES = vcal-conduit.cc vcal-factory.cc vcal-setup.cc
+--conduit_vcal_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+-+conduit_vcal_la_LDFLAGS = -module $(KDE_PLUGIN) -lkcal $(all_libraries)
+- conduit_vcal_la_LIBADD = ../../lib/libkpilot.la \
+--	../../../libkcal/libkcal.la \
+- 	libvcalconduit_shared.la
+- conduit_vcal_la_COMPILE_FIRST = vcalconduitSettings.h korganizerConduit.h
+- 
+- conduit_todo_la_SOURCES = todo-factory.cc todo-setup.cc todo-conduit.cc
+--conduit_todo_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+-+conduit_todo_la_LDFLAGS = -module $(KDE_PLUGIN) -lkcal $(all_libraries)
+- conduit_todo_la_LIBADD = ../../lib/libkpilot.la \
+--	../../../libkcal/libkcal.la \
+- 	libvcalconduit_shared.la
+- conduit_todo_la_COMPILE_FIRST = vcalconduitSettings.h korganizerConduit.h
+- 
+-Index: lib/options.h
+-===================================================================
+-RCS file: /home/kde/kdepim/kpilot/lib/options.h,v
+-retrieving revision 1.70
+-diff -u -3 -p -r1.70 options.h
+---- lib/options.h	10 Apr 2005 23:06:43 -0000	1.70
+-+++ lib/options.h	23 Apr 2005 20:05:31 -0000
+-@@ -62,7 +62,7 @@
+- // of to the KDE debugging facility (it does lose some niftiness then).
+- //
+- #ifndef DEBUG
+--// #define DEBUG			(1)
+-+#define DEBUG			(1)
+- #endif
+- // #define DEBUG_CERR			(1)
+- 
+-Index: lib/Makefile.am
+-===================================================================
+---- lib/Makefile.am	(revision 437137)
+-+++ lib/Makefile.am	(working copy)
+-@@ -25,7 +25,7 @@
+- 	recordConduit.cc
+- 
+- libkpilot_la_LDFLAGS = -no-undefined $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_EXTRA_RPATH) $(KDE_RPATH)
+--libkpilot_la_LIBADD = $(LIB_KDEUI) $(PISOCK_LIB) $(LIB_KABC) $(top_builddir)/libkcal/libkcal.la
+-+libkpilot_la_LIBADD = $(LIB_KDEUI) $(PISOCK_LIB) $(LIB_KABC) -lkcal
+- 
+- kpilotincludedir = $(includedir)/kpilot
+- kpilotinclude_HEADERS = kpilotlink.h uiDialog.h plugin.h syncAction.h \
+Binary files kpilot/Documentation/UML/vcal-classdiagram.xmi.tgz and /home/pusling/kpilot/kdepim-3.5.5+/kpilot/Documentation/UML/vcal-classdiagram.xmi.tgz differ
+diff -pruN kpilot/INSTALL /home/pusling/kpilot/kdepim-3.5.5+/kpilot/INSTALL
+--- kpilot/INSTALL	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/INSTALL	2006-11-26 23:53:25.000000000 +0100
+@@ -1,172 +1,46 @@
+ Basic Installation
+ ==================
+ 
+-   These are generic installation instructions.
+ 
+-   KPILOT IS NOT A SEPARATE PACKAGE. APPLY THESE INSTALL INSTRUCTIONS
+-   TO THE PACKAGE kdepim, WHICH SHOULD BE THE DIRECTORY ABOVE THE ONE
+-   CONTAINING KPILOT. YOU MAY make KPILOT BY ITSELF THOUGH, ONCE YOU
+-   HAVE CONFIGURED kdepim ACCORDING TO THE INSTRUCTIONS BELOW.
+-
+-   The `configure' shell script attempts to guess correct values for
+-various system-dependent variables used during compilation.  It uses
+-those values to create a `Makefile' in each directory of the package.
+-It may also create one or more `.h' files containing system-dependent
+-definitions.  Finally, it creates a shell script `config.status' that
+-you can run in the future to recreate the current configuration, a file
+-`config.cache' that saves the results of its tests to speed up
+-reconfiguring, and a file `config.log' containing compiler output
+-(useful mainly for debugging `configure').
+-
+-   If you need to do unusual things to compile the package, please try
+-to figure out how `configure' could check whether to do them, and mail
+-diffs or instructions to the address given in the `README' so they can
+-be considered for the next release.  If at some point `config.cache'
+-contains results you don't want to keep, you may remove or edit it.
+-
+-   The file `configure.in' is used to create `configure' by a program
+-called `autoconf'.  You only need `configure.in' if you want to change
+-it or regenerate `configure' using a newer version of `autoconf'.
+-
+-The simplest way to compile this package is:
+-
+-  1. `cd' to the directory containing the package's source code and type
+-     `./configure' to configure the package for your system.  If you're
+-     using `csh' on an old version of System V, you might need to type
+-     `sh ./configure' instead to prevent `csh' from trying to execute
+-     `configure' itself.
+-
+-     Running `configure' takes a while.  While running, it prints some
+-     messages telling which features it is checking for.
+-
+-  2. Type `make' to compile the package.
++KPilot uses the CMake build system which is the native build system
++for KDE4; for KDE3 applications like KPilot, CMake is also useable.
++You need CMake installed on your system to compile KPilot, but CMake
++is becoming more widespread now. You can get it from www.cmake.org .
+ 
+-  3. Type `make install' to install the programs and any data files and
+-     documentation.
+ 
+-  4. You can remove the program binaries and object files from the
+-     source code directory by typing `make clean'.  
++To compile KPilot, just run
+ 
+-Compilers and Options
+-=====================
++	make -f Makefile.cmake
+ 
+-   Some systems require unusual options for compilation or linking that
+-the `configure' script does not know about.  You can give `configure'
+-initial values for variables by setting them in the environment.  Using
+-a Bourne-compatible shell, you can do that on the command line like
+-this:
+-     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+-
+-Or on systems that have the `env' program, you can do it like this:
+-     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+-
+-Compiling For Multiple Architectures
+-====================================
+-
+-   You can compile the package for more than one kind of computer at the
+-same time, by placing the object files for each architecture in their
+-own directory.  To do this, you must use a version of `make' that
+-supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+-directory where you want the object files and executables to go and run
+-the `configure' script.  `configure' automatically checks for the
+-source code in the directory that `configure' is in and in `..'.
+-
+-   If you have to use a `make' that does not supports the `VPATH'
+-variable, you have to compile the package for one architecture at a time
+-in the source code directory.  After you have installed the package for
+-one architecture, use `make distclean' before reconfiguring for another
+-architecture.
++in the KPilot source directory (that is the one containing this
++INSTALL file). This will run CMake to generate the real Makefiles,
++then run make again to build the project in a build-* subdirectory.
++Once it is done, you can run
+ 
+-Installation Names
+-==================
++	make -f Makefile.cmake install
+ 
+-   By default, `make install' will install the package's files in
+-`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+-installation prefix other than `/usr/local' by giving `configure' the
+-option `--prefix=PATH'.
+-
+-   You can specify separate installation prefixes for
+-architecture-specific files and architecture-independent files.  If you
+-give `configure' the option `--exec-prefix=PATH', the package will use
+-PATH as the prefix for installing programs and libraries.
+-Documentation and other data files will still use the regular prefix.
+-
+-   If the package supports it, you can cause programs to be installed
+-with an extra prefix or suffix on their names by giving `configure' the
+-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+-
+-Optional Features
+-=================
+-
+-   Some packages pay attention to `--enable-FEATURE' options to
+-`configure', where FEATURE indicates an optional part of the package.
+-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+-is something like `gnu-as' or `x' (for the X Window System).  The
+-`README' should mention any `--enable-' and `--with-' options that the
+-package recognizes.
+-
+-   For packages that use the X Window System, `configure' can usually
+-find the X include and library files automatically, but if it doesn't,
+-you can use the `configure' options `--x-includes=DIR' and
+-`--x-libraries=DIR' to specify their locations.
+-
+-Specifying the System Type
+-==========================
+-
+-   There may be some features `configure' can not figure out
+-automatically, but needs to determine by the type of host the package
+-will run on.  Usually `configure' can figure that out, but if it prints
+-a message saying it can not guess the host type, give it the
+-`--host=TYPE' option.  TYPE can either be a short name for the system
+-type, such as `sun4', or a canonical name with three fields:
+-     CPU-COMPANY-SYSTEM
+-
+-See the file `config.sub' for the possible values of each field.  If
+-`config.sub' isn't included in this package, then this package doesn't
+-need to know the host type.
+-
+-   If you are building compiler tools for cross-compiling, you can also
+-use the `--target=TYPE' option to select the type of system they will
+-produce code for and the `--build=TYPE' option to select the type of
+-system on which you are compiling the package.
+-
+-Sharing Defaults
+-================
+-
+-   If you want to set default values for `configure' scripts to share,
+-you can create a site shell script called `config.site' that gives
+-default values for variables like `CC', `cache_file', and `prefix'.
+-`configure' looks for `PREFIX/share/config.site' if it exists, then
+-`PREFIX/etc/config.site' if it exists.  Or, you can set the
+-`CONFIG_SITE' environment variable to the location of the site script.
+-A warning: not all `configure' scripts look for a site script.
++to install KPilot in the KDE directory.
+ 
+-Operation Controls
+-==================
+ 
+-   `configure' recognizes the following options to control how it
+-operates.
+ 
+-`--cache-file=FILE'
+-     Use and save the results of the tests in FILE instead of
+-     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+-     debugging `configure'.
+-
+-`--help'
+-     Print a summary of the options to `configure', and exit.
+-
+-`--quiet'
+-`--silent'
+-`-q'
+-     Do not print messages saying which checks are being made.
+-
+-`--srcdir=DIR'
+-     Look for the package's source code in directory DIR.  Usually
+-     `configure' can determine that directory automatically.
+-
+-`--version'
+-     Print the version of Autoconf used to generate the `configure'
+-     script, and exit.
+ 
+-`configure' also accepts some other, not widely useful, options.
++Advanced Installation
++=====================
++
++In order to build KPilot somewhere else, or if the sources are on
++read-only media, use CMake directly instead of using the basic
++Makefile included with KPilot. To do this,
++	1) Create a build directory somewhere
++	2) cd into that build directory
++	3) Run cmake /path/to/kpilot/sources
++	4) Run make
++
++In order to install KPilot somewhere else, set PREFIX in the
++default Makefile, for instance like so:
++
++	make -f Makefile.cmake PREFIX=/usr/local/kpilot
++	make -f Makefile.cmake install PREFIX=/usr/local/kpilot
++
++If using CMake directly, use -DCMAKE_INSTALL_PREFIX .
++
+ 
+diff -pruN kpilot/kpilot/addressEditor.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/addressEditor.cc
+--- kpilot/kpilot/addressEditor.cc	2006-05-22 20:11:07.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/addressEditor.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -19,7 +19,7 @@
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ ** MA 02110-1301, USA.
+ */
+ 
+@@ -51,19 +51,17 @@
+ 
+ #include "addressEditor.moc"
+ 
+-static const char *addressEditor_id =
+-	"$Id: addressEditor.cc 529452 2006-04-13 14:05:00Z mueller $";
+ 
+ AddressEditor::AddressEditor(PilotAddress * p,
+-	struct AddressAppInfo *appInfo,
++	PilotAddressInfo *appInfo,
+ 	QWidget * parent,
+ 	const char *name) :
+ 	KDialogBase(KDialogBase::Plain,
+ 		i18n("Address Editor"),
+ 		Ok | Cancel, Cancel,
+ 		parent, name, false /* non-modal */ ),
+-	fDeleteOnCancel(p == 0L), 
+-	fAddress(p), 
++	fDeleteOnCancel(p == 0L),
++	fAddress(p),
+ 	fAppInfo(appInfo)
+ {
+ 	FUNCTIONSETUP;
+@@ -74,7 +72,6 @@ AddressEditor::AddressEditor(PilotAddres
+ 	connect(parent, SIGNAL(recordChanged(PilotAddress *)),
+ 		this, SLOT(updateRecord(PilotAddress *)));
+ 
+-	(void) addressEditor_id;
+ }
+ 
+ AddressEditor::~AddressEditor()
+@@ -116,7 +113,7 @@ QString AddressEditor::phoneLabelText(Pi
+ 
+ 	if (idx >= 0 && idx < 8)	// hard-coded, no constant in pi-address.h
+ 	{
+-		if ((s = fAppInfo->phoneLabels[idx]))
++		if ((s = fAppInfo->info()->phoneLabels[idx]))
+ 		{
+ 			ret = s;
+ 			ret += CSL1(":");
+@@ -134,7 +131,7 @@ void AddressEditor::fillFields()
+ 
+ 	if (fAddress == 0L)
+ 	{
+-		fAddress = new PilotAddress(*fAppInfo);
++		fAddress = new PilotAddress(fAppInfo);
+ 		fDeleteOnCancel = true;
+ 	}
+ 
+@@ -256,7 +253,6 @@ void AddressEditor::initLayout()
+ 	fAddress->setField(entryCustom4, fCustom4Field->text());
+ 
+ 	emit(recordChangeComplete(fAddress));
+-        fDeleteOnCancel = false;
+ 	KDialogBase::slotOk();
+ }
+ 
+diff -pruN kpilot/kpilot/addressEditor.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/addressEditor.h
+--- kpilot/kpilot/addressEditor.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/addressEditor.h	2006-11-19 22:21:12.000000000 +0100
+@@ -19,7 +19,7 @@
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ ** MA 02110-1301, USA.
+ */
+ 
+@@ -32,22 +32,23 @@
+ 
+ #include <kdialogbase.h>
+ 
++#include <pilotAddress.h>
++
+ class QLineEdit;
+ class PilotAddress;
+-struct AddressAppInfo;
+ 
+-class AddressEditor : public KDialogBase 
++class AddressEditor : public KDialogBase
+ {
+ 	Q_OBJECT
+ 
+ 
+ public:
+ 	AddressEditor(PilotAddress *address,
+-		struct AddressAppInfo *appInfo,
++		PilotAddressInfo *appInfo,
+ 		QWidget *parent, const char *name=0L);
+ 	~AddressEditor();
+ 
+- 
++
+ signals:
+ 	void recordChangeComplete ( PilotAddress* );
+ 
+@@ -60,7 +61,7 @@ private:
+ 	bool fDeleteOnCancel;
+ 
+ 	PilotAddress* fAddress;
+-	struct AddressAppInfo *fAppInfo;
++	PilotAddressInfo *fAppInfo;
+ 	// entry fields
+ 	QLineEdit *fCustom4Field;
+ 	QLineEdit *fCustom3Field;
+@@ -78,7 +79,7 @@ private:
+ 	QLineEdit *fLastNameField;
+ 	// phone labels (changing!)
+ 	QLabel    *m_phoneLabel[5];
+-	
++
+ 	void initLayout();
+ 	void fillFields();
+ 	QString phoneLabelText(PilotAddress *, int i);
+diff -pruN kpilot/kpilot/addressWidget.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/addressWidget.cc
+--- kpilot/kpilot/addressWidget.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/addressWidget.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,9 +28,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *addresswidget_id =
+-	"$Id: addressWidget.cc 450284 2005-08-17 20:49:09Z adridg $";
+-
+ 
+ 
+ #ifndef _KPILOT_OPTIONS_H
+@@ -79,9 +76,6 @@ AddressWidget::AddressWidget(QWidget * p
+ 
+ 	setupWidget();
+ 	fAddressList.setAutoDelete(true);
+-
+-	/* NOTREACHED */
+-	(void) addresswidget_id;
+ }
+ 
+ AddressWidget::~AddressWidget()
+@@ -146,7 +140,7 @@ void AddressWidget::showComponent()
+ 
+ 	fAddressList.clear();
+ 
+-	if (addressDB->isDBOpen())
++	if (addressDB->isOpen())
+ 	{
+ 		KPILOT_DELETE(fAddressAppInfo);
+ 		fAddressAppInfo = new PilotAddressInfo(addressDB);
+@@ -447,7 +441,7 @@ void AddressWidget::slotEditRecord()
+ 	}
+ 
+ 	AddressEditor *editor = new AddressEditor(selectedRecord,
+-		fAddressAppInfo->info(), this);
++		fAddressAppInfo, this);
+ 
+ 	connect(editor, SIGNAL(recordChangeComplete(PilotAddress *)),
+ 		this, SLOT(slotUpdateRecord(PilotAddress *)));
+@@ -470,7 +464,7 @@ void AddressWidget::slotCreateNewRecord(
+ 	//
+ 	PilotDatabase *myDB = new PilotLocalDatabase(dbPath(), CSL1("AddressDB"));
+ 
+-	if (!myDB || !myDB->isDBOpen())
++	if (!myDB || !myDB->isOpen())
+ 	{
+ #ifdef DEBUG
+ 		DEBUGKPILOT << fname
+@@ -480,7 +474,7 @@ void AddressWidget::slotCreateNewRecord(
+ 			<< " and got pointer @"
+ 			<< (long) myDB
+ 			<< " with status "
+-			<< ( myDB ? myDB->isDBOpen() : false )
++			<< ( myDB ? myDB->isOpen() : false )
+ 			<< endl;
+ #endif
+ 
+@@ -497,7 +491,7 @@ void AddressWidget::slotCreateNewRecord(
+ 	}
+ 
+ 	AddressEditor *editor = new AddressEditor(0L,
+-		fAddressAppInfo->info(), this);
++		fAddressAppInfo, this);
+ 
+ 	connect(editor, SIGNAL(recordChangeComplete(PilotAddress *)),
+ 		this, SLOT(slotAddRecord(PilotAddress *)));
+@@ -517,7 +511,7 @@ void AddressWidget::slotAddRecord(PilotA
+ 		fAddressAppInfo->categoryInfo(), true);
+ 
+ 
+-	address->PilotAppCategory::setCategory(currentCatID);
++	address->PilotRecordBase::setCategory(currentCatID);
+ 	fAddressList.append(address);
+ 	writeAddress(address);
+ 	// TODO: Just add the new record to the lists
+@@ -636,7 +630,7 @@ void AddressWidget::writeAddress(PilotAd
+ 	PilotDatabase *myDB = addressDB;
+ 	bool usemyDB = false;
+ 
+-	if (myDB == 0L || !myDB->isDBOpen())
++	if (myDB == 0L || !myDB->isOpen())
+ 	{
+ 		myDB = new PilotLocalDatabase(dbPath(), CSL1("AddressDB"));
+ 		usemyDB = true;
+@@ -645,7 +639,7 @@ void AddressWidget::writeAddress(PilotAd
+ 	// Still no valid address database...
+ 	//
+ 	//
+-	if (!myDB->isDBOpen())
++	if (!myDB->isOpen())
+ 	{
+ #ifdef DEBUG
+ 		DEBUGKPILOT << fname << ": Address database is not open" <<
+@@ -683,7 +677,7 @@ void AddressWidget::slotExport()
+ 
+ 	QString prompt = (currentCatID==-1) ?
+ 		i18n("Export All Addresses") :
+-		i18n("Export Address Category %1").arg(fAddressAppInfo->category(currentCatID)) ;
++		i18n("Export Address Category %1").arg(fAddressAppInfo->categoryName(currentCatID)) ;
+ 
+ 
+ 	QString saveFile = KFileDialog::getSaveFileName(
+diff -pruN kpilot/kpilot/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/CMakeLists.txt
+--- kpilot/kpilot/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/kpilot/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,167 @@
++link_directories(${CMAKE_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR})
++
++set(settings_SRC
++	kpilotConfig.cc
++)
++
++kde3_add_kcfg_files(settings_SRC kpilotSettings.kcfgc)
++
++set(shared_SRCS
++	${settings_SRC}
++	syncStack.cc
++	hotSync.cc
++	interactiveSync.cc
++	logWidget.cc
++	pilotComponent.cc
++)
++
++set(shared_STUBS
++	loggerDCOP.h
++)
++
++kde3_add_dcop_skels(shared_SRCS ${shared_STUBS})
++kde3_add_dcop_stubs(shared_SRCS ${shared_STUBS})
++
++set(kcmpilot_SRCS
++	${settings_SRC}
++	kpilotConfigWizard.cc
++	dbSelectionDialog.cc
++	kpilotConfigDialog.cc
++	conduitConfigDialog.cc
++	kpilotProbeDialog.cc
++)
++
++set(kcmpilot_KCFGS
++	kpilotConfigWizard_address.kcfgc
++	kpilotConfigWizard_notes.kcfgc
++	kpilotConfigWizard_vcal.kcfgc
++)
++
++set(kcmpilot_UIS
++	kpilotConfigDialog_device.ui
++	kpilotConfigDialog_sync.ui
++	kpilotConfigDialog_startup.ui
++	kpilotConfigDialog_viewers.ui
++	kpilotConfigDialog_backup.ui
++	kpilotConfigWizard_user.ui
++	kpilotConfigWizard_app.ui
++	dbSelection_base.ui
++)
++
++set(kcmpilot_STUBS
++	pilotDaemonDCOP.h
++)
++
++# Don't forget to include output directory, otherwise
++# the UI file won't be wrapped!
++include_directories(
++	${CMAKE_BINARY_DIR}/lib
++	${CMAKE_SOURCE_DIR}/lib
++	${CMAKE_CURRENT_BINARY_DIR}
++)
++
++kde3_add_ui_files(kcmpilot_SRCS ${kcmpilot_UIS})
++kde3_add_kcfg_files(kcmpilot_SRCS ${kcmpilot_KCFGS})
++kde3_add_dcop_skels(kcmpilot_SRCS ${kcmpilot_STUBS})
++kde3_add_dcop_stubs(kcmpilot_SRCS ${kcmpilot_STUBS})
++kde3_automoc(${kcmpilot_SRCS})
++
++# Now add these generated files to the ADD_LIBRARY step
++# If this is NOT done, then the ui_*.h files will not be generated
++add_library(kcm_kpilot SHARED ${kcmpilot_SRCS})
++set_target_properties(kcm_kpilot PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR}
++	PREFIX ""
++)
++
++set(kpilotTest_SRCS
++	${shared_SRCS}	
++	main-test.cc
++)
++
++kde3_automoc(${kpilotTest_SRCS})
++add_executable(kpilotTest ${kpilotTest_SRCS})
++target_link_libraries(kpilotTest ${QT_LIBRARIES} kpilot)
++kpilot_rpath(kpilotTest)
++
++set(kpilotDaemon_SRCS
++	${shared_SRCS}
++	fileInstaller.cc
++	internalEditorAction.cc
++	logFile.cc
++	pilotDaemon.cc
++)
++
++set(kpilot_STUBS
++	kpilotDCOP.h
++	pilotDaemonDCOP.h
++)
++
++kde3_add_dcop_skels(kpilotDaemon_SRCS ${kpilot_STUBS})
++kde3_add_dcop_stubs(kpilotDaemon_SRCS ${kpilot_STUBS})
++kde3_automoc(${kpilotDaemon_SRCS})
++add_executable(kpilotDaemon ${kpilotDaemon_SRCS})
++target_link_libraries(kpilotDaemon ${QT_LIBRARIES} kpilot)
++kpilot_rpath(kpilotDaemon)
++
++set(kpilot_SRCS
++	${shared_SRCS}
++	kpilot.cc
++	dbviewerWidget.cc
++	dbFlagsEditor.cc
++	dbRecordEditor.cc
++	dbAppInfoEditor.cc
++	memoWidget.cc
++	addressWidget.cc
++	addressEditor.cc
++	datebookWidget.cc
++	todoWidget.cc
++	todoEditor.cc
++	fileInstaller.cc
++	fileInstallWidget.cc
++	listItems.cc
++)
++
++set(kpilot_UIS
++	dbFlagsEditor_base.ui
++	todoEditor_base.ui
++)
++
++kde3_add_ui_files(kpilot_SRCS ${kpilot_UIS})
++kde3_add_dcop_skels(kpilot_SRCS ${kpilot_STUBS})
++kde3_add_dcop_stubs(kpilot_SRCS ${kpilot_STUBS})
++kde3_automoc(${kpilot_SRCS})
++add_executable(kpilot_bin ${kpilot_SRCS})
++target_link_libraries(kpilot_bin ${QT_LIBRARIES} kpilot kutils)
++kpilot_rpath(kpilot_bin)
++set_target_properties(kpilot_bin PROPERTIES 
++	OUTPUT_NAME kpilot
++)
++
++######################### INSTALL STUFF #######################################
++
++kde3_install_libtool_file(kcm_kpilot)
++
++install(
++	TARGETS kcm_kpilot kpilot_bin kpilotDaemon
++	LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR}
++	RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
++	RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
++)
++
++install(
++	FILES kpilot.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share
++)
++
++install(
++	FILES kpilotdaemon.desktop DESTINATION ${KDE3_XDG_APPS_DIR}
++)
++
++install(
++	FILES kpilotconduit.desktop DESTINATION ${KDE3_SERVICETYPES_DIR}
++)
++
++install(
++	FILES kpilot_config.desktop DESTINATION ${KDE3_SERVICES_DIR}
++)
++
++add_subdirectory(Icons)
+diff -pruN kpilot/kpilot/conduitConfigDialog.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/conduitConfigDialog.cc
+--- kpilot/kpilot/conduitConfigDialog.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/conduitConfigDialog.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,9 +28,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-static const char *conduitconfigdialog_id =
+-	"$Id: conduitConfigDialog.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ #include "options.h"
+ 
+ #include <qlistview.h>
+@@ -78,11 +75,13 @@ extern "C"
+ {
+ 	KDE_EXPORT KCModule *create_kpilotconfig( QWidget *parent, const char * )
+ 	{
++		FUNCTIONSETUP;
+ 		return new ConduitConfigWidget( parent, "kcmkpilotconfig" );
+ 	}
+ 
+ 	KDE_EXPORT ConfigWizard *create_wizard(QWidget *parent, int m)
+ 	{
++		FUNCTIONSETUP;
+ 		return new ConfigWizard(parent,"Wizard", m);
+ 	}
+ }
+@@ -217,6 +216,8 @@ ConduitConfigWidgetBase::ConduitConfigWi
+ 	fConfigureKontact(0L),
+ 	fActionDescription(0L)
+ {
++	FUNCTIONSETUP;
++
+ 	QWidget *w = 0L; // For spacing purposes only.
+ 	QHBox *btns = 0L;
+ 
+@@ -346,7 +347,6 @@ ConduitConfigWidget::ConduitConfigWidget
+ 	(void) new ConduitTip(fConduitList);
+ 	setButtons(Apply);
+ 
+-	(void) conduitconfigdialog_id;
+ }
+ 
+ ConduitConfigWidget::~ConduitConfigWidget()
+@@ -519,21 +519,25 @@ void ConduitConfigWidget::loadAndConfigu
+ 		return;
+ 	}
+ 
++	QString libraryName = p->text(CONDUIT_LIBRARY);
++
+ #ifdef DEBUG
+ 	DEBUGKPILOT << fname
+ 		<< ": Executing conduit "
+ 		<< p->text(CONDUIT_NAME)
++		<< " (library " << libraryName << ")"
+ 		<< endl;
+ #endif
+ 
+-	if (p->text(CONDUIT_LIBRARY).isEmpty())
++
++	if (libraryName.isEmpty())
+ 	{
+ 		fStack->raiseWidget(BROKEN_CONDUIT);
+ 		warnNoExec(p);
+ 		return;
+ 	}
+ 
+-	if (p->text(CONDUIT_LIBRARY).startsWith(CSL1("internal_")))
++	if (libraryName.startsWith(CSL1("internal_")))
+ 	{
+ 		fStack->raiseWidget(INTERNAL_CONDUIT);
+ 		fActionDescription->setText(
+@@ -544,18 +548,18 @@ void ConduitConfigWidget::loadAndConfigu
+ 		return;
+ 	}
+ 
+-	if (p->text(CONDUIT_LIBRARY) == CSL1("expln_conduits"))
++	if (libraryName == CSL1("expln_conduits"))
+ 	{
+ 		fStack->raiseWidget(CONDUIT_EXPLN);
+ 		return;
+ 	}
+-	if (p->text(CONDUIT_LIBRARY) == CSL1("expln_general"))
++	if (libraryName == CSL1("expln_general"))
+ 	{
+ 		fStack->raiseWidget(GENERAL_EXPLN);
+ 		return;
+ 	}
+ 
+-	if (p->text(CONDUIT_LIBRARY) == CSL1("general_about"))
++	if (libraryName == CSL1("general_about"))
+ 	{
+ 		fStack->raiseWidget(GENERAL_ABOUT);
+ 		return;
+@@ -564,13 +568,13 @@ void ConduitConfigWidget::loadAndConfigu
+ 	QObject *o = 0L;
+ 
+ 	// Page 4: General setup
+-	if (p->text(CONDUIT_LIBRARY).startsWith(CSL1("general_")))
++	if (libraryName.startsWith(CSL1("general_")))
+ 	{
+ 		o = handleGeneralPages(fStack,p);
+ 	}
+ 	else
+ 	{
+-		QCString library = QFile::encodeName(p->text(CONDUIT_LIBRARY));
++		QCString library = QFile::encodeName(libraryName);
+ 
+ 		KLibFactory *f = KLibLoader::self()->factory(library);
+ 		if (!f)
+@@ -578,7 +582,9 @@ void ConduitConfigWidget::loadAndConfigu
+ #ifdef DEBUG
+ 			DEBUGKPILOT << fname
+ 				<< ": No conduit library "
+-				<< library
++				<< library.data()
++				<< " [" << library.size() << "]"
++				<< " (" << libraryName << ")"
+ 				<< " found."
+ 				<< endl;
+ #endif
+diff -pruN kpilot/kpilot/dbFlagsEditor_base.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/dbFlagsEditor_base.ui
+--- kpilot/kpilot/dbFlagsEditor_base.ui	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/dbFlagsEditor_base.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -370,9 +370,7 @@
+ </tabstops>
+ <includes>
+     <include location="local" impldecl="in implementation">dbFlagsEditor_base.ui.h</include>
++    <include location="system" impldecl="in implementation">kdatewidget.h</include>
+ </includes>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kdatewidget.h</includehint>
+-</includehints>
+ </UI>
+diff -pruN kpilot/kpilot/dbFlagsEditor.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/dbFlagsEditor.cc
+--- kpilot/kpilot/dbFlagsEditor.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/dbFlagsEditor.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -25,25 +25,26 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ #include <pi-dlp.h>
+ 
+ #include <qlineedit.h>
+ #include <qcheckbox.h>
+-#include <qtextcodec.h>
+ #include <kdatewidget.h>
+ #include <ktimewidget.h>
+ #include <kmessagebox.h>
+ 
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ #include "dbFlagsEditor.h"
+ #include "dbFlagsEditor_base.h"
+ 
+ 
+ DBFlagsEditor::DBFlagsEditor(DBInfo*dbinfo, QWidget *parent) :
+ 	KDialogBase(parent, "FlagsEditor",false,
+-		i18n("Edit Database Flags"), Ok|Cancel), 
++		i18n("Edit Database Flags"), Ok|Cancel),
+ 	dbi(dbinfo)
+ {
+ 	widget=new DBFlagsEditorWidget(this);
+@@ -60,7 +61,7 @@ void DBFlagsEditor::slotOk()
+ {
+ 	if (KMessageBox::questionYesNo(this, i18n("Changing the database flags might corrupt the whole database, or make the data unusable. Do not change the values unless you are absolutely sure you know what you are doing.\n\nReally assign these new flags?"), i18n("Changing Database Flags"),i18n("Assign"),KStdGuiItem::cancel())==KMessageBox::Yes)
+ 	{
+-		strlcpy(dbi->name, PilotAppCategory::codec()->fromUnicode(widget->fDBName->text()), 33);
++		Pilot::toPilot(widget->fDBName->text(),dbi->name,33);
+ 
+ 		char buff[5];
+ 		strlcpy(buff, widget->fType->text().latin1(), 5);
+diff -pruN kpilot/kpilot/dbSelection_base.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/dbSelection_base.ui
+--- kpilot/kpilot/dbSelection_base.ui	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/dbSelection_base.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -71,10 +71,10 @@
+     </connection>
+ </connections>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>klistview.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-    <includehint>klineedit.h</includehint>
+-    <includehint>kpushbutton.h</includehint>
+-</includehints>
++<includes>
++	<include location="system" impldecl="in implementation">klistview.h</include>
++	<include location="system" impldecl="in implementation">kpushbutton.h</include>
++	<include location="system" impldecl="in implementation">klineedit.h</include>
++	<include location="system" impldecl="in implementation">kpushbutton.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/kpilot/dbviewerWidget.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/dbviewerWidget.cc
+--- kpilot/kpilot/dbviewerWidget.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/dbviewerWidget.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -184,7 +184,7 @@ void GenericDBWidget::slotSelected(const
+ 		currentDB.remove( QRegExp(CSL1(".(pdb|PDB)$")) );
+ 
+ 		fDB=new PilotLocalDatabase(dbPath(), currentDB, false);
+-		if (!fDB || !fDB->isDBOpen())
++		if (!fDB || !fDB->isOpen())
+ 		{
+ 			fDBInfo->setText(i18n("<B>Warning:</B> Cannot read "
+ 				"database file %1.").arg(currentDB));
+diff -pruN kpilot/kpilot/fileInstaller.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/fileInstaller.cc
+--- kpilot/kpilot/fileInstaller.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/fileInstaller.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -29,9 +29,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-static const char *fileinstaller_id =
+-	"$Id: fileInstaller.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ 
+ #include "options.h"
+ 
+@@ -58,7 +55,6 @@ FileInstaller::FileInstaller() :
+ 		CSL1("kpilot/pending_install/"));
+ 	fPendingCopies = 0;
+ 
+-	(void) fileinstaller_id;
+ }
+ 
+ /* virtual */ FileInstaller::~FileInstaller()
+@@ -116,7 +112,7 @@ void FileInstaller::deleteFiles(const QS
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Copying " << s << endl;
++	DEBUGKPILOT << fname << ": Copying " << s << endl;
+ #endif
+ 
+ 	KURL srcName;
+diff -pruN kpilot/kpilot/fileInstallWidget.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/fileInstallWidget.cc
+--- kpilot/kpilot/fileInstallWidget.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/fileInstallWidget.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,8 +28,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *fileinstallwidget_id =
+-	"$Id: fileInstallWidget.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+ 
+ #ifndef _KPILOT_OPTIONS_H
+ #include "options.h"
+@@ -109,7 +107,6 @@ FileInstallWidget::FileInstallWidget(QWi
+ 	connect(fInstaller, SIGNAL(filesChanged()),
+ 		this, SLOT(refreshFileInstallList()));
+ 
+-	(void) fileinstallwidget_id;
+ }
+ 
+ FileInstallWidget::~FileInstallWidget()
+diff -pruN kpilot/kpilot/hotSync.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/hotSync.cc
+--- kpilot/kpilot/hotSync.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/hotSync.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -2,6 +2,7 @@
+ **
+ ** Copyright (C) 2001 by Dan Pilone
+ ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
+ **
+ ** This file defines SyncActions, which are used to perform some specific
+ ** task during a HotSync. Conduits are not included here, nor are
+@@ -30,8 +31,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org.
+ */
+ 
+-static const char *hotsync_id =
+-	"$Id: hotSync.cc 449697 2005-08-16 13:19:47Z adridg $";
+ 
+ #include "options.h"
+ 
+@@ -40,6 +39,7 @@ static const char *hotsync_id =
+ #include <stdio.h>
+ 
+ #include <pi-file.h>
++#include <pi-util.h>
+ 
+ #include <qtimer.h>
+ #include <qfile.h>
+@@ -47,7 +47,6 @@ static const char *hotsync_id =
+ #include <qdir.h>
+ #include <qvaluelist.h>
+ #include <qregexp.h>
+-#include <qtextcodec.h>
+ #include <qstringlist.h>
+ 
+ #include <kglobal.h>
+@@ -55,7 +54,7 @@ static const char *hotsync_id =
+ #include <kapplication.h>
+ 
+ #include "pilotUser.h"
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ #include "syncStack.h"
+ #include "pilotSerialDatabase.h"
+ #include "pilotLocalDatabase.h"
+@@ -64,12 +63,11 @@ static const char *hotsync_id =
+ 
+ #include "hotSync.moc"
+ 
+-TestLink::TestLink(KPilotDeviceLink * p) :
++TestLink::TestLink(KPilotLink * p) :
+ 	SyncAction(p, "testLink")
+ {
+ 	FUNCTIONSETUP;
+ 
+-	(void) hotsync_id;
+ }
+ 
+ /* virtual */ bool TestLink::exec()
+@@ -83,33 +81,22 @@ TestLink::TestLink(KPilotDeviceLink * p)
+ 
+ 	addSyncLogEntry(i18n("Testing.\n"));
+ 
+-#ifdef BRUTE_FORCE
+-	for (i=0; i<32; i++)
+-#else
+-	while ((i = fHandle->getNextDatabase(dbindex,&db)) > 0)
+-#endif
++	while ((i = deviceLink()->getNextDatabase(dbindex,&db)) > 0)
+ 	{
+-#ifdef BRUTE_FORCE
+-		if (fHandle->getNextDatabase(i,&db) < 1)
+-		{
+-			DEBUGCONDUIT << fname << ": No database index " << i << endl;
+-			continue;
+-		}
+-#endif
+-
+ 		count++;
+ 		dbindex = db.index + 1;
+ 
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Read database " << db.name << endl;
+-#endif
++		DEBUGKPILOT << fname
++			<< ": Read database " << db.name
++			<< " with index " << db.index
++			<< endl;
+ 
+ 		// Let the Pilot User know what's happening
+ 		openConduit();
+ 		// Let the KDE User know what's happening
+ 		// Pretty sure all database names are in latin1.
+ 		emit logMessage(i18n("Syncing database %1...")
+-			.arg(PilotAppCategory::codec()->toUnicode(db.name)));
++			.arg(Pilot::fromPilot(db.name)));
+ 
+ 		kapp->processEvents();
+ 	}
+@@ -119,19 +106,32 @@ TestLink::TestLink(KPilotDeviceLink * p)
+ 	return true;
+ }
+ 
+-BackupAction::BackupAction(KPilotDeviceLink * p, bool full) :
++class BackupAction::Private
++{
++public:
++	Private() : fTimer(0L) { }
++
++	QTimer *fTimer;
++	bool fFullBackup;
++	QStringList fNoBackupDBs;
++	QValueList<unsigned long> fNoBackupCreators;
++	QStringList fDeviceDBs;
++
++	QString fPreferBackupDir; /**< Directory towrite backup in, overrides default */
++
++	// Remainder is used to hand around info during sync
++
++	int fDBIndex;       /**< Database number we're now doing */
++	QString fBackupDir; /**< Directory to write backup in.*/
++} ;
++
++BackupAction::BackupAction(KPilotLink * p, bool full) :
+ 	SyncAction(p, "backupAction"),
+-	fFullBackup(full)
++	fP( new Private )
+ {
+ 	FUNCTIONSETUP;
+ 
+-	fDatabaseDir = KGlobal::dirs()->saveLocation("data",
+-		CSL1("kpilot/DBBackup/"));
+-
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Will write to " << fDatabaseDir << endl;
+-	DEBUGCONDUIT << fname << ": Full sync? " << full << endl;
+-#endif
++	fP->fFullBackup = full;
+ }
+ 
+ /* virtual */ QString BackupAction::statusString() const
+@@ -171,6 +171,15 @@ BackupAction::BackupAction(KPilotDeviceL
+ 	return s;
+ }
+ 
++void BackupAction::setDirectory( const QString &p )
++{
++	fP->fPreferBackupDir = p;
++	if (!p.endsWith(CSL1("/")))
++	{
++		fP->fPreferBackupDir.append(CSL1("/"));
++	}
++}
++
+ static inline bool dontBackup(struct DBInfo *info,
+ 	const QStringList &dbnames,
+ 	const QValueList<unsigned long> &dbcreators)
+@@ -182,7 +191,7 @@ static inline bool dontBackup(struct DBI
+ 	if (dbcreators.findIndex(info->creator) != -1) return true;
+ 
+ 	// Now take wildcards into account
+-	QString db = PilotAppCategory::codec()->toUnicode(info->name);
++	QString db = Pilot::fromPilot(info->name);
+ 	for (QStringList::const_iterator i = dbnames.begin(); i != dbnames.end(); ++i)
+ 	{
+ 		QRegExp re(*i,true,true); // Wildcard match
+@@ -223,8 +232,7 @@ static inline void initNoBackup(QStringL
+ 		}
+ 	}
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Will skip databases "
++	DEBUGKPILOT << fname << ": Will skip databases "
+ 		<< dbnames.join(CSL1(",")) << endl;
+ 	QString creatorids;
+ 	for (QValueList<unsigned long>::const_iterator i = dbcreators.begin();
+@@ -232,35 +240,39 @@ static inline void initNoBackup(QStringL
+ 	{
+ 		creatorids.append(CSL1("[%1]").arg(*i,0,16));
+ 	}
+-	DEBUGCONDUIT << fname << ": Will skip creators " << creatorids << endl;
+-#endif
++	DEBUGKPILOT << fname << ": Will skip creators " << creatorids << endl;
+ }
+ 
+ /* virtual */ bool BackupAction::exec()
+ {
+ 	FUNCTIONSETUP;
+ 
+-	mDeviceDBs = KPilotSettings::deviceDBs();
++	fP->fDeviceDBs = KPilotSettings::deviceDBs();
+ 
+-	fBackupDir =
+-		fDatabaseDir +
+-		PilotAppCategory::codec()->toUnicode(fHandle->getPilotUser()->getUserName()) +
+-		CSL1("/");
++	if (fP->fPreferBackupDir.isEmpty())
++	{
++		fP->fBackupDir =
++			KGlobal::dirs()->saveLocation("data",CSL1("kpilot/DBBackup/")) +
++			Pilot::fromPilot(deviceLink()->getPilotUser().getUserName()) +
++			CSL1("/");
++	}
++	else
++	{
++		fP->fBackupDir = fP->fPreferBackupDir;
++	}
+ 
+-	logMessage(i18n("Backup directory: %1.").arg(fBackupDir));
++	logMessage(i18n("Backup directory: %1.").arg(fP->fBackupDir));
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
++	DEBUGKPILOT << fname
+ 		<< ": This Pilot user's name is \""
+-		<< fHandle->getPilotUser()->getUserName() << "\"" << endl;
+-	DEBUGCONDUIT << fname
+-		<< ": Using backup dir: " << fBackupDir << endl;
+-	DEBUGCONDUIT << fname
+-		<< ": Full Backup? " << fFullBackup << endl;
+-#endif
++		<< deviceLink()->getPilotUser().getUserName() << "\"" << endl;
++	DEBUGKPILOT << fname
++		<< ": Using backup dir: " << fP->fBackupDir << endl;
++	DEBUGKPILOT << fname
++		<< ": Full Backup? " << fP->fFullBackup << endl;
+ 
+ 
+-	if (fFullBackup)
++	if (fP->fFullBackup)
+ 	{
+ 		fActionStatus = FullBackup;
+ 		addSyncLogEntry(i18n("Full backup started."));
+@@ -271,7 +283,7 @@ static inline void initNoBackup(QStringL
+ 		addSyncLogEntry(i18n("Fast backup started"));
+ 	}
+ 
+-	if (!checkBackupDirectory(fBackupDir))
++	if (!checkBackupDirectory(fP->fBackupDir))
+ 	{
+ 		fActionStatus=BackupIncomplete;
+ 		// Don't issue an error message, checkBackupDirectory
+@@ -279,51 +291,56 @@ static inline void initNoBackup(QStringL
+ 		return false;
+ 	}
+ 
+-	initNoBackup( fNoBackupDBs, fNoBackupCreators );
++	initNoBackup( fP->fNoBackupDBs, fP->fNoBackupCreators );
+ 
+-	fTimer = new QTimer( this );
+-	QObject::connect( fTimer, SIGNAL( timeout() ),
++	fP->fTimer = new QTimer( this );
++	QObject::connect( fP->fTimer, SIGNAL( timeout() ),
+ 		this, SLOT( backupOneDB() ) );
+ 
+-	fDBIndex = 0;
++	fP->fDBIndex = 0;
+ 
+-	fTimer->start( 0, false );
++	fP->fTimer->start( 0, false );
+ 	return true;
+ }
+ 
+-bool BackupAction::checkBackupDirectory(QString backupDir)
++bool BackupAction::checkBackupDirectory( const QString &backupDir )
+ {
+ 	FUNCTIONSETUP;
+ 	QFileInfo fi(backupDir);
+ 
+-	if (!(fi.exists() && fi.isDir()))
++	if (fi.exists() && fi.isDir())
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname
+-			<< ": Need to create backup directory for user "
+-			<< fHandle->getPilotUser()->getUserName() << endl;
+-#endif
+-
+-		fi = QFileInfo(fDatabaseDir);
+-		if (!(fi.exists() && fi.isDir()))
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Database backup directory "
+-				<< "doesn't exist."
+-				<< endl;
+-			return false;
+-		}
++		return true;
++	}
+ 
+-		QDir databaseDir(backupDir);
++	if (fi.exists() && !fi.isDir())
++	{
++		kdWarning() << k_funcinfo
++			<< ": Requested backup directory "
++			<< backupDir
++			<< " exists but is not a directory."
++			<< endl;
++		return false;
++	}
+ 
+-		if (!databaseDir.mkdir(backupDir, true))
+-		{
+-			kdError() << k_funcinfo
+-				<< ": Can't create backup directory." << endl;
+-			return false;
+-		}
++	if ( !backupDir.endsWith("/") )
++	{
++		kdWarning() << k_funcinfo
++			<< ": Backup dir does not end with a / "
++			<< endl;
++		return false;
+ 	}
+-	return true;
++
++	Q_ASSERT(!fi.exists());
++
++	DEBUGKPILOT << fname
++		<< ": Creating directory " << backupDir << endl;
++
++	KStandardDirs::makeDir( backupDir );
++
++	fi = QFileInfo(backupDir);
++
++	return fi.exists() && fi.isDir();
+ }
+ 
+ /* slot */ void BackupAction::backupOneDB()
+@@ -332,15 +349,10 @@ bool BackupAction::checkBackupDirectory(
+ 
+ 	struct DBInfo info;
+ 
+-	emit logProgress(QString::null, fDBIndex);
++	emit logProgress(QString::null, fP->fDBIndex);
+ 
+ 	if (openConduit() < 0)
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname
+-			<< ": openConduit failed. User cancel?" << endl;
+-#endif
+-
+ 		addSyncLogEntry(i18n("Exiting on cancel."));
+ 		endBackup();
+ 		fActionStatus = BackupIncomplete;
+@@ -348,14 +360,10 @@ bool BackupAction::checkBackupDirectory(
+ 	}
+ 
+ 	// TODO: Is there a way to skip unchanged databases?
+-	int res = fHandle->getNextDatabase( fDBIndex, &info );
++	int res = deviceLink()->getNextDatabase( fP->fDBIndex, &info );
+ 	if (res < 0)
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Backup complete." << endl;
+-#endif
+-
+-		if ( fFullBackup )
++		if ( fP->fFullBackup )
+ 			addSyncLogEntry( i18n("Full backup complete.") );
+ 		else
+ 			addSyncLogEntry( i18n("Fast backup complete.") );
+@@ -364,7 +372,7 @@ bool BackupAction::checkBackupDirectory(
+ 		return;
+ 	}
+ 
+-	fDBIndex = info.index + 1;
++	fP->fDBIndex = info.index + 1;
+ 
+ 	char buff[8];
+ 	memset(buff, 0, 8);
+@@ -375,43 +383,37 @@ bool BackupAction::checkBackupDirectory(
+ 	QString creator = QString::fromLatin1( buff );
+ 	info.name[33]='\0';
+ 	QString dbname = QString::fromLatin1( info.name );
+-	if ( !mDeviceDBs.contains( creator ) )
+-		mDeviceDBs << creator;
+-	if ( !mDeviceDBs.contains( dbname ) )
+-		mDeviceDBs << dbname;
++	if ( !fP->fDeviceDBs.contains( creator ) )
++		fP->fDeviceDBs << creator;
++	if ( !fP->fDeviceDBs.contains( dbname ) )
++		fP->fDeviceDBs << dbname;
+ 
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Checking to see if we should backup database " << info.name
++	DEBUGKPILOT << fname << ": Checking to see if we should backup database " << info.name
+ 		<< " [" << QString::number(info.creator,16) << "]" << endl;
+-#endif
+ 
+ 	// see if user told us not to back this creator or database up...
+-	if (dontBackup(&info,fNoBackupDBs,fNoBackupCreators))
++	if (dontBackup(&info,fP->fNoBackupDBs,fP->fNoBackupCreators))
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Skipping database " << info.name
++		DEBUGKPILOT << fname << ": Skipping database " << info.name
+ 			<< " (database in no-backup list)" << endl;
+-#endif
+ 		QString s = i18n("Skipping %1")
+-			.arg(PilotAppCategory::codec()->toUnicode(info.name));
++			.arg(Pilot::fromPilot(info.name));
+ 		addSyncLogEntry(s);
+ 		return;
+ 	}
+ 
+ 	// don't backup resource databases...
+-	if ( (!fFullBackup) && PilotDatabase::isResource(&info))
++	if ( (!fP->fFullBackup) && PilotDatabase::isResource(&info))
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Skipping database " << info.name
++		DEBUGKPILOT << fname << ": Skipping database " << info.name
+ 			<< " (resource database)" << endl;
+-#endif
+ 		// Just skip resource DBs during an update hotsync.
+ 		return;
+ 	}
+ 
+ 	QString s = i18n("Backing up: %1")
+-		.arg(PilotAppCategory::codec()->toUnicode(info.name));
++		.arg(Pilot::fromPilot(info.name));
+ 	addSyncLogEntry(s);
+ 
+ 	if (!createLocalDatabase(&info))
+@@ -420,7 +422,7 @@ bool BackupAction::checkBackupDirectory(
+ 			<< ": Couldn't create local database for "
+ 			<< info.name << endl;
+ 		addSyncLogEntry(i18n("Backup of %1 failed.\n")
+-			.arg(PilotAppCategory::codec()->toUnicode(info.name)));
++			.arg(Pilot::fromPilot(info.name)));
+ 	}
+ 	else
+ 	{
+@@ -441,28 +443,29 @@ bool BackupAction::createLocalDatabase(D
+ {
+ 	FUNCTIONSETUP;
+ 
+-	QString databaseName(PilotAppCategory::codec()->toUnicode(info->name));
++	QString databaseName(Pilot::fromPilot(info->name));
+ 	// default this to true.  we will set it to false if there are no modified
+ 	// records and we are not doing a full sync.
+ 	bool doBackup = true;
+ 
+ 	// make sure that our directory is available...
+-	if (!checkBackupDirectory(fBackupDir)) return false;
++	if (!checkBackupDirectory( fP->fBackupDir )) return false;
+ 
+ 	// we always need to open the database on the pilot because if we're going to sync
+ 	// it, we need to reset the "dirty" flags, etc.
+-	PilotSerialDatabase*serial=new PilotSerialDatabase(pilotSocket(), databaseName);
+-	if (!serial->isDBOpen())
++	PilotDatabase *serial=deviceLink()->database(databaseName);
++	if (!serial->isOpen())
+ 	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT<<"Unable to open database "<<info->name<<" to check for modified records and reset sync flags."<<endl;
+-#endif
++		DEBUGKPILOT << fname << ": Unable to open database "<<info->name
++			<< " to check for modified records and reset sync flags." << endl;
++		KPILOT_DELETE(serial);
++		return false;
+ 	}
+ 
+ 	// now we look to see if the database on the pilot has at least one changed record
+ 	// in it.  we do this so that we don't waste time backing up a database that has
+ 	// not changed.  note: don't bother with this check if we're doing a full backup.
+-	if (!fFullBackup && serial->isDBOpen())
++	if (!fP->fFullBackup && serial->isOpen())
+ 	{
+ 		int index=0;
+ 		PilotRecord*rec=serial->readNextModifiedRec(&index);
+@@ -492,7 +495,7 @@ bool BackupAction::createLocalDatabase(D
+ 	// checks and proceed....
+ 	databaseName.replace('/', CSL1("_"));
+ 
+-	QString fullBackupName = fBackupDir + databaseName;
++	QString fullBackupName = fP->fBackupDir + databaseName;
+ 
+ 	if (PilotDatabase::isResource(info))
+ 	{
+@@ -515,8 +518,8 @@ bool BackupAction::createLocalDatabase(D
+ 
+ 	// if we've backed this one up, clean it up so we won't do it again next
+ 	// sync unless it's truly changed
+-	serial=new PilotSerialDatabase(pilotSocket(), databaseName);
+-	if (backedUp && serial->isDBOpen())
++	serial=deviceLink()->database(databaseName);
++	if (backedUp && serial->isOpen())
+ 	{
+ 		serial->cleanup();
+ 		serial->resetSyncFlags();
+@@ -530,26 +533,26 @@ void BackupAction::endBackup()
+ {
+ 	FUNCTIONSETUP;
+ 
+-	KPILOT_DELETE(fTimer);
+-	fDBIndex = (-1);
++	KPILOT_DELETE(fP->fTimer);
++	fP->fDBIndex = (-1);
+ 	fActionStatus = BackupEnded;
+-	mDeviceDBs.sort();
++	fP->fDeviceDBs.sort();
+ 	QString old( QString::null );
+-	QStringList::Iterator itr = mDeviceDBs.begin();
+-	while ( itr != mDeviceDBs.end() ) {
++	QStringList::Iterator itr = fP->fDeviceDBs.begin();
++	while ( itr != fP->fDeviceDBs.end() ) {
+ 		if ( old == *itr ) {
+-			itr = mDeviceDBs.remove( itr );
++			itr = fP->fDeviceDBs.remove( itr );
+ 		} else {
+ 			old = *itr;
+ 			++itr;
+ 		}
+ 	}
+-	KPilotSettings::setDeviceDBs( mDeviceDBs );
++	KPilotSettings::setDeviceDBs( fP->fDeviceDBs );
+ 
+ 	emit syncDone(this);
+ }
+ 
+-FileInstallAction::FileInstallAction(KPilotDeviceLink * p,
++FileInstallAction::FileInstallAction(KPilotLink * p,
+ 	const QString & d) :
+ 	SyncAction(p, "fileInstall"),
+ 	fDBIndex(-1),
+@@ -574,7 +577,7 @@ FileInstallAction::~FileInstallAction()
+ 	fList = installDir.entryList(QDir::Files |
+ 		QDir::NoSymLinks | QDir::Readable);
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname
++	DEBUGKPILOT << fname
+ 		<< ": Installing " << fList.count() << " files" << endl;
+ #endif
+ 
+@@ -608,7 +611,7 @@ FileInstallAction::~FileInstallAction()
+ 	Q_ASSERT((unsigned) fDBIndex <= fList.count());
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname
++	DEBUGKPILOT << fname
+ 		<< ": Installing file index "
+ 		<< fDBIndex << " (of " << fList.count() << ")" << endl;
+ #endif
+@@ -616,7 +619,7 @@ FileInstallAction::~FileInstallAction()
+ 	if ((!fList.count()) || ((unsigned) fDBIndex >= fList.count()))
+ 	{
+ #ifdef DEBUG
+-		DEBUGCONDUIT << fname
++		DEBUGKPILOT << fname
+ 			<< ": Peculiar file index, bailing out." << endl;
+ #endif
+ 		KPILOT_DELETE(fTimer);
+@@ -632,7 +635,7 @@ FileInstallAction::~FileInstallAction()
+ 	fDBIndex++;
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Installing file " << filePath << endl;
++	DEBUGKPILOT << fname << ": Installing file " << filePath << endl;
+ #endif
+ 
+ 	QString m = i18n("Installing %1").arg(fileName);
+@@ -749,7 +752,7 @@ bool FileInstallAction::resourceOK(const
+ 	}
+ }
+ 
+-CleanupAction::CleanupAction(KPilotDeviceLink *p)  : SyncAction(p,"cleanupAction")
++CleanupAction::CleanupAction(KPilotLink *p)  : SyncAction(p,"cleanupAction")
+ {
+ 	FUNCTIONSETUP;
+ }
+@@ -758,7 +761,7 @@ CleanupAction::~CleanupAction()
+ {
+ #ifdef DEBUG
+ 	FUNCTIONSETUP;
+-	DEBUGCONDUIT << fname
++	DEBUGKPILOT << fname
+ 		<< ": Deleting @" << (long)this << endl;
+ #endif
+ }
+diff -pruN kpilot/kpilot/hotSync.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/hotSync.h
+--- kpilot/kpilot/hotSync.h	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/hotSync.h	2006-11-19 22:21:12.000000000 +0100
+@@ -4,6 +4,7 @@
+ **
+ ** Copyright (C) 2001 by Dan Pilone
+ ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
+ **
+ ** This file defines SyncActions, which are used to perform some specific
+ ** task during a HotSync. Conduits are not included here, nor are
+@@ -36,14 +37,13 @@
+ class QTimer;
+ 
+ #include "syncAction.h"
+-#include "syncStack.h"
+ 
+ class TestLink : public SyncAction
+ {
+ Q_OBJECT
+ 
+ public:
+-	TestLink(KPilotDeviceLink *);
++	TestLink(KPilotLink *);
+ 
+ protected:
+ 	virtual bool exec();
+@@ -54,7 +54,15 @@ class BackupAction : public SyncAction
+ Q_OBJECT
+ 
+ public:
+-	BackupAction(KPilotDeviceLink *, bool full);
++	/** Constructor. Back up all the databases on
++	*   the link to a directory on the local disk.
++	*   If @p full is @c true, then a full backup,
++	*   including applications, is done. Otherwise,
++	*   only user data is backed-up.
++	*
++	* @see setDirectory()
++	*/
++	BackupAction(KPilotLink *, bool full);
+ 
+ 	enum Status { Init,
+ 		Error,
+@@ -66,35 +74,53 @@ public:
+ 		} ;
+ 	virtual QString statusString() const;
+ 
++	/** By default, a path based on the user name (either
++	*   on the handheld or set in KPilot) is used to
++	*   determine the backup directory name ( generally
++	*   $KDEHOME/share/apps/kpilot/DBBackup/_user_name_ ).
++	*   Use setDirectory() to change that and use a given
++	*   @p path as target for the backup. Use an empty
++	*   @p path to restore the default behavior of using
++	*   the username.
++	*/
++	void setDirectory( const QString &path );
++
+ protected:
+ 	virtual bool exec();
+ 
+ private:
+-	/**
+-	* All manner of support functions for full backup.
+-	*/
++	/** Finish the backup and clean up resources. */
+ 	void endBackup();
+-	bool createLocalDatabase(DBInfo *);
+-	bool checkBackupDirectory(QString backupDir);
++
++	/** Copy the database indicated by @p info to the local
++	*   disk; returns @c false on failure.
++	*/
++	bool createLocalDatabase(DBInfo *info);
++
++	/** Make sure that the backup directory @p backupDir
++	*   exists and is a directory; returns @c false
++	*   if this is not the case. This method will try
++	*   to create the directory if it doesn't exist yet.
++	*/
++	static bool checkBackupDirectory( const QString &backupDir );
+ 
+ private slots:
++	/** Implementation detail: databases get backed-up
++	*   one at a time because the backup function in
++	*   pilot-link isn't threaded.
++	*/
+ 	void backupOneDB();
+ 
+ private:
+-	QTimer *fTimer;
+-	int fDBIndex;
+-	QString fBackupDir, fDatabaseDir;
+-	bool fFullBackup;
+-	QStringList fNoBackupDBs;
+-	QValueList<unsigned long> fNoBackupCreators;
+-	QStringList mDeviceDBs;
++	class Private;
++	Private *fP;
+ } ;
+ 
+ class FileInstallAction : public SyncAction
+ {
+ Q_OBJECT
+ public:
+-	FileInstallAction(KPilotDeviceLink *,
++	FileInstallAction(KPilotLink *,
+ 		const QString &fileDir);
+ 	virtual ~FileInstallAction();
+ 
+@@ -120,7 +146,7 @@ private:
+ class CleanupAction : public SyncAction
+ {
+ public:
+-	CleanupAction(KPilotDeviceLink * p);
++	CleanupAction(KPilotLink * p);
+ 	virtual ~CleanupAction();
+ 
+ protected:
+diff -pruN kpilot/kpilot/Icons/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/Icons/CMakeLists.txt
+--- kpilot/kpilot/Icons/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/kpilot/Icons/CMakeLists.txt	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,4 @@
++
++kde3_install_icons_custom( hicolor )
++
++install( FILES kpilot-splash.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/apps/kpilot/pics/)
+diff -pruN kpilot/kpilot/interactiveSync.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/interactiveSync.cc
+--- kpilot/kpilot/interactiveSync.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/interactiveSync.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -2,6 +2,7 @@
+ **
+ ** Copyright (C) 2001 by Dan Pilone
+ ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
+ **
+ ** This file specializes SyncAction to a kind that can have interaction
+ ** with the user without the Sync timing out.
+@@ -28,9 +29,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org.
+ */
+ 
+-static const char *interactivesync_id =
+-	"$Id: interactiveSync.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ #include "options.h"
+ 
+ #include <time.h>
+@@ -50,7 +48,6 @@ static const char *interactivesync_id =
+ #include <qfileinfo.h>
+ #include <qtl.h>
+ #include <qstyle.h>
+-#include <qtextcodec.h>
+ 
+ #include <kdialogbase.h>
+ #include <kglobal.h>
+@@ -60,7 +57,7 @@ static const char *interactivesync_id =
+ #include <kapplication.h>
+ 
+ #include "pilotUser.h"
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ #include "pilotLocalDatabase.h"
+ #include "kpilotConfig.h"
+ #include "kpilotlink.h"
+@@ -68,12 +65,11 @@ static const char *interactivesync_id =
+ #include "interactiveSync.moc"
+ 
+ 
+-CheckUser::CheckUser(KPilotDeviceLink * p, QWidget * vp):
++CheckUser::CheckUser(KPilotLink * p, QWidget * vp):
+ 	SyncAction(p, vp, "userCheck")
+ {
+ 	FUNCTIONSETUP;
+ 
+-	(void) interactivesync_id;
+ }
+ 
+ CheckUser::~CheckUser()
+@@ -86,8 +82,8 @@ CheckUser::~CheckUser()
+ 	FUNCTIONSETUP;
+ 
+ 	QString guiUserName = KPilotSettings::userName();
+-	QString pilotUserName = PilotAppCategory::codec()->
+-		toUnicode(fHandle->getPilotUser()->getUserName());
++// TODO: add userName() to pilotUser class
++	QString pilotUserName = Pilot::fromPilot(fHandle->getPilotUser().getUserName());
+ 	bool pilotUserEmpty = pilotUserName.isEmpty();
+ 	// 4 cases to handle:
+ 	//    guiUserName empty / not empty
+@@ -111,8 +107,8 @@ CheckUser::~CheckUser()
+ 				KMessageBox::Yes)
+ 			{
+ 				KPilotSettings::setUserName(defaultUserName);
+-				fHandle->getPilotUser()->
+-					setUserName(PilotAppCategory::codec()->fromUnicode(defaultUserName));
++				fHandle->getPilotUser()
++					.setUserName(Pilot::toPilot(defaultUserName));
+ 				guiUserName=defaultUserName;
+ 				pilotUserName=defaultUserName;
+ 			}
+@@ -146,14 +142,14 @@ CheckUser::~CheckUser()
+ 				KMessageBox::Yes)
+ 			{
+ #ifdef DEBUG
+-				DEBUGDAEMON << fname
++				DEBUGKPILOT << fname
+ 					<< ": Setting user name in pilot to "
+ 					<< guiUserName << endl;
+ #endif
+ 
+-				QCString l1 = PilotAppCategory::codec()->fromUnicode(guiUserName);
++				QCString l1 = Pilot::toPilot(guiUserName);
+ 
+-				fHandle->getPilotUser()->setUserName(l1.data());
++				fHandle->getPilotUser().setUserName(l1.data());
+ 				pilotUserName=guiUserName;
+ 			}
+ 		}
+@@ -179,8 +175,8 @@ CheckUser::~CheckUser()
+ 				switch (r)
+ 				{
+ 				case KMessageBox::Yes:
+-					fHandle->getPilotUser()->setUserName(
+-						PilotAppCategory::codec()->fromUnicode(guiUserName));
++					fHandle->getPilotUser().setUserName(
++						Pilot::toPilot(guiUserName));
+ 					pilotUserName=guiUserName;
+ 					break;
+ 				case KMessageBox::No:
+@@ -198,11 +194,11 @@ CheckUser::~CheckUser()
+ 
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname
++	DEBUGKPILOT << fname
+ 		<< ": User name set to gui<"
+ 		<< guiUserName
+ 		<< "> hh<"
+-		<< fHandle->getPilotUser()->getUserName() << ">" << endl;
++		<< fHandle->getPilotUser().getUserName() << ">" << endl;
+ #endif
+ 
+ 	KPilotSettings::writeConfig();
+@@ -227,47 +223,68 @@ CheckUser::~CheckUser()
+ class RestoreInfo
+ {
+ public:
+-	struct db DBInfo;
++	struct DBInfo DBInfo;
+ 	QString path;
+ } ;
+ 
+-class RestoreAction::RestoreActionPrivate
++class RestoreAction::Private
+ {
+ public:
+-	QString fDatabaseDir;
+-	QValueList<RestoreInfo *> fDBList;
++	QString fPreferRestoreDir; /**< Preference setting where to get data from. */
++
++	QValueList<RestoreInfo> fDBList;
+ 	QTimer fTimer;
+-	QValueList<RestoreInfo *>::ConstIterator fDBIterator;
++	QValueList<RestoreInfo>::ConstIterator fDBIterator;
+ 	int fDBIndex;
+ };
+ 
+ 
+-RestoreAction::RestoreAction(KPilotDeviceLink * p, QWidget * visible ) :
++RestoreAction::RestoreAction(KPilotLink * p, QWidget * visible ) :
+ 	SyncAction(p, visible, "restoreAction")
+ {
+ 	FUNCTIONSETUP;
+ 
+-	fP = new RestoreActionPrivate;
+-	fP->fDatabaseDir = KGlobal::dirs()->saveLocation("data",
+-		CSL1("kpilot/DBBackup/"));
++	fP = new Private;
++}
++
++void RestoreAction::setDirectory( const QString &path )
++{
++	fP->fPreferRestoreDir = path;
+ }
+ 
+ /* virtual */ bool RestoreAction::exec()
+ {
+ 	FUNCTIONSETUP;
+ 
++	QString dirname;
++	if (fP->fPreferRestoreDir.isEmpty())
++	{
++		dirname = PilotLocalDatabase::getDBPath();
++	}
++	else
++	{
++		dirname = fP->fPreferRestoreDir;
++	}
++
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
+-		<< ": Restoring from base directory "
+-		<< *(PilotLocalDatabase::getDBPath()) << endl;
++	DEBUGKPILOT << fname << ": Restoring user " << dirname << endl;
+ #endif
+ 
+-	QString dirname = *(PilotLocalDatabase::getDBPath());
++	QDir dir(dirname, QString::null, QDir::Name,
++		QDir::Files | QDir::Readable | QDir::NoSymLinks);
+ 
+-#ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Restoring user " << dirname << endl;
+-#endif
++	if (!dir.exists())
++	{
++		kdWarning() << k_funcinfo
++			<< ": Restore directory "
++			<< dirname << " does not exist." << endl;
++		fActionStatus = Error;
++		addSyncLogEntry(i18n("Restore directory does not exist.") +
++			CSL1(" ") + i18n("Restore not performed."));
++		return false;
++	}
+ 
++	dirname = dir.absPath();
+ 	if (questionYesNo(i18n("<qt>Are you sure you want to completely "
+ 				"restore your Pilot from the backup directory "
+ 				"(<i>%1</i>)? This will erase any information "
+@@ -279,63 +296,32 @@ RestoreAction::RestoreAction(KPilotDevic
+ 
+ 		addSyncLogEntry(i18n("Canceled by user.") + CSL1(" ") +
+ 			i18n("Restore not performed."));
+-		emit syncDone(this);
+ 
++		// You might call this an error, but that causes
++		// a frightening message in the log .. and the
++		// user already _knows_ the restore didn't happen.
++		// So instead, act as if everything was ok.
++		delayDone();
+ 		return true;
+ 	}
+ 
+-	QDir dir(dirname, QString::null, QDir::Name,
+-		QDir::Files | QDir::Readable | QDir::NoSymLinks);
+-
+-	if (!dir.exists())
+-	{
+-		kdWarning() << k_funcinfo
+-			<< ": Restore directory "
+-			<< dirname << " does not exist." << endl;
+-		fActionStatus = Error;
+-		addSyncLogEntry(i18n("Restore directory does not exist.") +
+-			CSL1(" ") + i18n("Restore not performed."));
+-		return false;
+-	}
+ 
+ 	emit logProgress(i18n("Restoring %1...").arg(QString::null),1);
+ 
+ 	for (unsigned int i = 0; i < dir.count(); i++)
+ 	{
+ 		QString s;
+-		RestoreInfo *dbi;
+-		struct DBInfo info;
+-		struct pi_file *f;
++		RestoreInfo info;
+ 
+-		s = dir[i];
++		s = dirname + QDir::separator() + dir[i];
+ 
+-#ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGKPILOT << fname
+ 			<< ": Adding " << s << " to restore list." << endl;
+-#endif
+-
+-    char * fileName = qstrdup( QFile::encodeName(dirname + s) );
+-    f = pi_file_open( fileName );
+-    delete fileName;
+-		if (!f)
+-		{
+-			kdWarning() << k_funcinfo
+-				<< ": Can't open " << s << endl;
+-			logMessage(i18n("File '%1' cannot be read.").arg(s));
+-			continue;
+-		}
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-		if (!pi_file_get_info(f, &info))
+-#else
+-		pi_file_get_info(f,&info);
+-		if (true)
+-#endif
++		if ( PilotLocalDatabase::infoFromFile( s, &info.DBInfo ) )
+ 		{
+-			dbi = new RestoreInfo;
+-			memcpy(&dbi->DBInfo,&info,sizeof(struct DBInfo));
+-			dbi->path = dirname + s;
+-			fP->fDBList.append(dbi);
++			info.path = s;
++			fP->fDBList.append(info);
+ 		}
+ 		else
+ 		{
+@@ -343,41 +329,17 @@ RestoreAction::RestoreAction(KPilotDevic
+ 				<< ": Can't open " << s << endl;
+ 			logMessage(i18n("File '%1' cannot be read.").arg(s));
+ 		}
+-
+-		pi_file_close(f);
+-		f = 0L;
+ 	}
+ 
+ 	fP->fDBIndex = 0;
+ 	fP->fDBIterator = fP->fDBList.begin();
+-	fActionStatus = GettingFileInfo;
+-
+-	QObject::connect(&(fP->fTimer), SIGNAL(timeout()),
+-		this, SLOT(getNextFileInfo()));
+-
+-	fP->fTimer.start(0, false);
+-	return true;
+-}
+-
+-/* slot */ void RestoreAction::getNextFileInfo()
+-{
+-	FUNCTIONSETUP;
+-
+-	Q_ASSERT(fActionStatus == GettingFileInfo);
+-
+-	QObject::disconnect(&(fP->fTimer), SIGNAL(timeout()),
+-		this, SLOT(getNextFileInfo()));
+-	fP->fTimer.stop();
+-
+-	qBubbleSort(fP->fDBList);
+-
+-	fP->fDBIndex = 0;
+-	fP->fDBIterator = fP->fDBList.begin();
+ 	fActionStatus = InstallingFiles;
+ 
+ 	QObject::connect(&(fP->fTimer), SIGNAL(timeout()),
+ 		this, SLOT(installNextFile()));
++
+ 	fP->fTimer.start(0, false);
++	return true;
+ }
+ 
+ /* slot */ void RestoreAction::installNextFile()
+@@ -386,12 +348,9 @@ RestoreAction::RestoreAction(KPilotDevic
+ 
+ 	Q_ASSERT(fActionStatus == InstallingFiles);
+ 
+-	const RestoreInfo *dbi = 0L;
+ 
+ 	if (fP->fDBIterator == fP->fDBList.end())
+ 	{
+-		QObject::disconnect(&(fP->fTimer), SIGNAL(timeout()),
+-			this, SLOT(getNextFileInfo()));
+ 		fP->fTimer.stop();
+ 
+ 		fActionStatus = Done;
+@@ -400,12 +359,11 @@ RestoreAction::RestoreAction(KPilotDevic
+ 		return;
+ 	}
+ 
+-	dbi = *fP->fDBIterator;
++	const RestoreInfo dbi = *(fP->fDBIterator);
+ 	++(fP->fDBIterator);
+ 	++(fP->fDBIndex);
+-#ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Trying to install " << dbi->path << endl;
+-#endif
++
++	DEBUGKPILOT << fname << ": Trying to install " << dbi.path << endl;
+ 
+ 	if (openConduit() < 0)
+ 	{
+@@ -418,38 +376,18 @@ RestoreAction::RestoreAction(KPilotDevic
+ 		return;
+ 	}
+ 
+-	QFileInfo databaseInfo(dbi->path);
++	QFileInfo databaseInfo(dbi.path);
+ 	addSyncLogEntry(databaseInfo.fileName());
+ 	emit logProgress(i18n("Restoring %1...").arg(databaseInfo.fileName()),
+ 		(100*fP->fDBIndex) / (fP->fDBList.count()+1)) ;
+ 
+-	char * fileName = qstrdup( dbi->path.utf8() );
+-	pi_file *f  = pi_file_open( fileName );
+-	delete fileName;
+-
+-	if (!f)
+-	{
+-		kdWarning() << k_funcinfo
+-			<< ": Can't open "
+-			<< dbi->path << " for restore." << endl;
+-		logError(i18n("Cannot open file `%1' for restore.")
+-			.arg(databaseInfo.fileName()));
+-		return;
+-	}
+-
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	if (pi_file_install(f, pilotSocket(), 0) < 0)
+-#else
+-	if (pi_file_install(f, pilotSocket(), 0, NULL) < 0)
+-#endif
++	if ( !deviceLink()->installFiles( dbi.path, false /* don't delete */ ) )
+ 	{
+ 		kdWarning() << k_funcinfo
+-			<< ": Couldn't  restore " << dbi->path << endl;
++			<< ": Couldn't  restore " << dbi.path << endl;
+ 		logError(i18n("Cannot restore file `%1'.")
+ 			.arg(databaseInfo.fileName()));
+ 	}
+-
+-	pi_file_close(f);
+ }
+ 
+ /* virtual */ QString RestoreAction::statusString() const
+diff -pruN kpilot/kpilot/interactiveSync.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/interactiveSync.h
+--- kpilot/kpilot/interactiveSync.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/interactiveSync.h	2006-11-19 22:21:12.000000000 +0100
+@@ -4,6 +4,7 @@
+ **
+ ** Copyright (C) 2001 by Dan Pilone
+ ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
+ **
+ ** This file specializes SyncAction to a kind that can have interaction
+ ** with the user without the Sync timing out.
+@@ -38,7 +39,7 @@ class QTimer;
+ class CheckUser : public SyncAction
+ {
+ public:
+-	CheckUser(KPilotDeviceLink *p,QWidget *w=0L);
++	CheckUser(KPilotLink *p,QWidget *w=0L);
+ 	virtual ~CheckUser();
+ 
+ protected:
+@@ -49,26 +50,31 @@ class RestoreAction : public SyncAction
+ {
+ Q_OBJECT
+ public:
+-	RestoreAction(KPilotDeviceLink *,QWidget *w=0L);
++	RestoreAction(KPilotLink *,QWidget *w=0L);
+ 
+ 	typedef enum { InstallingFiles, GettingFileInfo,Done } Status;
+ 	virtual QString statusString() const;
+ 
++	/** By default, a path based on the user name (either
++	*   on the handheld or set in KPilot) is used to
++	*   determine the restory directory name ( generally
++	*   $KDEHOME/share/apps/kpilot/DBBackup/_user_name_ ).
++	*   Use setDirectory() to change that and use a given
++	*   @p path as target for the source. Use an empty
++	*   @p path to restore the default behavior of using
++	*   the username.
++	*/
++	void setDirectory( const QString &path );
++
+ protected:
+ 	virtual bool exec();
+ 
+ protected slots:
+-	void getNextFileInfo();
+ 	void installNextFile();
+ 
+ private:
+-	// Use a private-d pointer for once (well, in KPilot
+-	// parlance it'd be fd, which is confusing, so it's
+-	// become a private fP) since we need QList or QPtrList.
+-	//
+-	//
+-	class RestoreActionPrivate;
+-	RestoreActionPrivate *fP;
++	class Private;
++	Private *fP;
+ } ;
+ 
+ #endif
+diff -pruN kpilot/kpilot/internalEditorAction.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/internalEditorAction.cc
+--- kpilot/kpilot/internalEditorAction.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/internalEditorAction.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -52,7 +52,7 @@
+ using namespace KHE;
+ #endif
+ 
+-InternalEditorAction::InternalEditorAction(KPilotDeviceLink * p) :
++InternalEditorAction::InternalEditorAction(KPilotLink * p) :
+ 	SyncAction(p, "internalSync")
+ {
+ 	FUNCTIONSETUP;
+@@ -97,8 +97,8 @@ void InternalEditorAction::syncDirtyDB()
+ 
+ 	PilotRecord*rec=0L;
+ 	PilotLocalDatabase*localDB=new PilotLocalDatabase(*dbIter, false);
+-	PilotSerialDatabase*serialDB=new PilotSerialDatabase(pilotSocket(), *dbIter);
+-	if (!localDB->isDBOpen() || !serialDB->isDBOpen())
++	PilotDatabase *serialDB= deviceLink()->database(*dbIter);
++	if (!localDB->isOpen() || !serialDB->isOpen())
+ 	{
+ 		emit logError(i18n("Unable to open the serial or local database for %1. "
+ 			"Skipping it.").arg(*dbIter));
+@@ -337,7 +337,7 @@ QTimer::singleShot(0, this, SLOT(syncApp
+ return;
+ 
+ 	PilotLocalDatabase*localDB=new PilotLocalDatabase(*dbIter, false);
+-	PilotSerialDatabase*serialDB=new PilotSerialDatabase(pilotSocket(), *dbIter);
++	PilotDatabase *serialDB=deviceLink()->database(*dbIter);
+ 
+ 	// open the local and the serial database and copy the flags over
+ 	// TODO: Implement the copying
+@@ -374,7 +374,7 @@ void InternalEditorAction::syncAppBlockC
+ #endif
+ 
+ 	PilotLocalDatabase*localDB=new PilotLocalDatabase(*dbIter, false);
+-	PilotSerialDatabase*serialDB=new PilotSerialDatabase(pilotSocket(), *dbIter);
++	PilotDatabase *serialDB=deviceLink()->database(*dbIter);
+ 
+ 	unsigned char*appBlock=new unsigned char[0xFFFF];
+ 	int len=localDB->readAppBlock(appBlock, 0xFFFF);
+diff -pruN kpilot/kpilot/internalEditorAction.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/internalEditorAction.h
+--- kpilot/kpilot/internalEditorAction.h	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/internalEditorAction.h	2006-11-19 22:21:12.000000000 +0100
+@@ -38,7 +38,7 @@ class InternalEditorAction : public Sync
+ Q_OBJECT
+ 
+ public:
+-	InternalEditorAction(KPilotDeviceLink *);
++	InternalEditorAction(KPilotLink *);
+ 	~InternalEditorAction() {}
+ 
+ protected:
+diff -pruN kpilot/kpilot/kpilot.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilot.cc
+--- kpilot/kpilot/kpilot.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilot.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -29,11 +29,9 @@
+ */
+ 
+ 
+-static const char *kpilot_id =
+-	"$Id: kpilot.cc 450702 2005-08-18 21:37:28Z adridg $";
+-
+-
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ #include <qfile.h>
+ #include <qptrlist.h>
+@@ -127,8 +125,6 @@ KPilotInstaller::KPilotInstaller() :
+ #endif
+ 	fConfigureKPilotDialogInUse = false;
+ 
+-	/* NOTREACHED */
+-	(void) kpilot_id;
+ }
+ 
+ KPilotInstaller::~KPilotInstaller()
+@@ -233,12 +229,14 @@ void KPilotInstaller::readConfig()
+ 
+ 	KPilotSettings::self()->readConfig();
+ 
+-	(void) PilotAppCategory::setupPilotCodec(KPilotSettings::encoding());
++	(void) Pilot::setupPilotCodec(KPilotSettings::encoding());
++	(void) Pilot::setupPilotCodec(KPilotSettings::encoding());
++
+ 	if (fLogWidget)
+ 	{
+ 		fLogWidget->addMessage(i18n("Using character set %1 on "
+ 			"the handheld.")
+-			.arg(PilotAppCategory::codecName()));
++			.arg(Pilot::codecName()));
+ 	}
+ }
+ 
+@@ -421,14 +419,6 @@ void KPilotInstaller::slotHotSyncRequest
+ 		i18n("Please press the HotSync button."));
+ }
+ 
+-void KPilotInstaller::slotFastSyncRequested()
+-{
+-	FUNCTIONSETUP;
+-	setupSync(SyncAction::SyncMode::eFastSync,
+-		i18n("Next sync will be a Fast Sync. ") +
+-		i18n("Please press the HotSync button."));
+-}
+-
+ void KPilotInstaller::slotFullSyncRequested()
+ {
+ 	FUNCTIONSETUP;
+@@ -594,14 +584,6 @@ void KPilotInstaller::initMenu()
+ 		"should be a normal HotSync."));
+ 	syncPopup->insert(a);
+ 
+-	a = new KAction(i18n("&FastSync"), CSL1("fastsync"), 0,
+-		this, SLOT(slotFastSyncRequested()),
+-		actionCollection(), "file_fastsync");
+-	a->setToolTip(i18n("Next HotSync will be a FastSync."));
+-	a->setWhatsThis(i18n("Tell the daemon that the next HotSync "
+-		"should be a FastSync (run conduits only)."));
+-	syncPopup->insert(a);
+-
+ 	a = new KAction(i18n("Full&Sync"), CSL1("fullsync"), 0,
+ 		this, SLOT(slotFullSyncRequested()),
+ 		actionCollection(), "file_fullsync");
+@@ -1064,7 +1046,7 @@ void KPilotInstaller::componentUpdate()
+ 	//
+ 	if (kind)
+ 	{
+-		return ::kpilot_id;
++		return "kpilot.cc";
+ 	}
+ 	else
+ 	{
+@@ -1110,7 +1092,7 @@ int main(int argc, char **argv)
+ 		KPILOT_VERSION,
+ 		"KPilot - HotSync software for KDE\n\n",
+ 		KAboutData::License_GPL,
+-		"(c) 1998-2000,2001, Dan Pilone (c) 2000-2004, Adriaan de Groot",
++		"(c) 1998-2000,2001, Dan Pilone (c) 2000-2006, Adriaan de Groot",
+ 		0L,
+ 		"http://www.kpilot.org/"
+ 		);
+@@ -1119,9 +1101,12 @@ int main(int argc, char **argv)
+ 		"pilone at slac.com" );
+ 	about.addAuthor("Adriaan de Groot",
+ 		I18N_NOOP("Maintainer"),
+-		"groot at kde.org", "http://www.cs.kun.nl/~adridg/");
++		"groot at kde.org", "http://www.kpilot.org/");
+ 	about.addAuthor("Reinhold Kainhofer",
+ 		I18N_NOOP("Core and conduits developer"), "reinhold at kainhofer.com", "http://reinhold.kainhofer.com/Linux/");
++	about.addAuthor("Jason 'vanRijn' Kasper",
++		I18N_NOOP("Core and conduits developer"),
++		"vR at movingparts.net", "http://movingparts.net/");
+ 	about.addCredit("Preston Brown", I18N_NOOP("VCal conduit"));
+ 	about.addCredit("Greg Stern", I18N_NOOP("Abbrowser conduit"));
+ 	about.addCredit("Chris Molnar", I18N_NOOP("Expenses conduit"));
+@@ -1135,6 +1120,8 @@ int main(int argc, char **argv)
+ 		I18N_NOOP(".ui files"));
+ 	about.addCredit("Aaron J. Seigo",
+ 		I18N_NOOP("Bugfixer, coolness"));
++	about.addCredit("Bertjan Broeksema", 
++		I18N_NOOP("VCalconduit state machine, CMake"));
+ 
+ 	KCmdLineArgs::init(argc, argv, &about);
+ 	KCmdLineArgs::addCmdLineOptions(kpilotoptions, "kpilot");
+@@ -1222,6 +1209,7 @@ int main(int argc, char **argv)
+ 		CSL1("share/apps/kpilot/DBBackup"));
+ 	tp->show();
+ 	a.setMainWidget(tp);
++	DEBUGKPILOT << fname << ": MINIICON = " << a.miniIconName() << endl;
+ 	return a.exec();
+ }
+ 
+diff -pruN kpilot/kpilot/kpilotConfig.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilotConfig.cc
+--- kpilot/kpilot/kpilotConfig.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilotConfig.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -45,8 +45,6 @@
+ #include "kpilotSettings.h"
+ #include "kpilotConfig.h"
+ 
+-static const char kpilotconfig_id[] =
+-	"$Id: kpilotConfig.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+ 
+ // This is a number indicating what configuration version
+ // we're dealing with. Whenever new configuration options are
+diff -pruN kpilot/kpilot/kpilotConfigDialog_backup.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilotConfigDialog_backup.ui
+--- kpilot/kpilot/kpilotConfigDialog_backup.ui	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilotConfigDialog_backup.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -1,4 +1,4 @@
+-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
++<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+ <class>BackupConfigWidget</class>
+ <comment>A widget for editing HotSync-specific settings.</comment>
+ <author>David Bishop</author>
+@@ -10,21 +10,79 @@
+         <rect>
+             <x>0</x>
+             <y>0</y>
+-            <width>593</width>
+-            <height>328</height>
++            <width>549</width>
++            <height>424</height>
+         </rect>
+     </property>
+     <property name="caption">
+         <string>KPilot Options</string>
+     </property>
+-    <grid>
++    <vbox>
+         <property name="name">
+             <cstring>unnamed</cstring>
+         </property>
+-        <property name="margin">
+-            <number>0</number>
+-        </property>
+-        <widget class="QGroupBox" row="0" column="0">
++        <widget class="QGroupBox">
++            <property name="name">
++                <cstring>GroupBox23_2</cstring>
++            </property>
++            <property name="title">
++                <string>Backup Frequency</string>
++            </property>
++            <hbox>
++                <property name="name">
++                    <cstring>unnamed</cstring>
++                </property>
++                <widget class="QLabel">
++                    <property name="name">
++                        <cstring>TextLabel5_2</cstring>
++                    </property>
++                    <property name="sizePolicy">
++                        <sizepolicy>
++                            <hsizetype>5</hsizetype>
++                            <vsizetype>5</vsizetype>
++                            <horstretch>0</horstretch>
++                            <verstretch>0</verstretch>
++                        </sizepolicy>
++                    </property>
++                    <property name="minimumSize">
++                        <size>
++                            <width>100</width>
++                            <height>0</height>
++                        </size>
++                    </property>
++                    <property name="text">
++                        <string>Do &amp;backup:</string>
++                    </property>
++                    <property name="buddy" stdset="0">
++                        <cstring>fBackupFrequency</cstring>
++                    </property>
++                </widget>
++                <widget class="QComboBox">
++                    <item>
++                        <property name="text">
++                            <string>On every HotSync</string>
++                        </property>
++                    </item>
++                    <item>
++                        <property name="text">
++                            <string>On request only</string>
++                        </property>
++                    </item>
++                    <property name="name">
++                        <cstring>fBackupFrequency</cstring>
++                    </property>
++                    <property name="sizePolicy">
++                        <sizepolicy>
++                            <hsizetype>7</hsizetype>
++                            <vsizetype>0</vsizetype>
++                            <horstretch>0</horstretch>
++                            <verstretch>0</verstretch>
++                        </sizepolicy>
++                    </property>
++                </widget>
++            </hbox>
++        </widget>
++        <widget class="QGroupBox">
+             <property name="name">
+                 <cstring>GroupBox23</cstring>
+             </property>
+@@ -39,6 +97,12 @@
+                     <property name="name">
+                         <cstring>TextLabel5</cstring>
+                     </property>
++                    <property name="minimumSize">
++                        <size>
++                            <width>100</width>
++                            <height>0</height>
++                        </size>
++                    </property>
+                     <property name="text">
+                         <string>&amp;No backup:</string>
+                     </property>
+@@ -53,6 +117,12 @@
+                     <property name="name">
+                         <cstring>TextLabel6</cstring>
+                     </property>
++                    <property name="minimumSize">
++                        <size>
++                            <width>100</width>
++                            <height>0</height>
++                        </size>
++                    </property>
+                     <property name="text">
+                         <string>Not &amp;restored:</string>
+                     </property>
+@@ -103,20 +173,23 @@
+                 </widget>
+             </grid>
+         </widget>
+-        <widget class="QCheckBox" row="1" column="0">
++        <widget class="QCheckBox">
+             <property name="name">
+                 <cstring>fRunConduitsWithBackup</cstring>
+             </property>
+             <property name="text">
+-                <string>Run &amp;conduits during a backup sync</string>
++                <string>Run conduits durin&amp;g a backup sync</string>
++            </property>
++            <property name="accel">
++                <string>Alt+G</string>
+             </property>
+             <property name="whatsThis" stdset="0">
+                 <string>&lt;qt&gt;Check this box to run the selected conduits before every backup. This makes sure the backup is up to date with the last changes from your PC.&lt;/qt&gt;</string>
+             </property>
+         </widget>
+-        <spacer row="2" column="0">
++        <spacer>
+             <property name="name">
+-                <cstring>spacer3</cstring>
++                <cstring>spacer8</cstring>
+             </property>
+             <property name="orientation">
+                 <enum>Vertical</enum>
+@@ -127,11 +200,11 @@
+             <property name="sizeHint">
+                 <size>
+                     <width>20</width>
+-                    <height>131</height>
++                    <height>41</height>
+                 </size>
+             </property>
+         </spacer>
+-    </grid>
++    </vbox>
+ </widget>
+ <layoutdefaults spacing="6" margin="11"/>
+ </UI>
+diff -pruN kpilot/kpilot/kpilotConfigDialog.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilotConfigDialog.cc
+--- kpilot/kpilot/kpilotConfigDialog.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilotConfigDialog.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -30,9 +30,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-static const char *kpilotconfigdialog_id =
+-	"$Id: kpilotConfigDialog.cc 438196 2005-07-24 15:42:44Z binner $";
+-
+ #include "options.h"
+ 
+ #include <pi-version.h>
+@@ -103,8 +100,6 @@ DeviceConfigPage::DeviceConfigPage(QWidg
+ #undef CM
+ 
+ 	fConduitName = i18n("Device");
+-
+-	(void) kpilotconfigdialog_id;
+ }
+ 
+ void DeviceConfigPage::load()
+@@ -242,7 +237,7 @@ SyncConfigPage::SyncConfigPage(QWidget *
+ 
+ #define CM(a,b) connect(fConfigWidget->a,b,this,SLOT(modified()));
+ 	CM(fSpecialSync, SIGNAL(activated(int)));
+-	CM(fFullBackupCheck, SIGNAL(toggled(bool)));
++	CM(fFullSyncCheck, SIGNAL(toggled(bool)));
+ 	CM(fScreenlockSecure, SIGNAL(toggled(bool)));
+ 	CM(fConflictResolution, SIGNAL(activated(int)));
+ #undef CM
+@@ -250,10 +245,9 @@ SyncConfigPage::SyncConfigPage(QWidget *
+ 	fConduitName = i18n("HotSync");
+ }
+ 
+-#define MENU_ITEM_COUNT (5)
++#define MENU_ITEM_COUNT (4)
+ static SyncAction::SyncMode::Mode syncTypeMap[MENU_ITEM_COUNT] = {
+ 	SyncAction::SyncMode::eHotSync,
+-	SyncAction::SyncMode::eFastSync,
+ 	SyncAction::SyncMode::eFullSync,
+ 	SyncAction::SyncMode::eCopyPCToHH,
+ 	SyncAction::SyncMode::eCopyHHToPC
+@@ -281,7 +275,7 @@ void SyncConfigPage::load()
+ 		fConfigWidget->fSpecialSync->setCurrentItem(0); /* HotSync */
+ 	}
+ 
+-	fConfigWidget->fFullBackupCheck->setChecked(KPilotSettings::fullSyncOnPCChange());
++	fConfigWidget->fFullSyncCheck->setChecked(KPilotSettings::fullSyncOnPCChange());
+ 	fConfigWidget->fConflictResolution->setCurrentItem(KPilotSettings::conflictResolution());
+ 	fConfigWidget->fScreenlockSecure->setChecked(KPilotSettings::screenlockSecure());
+ 
+@@ -305,7 +299,7 @@ void SyncConfigPage::load()
+ 	}
+ 
+ 	KPilotSettings::setSyncType(synctype);
+-	KPilotSettings::setFullSyncOnPCChange(fConfigWidget->fFullBackupCheck->isChecked());
++	KPilotSettings::setFullSyncOnPCChange(fConfigWidget->fFullSyncCheck->isChecked());
+ 	KPilotSettings::setConflictResolution(fConfigWidget->fConflictResolution->currentItem());
+ 	KPilotSettings::setScreenlockSecure(fConfigWidget->fScreenlockSecure->isChecked());
+ 
+@@ -315,7 +309,6 @@ void SyncConfigPage::load()
+ }
+ 
+ 
+-
+ BackupConfigPage::BackupConfigPage(QWidget * w, const char *n ) : ConfigPage( w, n )
+ {
+ 	FUNCTIONSETUP;
+@@ -332,6 +325,7 @@ BackupConfigPage::BackupConfigPage(QWidg
+ #define CM(a,b) connect(fConfigWidget->a,b,this,SLOT(modified()));
+ 	CM(fBackupOnly, SIGNAL(textChanged(const QString &)));
+ 	CM(fSkipDB, SIGNAL(textChanged(const QString &)));
++	CM(fBackupFrequency, SIGNAL(activated(int)));
+ #undef CM
+ 
+ 	fConduitName = i18n("Backup");
+@@ -346,6 +340,11 @@ void BackupConfigPage::load()
+ 	fConfigWidget->fBackupOnly->setText(KPilotSettings::skipBackupDB().join(CSL1(",")));
+ 	fConfigWidget->fSkipDB->setText(KPilotSettings::skipRestoreDB().join(CSL1(",")));
+ 	fConfigWidget->fRunConduitsWithBackup->setChecked(KPilotSettings::runConduitsWithBackup());
++
++	int backupfreq=KPilotSettings::backupFrequency();
++
++	fConfigWidget->fBackupFrequency->setCurrentItem(backupfreq);
++
+ 	unmodified();
+ }
+ 
+@@ -359,6 +358,7 @@ void BackupConfigPage::load()
+ 	KPilotSettings::setSkipRestoreDB(
+ 		QStringList::split(CSL1(","),fConfigWidget->fSkipDB->text()));
+ 	KPilotSettings::setRunConduitsWithBackup(fConfigWidget->fRunConduitsWithBackup->isChecked());
++	KPilotSettings::setBackupFrequency(fConfigWidget->fBackupFrequency->currentItem());
+ 
+ 	KPilotConfig::updateConfigVersion();
+ 	KPilotSettings::self()->writeConfig();
+@@ -500,9 +500,9 @@ void StartExitConfigPage::load()
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Autostart=" << autostart << endl;
+-	DEBUGDAEMON << fname << ": desktop=" << desktopfile << endl;
+-	DEBUGDAEMON << fname << ": location=" << location << endl;
++	DEBUGKPILOT << fname << ": Autostart=" << autostart << endl;
++	DEBUGKPILOT << fname << ": desktop=" << desktopfile << endl;
++	DEBUGKPILOT << fname << ": location=" << location << endl;
+ #endif
+ 
+ 	KPilotSettings::setStartDaemonAtLogin(fConfigWidget->fStartDaemonAtLogin->isChecked());
+diff -pruN kpilot/kpilot/kpilotConfigDialog_sync.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilotConfigDialog_sync.ui
+--- kpilot/kpilot/kpilotConfigDialog_sync.ui	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilotConfigDialog_sync.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -1,4 +1,4 @@
+-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
++<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+ <class>SyncConfigWidget</class>
+ <comment>A widget for editing HotSync-specific settings.</comment>
+ <author>David Bishop</author>
+@@ -26,29 +26,30 @@
+         </property>
+         <widget class="QCheckBox" row="1" column="1">
+             <property name="name">
+-                <cstring>fFullBackupCheck</cstring>
++                <cstring>fFullSyncCheck</cstring>
+             </property>
+             <property name="text">
+-                <string>&amp;Do full backup when changing PCs</string>
++                <string>Do full sync when chan&amp;ging PCs</string>
++            </property>
++            <property name="accel">
++                <string>Alt+G</string>
++            </property>
++            <property name="checked">
++                <bool>true</bool>
+             </property>
+             <property name="whatsThis" stdset="0">
+-                <string>&lt;qt&gt;Check this box to perform a full backup when your last sync was performed with another PC or system, to guarantee the completeness of your backup data.&lt;/qt&gt;</string>
++                <string>&lt;qt&gt;Check this box to perform a full sync when your last sync was performed with another PC or system, to guarantee the completeness of your data.&lt;/qt&gt;</string>
+             </property>
+         </widget>
+         <widget class="QComboBox" row="0" column="1">
+             <item>
+                 <property name="text">
+-                    <string>HotSync (sync all changes, update backup)</string>
+-                </property>
+-            </item>
+-            <item>
+-                <property name="text">
+-                    <string>FastSync (sync changes, no backup)</string>
++                    <string>HotSync (sync all changes)</string>
+                 </property>
+             </item>
+             <item>
+                 <property name="text">
+-                    <string>FullSync (sync also unchanged records, full backup)</string>
++                    <string>FullSync (sync also unchanged records)</string>
+                 </property>
+             </item>
+             <item>
+@@ -65,7 +66,7 @@
+                 <cstring>fSpecialSync</cstring>
+             </property>
+             <property name="whatsThis" stdset="0">
+-                <string>&lt;qt&gt;Select in this list the synchronization type that KPilot will use as default. Possibly values are:&lt;br&gt;"HotSync", to run all selected conduits, and sync the databases with a modified flag set, updating the modified records only;&lt;br&gt;"FastSync", to only synchronize those databases that have conduits;&lt;br&gt;"FullSync" to run all selected conduits, and sync all databases, reading all records, and performing a full backup;&lt;br&gt;"Copy PC to handheld" to run all conduits and sync all databases, but instead of merging the information from both sources, copy the PC data to the handheld;&lt;br&gt;"Copy handheld to PC" to run all conduits and sync all databases, but instead of merging the information from both sources, copy the handheld data to the PC.&lt;/qt&gt;</string>
++                <string>&lt;qt&gt;Select in this list the synchronization type that KPilot will use as default. Possible values are:&lt;br&gt;"HotSync", to run all selected conduits, and sync the databases with a modified flag set, updating the modified records only;&lt;br&gt;"FullSync" to run all selected conduits, and sync all databases, reading all records, and performing a full backup;&lt;br&gt;"Copy PC to handheld" to run all conduits and sync all databases, but instead of merging the information from both sources, copy the PC data to the handheld;&lt;br&gt;"Copy handheld to PC" to run all conduits and sync all databases, but instead of merging the information from both sources, copy the handheld data to the PC.&lt;/qt&gt;</string>
+             </property>
+         </widget>
+         <widget class="QLabel" row="0" column="0">
+diff -pruN kpilot/kpilot/kpilotConfigWizard.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilotConfigWizard.cc
+--- kpilot/kpilot/kpilotConfigWizard.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilotConfigWizard.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -26,9 +26,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-static const char *conduitconfigwizard_id =
+-	"$Id: kpilotConfigWizard.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ //#include "options.h"
+ 
+ #include <qpushbutton.h>
+@@ -78,7 +75,6 @@ ConfigWizard::ConfigWizard(QWidget *pare
+ 	page2->fDeviceName->setText( KPilotSettings::pilotDevice() );
+ 	page2->fPilotRunningPermanently->setChecked( KPilotSettings::startDaemonAtLogin() );
+ 
+-	(void) conduitconfigwizard_id;
+ }
+ 
+ ConfigWizard::~ConfigWizard()
+@@ -100,7 +96,7 @@ void ConfigWizard::accept()
+ 	app=(eSyncApp)( page3->fAppType->selectedId() );
+ 	bool keepPermanently( page2->fPilotRunningPermanently->isChecked() );
+ #ifdef DEBUG
+-	DEBUGCONDUIT<<fname<<"Keep permanently: "<<keepPermanently<<endl;
++	DEBUGKPILOT<<fname<<"Keep permanently: "<<keepPermanently<<endl;
+ #endif
+ 
+ 	KPilotSettings::setPilotDevice( devicename );
+diff -pruN kpilot/kpilot/kpilot.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilot.h
+--- kpilot/kpilot/kpilot.h	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilot.h	2006-11-19 22:21:12.000000000 +0100
+@@ -102,7 +102,6 @@ public slots:
+ 	void slotRestoreRequested();
+ 	void slotBackupRequested();
+ 	void slotHotSyncRequested();
+-	void slotFastSyncRequested();
+ 	void slotFullSyncRequested();
+ 	void slotHHtoPCRequested();
+ 	void slotPCtoHHRequested();
+diff -pruN kpilot/kpilot/kpilot.kcfg /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilot.kcfg
+--- kpilot/kpilot/kpilot.kcfg	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilot.kcfg	2006-11-19 22:21:12.000000000 +0100
+@@ -108,13 +108,17 @@
+     </entry>
+     <entry name="SkipBackupDB" type="StringList">
+         <label>Which databases not to backup.</label>
+-        <default>[Arng],[PmDB],[lnch],[a86k],FATFS,ImgFile-Foto,Jpeg-Foto</default>
++        <default>[Arng],[PmDB],[lnch],[a86k],FATFS,ImgFile-Foto,Jpeg-Foto,WifiCoreLib</default>
+     </entry>
+     <entry name="SkipRestoreDB" type="StringList">
+         <label>
+         </label>
+         <default>[AvGo]</default>
+     </entry>
++    <entry name="BackupFrequency" type="UInt">
++        <label></label>
++        <default>0</default>
++    </entry>
+     <entry name="RunConduitsWithBackup" type="Bool">
+         <label></label>
+         <default>false</default>
+diff -pruN kpilot/kpilot/kpilotProbeDialog.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilotProbeDialog.cc
+--- kpilot/kpilot/kpilotProbeDialog.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilotProbeDialog.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -48,12 +48,10 @@
+ #include "pilotUser.h"
+ #include "pilotSysInfo.h"
+ #include "options.h"
+-#include "kpilotlink.h"
++#include "kpilotdevicelink.h"
+ 
+ #include "kpilotProbeDialog.moc"
+-#ifndef __PILOTDAEMONDCOP_STUB__
+ #include "pilotDaemonDCOP_stub.h"
+-#endif
+ 
+ /*
+ We can't connect to /dev/ttyUSB0 and /dev/ttyUSB1 at the same time, because that
+@@ -277,10 +275,10 @@ void ProbeDialog::connection( KPilotDevi
+ 
+ 	mActiveLink = lnk;
+ 	if ( !mActiveLink ) return;
+-	KPilotUser*usr( mActiveLink->getPilotUser() );
++	const KPilotUser &usr( mActiveLink->getPilotUser() );
+ 
+-	mUserName = usr->getUserName();
+-	mUID = usr->getUserID();
++	mUserName = usr.getUserName();
++	mUID = usr.getUserID();
+ 	mDevice = mActiveLink->pilotPath();
+ 
+ 	fStatus->setText( i18n("Found a connected device on %1").arg(mDevice) );
+@@ -296,23 +294,20 @@ void ProbeDialog::connection( KPilotDevi
+ 
+ void ProbeDialog::retrieveDBList()
+ {
+-	QPtrList<DBInfo> dbs = mActiveLink->getDBList();
++	DBInfoList dbs = mActiveLink->getDBList();
+ 	mDBs.clear();
+-	dbs.setAutoDelete( true );
+ 	char buff[7];
+ 	buff[0] = '[';
+ 
+-	DBInfo *dbi;
+-	for ( dbi = dbs.first(); dbi; dbi = dbs.next() ) {
+-		if ( dbi ) {
+-			set_long( &buff[1], dbi->creator );
+-			buff[5] = ']';
+-			buff[6] = '\0';
+-			QString cr( buff );
+-			mDBs << cr;
+-			dbi->name[33]='\0';
+-			mDBs << QString( dbi->name );
+-		}
++	for ( DBInfoList::ConstIterator i = dbs.begin();
++		i != dbs.end(); ++i )
++	{
++		set_long( &buff[1], (*i).creator );
++		buff[5] = ']';
++		buff[6] = '\0';
++		QString cr( buff );
++		mDBs << cr;
++		mDBs << QString( (*i).name );
+ 	}
+ 	mDBs.sort();
+ 	
+diff -pruN kpilot/kpilot/kpilotui.rc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kpilotui.rc
+--- kpilot/kpilot/kpilotui.rc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kpilotui.rc	2006-11-19 22:21:12.000000000 +0100
+@@ -5,7 +5,6 @@
+   <Menu name="file" noMerge="1"><text>&amp;File</text>
+     <!-- Keep this list synchronized with pilotDaemon.cc and kpilot.cc -->
+     <Action name="file_hotsync" />
+-    <Action name="file_fastsync" />
+     <Action name="file_fullsync" />
+     <Action name="file_backup" />
+     <Action name="file_restore" />
+@@ -28,7 +27,6 @@
+ 
+ <Menu name="rb_popup">
+   <Action name="file_hotsync" />
+-  <Action name="file_fastsync" />
+   <Action name="file_backup" />
+   <Action name="file_restore" />
+   <Separator />
+diff -pruN kpilot/kpilot/kroupware.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/kroupware.cc
+--- kpilot/kpilot/kroupware.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/kroupware.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -40,15 +40,12 @@
+ #include "kroupware.h"
+ #include "kpilotConfig.h"
+ 
+-static const char *kroupware_id =
+-	"$Id: kroupware.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ KroupwareSync::KroupwareSync(bool pre,int parts,KPilotDeviceLink *p) :
+ 	SyncAction(p,pre ? "KroupwarePreSync" : "KroupwarePostSync"),
+ 	fPre(pre),
+ 	fParts(parts)
+ {
+-	(void) kroupware_id;
++
+ }
+ 
+ /* virtual */ bool KroupwareSync::exec()
+diff -pruN kpilot/kpilot/listCat.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/listCat.cc
+--- kpilot/kpilot/listCat.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/listCat.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,9 +28,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-static const char *listCat_id =
+-	"$Id: listCat.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ #include "options.h"
+ 
+ #include <qpainter.h>
+@@ -46,7 +43,6 @@ ListCategorizer::ListCategorizer(QWidget
+ {
+ 	FUNCTIONSETUP;
+ 	setupWidget();
+-	(void) listCat_id;
+ }
+ 
+ ListCategorizer::ListCategorizer(const QStringList & i,
+@@ -240,7 +236,7 @@ void RichListViewItem::computeHeight(int
+ 	for (int i=0; i<fColumns; i++)
+ 	{
+ 		computeHeight(i);
+-		h = QMAX(h,fRect[i].height()+2*RVPAD);
++		h = kMax(h,fRect[i].height()+2*RVPAD);
+ 	}
+ 
+ 	setHeight(h);
+diff -pruN kpilot/kpilot/listItems.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/listItems.cc
+--- kpilot/kpilot/listItems.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/listItems.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -27,9 +27,6 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
+-static const char *listitems_id =
+-	"$Id: listItems.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ #include "options.h"
+ 
+ 
+@@ -68,7 +65,6 @@ PilotListItem::PilotListItem(const QStri
+ 	if (!(count & 0xff))
+ 		counts();
+ #endif
+-	(void) listitems_id;
+ }
+ 
+ PilotListItem::~PilotListItem()
+@@ -110,7 +106,6 @@ PilotCheckListItem::PilotCheckListItem(Q
+ 	if (!(count & 0xff))
+ 		counts();
+ #endif
+-	(void) listitems_id;
+ }
+ 
+ PilotCheckListItem::~PilotCheckListItem()
+@@ -164,7 +159,6 @@ PilotListViewItem::PilotListViewItem( QL
+ 	if (!(count & 0xff))
+ 		counts();
+ #endif
+-	(void) listitems_id;
+ }
+ 
+ PilotListViewItem::~PilotListViewItem()
+diff -pruN kpilot/kpilot/logFile.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/logFile.cc
+--- kpilot/kpilot/logFile.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/logFile.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -27,8 +27,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org.
+ */
+-static const char *logf_id =
+-	"$Id: logFile.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+ 
+ #include "options.h"
+ 
+@@ -50,7 +48,6 @@ static const char *logf_id =
+ LogFile::LogFile() : DCOPObject("LogIface"), QObject(), fOutfile(0L), fSyncing(false)
+ {
+ 	FUNCTIONSETUP;
+-	(void) logf_id;
+ }
+ 
+ 
+diff -pruN kpilot/kpilot/logWidget.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/logWidget.cc
+--- kpilot/kpilot/logWidget.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/logWidget.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -26,8 +26,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org.
+ */
+-static const char *logw_id =
+-	"$Id: logWidget.cc 438196 2005-07-24 15:42:44Z binner $";
+ 
+ #include "options.h"
+ 
+@@ -211,7 +209,6 @@ LogWidget::LogWidget(QWidget * parent) :
+ 		grid->addColSpacing(3,10);
+ 	}
+ 
+-	(void) logw_id;
+ }
+ 
+ void LogWidget::addMessage(const QString & s)
+diff -pruN kpilot/kpilot/main-test.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/main-test.cc
+--- kpilot/kpilot/main-test.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/main-test.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -29,8 +29,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org.
+ */
+-static const char *test_id =
+-	"$Id: main-test.cc 449698 2005-08-16 13:24:56Z adridg $";
+ 
+ #include "options.h"
+ 
+@@ -52,29 +50,43 @@ static const char *test_id =
+ 
+ #include <pi-version.h>
+ 
+-#include "logWidget.h"
+ #include "kpilotConfig.h"
+ #include "syncStack.h"
+ #include "hotSync.h"
+ #include "interactiveSync.h"
+ 
+-static KCmdLineOptions kpilotoptions[] = {
++#include "kpilotdevicelink.h"
++#include "kpilotlocallink.h"
++
++static KCmdLineOptions generalOptions[] = {
+ 	{"p",0,0},
+ 	{"port <device>",
+ 		I18N_NOOP("Path to Pilot device node"),
+ 		"/dev/pilot"},
+ 	{"l",0,0},
+-	{"list", I18N_NOOP("List DBs (default)"), 0},
++	{"list", I18N_NOOP("List DBs"), 0},
+ 	{"b",0,0},
+-	{"backup", I18N_NOOP("Backup instead of list DBs"), 0},
++	{"backup <dest dir>", I18N_NOOP("Backup Pilot to <dest dir>"), 0},
+ 	{"r",0,0},
+-	{"restore", I18N_NOOP("Restore Pilot from backup"), 0},
+-	{"L",0,0},
+-	{ "conduit-list", I18N_NOOP("List available conduits"), 0},
+-	{"E",0,0},
+-	{ "conduit-exec <filename>",
++	{"restore <src dir>", I18N_NOOP("Restore Pilot from backup"), 0},
++	{"e",0,0},
++	{ "exec <filename>",
+ 		I18N_NOOP("Run conduit from desktop file <filename>"),
+ 		0 },
++	{"c",0,0},
++	{ "check <what>",
++		I18N_NOOP("Run a specific check (with the device)"), "help"},
++	{"s",0,0},
++	{ "show <what>",
++		I18N_NOOP("Show KPilot configuration information"), "help"},
++#ifdef DEBUG
++	{ "debug <level>",
++		I18N_NOOP("Set the debug level"), "1" },
++#endif
++	KCmdLineLastOption
++} ;
++
++static KCmdLineOptions conduitOptions[] = {
+ 	{ "T",0,0},
+ 	{ "notest",
+ 		I18N_NOOP("*Really* run the conduit, not in test mode."),
+@@ -89,217 +101,155 @@ static KCmdLineOptions kpilotoptions[] =
+ 	{ "PCtoHH",
+ 		I18N_NOOP("Copy Desktop to Pilot."),
+ 		0 } ,
+-	{ "test-timeout",
+-		I18N_NOOP("Run conduit specially designed to timeout."),
+-		0 } ,
+-	{ "test-usercheck",
+-		I18N_NOOP("Run conduit just for user check."),
+-		0 } ,
+-	{ "dump-calendar",
+-		I18N_NOOP("Dump calendar to stdout."),
++	{ "loop",
++		I18N_NOOP("Repeated perform action - only useful for --list"),
+ 		0 } ,
+-#ifdef DEBUG
+-	{"debug <level>", I18N_NOOP("Set debugging level"), "0"},
+-#endif
+ 	KCmdLineLastOption
+-};
+-
+-
+-static LogWidget *logWidget = 0L;
+-static QPushButton *resetButton = 0L;
+-
+-
++} ;
+ 
+ /**
+ *** Conduits - sync actions - for testing specific scenarios.
+ **/
+ 
+-class TimeoutAction : public SyncAction
+-{
+-public:
+-	TimeoutAction(KPilotDeviceLink *p) ;
+-protected:
+-	virtual bool exec();
+-} ;
+ 
+-TimeoutAction::TimeoutAction(KPilotDeviceLink *p) :
+-	SyncAction(p)
++
++KPilotLink *createLink( bool local )
+ {
+ 	FUNCTIONSETUP;
++	if (!local)
++	{
++		return new KPilotDeviceLink(0, "deviceLink");
++	}
++	else
++	{
++		return new KPilotLocalLink(0, "localLink");
++	}
+ }
+ 
+-bool TimeoutAction::exec()
++/** If @p loop is true, then instead of quitting at end of
++*   sync, wait for a new sync just like the real daemon does.
++*/
++void connectStack( KPilotLink *l, ActionQueue *a, bool loop = false )
+ {
+ 	FUNCTIONSETUP;
+ 
+-	for (int i = 0; i<3; i++)
++	if (l && a)
+ 	{
+-		logMessage( CSL1("Hup two %1").arg(i) );
+-		fHandle->tickle();
+-		qApp->processEvents();
+-		sleep(1);
++		QObject::connect(a, SIGNAL(syncDone(SyncAction *)),
++			l, SLOT(close()));
++		if (!loop)
++		{
++			QObject::connect(a, SIGNAL(syncDone(SyncAction *)),
++				kapp, SLOT(quit()));
++		}
++		else
++		{
++			QObject::connect(a, SIGNAL(syncDone(SyncAction *)),
++				l, SLOT(reset()));
++		}
++		QObject::connect(l, SIGNAL(deviceReady(KPilotLink*)),
++			a, SLOT(execConduit()));
+ 	}
+-
+-	logMessage( CSL1("Now sleeping 65") );
+-	qApp->processEvents();
+-	sleep(65);
+-	return delayDone();
+ }
+ 
+ 
+ 
+-
+-
+-
+-
+-void createLogWidget()
+-{
+-	LogWidget *w = new LogWidget(0L);
+-
+-	w->resize(300, 300);
+-	w->show();
+-	w->setShowTime(true);
+-	kapp->setMainWidget(w);
+-	logWidget = w;
+-
+-	resetButton = new QPushButton(i18n("Reset"),w->buttonBox());
+-}
+-
+-static KPilotDeviceLink *deviceLink = 0L;
+-
+-void createLink()
++int exec(const QString &device, const QString &what, KCmdLineArgs *p)
+ {
+ 	FUNCTIONSETUP;
+ 
+-	deviceLink = new KPilotDeviceLink(0, "deviceLink");
++	// get --exec-conduit value
++	if (what.isEmpty()) return 1;
++	QStringList l;
++	l.append(what);
+ 
+-	QObject::connect(deviceLink, SIGNAL(logError(const QString &)),
+-		logWidget, SLOT(addError(const QString &)));
+-	QObject::connect(deviceLink, SIGNAL(logMessage(const QString &)),
+-		logWidget, SLOT(addMessage(const QString &)));
+-	QObject::connect(deviceLink,SIGNAL(logProgress(const QString &,int)),
+-		logWidget, SLOT(addProgress(const QString &,int)));
++	SyncAction::SyncMode::Mode syncMode = SyncAction::SyncMode::eHotSync;
++	if (p->isSet("HHtoPC")) syncMode = SyncAction::SyncMode::eCopyHHToPC;
++	if (p->isSet("PCtoHH")) syncMode = SyncAction::SyncMode::eCopyPCToHH;
++	SyncAction::SyncMode mode(syncMode,p->isSet("test"),p->isSet("local"));
+ 
++	KPilotLink *link = createLink( p->isSet("local") );
++	ActionQueue *syncStack = new ActionQueue( link );
++	syncStack->queueInit( ActionQueue::queueCheckUser );
++	syncStack->queueConduits(l,mode,false);
++	syncStack->queueCleanup();
++	connectStack(link,syncStack);
++	link->reset(device);
++	return kapp->exec();
+ }
+ 
+-static ActionQueue *syncStack = 0L;
+-
+-void connectStack()
++int backup(const QString &device, const QString &what, KCmdLineArgs *p)
+ {
+ 	FUNCTIONSETUP;
+-
+-	QObject::connect(syncStack, SIGNAL(logError(const QString &)),
+-		logWidget, SLOT(addError(const QString &)));
+-	QObject::connect(syncStack, SIGNAL(logMessage(const QString &)),
+-		logWidget, SLOT(addMessage(const QString &)));
+-	QObject::connect(syncStack,SIGNAL(logProgress(const QString &,int)),
+-		logWidget, SLOT(addProgress(const QString &,int)));
+-	QObject::connect(syncStack, SIGNAL(syncDone(SyncAction *)),
+-		logWidget, SLOT(syncDone()));
+-
+-	if (deviceLink)
+-	{
+-		QObject::connect(syncStack, SIGNAL(syncDone(SyncAction *)),
+-			deviceLink, SLOT(close()));
+-		QObject::connect(deviceLink, SIGNAL(deviceReady(KPilotDeviceLink*)), syncStack, SLOT(execConduit()));
+-		QObject::connect(resetButton,SIGNAL(clicked()),deviceLink,SLOT(reset()));
+-	}
++	KPilotLink *link = createLink( p->isSet("local") );
++	ActionQueue *syncStack = new ActionQueue( link );
++	syncStack->queueInit();
++	BackupAction *ba = new BackupAction( link, true /* full backup */ );
++	ba->setDirectory( what );
++	syncStack->addAction( ba );
++	syncStack->queueCleanup();
++	connectStack(link,syncStack);
++	link->reset(device);
++	return kapp->exec();
+ }
+ 
+-void createConnection(KCmdLineArgs *p)
++int restore(const QString &device, const QString &what, KCmdLineArgs *p)
+ {
+ 	FUNCTIONSETUP;
+-
+-	QString devicePath = p->getOption("port");
+-
+-	if (devicePath.isEmpty())
+-	{
+-		devicePath = "/dev/pilot";
+-	}
+-
+-	deviceLink->reset(devicePath);
++	KPilotLink *link = createLink( p->isSet("local") );
++	ActionQueue *syncStack = new ActionQueue( link );
++	syncStack->queueInit();
++	RestoreAction *ra = new RestoreAction( link );
++	ra->setDirectory( what );
++	syncStack->addAction( ra );
++	syncStack->queueCleanup();
++	connectStack(link,syncStack);
++	link->reset(device);
++	return kapp->exec();
+ }
+ 
+-int syncTest(KCmdLineArgs *p)
++int listDB(const QString &device, KCmdLineArgs *p)
+ {
+ 	FUNCTIONSETUP;
+-
+-	createLogWidget();
+-	createLink();
+-
+-	syncStack = new ActionQueue(deviceLink);
+-
+-	if (p->isSet("backup"))
+-	{
+-		syncStack->queueInit();
+-		syncStack->addAction(new BackupAction(deviceLink,true));
+-	}
+-	else if (p->isSet("restore"))
+-	{
+-		syncStack->queueInit(0);
+-		syncStack->addAction(new RestoreAction(deviceLink));
+-	}
+-	else if (p->isSet("test-timeout"))
+-	{
+-		syncStack->queueInit();
+-		syncStack->addAction( new TimeoutAction(deviceLink) );
+-		syncStack->addAction( new TimeoutAction(deviceLink) );
+-	}
+-	else
+-	{
+-		syncStack->queueInit(p->isSet("test-usercheck") /* whether to run usercheck */);
+-		syncStack->addAction(new TestLink(deviceLink));
+-	}
++	KPilotLink *link = createLink( p->isSet("local") );
++	ActionQueue *syncStack = new ActionQueue( link );
++	syncStack->queueInit();
++	syncStack->addAction( new TestLink( link ) );
+ 	syncStack->queueCleanup();
+-
+-	connectStack();
+-	createConnection(p);
++	connectStack(link,syncStack, p->isSet("loop") );
++	link->reset(device);
+ 	return kapp->exec();
+ }
+ 
+-int execConduit(KCmdLineArgs *p)
++int check( const QString &device, const QString &what, KCmdLineArgs *p )
+ {
+ 	FUNCTIONSETUP;
+ 
+-	// get --exec-conduit value
+-	QString s = p->getOption("conduit-exec");
+-	if (s.isEmpty()) return 1;
+-	QStringList l;
+-	l.append(s);
+-
+-	createLogWidget();
+-
+-	SyncAction::SyncMode::Mode syncMode = SyncAction::SyncMode::eHotSync;
+-	if (p->isSet("HHtoPC")) syncMode = SyncAction::SyncMode::eCopyHHToPC;
+-	if (p->isSet("PCtoHH")) syncMode = SyncAction::SyncMode::eCopyPCToHH;
+-	SyncAction::SyncMode mode(syncMode,p->isSet("test"),p->isSet("local"));
+-
+-	if (!p->isSet("local"))
+-	{
+-		createLink();
+-
+-		syncStack = new ActionQueue(deviceLink);
+-		syncStack->queueInit();
+-		syncStack->queueConduits(l,mode,false);
+-		syncStack->queueCleanup();
+-		connectStack();
+-		createConnection(p);
+-	}
+-	else
++	if ( "help" == what )
+ 	{
+-		syncStack = new ActionQueue( 0L );
+-		syncStack->queueInit();
+-		syncStack->queueConduits(l,mode,false);
++		std::cout <<
++"You can use the --check option to kpilotTest to run various\n"
++"small checks that require the use of the device. These are:\n"
++"\thelp - show this help\n"
++"\tuser - check the user name on the handheld\n"
++		<< std::endl;
++		return 0;
++	}
++
++	if ( "user" == what )
++	{
++		KPilotLink *link = createLink( p->isSet("local") );
++		ActionQueue *syncStack = new ActionQueue( link );
++		syncStack->queueInit( ActionQueue::queueCheckUser ); // Creates usercheck
+ 		syncStack->queueCleanup();
+-		connectStack();
+-		QTimer::singleShot(100,syncStack,SLOT(execConduit()));
++		connectStack(link,syncStack);
++		link->reset(device);
++		return kapp->exec();
+ 	}
+ 
+-
+-	return kapp->exec();
+ }
+ 
+-int listConduits(KCmdLineArgs *)
++void listConduits()
+ {
+ 	FUNCTIONSETUP;
+ 
+@@ -315,23 +265,78 @@ int listConduits(KCmdLineArgs *)
+ 	{
+ 		KSharedPtr < KService > o = (*availList).service();
+ 
+-		std::cout << o->desktopEntryName().latin1() << std::endl;
+-		std::cout << "\t" << o->name().latin1()  << std::endl;
++		std::cout << "File:   " << o->desktopEntryName().latin1() << std::endl;
++		std::cout << "  Desc: " << o->name().latin1()  << std::endl;
+ 		if (!o->library().isEmpty())
+ 		{
+-			std::cout << "\tIn "
++			std::cout << "  Lib : "
+ 				<< o->library().latin1()
+ 				<< std::endl;
+ 		}
+ 
+ 		++availList;
+ 	}
++}
++
++int show( const QString &what )
++{
++	FUNCTIONSETUP;
+ 
+-	return 0;
++	if ( "help" == what )
++	{
++		std::cout <<
++"Displays various bits of KPilot's internal settings. This\n"
++"does not require a device connection or a running KDE desktop.\n"
++"No change to data takes place. The following options are available\n"
++"for display:\n"
++"\thelp     - displays this help\n"
++"\tconduits - displays the list of available conduits\n"
++"\tuser     - displays the user name KPilot expects\n"
++"\tdevice   - displays the device settings in KPilot\n"
++"\tdebug    - displays internal numbers\n"
++		<< std::endl;
++		return 0;
++	}
++
++	if ( "conduits" == what )
++	{
++		listConduits();
++		return 0;
++	}
++
++	if ( "user" == what )
++	{
++		std::cout << "User: " << KPilotSettings::userName() << std::endl;
++		return 0;
++	}
++
++	if ( "device" == what )
++	{
++		std::cout << "Device:   " << KPilotSettings::pilotDevice()
++			<< "\nSpeed:    " << KPilotSettings::pilotSpeed()
++			<< "\nEncoding: " << KPilotSettings::encoding()
++			<< "\nQuirks:   " << KPilotSettings::workarounds()
++			<< std::endl;
++		return 0;
++	}
++
++	if ( "debug" == what )
++	{
++		std::cout << "Debug:  " << KPilotSettings::debug()
++			<< "\nConfig: " << KPilotSettings::configVersion()
++			<< std::endl;
++		return 0;
++	}
++
++	std::cerr << "Unknown --show argument, use --show help for help.\n";
++	return 1;
+ }
+ 
+ int main(int argc, char **argv)
+ {
++#ifdef DEBUG
++	debug_level = 1;
++#endif
+ 	FUNCTIONSETUP;
+ 	KAboutData about("kpilotTest",
+ 		I18N_NOOP("KPilotTest"),
+@@ -340,43 +345,88 @@ int main(int argc, char **argv)
+ 		KAboutData::License_GPL, "(C) 2001-2004, Adriaan de Groot");
+ 	about.addAuthor("Adriaan de Groot",
+ 		I18N_NOOP("KPilot Maintainer"),
+-		"groot at kde.org", "http://www.cs.kun.nl/~adridg/kpilot/");
++		"groot at kde.org", "http://www.kpilot.org/");
+ 
+ 	KCmdLineArgs::init(argc, argv, &about);
+-	KCmdLineArgs::addCmdLineOptions(kpilotoptions, "kpilottest");
++	KCmdLineArgs::addCmdLineOptions(generalOptions,
++		I18N_NOOP("General"));
++	KCmdLineArgs::addCmdLineOptions(conduitOptions,
++		I18N_NOOP("Conduit Actions"),"conduit");
++
+ 	KApplication::addCmdLineOptions();
+ 
+ 	KCmdLineArgs *p = KCmdLineArgs::parsedArgs();
+ 
++	bool needGUI = false;
+ 
+-	KApplication a;
++	// Some versions need a GUI
++	needGUI |= (p->isSet("check"));
++	needGUI |= (p->isSet("exec")); // assume worst wrt. conduits
++	needGUI |= (p->isSet("restore"));
++
++	KApplication a(needGUI,needGUI);
+ #ifdef DEBUG
+ 	KPilotConfig::getDebugLevel(p);
++	DEBUGKPILOT  << fname << "Created KApplication." << endl;
+ #endif
+ 
+-	if ( p->isSet("backup") ||
+-		p->isSet("restore") ||
+-		p->isSet("list") ||
+-		p->isSet("test-timeout") ||
+-		p->isSet("test-usercheck") )
++
++	unsigned int count = 0;
++	QString device( "/dev/pilot" );
++
++	if ( p->isSet("port") )
++	{
++		device = p->getOption("port");
++	}
++
++	if ( p->isSet("check") )
+ 	{
+-		return syncTest(p);
++		return check( device, p->getOption("check"),
++			KCmdLineArgs::parsedArgs("conduit") );
+ 	}
+ 
+-	if (p->isSet("conduit-list"))
++	if ( p->isSet("show") )
+ 	{
+-		return listConduits(p);
++		return show( p->getOption("show") );
+ 	}
+ 
+-	if (p->isSet("conduit-exec"))
++	if ( p->isSet("exec") )
+ 	{
+-		return execConduit(p);
++		return exec( device, p->getOption("exec"),
++			KCmdLineArgs::parsedArgs("conduit") );
+ 	}
+ 
+-	// The default is supposed to be "list"
+-	return syncTest(p);
+-	/* NOTREACHED */
+-	(void) test_id;
++	if ( p->isSet("list") )
++	{
++		return listDB( device,
++			KCmdLineArgs::parsedArgs("conduit") );
++	}
++
++	if ( p->isSet("backup") )
++	{
++		return backup( device, p->getOption("backup"),
++			KCmdLineArgs::parsedArgs("conduit") );
++	}
++
++	if ( p->isSet("restore") )
++	{
++		return restore( device, p->getOption("restore"),
++			KCmdLineArgs::parsedArgs("conduit") );
++	}
++
++
++
++	std::cout <<
++"Usage: kpilotTest [--port devicename] action\n\n"
++"Where action can be one of:\n"
++"\t--list - list the databases on the handheld\n"
++"\t--show (help | conduits | ...) - show configuration\n"
++"\t--check (help | user | ...) - check device\n"
++"\t--exec conduit - run a single conduit\n"
++"\t--backup - backup the device\n"
++"\t--restore - restore the device from backup\n"
++	<< std::endl;
++	return 1;
+ }
+ 
+ 
+diff -pruN kpilot/kpilot/memoWidget.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/memoWidget.cc
+--- kpilot/kpilot/memoWidget.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/memoWidget.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -27,10 +27,10 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *memowidget_id =
+-	"$Id: memoWidget.cc 444756 2005-08-10 13:35:01Z mlaurent $";
+ 
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ #include <time.h>
+ 
+@@ -47,7 +47,6 @@ static const char *memowidget_id =
+ #include <qtextstream.h>
+ #include <qwhatsthis.h>
+ #include <qlabel.h>
+-#include <qtextcodec.h>
+ #include <qdatetime.h>
+ #include <qptrlist.h>
+ 
+@@ -91,9 +90,6 @@ MemoWidget::MemoWidget(QWidget * parent,
+ 	setupWidget();
+ 	d->fMemoList.setAutoDelete(true);
+ 	slotUpdateButtons();
+-
+-	/* NOTREACHED */
+-	(void) memowidget_id;
+ }
+ 
+ MemoWidget::~MemoWidget()
+@@ -178,7 +174,7 @@ void MemoWidget::showComponent()
+ 	//
+ 	PilotLocalDatabase *memoDB =
+ 		new PilotLocalDatabase(dbPath(), CSL1("MemoDB"));
+-	if (memoDB == NULL || !memoDB->isDBOpen())
++	if (memoDB == NULL || !memoDB->isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo <<
+ 			": Can't open local database MemoDB\n";
+@@ -366,7 +362,7 @@ void MemoWidget::slotDeleteMemo()
+ 		DEBUGKPILOT << fname << ": Searching for record to delete (it's fresh)" << endl;
+ #endif
+ 		PilotLocalDatabase *memoDB = new PilotLocalDatabase(dbPath(), CSL1("MemoDB"));
+-		if (!memoDB || (!memoDB->isDBOpen()))
++		if (!memoDB || (!memoDB->isOpen()))
+ 		{
+ 			// Err.. peculiar.
+ 			kdWarning() << k_funcinfo << ": Can't open MemoDB" << endl;
+@@ -554,8 +550,8 @@ void MemoWidget::saveChangedMemo()
+ 		(PilotListItem *) fListBox->item(lastSelectedMemo);
+ 	PilotMemo *currentMemo = (PilotMemo *) p->rec();
+ 
+-	currentMemo->setText(PilotAppCategory::codec()->
+-		fromUnicode(fTextWidget->text()));
++// TODO: overload setText in PilotMemo
++	currentMemo->setText(Pilot::toPilot(fTextWidget->text()));
+ 	writeMemo(currentMemo);
+ }
+ 
+@@ -574,21 +570,17 @@ bool MemoWidget::addMemo(const QString &
+ 	{
+ 		return false;
+ 	}
+-	if ((category<0) || (category>=PILOT_CATEGORY_MAX)) category=0;
+-
+-	char *text = new char[s.length() + 2];
+-	if (s.isEmpty())
++	if ((category<0) || (category>=(int)Pilot::CATEGORY_COUNT))
+ 	{
+-		text[0]=0;
++		category=Pilot::Unfiled;
+ 	}
+-	else
+-	{
+-		strlcpy(text,PilotAppCategory::codec()->fromUnicode(s),s.length()+2);
+-	}
+-	PilotMemo *aMemo = new PilotMemo(text, 0, 0, category);
++
++	PilotMemo *aMemo = new PilotMemo();
++	aMemo->setCategory(category);
++	aMemo->setText(s);
++
+ 	d->fMemoList.append(aMemo);
+ 	writeMemo(aMemo);
+-	delete[]text;
+ 	updateWidget();
+ #ifdef DEBUG
+ 	DEBUGKPILOT << fname << ": New memo @" << (void *)aMemo << endl;
+diff -pruN kpilot/kpilot/pilotComponent.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/pilotComponent.cc
+--- kpilot/kpilot/pilotComponent.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/pilotComponent.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -37,19 +37,15 @@
+ 
+ #include <qwidget.h>
+ #include <qcombobox.h>
+-#include <qtextcodec.h>
+ 
+ #include <kdebug.h>
+ 
+ #include "kpilotConfig.h"
+-#include "pilotAppCategory.h"
+-#include "pilotDatabase.h"
++#include "pilotRecord.h"
++#include "pilot.h"
+ 
+ #include "pilotComponent.moc"
+ 
+-static const char *pilotComponent_id =
+-	"$Id: pilotComponent.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+ PilotComponent::PilotComponent(QWidget * parent,
+ 	const char *id,
+ 	const QString & path) :
+@@ -65,7 +61,6 @@ PilotComponent::PilotComponent(QWidget *
+ 			parent->geometry().height());
+ 	}
+ 
+-	(void) pilotComponent_id;
+ }
+ 
+ 
+@@ -108,7 +103,7 @@ int PilotComponent::findSelectedCategory
+ 	{
+ 		QString selectedCategory =
+ 			fCatList->text(fCatList->currentItem());
+-		currentCatID = PilotAppInfoBase::findCategory(selectedCategory, AllIsUnfiled, info);
++		currentCatID = Pilot::findCategory(info, selectedCategory, AllIsUnfiled);
+ 	}
+ 
+ 	if ((currentCatID == -1) && AllIsUnfiled)
+@@ -139,7 +134,7 @@ void PilotComponent::populateCategories(
+ 	// the user uses, so no translation is necessary.
+ 	//
+ 	//
+-	for (int i = 0; i < PILOT_CATEGORY_MAX; i++)
++	for (unsigned int i = 0; i < Pilot::CATEGORY_COUNT; i++)
+ 	{
+ 		if (info->name[i][0])
+ 		{
+@@ -150,7 +145,7 @@ void PilotComponent::populateCategories(
+ 				<< " with ID: " << (int) info->ID[i] << endl;
+ #endif
+ 
+-			c->insertItem(PilotAppCategory::codec()->toUnicode(info->name[i]));
++			c->insertItem(Pilot::fromPilot(info->name[i]));
+ 		}
+ 	}
+ 
+diff -pruN kpilot/kpilot/pilotDaemon.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/pilotDaemon.cc
+--- kpilot/kpilot/pilotDaemon.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/pilotDaemon.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,8 +28,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *pilotdaemon_id =
+-	"$Id: pilotDaemon.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+ 
+ #include "options.h"
+ 
+@@ -54,11 +52,13 @@ static const char *pilotdaemon_id =
+ #include <kapplication.h>
+ #include <khelpmenu.h>
+ 
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ 
+ #include "fileInstaller.h"
+ #include "pilotUser.h"
+ #include "pilotDatabase.h"
++#include "kpilotlink.h"
++#include "kpilotdevicelink.h"
+ 
+ #include "hotSync.h"
+ #include "interactiveSync.h"
+@@ -87,10 +87,6 @@ PilotDaemonTray::PilotDaemonTray(PilotDa
+ 	FUNCTIONSETUP;
+ 	setupWidget();
+ 	setAcceptDrops(true);
+-
+-
+-	/* NOTREACHED */
+-	(void) pilotdaemon_id;
+ }
+ 
+ /* virtual */ void PilotDaemonTray::dragEnterEvent(QDragEnterEvent * e)
+@@ -149,7 +145,7 @@ void PilotDaemonTray::setupWidget()
+ 	FUNCTIONSETUP;
+ 
+ 	KGlobal::iconLoader()->addAppDir( CSL1("kpilot") );
+-	icons[Normal] = loadIcon( CSL1("kpilot") );
++	icons[Normal] = loadIcon( CSL1("kpilotDaemon") );
+ 	icons[Busy] = loadIcon( CSL1("busysync") );
+ 	icons[NotListening] = loadIcon( CSL1("nosync") );
+ 
+@@ -176,7 +172,6 @@ void PilotDaemonTray::setupWidget()
+ 
+         // Keep this synchronized with kpilotui.rc and kpilot.cc if at all possible.
+ 	MI(eHotSync);
+-	MI(eFastSync);
+ 	MI(eFullSync);
+ 	MI(eBackup);
+ 	MI(eRestore);
+@@ -197,7 +192,7 @@ void PilotDaemonTray::setupWidget()
+ 
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Finished getting icons" << endl;
++	DEBUGKPILOT << fname << ": Finished getting icons" << endl;
+ #endif
+ }
+ 
+@@ -318,7 +313,7 @@ PilotDaemon::PilotDaemon() :
+ 	fNextSyncType.setMode( KPilotSettings::syncType() );
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGKPILOT << fname
+ 		<< ": The daemon is ready with status "
+ 		<< statusString() << " (" << (int) fDaemonStatus << ")" << endl;
+ #endif
+@@ -377,7 +372,7 @@ int PilotDaemon::getPilotSpeed()
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGKPILOT << fname
+ 		<< ": Speed set to "
+ 		<< speedname << " (" << speed << ")" << endl;
+ #endif
+@@ -395,7 +390,7 @@ void PilotDaemon::showTray()
+ 	if (!fTray)
+ 	{
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname << ": No tray icon to display!" << endl;
++		DEBUGKPILOT << fname << ": No tray icon to display!" << endl;
+ #endif
+ 
+ 		return;
+@@ -407,7 +402,7 @@ void PilotDaemon::showTray()
+ 	fTray->show();
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Tray icon displayed." << endl;
++	DEBUGKPILOT << fname << ": Tray icon displayed." << endl;
+ #endif
+ 
+ 	updateTrayStatus();
+@@ -450,14 +445,15 @@ void PilotDaemon::showTray()
+ 	KPilotSettings::self()->readConfig();
+ 	getPilotSpeed();
+ 
+-	(void) PilotAppCategory::setupPilotCodec(KPilotSettings::encoding());
++	(void) Pilot::setupPilotCodec(KPilotSettings::encoding());
++	(void) Pilot::setupPilotCodec(KPilotSettings::encoding());
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGKPILOT << fname
+ 		<< ": Got configuration "
+ 		<< KPilotSettings::pilotDevice()
+ 		<< endl;
+-	DEBUGDAEMON << fname
++	DEBUGKPILOT << fname
+ 		<< ": Got conduit list "
+ 		<< (KPilotSettings::installedConduits().join(CSL1(",")))
+ 		<< endl;
+@@ -469,7 +465,7 @@ void PilotDaemon::showTray()
+ 	if (fPilotLink)
+ 	{
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGKPILOT << fname
+ 			<< ": Resetting with device "
+ 			<< KPilotSettings::pilotDevice()
+ 			<< endl;
+@@ -477,7 +473,7 @@ void PilotDaemon::showTray()
+ 
+ 		fPilotLink->reset( KPilotSettings::pilotDevice() );
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGKPILOT << fname
+ 			<< ": Using workarounds "
+ 			<< KPilotSettings::workarounds()
+ 			<< endl;
+@@ -485,7 +481,7 @@ void PilotDaemon::showTray()
+ 		if ( KPilotSettings::workarounds() == KPilotSettings::eWorkaroundUSB )
+ 		{
+ #ifdef DEBUG
+-			DEBUGDAEMON << fname
++			DEBUGKPILOT << fname
+ 				<< ": Using Zire31 USB workaround." << endl;
+ #endif
+ 			fPilotLink->setWorkarounds(true);
+@@ -604,8 +600,8 @@ bool PilotDaemon::setupPilotLink()
+ 		return false;
+ 	}
+ 
+-	QObject::connect(fPilotLink, SIGNAL(deviceReady(KPilotDeviceLink*)),
+-		this, SLOT(startHotSync(KPilotDeviceLink*)));
++	QObject::connect(fPilotLink, SIGNAL(deviceReady(KPilotLink*)),
++		this, SLOT(startHotSync(KPilotLink*)));
+ 	// connect the signals emitted by the pilotDeviceLink
+ 	QObject::connect(fPilotLink, SIGNAL(logError(const QString &)),
+ 		this, SLOT(logError(const QString &)));
+@@ -649,11 +645,6 @@ bool PilotDaemon::setupPilotLink()
+ 	requestSync(SyncAction::SyncMode::eHotSync);
+ }
+ 
+-/* DCOP ASYNC */ void PilotDaemon::requestFastSyncNext()
+-{
+-	requestSync(SyncAction::SyncMode::eFastSync);
+-}
+-
+ 
+ /* DCOP ASYNC */ void PilotDaemon::requestSync(int mode)
+ {
+@@ -674,7 +665,7 @@ bool PilotDaemon::setupPilotLink()
+ 
+ 	if (fTray && (fTray->fSyncTypeMenu))
+ 	{
+-		for (int i=((int)SyncAction::SyncMode::eFastSync);
++		for (int i=((int)SyncAction::SyncMode::eHotSync);
+ 			i<=((int)SyncAction::SyncMode::eRestore) /* Restore */ ;
+ 			++i)
+ 		{
+@@ -692,7 +683,6 @@ bool PilotDaemon::setupPilotLink()
+ 
+ 	// This checks unique prefixes of the names of the various sync types.
+ 	if (s.startsWith(CSL1("H"))) requestSync(SyncAction::SyncMode::eHotSync);
+-	else if (s.startsWith(CSL1("Fa"))) requestSync(SyncAction::SyncMode::eFastSync);
+ 	else if (s.startsWith(CSL1("Fu"))) requestSync(SyncAction::SyncMode::eFullSync);
+ 	else if (s.startsWith(CSL1("B"))) requestSync(SyncAction::SyncMode::eBackup);
+ 	else if (s.startsWith(CSL1("R"))) requestSync(SyncAction::SyncMode::eRestore);
+@@ -869,7 +859,7 @@ static void informOthers(KPilotDCOP_stub
+ }
+ 
+ static bool isSyncPossible(ActionQueue *fSyncStack,
+-	KPilotDeviceLink *pilotLink,
++	KPilotLink *pilotLink,
+ 	KPilotDCOP_stub &kpilot)
+ {
+ 	FUNCTIONSETUP;
+@@ -886,12 +876,12 @@ static bool isSyncPossible(ActionQueue *
+ #ifdef DEBUG
+ 	if (callstatus != DCOPStub::CallSucceeded)
+ 	{
+-		DEBUGDAEMON << fname <<
++		DEBUGKPILOT << fname <<
+ 			": Could not call KPilot for status." << endl;
+ 	}
+ 	else
+ 	{
+-		DEBUGDAEMON << fname << ": KPilot status " << kpilotstatus << endl;
++		DEBUGKPILOT << fname << ": KPilot status " << kpilotstatus << endl;
+ 	}
+ #endif
+ 	/**
+@@ -942,7 +932,7 @@ static void queueInstaller(ActionQueue *
+ 	}
+ }
+ 
+-static void queueEditors(ActionQueue *fSyncStack, KPilotDeviceLink *pilotLink)
++static void queueEditors(ActionQueue *fSyncStack, KPilotLink *pilotLink)
+ {
+ 	if (KPilotSettings::internalEditors())
+ 	{
+@@ -963,20 +953,59 @@ static void queueConduits(ActionQueue *f
+ 	}
+ }
+ 
+-/* slot */ void PilotDaemon::startHotSync(KPilotDeviceLink *pilotLink)
++bool PilotDaemon::shouldBackup()
++{
++
++	FUNCTIONSETUP;
++
++	bool ret = false;
++	int backupfreq = KPilotSettings::backupFrequency();
++
++#ifdef DEBUG
++	DEBUGKPILOT << fname << ": Backup Frequency is: [" << backupfreq <<
++	"]. " << endl;
++#endif
++
++	if ( (fNextSyncType == SyncAction::SyncMode::eHotSync) ||
++		(fNextSyncType == SyncAction::SyncMode::eFullSync) )
++	{
++		/** If we're doing a Hot or Full sync, see if our user has
++		 * configured us to or to not always do a backup.
++		 */
++		if ( backupfreq == SyncAction::eOnRequestOnly )
++		{
++#ifdef DEBUG
++	DEBUGKPILOT << fname << ": Should not do backup..." << endl;
++#endif
++			ret = false;
++		}
++		else if ( backupfreq == SyncAction::eEveryHotSync )
++		{
++#ifdef DEBUG
++	DEBUGKPILOT << fname << ": Should do backup..." << endl;
++#endif
++			ret = true;
++		}
++	}
++
++	return ret;
++
++}
++
++
++/* slot */ void PilotDaemon::startHotSync(KPilotLink *pilotLink)
+ {
+ 	FUNCTIONSETUP;
+ 
+ 	bool pcchanged=false; // If last PC to sync was a different one (implies full sync, normally)
+ 	QStringList conduits ; // list of conduits to run
+ 	QString s; // a generic string for stuff
+-	KPilotUser *usr = 0L; // Pointer to user data on Pilot
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGKPILOT << fname
+ 		<< ": Starting Sync with type "
+ 		<< fNextSyncType.name() << endl;
+-	DEBUGDAEMON << fname << ": Status is " << shortStatusString() << endl;
++	DEBUGKPILOT << fname << ": Status is " << shortStatusString() << endl;
+ 	(void) PilotDatabase::count();
+ #endif
+ 
+@@ -1003,19 +1032,35 @@ static void queueConduits(ActionQueue *f
+ 	// want to sync with a blank palm and then back up the result over her stored backup files,
+ 	// do a Full Sync when changing the PC or using a different Palm Desktop app.
+ 	if (fNextSyncType.mode() != SyncAction::SyncMode::eRestore)
+-	{
+-		// Use gethostid to determine , since JPilot uses 1+(2000000000.0*random()/(RAND_MAX+1.0))
++	{ // Use gethostid to determine , since JPilot uses 1+(2000000000.0*random()/(RAND_MAX+1.0))
+ 		// as PC_ID, so using JPilot and KPilot is the same as using two different PCs
+-		usr = pilotLink->getPilotUser();
+-		pcchanged = usr->getLastSyncPC() !=(unsigned long) gethostid();
+-		if (pcchanged && KPilotSettings::fullSyncOnPCChange() )
++		KPilotUser &usr = pilotLink->getPilotUser();
++		pcchanged = usr.getLastSyncPC() !=(unsigned long) gethostid();
++
++		if (pcchanged)
+ 		{
+-			fNextSyncType = SyncAction::SyncMode::eFullSync;
++#ifdef DEBUG
++			DEBUGKPILOT << fname << ": PC changed. Last sync PC: [" << usr.getLastSyncPC()
++				<< "], me: [" << (unsigned long) gethostid() << "]" << endl;
++#endif
++ 			if ( KPilotSettings::fullSyncOnPCChange() )
++			{
++#ifdef DEBUG
++				DEBUGKPILOT << fname << ": Setting sync mode to full sync. " << endl;
++#endif
++				fNextSyncType = SyncAction::SyncMode::eFullSync;
++			}
++			else
++			{
++#ifdef DEBUG
++				DEBUGKPILOT << fname << ": Not changing sync mode because of settings. " << endl;
++#endif
++			}
+ 		}
+ 	}
+ 
+ 	// Normal case: regular sync.
+-	fSyncStack->queueInit(true);
++	fSyncStack->queueInit( ActionQueue::queueCheckUser );
+ 
+ 	conduits = KPilotSettings::installedConduits() ;
+ 
+@@ -1039,7 +1084,6 @@ static void queueConduits(ActionQueue *f
+ 			queueInstaller(fSyncStack,fInstaller,conduits);
+ 			break;
+ 		case SyncAction::SyncMode::eFullSync:
+-		case SyncAction::SyncMode::eFastSync:
+ 		case SyncAction::SyncMode::eHotSync:
+ 			// first install the files, and only then do the conduits
+ 			// (conduits might want to sync a database that will be installed
+@@ -1049,8 +1093,7 @@ static void queueConduits(ActionQueue *f
+ 			// After running the conduits, install new databases
+ 			queueInstaller(fSyncStack,fInstaller,conduits);
+ 			// And sync the remaining databases if needed.
+-			if ( (fNextSyncType == SyncAction::SyncMode::eHotSync) ||
+-				(fNextSyncType == SyncAction::SyncMode::eFullSync))
++			if (shouldBackup())
+ 			{
+ 				fSyncStack->addAction(new BackupAction(pilotLink, (fNextSyncType == SyncAction::SyncMode::eFullSync)));
+ 			}
+@@ -1145,7 +1188,7 @@ launch:
+ 	}
+ 	else
+ 	{
+-		QTimer::singleShot(5000,fPilotLink,SLOT(reset()));
++		QTimer::singleShot(10000,fPilotLink,SLOT(reset()));
+ 	}
+ 
+ 	fPostSyncAction = None;
+@@ -1184,7 +1227,7 @@ void PilotDaemon::slotRunKPilot()
+ 	else
+ 	{
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGKPILOT << fname
+ 			<< ": Started KPilot with DCOP name "
+ 			<< kpilotDCOP << " (pid " << kpilotPID << ")" << endl;
+ #endif
+@@ -1285,7 +1328,7 @@ int main(int argc, char **argv)
+ 		"pilone at slac.com");
+ 	about.addAuthor("Adriaan de Groot",
+ 		I18N_NOOP("Maintainer"),
+-		"groot at kde.org", "http://www.cs.kun.nl/~adridg/");
++		"groot at kde.org", "http://www.kpilot.org/");
+ 	about.addAuthor("Reinhold Kainhofer",
+ 		I18N_NOOP("Developer"),
+ 		"reinhold at kainhofer.com", "http://reinhold.kainhofer.com/Linux/");
+@@ -1338,7 +1381,7 @@ int main(int argc, char **argv)
+ 		}
+ 
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGKPILOT << fname
+ 			<< ": Configuration version "
+ 			<< KPilotSettings::configVersion() << endl;
+ #endif
+@@ -1365,9 +1408,6 @@ int main(int argc, char **argv)
+ 	gPilotDaemon->showTray();
+ 
+ 	return a.exec();
+-
+-	/* NOTREACHED */
+-	(void) pilotdaemon_id;
+ }
+ 
+ 
+diff -pruN kpilot/kpilot/pilotDaemonDCOP.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/pilotDaemonDCOP.h
+--- kpilot/kpilot/pilotDaemonDCOP.h	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/pilotDaemonDCOP.h	2006-11-19 22:21:12.000000000 +0100
+@@ -55,8 +55,6 @@ k_dcop:
+ 	*/
+ 	virtual ASYNC requestSyncType(QString) = 0;
+ 	/** Shortcut for using requestSync(1) */
+-	virtual ASYNC requestFastSyncNext() = 0;
+-	/** Shortcut for using requestSync(2) */
+ 	virtual ASYNC requestRegularSyncNext() = 0;
+ 	/** Query what type is set most recently. */
+ 	virtual int nextSyncType() const = 0;
+diff -pruN kpilot/kpilot/pilotDaemon.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/pilotDaemon.h
+--- kpilot/kpilot/pilotDaemon.h	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/pilotDaemon.h	2006-11-19 22:21:12.000000000 +0100
+@@ -48,6 +48,9 @@ class LoggerDCOP_stub;
+ class KPilotDCOP_stub;
+ class LogFile;
+ 
++class KPilotLink;
++class KPilotDeviceLink;
++
+ class PilotDaemonTray : public KSystemTray
+ {
+ 	Q_OBJECT
+@@ -163,7 +166,6 @@ public slots:
+ 	virtual ASYNC requestSync(int);
+ public:
+ 	virtual ASYNC requestSyncType(QString);
+-	virtual ASYNC requestFastSyncNext();
+ 	virtual ASYNC requestRegularSyncNext();
+ 	virtual int nextSyncType() const;
+ 	virtual ASYNC requestSyncOptions(bool,bool);
+@@ -196,7 +198,7 @@ protected:
+ 	int fPostSyncAction;
+ 
+ protected slots:
+-	void startHotSync( KPilotDeviceLink* lnk );
++	void startHotSync( KPilotLink* lnk );
+ 	void endHotSync();
+ 
+ 	void logMessage(const QString &);
+@@ -206,6 +208,14 @@ protected slots:
+ private:
+ 	int getPilotSpeed();
+ 
++	/**
++	* Check whether we should do a backup.  This is based on the
++	* KPilotSettings::backupFrequency and uses
++	* SyncAction::BackupFrequency.  This will be expanded, hopefully,
++	* to provide backup scheduling at some point.
++	*/
++	bool shouldBackup();
++
+ 	bool setupPilotLink();
+ 
+ 	KPilotDeviceLink &getPilotLink() { return *fPilotLink; }
+diff -pruN kpilot/kpilot/syncStack.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/syncStack.cc
+--- kpilot/kpilot/syncStack.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/syncStack.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -29,14 +29,11 @@
+ */
+ #include "options.h"
+ 
+-static const char *syncStack_id = "$Id: syncStack.cc 449694 2005-08-16 13:07:41Z adridg $";
+-
+ #include <unistd.h>
+ 
+ #include <qtimer.h>
+ #include <qfile.h>
+ #include <qdir.h>
+-#include <qtextcodec.h>
+ 
+ #include <kservice.h>
+ #include <kservicetype.h>
+@@ -49,18 +46,16 @@ static const char *syncStack_id = "$Id: 
+ #include "interactiveSync.h"
+ #include "fileInstaller.h"
+ #include "kpilotSettings.h"
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ 
+ #include "syncStack.moc"
+ 
+ 
+ 
+-WelcomeAction::WelcomeAction(KPilotDeviceLink *p) :
++WelcomeAction::WelcomeAction(KPilotLink *p) :
+ 	SyncAction(p,"welcomeAction")
+ {
+ 	FUNCTIONSETUP;
+-
+-	(void) syncStack_id;
+ }
+ 
+ /* virtual */ bool WelcomeAction::exec()
+@@ -69,12 +64,12 @@ WelcomeAction::WelcomeAction(KPilotDevic
+ 
+ 	addSyncLogEntry(i18n("KPilot %1 HotSync starting...\n")
+ 		.arg(QString::fromLatin1(KPILOT_VERSION)));
+-	emit logMessage( i18n("Using encoding %1 on the handheld.").arg(PilotAppCategory::codecName()) );
++	emit logMessage( i18n("Using encoding %1 on the handheld.").arg(Pilot::codecName()) );
+ 	emit syncDone(this);
+ 	return true;
+ }
+ 
+-SorryAction::SorryAction(KPilotDeviceLink *p, const QString &s) :
++SorryAction::SorryAction(KPilotLink *p, const QString &s) :
+ 	SyncAction(p,"sorryAction"),
+ 	fMessage(s)
+ {
+@@ -93,7 +88,7 @@ bool SorryAction::exec()
+ 	return delayDone();
+ }
+ 
+-LocalBackupAction::LocalBackupAction(KPilotDeviceLink *p, const QString &d) :
++LocalBackupAction::LocalBackupAction(KPilotLink *p, const QString &d) :
+ 	SyncAction(p,"LocalBackupAction"),
+ 	fDir(d)
+ {
+@@ -106,7 +101,7 @@ bool LocalBackupAction::exec()
+ 	startTickle();
+ 
+ 	QString dirname = fDir +
+-		PilotAppCategory::codec()->toUnicode(fHandle->getPilotUser()->getUserName()) +
++		Pilot::fromPilot(fHandle->getPilotUser().getUserName()) +
+ 		CSL1("/");
+ 	QDir dir(dirname,QString::null,QDir::Unsorted,QDir::Files);
+ 
+@@ -135,7 +130,7 @@ bool LocalBackupAction::exec()
+ }
+ 
+ 
+-ConduitProxy::ConduitProxy(KPilotDeviceLink *p,
++ConduitProxy::ConduitProxy(KPilotLink *p,
+ 	const QString &name,
+ 	const SyncAction::SyncMode &m) :
+ 	ConduitAction(p,name.latin1(),m.list()),
+@@ -173,23 +168,51 @@ ConduitProxy::ConduitProxy(KPilotDeviceL
+ 		<< endl;
+ #endif
+ 
+-	KLibFactory *factory = KLibLoader::self()->factory(
++	KLibrary *library = KLibLoader::self()->library(
+ 		QFile::encodeName(fLibraryName));
+-	if (!factory)
++	if (!library)
+ 	{
+ 		kdWarning() << k_funcinfo
+ 			<< ": Can't load library "
+ 			<< fLibraryName
++			<< " - "
++			<< KLibLoader::self()->lastErrorMessage()
+ 			<< endl;
+ 		addSyncLogEntry(i18n("Could not load conduit %1.").arg(fDesktopName));
+ 		emit syncDone(this);
+ 		return true;
+ 	}
+ 
++	unsigned long version = PluginUtility::pluginVersion(library);
++	if ( Pilot::PLUGIN_API != version )
++	{
++		kdWarning() << k_funcinfo
++			<< ": Library "
++			<< fLibraryName
++			<< " has version "
++			<< version
++			<< endl;
++		addSyncLogEntry(i18n("Conduit %1 has wrong version (%2).").arg(fDesktopName).arg(version));
++		emit syncDone(this);
++		return true;
++	}
++
++	KLibFactory *factory = library->factory();
++	if (!factory)
++	{
++		kdWarning() << k_funcinfo
++			<< ": Can't find factory in library "
++			<< fLibraryName
++			<< endl;
++		addSyncLogEntry(i18n("Could not initialize conduit %1.").arg(fDesktopName));
++		emit syncDone(this);
++		return true;
++	}
++
+ 	QStringList l = syncMode().list();
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Flags: " << syncMode().name() << endl;
++	DEBUGKPILOT << fname << ": Flags: " << syncMode().name() << endl;
+ #endif
+ 
+ 	QObject *object = factory->create(fHandle,name(),"SyncAction",l);
+@@ -254,7 +277,7 @@ void ConduitProxy::execDone(SyncAction *
+ }
+ 
+ 
+-ActionQueue::ActionQueue(KPilotDeviceLink *d) :
++ActionQueue::ActionQueue(KPilotLink *d) :
+ 	SyncAction(d,"ActionQueue"),
+ 	fReady(false)
+ 	// The string lists have default constructors
+@@ -268,13 +291,13 @@ ActionQueue::~ActionQueue()
+ }
+ 
+ 
+-void ActionQueue::queueInit(bool checkUser)
++void ActionQueue::queueInit( ActionQueue::InitFlags checkUser)
+ {
+ 	FUNCTIONSETUP;
+ 
+ 	addAction(new WelcomeAction(fHandle));
+ 
+-	if (checkUser)
++	if ( ActionQueue::queueCheckUser == checkUser)
+ 	{
+ 		addAction(new CheckUser(fHandle));
+ 	}
+@@ -294,14 +317,14 @@ void ActionQueue::queueConduits(const QS
+ 		if ((*it).startsWith(CSL1("internal_")))
+ 		{
+ #ifdef DEBUG
+-			DEBUGDAEMON << fname <<
++			DEBUGKPILOT << fname <<
+ 				": Ignoring conduit " << *it << endl;
+ #endif
+ 			continue;
+ 		}
+ 
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGKPILOT << fname
+ 			<< ": Creating proxy with mode=" << m.name() << endl;
+ #endif
+ 		ConduitProxy *cp = new ConduitProxy(fHandle,*it,m);
+@@ -332,7 +355,7 @@ void ActionQueue::actionCompleted(SyncAc
+ 	if (b)
+ 	{
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGKPILOT << fname
+ 			<< ": Completed action "
+ 			<< b->name()
+ 			<< endl;
+@@ -369,7 +392,7 @@ void ActionQueue::actionCompleted(SyncAc
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGKPILOT << fname
+ 		<< ": Will run action "
+ 		<< a->name()
+ 		<< endl;
+diff -pruN kpilot/kpilot/syncStack.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/syncStack.h
+--- kpilot/kpilot/syncStack.h	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/syncStack.h	2006-11-19 22:21:12.000000000 +0100
+@@ -52,7 +52,7 @@
+ * ActionQueue.
+ *
+ * An ActionQueue is constructed with a @p device. As usual, you should connect
+-* the device's deviceReady(KPilotDeviceLink*) signal with the exec() slot --
++* the device's deviceReady(KPilotLink*) signal with the exec() slot --
+ * or something to that effect.
+ * The ActionQueue will then run all the actions in the queue in sequence.
+ *
+@@ -65,7 +65,7 @@ public:
+ 	/** Constructor. Pass in a KPilot device link for it to act on.
+ 	* It is legal to pass in 0 (NULL) as a device.
+ 	*/
+-	ActionQueue(KPilotDeviceLink *device);
++	ActionQueue(KPilotLink *device);
+ 
+ 	virtual ~ActionQueue();
+ 
+@@ -91,6 +91,14 @@ protected:
+ 	QStringList fConduits;
+ 
+ public:
++	/** Enum values for queueInit(), specifying what
++	*   standard actions to queue automatically.
++	*/
++	enum InitFlags {
++		queueNone=0,
++		queueCheckUser
++	} ;
++
+ 	/**
+ 	* Call these queue*() functions to append standard functional
+ 	* blocks. You should at least call queueInit() and
+@@ -106,7 +114,7 @@ public:
+ 	*   of files to install (checked at exec() time).
+ 	*/
+ 
+-	void queueInit(bool checkUser = false);
++	void queueInit( InitFlags checkUser = queueNone );
+ 	void queueConduits(const QStringList &conduits,const SyncAction::SyncMode &e, bool local=false);
+ 	void queueInstaller(const QString &dir);
+ 	void queueCleanup();
+@@ -129,7 +137,7 @@ protected slots:
+ class WelcomeAction : public SyncAction
+ {
+ public:
+-	WelcomeAction(KPilotDeviceLink *);
++	WelcomeAction(KPilotLink *);
+ 
+ protected:
+ 	virtual bool exec();
+@@ -143,7 +151,7 @@ protected:
+ class SorryAction : public SyncAction
+ {
+ public:
+-	SorryAction(KPilotDeviceLink *, const QString &s=QString::null);
++	SorryAction(KPilotLink *, const QString &s=QString::null);
+ 
+ protected:
+ 	virtual bool exec();
+@@ -160,7 +168,7 @@ protected:
+ class LocalBackupAction : public SyncAction
+ {
+ public:
+-	LocalBackupAction(KPilotDeviceLink *, const QString &);
++	LocalBackupAction(KPilotLink *, const QString &);
+ protected:
+ 	virtual bool exec();
+ 	QString fDir;
+@@ -177,7 +185,7 @@ class ConduitProxy : public ConduitActio
+ Q_OBJECT
+ 
+ public:
+-	ConduitProxy(KPilotDeviceLink *,
++	ConduitProxy(KPilotLink *,
+ 		const QString &desktopName,
+ 		const SyncAction::SyncMode &m);
+ 
+diff -pruN kpilot/kpilot/todoEditor_base.ui /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/todoEditor_base.ui
+--- kpilot/kpilot/todoEditor_base.ui	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/todoEditor_base.ui	2006-11-19 22:21:12.000000000 +0100
+@@ -174,7 +174,7 @@
+     </connection>
+ </connections>
+ <layoutdefaults spacing="6" margin="11"/>
+-<includehints>
+-    <includehint>kdatewidget.h</includehint>
+-</includehints>
++<includes>
++    <include location="system" impldecl="in implementation">kdatewidget.h</include>
++</includes>
+ </UI>
+diff -pruN kpilot/kpilot/todoEditor.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/todoEditor.cc
+--- kpilot/kpilot/todoEditor.cc	2006-05-22 20:11:07.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/todoEditor.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -43,8 +43,6 @@
+ #include "todoEditor_base.h"
+ #include "todoEditor.moc"
+ 
+-static const char *todoEditor_id =
+-	"$Id: todoEditor.cc 529452 2006-04-13 14:05:00Z mueller $";
+ 
+ TodoEditor::TodoEditor(PilotTodoEntry * p, struct ToDoAppInfo *appInfo,
+ 	QWidget * parent, const char *name) :
+@@ -62,7 +60,6 @@ TodoEditor::TodoEditor(PilotTodoEntry * 
+ 	connect(parent, SIGNAL(recordChanged(PilotTodoEntry *)),
+ 		this, SLOT(updateRecord(PilotTodoEntry *)));
+ 
+-	(void) todoEditor_id;
+ }
+ 
+ TodoEditor::~TodoEditor()
+@@ -149,7 +146,6 @@ void TodoEditor::fillFields()
+ 	fTodo->setNote(fWidget->fNote->text());
+ 
+ 	emit(recordChangeComplete(fTodo));
+-	fDeleteOnCancel = false;
+ 	KDialogBase::slotOk();
+ }
+ 
+diff -pruN kpilot/kpilot/todoWidget.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/kpilot/todoWidget.cc
+--- kpilot/kpilot/todoWidget.cc	2005-09-10 10:24:39.000000000 +0200
++++ kdepim-3.5.5+/kpilot/kpilot/todoWidget.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -26,9 +26,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *todowidget_id =
+-	"$Id: todoWidget.cc 444649 2005-08-10 13:21:07Z mlaurent $";
+-
+ 
+ #include "options.h"
+ 
+@@ -79,8 +76,6 @@ TodoWidget::TodoWidget(QWidget * parent,
+ 	setupWidget();
+ 	fTodoList.setAutoDelete(true);
+ 
+-	/* NOTREACHED */
+-	(void) todowidget_id;
+ }
+ 
+ TodoWidget::~TodoWidget()
+@@ -144,7 +139,7 @@ void TodoWidget::showComponent()
+ 
+ 	fTodoList.clear();
+ 
+-	if (fTodoDB->isDBOpen())
++	if (fTodoDB->isOpen())
+ 	{
+ 		KPILOT_DELETE(fTodoAppInfo);
+ 		fTodoAppInfo = new PilotToDoInfo(fTodoDB);
+@@ -397,7 +392,7 @@ void TodoWidget::slotCreateNewRecord()
+ 	//
+ 	PilotDatabase *myDB = new PilotLocalDatabase(dbPath(), CSL1("ToDoDB"));
+ 
+-	if (!myDB || !myDB->isDBOpen())
++	if (!myDB || !myDB->isOpen())
+ 	{
+ #ifdef DEBUG
+ 		DEBUGKPILOT << fname
+@@ -407,7 +402,7 @@ void TodoWidget::slotCreateNewRecord()
+ 			<< " and got pointer @"
+ 			<< (void *) myDB
+ 			<< " with status "
+-			<< ( myDB ? myDB->isDBOpen() : false )
++			<< ( myDB ? myDB->isOpen() : false )
+ 			<< endl;
+ #endif
+ 
+@@ -444,7 +439,7 @@ void TodoWidget::slotAddRecord(PilotTodo
+ 		fTodoAppInfo->categoryInfo(), true);
+ 
+ 
+-	todo->PilotAppCategory::setCategory(currentCatID);
++	todo->PilotRecordBase::setCategory(currentCatID);
+ 	fTodoList.append(todo);
+ 	writeTodo(todo);
+ 	// TODO: Just add the new record to the lists
+@@ -555,7 +550,7 @@ void TodoWidget::writeTodo(PilotTodoEntr
+ 	PilotDatabase *myDB = todoDB;
+ 	bool usemyDB = false;
+ 
+-	if (myDB == 0L || !myDB->isDBOpen())
++	if (myDB == 0L || !myDB->isOpen())
+ 	{
+ 		myDB = new PilotLocalDatabase(dbPath(), CSL1("ToDoDB"));
+ 		usemyDB = true;
+@@ -564,7 +559,7 @@ void TodoWidget::writeTodo(PilotTodoEntr
+ 	// Still no valid todo database...
+ 	//
+ 	//
+-	if (!myDB->isDBOpen())
++	if (!myDB->isOpen())
+ 	{
+ #ifdef DEBUG
+ 		DEBUGKPILOT << fname << ": Todo database is not open" <<
+diff -pruN kpilot/lib/CMakeLists.txt /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/CMakeLists.txt
+--- kpilot/lib/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/CMakeLists.txt	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,77 @@
++include(CheckIncludeFiles)
++include(CheckFunctionExists)
++
++check_include_files( stdint.h HAVE_STDINT_H )
++check_include_files( alloca.h HAVE_ALLOCA_H )
++check_include_files( "sys/time.h" HAVE_SYS_TIME_H )
++check_include_files( "sys/stat.h" HAVE_SYS_STAT_H )
++check_function_exists( cfsetspeed HAVE_CFSETSPEED )
++check_function_exists( strdup HAVE_STRDUP )
++check_function_exists( setenv HAVE_SETENV )
++check_function_exists( unsetenv HAVE_UNSETENV )
++check_function_exists( usleep HAVE_USLEEP )
++check_function_exists( random HAVE_RANDOM )
++check_function_exists( putenv HAVE_PUTENV )
++check_function_exists( seteuid HAVE_SETEUID )
++check_function_exists( mkstemps HAVE_MKSTEMPS )
++check_function_exists( mkstemp HAVE_MKSTEMP )
++check_function_exists( mkdtemp HAVE_MKDTEMP )
++check_function_exists( revoke HAVE_REVOKE )
++check_function_exists( strlcpy HAVE_STRLCPY )
++check_function_exists( strlcat HAVE_STRLCAT )
++check_function_exists( inet_aton HAVE_INET_ATON )
++
++configure_file(
++	${CMAKE_SOURCE_DIR}/config.h.cmake
++	${CMAKE_CURRENT_BINARY_DIR}/config.h
++)
++
++include_directories(${CMAKE_CURRENT_BINARY_DIR})
++
++set(lib_SRCS
++	options.cc
++	uiDialog.cc
++	plugin.cc
++	syncAction.cc
++	kpilotlink.cc
++	pilot.cc
++	pilotAppInfo.cc
++	pilotRecord.cc
++	pilotDatabase.cc
++	pilotLocalDatabase.cc
++	pilotSerialDatabase.cc
++	pilotMemo.cc
++	pilotAddress.cc
++	pilotDateEntry.cc
++	pilotTodoEntry.cc
++	pilotStruct.cc
++)
++
++kde3_automoc(${lib_SRCS})
++kde3_add_kcfg_files(lib_SRCS kpilotlibSettings.kcfgc)
++add_library(kpilot SHARED ${lib_SRCS})
++target_link_libraries(kpilot ${PILOTLINK_LIBRARY} ${QT_LIBRARIES} kabc kdeui)
++kpilot_rpath(kpilot)
++
++#---------- INSTALL -----------------------*
++set(kpilotinclude_HEADERS
++	kpilotlink.h
++	uiDialog.h
++	plugin.h
++	pluginfactory.h
++	syncAction.h
++	pilotRecord.h
++	pilotDatabase.h
++	pilotLocalDatabase.h
++	pilotSerialDatabase.h
++)
++
++install(
++	TARGETS kpilot
++	LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
++)
++
++install(
++	FILES ${kpilotinclude_HEADERS}
++	DESTINATION ${CMAKE_INSTALL_PREFIX}/include/kpilot
++)
+Binary files kpilot/lib/data/MemoDB.pdb and /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/data/MemoDB.pdb differ
+diff -pruN kpilot/lib/fakes.c /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/fakes.c
+--- kpilot/lib/fakes.c	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/fakes.c	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,367 @@
++/* This file is part of the KDE libraries
++   Copyright (c) 2000 The KDE Project
++
++   unsetenv() taken from the GNU C Library.
++   Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc.
++
++   This library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Library General Public
++   License version 2 as published by the Free Software Foundation.
++
++   This library 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 this library; 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 <config.h>
++
++#define KDE_open open
++#define KDE_mkdir mkdir 
++
++#ifndef HAVE_SETENV
++
++#ifdef HAVE_ALLOCA_H
++#include <alloca.h>
++#endif
++
++#include <string.h>
++#include <stdlib.h>
++#include <unistd.h>
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++ int setenv(const char *name, const char *value, int overwrite) {
++    int i;
++    char * a;
++
++    if (!overwrite && getenv(name)) return 0;
++
++    i = strlen(name) + strlen(value) + 2;
++    a = (char*)malloc(i);
++    if (!a) return 1;
++
++    strcpy(a, name);
++    strcat(a, "=");
++    strcat(a, value);
++
++    return putenv(a);
++}
++#endif /* !HAVE_SETENV */
++
++#ifndef HAVE_UNSETENV
++
++#ifdef HAVE_ALLOCA_H
++#include <alloca.h>
++#endif
++
++#include <string.h>
++#include <stdlib.h>
++#include <errno.h>
++#include <unistd.h>
++
++#ifndef environ
++extern char ** environ;
++#endif
++
++ void unsetenv (name)
++     const char *name;
++{
++  size_t len;
++  char **ep;
++
++  if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
++    {
++      errno = EINVAL;
++      return;
++    }
++
++  len = strlen (name);
++
++  ep = environ;
++  while (*ep != NULL)
++    if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
++      {
++	/* Found it.  Remove this pointer by moving later ones back.  */
++	char **dp = ep;
++
++	do
++	  dp[0] = dp[1];
++	while (*dp++);
++	/* Continue the loop in case NAME appears again.  */
++      }
++    else
++      ++ep;
++
++}
++
++#endif /* !HAVE_UNSETENV */
++
++#ifndef HAVE_USLEEP
++
++#if TIME_WITH_SYS_TIME
++# include <sys/time.h>
++# include <time.h>
++#else
++# if defined(HAVE_SYS_TIME_H)
++#  include <sys/time.h>
++# else
++#  include <time.h>
++# endif
++#endif
++
++#ifdef HAVE_SYS_SELECT_H
++#include <sys/select.h>
++#endif
++
++#ifdef __cplusplus  /* this is supposed to be a C source file but still.. */
++extern "C" {
++#endif
++
++void usleep(unsigned int usec) {
++        struct timeval _usleep_tv;
++        _usleep_tv.tv_sec = usec/1000000;
++        _usleep_tv.tv_usec = usec%1000000;
++        select(0,0,0,0,&_usleep_tv);
++}
++
++#ifdef __cplusplus
++}
++#endif
++
++#endif /* !HAVE_USLEEP */
++
++#ifndef HAVE_RANDOM
++long int random()
++{
++    return lrand48();
++}
++
++void srandom(unsigned int seed)
++{
++    srand48(seed);
++}
++#endif
++
++#ifndef HAVE_SETEUID
++int seteuid(uid_t euid)
++{
++    setreuid(-1, euid); /* Well, if you have neither you are in trouble :) */
++}
++#endif
++
++#ifndef HAVE_MKSTEMPS
++#include <sys/types.h>
++#ifdef HAVE_SYS_STAT_H
++#include <sys/stat.h>
++#endif
++#include <fcntl.h>
++#include <string.h>
++#include <strings.h>
++#include <stdlib.h>
++
++/* this is based on code taken from the GNU libc, distributed under the LGPL license */
++
++/* Generate a unique temporary file name from TEMPLATE.
++
++   TEMPLATE has the form:
++
++   <path>/ccXXXXXX<suffix>
++
++   SUFFIX_LEN tells us how long <suffix> is (it can be zero length).
++
++   The last six characters of TEMPLATE before <suffix> must be "XXXXXX";
++   they are replaced with a string that makes the filename unique.
++
++   Returns a file descriptor open on the file for reading and writing.  */
++
++ int mkstemps (char* _template, int suffix_len)
++{
++  static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
++  char *XXXXXX;
++  int len;
++  int count;
++  int value;
++
++  len = strlen (_template);
++
++  if ((int) len < 6 + suffix_len || strncmp (&_template[len - 6 - suffix_len], "XXXXXX", 6))
++      return -1;
++
++  XXXXXX = &_template[len - 6 - suffix_len];
++
++  value = rand();
++  for (count = 0; count < 256; ++count)
++  {
++      int v = value;
++      int fd;
++
++      /* Fill in the random bits.  */
++      XXXXXX[0] = letters[v % 62];
++      v /= 62;
++      XXXXXX[1] = letters[v % 62];
++      v /= 62;
++      XXXXXX[2] = letters[v % 62];
++      v /= 62;
++      XXXXXX[3] = letters[v % 62];
++      v /= 62;
++      XXXXXX[4] = letters[v % 62];
++      v /= 62;
++      XXXXXX[5] = letters[v % 62];
++
++      fd = KDE_open (_template, O_RDWR|O_CREAT|O_EXCL, 0600);
++      if (fd >= 0)
++	/* The file does not exist.  */
++	return fd;
++
++      /* This is a random value.  It is only necessary that the next
++	 TMP_MAX values generated by adding 7777 to VALUE are different
++	 with (module 2^32).  */
++      value += 7777;
++    }
++  /* We return the null string if we can't find a unique file name.  */
++  _template[0] = '\0';
++  return -1;
++}
++
++#endif /* !HAVE_MKSTEMPS */
++
++#ifndef HAVE_MKSTEMP
++ int mkstemp (char* _template)
++{
++  return mkstemps( _template, 0 );
++}
++#endif
++
++#ifndef HAVE_MKDTEMP
++
++#ifndef HAVE_MKSTEMPS
++#include <sys/types.h>
++#ifdef HAVE_SYS_STAT_H
++#include <sys/stat.h>
++#endif
++#endif
++
++/* Generate a unique temporary directory name from TEMPLATE.
++
++   TEMPLATE has the form:
++
++   <path>/ccXXXXXX
++
++
++   The last six characters of TEMPLATE must be "XXXXXX";
++   they are replaced with a string that makes the filename unique.
++
++   Returns a file descriptor open on the file for reading and writing.  */
++
++ char* mkdtemp (char* _template)
++{
++  static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
++  char *XXXXXX;
++  int len;
++  int count;
++  int value;
++
++  len = strlen (_template);
++
++  if ((int) len < 6 || strncmp (&_template[len - 6], "XXXXXX", 6))
++      return 0;
++
++  XXXXXX = &_template[len - 6];
++
++  value = rand();
++  for (count = 0; count < 256; ++count)
++  {
++      int v = value;
++
++      /* Fill in the random bits.  */
++      XXXXXX[0] = letters[v % 62];
++      v /= 62;
++      XXXXXX[1] = letters[v % 62];
++      v /= 62;
++      XXXXXX[2] = letters[v % 62];
++      v /= 62;
++      XXXXXX[3] = letters[v % 62];
++      v /= 62;
++      XXXXXX[4] = letters[v % 62];
++      v /= 62;
++      XXXXXX[5] = letters[v % 62];
++
++      /* This is a random value.  It is only necessary that the next
++	 TMP_MAX values generated by adding 7777 to VALUE are different
++	 with (module 2^32).  */
++      value += 7777;
++
++      if (!KDE_mkdir(_template,0700))
++	return _template;	
++    }
++    return 0;
++}
++#endif /* !HAVE_MKDTEMP */
++
++#ifndef HAVE_REVOKE
++#include <errno.h>
++#ifndef ENOTSUP
++#define ENOTSUP 134 /* Not supported */
++#endif
++ int revoke(const char *tty)
++{
++        errno = ENOTSUP;
++        return -1;
++}
++#endif
++
++#ifndef HAVE_STRLCPY
++ unsigned long strlcpy(char* d, const char* s, unsigned long bufsize)
++{
++    unsigned long len, ret = strlen(s);
++
++    if (ret >= bufsize) {
++        if (bufsize) {
++            len = bufsize - 1;
++            memcpy(d, s, len);
++            d[len] = '\0';
++        }
++    } else
++	memcpy(d, s, ret + 1);
++	
++    return ret;
++}
++#endif
++
++#ifndef HAVE_STRLCAT
++ unsigned long strlcat(char* d, const char* s, unsigned long bufsize)
++{
++    char *cp;
++    unsigned long ret, len1, len2 = strlen(s);
++
++    cp = (char *)memchr (d, '\0', bufsize);
++    if (!cp)
++	return bufsize + len2;
++    len1 = cp - d;
++    ret = len1 + len2;
++    if (ret >= bufsize) {
++        len2 = bufsize - len1 - 1;
++        memcpy(cp, s, len2);
++        cp[len2] = '\0';
++    } else
++        memcpy(cp, s, len2 + 1);
++
++    return ret;
++}
++#endif
++
++
++#ifdef __cplusplus
++}
++#endif
++
++
+diff -pruN kpilot/lib/fakes.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/fakes.h
+--- kpilot/lib/fakes.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/fakes.h	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,79 @@
++#ifndef _KPILOT_FAKES_H
++#define _KPILOT_FAKES_H
++
++/* This file is part of the KDE libraries
++   Copyright (c) 2000 The KDE Project
++
++   unsetenv() taken from the GNU C Library.
++   Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc.
++
++   This library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Library General Public
++   License version 2 as published by the Free Software Foundation.
++
++   This library 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 this library; see the file COPYING.LIB.  If not, write to
++   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
++   Boston, MA 02110-1301, USA.
++*/
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++#ifndef HAVE_SETENV
++int setenv(const char *name, const char *value, int overwrite);
++#endif /* !HAVE_SETENV */
++
++#ifndef HAVE_UNSETENV
++void unsetenv (const char *name);
++#endif /* !HAVE_UNSETENV */
++
++#ifndef HAVE_USLEEP
++void usleep(unsigned int usec);
++#endif /* !HAVE_USLEEP */
++
++#ifndef HAVE_RANDOM
++long int random();
++void srandom(unsigned int seed);
++#endif
++
++#ifndef HAVE_SETEUID
++int seteuid(uid_t euid);
++#endif
++
++#ifndef HAVE_MKSTEMPS
++int mkstemps (char* _template, int suffix_len);
++#endif /* !HAVE_MKSTEMPS */
++
++#ifndef HAVE_MKSTEMP
++int mkstemp (char* _template);
++#endif
++
++#ifndef HAVE_MKDTEMP
++char* mkdtemp (char* _template);
++#endif /* !HAVE_MKDTEMP */
++
++#ifndef HAVE_REVOKE
++int revoke(const char *tty);
++#endif
++
++#ifndef HAVE_STRLCPY
++unsigned long strlcpy(char* d, const char* s, unsigned long bufsize);
++#endif
++
++#ifndef HAVE_STRLCAT
++unsigned long strlcat(char* d, const char* s, unsigned long bufsize);
++#endif
++
++#ifdef __cplusplus
++}
++#endif
++
++
++#endif
+diff -pruN kpilot/lib/kpilotdevicelink.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/kpilotdevicelink.h
+--- kpilot/lib/kpilotdevicelink.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/kpilotdevicelink.h	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,219 @@
++#ifndef _KPILOT_KPILOTDEVICELINK_H
++#define _KPILOT_KPILOTDEVICELINK_H
++/* kpilotdevicelink.h			KPilot
++**
++** Copyright (C) 1998-2001 by Dan Pilone
++** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
++**
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "kpilotlink.h"
++
++/** @file Definition of the device link class; implemented in kpilotlink.cc */
++
++/** Implementation of the device link class for physical
++*   handheld devices, which communicate with the PC
++*   using DLP / SLP via the pilot-link library.
++*/
++class KDE_EXPORT KPilotDeviceLink : public KPilotLink
++{
++// friend class SyncAction;
++friend class PilotSerialDatabase;
++Q_OBJECT
++
++/*
++** Constructors and destructors.
++*/
++public:
++	/**
++	* Creates a pilot link that can sync to the pilot.
++	*
++	* Call reset() on it to start looking for a device.
++	*/
++	KPilotDeviceLink( QObject *parent = 0, const char *name = 0, const QString &tempDevice = QString::null );
++	/** Destructor. This rudely ends the communication with the handheld. */
++	virtual ~KPilotDeviceLink();
++
++
++	/**
++	* The link behaves like a state machine most of the time:
++	* it waits for the actual device to become available, and
++	* then becomes ready to handle syncing.
++	*/
++	typedef enum {
++		Init,
++		WaitingForDevice,
++		FoundDevice,
++		CreatedSocket,
++		DeviceOpen,
++		AcceptedDevice,
++		SyncDone,
++		PilotLinkError,
++		WorkaroundUSB
++		} LinkStatus;
++
++	/** Get the status (state enum) of this link.
++	* @return The LinkStatus enum for the link's current state.
++	*/
++	LinkStatus status() const { return fLinkStatus; } ;
++	/** Get a human-readable string for the given status @p l. */
++	static QString statusString(LinkStatus l);
++
++
++	virtual QString statusString() const;
++	virtual bool isConnected() const;
++	virtual void reset( const QString & );
++	virtual void close();
++	virtual void reset();
++	virtual bool tickle();
++	virtual const KPilotCard *getCardInfo(int card);
++	virtual void endOfSync();
++	virtual void finishSync();
++	virtual int openConduit();
++	virtual int getNextDatabase(int index,struct DBInfo *);
++	virtual int findDatabase(const char *name, struct DBInfo*,
++		int index=0, unsigned long type=0, unsigned long creator=0);
++	virtual bool retrieveDatabase(const QString &path, struct DBInfo *db);
++	virtual DBInfoList getDBList(int cardno=0, int flags=dlpDBListRAM);
++	virtual PilotDatabase *database( const QString &name );
++
++protected:
++	virtual bool installFile(const QString &, const bool deleteFile);
++	virtual void addSyncLogEntryImpl( const QString &s );
++	virtual int pilotSocket() const { return fCurrentPilotSocket; } ;
++
++
++private:
++	LinkStatus fLinkStatus;
++
++
++
++
++
++public:
++
++	/**
++	* Special-cases. Call this after a reset to set device-
++	* specific workarounds; the only one currently known
++	* is the Zire 31/72 T5 quirk of doing a non-HotSync
++	* connect when it's switched on.
++	*/
++	void setWorkarounds(bool usb)
++	{
++		fWorkaroundUSB = usb;
++	} ;
++
++	/**
++	* sets an additional device, which should be tried as fallback
++	* usefull for hotplug enviroments
++	*/
++	void setTempDevice( const QString &device );
++
++private:
++	bool fWorkaroundUSB;
++	QTimer *fWorkaroundUSBTimer;
++
++private slots:
++	void workaroundUSB();
++
++protected slots:
++	/**
++	* Attempt to open the device. Called regularly to check
++	* if the device exists (to handle USB-style devices).
++	*/
++	void openDevice();
++
++	/**
++	* Called when the device is opened *and* activity occurs on the
++	* device. This indicates the beginning of a hotsync.
++	*/
++	void acceptDevice();
++
++protected:
++	/**
++	* Does the low-level opening of the device and handles the
++	* pilot-link library initialisation.
++	*/
++	bool open( QString device = QString::null );
++
++	/**
++	* Check for device permissions and existence, emitting
++	* warnings for weird situations. This is primarily intended
++	* to inform the user.
++	*/
++	void checkDevice();
++
++	/**
++	* Some messages are only printed once and are suppressed
++	* after that. These are indicated by flag bits in
++	* messages.
++	*/
++	enum { OpenMessage=1, OpenFailMessage=2 } ;
++	int messages;
++	int messagesMask;
++	static const int messagesType;
++
++	void shouldPrint(int,const QString &);
++
++
++
++private:
++	/**
++	* Path with resolved symlinks, to prevent double binding
++	* to the same device.
++	*/
++	QString fRealPilotPath;
++
++	/**
++	* For transient devices: how often have we tried pi_bind()?
++	*/
++	int fRetries;
++
++	/**
++	* Timers and Notifiers for detecting activity on the device.
++	*/
++	QTimer *fOpenTimer;
++	QSocketNotifier *fSocketNotifier;
++	bool fSocketNotifierActive;
++
++	/**
++	* Pilot-link library handles for the device once it's opened.
++	*/
++	int fPilotMasterSocket;
++	int fCurrentPilotSocket;
++	QString fTempDevice;
++
++	/**
++	* Handle cases where we can't accept or open the device,
++	* and data remains available on the pilot socket.
++	*/
++	int fAcceptedCount;
++
++private:
++	class KPilotDeviceLinkPrivate;
++} ;
++
++#endif
++
+diff -pruN kpilot/lib/kpilotlink.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/kpilotlink.cc
+--- kpilot/lib/kpilotlink.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/kpilotlink.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -2,6 +2,7 @@
+ **
+ ** Copyright (C) 1998-2001 by Dan Pilone
+ ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
+ **
+ */
+ 
+@@ -25,9 +26,10 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *kpilotlink_id = "$Id: kpilotlink.cc 444649 2005-08-10 13:21:07Z mlaurent $";
+ 
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ 
+ 
+@@ -44,27 +46,234 @@ static const char *kpilotlink_id = "$Id:
+ #include <pi-socket.h>
+ #include <pi-dlp.h>
+ #include <pi-file.h>
+-#if !(PILOT_LINK_NUMBER < PILOT_LINK_0_12_0)
+ #include <pi-buffer.h>
+-#endif
+ 
+ #include <qdir.h>
+ #include <qtimer.h>
+ #include <qdatetime.h>
+ #include <qsocketnotifier.h>
+ #include <qthread.h>
+-#include <qtextcodec.h>
+ 
+ #include <kconfig.h>
+ #include <kmessagebox.h>
+ #include <kstandarddirs.h>
++#include <kurl.h>
++#include <kio/netaccess.h>
+ 
+ #include "pilotUser.h"
+ #include "pilotSysInfo.h"
+ #include "pilotCard.h"
+-#include "pilotAppCategory.h"
++#include "pilotSerialDatabase.h"
++#include "pilotLocalDatabase.h"
+ 
+ #include "kpilotlink.moc"
++#include "kpilotdevicelink.moc"
++#include "kpilotlocallink.moc"
++
++/** Class that handles periodically tickling the handheld through
++*   the virtual tickle() method; deals with cancels through the
++*   shared fDone variable.
++*/
++class TickleThread : public QThread
++{
++public:
++	TickleThread(KPilotLink *d, bool *done, int timeout) :
++		QThread(),
++		fHandle(d),
++		fDone(done),
++		fTimeout(timeout)
++	{ };
++	virtual ~TickleThread();
++
++	virtual void run();
++
++	static const int ChecksPerSecond = 5;
++	static const int SecondsPerTickle = 5;
++	static const unsigned int TickleTimeoutEvent = 1066;
++
++private:
++	KPilotLink *fHandle;
++	bool *fDone;
++	int fTimeout;
++} ;
++
++TickleThread::~TickleThread()
++{
++}
++
++void TickleThread::run()
++{
++	FUNCTIONSETUP;
++	int subseconds = ChecksPerSecond;
++	int ticktock = SecondsPerTickle;
++	int timeout = fTimeout;
++#ifdef DEBUG_CERR
++	DEBUGLIBRARY << fname << ": Running for " << timeout << " seconds." << endl;
++	DEBUGLIBRARY << fname << ": Done @" << (void *) fDone << endl;
++#endif
++	while (!(*fDone))
++	{
++		QThread::msleep(1000/ChecksPerSecond);
++		if (!(--subseconds))
++		{
++#ifdef DEBUG_CERR
++// Don't dare use kdDebug() here, we're in a separate thread
++			DEBUGLIBRARY << fname << ": One second." << endl;
++#endif
++			if (timeout)
++			{
++				if (!(--timeout))
++				{
++					QApplication::postEvent(fHandle, new QEvent(static_cast<QEvent::Type>(TickleTimeoutEvent)));
++					break;
++				}
++			}
++			subseconds=ChecksPerSecond;
++			if (!(--ticktock))
++			{
++#ifdef DEBUG_CERR
++				DEBUGLIBRARY << fname << ": Kietel kietel!." << endl;
++#endif
++				ticktock=SecondsPerTickle;
++				fHandle->tickle();
++			}
++		}
++	}
++#ifdef DEBUG_CERR
++	DEBUGLIBRARY << fname << ": Finished." << endl;
++#endif
++}
++
++
++
++
++
++
++
++
++KPilotLink::KPilotLink( QObject *parent, const char *name ) :
++	QObject( parent, name ),
++	fPilotPath(QString::null),
++	fPilotUser(0L),
++	fPilotSysInfo(0L),
++	fTickleDone(true),
++	fTickleThread(0L)
++
++{
++	FUNCTIONSETUP;
++
++	fPilotUser = new KPilotUser();
++	fPilotUser->setUserName( "Henk Westbroek" );
++	fPilotUser->setLastSuccessfulSyncDate( 1139171019 );
++
++	fPilotSysInfo = new KPilotSysInfo();
++	fPilotSysInfo->setProductID( "LocalLink" );
++}
++
++KPilotLink::~KPilotLink()
++{
++	FUNCTIONSETUP;
++	KPILOT_DELETE(fPilotUser);
++	KPILOT_DELETE(fPilotSysInfo);
++}
++
++/* virtual */ bool KPilotLink::event(QEvent *e)
++{
++	if (e->type() == TickleThread::TickleTimeoutEvent)
++	{
++		stopTickle();
++		emit timeout();
++		return true;
++	}
++	else	return QObject::event(e);
++}
++
++/*
++Start a tickle thread with the indicated timeout.
++*/
++void KPilotLink::startTickle(unsigned int timeout)
++{
++	FUNCTIONSETUP;
++
++	Q_ASSERT(fTickleDone);
++
++	/*
++	** We've told the thread to finish up, but it hasn't
++	** done so yet - so wait for it to do so, should be
++	** only 200ms at most.
++	*/
++	if (fTickleDone && fTickleThread)
++	{
++		fTickleThread->wait();
++		KPILOT_DELETE(fTickleThread);
++	}
++
++#ifdef DEBUG
++	DEBUGLIBRARY << fname << ": Done @" << (void *) (&fTickleDone) << endl;
++#endif
++	fTickleDone = false;
++	fTickleThread = new TickleThread(this,&fTickleDone,timeout);
++	fTickleThread->start();
++}
++
++void KPilotLink::stopTickle()
++{
++	FUNCTIONSETUP;
++	fTickleDone = true;
++	if (fTickleThread)
++	{
++		fTickleThread->wait();
++		KPILOT_DELETE(fTickleThread);
++	}
++}
++
++unsigned int KPilotLink::installFiles(const QStringList & l, const bool deleteFiles)
++{
++	FUNCTIONSETUP;
++
++	QStringList::ConstIterator i,e;
++	unsigned int k = 0;
++	unsigned int n = 0;
++	unsigned int total = l.count();
++
++	for (i = l.begin(), e = l.end(); i != e; ++i)
++	{
++		emit logProgress(QString::null,
++			(int) ((100.0 / total) * (float) n));
++
++		if (installFile(*i, deleteFiles))
++			k++;
++		n++;
++	}
++	emit logProgress(QString::null, 100);
++
++	return k;
++}
++
++void KPilotLink::addSyncLogEntry(const QString & entry, bool log)
++{
++	FUNCTIONSETUP;
++	if (entry.isEmpty()) return;
++
++	addSyncLogEntryImpl(entry);
++	if (log)
++	{
++		emit logMessage(entry);
++	}
++}
++
++
++/* virtual */ int KPilotLink::openConduit()
++{
++	return 0;
++}
++
++/* virtual */ int KPilotLink::pilotSocket() const
++{
++	return -1;
++}
++
++
+ 
+ 
+ // singleton helper class
+@@ -77,19 +286,19 @@ public:
+ 		return mThis;
+ 	}
+ 
+-	bool canBind( QString device )
++	bool canBind( const QString &device )
+ 	{
+ 		showList();
+ 		return !mBoundDevices.contains( device );
+ 	}
+ 
+-	void bindDevice( QString device )
++	void bindDevice( const QString &device )
+ 	{
+ 		mBoundDevices.append( device );
+ 		showList();
+ 	}
+ 
+-	void unbindDevice( QString device )
++	void unbindDevice( const QString &device )
+ 	{
+ 		mBoundDevices.remove( device );
+ 		showList();
+@@ -105,9 +314,10 @@ protected:
+ private:
+ 	inline void showList() const
+ 	{
++		if ( !(mBoundDevices.count() > 0) ) return;
+ #ifdef DEBUG
+ 		FUNCTIONSETUPL(3);
+-		DEBUGDAEMON << fname << "Bound devices: "
++		DEBUGLIBRARY << fname << ": Bound devices: "
+ 			<< ((mBoundDevices.count() > 0) ? mBoundDevices.join(CSL1(", ")) : CSL1("<none>")) << endl;
+ #endif
+ 	}
+@@ -117,34 +327,28 @@ KPilotDeviceLink::KPilotDeviceLinkPrivat
+ 
+ 
+ KPilotDeviceLink::KPilotDeviceLink(QObject * parent, const char *name, const QString &tempDevice) :
+-	QObject(parent, name),
++	KPilotLink(parent, name),
+ 	fLinkStatus(Init),
+-	fTickleDone(true),
+-	fTickleThread(0L),
+ 	fWorkaroundUSB(false),
+ 	fWorkaroundUSBTimer(0L),
+-	fPilotPath(QString::null),
+ 	fRetries(0),
+ 	fOpenTimer(0L),
+ 	fSocketNotifier(0L),
+ 	fSocketNotifierActive(false),
+ 	fPilotMasterSocket(-1),
+ 	fCurrentPilotSocket(-1),
+-	fTempDevice(tempDevice),
+-	fPilotUser(0L),
+-	fPilotSysInfo(0L)
++	fTempDevice(tempDevice)
+ {
+ 	FUNCTIONSETUP;
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Pilot-link version " << PILOT_LINK_NUMBER
+ 		<< endl;
+ #endif
+ 
+ 	messagesMask=0xffffffff;
+ 
+-	(void) kpilotlink_id;
+ }
+ 
+ KPilotDeviceLink::~KPilotDeviceLink()
+@@ -156,6 +360,12 @@ KPilotDeviceLink::~KPilotDeviceLink()
+ 	KPILOT_DELETE(fPilotUser);
+ }
+ 
++/* virtual */ bool KPilotDeviceLink::isConnected() const
++{
++	 return fLinkStatus == AcceptedDevice;
++}
++
++
+ void KPilotDeviceLink::close()
+ {
+ 	FUNCTIONSETUP;
+@@ -165,7 +375,7 @@ void KPilotDeviceLink::close()
+ 	KPILOT_DELETE(fSocketNotifier);
+ 	fSocketNotifierActive=false;
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Closing sockets "
+ 		<< fCurrentPilotSocket
+ 		<< " and "
+@@ -348,16 +558,11 @@ bool KPilotDeviceLink::open(QString devi
+ 	if (fPilotMasterSocket == -1)
+ 	{
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname << ": Typing to open " << fRealPilotPath << endl;
++		DEBUGLIBRARY << fname << ": Typing to open " << fRealPilotPath << endl;
+ #endif
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_10_0
+-		fPilotMasterSocket = pi_socket(PI_AF_SLP,
+-			PI_SOCK_STREAM, PI_PF_PADP);
+-#else
+ 		fPilotMasterSocket = pi_socket(PI_AF_PILOT,
+ 			PI_SOCK_STREAM, PI_PF_DLP);
+-#endif
+ 
+ 		if (fPilotMasterSocket<1)
+ 		{
+@@ -368,7 +573,7 @@ bool KPilotDeviceLink::open(QString devi
+ 		}
+ 
+ #ifdef DEBUG
+-		DEBUGDAEMON << fname
++		DEBUGLIBRARY << fname
+ 			<< ": Got master " << fPilotMasterSocket << endl;
+ #endif
+ 
+@@ -378,23 +583,10 @@ bool KPilotDeviceLink::open(QString devi
+ 	Q_ASSERT(fLinkStatus == CreatedSocket);
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Binding to path " << fPilotPath << endl;
++	DEBUGLIBRARY << fname << ": Binding to path " << fPilotPath << endl;
+ #endif
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	struct pi_sockaddr addr;
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_10_0
+-	addr.pi_family = PI_AF_SLP;
+-#else
+-	addr.pi_family = PI_AF_PILOT;
+-#endif
+-	strlcpy(addr.pi_device, QFile::encodeName(device),sizeof(addr.pi_device));
+-
+-	ret = pi_bind(fPilotMasterSocket,
+-		(struct sockaddr *) &addr, sizeof(addr));
+-#else
+ 	ret = pi_bind(fPilotMasterSocket, QFile::encodeName(device));
+-#endif
+ 
+ 	if (ret >= 0)
+ 	{
+@@ -408,11 +600,11 @@ bool KPilotDeviceLink::open(QString devi
+ 		QObject::connect(fSocketNotifier, SIGNAL(activated(int)),
+ 			this, SLOT(acceptDevice()));
+ 		fSocketNotifierActive=true;
+-		
++
+ 		if (fWorkaroundUSB)
+ 		{
+ #ifdef DEBUG
+-			DEBUGDAEMON << fname << ": Adding Z31 workaround." << endl;
++			DEBUGLIBRARY << fname << ": Adding Z31 workaround." << endl;
+ #endif
+ 			// Special case for Zire 31, 72, Tungsten T5,
+ 			// all of which may make a non-HotSync connection
+@@ -423,24 +615,15 @@ bool KPilotDeviceLink::open(QString devi
+ 				this,SLOT(workaroundUSB()));
+ 			fWorkaroundUSBTimer->start(5000,true);
+ 		}
+-		
++
+ 		return true;
+ 	}
+ 	else
+ 	{
+ #ifdef DEBUG
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-		DEBUGDAEMON << fname
+-			<< ": Tried "
+-			<< addr.pi_device
+-			<< " and got "
+-			<< strerror(errno)
+-			<< endl;
+-#else
+-		DEBUGDAEMON << fname
++		DEBUGLIBRARY << fname
+ 			<< ": Tried " << device << " and got " << strerror(errno) << endl;
+ #endif
+-#endif
+ 
+ 		if (fRetries < 5)
+ 		{
+@@ -536,9 +719,9 @@ void KPilotDeviceLink::acceptDevice()
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Found connection on device "<<pilotPath().latin1()<<endl;
+-	DEBUGDAEMON << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Current status "
+ 		<< statusString()
+ 		<< " and master " << fPilotMasterSocket << endl;
+@@ -604,14 +787,10 @@ void KPilotDeviceLink::acceptDevice()
+ #ifdef DEBUG
+ 	else
+ 	{
+-		DEBUGDAEMON << fname
++		DEBUGLIBRARY << fname
+ 			<< ": RomVersion=" << fPilotSysInfo->getRomVersion()
+ 			<< " Locale=" << fPilotSysInfo->getLocale()
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_10_0
+-			/* No prodID member */
+-#else
+ 			<< " Product=" << fPilotSysInfo->getProductID()
+-#endif
+ 			<< endl;
+ 	}
+ #endif
+@@ -623,17 +802,22 @@ void KPilotDeviceLink::acceptDevice()
+ 
+ 	/* Ask the pilot who it is.  And see if it's who we think it is. */
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Reading user info @"
+-		<< (long) fPilotUser << endl;
+-	DEBUGDAEMON << fname << ": Buffer @"
+-		<< (long) fPilotUser->pilotUser() << endl;
++	DEBUGLIBRARY << fname << ": Reading user info @"
++		<< (void *) fPilotUser << endl;
++	DEBUGLIBRARY << fname << ": Buffer @"
++		<< (void *) fPilotUser->pilotUser() << endl;
+ #endif
+ 
+ 	dlp_ReadUserInfo(fCurrentPilotSocket, fPilotUser->pilotUser());
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
+-		<< ": Read user name " << fPilotUser->getUserName() << endl;
++	const char *n = fPilotUser->getUserName();
++	DEBUGLIBRARY << fname
++		<< ": Read user name "
++		<< ( (!n || !*n) ?
++			"<empty>" :
++			fPilotUser->getUserName() )
++		<< endl;
+ #endif
+ 
+ 	emit logProgress(i18n("Checking last PC..."), 90);
+@@ -642,16 +826,10 @@ void KPilotDeviceLink::acceptDevice()
+ 	if ((ret=dlp_OpenConduit(fCurrentPilotSocket)) < 0)
+ 	{
+ #ifdef DEBUG
+-		DEBUGDAEMON << k_funcinfo
++		DEBUGLIBRARY << k_funcinfo
+ 			<< ": dlp_OpenConduit returned " << ret << endl;
+ #endif
+ 
+-#if 0
+-		fLinkStatus = SyncDone;
+-		emit logMessage(i18n
+-			("Exiting on cancel. All data not restored."));
+-		return;
+-#endif
+ 		emit logError(i18n("Could not read user information from the Pilot. "
+ 			"Perhaps you have a password set on the device?"));
+ 	}
+@@ -665,14 +843,14 @@ void KPilotDeviceLink::acceptDevice()
+ void KPilotDeviceLink::workaroundUSB()
+ {
+ 	FUNCTIONSETUP;
+-	
++
+ 	Q_ASSERT((fLinkStatus == DeviceOpen) || (fLinkStatus == WorkaroundUSB));
+ 	if (fLinkStatus == DeviceOpen)
+ 	{
+ 		reset();
+ 	}
+ 	fLinkStatus = WorkaroundUSB;
+-	
++
+ 	if (!QFile::exists(fRealPilotPath))
+ 	{
+ 		// Fake connection has vanished again.
+@@ -688,158 +866,17 @@ void KPilotDeviceLink::workaroundUSB()
+ 	QTimer::singleShot(1000,this,SLOT(workaroundUSB()));
+ }
+ 
+-bool KPilotDeviceLink::tickle() const
++/* virtual */ bool KPilotDeviceLink::tickle()
+ {
+ 	// No FUNCTIONSETUP here because it may be called from
+ 	// a separate thread.
+ 	return pi_tickle(pilotSocket()) >= 0;
+ }
+ 
+-class TickleThread : public QThread
+-{
+-public:
+-	TickleThread(KPilotDeviceLink *d, bool *done, int timeout) :
+-		QThread(),
+-		fHandle(d),
+-		fDone(done),
+-		fTimeout(timeout)
+-	{ };
+-	virtual ~TickleThread();
+-
+-	virtual void run();
+-
+-	static const int ChecksPerSecond = 5;
+-	static const int SecondsPerTickle = 5;
+-
+-private:
+-	KPilotDeviceLink *fHandle;
+-	bool *fDone;
+-	int fTimeout;
+-} ;
+-
+-TickleThread::~TickleThread()
+-{
+-}
+-
+-void TickleThread::run()
+-{
+-	FUNCTIONSETUP;
+-	int subseconds = ChecksPerSecond;
+-	int ticktock = SecondsPerTickle;
+-	int timeout = fTimeout;
+-#ifdef DEBUG_CERR
+-	DEBUGDAEMON << fname << ": Running for " << timeout << " seconds." << endl;
+-	DEBUGDAEMON << fname << ": Done @" << (void *) fDone << endl;
+-#endif
+-	while (!(*fDone))
+-	{
+-		QThread::msleep(1000/ChecksPerSecond);
+-		if (!(--subseconds))
+-		{
+-#ifdef DEBUG_CERR
+-// Don't dare use kdDebug() here, we're in a separate thread
+-			DEBUGDAEMON << fname << ": One second." << endl;
+-#endif
+-			if (timeout)
+-			{
+-				if (!(--timeout))
+-				{
+-					QApplication::postEvent(fHandle, new QEvent((QEvent::Type)(KPilotDeviceLink::TickleTimeoutEvent)));
+-					break;
+-				}
+-			}
+-			subseconds=ChecksPerSecond;
+-			if (!(--ticktock))
+-			{
+-#ifdef DEBUG_CERR
+-				DEBUGDAEMON << fname << ": Kietel kietel!." << endl;
+-#endif
+-				ticktock=SecondsPerTickle;
+-				fHandle->tickle();
+-			}
+-		}
+-	}
+-#ifdef DEBUG_CERR
+-	DEBUGDAEMON << fname << ": Finished." << endl;
+-#endif
+-}
+-
+-/*
+-** Deal with events, especially the ones used to signal a timeout
+-** in a tickle thread.
+-*/
+-
+-/* virtual */ bool KPilotDeviceLink::event(QEvent *e)
+-{
+-	if (e->type() == TickleTimeoutEvent)
+-	{
+-		stopTickle();
+-		emit timeout();
+-		return true;
+-	}
+-	else	return QObject::event(e);
+-}
+-
+-/*
+-Start a tickle thread with the indicated timeout.
+-*/
+-void KPilotDeviceLink::startTickle(unsigned int timeout)
++/* virtual */ void KPilotDeviceLink::addSyncLogEntryImpl( const QString &entry )
+ {
+-	FUNCTIONSETUP;
+-
+-	Q_ASSERT(fTickleDone);
+-
+-	/*
+-	** We've told the thread to finish up, but it hasn't
+-	** done so yet - so wait for it to do so, should be
+-	** only 200ms at most.
+-	*/
+-	if (fTickleDone && fTickleThread)
+-	{
+-		fTickleThread->wait();
+-		KPILOT_DELETE(fTickleThread);
+-	}
+-
+-#ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Done @" << (void *) (&fTickleDone) << endl;
+-#endif
+-	fTickleDone = false;
+-	fTickleThread = new TickleThread(this,&fTickleDone,timeout);
+-	fTickleThread->start();
+-}
+-
+-void KPilotDeviceLink::stopTickle()
+-{
+-	FUNCTIONSETUP;
+-	fTickleDone = true;
+-	if (fTickleThread)
+-	{
+-		fTickleThread->wait();
+-		KPILOT_DELETE(fTickleThread);
+-	}
+-}
+-
+-
+-int KPilotDeviceLink::installFiles(const QStringList & l, const bool deleteFiles)
+-{
+-	FUNCTIONSETUP;
+-
+-	QStringList::ConstIterator i;
+-	int k = 0;
+-	int n = 0;
+-
+-	for (i = l.begin(); i != l.end(); ++i)
+-	{
+-		emit logProgress(QString::null,
+-			(int) ((100.0 / l.count()) * (float) n));
+-
+-		if (installFile(*i, deleteFiles))
+-			k++;
+-		n++;
+-	}
+-	emit logProgress(QString::null, 100);
+-
+-	return k;
++	dlp_AddSyncLogEntry(fCurrentPilotSocket,
++		const_cast<char *>((const char *)Pilot::toPilot(entry)));
+ }
+ 
+ bool KPilotDeviceLink::installFile(const QString & f, const bool deleteFile)
+@@ -847,7 +884,7 @@ bool KPilotDeviceLink::installFile(const
+ 	FUNCTIONSETUP;
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Installing file " << f << endl;
++	DEBUGLIBRARY << fname << ": Installing file " << f << endl;
+ #endif
+ 
+ 	if (!QFile::exists(f))
+@@ -869,11 +906,7 @@ bool KPilotDeviceLink::installFile(const
+ 		return false;
+ 	}
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	if (pi_file_install(pf, fCurrentPilotSocket, 0) < 0)
+-#else
+ 	if (pi_file_install(pf, fCurrentPilotSocket, 0, 0L) < 0)
+-#endif
+ 	{
+ 		kdWarning() << k_funcinfo
+ 			<< ": Cannot pi_file_install " << f << endl;
+@@ -890,25 +923,6 @@ bool KPilotDeviceLink::installFile(const
+ }
+ 
+ 
+-void KPilotDeviceLink::addSyncLogEntry(const QString & entry, bool log)
+-{
+-	FUNCTIONSETUP;
+-	if (entry.isEmpty()) return;
+-
+-	QString t(entry);
+-
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_11_0
+-	t.append("X");
+-#endif
+-
+-	dlp_AddSyncLogEntry(fCurrentPilotSocket,
+-		const_cast<char *>((const char *)PilotAppCategory::codec()->fromUnicode(entry)));
+-	if (log)
+-	{
+-		emit logMessage(entry);
+-	}
+-}
+-
+ int KPilotDeviceLink::openConduit()
+ {
+ 	return dlp_OpenConduit(fCurrentPilotSocket);
+@@ -969,14 +983,14 @@ void KPilotDeviceLink::finishSync()
+ {
+ 	FUNCTIONSETUP ;
+ 
+-	getPilotUser()->setLastSyncPC((unsigned long) gethostid());
+-	getPilotUser()->setLastSyncDate(time(0));
++	getPilotUser().setLastSyncPC((unsigned long) gethostid());
++	getPilotUser().setLastSyncDate(time(0));
+ 
+-	
+-#ifdef DEBUG	
+-	DEBUGDAEMON << fname << ": Writing username " << getPilotUser()->getUserName() << endl;
++
++#ifdef DEBUG
++	DEBUGLIBRARY << fname << ": Writing username " << getPilotUser().getUserName() << endl;
+ #endif
+-	dlp_WriteUserInfo(pilotSocket(),getPilotUser()->pilotUser());
++	dlp_WriteUserInfo(pilotSocket(),getPilotUser().pilotUser());
+ 	addSyncLogEntry(i18n("End of HotSync\n"));
+ 	endOfSync();
+ }
+@@ -985,9 +999,6 @@ int KPilotDeviceLink::getNextDatabase(in
+ {
+ 	FUNCTIONSETUP;
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	return dlp_ReadDBList(pilotSocket(),0,dlpDBListRAM,index,dbinfo);
+-#else
+ 	pi_buffer_t buf = { 0,0,0 };
+ 	int r = dlp_ReadDBList(pilotSocket(),0,dlpDBListRAM,index,&buf);
+ 	if (r >= 0)
+@@ -995,12 +1006,11 @@ int KPilotDeviceLink::getNextDatabase(in
+ 		memcpy(dbinfo,buf.data,sizeof(struct DBInfo));
+ 	}
+ 	return r;
+-#endif
+ }
+ 
+ // Find a database with the given name. Info about the DB is stored into dbinfo (e.g. to be used later on with retrieveDatabase).
+ int KPilotDeviceLink::findDatabase(const char *name, struct DBInfo *dbinfo,
+-	int index, long type, long creator)
++	int index, unsigned long type, unsigned long creator)
+ {
+ 	FUNCTIONSETUP;
+ 	return dlp_FindDBInfo(pilotSocket(), 0, index,
+@@ -1013,7 +1023,7 @@ bool KPilotDeviceLink::retrieveDatabase(
+ 	FUNCTIONSETUP;
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Writing DB <" << info->name << "> "
++	DEBUGLIBRARY << fname << ": Writing DB <" << info->name << "> "
+ 		<< " to " << fullBackupName << endl;
+ #endif
+ 
+@@ -1036,11 +1046,7 @@ bool KPilotDeviceLink::retrieveDatabase(
+ 		return false;
+ 	}
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	if (pi_file_retrieve(f, pilotSocket(), 0) < 0)
+-#else
+ 	if (pi_file_retrieve(f, pilotSocket(), 0, 0L) < 0)
+-#endif
+ 	{
+ 		kdWarning() << k_funcinfo
+ 			<< ": Failed, unable to back up database" << endl;
+@@ -1054,26 +1060,13 @@ bool KPilotDeviceLink::retrieveDatabase(
+ }
+ 
+ 
+-QPtrList<DBInfo> KPilotDeviceLink::getDBList(int cardno, int flags)
++DBInfoList KPilotDeviceLink::getDBList(int cardno, int flags)
+ {
+ 	bool cont=true;
+-	QPtrList<DBInfo>dbs;
++	DBInfoList dbs;
+ 	int index=0;
+ 	while (cont)
+ 	{
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-		DBInfo*dbi=new DBInfo();
+-		if (dlp_ReadDBList(pilotSocket(), cardno, flags, index, dbi)<0)
+-		{
+-			KPILOT_DELETE(dbi);
+-			cont=false;
+-		}
+-		else
+-		{
+-			index=dbi->index+1;
+-			dbs.append(dbi);
+-		}
+-#else
+ 		pi_buffer_t buf = { 0,0,0 };
+ 		pi_buffer_clear(&buf);
+ 		// DBInfo*dbi=new DBInfo();
+@@ -1083,29 +1076,24 @@ QPtrList<DBInfo> KPilotDeviceLink::getDB
+ 		}
+ 		else
+ 		{
+-			DBInfo *db_n = 0L;
++			DBInfo db_n;
+ 			DBInfo *db_it = (DBInfo *)buf.data;
+ 			int info_count = buf.used / sizeof(struct DBInfo);
+ 
+ 			while(info_count>0)
+ 			{
+-				db_n = new DBInfo();
+-				memcpy(db_n,db_it,sizeof(struct DBInfo));
++				memcpy(&db_n,db_it,sizeof(struct DBInfo));
+ 				++db_it;
+ 				info_count--;
+ 				dbs.append(db_n);
+ 			}
+-			if (db_n)
+-			{
+-				index=db_n->index+1;
+-			}
++			index=db_n.index+1;
+ 		}
+-#endif
+ 	}
+ 	return dbs;
+ }
+ 
+-KPilotCard *KPilotDeviceLink::getCardInfo(int card)
++const KPilotCard *KPilotDeviceLink::getCardInfo(int card)
+ {
+ 	KPilotCard *cardinfo=new KPilotCard();
+ 	if (dlp_ReadStorageInfo(pilotSocket(), card, cardinfo->cardInfo())<0)
+@@ -1119,68 +1107,325 @@ KPilotCard *KPilotDeviceLink::getCardInf
+ 	return cardinfo;
+ }
+ 
+-QDateTime KPilotDeviceLink::getTime()
++/* static */ const int KPilotDeviceLink::messagesType=
++	(int)OpenFailMessage ;
++
++void KPilotDeviceLink::shouldPrint(int m,const QString &s)
+ {
+-	QDateTime time;
+-	time_t palmtime;
+-	if (dlp_GetSysDateTime(pilotSocket(), &palmtime))
++	if (!(messages & m))
+ 	{
+-		time.setTime_t(palmtime);
++		if (messagesType & m) { emit logError(s); }
++		else { emit logMessage(s); }
++		messages |= (m & messagesMask);
+ 	}
+-	return time;
+ }
+ 
+-bool KPilotDeviceLink::setTime(const time_t &pctime)
++PilotDatabase *KPilotDeviceLink::database( const QString &name )
+ {
+-//	struct tm time_tm=writeTm(time);
+-//	time_t pctime=mktime(&time_tm);
+-	return dlp_SetSysDateTime(pilotSocket(), pctime);
++	return new PilotSerialDatabase( this, name );
+ }
+ 
+ 
++typedef QPair<QString, struct DBInfo> DatabaseDescriptor;
++typedef QValueList<DatabaseDescriptor> DatabaseDescriptorList;
++
++class KPilotLocalLink::Private
++{
++public:
++	DatabaseDescriptorList fDBs;
++} ;
+ 
+-unsigned long KPilotDeviceLink::ROMversion() const
++unsigned int KPilotLocalLink::findAvailableDatabases( KPilotLocalLink::Private &info, const QString &path )
+ {
+-	unsigned long rom;
+-	dlp_ReadFeature(pilotSocket(),
+-		makelong(const_cast<char *>("psys")), 1, &rom);
+-	return rom;
++	FUNCTIONSETUP;
++
++	info.fDBs.clear();
++
++	QDir d(path);
++	if (!d.exists())
++	{
++		// Perhaps return an error?
++		return 0;
++	}
++
++	// Use this to fake indexes in the list of DBInfo structs
++	unsigned int counter = 0;
++
++	QStringList dbs = d.entryList( CSL1("*.pdb"), QDir::Files | QDir::NoSymLinks | QDir::Readable );
++	for ( QStringList::ConstIterator i = dbs.begin(); i != dbs.end() ; ++i)
++	{
++		struct DBInfo dbi;
++
++		// Remove the trailing 4 characters
++		QString dbname = (*i);
++		dbname.remove(dbname.length()-4,4);
++#ifdef DEBUG
++		QString dbnamecheck = (*i).left((*i).findRev(CSL1(".pdb")));
++		Q_ASSERT(dbname == dbnamecheck);
++#endif
++		if (PilotLocalDatabase::infoFromFile( path + CSL1("/") + (*i), &dbi))
++		{
++			DEBUGLIBRARY << fname << ": Loaded "
++				<< dbname << endl;
++			dbi.index = counter;
++			info.fDBs.append( DatabaseDescriptor(dbname,dbi) );
++			++counter;
++		}
++	}
++
++	DEBUGLIBRARY << fname << ": Total " << info.fDBs.count()
++		<< " databases." << endl;
++	return info.fDBs.count();
+ }
+-unsigned long KPilotDeviceLink::majorVersion() const
++
++
++KPilotLocalLink::KPilotLocalLink( QObject *parent, const char *name ) :
++	KPilotLink(parent,name),
++	fReady(false),
++	d( new Private )
+ {
+-	unsigned long rom=ROMversion();
+-	return (((rom >> 28) & 0xf) * 10)+ ((rom >> 24) & 0xf);
++	FUNCTIONSETUP;
+ }
+-unsigned long KPilotDeviceLink::minorVersion() const
++
++KPilotLocalLink::~KPilotLocalLink()
+ {
+-	unsigned long int rom=ROMversion();
+-	return (((rom >> 20) & 0xf) * 10)+ ((rom >> 16) & 0xf);
++	FUNCTIONSETUP;
++	KPILOT_DELETE(d);
+ }
+ 
+-/* static */ const int KPilotDeviceLink::messagesType=
+-	(int)OpenFailMessage ;
++/* virtual */ QString KPilotLocalLink::statusString() const
++{
++	return fReady ? CSL1("Ready") : CSL1("Waiting") ;
++}
+ 
+-void KPilotDeviceLink::shouldPrint(int m,const QString &s)
++/* virtual */ bool KPilotLocalLink::isConnected() const
+ {
+-	if (!(messages & m))
++	return fReady;
++}
++
++/* virtual */ void KPilotLocalLink::reset( const QString &p )
++{
++	FUNCTIONSETUP;
++	fPath = p;
++	reset();
++}
++
++/* virtual */ void KPilotLocalLink::reset()
++{
++	FUNCTIONSETUP;
++	QFileInfo info( fPath );
++	fReady = !fPath.isEmpty() && info.exists() && info.isDir() ;
++	if (fReady)
+ 	{
+-		if (messagesType & m) { emit logError(s); }
+-		else { emit logMessage(s); }
+-		messages |= (m & messagesMask);
++		findAvailableDatabases(*d, fPath);
++		QTimer::singleShot(500,this,SLOT(ready()));
++	}
++	else
++	{
++		kdWarning() << k_funcinfo << ": The local link path "
++			<< fPath
++			<< " does not exist or is not a direcotory. No sync will be done."
++			<< endl;
+ 	}
+ }
+ 
+-bool operator < (const db & a, const db & b) {
+-	if (a.creator == b.creator)
++/* virtual */ void KPilotLocalLink::close()
++{
++	fReady = false;
++}
++
++/* virtual */ bool KPilotLocalLink::tickle()
++{
++	return true;
++}
++
++/* virtual */ const KPilotCard *KPilotLocalLink::getCardInfo(int)
++{
++	return 0;
++}
++
++/* virtual */ void KPilotLocalLink::endOfSync()
++{
++}
++
++/* virtual */ void KPilotLocalLink::finishSync()
++{
++}
++
++/* virtual */ int KPilotLocalLink::openConduit()
++{
++	FUNCTIONSETUP;
++	return 0;
++}
++
++
++/* virtual */ int KPilotLocalLink::getNextDatabase( int index, struct DBInfo *info )
++{
++	FUNCTIONSETUP;
++
++	if ( (index<0) || (index>=(int)d->fDBs.count()) )
+ 	{
+-		if (a.type != b.type)
++		kdWarning() << k_funcinfo << ": Index out of range." << endl;
++		return -1;
++	}
++
++	DatabaseDescriptor dd = d->fDBs[index];
++
++	DEBUGLIBRARY << fname << ": Getting database " << dd.first << endl;
++
++	if (info)
++	{
++		*info = dd.second;
++	}
++
++	return index+1;
++}
++
++/* virtual */ int KPilotLocalLink::findDatabase(const char *name, struct DBInfo*info,
++		int index, unsigned long type, unsigned long creator)
++{
++	FUNCTIONSETUP;
++
++	if ( (index<0) || (index>=(int)d->fDBs.count()) )
++	{
++		kdWarning() << k_funcinfo << ": Index out of range." << endl;
++		return -1;
++	}
++
++	if (!name)
++	{
++		kdWarning() << k_funcinfo << ": NULL name." << endl;
++		return -1;
++	}
++
++	QString desiredName = Pilot::fromPilot(name);
++	DEBUGLIBRARY << fname << ": Looking for DB " << desiredName << endl;
++	for ( DatabaseDescriptorList::ConstIterator i = d->fDBs.at(index);
++		i != d->fDBs.end(); ++i)
++	{
++		const DatabaseDescriptor &dd = *i;
++		if (dd.first == desiredName)
+ 		{
+-			if (a.type == pi_mktag('a', 'p', 'p', 'l'))
+-				return false;
+-			else
+-				return true;
++			if ( (!type || (type == dd.second.type)) &&
++				(!creator || (creator == dd.second.creator)) )
++			{
++				if (info)
++				{
++					*info = dd.second;
++				}
++				return index;
++			}
+ 		}
++
++		++index;
++	}
++
++	return -1;
++}
++
++/* virtual */ void KPilotLocalLink::addSyncLogEntryImpl(QString const &s)
++{
++	FUNCTIONSETUP;
++	DEBUGLIBRARY << fname << ": " << s << endl ;
++}
++
++/* virtual */ bool KPilotLocalLink::installFile(QString const &path, bool deletefile)
++{
++	FUNCTIONSETUP;
++
++	QFileInfo srcInfo(path);
++	QString canonicalSrcPath = srcInfo.dir().canonicalPath() + CSL1("/") + srcInfo.fileName() ;
++	QString canonicalDstPath = fPath + CSL1("/") + srcInfo.fileName();
++
++	if (canonicalSrcPath == canonicalDstPath)
++	{
++		// That's a cheap copy operation
++		return true;
++	}
++
++	KURL src = KURL::fromPathOrURL( canonicalSrcPath );
++	KURL dst = KURL::fromPathOrURL( canonicalDstPath );
++
++	KIO::NetAccess::file_copy(src,dst,-1,true);
++
++	if (deletefile)
++	{
++		KIO::NetAccess::del(src, 0L);
++	}
++
++	return true;
++}
++
++/* virtual */ bool KPilotLocalLink::retrieveDatabase( const QString &path, struct DBInfo *db )
++{
++	FUNCTIONSETUP;
++
++	QString dbname = Pilot::fromPilot(db->name) + CSL1(".pdb") ;
++	QString sourcefile = fPath + CSL1("/") + dbname ;
++	QString destfile = path ;
++
++	DEBUGLIBRARY << fname << ": src=" << sourcefile << endl;
++	DEBUGLIBRARY << fname << ": dst=" << destfile << endl;
++
++	QFile in( sourcefile );
++	if ( !in.exists() )
++	{
++		kdWarning() << k_funcinfo<< ": Source file " << sourcefile << " doesn't exist." << endl;
++		return false;
++	}
++	if ( !in.open( IO_ReadOnly | IO_Raw ) )
++	{
++		kdWarning() << k_funcinfo << ": Can't read source file " << sourcefile << endl;
++		return false;
++	}
++
++	QFile out( destfile );
++	if ( !out.open( IO_WriteOnly | IO_Truncate | IO_Raw ) )
++	{
++		kdWarning() << k_funcinfo << ": Can't write destination file " << destfile << endl;
++		return false;
+ 	}
+ 
+-	return a.maxblock < b.maxblock;
++	const Q_ULONG BUF_SIZ = 8192 ;
++	char buf[BUF_SIZ];
++	Q_LONG r;
++
++	while ( (r=in.readBlock(buf,BUF_SIZ))>0 )
++	{
++		out.writeBlock(buf,r);
++	}
++	out.flush();
++	in.close();
++
++	return out.exists();
+ }
++
++/* virtual */ DBInfoList KPilotLocalLink::getDBList( int, int )
++{
++	FUNCTIONSETUP;
++	DBInfoList l;
++	for ( DatabaseDescriptorList::ConstIterator i=d->fDBs.begin();
++		i != d->fDBs.end(); ++i)
++	{
++		l.append( (*i).second );
++	}
++	return l;
++}
++
++
++/* virtual */ PilotDatabase *KPilotLocalLink::database( const QString &name )
++{
++	FUNCTIONSETUP;
++	return new PilotLocalDatabase( fPath, name );
++}
++
++
++
++/* slot */ void KPilotLocalLink::ready()
++{
++	if (fReady)
++	{
++		emit deviceReady(this);
++	}
++}
++
+diff -pruN kpilot/lib/kpilotlink.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/kpilotlink.h
+--- kpilot/lib/kpilotlink.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/kpilotlink.h	2006-11-26 23:53:25.000000000 +0100
+@@ -4,15 +4,10 @@
+ **
+ ** Copyright (C) 1998-2001 by Dan Pilone
+ ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
+ **
+ */
+ 
+-/** @file
+-** Encapsulates all the communication with the pilot. Also
+-** does daemon-like polling of the Pilot. Interesting status
+-** changes are signalled.
+-*/
+-
+ /*
+ ** This program is free software; you can redistribute it and/or modify
+ ** it under the terms of the GNU Lesser General Public License as published by
+@@ -38,7 +33,7 @@
+ #include <pi-dlp.h>
+ 
+ #include <qobject.h>
+-#include <qptrlist.h>
++#include <qvaluelist.h>
+ 
+ class QTimer;
+ class QDateTime;
+@@ -47,35 +42,20 @@ class QThread;
+ class KPilotUser;
+ class KPilotSysInfo;
+ class KPilotCard;
++class PilotDatabase;
+ struct DBInfo;
+ 
+-/**
+-** The struct db is a description class for Pilot databases
+-** by Kenneth Albanowski. It's not really clear why it's *here*.
+-** The macro pi_mktag is meant to be given four char (8-bit)
+-** quantities, which are arranged into an unsigned long; for example
+-** pi_mktag('l','n','c','h'). This is called the creator tag
+-** of a database, and db.creator can be compared with such a
+-** tag. The tag lnch is used by the Pilot's launcher app. Some
+-** parts of KPilot require such a tag.
+-*/
+-struct db
+-{
+-	char name[256];
+-	int flags;
+-	unsigned long creator;
+-	unsigned long type;
+-	int maxblock;
+-};
+-
+-#define pi_mktag(c1,c2,c3,c4) (((c1)<<24)|((c2)<<16)|((c3)<<8)|(c4))
+ 
+ 
+-
+-/** A class that handles some aspects of communication with the
+-** Handheld. A KPilotLink object represents a connection to a device
+-** (which may be active or inactive -- the latter in cases where
+-** the link is @e waiting for a device to show up). The object
++/** @file
++** Encapsulates all the communication with the pilot. Also
++** does daemon-like polling of the Pilot. Interesting status
++** changes are signalled.
++**
++** This file defines three classes; these handle some aspects of
++** communication with a Handheld. A KPilotLink object represents a
++** connection to a device (which may be active or inactive -- the latter in
++** cases where the link is @e waiting for a device to show up). The object
+ ** handles waiting, protocol initialization and some general
+ ** tasks such as getting system information or user data.
+ **
+@@ -83,73 +63,19 @@ struct db
+ ** PilotDatabase methods or use pilot-link dlp_* functions directly
+ ** on handle().
+ **
+-**
+ ** The KPilotLink class was originally a kind of C++ wrapper
+ ** for the pilot-link library. It grew and grew and mutated
+ ** until it was finally cleaned up again in 2001. In the meantime
+ ** it had become something that wrapped a lot more than just
+ ** pilot-link.
++**
++** This file defines an abstract base class KPilotLink, which may
++** be specialized for a real physical device that communicates
++** with DLP/SLP through the pilot-link library, or as a "fake"
++** device which uses data on the local filesystem to simulate
++** a device. These subclasses are KPilotDeviceLink and KPilotLocalLink.
+ */
+ 
+-class KDE_EXPORT KPilotDeviceLink : public QObject
+-{
+-friend class SyncAction;
+-Q_OBJECT
+-
+-/*
+-** Constructors and destructors.
+-*/
+-public:
+-	/**
+-	* Creates a pilot link that can sync to the pilot.
+-	*
+-	* Call reset() on it to start looking for a device.
+-	*/
+-	KPilotDeviceLink( QObject *parent = 0, const char *name = 0, const QString &tempDevice = QString::null );
+-	/** Destructor. This rudely ends the communication with the handheld. */
+-	virtual ~KPilotDeviceLink();
+-
+-
+-/*
+-** Status information
+-*/
+-
+-public:
+-	/**
+-	* The link behaves like a state machine most of the time:
+-	* it waits for the actual device to become available, and
+-	* then becomes ready to handle syncing.
+-	*/
+-	typedef enum {
+-		Init,
+-		WaitingForDevice,
+-		FoundDevice,
+-		CreatedSocket,
+-		DeviceOpen,
+-		AcceptedDevice,
+-		SyncDone,
+-		PilotLinkError,
+-		WorkaroundUSB
+-		} LinkStatus;
+-
+-	/** Get the status (state enum) of this link.
+-	* @return The LinkStatus enum for the link's current state.
+-	*/
+-	LinkStatus status() const { return fLinkStatus; } ;
+-	/** Get a human-readable string for the given status @p l. */
+-	static QString statusString(LinkStatus l);
+-	/** Get a human-readable string for the status of this object. */
+-	virtual QString statusString() const;
+-
+-	/**
+-	* True if HotSync has been started but not finished yet
+-	* (ie. the physical Pilot is waiting for sync commands)
+-	*/
+-	bool getConnected() const { return fLinkStatus == AcceptedDevice; }
+-
+-private:
+-	LinkStatus fLinkStatus;
+-
+ /**
+ * Tickle handling.
+ *
+@@ -213,270 +139,275 @@ private:
+ * with a non-zero timeout and that timeout has elapsed. The
+ * tickler is stopped before timeout is emitted.
+ */
+-public slots:
+-	bool tickle() const;
+-protected:
+-	void startTickle(unsigned int timeout=0);
+-	void stopTickle();
+-public:
+-	virtual bool event(QEvent *e);
+-	static const unsigned int TickleTimeoutEvent = 1066;
+ 
+-signals:
+-	void timeout();
++/** A list of DBInfo structures. */
++typedef QValueList<struct DBInfo> DBInfoList;
+ 
+-private:
+-	bool fTickleDone;
+-	QThread *fTickleThread;
++/** This is the abstract base class for Handheld interaction.
++*   It tries to define all the behavior that we need; calls
++*   to virtual *Impl() functions are used to implement the
++*   specific behavior for subclasses.
++*/
++class KDE_EXPORT KPilotLink : public QObject
++{
++Q_OBJECT
++friend class SyncAction;
++public:
++	/** Constructor. Use reset() to start looking for a device. */
++	KPilotLink( QObject *parent = 0, const char *name = 0 );
++	/** Destructor. This rudely interrupts any communication in progress. */
++	virtual ~KPilotLink();
+ 
+ 
++	/** Provides a human-readable status string. */
++	virtual QString statusString() const = 0;
+ 
++	/**
++	* True if HotSync has been started but not finished yet
++	* (ie. the physical Pilot is waiting for sync commands)
++	*/
++	virtual bool isConnected() const = 0;
+ 
+ 
+-/*
+-** Used for initially attaching to the device.
+-** deviceReady(KPilotDeviceLink*) is emitted when the device has been opened
+-** and a Sync can start.
+-*/
+-public:
+ 	/**
+ 	* Information on what kind of device we're dealing with.
++	* A link is associated with a path -- either the node in
++	* /dev that the physical device is attached to, or an
++	* IP address, or a filesystem path for local links.
++	* Whichever is being used, this function returns its
++	* name in a human-readable form.
+ 	*/
+ 	QString pilotPath() const { return fPilotPath; } ;
+ 
+ 	/**
+ 	* Return the device link to the Init state and try connecting
+-	* to the given device path (if it's non-empty).
++	* to the given device path (if it's non-empty). What the
++	* path means depends on the kind of link we're instantiating.
++	*
++	* @see reset()
++	* @see pilotPath()
+ 	*/
+-	void reset(const QString &pilotPath);
++	virtual void reset(const QString &pilotPath) = 0;
+ 
++	/** Implementation detail to handle tickle timeouts. */
++	virtual bool event(QEvent *e);
+ 
+-	/**
+-	* Special-cases. Call this after a reset to set device-
+-	* specific workarounds; the only one currently known
+-	* is the Zire 31/72 T5 quirk of doing a non-HotSync
+-	* connect when it's switched on.
++	/** Install the list of files (full paths!) named by @p l
++	*   onto the handheld (or whatever this link represents).
++	*   If @p deleteFiles  is true, the source files are removed.
++	*
++	*   @return the number of files successfully installed.
+ 	*/
+-	void setWorkarounds(bool usb)
+-	{
+-		fWorkaroundUSB = usb;
+-	} ;
++	unsigned int installFiles(const QStringList &l, const bool deleteFiles);
+ 
+ 	/**
+-	* sets an additional device, which should be tried as fallback
+-	* usefull for hotplug enviroments
++	* Write a log entry to the handheld. If @p log is true,
++	* then the signal logMessage() is also emitted. This
++	* function is supposed to @em only write to the handheld's
++	* log (with a physical device, that is what appears on
++	* screen at the end of a sync).
+ 	*/
+-	void setTempDevice( const QString &device );
+-
+-private:
+-	bool fWorkaroundUSB;
+-	QTimer *fWorkaroundUSBTimer;
++	void addSyncLogEntry(const QString &entry,bool log=true);
+ 
+-private slots:
+-	void workaroundUSB();
++	/** Find a database with the given @p name (and optionally,
++	*   type @p type and creator ID (from pi_mktag) @p creator,
++	*   on searching from index @p index on the handheld.
++	*   Fills in the DBInfo structure if found, returns < 0
++	*   on error.
++	*/
++	virtual int findDatabase(const char *name, struct DBInfo*,
++		int index=0, unsigned long type=0, unsigned long creator=0) = 0;
+ 
+-public slots:
+ 	/**
+-	* Release all resources, including the master pilot socket,
+-	* timers, notifiers, etc.
++	* Retrieve the database indicated by DBInfo @p *db into the
++	* local file @p path. This copies all the data, and you can
++	* create a PilotLocalDatabase from the resulting @p path .
++	*
++	* @return @c true on success
+ 	*/
+-	void close();
++	virtual bool retrieveDatabase(const QString &path, struct DBInfo *db) = 0;
+ 
+-	/**
+-	* Assuming things have been set up at least once already by
+-	* a call to reset() with parameters, use this slot to re-start
+-	* with the same settings.
++	/** Fill the DBInfo structure @p db with information about
++	*   the next database (in some ordering) counting from
++	*   @p index.
++	*   @return < 0 on error
++	*/
++	virtual int getNextDatabase(int index,struct DBInfo *db) = 0;
++
++	/** Returns a list of DBInfo structures describing all the
++	*   databases available on the link (ie. device) with the
++	*   given card number @p cardno and flags @p flags. No known
++	*   handheld uses a cardno other than 0; use flags to
++	*   indicate what kind of databases to fetch -- @c dlpDBListRAM
++	*   or @c dlpDBListROM.
++	*
++	*   @return list of DBInfo objects, one for each database
++	*   @note ownership of the DBInfo objects is passed to the
++	*         caller, who must delete the objects.
++	*/
++	virtual DBInfoList getDBList(int cardno=0, int flags=dlpDBListRAM) = 0;
++
++	/** Return a database object for manipulating the database with
++	*    name @p name on the link. This database may be local or
++	*    remote, depending on the kind of link in use.
++	*
++	*    @return pointer to database object, or 0 on error.
++	*    @note ownership of the database object is given to the caller,
++	*          who must delete the object in time.
+ 	*/
+-	void reset();
++	virtual PilotDatabase *database( const QString &name ) = 0;
+ 
+-protected slots:
+ 	/**
+-	* Attempt to open the device. Called regularly to check
+-	* if the device exists (to handle USB-style devices).
++	* Retrieve the user information from the device. Ownership
++	* is kept by the link, and at the end of a sync the user
++	* information is synced back to the link -- so it may be
++	* modified, but don't make local copies of it.
++	*
++	* @note Do not call this before the sync begins!
+ 	*/
+-	void openDevice();
++	KPilotUser &getPilotUser() { return *fPilotUser; }
+ 
+ 	/**
+-	* Called when the device is opened *and* activity occurs on the
+-	* device. This indicates the beginning of a hotsync.
++	* System information about the handheld. Ownership is kept
++	* by the link. For non-device links, something fake is
++	* returned.
++	*
++	* @note Do not call this before the sync begins!
+ 	*/
+-	void acceptDevice();
++	const KPilotSysInfo &getSysInfo() { return *fPilotSysInfo; }
+ 
+-protected:
+ 	/**
+-	* Does the low-level opening of the device and handles the
+-	* pilot-link library initialisation.
++	* Retrieve information about the data card @p card;
++	* I don't think that any pilot supports card numbers
++	* other than 0. Non-device links return something fake.
++	*
++	* This function may return NULL (non-device links or
++	* on error).
++	*
++	* @note Ownership of the KPilotCard object is given
++	*       to the caller, who must delete it.
+ 	*/
+-	bool open( QString device = QString::null );
++	virtual const KPilotCard *getCardInfo(int card=0) = 0;
+ 
+-	/**
+-	* Check for device permissions and existence, emitting
+-	* warnings for weird situations. This is primarily intended
+-	* to inform the user.
++	/** End the sync in a gracuful manner. */
++	virtual void endOfSync() = 0;
++	/** End the sync in a graceful manner @em and update
++	*   the last-sync time and user information on the handheld.
+ 	*/
+-	void checkDevice();
++	virtual void finishSync() = 0;
+ 
+-	/**
+-	* Some messages are only printed once and are suppressed
+-	* after that. These are indicated by flag bits in
+-	* messages.
++signals:
++	/** A timeout associated with tickling has occurred. Each
++	*   time startTickle() is called, you can state how long
++	*   tickling should last (at most) before timing out.
++	*
++	*   You can only get a timeout when the Qt event loop is
++	*   running, which somewhat limits the usefulness of timeouts.
+ 	*/
+-	enum { OpenMessage=1, OpenFailMessage=2 } ;
+-	int messages;
+-	int messagesMask;
+-	static const int messagesType;
++	void timeout();
+ 
+-	void shouldPrint(int,const QString &);
++	/** Signal that a message has been written to the sync log. */
++	void logMessage(const QString &);
++	/** Signal that an error has occurred, for logging. */
++	void logError(const QString &);
++	/** Signal that progress has been made, for logging purposes.
++	*   @p p is the percentage completed (0 <= s <= 100).
++	*   The string @p s is logged as well, if non-Null.
++	*/
++	void logProgress(const QString &s, int p);
+ 
+-signals:
+ 	/**
+ 	* Emitted once the user information has been read and
+ 	* the HotSync is really ready to go.
+ 	*/
+-	void deviceReady( KPilotDeviceLink* );
+-
+-protected:
+-	int pilotSocket() const { return fCurrentPilotSocket; } ;
++	void deviceReady( KPilotLink* );
+ 
+ 
+-private:
+-	/**
+-	* Path of the device special file that will be used.
+-	* Usually /dev/pilot, /dev/ttySx, or /dev/usb/x.
+-	*/
+-	QString fPilotPath;
++public slots:
+ 	/**
+-	* Path with resolved symlinks, to prevent double binding
+-	* to the same device.
++	* Release all resources, including the master pilot socket,
++	* timers, notifiers, etc.
+ 	*/
+-	QString fRealPilotPath;
++	virtual void close() = 0;
+ 
+ 	/**
+-	* For transient devices: how often have we tried pi_bind()?
++	* Assuming things have been set up at least once already by
++	* a call to reset() with parameters, use this slot to re-start
++	* with the same settings.
+ 	*/
+-	int fRetries;
++	virtual void reset() = 0;
+ 
+-	/**
+-	* Timers and Notifiers for detecting activity on the device.
+-	*/
+-	QTimer *fOpenTimer;
+-	QSocketNotifier *fSocketNotifier;
+-	bool fSocketNotifierActive;
++	/** Tickle the underlying device exactly once. */
++	virtual bool tickle() = 0;
+ 
++protected:
+ 	/**
+-	* Pilot-link library handles for the device once it's opened.
++	* Path of the device special file that will be used.
++	* Usually /dev/pilot, /dev/ttySx, or /dev/usb/x. May be
++	* a filesystem path for local links.
+ 	*/
+-	int fPilotMasterSocket;
+-	int fCurrentPilotSocket;
+-	QString fTempDevice;
++	QString fPilotPath;
+ 
+-	/**
+-	* Handle cases where we can't accept or open the device,
+-	* and data remains available on the pilot socket.
+-	*/
+-	int fAcceptedCount;
+-signals:
+-	/**
+-	* Whenever a conduit adds a Sync log entry (actually,
+-	* KPilotLink itself adds some log entries itself),
+-	* this signal is emitted.
++	/** Start tickling the Handheld (every few seconds). This
++	*   lasts until @p timeout seconds have passed (or forever
++	*   if @p timeout is zero).
++	*
++	*   @note Do not call startTickle() twice with no intervening
++	*         stopTickle().
+ 	*/
+-	void logEntry(const char *);
++	void startTickle(unsigned int timeout=0);
+ 
+-/*
+-** File installation.
+-*/
+-public:
+-	int installFiles(const QStringList &, const bool deleteFiles=true);
+-protected:
+-	bool installFile(const QString &, const bool deleteFile=true);
++	/** Stop tickling the Handheld. This may block for some
++	*   time (less than a second) to allow the tickle thread
++	*   to finish.
++	*/
++	void stopTickle();
+ 
+-	/**
+-	* Write a log entry to the pilot. Note that the library
+-	* function takes a char *, not const char * (which is
+-	* highly dubious). Causes signal logEntry(const char *)
+-	* to be emitted if @p log is true.
++	/** Install a single file onto the device link. Full pathname
++	*   @p f is used; in addition, if @p deleteFile is true remove
++	*   the source file. Returns @c true if the install succeeded.
++	*
++	*   The default
+ 	*/
+-	void addSyncLogEntry(const QString &entry,bool log=true);
++	virtual bool installFile( const QString &f, const bool deleteFile ) = 0;
+ 
+-signals:
+ 	/**
+-	* Whenever a conduit adds a Sync log entry (actually,
+-	* KPilotLink itself adds some log entries itself),
+-	* this signal is emitted.
++	* Notify the Pilot user that a conduit is running now.
++	* On real devices, this prints out (on screen) which database
++	* is now opened; useful for progress reporting.
++	*
++	* @return -1 on error
++	* @note the default implementation returns 0
+ 	*/
+-	void logMessage(const QString &);
+-	void logError(const QString &);
+-	void logProgress(const QString &, int);
++	virtual int openConduit();
+ 
++	/** Returns a file handle for raw operations. Not recommended.
++	*   On links with no physical device backing, returns -1.
++	*
++	*   @note the default implementation returns -1
++	*/
++	virtual int pilotSocket() const;
+ 
+-/*
+-** Pilot User Identity functions.
+-*/
+-protected:
+-	KPilotUser  *fPilotUser;
+-	KPilotSysInfo *fPilotSysInfo;
+-public:
+-	/**
+-	* Returns the user information as set in the KPilot settings dialog.
+-	* The user information can also be set by the Pilot, and at the
+-	* end of a HotSync the two user informations can be synced as well
+-	* with finishSync -- this writes fPilotUser again, so don't make
+-	* local copies of the KPilotUser structure and modify them.
+-	*/
+-	KPilotUser *getPilotUser() { return fPilotUser; }
+-	KPilotSysInfo *getSysInfo() { return fPilotSysInfo; }
+-	KPilotCard *getCardInfo(int card=0);
+-	void endOfSync();
+-	void finishSync();
++	/** Actually write an entry to the device link. The message
++	*   @p s is guaranteed to be non-Null.
++	*/
++	virtual void addSyncLogEntryImpl( const QString &s ) = 0;
+ 
+-/*
+-** Actions intended just to abstract away the pilot-link library interface.
+-*/
+-protected:
+-	/**
+-	* Notify the Pilot user which conduit is running now.
++	/** User information structure. Should be filled in when a sync
++	*   starts, so that conduits can use the information.
+ 	*/
+-	int openConduit();
+-public:
+-	int getNextDatabase(int index,struct DBInfo *);
+-	int findDatabase(const char *name, struct DBInfo*,
+-		int index=0, long type=0, long creator=0);
++	KPilotUser  *fPilotUser;
+ 
+-	/**
+-	* Retrieve the database indicated by DBInfo *db into the
+-	* local file @p path.
++	/** System information about the device. Filled in when the
++	*   sync starts. Non-device links need to fake something.
+ 	*/
+-	bool retrieveDatabase(const QString &path, struct DBInfo *db);
+-	QPtrList<DBInfo> getDBList(int cardno=0, int flags=dlpDBListRAM);
++	KPilotSysInfo *fPilotSysInfo;
+ 
+-public:
+-	/**
+-	 * Get the time from the handheld device into a QDateTime
+-	 */
+-	QDateTime getTime();
+-	/**
+-	 * Set the time on the handheld to the give QDateTime
+-	 */
+-	bool setTime(const time_t &pctime);
+-
+-	/**
+-	 * Get the version number from the handheld
+-	 */
+-	unsigned long ROMversion() const;
+-	/**
+-	 * Get the major PalmOS version number
+-	 */
+-	unsigned long majorVersion() const;
+-	/**
+-	 * Get the minor PalmOS version number
+-	 */
+-	unsigned long minorVersion() const;
+ 
+ private:
+-	class KPilotDeviceLinkPrivate;
+-} ;
++	bool fTickleDone;
++	QThread *fTickleThread;
+ 
+-bool operator < ( const struct db &, const struct db &) ;
++} ;
+ 
+ #endif
+diff -pruN kpilot/lib/kpilotlocallink.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/kpilotlocallink.h
+--- kpilot/lib/kpilotlocallink.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/kpilotlocallink.h	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,84 @@
++#ifndef _KPILOT_KPILOTLOCALLINK_H
++#define _KPILOT_KPILOTLOCALLINK_H
++/* kpilotlocallink.h			KPilot
++**
++** Copyright (C) 1998-2001 by Dan Pilone
++** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2006 Adriaan de Groot <groot at kde.org>
++**
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "kpilotlink.h"
++
++/** @file Definition of the local link class; implemented in kpilotlink.cc */
++
++
++/** Implementation of the device link for file-system backed (ie. local, fake)
++*   devices. Uses a directory specified in the reset() call to serve databases.
++*/
++class KDE_EXPORT KPilotLocalLink : public KPilotLink
++{
++Q_OBJECT
++public:
++	KPilotLocalLink( QObject *parent=0L, const char *name=0L );
++	virtual ~KPilotLocalLink();
++
++	virtual QString statusString() const;
++	virtual bool isConnected() const;
++	virtual void reset( const QString & );
++	virtual void close();
++	virtual void reset();
++	virtual bool tickle();
++	virtual const KPilotCard *getCardInfo(int card);
++	virtual void endOfSync();
++	virtual void finishSync();
++	virtual int openConduit();
++	virtual int getNextDatabase(int index,struct DBInfo *);
++	virtual int findDatabase(const char *name, struct DBInfo*,
++		int index=0, unsigned long type=0, unsigned long creator=0);
++	virtual bool retrieveDatabase(const QString &path, struct DBInfo *db);
++	virtual DBInfoList getDBList(int cardno=0, int flags=dlpDBListRAM);
++	virtual PilotDatabase *database( const QString &name );
++
++public slots:
++	void ready();
++
++protected:
++	virtual bool installFile(const QString &, const bool deleteFile);
++	virtual void addSyncLogEntryImpl( const QString &s );
++	virtual int pilotSocket() const { return -1; } ;
++
++protected:
++	bool fReady;
++	QString fPath;
++
++	class Private;
++	Private *d;
++
++	unsigned int findAvailableDatabases( Private &, const QString &path );
++} ;
++
++
++#endif
++
+diff -pruN kpilot/lib/Makefile.am /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/Makefile.am
+--- kpilot/lib/Makefile.am	2005-11-19 11:56:43.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/Makefile.am	2006-11-19 22:21:12.000000000 +0100
+@@ -22,42 +22,25 @@ libkpilot_la_SOURCES = kpilotlibSettings
+ 	pilotLocalDatabase.cc pilotSerialDatabase.cc \
+ 	pilotMemo.cc pilotAddress.cc \
+ 	pilotDateEntry.cc pilotTodoEntry.cc \
+-	recordConduit.cc
++	pilotStruct.cc
+ 
+-libkpilot_la_LDFLAGS = -no-undefined $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_EXTRA_RPATH) $(KDE_RPATH)
+-libkpilot_la_LIBADD = $(LIB_KDEUI) $(PISOCK_LIB) $(LIB_KABC) $(top_builddir)/libkcal/libkcal.la
++libkpilot_la_LDFLAGS = $(PISOCK_LDFLAGS) -no-undefined $(all_libraries) $(KDE_EXTRA_RPATH) $(KDE_RPATH)
++libkpilot_la_LIBADD = $(PISOCK_LIB) $(LIB_KDEUI) $(LIB_KABC) $(top_builddir)/libkcal/libkcal.la
+ 
+ kpilotincludedir = $(includedir)/kpilot
+ kpilotinclude_HEADERS = kpilotlink.h uiDialog.h \
+ 	plugin.h pluginfactory.h syncAction.h \
+ 	pilotRecord.h pilotDatabase.h \
+-	pilotLocalDatabase.h pilotSerialDatabase.h \
+-	pilotLinkVersion.h
++	pilotLocalDatabase.h pilotSerialDatabase.h
+ 
+ kde_kcfg_DATA = kpilotlib.kcfg
+ 
+-check_PROGRAMS = testactions testconstants testdatabase
+-TESTS = testactions testconstants testdatabase
+-
+-testactions_SOURCES = testactions.cc
+-testactions_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH)
+-testactions_LDADD  = libkpilot.la $(PISOCK_LIB)
+-
+-testconstants_SOURCES = testconstants.cc
+-testconstants_LDFLAGS = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH)
+-testconstants_LDADD   = libkpilot.la $(PISOCK_LIB)
+-
+-testdatabase_SOURCES  = testdatabase.cc
+-testdatabase_LDFLAGS  = $(PISOCK_LDFLAGS) $(all_libraries) $(KDE_RPATH)
+-testdatabase_LDADD    = libkpilot.la $(PISOCK_LIB)
+-testdatabase_CXXFLAGS = '-DSOURCE="$(srcdir)"'
+-
+ check-local:
+ 	rm -f FAILED
+ 	for i in $(srcdir)/*.h ; do \
+ 		( echo "#include <kdemacros.h>" ; echo "#include \"$$i\"" ; echo "int main(int argc,char **argv){return 0;}" ) > header-test.cc; \
+ 		echo "$$i" ; \
+-		g++ $(all_includes) $(PISOCK_INCLUDE) -c header-test.cc || echo "$$i" >> FAILED; \
++		g++ $(all_includes) -c header-test.cc || echo "$$i" >> FAILED; \
+ 	done
+ 	test ! -e FAILED
+ 
+diff -pruN kpilot/lib/options.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/options.cc
+--- kpilot/lib/options.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/options.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,25 +28,11 @@
+ */
+ 
+ 
+-static const char *options_id =
+-	"$Id: options.cc 449050 2005-08-14 05:03:22Z vanrijn $";
+-
+ #include "options.h"
+ 
+ 
+ #include <iostream>
+ 
+-#if TIME_WITH_SYS_TIME
+-# include <sys/time.h>
+-# include <time.h>
+-#else
+-# if HAVE_SYS_TIME_H
+-#  include <sys/time.h>
+-# else
+-#  include <time.h>
+-# endif
+-#endif
+-
+ #include <qsize.h>
+ 
+ #include <kconfig.h>
+@@ -57,7 +43,11 @@ static const char *options_id =
+ // to align FUNCTIONSETUP output.
+ //
+ //
++#ifdef DEBUG
++int debug_level = 1;
++#else
+ int debug_level = 0;
++#endif
+ const char *debug_spaces =
+ 	"                                                    ";
+ QString rtExpand(const QString &s, bool richText)
+@@ -70,56 +60,45 @@ QString rtExpand(const QString &s, bool 
+ 	else
+ 		return s;
+ 
+-	Q_UNUSED(options_id);
+ }
+ 
+ QDateTime readTm(const struct tm &t)
+ {
+-  QDateTime dt;
+-  dt.setDate(QDate(1900 + t.tm_year, t.tm_mon + 1, t.tm_mday));
+-  dt.setTime(QTime(t.tm_hour, t.tm_min, t.tm_sec));
+-  return dt;
++	QDateTime dt;
++	dt.setDate(QDate(1900 + t.tm_year, t.tm_mon + 1, t.tm_mday));
++	dt.setTime(QTime(t.tm_hour, t.tm_min, t.tm_sec));
++	return dt;
+ }
+ 
+ 
+ 
+ struct tm writeTm(const QDateTime &dt)
+ {
+-  struct tm t;
++	struct tm t;
+ 
+-  t.tm_wday = 0; // unimplemented
+-  t.tm_yday = 0; // unimplemented
+-  t.tm_isdst = 0; // unimplemented
+-  t.tm_zone = 0; // unimplemented
++	t.tm_wday = 0; // unimplemented
++	t.tm_yday = 0; // unimplemented
++	t.tm_isdst = 0; // unimplemented
++#ifdef HAVE_STRUCT_TM_TM_ZONE
++	t.tm_zone = 0; // unimplemented
++#endif
+ 
+-  t.tm_year = dt.date().year() - 1900;
+-  t.tm_mon = dt.date().month() - 1;
+-  t.tm_mday = dt.date().day();
+-  t.tm_hour = dt.time().hour();
+-  t.tm_min = dt.time().minute();
+-  t.tm_sec = dt.time().second();
++	t.tm_year = dt.date().year() - 1900;
++	t.tm_mon = dt.date().month() - 1;
++	t.tm_mday = dt.date().day();
++	t.tm_hour = dt.time().hour();
++	t.tm_min = dt.time().minute();
++	t.tm_sec = dt.time().second();
+ 
+-  return t;
++	return t;
+ }
+ 
+ 
+ 
+-struct tm writeTm(const QDate &dt)
++struct tm writeTm(const QDate &d)
+ {
+-  struct tm t;
+-
+-  t.tm_wday = 0; // unimplemented
+-  t.tm_yday = 0; // unimplemented
+-  t.tm_isdst = 0; // unimplemented
+-
+-  t.tm_year = dt.year() - 1900;
+-  t.tm_mon = dt.month() - 1;
+-  t.tm_mday = dt.day();
+-  t.tm_hour = 0;
+-  t.tm_min = 0;
+-  t.tm_sec = 0;
+-
+-  return t;
++	QDateTime dt(d);
++	return writeTm(dt);
+ }
+ 
+ #ifdef DEBUG
+@@ -131,7 +110,8 @@ KPilotDepthCount::KPilotDepthCount(int a
+ 	if (debug_level>=fLevel)
+ 	{
+ #ifdef DEBUG_CERR
+-		DEBUGKPILOT
++		Q_UNUSED(area);
++		DEBUGLIBRARY
+ #else
+ 		debug(area)
+ #endif
+diff -pruN kpilot/lib/options.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/options.h
+--- kpilot/lib/options.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/options.h	2006-11-26 23:53:25.000000000 +0100
+@@ -52,19 +52,16 @@
+ 
+ // Switch _on_ debugging if it's not off.
+ //
+-#ifndef NDEBUG
+-#ifndef DEBUG
+-#define DEBUG				(1)
+-#endif
+-#endif
++#undef NDEBUG
+ 
+ // Switch on debugging explicitly. Perhaps send debug to stderr instead
+-// of to the KDE debugging facility (it does lose some niftiness then).
++// of to the KDE debugging facility (it does lose some niftiness then), but
++// it seems to be required with FC6 and others possibly.
+ //
+ #ifndef DEBUG
+-// #define DEBUG			(1)
++#define DEBUG			(1)
+ #endif
+-// #define DEBUG_CERR			(1)
++#define DEBUG_CERR		(1)
+ 
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+@@ -72,19 +69,21 @@
+ 
+ #include <unistd.h>     /* For size_t for pilot-link */
+ #include <qglobal.h>
+-// For KDE_EXPORT with kdelibs 3.3.x
+-#include <kdepimmacros.h>
+ 
+-#if (QT_VERSION < 0x030200)
+-#error "This is KPilot for KDE3.3 and won't compile with Qt < 3.2.0"
++#if (QT_VERSION < 0x030300)
++#error "This is KPilot for KDE3.5 and won't compile with Qt < 3.3.0"
+ #endif
+ 
+ #ifndef KDE_VERSION
+ #include <kdeversion.h>
+ #endif
+ 
+-#if !(KDE_IS_VERSION(3,3,0))
+-#error "This is KPilot for KDE 3.3 and won't compile with KDE < 3.3.0"
++#if !(KDE_IS_VERSION(3,4,0))
++#error "This is KPilot for (really) KDE 3.5 and won't compile with KDE < 3.4.0"
++#endif
++
++#if !(KDE_IS_VERSION(3,5,0))
++#warning "This is KPilot for KDE 3.5 and might not compile with KDE < 3.5.0"
+ #endif
+ 
+ #include "pilotLinkVersion.h"
+@@ -116,7 +115,7 @@ extern KDE_EXPORT int debug_level;
+ #define DEBUGAREA 		0
+ 
+ #define DEBUGAREA_KPILOT	5510
+-#define DEBUGAREA_DAEMON	5511
++#define DEBUGAREA_LIBRARY	5511
+ #define DEBUGAREA_CONDUIT	5512
+ #define DEBUGAREA_DB		5513
+ 
+@@ -151,10 +150,9 @@ protected:
+ #ifdef DEBUG_CERR
+ #include <iostream>
+ #define DEBUGKPILOT	std::cerr
+-#define DEBUGDAEMON	std::cerr
++#define DEBUGLIBRARY	std::cerr
+ #define DEBUGCONDUIT	std::cerr
+ #define DEBUGDB		std::cerr
+-
+ using namespace std;
+ 
+ inline std::ostream& operator <<(std::ostream &o, const QString &s)
+@@ -173,7 +171,7 @@ inline std::ostream& operator <<(std::os
+ //
+ //
+ #define DEBUGKPILOT	fname.debug(DEBUGAREA_KPILOT)
+-#define DEBUGDAEMON	fname.debug(DEBUGAREA_DAEMON)
++#define DEBUGLIBRARY	fname.debug(DEBUGAREA_LIBRARY)
+ #define DEBUGCONDUIT	fname.debug(DEBUGAREA_CONDUIT)
+ #define DEBUGDB         fname.debug(DEBUGAREA_DB)
+ 
+@@ -188,7 +186,7 @@ inline kdbgstream& operator <<(kdbgstrea
+ #else
+ #define DEBUGSTREAM	kndbgstream
+ #define DEBUGKPILOT	kndDebug()
+-#define DEBUGDAEMON	kndDebug()
++#define DEBUGLIBRARY	kndDebug()
+ #define DEBUGCONDUIT	kndDebug()
+ #define DEBUGDB         kndDebug()
+ 
+@@ -199,7 +197,7 @@ inline kdbgstream& operator <<(kdbgstrea
+ #define FUNCTIONSETUPL(a) const int fname = a; Q_UNUSED(fname);
+ #endif
+ 
+-#define KPILOT_VERSION	"4.6.0 (blivit)"
++#define KPILOT_VERSION	"4.9.0 (depth9)"
+ 
+ 
+ // Function to expand newlines in rich text to <br>\n
+diff -pruN kpilot/lib/pilotAddress.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotAddress.cc
+--- kpilot/lib/pilotAddress.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotAddress.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,17 +28,14 @@
+ */
+ 
+ 
+-static const char *pilotadress_id =
+-	"$Id: pilotAddress.cc 450284 2005-08-17 20:49:09Z adridg $";
+-
+-#ifndef _KPILOT_OPTIONS_H
++#include <config.h>
+ #include "options.h"
+-#endif
++#include "fakes.h"
++
+ 
+ #include <stdlib.h>
+ #include <assert.h>
+ 
+-#include <qtextcodec.h>
+ #include <qstringlist.h>
+ 
+ #include "pilotAddress.h"
+@@ -46,45 +43,8 @@ static const char *pilotadress_id =
+ 
+ #define MAXFIELDS 19
+ 
+-PilotAddress::PilotAddress(struct AddressAppInfo &appInfo,
+-	PilotRecord * rec) :
+-	PilotAppCategory(rec),
+-	fAppInfo(appInfo),
+-	fAddressInfo()
+-{
+-	FUNCTIONSETUPL(4);
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-	pi_buffer_t b;
+-	b.data = (unsigned char *) rec->getData();
+-	b.allocated = b.used = rec->size();
+-	if (rec) unpack_Address(&fAddressInfo, &b, address_v1);
+-#else
+-	if (rec) unpack_Address(&fAddressInfo, (unsigned char *) rec->data(), rec->size());
+-#endif
+-	(void) pilotadress_id;
+-	_loadMaps();
+-}
+-
+-PilotAddress::PilotAddress(struct AddressAppInfo &appInfo) :
+-	PilotAppCategory(),
+-	fAppInfo(appInfo)
+-{
+-	FUNCTIONSETUPL(4);
+-	reset();
+-
+-	// assign the phoneLabel so it doesn't appear in the pilot as
+-	// work for all fields, but at least shows other fields
+-	fAddressInfo.phoneLabel[0] = (int) eWork;
+-	fAddressInfo.phoneLabel[1] = (int) eHome;
+-	fAddressInfo.phoneLabel[2] = (int) eOther;
+-	fAddressInfo.phoneLabel[3] = (int) eMobile;
+-	fAddressInfo.phoneLabel[4] = (int) eEmail;
+-
+-	_loadMaps();
+-}
+-
+ PilotAddress::PilotAddress(PilotAddressInfo *info, PilotRecord *rec) :
+-	PilotAppCategory(rec),
++	PilotRecordBase(rec),
+ 	fAppInfo(*(info->info())),
+ 	fAddressInfo()
+ {
+@@ -93,14 +53,10 @@ PilotAddress::PilotAddress(PilotAddressI
+ 
+ 	if (rec)
+ 	{
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 		pi_buffer_t b;
+-		b.data = (unsigned char *) rec->getData();
++		b.data = (unsigned char *) rec->data();
+ 		b.allocated = b.used = rec->size();
+ 		unpack_Address(&fAddressInfo, &b, address_v1);
+-#else
+-		unpack_Address(&fAddressInfo, (unsigned char *) rec->data(), rec->size());
+-#endif
+ 	}
+ 	else
+ 	{
+@@ -115,7 +71,7 @@ PilotAddress::PilotAddress(PilotAddressI
+ }
+ 
+ PilotAddress::PilotAddress(const PilotAddress & copyFrom) :
+-	PilotAppCategory(copyFrom),
++	PilotRecordBase(copyFrom),
+ 	fAppInfo(copyFrom.fAppInfo),
+ 	fAddressInfo()
+ {
+@@ -128,7 +84,7 @@ PilotAddress::PilotAddress(const PilotAd
+ PilotAddress & PilotAddress::operator = (const PilotAddress & copyFrom)
+ {
+ 	FUNCTIONSETUPL(4);
+-	PilotAppCategory::operator = (copyFrom);
++	PilotRecordBase::operator = (copyFrom);
+ 	_copyAddressInfo(copyFrom.fAddressInfo);
+ 	return *this;
+ }
+@@ -226,7 +182,7 @@ QString PilotAddress::getTextRepresentat
+ 			}
+ 			else
+ 				tmp=CSL1("%1: %2");
+-			tmp=tmp.arg(PilotAppCategory::codec()->toUnicode(
++			tmp=tmp.arg(Pilot::fromPilot(
+ 				fAppInfo.phoneLabels[getPhoneLabelIndex(i-entryPhone1)]));
+ 			tmp=tmp.arg(rtExpand(getField(i), richText));
+ 			text += tmp;
+@@ -296,7 +252,7 @@ QString PilotAddress::getTextRepresentat
+ QString PilotAddress::getCategoryLabel() const
+ {
+ 	int cat(category());
+-	if (cat>0) return codec()->toUnicode(fAppInfo.category.name[cat]);
++	if (cat>0) return Pilot::fromPilot(fAppInfo.category.name[cat]);
+ 	else return QString::null;
+ }
+ 
+@@ -320,7 +276,7 @@ QStringList PilotAddress::getEmails() co
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": returning: ["
++	DEBUGLIBRARY << fname << ": returning: ["
+ 				<< list.size() << "] e-mail addresses." << endl;
+ #endif
+ 	return list;
+@@ -335,7 +291,7 @@ KABC::PhoneNumber::List PilotAddress::ge
+ 
+ 	int shownPhone = getShownPhone() + entryPhone1;
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": preferred pilot index is: ["
++	DEBUGLIBRARY << fname << ": preferred pilot index is: ["
+ 				<< shownPhone << "], preferred phone number is: ["
+ 				<< getField(shownPhone) << "]" << endl;
+ #endif
+@@ -359,7 +315,7 @@ KABC::PhoneNumber::List PilotAddress::ge
+ 					if (shownPhone == i) {
+ 						phoneType |= KABC::PhoneNumber::Pref;
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": found preferred pilot index: ["
++	DEBUGLIBRARY << fname << ": found preferred pilot index: ["
+ 				<< i << "], text: [" << test << "]" << endl;
+ #endif
+ 					}
+@@ -367,7 +323,7 @@ KABC::PhoneNumber::List PilotAddress::ge
+ 					list.append(ph);
+ 				} else {
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": whoopsie.  pilot phone number: ["
++	DEBUGLIBRARY << fname << ": whoopsie.  pilot phone number: ["
+ 				<< test << "], index: [" << i << "], type: ["
+ 				<< ind << "], has no corresponding PhoneNumber type." << endl;
+ #endif
+@@ -376,7 +332,7 @@ KABC::PhoneNumber::List PilotAddress::ge
+ 		}
+ 	}
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": returning: ["
++	DEBUGLIBRARY << fname << ": returning: ["
+ 				<< list.size() << "] phone numbers" << endl;
+ #endif
+ 	return list;
+@@ -420,7 +376,7 @@ void PilotAddress::setPhoneNumbers(KABC:
+ 			if ( phone.type() & phoneKey)
+ 			{
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": found pilot type: ["
++	DEBUGLIBRARY << fname << ": found pilot type: ["
+ 				<< pilotKey << "] ("
+ 				<< fAppInfo.phoneLabels[pilotKey]
+ 				<< ") for PhoneNumber: ["
+@@ -436,7 +392,7 @@ void PilotAddress::setPhoneNumbers(KABC:
+ 		// if this is the preferred phone number, then set it as such
+ 		if (phone.type() & KABC::PhoneNumber::Pref) {
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": found preferred PhoneNumber. "
++	DEBUGLIBRARY << fname << ": found preferred PhoneNumber. "
+ 				<< "setting showPhone to index: ["
+ 				<< fieldSlot << "], PhoneNumber: ["
+ 				<< phone.number() << "]" << endl;
+@@ -446,7 +402,7 @@ void PilotAddress::setPhoneNumbers(KABC:
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Pilot's showPhone now: ["
++	DEBUGLIBRARY << fname << ": Pilot's showPhone now: ["
+ 				<< fAddressInfo.showPhone << "]." << endl;
+ #endif
+ 
+@@ -455,7 +411,7 @@ void PilotAddress::setPhoneNumbers(KABC:
+ 	QString pref = getField(fAddressInfo.showPhone + entryPhone1);
+ 	if (fAddressInfo.showPhone < 0 || fAddressInfo.showPhone > 4 || pref.isEmpty()) {
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Pilot's showPhone: ["
++	DEBUGLIBRARY << fname << ": Pilot's showPhone: ["
+ 				<< fAddressInfo.showPhone
+ 				<< "] not properly set to a default. trying to set a sensible one."
+ 				<< endl;
+@@ -471,7 +427,7 @@ void PilotAddress::setPhoneNumbers(KABC:
+ 		}
+ 	}
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": Pilot's showPhone now: ["
++	DEBUGLIBRARY << fname << ": Pilot's showPhone now: ["
+ 				<< fAddressInfo.showPhone << "], and that's final." << endl;
+ #endif
+ }
+@@ -544,7 +500,7 @@ void PilotAddress::_loadMaps()
+ 
+ QString PilotAddress::getField(int field) const
+ {
+-	return codec()->toUnicode(fAddressInfo.entry[field]);
++	return Pilot::fromPilot(fAddressInfo.entry[field]);
+ }
+ 
+ int PilotAddress::_getNextEmptyPhoneSlot() const
+@@ -582,7 +538,7 @@ int PilotAddress::setPhoneField(EPhoneTy
+ 		{
+ 			QString custom4Field = getField(entryCustom4);
+ 			QString typeStr(
+-				codec()->toUnicode(fAppInfo.phoneLabels[appPhoneLabelNum]));
++				Pilot::fromPilot(fAppInfo.phoneLabels[appPhoneLabelNum]));
+ 
+ 			custom4Field += typeStr + CSL1(" ") + fieldStr;
+ 			setField(entryCustom4, custom4Field);
+@@ -628,7 +584,7 @@ QString PilotAddress::getPhoneField(EPho
+ 		return QString::null;
+ 
+ 	// look for the phone type str
+-	QString typeToStr(codec()->toUnicode(fAppInfo.phoneLabels[appTypeNum]));
++	QString typeToStr(Pilot::fromPilot(fAppInfo.phoneLabels[appTypeNum]));
+ 	QString customField(getField(entryCustom4));
+ 	int foundField = customField.find(typeToStr);
+ 
+@@ -655,7 +611,7 @@ int PilotAddress::_getAppPhoneLabelNum(c
+ 	FUNCTIONSETUPL(4);
+ 	for (int index = 0; index < 8; index++)
+ 	{
+-		if (phoneType == codec()->toUnicode(fAppInfo.phoneLabels[index]))
++		if (phoneType == Pilot::fromPilot(fAppInfo.phoneLabels[index]))
+ 			return index;
+ 	}
+ 
+@@ -693,7 +649,7 @@ void PilotAddress::setField(int field, c
+ 	if (!text.isEmpty())
+ 	{
+ 		fAddressInfo.entry[field] = (char *) malloc(text.length() + 1);
+-		strlcpy(fAddressInfo.entry[field], codec()->fromUnicode(text), text.length() + 1);
++		strlcpy(fAddressInfo.entry[field], Pilot::toPilot(text), text.length() + 1);
+ 	}
+ 	else
+ 	{
+@@ -701,20 +657,17 @@ void PilotAddress::setField(int field, c
+ 	}
+ }
+ 
+-void *PilotAddress::pack_(void *buf, int *len)
++PilotRecord *PilotAddress::pack() const
+ {
+ 	FUNCTIONSETUPL(4);
+ 	int i;
+ 
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-	pi_buffer_t b = { 0,0,0 } ;
+-	i = pack_Address(&fAddressInfo, &b, address_v1);
+-	memcpy(buf,b.data,kMin(i,*len));
+-	*len = kMin(i,*len);
+-#else
+-	i = pack_Address(&fAddressInfo, (unsigned char *) buf, *len);
+-	*len = i;
+-#endif
+-	return buf;
++	pi_buffer_t *b = pi_buffer_new( sizeof(fAddressInfo) );
++	i = pack_Address(const_cast<Address_t *>(&fAddressInfo), b, address_v1);
++	if (i<0)
++	{
++		return 0L;
++	}
++	// pack_Address sets b->used
++	return new PilotRecord( b, this );
+ }
+-
+diff -pruN kpilot/lib/pilotAddress.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotAddress.h
+--- kpilot/lib/pilotAddress.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotAddress.h	2006-11-26 23:53:25.000000000 +0100
+@@ -34,8 +34,8 @@
+ 
+ #include <kabc/addressbook.h>
+ 
+-#include "pilotAppCategory.h"
+-#include "pilotDatabase.h"
++#include "pilotRecord.h"
++#include "pilotAppInfo.h"
+ 
+ /** @brief A wrapper class around the Address struct provided by pi-address.h
+  *
+@@ -78,7 +78,7 @@ namespace KABC
+ 
+ typedef PilotAppInfo<AddressAppInfo,unpack_AddressAppInfo, pack_AddressAppInfo> PilotAddressInfo;
+ 
+-class KDE_EXPORT PilotAddress : public PilotAppCategory
++class KDE_EXPORT PilotAddress : public PilotRecordBase
+ {
+ public:
+ 	enum EPhoneType {
+@@ -86,14 +86,12 @@ public:
+ 		ePager, eMobile
+ 		};
+ 
+-	PilotAddress(struct AddressAppInfo &appInfo) KDE_DEPRECATED ;
+-	PilotAddress(struct AddressAppInfo &appInfo, PilotRecord* rec) KDE_DEPRECATED ;
+ 	PilotAddress(PilotAddressInfo *appinfo, PilotRecord *rec = 0L);
+ 	PilotAddress(const PilotAddress &copyFrom);
+ 	PilotAddress& operator=( const PilotAddress &r );
+ 	bool operator==(const PilotAddress &r);
+ 
+-	~PilotAddress();
++	virtual ~PilotAddress();
+ 
+ 	/** Returns a text representation of the address. If richText is true, the
+ 	 *  text is allowed to contain Qt-HTML tags.
+@@ -119,17 +117,17 @@ public:
+ 	void setField(int field, const QString &text);
+ 	QString getField(int field) const;
+ 
+-    /**
+-      Return list of all email addresses.  This will search through our "phone"
+-	  fields and will return only those which are e-mail addresses.
+-     */
+-    QStringList getEmails() const;
++	/**
++	*   Return list of all email addresses.  This will search through our "phone"
++	*   fields and will return only those which are e-mail addresses.
++	*/
++	QStringList getEmails() const;
+ 	void setEmails(QStringList emails);
+ 
+-    /**
+-	Return list of all phone numbers.  This will search through our "phone"
+-	fields and will return only those which are not e-mail addresses.
+-	 */
++	/**
++	*   Return list of all phone numbers.  This will search through our "phone"
++	*   fields and will return only those which are not e-mail addresses.
++	*/
+ 	KABC::PhoneNumber::List getPhoneNumbers() const;
+ 	void setPhoneNumbers(KABC::PhoneNumber::List list);
+ 
+@@ -139,7 +137,7 @@ public:
+ 	*  to the category list
+ 	*  @return false if category labels are full
+ 	*/
+-	inline bool setCategory(const QString &label) { return PilotAppCategory::setCategory(fAppInfo.category,label); } ;
++	inline bool setCategory(const QString &label) { return Pilot::insertCategory(&fAppInfo.category,label,false)>=0; } ;
+ 
+ 
+ 	/**
+@@ -175,10 +173,7 @@ public:
+ 	int  getPhoneLabelIndex(int index) const { return fAddressInfo.phoneLabel[index]; }
+ 
+ 
+-	virtual void *pack_(void *, int *);
+-	void unpack(const void *, int = 0) { }
+-
+-	static const int APP_BUFFER_SIZE;
++	PilotRecord *pack() const;
+ 
+ 	const struct Address *address() const { return &fAddressInfo; } ;
+ 
+diff -pruN kpilot/lib/pilotAppCategory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotAppCategory.h
+--- kpilot/lib/pilotAppCategory.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotAppCategory.h	1970-01-01 01:00:00.000000000 +0100
+@@ -1,198 +0,0 @@
+-#ifndef _KPILOT_PILOTAPPCATEGORY_H
+-#define _KPILOT_PILOTAPPCATEGORY_H
+-/* pilotAppCategory.h			KPilot
+-**
+-** Copyright (C) 1998-2001 by Dan Pilone
+-** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
+-**
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-/**
+-* @file The class PilotAppCategory is the base class for "interpretations"
+-* of a PilotRecord. This is where the records change from a collection
+-* of bits to something with meaning. Subclasses of PilotAppCategory
+-* give specific meaning to records from specific databases.
+-*
+-* Almost everything is inline; as a crufty hack, the non-inline
+-* part of this class lives in pilotRecord.cc.
+-*/
+-
+-#include <qstring.h>
+-#include <klocale.h>
+-
+-#include <pi-appinfo.h>
+-
+-#include "pilotRecord.h"
+-
+-class QTextCodec;
+-
+-/**
+-* Base class for interpretations of the binary blobs. Also
+-* exposes the common characteristics of all entries (in general,
+-* these characteristics are copied from the binary blob that
+-* this interpretation represents).
+-*
+-* Since this is the base of interpretation of the binary blobs,
+-* we include codec() here, which is used to translate from and to
+-* the handheld native (8 bit) encoding.
+-*/
+-class KDE_EXPORT PilotAppCategory : public PilotRecordBase
+-{
+-protected:			// Use protected since we will be subclassed
+-	/**
+-	* Pack whatever data the interpreted record holds into the given
+-	* buffer, of length @p size; return NULL to indicate failure,
+-	* otherwise @p buf. Set @p size to the actual size of data returned.
+-	* (all of this is dictated by the pilot-link interfaces).
+-	*
+-	* Subclasses must reimplement this to give a @em specific
+-	* meaning to the binary blob.
+-	*
+-	* @param buf Data buffer containing the blob.
+-	* @param size Size of the buffer (in bytes). As input, the maximum
+-	*        size of the buffer. As output, the number of bytes used.
+-	*/
+-	virtual void *pack_(void *buf, int *size) = 0;
+-
+-	/** Unpack the binary blob @p buf of size @p size into
+-	* some structure with meaning.
+-	*/
+-	virtual void unpack(const void *buf, int size) = 0;
+-
+-
+-public:
+-	/** Constructor with no data. Use the indicated values
+-	* of the characteristics. @em Note that the order of the
+-	* parameters is subtly different from that in PilotRecordBase .
+-	*/
+-	PilotAppCategory(int a=0, recordid_t i=0, int c=0) :
+-		PilotRecordBase(a,c,i)
+-	{} ;
+-
+-	/** Constructor. Use the common characteristics values from the
+-	* given record @p rec.
+-	*/
+-	PilotAppCategory(const PilotRecord* rec) :
+-		PilotRecordBase( ((rec)?rec->attributes():0),
+-			((rec)?rec->category():0),
+-			((rec)?rec->id():0)
+-			)
+-	{} ;
+-
+-	/** Copy constructor. */
+-	PilotAppCategory(const PilotAppCategory &copyFrom) :
+-		PilotRecordBase(copyFrom.attributes(),
+-			copyFrom.id(),
+-			copyFrom.category() )
+-	{} ;
+-
+-	/** Assignment operator. I rather doubt that this is useful. */
+-	PilotAppCategory& operator=( const PilotAppCategory &r )
+-	{
+-		setAttributes( r.attributes() );
+-		setID( r.id() );
+-		setCategory( r.category() );
+-		return *this;
+-	} ;
+-
+-	/** Comparison operator. Not really useful, since it also
+-	* wants the same record ID.
+-	*/
+-	bool operator==(const PilotAppCategory &compareTo)
+-	{
+-		return (attributes() ==compareTo.attributes() &&
+-			id() ==compareTo.id() &&
+-			category() ==compareTo.category() );
+-	} ;
+-
+-	/** Destructor. VIrtual, since we will be subclassed. */
+-	virtual ~PilotAppCategory(void) {};
+-
+-	/** @return a PilotRecord that contains all of the info of the
+-	*  subclass.  Remember to delete the PilotRecord when finished.
+-	* Calls pack_() to get the work done.
+-	*/
+-	virtual PilotRecord* pack();
+-
+-	/** Returns a text representation of this (interpreted) data.
+-	* The text may use Qt rich text tags if @p rt is true. The
+-	* default implementation just returns a junk message.
+-	*
+-	* @param rt Use right text (if needed) if and only if @p rt is true.
+-	*/
+-	virtual QString getTextRepresentation(bool rt=false)
+-		{ Q_UNUSED(rt); return i18n("Unknown record type"); }
+-
+-	/** Sets the category number to @p c in the range 
+-	* 0 <= c < PILOT_CATEGORY_MAX). Using an invalid
+-	* category number results in category 0.
+-	*/
+-	void setCategory( int c ) { return PilotRecordBase::setCategory(c); }
+-	/** Sets the category number by looking up the string @p label
+-	* in the category table @p info . Sets the category to 0 (unfiled)
+-	* if no match is found.
+-	*
+-	* @param info AppInfo structure containing the labels (in handheld
+-	*        native encoding).
+-	* @param label The label to look for.
+-	*/
+-	bool setCategory(struct CategoryAppInfo &info,const QString &label);
+-	bool KDE_DEPRECATED setCat(struct CategoryAppInfo &info,const QString &label)
+-		{ return setCategory(info,label); }
+-
+-protected:
+-	static QTextCodec *pilotCodec;
+-public:
+-	/** Static translaion function that maps handheld native (8 bit,
+-	* usually latin1 but sometimes someting else) encoded data to
+-	* a Unicode string. Converts the @p len characters in @p c
+-	* to a Unicode string.
+-	*/
+-	static QString fromPilot( const char *c, int len );
+-
+-	/** Static translation function that maps a QString onto the
+-	* native 8 bit encoding of the handheld. Writes the result into
+-	* the buffer @p buf which has size @p len. Returns the length
+-	* of the result. Zero-fills the buffer as needed.
+-	*/
+-	static int toPilot( const QString &s, char *buf, int len);
+-
+-	/** Get the codec for use in translating strings from handheld
+-	* native encoding to QString and vice-versa.
+-	*/
+-	static QTextCodec *codec()
+-		{ if (pilotCodec) return pilotCodec; else return setupPilotCodec(QString::null); } ;
+-	/** Create a codec for translating handheld native 8 bit to Unicode,
+-	* using the given codec @p name -- this will often be latin1, but
+-	* might be something else for, say, Russian-language Pilots.
+-	* If @p name is empty, use latin1.
+-	*/
+-	static QTextCodec *setupPilotCodec(const QString &name);
+-	/** Returns the name of the codec being used. */
+-	static QString codecName();
+-};
+-
+-
+-
+-#endif
+diff -pruN kpilot/lib/pilotAppInfo.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotAppInfo.cc
+--- kpilot/lib/pilotAppInfo.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/pilotAppInfo.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,69 @@
++/* pilotAppInfo.cc		KPilot
++**
++** Copyright (C) 2005-2006 Adriaan de Groot <groot at kde.org>
++**
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++
++#include "options.h"
++
++#include <stdio.h>
++
++#include "pilotAppInfo.h"
++
++PilotAppInfoBase::PilotAppInfoBase(PilotDatabase *d) : fC(new struct CategoryAppInfo), fLen(0), fOwn(true)
++{
++	FUNCTIONSETUP;
++	int appLen = Pilot::MAX_APPINFO_SIZE;
++	unsigned char buffer[Pilot::MAX_APPINFO_SIZE];
++
++	if (!d || !d->isOpen())
++	{
++		kdError() << "Bad database pointer." << endl;
++		fLen = 0;
++		KPILOT_DELETE( fC );
++		return;
++	}
++	fLen = appLen = d->readAppBlock(buffer,appLen);
++	unpack_CategoryAppInfo(fC, buffer, appLen);
++}
++
++PilotAppInfoBase::~PilotAppInfoBase()
++{
++	if (fOwn) delete fC;
++}
++
++bool PilotAppInfoBase::setCategoryName(unsigned int i, const QString &s)
++{
++	if ( (i>=Pilot::CATEGORY_COUNT) || // bad category number
++		(!categoryInfo())) // Nowhere to write to
++	{
++		return false;
++	}
++
++	(void) Pilot::toPilot(s, categoryInfo()->name[i], Pilot::CATEGORY_SIZE - 1);
++	return true;
++}
++
++
+diff -pruN kpilot/lib/pilotAppInfo.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotAppInfo.h
+--- kpilot/lib/pilotAppInfo.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/pilotAppInfo.h	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,201 @@
++#ifndef _KPILOT_PILOTAPPINFO_H
++#define _KPILOT_PILOTAPPINFO_H
++/* pilotAppInfo.h			KPilot
++**
++** Copyright (C) 2005-2006 Adriaan de Groot <groot at kde.org>
++**
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "pilotLinkVersion.h"
++
++#include "pilot.h"
++#include "pilotDatabase.h"
++
++/**
++* A database on the handheld has an "AppInfo" block at the beginning
++* with some database-specific information and a common part.
++* This base class deals with the common part, the categories.
++*
++* Most data in the handheld is stored in @em categories ; every
++* record in every database, for instance, has a category assigned
++* to it (perhaps "Unfiled", but that's just another category).
++*
++* Every database has a category table assigning labels to the
++* categories that exist. There are CATEGORY_COUNT (16) categories
++* available for each database; labels may vary per database.
++*
++* This class encapsulates the basic category table manipulations.
++*/
++class KDE_EXPORT PilotAppInfoBase
++{
++protected:
++	/** Constructor. This is for use by derived classes (using the template below
++	* only, and says that the category info in the base class aliases data in
++	* the derived class. Remember to call init()!
++	*/
++	PilotAppInfoBase() : fC(0L), fLen(0), fOwn(false) { } ;
++
++	/** Initialize class members after reading header, to alias data elsewhere.
++	* Only for use by the (derived) template classes below.
++	*/
++	void init(struct CategoryAppInfo *c, int len)
++	{
++		fC = c;
++		fLen = len ;
++	} ;
++
++public:
++	/** Constructor, intended for untyped access to the AppInfo only. This throws
++	* away everything but the category information. In this variety, the
++	* CategoryAppInfo structure is owned by the PilotAppInfoBase object.
++	*/
++	PilotAppInfoBase(PilotDatabase *d);
++
++	/** Destructor. */
++	virtual ~PilotAppInfoBase();
++
++	/** Retrieve the most basic part of the AppInfo block -- the category
++	* information which is guaranteed to be the first 240-odd bytes of
++	* a database.
++	*/
++	struct CategoryAppInfo *categoryInfo()
++	{
++		return fC;
++	} ;
++
++	/** Const version of the above function. */
++	inline const struct CategoryAppInfo *categoryInfo() const
++	{
++		return fC;
++	} ;
++
++	/** Returns the length of the (whole) AppInfo block. */
++	inline PI_SIZE_T length() const
++	{
++		return fLen;
++	} ;
++
++	/** @see findCategory(const QString &name, bool unknownIsUnfiled, struct CategoryAppInfo *info). */
++	inline int findCategory(const QString &name, bool unknownIsUnfiled = false)
++	{
++		return Pilot::findCategory(fC,name,unknownIsUnfiled);
++	} ;
++
++	/** Gets a single category name. Returns QString::null if there is no
++	* such category number @p i . */
++	inline QString categoryName(unsigned int i) const
++	{
++		return Pilot::categoryName(fC,i);
++	}
++
++	/** Sets a category name. @return true if this succeeded. @return false
++	* on failure, e.g. the index @p i was out of range or the category name
++	* was invalid. Category names that are too long are truncated to 15 characters.
++	*/
++	bool setCategoryName(unsigned int i, const QString &s);
++
++	/** For debugging, display all the category names */
++	inline void dump() const
++	{
++		Pilot::dumpCategories(fC);
++	};
++
++protected:
++	struct CategoryAppInfo *fC;
++	PI_SIZE_T fLen;
++
++	bool fOwn;
++} ;
++
++/** A template class for reading and interpreting AppInfo blocks;
++* the idea is that it handles all the boilerplate code for reading
++* the app block, converting it to the right kind, and then unpacking
++* it. Template parameters are the type (struct, from pilot-link probably)
++* of the interpreted appinfo, and the pack and unpack functions for it
++* (again, from pilot-link).
++*/
++template <typename appinfo,
++	int(*unpack)(appinfo *, unsigned char *, PI_SIZE_T),
++	int(*pack)(appinfo *, unsigned char *, PI_SIZE_T)>
++class PilotAppInfo : public PilotAppInfoBase
++{
++public:
++	/** Constructor. Read the appinfo from database @p d and
++	* interpret it.
++	*/
++	PilotAppInfo(PilotDatabase *d) : PilotAppInfoBase()
++	{
++		int appLen = Pilot::MAX_APPINFO_SIZE;
++		unsigned char buffer[Pilot::MAX_APPINFO_SIZE];
++
++		memset(&fInfo,0,sizeof(fInfo));
++		if (d && d->isOpen())
++		{
++			appLen = d->readAppBlock(buffer,appLen);
++			(*unpack)(&fInfo, buffer, appLen);
++			// fInfo is just a struct, so we can point to it anyway.
++			init(&fInfo.category,appLen);
++		}
++		else
++		{
++			delete fC;
++			fC = 0L;
++			fLen = 0;
++		}
++	} ;
++
++	/** Write this appinfo block to the database @p d; returns
++	* the number of bytes written or -1 on failure. This
++	* function is robust when called with a NULL database @p d.
++	*/
++	int writeTo(PilotDatabase *d)
++	{
++		unsigned char buffer[Pilot::MAX_APPINFO_SIZE];
++		if (!d || !d->isOpen())
++		{
++			return -1;
++		}
++		int appLen = (*pack)(&fInfo, buffer, length());
++		if (appLen > 0)
++		{
++			d->writeAppBlock(buffer,appLen);
++		}
++		return appLen;
++	} ;
++
++	/** Returns a (correctly typed) pointer to the interpreted
++	* appinfo block.
++	*/
++	appinfo *info() { return &fInfo; } ;
++	/** Returns a const (correctly typed) pointer to the interpreted
++	* appinfo block.
++	*/
++	const appinfo *info() const { return &fInfo; } ;
++
++protected:
++	appinfo fInfo;
++} ;
++
++
++#endif
+diff -pruN kpilot/lib/pilot.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilot.cc
+--- kpilot/lib/pilot.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/pilot.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,213 @@
++/* pilot.cc			KPilot
++**
++** Copyright (C) 1998-2001 by Dan Pilone
++** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2003-2006 Adriaan de Groot <groot at kde.org>
++**
++** These are the base class structures that reside on the
++** handheld device -- databases and their parts.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "options.h"
++
++#include <qtextcodec.h>
++#include <kcharsets.h>
++#include <kglobal.h>
++
++#include "pilot.h"
++#include "pilotDatabase.h"
++#include "pilotAppInfo.h"
++#include "pilotRecord.h"
++
++
++namespace Pilot
++{
++static QTextCodec *codec = 0L;
++
++
++QString fromPilot( const char *c, int len )
++{
++	return codec->toUnicode(c,len);
++}
++
++QString fromPilot( const char *c )
++{
++	return codec->toUnicode(c);
++}
++
++QCString toPilot( const QString &s )
++{
++	return codec->fromUnicode(s);
++}
++
++int toPilot( const QString &s, char *buf, int len)
++{
++	int used = len;
++	QCString cbuf = codec->fromUnicode(s,used);
++	memset( buf, 0, len );
++	if (used > len) used=len;
++	memcpy( buf, cbuf.data(), used );
++	return used;
++}
++
++int toPilot( const QString &s, unsigned char *buf, int len)
++{
++	int used = len;
++	QCString cbuf = codec->fromUnicode(s,used);
++	memset( buf, 0, len );
++	if (used > len) used=len;
++	memcpy( buf, cbuf.data(), used );
++	return used;
++}
++
++bool setupPilotCodec(const QString &s)
++{
++	FUNCTIONSETUP;
++	QString encoding(KGlobal::charsets()->encodingForName(s));
++
++	DEBUGLIBRARY << fname << ": Using codec name " << s << endl;
++	DEBUGLIBRARY << fname << ": Creating codec " << encoding << endl;
++
++	// if the desired codec can't be found, latin1 will be returned anyway, no need to do this manually
++	codec = KGlobal::charsets()->codecForName(encoding);
++
++	if (codec)
++	{
++		DEBUGLIBRARY << fname << ": Got codec " << codec->name() << endl;
++	}
++
++	return codec;
++}
++
++QString codecName()
++{
++	return QString::fromLatin1(codec->name());
++}
++
++QString category(const struct CategoryAppInfo *info, unsigned int i)
++{
++	if (!info || (i>=CATEGORY_COUNT))
++	{
++		return QString::null;
++	}
++
++	return codec->toUnicode(info->name[i],CATEGORY_SIZE-1);
++}
++
++
++int findCategory(const struct CategoryAppInfo *info,
++	const QString &selectedCategory,
++	bool unknownIsUnfiled)
++{
++	FUNCTIONSETUP;
++
++	if (!info)
++	{
++		kdError() << k_funcinfo << "! Bad CategoryAppInfo pointer" << endl;
++		return -1;
++	}
++
++	int currentCatID = -1;
++	for (unsigned int i=0; i<CATEGORY_COUNT; i++)
++	{
++		if (!info->name[i][0]) continue;
++		if (selectedCategory == category(info, i))
++		{
++			currentCatID = i;
++			break;
++		}
++	}
++
++	if (-1 == currentCatID)
++	{
++		DEBUGLIBRARY << fname << ": Category name "
++			<< selectedCategory << " not found." << endl;
++	}
++	else
++	{
++		DEBUGLIBRARY << fname << ": Matched category " << currentCatID << endl;
++	}
++
++	if ((currentCatID == -1) && unknownIsUnfiled)
++		currentCatID = 0;
++	return currentCatID;
++}
++
++int insertCategory(struct CategoryAppInfo *info,
++	const QString &label,
++	bool unknownIsUnfiled)
++{
++	int c = findCategory(info,label,unknownIsUnfiled);
++	if (c<0)
++	{
++		// This is the case when the category is not known
++		// and unknownIsUnfiled is false.
++		for (unsigned int i=0; i<CATEGORY_COUNT; i++)
++		{
++			if (!info->name[i][0])
++			{
++				c = i;
++				break;
++			}
++		}
++
++		if ((c>0) && (c < (int)CATEGORY_COUNT))
++		{
++			// 0 is always unfiled, can't change that.
++			toPilot(label,info->name[c],CATEGORY_SIZE);
++		}
++		else
++		{
++			c = -1;
++		}
++	}
++
++	return c;
++}
++
++void dumpCategories(const struct CategoryAppInfo *info)
++{
++	FUNCTIONSETUP;
++
++	if (!info)
++	{
++		kdWarning() << "! Dumping bad pointer." << endl;
++		return;
++	}
++
++	DEBUGLIBRARY << fname << " lastUniqueId: "
++		<< (int) info->lastUniqueID << endl;
++	for (unsigned int i = 0; i < CATEGORY_COUNT; i++)
++	{
++		if (!info->name[i][0]) continue;
++		DEBUGLIBRARY << fname << ": " << i << " = "
++			<< info->ID[i] << " <"
++			<< info->name[i] << ">" << endl;
++	}
++}
++
++
++}
++
++
+diff -pruN kpilot/lib/pilotDatabase.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotDatabase.cc
+--- kpilot/lib/pilotDatabase.cc	2005-10-10 17:02:28.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotDatabase.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -1,6 +1,8 @@
+ /* KPilot
+ **
+ ** Copyright (C) 1998-2001 by Dan Pilone
++** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2005-2006 Adriaan de Groot <groot at kde.org>
+ **
+ ** This is the abstract base class for databases, which is used both
+ ** by local databases and by the serial databases held in the Pilot.
+@@ -33,12 +35,11 @@
+ #include <pi-appinfo.h>
+ 
+ #include <qstringlist.h>
+-#include <qtextcodec.h>
+ 
+ #include <kglobal.h>
+ 
+ #include "pilotDatabase.h"
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ 
+ static int creationCount = 0;
+ static QStringList *createdNames = 0L;
+@@ -70,19 +71,19 @@ PilotDatabase::PilotDatabase(const QStri
+ {
+ 	FUNCTIONSETUP;
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname << ": " << creationCount << " databases." << endl;
++	DEBUGLIBRARY << fname << ": " << creationCount << " databases." << endl;
+ 	if (createdNames)
+ 	{
+-		DEBUGDAEMON << fname << ": "
++		DEBUGLIBRARY << fname << ": "
+ 			<< createdNames->join(CSL1(",")) << endl;
+ 	}
+ #endif
+ 	return creationCount;
+ }
+ 
+-/* virtual */ RecordIDList PilotDatabase::idList()
++/* virtual */ Pilot::RecordIDList PilotDatabase::idList()
+ {
+-	RecordIDList l;
++	Pilot::RecordIDList l;
+ 
+ 	for (unsigned int i = 0 ; ; i++)
+ 	{
+@@ -95,9 +96,9 @@ PilotDatabase::PilotDatabase(const QStri
+ 	return l;
+ }
+ 
+-/* virtual */ RecordIDList PilotDatabase::modifiedIDList()
++/* virtual */ Pilot::RecordIDList PilotDatabase::modifiedIDList()
+ {
+-	RecordIDList l;
++	Pilot::RecordIDList l;
+ 
+ 	resetDBIndex();
+ 	while(1)
+@@ -111,94 +112,3 @@ PilotDatabase::PilotDatabase(const QStri
+ 	return l;
+ }
+ 
+-PilotAppInfoBase::PilotAppInfoBase(PilotDatabase *d) : fC(new struct CategoryAppInfo), fLen(0), fOwn(true)
+-{
+-	FUNCTIONSETUP;
+-	int appLen = MAX_APPINFO_SIZE;
+-	unsigned char buffer[MAX_APPINFO_SIZE];
+-
+-	fLen = appLen = d->readAppBlock(buffer,appLen);
+-	unpack_CategoryAppInfo(fC, buffer, appLen);
+-}
+-
+-PilotAppInfoBase::~PilotAppInfoBase()
+-{
+-	if (fOwn) delete fC;
+-}
+-
+-
+-int PilotAppInfoBase::findCategory(const QString &selectedCategory,
+-	bool unknownIsUnfiled, struct CategoryAppInfo *info)
+-{
+-	FUNCTIONSETUP;
+-
+-	int currentCatID = -1;
+-	for (int i=0; i<PILOT_CATEGORY_MAX; i++)
+-	{
+-		if (!info->name[i][0]) continue;
+-		if (selectedCategory ==
+-			PilotAppCategory::codec()->toUnicode(info->name[i]))
+-		{
+-			currentCatID = i;
+-			break;
+-		}
+-	}
+-
+-#ifdef DEBUG
+-	if (-1 == currentCatID)
+-	{
+-		DEBUGKPILOT << fname << ": Category name "
+-			<< selectedCategory << " not found." << endl;
+-	}
+-	else
+-	{
+-		DEBUGKPILOT << fname << ": Matched category " << currentCatID << endl;
+-	}
+-#endif
+-
+-	if ((currentCatID == -1) && unknownIsUnfiled)
+-		currentCatID = 0;
+-	return currentCatID;
+-}
+-
+-void PilotAppInfoBase::dumpCategories(const struct CategoryAppInfo &info)
+-{
+-#ifdef DEBUG
+-	FUNCTIONSETUP;
+-	DEBUGCONDUIT << fname << " lastUniqueId"
+-		<< info.lastUniqueID << endl;
+-	for (int i = 0; i < PILOT_CATEGORY_MAX; i++)
+-	{
+-		if (!info.name[i][0]) continue;
+-		DEBUGCONDUIT << fname << ": " << i << " = "
+-			<< info.ID[i] << " <"
+-			<< info.name[i] << ">" << endl;
+-	}
+-#else
+-	Q_UNUSED(info);
+-#endif
+-}
+-
+-void PilotAppInfoBase::dump() const
+-{
+-	dumpCategories(*categoryInfo());
+-}
+-
+-
+-QString PilotAppInfoBase::category(unsigned int i)
+-{
+-	if (i>=PILOT_CATEGORY_MAX) return QString::null;
+-	return PilotAppCategory::codec()->toUnicode(categoryInfo()->name[i],PILOT_CATEGORY_SIZE-1);
+-}
+-
+-bool PilotAppInfoBase::setCategoryName(unsigned int i, const QString &s)
+-{
+-	if (i>=PILOT_CATEGORY_MAX) return false;
+-	int len = PILOT_CATEGORY_SIZE - 1;
+-	QCString t = PilotAppCategory::codec()->fromUnicode(s,len);
+-	memset(categoryInfo()->name[i],0,PILOT_CATEGORY_SIZE);
+-	qstrncpy(categoryInfo()->name[i],t,PILOT_CATEGORY_SIZE);
+-	return true;
+-}
+-
+-
+diff -pruN kpilot/lib/pilotDatabase.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotDatabase.h
+--- kpilot/lib/pilotDatabase.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotDatabase.h	2006-11-26 23:53:25.000000000 +0100
+@@ -4,6 +4,7 @@
+ **
+ ** Copyright (C) 1998-2001 by Dan Pilone
+ ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2005-2006 Adriaan de Groot <groot at kde.org>
+ **
+ ** This is the abstract base class for databases, which is used both
+ ** by local databases and by the serial databases held in the Pilot.
+@@ -31,33 +32,7 @@
+ */
+ 
+ 
+-#include <qstring.h>
+-#include <qvaluelist.h>
+-
+-// Handle all time.h variations properly.
+-// Required because pi-macros.h sometimes forgets it.
+-//
+-#ifdef TIME_WITH_SYS_TIME
+-# include <sys/time.h>
+-# include <time.h>
+-#else
+-# ifdef HAVE_SYS_TIME_H
+-#  include <sys/time.h>
+-# else
+-#  include <time.h>
+-# endif
+-#endif
+-
+-#include "pilotLinkVersion.h"
+-
+-#include <pi-dlp.h>
+-
+-
+-class PilotRecord;
+-struct CategoryAppInfo;
+-
+-typedef QValueList<recordid_t> RecordIDList;
+-
++#include "pilot.h"
+ 
+ 
+ /**
+@@ -111,10 +86,11 @@ public:
+ 
+ 	/** Returns a QValueList of all record ids in the database.
+ 	    This implementation is really bad. */
+-	virtual RecordIDList idList();
++	virtual Pilot::RecordIDList idList();
++
+ 	/** Returns a list of all record ids that have been modified in the
+ 	    database. This implementation is really bad. */
+-	virtual RecordIDList modifiedIDList();
++	virtual Pilot::RecordIDList modifiedIDList();
+ 
+ 
+ 	/** Reads a record from database by id, returns record length */
+@@ -158,7 +134,7 @@ public:
+ 	/** Purges all Archived/Deleted records from Palm Pilot database */
+ 	virtual int cleanup() = 0;
+ 
+-	bool isDBOpen() const { return fDBOpen; }
++	bool isOpen() const { return fDBOpen; }
+ 
+ 	/** Returns some sensible human-readable identifier for
+ 	*   the database. Serial databases get Pilot:, local
+@@ -191,149 +167,6 @@ private:
+ 	QString fName;
+ };
+ 
+-/** Base class for all specific kinds of AppInfo. */
+-class KDE_EXPORT PilotAppInfoBase
+-{
+-protected:
+-	/** Constructor. This is for use by derived classes (using the template below
+-	* only, and says that the category info in the base class aliases data in
+-	* the derived class. Remember to call init()!
+-	*/
+-	PilotAppInfoBase() : fC(0L), fLen(0), fOwn(false) { } ;
+-
+-	/** Initialize class members after reading header, to alias data elsewhere.
+-	* Only for use by the (derived) template classes below.
+-	*/
+-	void init(struct CategoryAppInfo *c, int len)
+-	{
+-		fC = c;
+-		fLen = len ;
+-	} ;
+-
+-public:
+-	/** Maximum size of an AppInfo block, taken roughly from the pilot-link source. */
+-	static const int MAX_APPINFO_SIZE=8192;
+-
+-	/** Constructor, intended for untyped access to the AppInfo only. This throws
+-	* away everything but the category information. In this variety, the
+-	* CategoryAppInfo structure is owned by the PilotAppInfoBase object.
+-	*/
+-	PilotAppInfoBase(PilotDatabase *d);
+-	/** Destructor. */
+-	virtual ~PilotAppInfoBase();
+-
+-	/** Retrieve the most basic part of the AppInfo block -- the category
+-	* information which is guaranteed to be the first 240-odd bytes of
+-	* a database.
+-	*/
+-	struct CategoryAppInfo *categoryInfo() { return fC; } ;
+-	/** Const version of the above function. */
+-	const struct CategoryAppInfo *categoryInfo() const { return fC; } ;
+-	/** Returns the length of the (whole) AppInfo block. */
+-	PI_SIZE_T length() const { return fLen; } ;
+-
+-	/** Search for the given category @p name in the list
+-	* of categories; returns the category number. If @p unknownIsUnfiled
+-	* is true, then map unknown categories to Unfiled instead of returning
+-	* an error number.
+-	*
+-	* @return >=0   is a specific category based on the text-to-
+-	*               category number mapping defined by the Pilot,
+-	*               where 0 is always the 'unfiled' category.
+-	*  @return -1   means unknown category selected when
+-	*               @p unknownIsUnfiled is false.
+-	*  @return  0   == Unfiled means unknown category selected when
+-	*               @p unknownIsUnfiled is true.
+-	*
+-	*/
+-	static int findCategory(const QString &name, bool unknownIsUnfiled, struct CategoryAppInfo *info);
+-	/** Alternative to the above inconvenience function. */
+-	int findCategory(const QString &name, bool unknownIsUnfiled = false)
+-		{ return findCategory(name,unknownIsUnfiled,categoryInfo()); } ;
+-
+-	/** For debugging, display all the category names */
+-	void dump() const;
+-
+-	/** For debugging, display category names for the given AppInfo
+-	* structure. Called by dump().
+-	*/
+-	static void dumpCategories(const struct CategoryAppInfo &info);
+-
+-	/** Gets a single category name. Returns QString::null if there is no
+-	* such category number @p i . */
+-	QString category(unsigned int i);
+-
+-	/** Sets a category name. @return true if this succeeded. @return false
+-	* on failure, e.g. the index @p i was out of range or the category name
+-	* was invalid. Category names that are too long are truncated to 15 characters.
+-	*/
+-	bool setCategoryName(unsigned int i, const QString &s);
+-
+-private:
+-	struct CategoryAppInfo *fC;
+-	PI_SIZE_T fLen;
+-	bool fOwn;
+-} ;
+-
+-/** A template class for reading and interpreting AppInfo blocks;
+-* the idea is that it handles all the boilerplate code for reading
+-* the app block, converting it to the right kind, and then unpacking
+-* it. Template parameters are the type (struct, from pilot-link probably)
+-* of the interpreted appinfo, and the pack and unpack functions for it
+-* (again, from pilot-link).
+-*/
+-template <typename appinfo,
+-	int(*unpack)(appinfo *, unsigned char *, PI_SIZE_T),
+-	int(*pack)(appinfo *, unsigned char *, PI_SIZE_T)>
+-class PilotAppInfo : public PilotAppInfoBase
+-{
+-public:
+-	/** Constructor. Read the appinfo from database @p d and
+-	* interpret it.
+-	*/
+-	PilotAppInfo(PilotDatabase *d) : PilotAppInfoBase()
+-	{
+-		int appLen = MAX_APPINFO_SIZE;
+-		unsigned char buffer[MAX_APPINFO_SIZE];
+-
+-		memset(&fInfo,0,sizeof(fInfo));
+-		if (d && d->isDBOpen())
+-		{
+-			appLen = d->readAppBlock(buffer,appLen);
+-			(*unpack)(&fInfo, buffer, appLen);
+-		}
+-		// fInfo is just a struct, so we can point to it anyway.
+-		init(&fInfo.category,appLen);
+-	} ;
+-
+-	/** Write this appinfo block to the database @p d; returns
+-	* the number of bytes written or -1 on failure. This
+-	* function is robust when called with a NULL database @p d.
+-	*/
+-	int write(PilotDatabase *d)
+-	{
+-		unsigned char buffer[MAX_APPINFO_SIZE];
+-		if (!d || !d->isDBOpen())
+-		{
+-			return -1;
+-		}
+-		int appLen = (*pack)(&fInfo, buffer, length());
+-		if (appLen > 0)
+-		{
+-			d->writeAppBlock(buffer,appLen);
+-		}
+-		return appLen;
+-	} ;
+-
+-	/** Returns a (correctly typed) pointer to the interpreted
+-	* appinfo block.
+-	*/
+-	appinfo *info() { return &fInfo; } ;
+-
+-protected:
+-	appinfo fInfo;
+-} ;
+-
+ /** A template class for reading and interpreting a database. This removes
+ * the need for a lot of boilerplate code that does the conversions.
+ * Parameters are two interpretation classes: one for the KDE side of
+diff -pruN kpilot/lib/pilotDateEntry.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotDateEntry.cc
+--- kpilot/lib/pilotDateEntry.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotDateEntry.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -27,12 +27,14 @@
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+ 
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ #include <stdlib.h>
+ 
+-#include <qtextcodec.h>
+ #include <qdatetime.h>
++#include <qregexp.h>
+ 
+ #include <kglobal.h>
+ #include <kdebug.h>
+@@ -40,11 +42,7 @@
+ 
+ #include "pilotDateEntry.h"
+ 
+-static const char *pilotDateEntry_id = "$Id: pilotDateEntry.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-const int PilotDateEntry::APP_BUFFER_SIZE = 0xffff;
+-
+-
+-PilotDateEntry::PilotDateEntry(struct AppointmentAppInfo &appInfo):PilotAppCategory(), fAppInfo(appInfo)
++PilotDateEntry::PilotDateEntry(struct AppointmentAppInfo &appInfo):PilotRecordBase(), fAppInfo(appInfo)
+ {
+ 	::memset(&fAppointmentInfo, 0, sizeof(struct Appointment));
+ }
+@@ -52,27 +50,19 @@ PilotDateEntry::PilotDateEntry(struct Ap
+ /* initialize the entry from another one. If rec==NULL, this constructor does the same as PilotDateEntry()
+ */
+ PilotDateEntry::PilotDateEntry(struct AppointmentAppInfo &appInfo, PilotRecord * rec) :
+-	PilotAppCategory(rec),
++	PilotRecordBase(rec),
+ 	fAppInfo(appInfo)
+ {
+ 	::memset(&fAppointmentInfo, 0, sizeof(fAppointmentInfo));
+ 	if (rec)
+ 	{
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 		pi_buffer_t b;
+-		b.data = (unsigned char *) rec->getData();
++		b.data = (unsigned char *) rec->data();
+ 		b.allocated = b.used = rec->size();
+ 		unpack_Appointment(&fAppointmentInfo, &b, datebook_v1);
+-#else
+-		unpack_Appointment(&fAppointmentInfo,
+-			(unsigned char *) rec->data(), rec->size());
+-#endif
+ 	}
+ 	return;
+ 
+-	/* NOTREACHED */
+-	/* Included to avoid warning that id isn't used. */
+-	(void) pilotDateEntry_id;
+ }
+ 
+ void PilotDateEntry::_copyExceptions(const PilotDateEntry & e)
+@@ -108,7 +98,7 @@ void PilotDateEntry::_copyExceptions(con
+ 
+ 
+ PilotDateEntry::PilotDateEntry(const PilotDateEntry & e) :
+-	PilotAppCategory(e),
++	PilotRecordBase(e),
+ 	fAppInfo(e.fAppInfo)
+ {
+ 	::memcpy(&fAppointmentInfo, &e.fAppointmentInfo,
+@@ -318,23 +308,23 @@ unsigned int PilotDateEntry::alarmLeadTi
+ 
+ QString PilotDateEntry::getCategoryLabel() const
+ {
+-	return codec()->toUnicode(fAppInfo.category.name[category()]);
++	return Pilot::fromPilot(fAppInfo.category.name[category()]);
+ }
+ 
+-void *PilotDateEntry::pack_(void *buf, int *len)
++PilotRecord *PilotDateEntry::pack() const
+ {
+ 	int i;
+ 
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-	pi_buffer_t b = { 0,0,0 } ;
+-	i = pack_Appointment(&fAppointmentInfo, &b, datebook_v1);
+-	memcpy(buf,b.data,kMin(i,*len));
+-	*len = kMin(i,*len);
+-#else
+-	i = pack_Appointment(&fAppointmentInfo, (unsigned char *) buf, *len);
+-	*len = i;
+-#endif
+-	return buf;
++	pi_buffer_t *b = pi_buffer_new( sizeof(fAppointmentInfo) );
++	i = pack_Appointment(const_cast<Appointment_t *>(&fAppointmentInfo), b, datebook_v1);
++	if (i<0)
++	{
++		// Generic error from the pack_*() functions.
++		return 0;
++	}
++
++	// pack_Appointment sets b->used
++	return new PilotRecord( b, this );
+ }
+ 
+ /* setExceptions sets a new set of exceptions. Note that
+@@ -403,23 +393,74 @@ void PilotDateEntry::setNoteP(const char
+ 
+ void PilotDateEntry::setNote(const QString &s)
+ {
+-	QCString t = codec()->fromUnicode(s);
++	QCString t = Pilot::toPilot(s);
+ 	setNoteP( t.data(),t.length() );
+ }
+ 
++void PilotDateEntry::setLocation(const QString &s)
++{
++	QString note = Pilot::fromPilot(getNoteP());
++	QRegExp rxp = QRegExp("^[Ll]ocation:[^\n]+\n");
++
++	if( s.isNull() )
++	{
++		note.replace(rxp,"");
++	}
++	else
++	{
++		QString location = "Location: " + s + "\n";
++		int pos = note.find(rxp);
++
++		if(pos >= 0)
++		{
++			note.replace( rxp, location );
++		}
++		else
++		{
++			note = location + note;
++			setNote( note );
++		}
++	}
++}
++
++QString PilotDateEntry::getLocation() const
++{
++	// Read the complete note here and not the filtered
++	// one from PilotDateEntry::getNote();
++	QString note = Pilot::fromPilot(getNoteP());
++	QRegExp rxp = QRegExp("^[Ll]ocation:[^\n]+\n");
++	int pos = note.find(rxp, 0);
++
++	if(pos >= 0)
++	{
++		QString location = rxp.capturedTexts().first();
++		rxp = QRegExp("^[Ll]ocation:[\\s|\t]*");
++		location.replace(rxp,"");
++		location.replace("\n", "");
++		return location;
++	}
++	else
++	{
++		return "";
++	}
++}
++
+ void PilotDateEntry::setDescription(const QString &s)
+ {
+-	QCString t = codec()->fromUnicode(s);
++	QCString t = Pilot::toPilot(s);
+ 	setDescriptionP( t.data(),t.length() );
+ }
+ 
+ QString PilotDateEntry::getNote() const
+ {
+-	return codec()->toUnicode(getNoteP());
++	QString note = Pilot::fromPilot(getNoteP());
++	QRegExp rxp = QRegExp("^[Ll]ocation:[^\n]+\n");
++	note.replace(rxp, "" );
++	return note;
+ }
+ 
+ QString PilotDateEntry::getDescription() const
+ {
+-	return codec()->toUnicode(getDescriptionP());
++	return Pilot::fromPilot(getDescriptionP());
+ }
+ 
+diff -pruN kpilot/lib/pilotDateEntry.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotDateEntry.h
+--- kpilot/lib/pilotDateEntry.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotDateEntry.h	2006-11-26 23:53:25.000000000 +0100
+@@ -36,8 +36,8 @@
+ #include <pi-macros.h>
+ #include <pi-datebook.h>
+ 
+-#include "pilotAppCategory.h"
+-#include "pilotDatabase.h"
++#include "pilotRecord.h"
++#include "pilotAppInfo.h"
+ 
+ namespace KCal
+ {
+@@ -45,20 +45,23 @@ class Event;
+ }
+ 
+ /** This class is a wrapper for pilot-link's datebook entries (struct Appointment). */
+-class KDE_EXPORT PilotDateEntry : public PilotAppCategory
++class KDE_EXPORT PilotDateEntry : public PilotRecordBase
+ {
+ public:
+ 	/** Constructor. Sets the appinfo structure and zeroes out the appointment. */
+ 	PilotDateEntry(struct AppointmentAppInfo &appInfo);
+ 
+ 	/** Constructor. Interprets the given record as an appointment. */
+-	PilotDateEntry(struct AppointmentAppInfo &appInfo, PilotRecord* rec);
++	PilotDateEntry(struct AppointmentAppInfo &appInfo, PilotRecord *rec);
+ 
+ 	/** Copy constructor. */
+ 	PilotDateEntry(const PilotDateEntry &e);
+ 
+ 	/** Destructor. */
+-	~PilotDateEntry() { free_Appointment(&fAppointmentInfo); }
++	~PilotDateEntry()
++	{
++		free_Appointment(&fAppointmentInfo);
++	}
+ 
+ 	/** Assignment operator. */
+ 	PilotDateEntry& operator=(const PilotDateEntry &e);
+@@ -77,13 +80,18 @@ public:
+ 	*  as opposed to a regular "appointment", which does normally have a time
+ 	*  associated with it.
+ 	*/
+-	bool doesFloat() const { return fAppointmentInfo.event; }
++	bool doesFloat() const
++	{
++		return fAppointmentInfo.event;
++	}
++
+ 	/** Is this a non-time-related event as opposed to an appointment that has a
+ 	* time associated with it?.
+ 	*/
+-	inline bool isEvent() const { return doesFloat(); }
+-	/** A synonym for isEvent, deprecated. */
+-	int KDE_DEPRECATED getEvent() const { return doesFloat(); }
++	inline bool isEvent() const
++	{
++		return doesFloat();
++	}
+ 
+ 	/** Sets this appointment's floating status.
+ 	*
+@@ -93,16 +101,26 @@ public:
+ 	*  as opposed to a regular "appointment", which does normally have a time
+ 	*  associated with it.
+ 	*/
+-	void setFloats(bool f) { fAppointmentInfo.event = (f ? 1 : 0) /* Force 1 or 0 */ ; }
+-	/** Synonym for setFloats() */
+-	void KDE_DEPRECATED setEvent(int event) { setFloats( event ); }
++	void setFloats(bool f)
++	{
++		fAppointmentInfo.event = (f ? 1 : 0) /* Force 1 or 0 */ ;
++	}
+ 
+ 	/** Get the start time of this appointment.  See dtStart() for caveats. */
+ 	struct tm getEventStart() const { return fAppointmentInfo.begin; }
++
+ 	/** Get a pointer to the start time of this appointment.  See dtStart() for caveats. */
+-	const struct tm *getEventStart_p() const { return &fAppointmentInfo.begin; }
++	const struct tm *getEventStart_p() const
++	{
++		return &fAppointmentInfo.begin;
++	}
++
+ 	/** Sets the start time of this appointment. */
+-	void setEventStart(struct tm& start) { fAppointmentInfo.begin = start; }
++	void setEventStart(struct tm& start)
++	{
++		fAppointmentInfo.begin = start;
++	}
++
+ 	/** Get the start time of this appointment. For floating appointments, the
+ 	* time is undefined (perhaps 1 minute past midnight).
+ 	*
+@@ -112,11 +130,23 @@ public:
+ 	QDateTime dtStart() const;
+ 
+ 	/** Get the end time of this appointment.  See dtEnd() for caveats. */
+-	struct tm getEventEnd() const { return fAppointmentInfo.end; }
++	struct tm getEventEnd() const
++	{
++		return fAppointmentInfo.end;
++	}
++
+ 	/** Get a pointer to the end time of this appointment.  See dtEnd() for caveats. */
+-	const struct tm *getEventEnd_p() const { return &fAppointmentInfo.end; }
++	const struct tm *getEventEnd_p() const
++	{
++		return &fAppointmentInfo.end;
++	}
++
+ 	/** Set the end time of this appointment. */
+-	void setEventEnd(struct tm& end) { fAppointmentInfo.end = end; }
++	void setEventEnd(struct tm& end)
++	{
++		fAppointmentInfo.end = end;
++	}
++
+ 	/** Get the end time of this appointment. For floating appointments, the
+ 	* time is undefined (perhaps 1 minute past midnight).
+ 	*
+@@ -129,13 +159,16 @@ public:
+ 	* may have an alarm (or not). If it has one, it is also enabled and
+ 	* causes the Pilot to beep (or whatever is set in the system preferences).
+ 	*/
+-	bool isAlarmEnabled() const { return fAppointmentInfo.alarm; }
+-	/** Does this appointment have an alarm set?  See isAlarmEnabled() */
+-	int KDE_DEPRECATED getAlarm() const { return fAppointmentInfo.alarm; }
+-	/** Set whether this appointment has an alarm. */
+-	void KDE_DEPRECATED setAlarm(int alarm) { fAppointmentInfo.alarm = alarm; }
++	bool isAlarmEnabled() const
++	{
++		return fAppointmentInfo.alarm;
++	}
++
+ 	/** Set whether this appointment has an alarm. */
+-	void setAlarmEnabled(bool b) { fAppointmentInfo.alarm = (b?1:0) /* Force to known int values */ ; }
++	void setAlarmEnabled(bool b)
++	{
++		fAppointmentInfo.alarm = (b?1:0) /* Force to known int values */ ;
++	}
+ 
+ 	/** Get the numeric part of "alarm: __ (v) minutes" on the pilot -- you
+ 	* set the alarm time in two parts, a number and a unit type to use; unit
+@@ -146,14 +179,28 @@ public:
+ 	* @see alarmLeadTime()
+ 	* @see dtAlarm()
+ 	*/
+-	int getAdvance() const { return fAppointmentInfo.advance; }
++	int getAdvance() const
++	{
++		return fAppointmentInfo.advance;
++	}
++
+ 	/** Set the numeric part of the alarm setting.  See getAdvance for details. */
+-	void setAdvance(int advance) { fAppointmentInfo.advance = advance; }
++	void setAdvance(int advance)
++	{
++		fAppointmentInfo.advance = advance;
++	}
+ 
+ 	/** Returns the units part of the alarm time.  See getAdvance . */
+-	int getAdvanceUnits() const { return fAppointmentInfo.advanceUnits; }
++	int getAdvanceUnits() const
++	{
++		return fAppointmentInfo.advanceUnits;
++	}
++
+ 	/** Sets the unites part of the alarm time.  See getAdvance . */
+-	void setAdvanceUnits(int units) { fAppointmentInfo.advanceUnits = units; }
++	void setAdvanceUnits(int units)
++	{
++		fAppointmentInfo.advanceUnits = units;
++	}
+ 
+ 	/** Returns the number of @em seconds "lead time" the alarm should sound
+ 	* before the actual appointment. This interprets the advance number and units.
+@@ -164,43 +211,95 @@ public:
+ 	/** Returns the absolute date and time that the alarm should sound for
+ 	* this appointment.
+ 	*/
+-	QDateTime dtAlarm() const { return dtStart().addSecs(-alarmLeadTime()); }
+-
+-  // The following need set routines written
+-  repeatTypes getRepeatType() const { return fAppointmentInfo.repeatType; }
+-  void setRepeatType(repeatTypes r) { fAppointmentInfo.repeatType = r; }
+-
+-  int getRepeatForever() const { return fAppointmentInfo.repeatForever; }
+-  void setRepeatForever(int f = 1) { fAppointmentInfo.repeatForever = f; }
++	QDateTime dtAlarm() const
++	{
++		return dtStart().addSecs(-alarmLeadTime());
++	}
++
++	// The following need set routines written
++	repeatTypes getRepeatType() const
++	{
++		return fAppointmentInfo.repeatType;
++	}
++	void setRepeatType(repeatTypes r)
++	{
++		fAppointmentInfo.repeatType = r;
++	}
++
++	int getRepeatForever() const
++	{
++		return fAppointmentInfo.repeatForever;
++	}
++	void setRepeatForever(int f = 1)
++	{
++		fAppointmentInfo.repeatForever = f;
++	}
++
++	struct tm getRepeatEnd() const
++	{
++		return fAppointmentInfo.repeatEnd;
++	}
++	void setRepeatEnd(struct tm tm)
++	{
++		fAppointmentInfo.repeatEnd = tm;
++	}
+ 
+-  struct tm getRepeatEnd() const { return fAppointmentInfo.repeatEnd; }
+-  void setRepeatEnd(struct tm tm) { fAppointmentInfo.repeatEnd = tm; }
+ 	/** Returns the date and time that the repeat ends. If there is no repeat,
+ 	* returns an invalid date and time.
+ 	*/
+ 	QDateTime dtRepeatEnd() const;
+ 
+-  int getRepeatFrequency() const { return fAppointmentInfo.repeatFrequency; }
+-  void setRepeatFrequency(int f) { fAppointmentInfo.repeatFrequency = f; }
+-
+-  DayOfMonthType getRepeatDay() const { return fAppointmentInfo.repeatDay; }
+-  void setRepeatDay(DayOfMonthType rd) { fAppointmentInfo.repeatDay = rd; };
+-
+-  const int *getRepeatDays() const { return fAppointmentInfo.repeatDays; }
+-  void setRepeatDays(int *rd) {
+-    for (int i = 0; i < 7; i++)
+-      fAppointmentInfo.repeatDays[i] = rd[i];
+-  }
+-  void setRepeatDays(QBitArray rba) {
+-    for (int i = 0; i < 7; i++)
+-      fAppointmentInfo.repeatDays[i] = (rba[i] ? 1 : 0);
+-  }
+-
+-  int getExceptionCount() const { return fAppointmentInfo.exceptions; }
+-  void setExceptionCount(int e) { fAppointmentInfo.exceptions = e; }
+-
+-  const struct tm *getExceptions() const { return fAppointmentInfo.exception; }
+-  void setExceptions(struct tm *e);
++	int getRepeatFrequency() const
++	{
++		return fAppointmentInfo.repeatFrequency;
++	}
++	void setRepeatFrequency(int f)
++	{
++		fAppointmentInfo.repeatFrequency = f;
++	}
++
++	DayOfMonthType getRepeatDay() const
++	{
++		return fAppointmentInfo.repeatDay;
++	}
++	void setRepeatDay(DayOfMonthType rd)
++	{
++		fAppointmentInfo.repeatDay = rd;
++	};
++
++	const int *getRepeatDays() const
++	{
++		return fAppointmentInfo.repeatDays;
++	}
++	void setRepeatDays(int *rd)
++	{
++		for (int i = 0; i < 7; i++)
++		{
++			fAppointmentInfo.repeatDays[i] = rd[i];
++		}
++	}
++	void setRepeatDays(QBitArray rba)
++	{
++		for (int i = 0; i < 7; i++)
++		{
++			fAppointmentInfo.repeatDays[i] = (rba[i] ? 1 : 0);
++		}
++	}
++
++	int getExceptionCount() const
++	{
++		return fAppointmentInfo.exceptions;
++	}
++	void setExceptionCount(int e)
++	{
++		fAppointmentInfo.exceptions = e;
++	}
++
++	const struct tm *getExceptions() const
++	{
++		return fAppointmentInfo.exception;
++	}
++	void setExceptions(struct tm *e);
+ 
+ 	/** Sets the description of the appointment. This is the short string
+ 	* entered in the day view on the handheld, and it is called the summary
+@@ -218,32 +317,51 @@ public:
+ 	/** Gets the note for this appointment.  See setNote for meaning. */
+ 	QString getNote() const;
+ 
++	/**
++	 * Sets the location for the appointment. For now it will be placed within
++	 * the notes on the handheld. It will be placed on one line and starts with:
++	 * Location: {location}. Everything on that line will be counted as location.
++	 * TODO: Make distinguish between handhelds that support the location field
++	 * and the ones that don't. (Shouldn't this be done in the pilot-link lib?)
++	 */
++	void setLocation(const QString &);
++
++	/** Gets the location for this appointment.  See setNote for meaning. */
++	QString getLocation() const;
++
+ protected:
+ 	void  setDescriptionP(const char* desc, int l=-1);
+-	const char* getDescriptionP() const { return fAppointmentInfo.description; }
++	const char* getDescriptionP() const
++	{
++		return fAppointmentInfo.description;
++	}
+ 
+ 	void  setNoteP(const char* note, int l=-1);
+-	const char* getNoteP() const { return fAppointmentInfo.note; }
++	const char* getNoteP() const
++	{
++		return fAppointmentInfo.note;
++	}
+ 
+ public:
+-  bool isMultiDay() const {
+-    return ((fAppointmentInfo.repeatType == repeatDaily) &&
+-            (fAppointmentInfo.repeatFrequency == 1) &&
+-            ( !getRepeatForever() ) &&
+-            !doesFloat() );
+-  }
+-
+-  QString getCategoryLabel() const;
+-  inline bool setCategory(const QString &label) { return PilotAppCategory::setCategory(fAppInfo.category,label); } ;
+-  static const int KDE_DEPRECATED APP_BUFFER_SIZE;
++	bool isMultiDay() const
++	{
++	return ((fAppointmentInfo.repeatType == repeatDaily) &&
++		(fAppointmentInfo.repeatFrequency == 1) &&
++		( !getRepeatForever() ) &&
++		!doesFloat() );
++	}
++
++	QString getCategoryLabel() const;
++	inline bool setCategory(const QString &label)
++	{
++		return Pilot::insertCategory(&fAppInfo.category,label,false) >= 0;
++	} ;
+ 
+-protected:
+-  void *pack_(void *buf, int *size);
+-  void unpack(const void *buf, int size = 0) { }
++	PilotRecord *pack() const;
+ 
+ private:
+-  struct Appointment fAppointmentInfo;
+-        struct AppointmentAppInfo &fAppInfo;
++	struct Appointment fAppointmentInfo;
++	struct AppointmentAppInfo &fAppInfo;
+ 	void _copyExceptions(const PilotDateEntry &e);
+ };
+ 
+diff -pruN kpilot/lib/pilot.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilot.h
+--- kpilot/lib/pilot.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/pilot.h	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,280 @@
++#ifndef _KPILOT_PILOT_H
++#define _KPILOT_PILOT_H
++/* pilot.h			KPilot
++**
++** Copyright (C) 1998-2001 by Dan Pilone
++** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold at kainhofer.com>
++** Copyright (C) 2003-2006 Adriaan de Groot <groot at kde.org>
++**
++** These are the base class structures that reside on the
++** handheld device -- databases and their parts.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++class QTextCodec;
++
++class PilotDatabase;     // A database
++class PilotRecord;       // ... has records
++class PilotCategoryInfo; // ... and category information
++
++#include "pilotLinkVersion.h"
++
++#include <stdio.h>
++
++#include <pi-dlp.h>
++#include <pi-file.h>
++#include <pi-appinfo.h>
++#include <pi-buffer.h>
++
++#include <qstring.h>
++#include <qvaluelist.h>
++
++/**
++* The Pilot namespace holds constants that are global for
++* the handheld data structures. Also contains some global
++* functions that deal with pilot-link structures as well
++* as mapping user-visible strings from UTF8 (KDE side) to
++* the encoding used on the handheld.
++*/
++
++namespace Pilot
++{
++	/** Maximum size of an AppInfo block, taken roughly from the pilot-link source. */
++	static const int MAX_APPINFO_SIZE=8192;
++
++	/** Maximum number of categories the handheld has */
++	static const unsigned int CATEGORY_COUNT=16;
++
++	/** Maximum size of a category label */
++	static const unsigned int CATEGORY_SIZE=16;
++
++	/** Category number for unfiled records */
++	static const int Unfiled = 0;
++
++	/** Maximum size (in bytes) of a record's data */
++	static const int MAX_RECORD_SIZE = 65535;
++
++	typedef QValueList<recordid_t> RecordIDList;
++
++	/** Static translation function that maps handheld native (8 bit,
++	* usually latin1 but sometimes someting else) encoded data to
++	* a Unicode string. Converts the @p len characters in @p c
++	* to a Unicode string.
++	*/
++	QString fromPilot( const char *c, int len );
++
++	/** Static translation function mapping a NUL-terminated
++	* string from the handheld's encoding to UTF-8.
++	* @param c the NUL-terminated string to decode
++	* @return QString (UTF-8) value of @p c
++	* @note NUL-terminated strings are rare on the handheld.
++	*/
++	QString fromPilot( const char *c );
++
++	/** Static translation function that maps a QString onto the
++	* native 8 bit encoding of the handheld. Writes the result into
++	* the buffer @p buf which has size @p len. Returns the length
++	* of the result. Zero-fills the buffer as needed.
++	*/
++	int toPilot( const QString &s, char *buf, int len);
++	int toPilot( const QString &s, unsigned char *buf, int len);
++
++	/** Static translation function that maps a QString onto the
++	* native 8 bit encoding of the handheld.
++	*
++	* @param s String to encode
++	* @return Encoded string in a QCString
++	*/
++	QCString toPilot( const QString &s );
++
++	/** Create a codec for translating handheld native 8 bit to Unicode,
++	* using the given codec @p name -- this will often be latin1, but
++	* might be something else for, say, Russian-language Pilots.
++	* If @p name is empty, use latin1.
++	*
++	* @return @c true on success, @c false otherwise
++	*/
++	bool setupPilotCodec(const QString &name);
++
++	/** Returns the name of the codec being used. */
++	QString codecName();
++
++	/** For debugging, display category names for the given AppInfo
++	* structure. Called by dump(). You must pass a valid reference.
++	*/
++	void dumpCategories(const struct CategoryAppInfo *info);
++
++	/** Returns the QString for the requested category @p i
++	* in the category structure @p info. Returns @c QString::null
++	* on error (bad pointer or bad category number). May also
++	* return @c QString::null if the category name is empty.
++	*/
++	inline QString categoryName(const struct CategoryAppInfo *info, unsigned int i)
++	{
++		if ( i < CATEGORY_COUNT )
++		{
++			return fromPilot( info->name[i], CATEGORY_SIZE );
++		}
++		else
++		{
++			return QString::null;
++		}
++	}
++
++
++	/** Search for the given category @p name in the list
++	* of categories; returns the category number. If @p unknownIsUnfiled
++	* is true, then map unknown categories to Unfiled instead of returning
++	* an error number.
++	*
++	* @return >=0   is a specific category based on the text-to-
++	*               category number mapping defined by the Pilot,
++	*               where 0 is always the 'unfiled' category.
++	*  @return -1   means unknown category selected when
++	*               @p unknownIsUnfiled is false.
++	*  @return  0   == Unfiled means unknown category selected when
++	*               @p unknownIsUnfiled is true.
++	*
++	*/
++	int findCategory(const struct CategoryAppInfo *info, const QString &name, bool unknownIsUnfiled);
++
++	/** Search for the given category @p name in the list
++	* of categories; returns the category number. If @p unknownIsUnfiled
++	* is @c true, then map unknown categories to Unfiled.
++	* If @p unknownIsUnfiled is @c false, insert a @em new
++	* category into the structure and return the category
++	* number of the new category. Return -1 if (and only if)
++	* @p unknownIsUnfiled is false and the category structure
++	* is already full.
++	*
++	* @return >=0   is a specific category based on the text-to-
++	*               category number mapping defined by the Pilot,
++	*               where 0 is always the 'unfiled' category.
++	* @return 0     Unknown category and @p unknownIsUnfiled is @c true
++	* @return -1    means unknown category selected when
++	*               @p unknownIsUnfiled is false and categories
++	*               are all full.
++	*
++	*/
++	int insertCategory(struct CategoryAppInfo *info, const QString &label, bool unknownIsUnfiled);
++
++	/** The handheld also holds data about each database
++	* in a DBInfo structure; check if the database described
++	* by this structure is a resource database.
++	*/
++	static inline bool isResource(struct DBInfo *info)
++	{
++		return (info->flags & dlpDBFlagResource);
++	}
++}
++
++
++template<typename t> struct dlp { } ;
++template<> struct dlp<short> 
++{ 
++	enum { size = 2 }; 
++
++	static void append(pi_buffer_t *b, short v)
++	{
++		char buf[size];
++		set_short(buf,v);
++		pi_buffer_append(b,buf,size);
++	}
++
++	static int read(const pi_buffer_t *b, unsigned int &offset)
++	{
++		if ((offset>=b->used) || (offset>=b->allocated))
++		{
++			return -1;
++		}
++		else
++		{
++			int r = get_short(b->data + offset);
++			offset+=size;
++			return r;
++		}
++	}
++
++	static int read(const unsigned char *b, unsigned int &offset)
++	{
++		int r = get_short(b+offset);
++		offset+=size;
++		return r;
++	}
++} ;
++template<> struct dlp<long> 
++{ 
++	enum { size = 4 }; 
++
++	static void append(pi_buffer_t *b, int v)
++	{
++		char buf[size];
++		set_long(buf,v);
++		pi_buffer_append(b,buf,size);
++	}
++
++	static int read(const pi_buffer_t *b, unsigned int &offset)
++	{
++		if ((offset>=b->used) || (offset>=b->allocated))
++		{
++			return -1;
++		}
++		else
++		{
++			int r = get_long(b->data + offset);
++			offset+=size;
++			return r;
++		}
++	}
++
++	static int read(const unsigned char *b, unsigned int &offset)
++	{
++		int r = get_long(b+offset);
++		offset+=size;
++		return r;
++	}
++} ;
++
++template<> struct dlp<char *>
++{
++	// No size enum, doesn't make sense
++	// No append, use pi_buffer_append
++	static int read(const pi_buffer_t *b, unsigned int &offset, unsigned char *v, size_t s)
++	{
++		if ( s+offset > b->allocated )
++		{
++			s = b->allocated - offset;
++		}
++		memcpy(v, b->data + offset, s);
++		offset+=s;
++		return s;
++	}
++
++	inline static int read(const pi_buffer_t *b, unsigned int &offset, char *v, size_t s)
++	{
++		return read(b,offset,(unsigned char *)v,s);
++	}
++} ;
++
++#endif
++
+diff -pruN kpilot/lib/pilotLinkVersion.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotLinkVersion.h
+--- kpilot/lib/pilotLinkVersion.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotLinkVersion.h	2006-11-26 23:53:25.000000000 +0100
+@@ -1,5 +1,5 @@
+-#ifndef PILOTLINKVERSION_H
+-#define PILOTLINKVERSION_H
++#ifndef _KPILOT_PILOTLINKVERSION_H
++#define _KPILOT_PILOTLINKVERSION_H
+ 
+ /* pilotLinkVersion.h                           KPilot
+ **
+@@ -34,7 +34,7 @@
+ #include <pi-version.h>
+ 
+ #ifndef PILOT_LINK_VERSION
+-#error "You need at least pilot-link version 0.9.5"
++#error "You need at least pilot-link version 0.12.1"
+ #endif
+ 
+ 
+@@ -44,16 +44,13 @@
+ #define PILOT_LINK_0_11_0	(1100)
+ #define PILOT_LINK_0_11_8	(1108)
+ #define PILOT_LINK_0_12_0	(1200)
++#define PILOT_LINK_0_12_1	(1201)
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_11_8
+-#warning "You need at least pilot-link version 0.11.8 for modern devices"
++#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_1
++#error "You need at least pilot-link version 0.12.1 for KPilot"
+ #endif
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-#define PI_SIZE_T int
+-#else
+ #define PI_SIZE_T size_t
+-#endif
+ 
+ 
+ #endif
+diff -pruN kpilot/lib/pilotLocalDatabase.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotLocalDatabase.cc
+--- kpilot/lib/pilotLocalDatabase.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotLocalDatabase.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -28,10 +28,9 @@
+ */
+ 
+ 
+-static const char *pilotlocaldatabase_id =
+-	"$Id: pilotLocalDatabase.cc 452989 2005-08-24 21:20:38Z adridg $";
+-
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ #include <stdio.h>
+ #include <unistd.h>
+@@ -43,14 +42,14 @@ static const char *pilotlocaldatabase_id
+ #include <qfile.h>
+ #include <qregexp.h>
+ #include <qdatetime.h>
+-#include <qtextcodec.h>
+ #include <qvaluevector.h>
+ 
+ #include <kdebug.h>
+ #include <kglobal.h>
+ #include <kstandarddirs.h>
++#include <ksavefile.h>
+ 
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ #include "pilotLocalDatabase.h"
+ 
+ typedef QValueVector<PilotRecord *> Records;
+@@ -91,7 +90,7 @@ PilotLocalDatabase::PilotLocalDatabase(c
+ 	fixupDBName();
+ 	openDatabase();
+ 
+-	if (!isDBOpen() && useDefaultPath)
++	if (!isOpen() && useDefaultPath)
+ 	{
+ 		if (fPathBase && !fPathBase->isEmpty())
+ 		{
+@@ -104,38 +103,12 @@ PilotLocalDatabase::PilotLocalDatabase(c
+ 		}
+ 		fixupDBName();
+ 		openDatabase();
+-		if (!isDBOpen())
++		if (!isOpen())
++		{
+ 			fPathName=path;
++		}
+ 	}
+ 
+-	/* NOTREACHED */
+-	(void) pilotlocaldatabase_id;
+-}
+-
+-PilotLocalDatabase::PilotLocalDatabase(const QString & dbName,
+-	bool useConduitDBs) :
+-	PilotDatabase(dbName),
+-	fPathName(QString::null),
+-	fDBName(dbName),
+-	fAppInfo(0L),
+-	fAppLen(0),
+-	d(0L)
+-{
+-	FUNCTIONSETUP;
+-	if (fPathBase && !fPathBase->isEmpty() )
+-	{
+-		fPathName = *fPathBase;
+-		if (useConduitDBs)
+-			fPathName.replace(CSL1("DBBackup/"), CSL1("conduits/"));
+-	}
+-	else
+-	{
+-		fPathName = KGlobal::dirs()->saveLocation("data",
+-			CSL1("kpilot/")+(useConduitDBs?CSL1("conduits/"):CSL1("DBBackup/")));
+-	}
+-
+-	fixupDBName();
+-	openDatabase();
+ }
+ 
+ PilotLocalDatabase::PilotLocalDatabase(const QString &dbName) :
+@@ -184,19 +157,19 @@ bool PilotLocalDatabase::createDatabase(
+ 	FUNCTIONSETUP;
+ 
+ 	// if the database is already open, we cannot create it again. How about completely resetting it? (i.e. deleting it and the createing it again)
+-	if (isDBOpen()) {
++	if (isOpen()) {
+ #ifdef DEBUG
+-		DEBUGCONDUIT<<"Database "<<fDBName<<" already open. Cannot recreate it."<<endl;
++		DEBUGLIBRARY<<"Database "<<fDBName<<" already open. Cannot recreate it."<<endl;
+ #endif
+ 		return true;
+ 	}
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT<<"Creating database "<<fDBName<<endl;
++	DEBUGLIBRARY<<"Creating database "<<fDBName<<endl;
+ #endif
+ 
+ 	// Database names seem to be latin1.
+-	memcpy(&fDBInfo.name[0], PilotAppCategory::codec()->fromUnicode(fDBName), 34*sizeof(char));
++	memcpy(&fDBInfo.name[0], Pilot::toPilot(fDBName), 34*sizeof(char));
+ 	fDBInfo.creator=creator;
+ 	fDBInfo.type=type;
+ 	fDBInfo.more=0;
+@@ -223,7 +196,7 @@ bool PilotLocalDatabase::createDatabase(
+ int PilotLocalDatabase::deleteDatabase()
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen()) closeDatabase();
++	if (isOpen()) closeDatabase();
+ 
+ 	QString dbpath=dbPathName();
+ 	QFile fl(dbpath);
+@@ -242,7 +215,7 @@ int PilotLocalDatabase::readAppBlock(uns
+ 
+ 	size_t m = kMin((size_t)size,(size_t)fAppLen);
+ 
+-	if (!isDBOpen())
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open!" << endl;
+ 		memset(buffer,0,m);
+@@ -257,7 +230,7 @@ int PilotLocalDatabase::writeAppBlock(un
+ {
+ 	FUNCTIONSETUP;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open!" << endl;
+ 		return -1;
+@@ -300,7 +273,7 @@ PilotRecord *PilotLocalDatabase::readRec
+ 	FUNCTIONSETUP;
+ 
+ 	d->pending = -1;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo << fDBName << ": DB not open!" << endl;
+ 		return 0L;
+@@ -324,13 +297,13 @@ PilotRecord *PilotLocalDatabase::readRec
+ {
+ 	FUNCTIONSETUP;
+ 	d->pending = -1;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo << ": DB not open!" << endl;
+ 		return 0L;
+ 	}
+ #ifdef DEBUG
+-	DEBUGKPILOT << "Index=" << index << " Count=" << recordCount() << endl;
++	DEBUGLIBRARY << fname << ": Index=" << index << " Count=" << recordCount() << endl;
+ #endif
+ 	if (index >= recordCount())
+ 		return 0L;
+@@ -345,7 +318,7 @@ PilotRecord *PilotLocalDatabase::readNex
+ {
+ 	FUNCTIONSETUP;
+ 	d->pending  = -1;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo << ": DB not open!" << endl;
+ 		return 0L;
+@@ -369,13 +342,13 @@ const PilotRecord *PilotLocalDatabase::f
+ {
+ 	FUNCTIONSETUP;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo << ": DB not open!" << endl;
+ 		return 0L;
+ 	}
+ #ifdef DEBUG
+-	DEBUGKPILOT << fname << ": looking for new record from " << d->current << endl;
++	DEBUGLIBRARY << fname << ": looking for new record from " << d->current << endl;
+ #endif
+ 	// Should this also check for deleted?
+ 	while ((d->current < d->size())
+@@ -396,7 +369,7 @@ PilotRecord *PilotLocalDatabase::readNex
+ {
+ 	FUNCTIONSETUP;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo << ": DB not open!" << endl;
+ 		return 0L;
+@@ -425,7 +398,7 @@ recordid_t PilotLocalDatabase::updateID(
+ {
+ 	FUNCTIONSETUP;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open!" << endl;
+ 		return 0;
+@@ -446,7 +419,7 @@ recordid_t PilotLocalDatabase::writeReco
+ {
+ 	FUNCTIONSETUP;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open!" << endl;
+ 		return 0;
+@@ -486,7 +459,7 @@ recordid_t PilotLocalDatabase::writeReco
+ int PilotLocalDatabase::deleteRecord(recordid_t id, bool all)
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo <<": DB not open"<<endl;
+ 		return -1;
+@@ -524,7 +497,7 @@ int PilotLocalDatabase::resetSyncFlags()
+ {
+ 	FUNCTIONSETUP;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open!" << endl;
+ 		return -1;
+@@ -541,7 +514,7 @@ int PilotLocalDatabase::resetSyncFlags()
+ int PilotLocalDatabase::resetDBIndex()
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo << ": DB not open!" << endl;
+ 		return -1;
+@@ -554,7 +527,7 @@ int PilotLocalDatabase::resetDBIndex()
+ int PilotLocalDatabase::cleanup()
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdWarning() << k_funcinfo << ": DB not open!" << endl;
+ 		return -1;
+@@ -602,15 +575,13 @@ void PilotLocalDatabase::openDatabase()
+ 	pi_file *dbFile;
+ 
+ 	setDBOpen(false);
+-	char buffer[PATH_MAX];
+-	memset(buffer,0,PATH_MAX);
+-	strlcpy(buffer,QFile::encodeName(dbPathName()),PATH_MAX);
+ 
+-	dbFile = pi_file_open(buffer);
++	dbFile = pi_file_open( QFile::encodeName(dbPathName()) );
+ 	if (dbFile == 0L)
+ 	{
+ #ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Failed to open " << dbPathName() << endl;
++		QString path = dbPathName();
++		DEBUGLIBRARY << fname << ": Failed to open " << path << endl;
+ #endif
+ 		return;
+ 	}
+@@ -638,10 +609,16 @@ void PilotLocalDatabase::openDatabase()
+ 	while (pi_file_read_record(dbFile, i,
+ 			&tmpBuffer, &size, &attr, &cat, &id) == 0)
+ 	{
+-		(*d)[i] = new PilotRecord(tmpBuffer, size, attr, cat, id);
++		pi_buffer_t *b = pi_buffer_new(size);
++		memcpy(b->data,tmpBuffer,size);
++		b->used = size;
++		(*d)[i] = new PilotRecord(b, attr, cat, id);
+ 		i++;
+ 	}
+ 	pi_file_close(dbFile);	// We done with it once we've read it in.
++
++	KSaveFile::backupFile( dbPathName() );
++
+ 	setDBOpen(true);
+ }
+ 
+@@ -650,10 +627,12 @@ void PilotLocalDatabase::closeDatabase()
+ 	FUNCTIONSETUP;
+ 	pi_file *dbFile;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ #ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": Database "<<fDBName<<" is not open. Cannot close and write it"<<endl;
++		DEBUGLIBRARY << fname << ": Database " << fDBName
++			<< " is not open. Cannot close and write it"
++			<< endl;
+ #endif
+ 		return;
+ 	}
+@@ -664,9 +643,10 @@ void PilotLocalDatabase::closeDatabase()
+ 	strlcpy(buf,QFile::encodeName(newName),PATH_MAX);
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname
++	QString path = dbPathName();
++	DEBUGLIBRARY << fname
+ 		<< ": Creating temp file " << buf
+-		<< " for the database file " << dbPathName() << endl;
++		<< " for the database file " << path << endl;
+ #endif
+ 
+ 	dbFile = pi_file_create(buf,&fDBInfo);
+@@ -702,7 +682,7 @@ void PilotLocalDatabase::setDBPath(const
+ 	FUNCTIONSETUP;
+ 
+ #ifdef DEBUG
+-	DEBUGDAEMON << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Setting default DB path to "
+ 		<< s
+ 		<< endl;
+@@ -723,3 +703,34 @@ void PilotLocalDatabase::setDBPath(const
+ 	return eLocalDB;
+ }
+ 
++
++/* static */ bool PilotLocalDatabase::infoFromFile( const QString &path, DBInfo *d )
++{
++	FUNCTIONSETUP;
++
++	pi_file *f = 0L;
++
++	if (!d)
++	{
++		return false;
++	}
++	if (!QFile::exists(path))
++	{
++		return false;
++	}
++
++	const char * fileName = QFile::encodeName( path );
++	f = pi_file_open( fileName );
++	if (!f)
++	{
++		kdWarning() << k_funcinfo
++			<< ": Can't open " << path << endl;
++		return false;
++	}
++
++	pi_file_get_info(f,d);
++	pi_file_close(f);
++
++	return true;
++}
++
+diff -pruN kpilot/lib/pilotLocalDatabase.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotLocalDatabase.h
+--- kpilot/lib/pilotLocalDatabase.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotLocalDatabase.h	2006-11-19 22:21:12.000000000 +0100
+@@ -47,20 +47,6 @@ public:
+ 	*/
+ 	PilotLocalDatabase( const QString& path,
+ 		const QString& name, bool useDefaultPath=true);
+-	/**
+-	* Opens the local database. A default path is used
+-	* ($KDEHOME/share/apps/kpilot/DBBackup)
+-	* and if the file is found there, it is opened.
+-	* Since a backup messes up the state of the conduits (i.e.
+-	* changes on the handheld might no longer be detected after
+-	* a backup run, since the conduit assumes the database to have
+-	* the state of the previous conduit run,  useConduitDBs=true
+-	* opens the database in $KDEHOME/share/apps/kpilot/conduits
+-	*
+-	* TODO: Deprecate this one.
+-	*/
+-	PilotLocalDatabase(const QString &name, bool useConduitDBs /* =false */);
+-
+ 
+ 	/**
+ 	* Opens the local database. This is primarily for testing
+@@ -152,7 +138,7 @@ public:
+ 	* Accessor functions for the application info block.
+ 	*/
+ 	int appInfoSize() const
+-		{ if (isDBOpen()) return fAppLen; else return -1; } ;
++		{ if (isOpen()) return fAppLen; else return -1; } ;
+ 	char *appInfo() { return fAppInfo; } ;
+ 
+ 	const struct DBInfo &getDBInfo() const { return fDBInfo; }
+@@ -160,6 +146,18 @@ public:
+ 
+ 	virtual DBType dbType() const;
+ 
++	/** Reads local file @p path and fills in the DBInfo
++	*   structure @p d with the DBInfo from the file.
++	*
++	*   @return @c false if d is NULL
++	*   @return @c false if the file @p path does not exist
++	*   @return @c true if reading the DBInfo succeeds
++	*
++	*   @note Relatively expensive operation, since the pilot-link
++	*         library doesn't provide a cheap way of getting this
++	*         information.
++	*/
++	static bool infoFromFile( const QString &path, DBInfo *d );
+ 
+ protected:
+ 	// Changes any forward slashes to underscores
+@@ -183,7 +181,7 @@ private:
+ 	*/
+ public:
+ 	static void setDBPath(const QString &);
+-	static const QString *getDBPath() { return fPathBase; } ;
++	static const QString &getDBPath() { return *fPathBase; } ;
+ private:
+ 	static QString *fPathBase;
+ };
+diff -pruN kpilot/lib/pilotMemo.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotMemo.cc
+--- kpilot/lib/pilotMemo.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotMemo.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -25,70 +25,31 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *pilotMemo_id =
+-	"$Id: pilotMemo.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+ 
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+-#include <qtextcodec.h>
+ 
+ #include "pilotMemo.h"
+ #include "pilotDatabase.h"
+ 
+ 
+ 
+-PilotMemo::PilotMemo(const PilotRecord * rec) : PilotAppCategory(rec)
++PilotMemo::PilotMemo(const PilotRecord * rec) : PilotRecordBase(rec)
+ {
+ 	FUNCTIONSETUP;
+-	fText = codec()->toUnicode((const char *)(rec->data()),rec->size());
+-	(void) pilotMemo_id;
+-}
+-
+-void PilotMemo::unpack(const void *text, int /* firstTime */)
+-{
+-	FUNCTIONSETUP;
+-	kdWarning() << k_funcinfo << ": deprecated and broken function." << endl;
+-	fText = codec()->toUnicode((const char *)text);
++	fText = Pilot::fromPilot((const char *)(rec->data()),rec->size());
+ }
+ 
+ PilotRecord *PilotMemo::pack()
+ {
+-	char *buf = new char[fText.length() + 8];
+-	int len = fText.length() + 8;
+-	pack_(buf,&len);
+-	PilotRecord *r = new PilotRecord(buf, len, attributes(), category(), id());
+-	delete[] buf;
++	pi_buffer_t *b = pi_buffer_new(fText.length()+8);
++	b->used = Pilot::toPilot(fText, b->data, b->allocated);
++	PilotRecord *r = new PilotRecord(b, this);
+ 	return r;
+ }
+ 
+-void *PilotMemo::pack_(void *buf, int *len)
+-{
+-	FUNCTIONSETUP;
+-	if (!*len) return NULL;
+-	if (*len < 0) return NULL; // buffer size being silly
+-	if (fText.length() > (unsigned) *len) return NULL; // won't fit either
+-
+-	QCString s = codec()->fromUnicode(fText);
+-
+-	int use_length = *len;
+-	if (MAX_MEMO_LEN < use_length) use_length = MAX_MEMO_LEN;
+-
+-	// Zero out the buffer, up to the max memo size.
+-	memset(buf,0,use_length);
+-
+-	// Copy the encoded string and make extra sure it's NUL terminated.
+-	// Yay, _every_ parameter needs a cast.
+-	// *NOTE* This will truncate the memo text if it was passed in as being
+-	//        too long, but this is better than allowing garbage in
+-	strlcpy(( char *)buf,(const char *)s,use_length);
+-
+-	// Finally, we set the length of the memo to the used length
+-	// of the data buffer, which might be the length of the string.
+-	if ((int)s.length() < use_length) use_length = s.length()+1;
+-	*len = use_length;
+-	return buf;
+-}
+-
+ 
+ QString PilotMemo::getTextRepresentation(bool richText)
+ {
+diff -pruN kpilot/lib/pilotMemo.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotMemo.h
+--- kpilot/lib/pilotMemo.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotMemo.h	2006-11-26 23:53:25.000000000 +0100
+@@ -32,19 +32,44 @@
+ 
+ #include <pi-memo.h>
+ 
+-#include "pilotAppCategory.h"
+-#include "pilotDatabase.h"
++#include "pilotRecord.h"
++#include "pilotAppInfo.h"
+ 
+-
+-class KDE_EXPORT PilotMemo : public PilotAppCategory
++class KDE_EXPORT PilotMemo : public PilotRecordBase
+ {
+ public:
+-	PilotMemo(void) : PilotAppCategory() { } ;
+-	PilotMemo(const QString &s) : PilotAppCategory() { setText(s); } ;
++	/**
++	* Constructor. Create an empty memo.
++	*/
++	PilotMemo(void) : PilotRecordBase() { } ;
++
++	/**
++	* Constructor. Create a memo in the Unfiled category with
++	* text @p s .
++	*/
++	PilotMemo(const QString &s) : PilotRecordBase()
++	{
++		setText(s);
++	} ;
++
++	/**
++	* Constructor. Create a memo with the category and
++	* attributes of the given record @p rec, and extract
++	* the text from that record as if it comes from the MemoDB.
++	*/
+ 	PilotMemo(const PilotRecord* rec);
+-	PilotMemo(void *buf) : PilotAppCategory() { unpack(buf, 1); } ;
+-	PilotMemo(void *buf, int attr, recordid_t id, int category)
+-		: PilotAppCategory(attr, id, category) { unpack(buf, 1); } ;
++
++	/**
++	* Constructor. Create a memo with category and
++	* attributes from the argument @p r, and set the
++	* text of the memo from string @p s.
++	*/
++	PilotMemo(const PilotRecordBase *r, const QString &s) :
++		PilotRecordBase(r)
++	{
++		setText(s);
++	}
++
+ 	~PilotMemo() { } ;
+ 
+ 	virtual QString getTextRepresentation(bool richText=false);
+@@ -69,10 +94,6 @@ public:
+ 	*/
+ 	QString sensibleTitle() const;
+ 
+-protected:
+-	void *pack_(void *, int *);
+-	void unpack(const void *, int = 0);
+-
+ private:
+ 	QString fText;
+ };
+diff -pruN kpilot/lib/pilotRecord.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotRecord.cc
+--- kpilot/lib/pilotRecord.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotRecord.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -32,25 +32,35 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ #include <string.h>
+ 
+-#include <qtextcodec.h>
+ #include <qregexp.h>
+ 
+ #include <kglobal.h>
+ #include <kcharsets.h>
+ 
+-// PilotAppCategory includes pilotRecord and we
+-// provide its implementation here as well.
+-//
+-#include "pilotAppCategory.h"
++#include "pilot.h"
++#include "pilotRecord.h"
+ 
+ 
+ 
+-static const char *pilotRecord_id =
+-	"$Id: pilotRecord.cc 437980 2005-07-23 19:53:57Z kainhofe $";
++/* virtual */ QString PilotRecordBase::textRepresentation() const
++{
++	return CSL1("[ %1,%2,%3 ]") . arg(attributes(),category(),id());
++}
++
++/* virtual */ QString PilotRecord::textRepresentation() const
++{
++	return CSL1("[ %1,%2 ]")
++		.arg(PilotRecordBase::textRepresentation())
++		.arg(size());
++}
++
++
+ 
+ /* static */ int PilotRecord::fAllocated = 0;
+ /* static */ int PilotRecord::fDeleted = 0;
+@@ -59,7 +69,7 @@ static const char *pilotRecord_id =
+ {
+ #ifdef DEBUG
+ 	FUNCTIONSETUP;
+-	DEBUGKPILOT << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Allocated " << fAllocated
+ 		<< "  Deleted " << fDeleted << endl;
+ #endif
+@@ -68,11 +78,8 @@ static const char *pilotRecord_id =
+ PilotRecord::PilotRecord(void *data, int len, int attrib, int cat, recordid_t uid) :
+ 	PilotRecordBase(attrib,cat,uid),
+ 	fData(0L),
+-	fLen(len)
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-	,
++	fLen(len),
+ 	fBuffer(0L)
+-#endif
+ {
+ 	FUNCTIONSETUPL(4);
+ 	fData = new char[len];
+@@ -80,15 +87,11 @@ PilotRecord::PilotRecord(void *data, int
+ 	memcpy(fData, data, len);
+ 
+ 	fAllocated++;
+-	(void) pilotRecord_id;
+ }
+ 
+ PilotRecord::PilotRecord(PilotRecord * orig) :
+-	PilotRecordBase( orig->attributes(), orig->category(), orig->id() )
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-	,
++	PilotRecordBase( orig->attributes(), orig->category(), orig->id() ) ,
+ 	fBuffer(0L)
+-#endif
+ {
+ 	FUNCTIONSETUPL(4);
+ 	fData = new char[orig->size()];
+@@ -101,14 +104,12 @@ PilotRecord::PilotRecord(PilotRecord * o
+ PilotRecord & PilotRecord::operator = (PilotRecord & orig)
+ {
+ 	FUNCTIONSETUP;
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 	if (fBuffer)
+ 	{
+ 		pi_buffer_free(fBuffer);
+ 		fBuffer=0L;
+ 		fData=0L;
+ 	}
+-#endif
+ 
+ 	if (fData)
+ 		delete[]fData;
+@@ -133,75 +134,3 @@ void PilotRecord::setData(const char *da
+ 	fLen = len;
+ }
+ 
+-
+-/* static */ QTextCodec *PilotAppCategory::pilotCodec = 0L;
+-
+-/* static */ QTextCodec *PilotAppCategory::setupPilotCodec(const QString &s)
+-{
+-	FUNCTIONSETUP;
+-	QString encoding(KGlobal::charsets()->encodingForName(s));
+-
+-#ifdef DEBUG
+-	DEBUGKPILOT << fname << ": Creating codec " << encoding << endl;
+-#endif
+-
+-	// if the desired codec can't be found, latin1 will be returned anyway, no need to do this manually
+-	pilotCodec = KGlobal::charsets()->codecForName(encoding);
+-
+-#ifdef DEBUG
+-	DEBUGKPILOT << fname
+-		<< ": Got codec " << codecName() << " for setting "
+-		<< s << endl;
+-#endif
+-	return codec();
+-}
+-
+-/* static */ QString PilotAppCategory::codecName()
+-{
+-	return QString::fromLatin1(codec()->name());
+-}
+-
+-bool PilotAppCategory::setCategory(struct CategoryAppInfo &info,const QString &label)
+-{
+-	int emptyAvailable = -1;
+-	if (label.isEmpty()) { setCategory(0); return true; }
+-	for (int catId = 1; catId < PILOT_CATEGORY_MAX; catId++)
+-	{
+-		QString aCat;
+-		if (!info.name[catId][0])
+-		{
+-			emptyAvailable=catId; continue;
+-		}
+-		aCat = codec()->toUnicode(info.name[catId]);
+-		if (label == aCat) { setCategory(catId); return true; }
+-	}
+-	if (emptyAvailable<0) return false;
+-	strlcpy(info.name[emptyAvailable], codec()->fromUnicode(label), sizeof(info.name[emptyAvailable]) );
+-	setCategory(emptyAvailable);
+-	return true;
+-}
+-
+-PilotRecord *PilotAppCategory::pack()
+-{
+-	int len = PilotRecord::APP_BUFFER_SIZE;
+-	void* buff = new unsigned char[len];
+-	pack_(buff, &len);
+-	PilotRecord* rec =  new PilotRecord(buff, len, attributes(), category(), id());
+-	delete [] (unsigned char*)buff;
+-	return rec;
+-}
+-
+-QString PilotAppCategory::fromPilot( const char *c, int len )
+-{
+-	return codec()->toUnicode(c,len);
+-}
+-
+-int PilotAppCategory::toPilot( const QString &s, char *buf, int len)
+-{
+-	int used = len;
+-	QCString cbuf = codec()->fromUnicode(s,used);
+-	memset( buf, 0, len );
+-	if (used > len) used=len;
+-	memcpy( buf, cbuf.data(), used );
+-	return used;
+-}
+diff -pruN kpilot/lib/pilotRecord.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotRecord.h
+--- kpilot/lib/pilotRecord.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotRecord.h	2006-11-26 23:53:25.000000000 +0100
+@@ -34,20 +34,11 @@
+ */
+ 
+ 
+-#include <time.h>
+-#include <unistd.h>
+-#include <stdio.h>
+-#include <kdemacros.h>
+-
+ #include "pilotLinkVersion.h"
+ 
+-struct pi_buffer_t;
+-
+-#include <pi-dlp.h>
+-#include <pi-file.h>
++#include "pilot.h"
+ 
+-#define PILOT_CATEGORY_SIZE 16 // (sizeof(((struct CategoryAppInfo *)0)->name[0]))
+-#define PILOT_CATEGORY_MAX 16 // ( (sizeof(((struct CategoryAppInfo *)0)->name)) / PILOT_CATEGORY_SIZE )
++#include <pi-buffer.h>
+ 
+ 
+ /** All entries in the Handheld -- whether interpreted or binary blobs --
+@@ -63,42 +54,88 @@ public:
+ 	* given values.
+ 	* @param attrib Attributes (bitfield) for this entry.
+ 	* @param cat Category for this entry. Should be in the
+-	*        range 0 <= cat < PILOT_CATEGORY_MAX . Using an
++	*        range 0 <= cat < Pilot::CATEGORY_COUNT . Using an
+ 	*        invalid category means 0 (unfiled) is used.
+ 	* @param id Unique ID for this entry. May be 0 (non-unique) as well.
+ 	*/
+ 	PilotRecordBase(int attrib=0, int cat=0, recordid_t id=0) :
+-		fAttrib(attrib),fCat(cat),fID(id) 
+-	{ 
+-		if ( !( (0<=cat) && (cat<PILOT_CATEGORY_MAX) ) ) fCat=0; 
++		fAttrib(attrib),fCat(0),fID(id)
++	{
++		setCategory(cat);
++	}
++
++	PilotRecordBase( const PilotRecordBase *b ) :
++		fAttrib( b ? b->attributes() : 0 ),
++		fCat( 0 ),
++		fID( b ? b->id() : 0 )
++	{
++		if (b)
++		{
++			setCategory( b->category() );
++		}
+ 	}
+ 
+-	/** Attributes of this record (deleted, secret, ...); it's a bitfield. */
++	/** Destructor. Nothing to do for it. */
++	virtual ~PilotRecordBase() { } ;
++
++	/** Attributes of this record (deleted, secret, ...);
++	* it's a bitfield.
++	*/
+ 	inline int attributes() const { return fAttrib; }
++
+ 	/** Set the attributes of this record. */
+ 	inline void  setAttributes(int attrib) { fAttrib = attrib; }
+-	int KDE_DEPRECATED getAttrib() const { return attributes(); }
+-	void KDE_DEPRECATED setAttrib(int attrib) { setAttributes(attrib); }
+ 
+-	/** Returns the category number 0 <= < PILOT_CATEGORY_MAX of this record. */
+-	int   category() const { return fCat; }
+-	/** Sets the category number 0 <= < PILOT_CATEGORY_MAX of this record. 
+-	* Trying to set an illegal category number files this one under 
++	/** Returns the category number [ 0 .. Pilot::CATEGORY_COUNT-1]
++	* of this record.
++	*/
++	inline int   category() const { return fCat; }
++
++	/** Sets the category number [ 0 .. Pilot::CATEGORY_COUNT-1]
++	* of this record.
++	* Trying to set an illegal category number files this one under
+ 	* "Unfiled" (which is 0).
+ 	*/
+-	void  setCategory(int cat) { if ( (cat<0) || (cat>=PILOT_CATEGORY_MAX)) cat=0; fCat = cat; }
+-	int  KDE_DEPRECATED  getCat() const { return category(); }
+-	void KDE_DEPRECATED  setCat(int cat) { return setCategory(cat); }
++	inline void  setCategory(int cat) { if ( (cat<0) || (cat>=(int)Pilot::CATEGORY_COUNT)) cat=0; fCat = cat; }
++
++	/** Sets the category number by looking up the string @p label
++	* in the category table @p info . Leaves the category unchanged
++	* if no match is found and returns @c false.
++	*
++	* @param info AppInfo structure containing the labels (in handheld
++	*        native encoding).
++	* @param label The label to look for.
++	*
++	* @return @c true on success, @c false on failure
++	*/
++	bool setCategory(const struct CategoryAppInfo *info, const QString &label)
++	{
++		if (!info)
++		{
++			return false;
++		}
++
++		int cat = Pilot::findCategory( info, label, false );
++		if ( (cat<0) || (cat>=(int)Pilot::CATEGORY_COUNT) )
++		{
++			return false;
++		}
++		else
++		{
++			setCategory( cat );
++			return true;
++		}
++	}
+ 
+ 	/** Returns the record ID for this record. Record IDs are unique for a given
+ 	* handheld and database.
+ 	*/
+ 	inline recordid_t id() const { return fID; }
++
+ 	/** Sets the record ID for this record. Use with caution -- you ca confuse
+ 	* the handheld by doing weird things here.
+ 	*/
+ 	void setID(recordid_t id) { fID = id; }
+-	recordid_t KDE_DEPRECATED getID() const { return id(); }
+ 
+ 	/** Accessor for one bit of the record's attributes. Is this record marked
+ 	* deleted (on the handheld) ? Deleted records are not removed from the
+@@ -106,10 +143,12 @@ public:
+ 	* or so to really get rid of the records from storage.
+ 	*/
+ 	inline bool isDeleted() const { return fAttrib & dlpRecAttrDeleted; };
++
+ 	/** Accessor for one bit of the record's attributes. Is this record secret?
+ 	* Secret records are not displayed on the desktop by default.
+ 	*/
+ 	inline bool isSecret() const { return fAttrib & dlpRecAttrSecret; } ;
++
+ 	/** Accessor for one bit of the record's attributes. Is this record a
+ 	* to-be-archived record? When a record is deleted, it may be marked
+ 	* as "archive on PC" which means the PC should keep a copy. The
+@@ -117,11 +156,11 @@ public:
+ 	* be deleted.
+ 	*/
+ 	inline bool isArchived() const { return fAttrib & dlpRecAttrArchived; } ;
++
+ 	/** Accessor for one bit of the record's attributes. Is this record modified?
+ 	* Modified records are those that have been modified since the last HotSync.
+ 	*/
+ 	inline bool isModified() const { return fAttrib & dlpRecAttrDirty; }
+-	inline bool KDE_DEPRECATED isDirty() const { return isModified(); } ;
+ 
+ #define SETTER(a) {\
+ 		if (d) { fAttrib |= a; } \
+@@ -139,11 +178,11 @@ public:
+ 	/** Mark a record as modified (or not). */
+ 	inline void setModified(bool d=true) SETTER(dlpRecAttrDirty)
+ 
+-	void KDE_DEPRECATED makeDeleted() { setDeleted(true); }
+-	void KDE_DEPRECATED makeSecret() { setSecret(true); }
+-	void KDE_DEPRECATED makeArchived() { setArchived(true); }
+ #undef SETTER
+ 
++	/** Returns a text representation of this record. */
++	virtual QString textRepresentation() const;
++
+ private:
+ 	int fAttrib, fCat;
+ 	recordid_t fID;
+@@ -162,9 +201,8 @@ public:
+ 	*
+ 	* This constructor makes a copy of the data buffer (and owns that buffer).
+ 	*/
+-	PilotRecord(void* data, int length, int attrib, int cat, recordid_t uid);
++	PilotRecord(void* data, int length, int attrib, int cat, recordid_t uid) KDE_DEPRECATED;
+ 
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 	/** Constructor. Using the given buffer @p buf (which carries its
+ 	* own data and length), create a record. Otherwise much like the
+ 	* above constructor @em except that this record assumes ownership
+@@ -176,16 +214,33 @@ public:
+ 		fData((char *)buf->data),
+ 		fLen(buf->used),
+ 		fBuffer(buf)
+-	{ fAllocated++; }
+-#endif
++	{
++		fAllocated++;
++	}
++
++	/** Constructor. Like the above, only take the attributes, category
++	* and id from the given @p entry.
++	*/
++	PilotRecord( pi_buffer_t *buf, const PilotRecordBase *entry ) :
++		PilotRecordBase( entry ),
++		fData((char *)buf->data),
++		fLen(buf->used),
++		fBuffer(buf)
++	{
++		fAllocated++;
++	}
+ 
+ 	/** Destructor. Dispose of the buffers in the right form. */
+-	~PilotRecord()
++	virtual ~PilotRecord()
+ 	{
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-		if (fBuffer) { pi_buffer_free(fBuffer); } else
+-#endif
+-		{ delete [] fData; }
++		if (fBuffer)
++		{
++			pi_buffer_free(fBuffer);
++		}
++		else
++		{
++			delete [] fData;
++		}
+ 		fDeleted++;
+ 	}
+ 
+@@ -200,24 +255,23 @@ public:
+ 	*/
+ 	char *data() const
+ 	{
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-		if (fBuffer) return (char *)(fBuffer->data); else
+-#endif
+-		return fData;
++		if (fBuffer)
++		{
++			return (char *)(fBuffer->data);
++		}
++		else
++		{
++			return fData;
++		}
+ 	}
+-	char *KDE_DEPRECATED getData() const { return data(); }
+ 
+ 	/** Returns the size of the data for this record. */
+ 	int size() const
+ 	{
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 		if (fBuffer) return fBuffer->used; else
+-#endif
+ 		return fLen;
+ 	}
+-	int KDE_DEPRECATED getLen() const { return size(); }
+ 
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 	/** Returns the data buffer associated with this record. */
+ 	const pi_buffer_t *buffer() const { return fBuffer; }
+ 
+@@ -232,13 +286,6 @@ public:
+ 		fLen = b->used;
+ 		fBuffer = b;
+ 	}
+-#endif
+-
+-	/** A constant, really left over from PalmOS 4 days, when records
+-	* could be 64k in size at most. It is used in various places to
+-	* dimension buffers, but should be considered deprecated.
+-	*/
+-	enum { APP_BUFFER_SIZE = 0xffff } ;
+ 
+ 	/** Assignment operator. Makes a copy of the @p orig record. */
+ 	PilotRecord& operator=(PilotRecord& orig);
+@@ -246,12 +293,13 @@ public:
+ 	/** Sets the data for this record. Makes a copy of the data buffer. */
+ 	void setData(const char* data, int len);
+ 
++	/** Returns a text representation of this record. */
++	virtual QString textRepresentation() const;
++
+ private:
+ 	char* fData;
+ 	int   fLen;
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 	pi_buffer_t *fBuffer;
+-#endif
+ 
+ public:
+ 	/**
+diff -pruN kpilot/lib/pilotSerialDatabase.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotSerialDatabase.cc
+--- kpilot/lib/pilotSerialDatabase.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotSerialDatabase.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -27,7 +27,9 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
+ 
+ #include <time.h>
+ #include <iostream>
+@@ -35,32 +37,27 @@
+ #include <pi-dlp.h>
+ 
+ #include <qfile.h>
+-#include <qtextcodec.h>
+ 
+ #include <klocale.h>
+ #include <kdebug.h>
+ #include <kglobal.h>
+ 
+-#include "pilotAppCategory.h"
++#include "pilotRecord.h"
+ #include "pilotSerialDatabase.h"
++#include "kpilotdevicelink.h"
+ 
+-static const char *pilotSerialDatabase_id =
+-	"$Id: pilotSerialDatabase.cc 437980 2005-07-23 19:53:57Z kainhofe $";
+-
+-PilotSerialDatabase::PilotSerialDatabase(int linksocket,
++PilotSerialDatabase::PilotSerialDatabase(KPilotDeviceLink *l,
+ 	const QString &dbName) :
+ 	PilotDatabase(dbName),
+ 	fDBName(QString::null),
+ 	fDBHandle(-1),
+-	fDBSocket(linksocket)
++	fDBSocket(l->pilotSocket())
+ {
+ 	FUNCTIONSETUP;
+ 	fDBName = dbName;
+ 
+ 	openDatabase();
+ 
+-	/* NOTREACHED */
+-	(void) pilotSerialDatabase_id;
+ }
+ 
+ PilotSerialDatabase::~PilotSerialDatabase()
+@@ -80,15 +77,11 @@ QString PilotSerialDatabase::dbPathName(
+ int PilotSerialDatabase::readAppBlock(unsigned char *buffer, int maxLen)
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return -1;
+ 	}
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	return dlp_ReadAppBlock(fDBSocket, getDBHandle(), 0, (void *) buffer,
+-		maxLen);
+-#else
+ 	pi_buffer_t *buf = pi_buffer_new(maxLen);
+ 	int r = dlp_ReadAppBlock(fDBSocket, getDBHandle(), 0 /* offset */, maxLen, buf);
+ 	if (r>=0)
+@@ -97,14 +90,13 @@ int PilotSerialDatabase::readAppBlock(un
+ 	}
+ 	pi_buffer_free(buf);
+ 	return r;
+-#endif
+ }
+ 
+ // Writes the application block info.
+ int PilotSerialDatabase::writeAppBlock(unsigned char *buffer, int len)
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return -1;
+@@ -117,7 +109,7 @@ int PilotSerialDatabase::recordCount()
+ {
+ 	int idlen;
+ 	// dlp_ReadOpenDBInfo returns the number of bytes read and sets idlen to the # of recs
+-	if (isDBOpen() && dlp_ReadOpenDBInfo(fDBSocket, getDBHandle(), &idlen)>0)
++	if (isOpen() && dlp_ReadOpenDBInfo(fDBSocket, getDBHandle(), &idlen)>0)
+ 	{
+ 		return idlen;
+ 	}
+@@ -158,7 +150,7 @@ PilotRecord *PilotSerialDatabase::readRe
+ 	FUNCTIONSETUPL(3);
+ 	int index, attr, category;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return 0L;
+@@ -169,19 +161,11 @@ PilotRecord *PilotSerialDatabase::readRe
+ 			<<id<<endl;;
+ 		return 0L;
+ 	}
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	char buffer[PilotRecord::APP_BUFFER_SIZE];
+-	PI_SIZE_T size;
+-	if (dlp_ReadRecordById(fDBSocket, getDBHandle(), id, buffer, &index,
+-			&size, &attr, &category) >= 0)
+-		return new PilotRecord(buffer, size, attr, category, id);
+-#else
+ 	pi_buffer_t *b = pi_buffer_new(InitialBufferSize);
+ 	if (dlp_ReadRecordById(fDBSocket,getDBHandle(),id,b,&index,&attr,&category) >= 0)
+ 	{
+ 		return new PilotRecord(b, attr, category, id);
+ 	}
+-#endif
+ 	return 0L;
+ }
+ 
+@@ -190,7 +174,7 @@ PilotRecord *PilotSerialDatabase::readRe
+ {
+ 	FUNCTIONSETUPL(3);
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return 0L;
+@@ -200,22 +184,12 @@ PilotRecord *PilotSerialDatabase::readRe
+ 	recordid_t id;
+ 	PilotRecord *rec = 0L;
+ 
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	char buffer[PilotRecord::APP_BUFFER_SIZE];
+-	PI_SIZE_T size;
+-	if (dlp_ReadRecordByIndex(fDBSocket, getDBHandle(), index,
+-			buffer, &id, &size, &attr, &category) >= 0)
+-	{
+-		rec = new PilotRecord(buffer, size, attr, category, id);
+-	}
+-#else
+ 	pi_buffer_t *b = pi_buffer_new(InitialBufferSize);
+ 	if (dlp_ReadRecordByIndex(fDBSocket, getDBHandle(), index,
+ 		b, &id, &attr, &category) >= 0)
+ 	{
+ 		rec = new PilotRecord(b, attr, category, id);
+ 	}
+-#endif
+ 
+ 
+ 	return rec;
+@@ -228,23 +202,15 @@ PilotRecord *PilotSerialDatabase::readNe
+ 	int index, attr;
+ 	recordid_t id;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return 0L;
+ 	}
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	char buffer[PilotRecord::APP_BUFFER_SIZE];
+-	PI_SIZE_T size;
+-	if (dlp_ReadNextRecInCategory(fDBSocket, getDBHandle(),
+-			category, buffer, &id, &index, &size, &attr) >= 0)
+-		return new PilotRecord(buffer, size, attr, category, id);
+-#else
+ 	pi_buffer_t *b = pi_buffer_new(InitialBufferSize);
+ 	if (dlp_ReadNextRecInCategory(fDBSocket, getDBHandle(),
+ 		category,b,&id,&index,&attr) >= 0)
+ 		return new PilotRecord(b, attr, category, id);
+-#endif
+ 	return 0L;
+ }
+ 
+@@ -255,28 +221,17 @@ PilotRecord *PilotSerialDatabase::readNe
+ 	int index, attr, category;
+ 	recordid_t id;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return 0L;
+ 	}
+-#if PILOT_LINK_NUMBER < PILOT_LINK_0_12_0
+-	char buffer[PilotRecord::APP_BUFFER_SIZE];
+-	PI_SIZE_T size;
+-	if (dlp_ReadNextModifiedRec(fDBSocket, getDBHandle(), (void *) buffer,
+-			&id, &index, &size, &attr, &category) >= 0)
+-	{
+-		if (ind) *ind=index;
+-		return new PilotRecord(buffer, size, attr, category, id);
+-	}
+-#else
+ 	pi_buffer_t *b = pi_buffer_new(InitialBufferSize);
+ 	if (dlp_ReadNextModifiedRec(fDBSocket, getDBHandle(), b, &id, &index, &attr, &category) >= 0)
+ 	{
+ 		if (ind) *ind=index;
+ 		return new PilotRecord(b, attr, category, id);
+ 	}
+-#endif
+ 	return 0L;
+ }
+ 
+@@ -287,7 +242,7 @@ recordid_t PilotSerialDatabase::writeRec
+ 	recordid_t newid;
+ 	int success;
+ 
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return 0;
+@@ -316,7 +271,7 @@ recordid_t PilotSerialDatabase::writeRec
+ int PilotSerialDatabase::deleteRecord(recordid_t id, bool all)
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo <<": DB not open"<<endl;
+ 		return -1;
+@@ -329,7 +284,7 @@ int PilotSerialDatabase::deleteRecord(re
+ int PilotSerialDatabase::resetSyncFlags()
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return -1;
+@@ -341,7 +296,7 @@ int PilotSerialDatabase::resetSyncFlags(
+ int PilotSerialDatabase::resetDBIndex()
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return -1;
+@@ -353,7 +308,7 @@ int PilotSerialDatabase::resetDBIndex()
+ int PilotSerialDatabase::cleanup()
+ {
+ 	FUNCTIONSETUP;
+-	if (isDBOpen() == false)
++	if (!isOpen())
+ 	{
+ 		kdError() << k_funcinfo << ": DB not open" << endl;
+ 		return -1;
+@@ -409,11 +364,11 @@ bool PilotSerialDatabase::createDatabase
+ 	int db;
+ 
+ 	// if the database is already open, we cannot create it again. How about completely resetting it? (i.e. deleting it and the createing it again)
+-	if (isDBOpen()) return true;
++	if (isOpen()) return true;
+ 	// The latin1 seems ok, database names are latin1.
+ 	int res=dlp_CreateDB(fDBSocket,
+ 		creator, type, cardno, flags, version,
+-		PilotAppCategory::codec()->fromUnicode(getDBName()), &db);
++		Pilot::toPilot(getDBName()), &db);
+ 	if (res<0) {
+ 		kdError() <<k_funcinfo
+ 			<< i18n("Cannot create database %1 on the handheld").arg(getDBName())<<endl;
+@@ -428,7 +383,7 @@ bool PilotSerialDatabase::createDatabase
+ void PilotSerialDatabase::closeDatabase()
+ {
+ 	FUNCTIONSETUP;
+-	if (!isDBOpen() ) return;
++	if (!isOpen() ) return;
+ 
+ 	dlp_CloseDB(fDBSocket, getDBHandle());
+ 	setDBOpen(false);
+@@ -438,9 +393,9 @@ int PilotSerialDatabase::deleteDatabase(
+ {
+ 	FUNCTIONSETUP;
+ 
+-	if (isDBOpen()) closeDatabase();
++	if (isOpen()) closeDatabase();
+ 
+-	return dlp_DeleteDB(fDBSocket, 0, PilotAppCategory::codec()->fromUnicode(fDBName));
++	return dlp_DeleteDB(fDBSocket, 0, Pilot::toPilot(fDBName));
+ }
+ 
+ 
+diff -pruN kpilot/lib/pilotSerialDatabase.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotSerialDatabase.h
+--- kpilot/lib/pilotSerialDatabase.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotSerialDatabase.h	2006-11-19 22:21:12.000000000 +0100
+@@ -35,11 +35,15 @@
+ #include "pilotDatabase.h"
+ #include "pilotRecord.h"
+ 
++class KPilotDeviceLink;
+ 
+ class KDE_EXPORT PilotSerialDatabase : public PilotDatabase
+ {
++friend class KPilotDeviceLink;
++protected:
++	PilotSerialDatabase( KPilotDeviceLink *l, const QString &dbName);
++
+ public:
+-	PilotSerialDatabase(int linksocket, const QString &dbName);
+ 	virtual ~PilotSerialDatabase();
+ 
+ 	/** Reads the application block info, returns size */
+@@ -114,14 +118,12 @@ private:
+ 	QString     fDBName;
+ 	int         fDBHandle;
+ 	int         fDBSocket;
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 	// Pilot-link 0.12 allocates buffers as needed and resizes them.
+ 	// Start with a buffer that is _probably_ big enough for most 
+ 	// PIM records, but much smaller than the 64k that we use otherwise.
+ 	// Might want to add algorithm for trying to optimize the initial 
+ 	// allocation for a given database.
+ 	static const int InitialBufferSize = 2048;
+-#endif
+ };
+ 
+ #endif
+diff -pruN kpilot/lib/pilotStruct.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotStruct.cc
+--- kpilot/lib/pilotStruct.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/lib/pilotStruct.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,58 @@
++/* pilotStruct.cc
++**
++** Copyright (C) 1998-2001 by Dan Pilone
++** Copyright (C) 2003 by Reinhold Kainhofer
++** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org>
++**
++** Implementation for PilotUser and PilotSysInfo methods.
++**
++** Wrapper for the PilotUser struct from pilot-link, which describes
++** the user-data set in the Pilot.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++#include <config.h>
++#include "options.h"
++#include "fakes.h"
++
++#include "pilotUser.h"
++#include "pilotSysInfo.h"
++
++
++
++void KPilotSysInfo::setProductID(const char *prodid)
++{
++	strlcpy(fSysInfo.prodID, prodid, sizeof(fSysInfo.prodID));
++	boundsCheck();
++	fSysInfo.prodIDLength = strlen(fSysInfo.prodID);
++}
++
++void KPilotUser::setUserName(const char *name)
++{
++	memset(&fUser.username, 0, sizeof(fUser.username));
++	strlcpy(fUser.username, name,sizeof(fUser.username));
++}
++
++void KPilotUser::setPassword(const char *password)
++{
++	memset(&fUser.password, 0, sizeof(fUser.password));
++	strlcpy(fUser.password, password,sizeof(fUser.password));
++	fUser.passwordLength = strlen(fUser.password);
++}
++
+diff -pruN kpilot/lib/pilotSysInfo.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotSysInfo.h
+--- kpilot/lib/pilotSysInfo.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotSysInfo.h	2006-11-26 23:53:25.000000000 +0100
+@@ -59,48 +59,19 @@ public:
+ 	const unsigned long getLocale() const {return fSysInfo.locale;}
+ 	void setLocale(unsigned long newval)  {fSysInfo.locale=newval;}
+ 
+-#if ( PILOT_LINK_VERSION < 1 ) && ( PILOT_LINK_MAJOR < 11 )
+-// Older pilot-link versions < 0.11.x don't have prodID, but name instead,
+-// and they also do not have the *Version members.
+-	const int getProductIDLength() const { return fSysInfo.nameLength; }
+-	const char* getProductID()
+-	{
+-		fSysInfo.name[fSysInfo.nameLength]='\0';
+-		return fSysInfo.name;
+-	}
+-	void setProductID(char* prodid)
+-	{
+-		strlcpy(fSysInfo.name, prodid, sizeof(fSysInfo.name));
+-		boundsCheck();
+-		fSysInfo.nameLength = strlen(fSysInfo.name);
+-	}
+-
+-	const unsigned short getMajorVersion() const {return 0;}
+-	const unsigned short getMinorVersion() const {return 0;}
+-	const unsigned short getCompatMajorVersion() const {return 0;}
+-	const unsigned short getCompatMinorVersion() const {return 0;}
+-	const unsigned short getMaxRecSize() const {return 0;}
+-#else
+-// Newer pilot-link versions have these fields, so use them:
+ 	const int getProductIDLength() const { return fSysInfo.prodIDLength; }
+ 	const char* getProductID()
+ 	{
+ 		fSysInfo.prodID[fSysInfo.prodIDLength]='\0';
+ 		return fSysInfo.prodID;
+ 	}
+-	void setProductID(char* prodid)
+-	{
+-		strlcpy(fSysInfo.prodID, prodid, sizeof(fSysInfo.prodID));
+-		boundsCheck();
+-		fSysInfo.prodIDLength = strlen(fSysInfo.prodID);
+-	}
++	void setProductID(const char* prodid);
+ 
+ 	const unsigned short getMajorVersion() const {return fSysInfo.dlpMajorVersion;}
+ 	const unsigned short getMinorVersion() const {return fSysInfo.dlpMinorVersion;}
+ 	const unsigned short getCompatMajorVersion() const {return fSysInfo.compatMajorVersion;}
+ 	const unsigned short getCompatMinorVersion() const {return fSysInfo.compatMinorVersion;}
+ 	const unsigned short getMaxRecSize() const {return fSysInfo.maxRecSize;}
+-#endif
+ 
+ private:
+ 	struct SysInfo fSysInfo;
+diff -pruN kpilot/lib/pilotTodoEntry.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotTodoEntry.cc
+--- kpilot/lib/pilotTodoEntry.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotTodoEntry.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -26,11 +26,13 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
++#include <config.h>
+ #include "options.h"
++#include "fakes.h"
++
+ 
+ #include <stdlib.h>
+ 
+-#include <qtextcodec.h>
+ #include <qdatetime.h>
+ 
+ #include <kglobal.h>
+@@ -39,10 +41,8 @@
+ 
+ #include "pilotTodoEntry.h"
+ 
+-static const char *pilotTodoEntry_id = "$Id: pilotTodoEntry.cc 450724 2005-08-18 22:12:19Z adridg $";
+-
+ 
+-PilotTodoEntry::PilotTodoEntry(struct ToDoAppInfo &appInfo):PilotAppCategory(), fAppInfo(appInfo)
++PilotTodoEntry::PilotTodoEntry(struct ToDoAppInfo &appInfo): fAppInfo(appInfo)
+ {
+ 	FUNCTIONSETUP;
+ 	::memset(&fTodoInfo, 0, sizeof(struct ToDo));
+@@ -50,27 +50,21 @@ PilotTodoEntry::PilotTodoEntry(struct To
+ 
+ /* initialize the entry from another one. If rec==NULL, this constructor does the same as PilotTodoEntry()
+ */
+-PilotTodoEntry::PilotTodoEntry(struct ToDoAppInfo &appInfo, PilotRecord * rec):PilotAppCategory(rec), fAppInfo(appInfo)
++PilotTodoEntry::PilotTodoEntry(struct ToDoAppInfo &appInfo, PilotRecord * rec):PilotRecordBase(rec), fAppInfo(appInfo)
+ {
+ 	::memset(&fTodoInfo, 0, sizeof(struct ToDo));
+ 	if (rec)
+ 	{
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+ 		pi_buffer_t b;
+-		b.data = (unsigned char *) rec->getData();
++		b.data = (unsigned char *) rec->data();
+ 		b.allocated = b.used = rec->size();
+ 		unpack_ToDo(&fTodoInfo, &b, todo_v1);
+-#else
+-		unpack_ToDo(&fTodoInfo, (unsigned char *) rec->data(),
+-			rec->size());
+-#endif
+ 	}
+ 
+-	(void) pilotTodoEntry_id;
+ }
+ 
+ 
+-PilotTodoEntry::PilotTodoEntry(const PilotTodoEntry & e):PilotAppCategory(e), fAppInfo(e.fAppInfo)
++PilotTodoEntry::PilotTodoEntry(const PilotTodoEntry & e):PilotRecordBase( &e ), fAppInfo(e.fAppInfo)
+ {
+ 	FUNCTIONSETUP;
+ 	::memcpy(&fTodoInfo, &e.fTodoInfo, sizeof(fTodoInfo));
+@@ -154,28 +148,26 @@ QString PilotTodoEntry::getTextRepresent
+ 
+ QString PilotTodoEntry::getCategoryLabel() const
+ {
+-	return codec()->toUnicode(fAppInfo.category.name[category()]);
++	return Pilot::fromPilot(fAppInfo.category.name[category()]);
+ }
+ 
+-void *PilotTodoEntry::pack_(void *buf, int *len)
++PilotRecord *PilotTodoEntry::pack() const
+ {
+ 	int i;
+ 
+-#if PILOT_LINK_NUMBER >= PILOT_LINK_0_12_0
+-	pi_buffer_t b = { 0,0,0 } ;
+-	i = pack_ToDo(&fTodoInfo, &b, todo_v1);
+-	memcpy(buf,b.data,kMin(i,*len));
+-	*len = kMin(i,*len);
+-#else
+-	i = pack_ToDo(&fTodoInfo, (unsigned char *) buf, *len);
+-	*len = i;
+-#endif
+-	return buf;
++	pi_buffer_t *b = pi_buffer_new( sizeof(fTodoInfo) );
++	i = pack_ToDo(const_cast<ToDo_t *>(&fTodoInfo), b, todo_v1);
++	if (i<0)
++	{
++		return 0;
++	}
++	// pack_ToDo sets b->used
++	return new PilotRecord( b, this );
+ }
+ 
+ void PilotTodoEntry::setDescription(const QString &desc)
+ {
+-	setDescriptionP(codec()->fromUnicode(desc),desc.length());
++	setDescriptionP(Pilot::toPilot(desc),desc.length());
+ }
+ 
+ void PilotTodoEntry::setDescriptionP(const char *desc, int len)
+@@ -205,12 +197,12 @@ void PilotTodoEntry::setDescriptionP(con
+ 
+ QString PilotTodoEntry::getDescription() const
+ {
+-	return codec()->toUnicode(getDescriptionP());
++	return Pilot::fromPilot(getDescriptionP());
+ }
+ 
+ void PilotTodoEntry::setNote(const QString &note)
+ {
+-	setNoteP(codec()->fromUnicode(note),note.length());
++	setNoteP(Pilot::toPilot(note),note.length());
+ }
+ 
+ void PilotTodoEntry::setNoteP(const char *note, int len)
+@@ -238,6 +230,6 @@ void PilotTodoEntry::setNoteP(const char
+ 
+ QString PilotTodoEntry::getNote() const
+ {
+-	return codec()->toUnicode(getNoteP());
++	return Pilot::fromPilot(getNoteP());
+ }
+ 
+diff -pruN kpilot/lib/pilotTodoEntry.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotTodoEntry.h
+--- kpilot/lib/pilotTodoEntry.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotTodoEntry.h	2006-11-26 23:53:25.000000000 +0100
+@@ -37,36 +37,40 @@
+ 
+ #include <qstring.h>
+ 
+-#include "pilotAppCategory.h"
+-#include "pilotDatabase.h"
++#include "pilotRecord.h"
++#include "pilotAppInfo.h"
+ 
+ /** @file This file defines structures wrapped around the ToDo database
+ * on the Pilot, based on pilot-link's ToDo stuff.
+ */
+ 
+ /** A decoded ToDo item. */
+-class KDE_EXPORT PilotTodoEntry : public PilotAppCategory
++class KDE_EXPORT PilotTodoEntry : public PilotRecordBase
+ {
+ public:
+ 	/** Create an empty ToDo item */
+ 	PilotTodoEntry(struct ToDoAppInfo &appInfo);
++
+ 	/** Create a ToDo item and fill it with data from the uninterpreted record @p rec. */
+ 	PilotTodoEntry(struct ToDoAppInfo &appInfo, PilotRecord * rec);
++
+ 	/** Copy an existing ToDo item. */
+ 	PilotTodoEntry(const PilotTodoEntry &e);
++
+ 	/** Delete a ToDo item. */
+ 	~PilotTodoEntry() { free_ToDo(&fTodoInfo); }
+ 
+ 	/** Return a string for the ToDo item. If @param richText is true, then
+ 	* use qt style markup to make the string clearer when displayed.
+ 	*/
+-	virtual QString getTextRepresentation(bool richText=false);
++	QString getTextRepresentation(bool richText=false);
+ 
+ 	/** Assign an existing ToDo item to this one. */
+ 	PilotTodoEntry& operator=(const PilotTodoEntry &e);
+ 
+ 	/** Accessor for the Due Date of the ToDo item. */
+ 	struct tm getDueDate() const { return fTodoInfo.due; }
++
+ 	/** Set the Due Date for the ToDo item. */
+ 	void setDueDate(struct tm& d) { fTodoInfo.due = d; }
+ 
+@@ -75,6 +79,7 @@ public:
+ 	* (not indefinite) or non-0.
+ 	*/
+ 	int getIndefinite() const { return fTodoInfo.indefinite; }
++
+ 	/** Set whether the ToDo is indefinite or not. */
+ 	void setIndefinite(int i) { fTodoInfo.indefinite = i; }
+ 
+@@ -83,11 +88,13 @@ public:
+ 	* onto KOrganizer's priority levels.
+ 	*/
+ 	int getPriority() const { return fTodoInfo.priority; }
++
+ 	/** Set the priority of the ToDo. */
+ 	void setPriority(int p) { fTodoInfo.priority = p; }
+ 
+ 	/** Return whether the ToDo is complete (done, finished) or not. */
+ 	int getComplete() const { return fTodoInfo.complete; }
++
+ 	/** Set whether the ToDo is done. */
+ 	void setComplete(int c) { fTodoInfo.complete = c; }
+ 
+@@ -102,6 +109,7 @@ public:
+ 	* on the handheld). This uses the default codec.
+ 	*/
+ 	QString getNote() const;
++
+ 	/** Set the ToDo item's note. */
+ 	void  setNote(const QString &note);
+ 
+@@ -112,14 +120,11 @@ public:
+ 	/** If the label already exists, uses the id; if not, adds the label
+ 	*  to the category list. @return false if category labels are full.
+ 	*/
+-	inline bool setCategory(const QString &label) { return PilotAppCategory::setCategory(fAppInfo.category,label);  };
++	inline bool setCategory(const QString &label) { return Pilot::insertCategory(&fAppInfo.category,label,false) >= 0;  };
+ 
+-	// static const int APP_BUFFER_SIZE;
++	PilotRecord *pack() const;
+ 
+ protected:
+-	void *pack_(void *buf, int *size);
+-	void unpack(const void *buf, int size = 0) { } ;
+-
+ 	const char *getDescriptionP() const { return fTodoInfo.description; } ;
+ 	void setDescriptionP(const char *, int len=-1) ;
+ 	const char *getNoteP() const { return fTodoInfo.note; } ;
+diff -pruN kpilot/lib/pilotUser.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pilotUser.h
+--- kpilot/lib/pilotUser.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pilotUser.h	2006-11-26 23:53:25.000000000 +0100
+@@ -39,25 +39,16 @@ class KPilotUser
+ {
+ public:
+ 	KPilotUser() { ::memset(&fUser,0,sizeof(struct PilotUser)); }
+-	KPilotUser(const PilotUser* user) { fUser = *user; }
++	KPilotUser(const PilotUser *user) { fUser = *user; }
+ 
+ 	PilotUser *pilotUser() { return &fUser; }
+ 
+ 	const char* getUserName() const     { return fUser.username; }
+-	void setUserName(const char* name)
+-	{
+-		memset(&fUser.username, 0, sizeof(fUser.username));
+-		strlcpy(fUser.username, name,sizeof(fUser.username));
+-	}
++	void setUserName(const char *name);
+ 
+ 	const int getPasswordLength() const { return fUser.passwordLength; }
+ 	const char* getPassword() const     { return fUser.password; }
+-	void setPassword(char* password)
+-	{
+-		memset(&fUser.password, 0, sizeof(fUser.password));
+-		strlcpy(fUser.password, password,sizeof(fUser.password));
+-		fUser.passwordLength = strlen(fUser.password);
+-	}
++	void setPassword(const char *password);
+ 
+ 	unsigned long getUserID() const     { return fUser.userID; }
+ 	unsigned long getViewerID() const   { return fUser.viewerID; }
+diff -pruN kpilot/lib/plugin.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/plugin.cc
+--- kpilot/lib/plugin.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/plugin.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -39,7 +39,6 @@
+ #include <qfileinfo.h>
+ #include <qdir.h>
+ #include <qregexp.h>
+-#include <qtextcodec.h>
+ 
+ #include <dcopclient.h>
+ #include <kapplication.h>
+@@ -49,7 +48,6 @@
+ 
+ #include "pilotSerialDatabase.h"
+ #include "pilotLocalDatabase.h"
+-#include "pilotAppCategory.h"
+ 
+ #include "plugin.moc"
+ 
+@@ -96,7 +94,7 @@ ConduitConfigBase::~ConduitConfigBase()
+ 	return true;
+ }
+ 
+-ConduitAction::ConduitAction(KPilotDeviceLink *p,
++ConduitAction::ConduitAction(KPilotLink *p,
+ 	const char *name,
+ 	const QStringList &args) :
+ 	SyncAction(p,name),
+@@ -120,10 +118,10 @@ ConduitAction::ConduitAction(KPilotDevic
+ 		it != args.end();
+ 		++it)
+ 	{
+-		DEBUGCONDUIT << fname << ": " << *it << endl;
++		DEBUGLIBRARY << fname << ": " << *it << endl;
+ 	}
+ 
+-	DEBUGCONDUIT << fname << ": Direction=" << fSyncDirection.name() << endl;
++	DEBUGLIBRARY << fname << ": Direction=" << fSyncDirection.name() << endl;
+ #endif
+ }
+ 
+@@ -134,18 +132,23 @@ ConduitAction::ConduitAction(KPilotDevic
+ 	KPILOT_DELETE(fLocalDatabase);
+ }
+ 
+-bool ConduitAction::openDatabases_(const QString &name, bool *retrieved)
++bool ConduitAction::openDatabases(const QString &name, bool *retrieved)
+ {
+ 	FUNCTIONSETUP;
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Trying to open database "
+ 		<< name << endl;
+-#endif
++	DEBUGLIBRARY << fname
++		<< ": Mode="
++		<< (syncMode().isTest() ? "test " : "")
++		<< (syncMode().isLocal() ? "local " : "")
++		<< endl ;
+ 
+ 	KPILOT_DELETE(fLocalDatabase);
+-	PilotLocalDatabase *localDB = new PilotLocalDatabase(name, true);
++
++	QString localPathName = PilotLocalDatabase::getDBPath() + name;
++	PilotLocalDatabase *localDB = new PilotLocalDatabase( localPathName );
+ 
+ 	if (!localDB)
+ 	{
+@@ -158,69 +161,59 @@ bool ConduitAction::openDatabases_(const
+ 	}
+ 
+ 	// if there is no backup db yet, fetch it from the palm, open it and set the full sync flag.
+-	if (!localDB->isDBOpen() )
++	if (!localDB->isOpen() )
+ 	{
+ 		QString dbpath(localDB->dbPathName());
+ 		KPILOT_DELETE(localDB);
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname
+-			<< ": Backup database "<< dbpath <<" could not be opened. Will fetch a copy from the palm and do a full sync"<<endl;
+-#endif
++		DEBUGLIBRARY << fname
++			<< ": Backup database " << dbpath
++			<< " not found." << endl;
+ 		struct DBInfo dbinfo;
+-		if (fHandle->findDatabase(PilotAppCategory::codec()->fromUnicode( name ), &dbinfo)<0 )
++
++// TODO Extend findDatabase() with extra overload?
++		if (deviceLink()->findDatabase(Pilot::toPilot( name ), &dbinfo)<0 )
+ 		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname
+-				<< ": Could not get DBInfo for "<<name<<"! "<<endl;
+-#endif
++			kdWarning() << k_funcinfo
++				<< ": Could not get DBInfo for " << name << endl;
+ 			if (retrieved) *retrieved = false;
+ 			return false;
+ 		}
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname
+-				<< ": Found Palm database: "<<dbinfo.name<<endl
+-				<<"type = "<< dbinfo.type<<endl
+-				<<"creator = "<< dbinfo.creator<<endl
+-				<<"version = "<< dbinfo.version<<endl
+-				<<"index = "<< dbinfo.index<<endl;
+-#endif
++
++		DEBUGLIBRARY << fname
++				<< ": Found Palm database: " << dbinfo.name <<endl
++				<< fname << ": type = " << dbinfo.type
++				<< " creator = " << dbinfo.creator
++				<< " version = " << dbinfo.version
++				<< " index = " << dbinfo.index << endl;
+ 		dbinfo.flags &= ~dlpDBFlagOpen;
+ 
+ 		// make sure the dir for the backup db really exists!
+ 		QFileInfo fi(dbpath);
+-		QString path(QFileInfo(dbpath).dir(TRUE).absPath());
++		QString path(QFileInfo(dbpath).dir(true).absPath());
+ 		if (!path.endsWith(CSL1("/"))) path.append(CSL1("/"));
+ 		if (!KStandardDirs::exists(path))
+ 		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname << ": Trying to create path for database: <"
++			DEBUGLIBRARY << fname << ": Trying to create path for database: <"
+ 				<< path << ">" << endl;
+-#endif
+ 			KStandardDirs::makeDir(path);
+ 		}
+ 		if (!KStandardDirs::exists(path))
+ 		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname << ": Database directory does not exist." << endl;
+-#endif
++			DEBUGLIBRARY << fname << ": Database directory does not exist." << endl;
+ 			if (retrieved) *retrieved = false;
+ 			return false;
+ 		}
+ 
+-		if (!fHandle->retrieveDatabase(dbpath, &dbinfo) )
++		if (!deviceLink()->retrieveDatabase(dbpath, &dbinfo) )
+ 		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname << ": Could not retrieve database "<<name<<" from the handheld."<<endl;
+-#endif
++			kdWarning() << k_funcinfo << ": Could not retrieve database "<<name<<" from the handheld."<<endl;
+ 			if (retrieved) *retrieved = false;
+ 			return false;
+ 		}
+-		localDB = new PilotLocalDatabase(name, true);
+-		if (!localDB || !localDB->isDBOpen())
++		localDB = new PilotLocalDatabase( localPathName );
++		if (!localDB || !localDB->isOpen())
+ 		{
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname << ": local backup of database "<<name<<" could not be initialized."<<endl;
+-#endif
++			kdWarning() << k_funcinfo << ": local backup of database "<<name<<" could not be initialized."<<endl;
+ 			if (retrieved) *retrieved = false;
+ 			return false;
+ 		}
+@@ -228,7 +221,7 @@ bool ConduitAction::openDatabases_(const
+ 	}
+ 	fLocalDatabase = localDB;
+ 
+-	fDatabase = new PilotSerialDatabase(pilotSocket(), name /* On pilot */);
++	fDatabase = deviceLink()->database( name );
+ 
+ 	if (!fDatabase)
+ 	{
+@@ -239,150 +232,58 @@ bool ConduitAction::openDatabases_(const
+ 			<< endl;
+ 	}
+ 
+-	return (fDatabase && fDatabase->isDBOpen() &&
+-	        fLocalDatabase && fLocalDatabase->isDBOpen() );
++	return (fDatabase && fDatabase->isOpen() &&
++	        fLocalDatabase && fLocalDatabase->isOpen() );
+ }
+ 
+-// This whole function is for debugging purposes only.
+-bool ConduitAction::openDatabases_(const QString &dbName,const QString &localPath)
++
++bool ConduitAction::changeSync(SyncMode::Mode m)
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Doing local test mode for " << dbName << endl;
+-#endif
+-	if (localPath.isNull())
+-	{
+-#ifdef DEBUG
+-		DEBUGCONDUIT << fname
+-			<< ": local mode test for one database only."
+-			<< endl;
+-#endif
+-		fDatabase = new PilotLocalDatabase(dbName,false);
+-		fLocalDatabase = 0L;
+-		return false;
+-	}
+ 
+-	fDatabase = new PilotLocalDatabase(localPath,dbName);
+-	fLocalDatabase= new PilotLocalDatabase(dbName, true); // From default
+-	if (!fLocalDatabase || !fDatabase)
+-	{
+-#ifdef DEBUG
+-		const QString *where2 = PilotLocalDatabase::getDBPath();
+-
+-		QString none = CSL1("<null>");
+-		DEBUGCONDUIT << fname
+-			<< ": Could not open both local copies of \""
+-			<< dbName
+-			<< "\"" << endl
+-			<< "Using \""
+-			<< (where2 ? *where2 : none)
+-			<< "\" and \""
+-			<< (localPath.isEmpty() ? localPath : none)
+-			<< "\""
+-			<< endl;
+-#endif
+-	}
+-#ifdef DEBUG
+-	if (fLocalDatabase)
+-	{
+-		DEBUGCONDUIT << fname
+-			<< ": Opened local database "
+-			<< fLocalDatabase->dbPathName()
+-			<< (fLocalDatabase->isDBOpen() ? " OK" : "")
+-			<< endl;
+-	}
+-	if (fDatabase)
++	if ( fSyncDirection.isSync() && SyncMode::eFullSync == m)
+ 	{
+-		DEBUGCONDUIT << fname
+-			<< ": Opened database "
+-			<< fDatabase->dbPathName()
+-			<< (fDatabase->isDBOpen() ? " OK" : "")
+-			<< endl;
++		fSyncDirection.setMode(m);
++		return true;
+ 	}
+-#endif
+-
+-	return (fDatabase && fLocalDatabase);
++	return false;
+ }
+ 
+-bool ConduitAction::openDatabases(const QString &dbName, bool *retrieved)
++
++namespace PluginUtility
++{
++
++QString findArgument(const QStringList &a, const QString &arg)
+ {
+ 	FUNCTIONSETUP;
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": Mode="
+-		<< (syncMode().isTest() ? "test " : "")
+-		<< (syncMode().isLocal() ? "local " : "")
+-		<< endl ;
+-#endif
++	QString search;
+ 
+-	if (syncMode().isLocal())
++	if (arg.startsWith( CSL1("--") ))
+ 	{
+-		return openDatabases_(dbName,CSL1("/tmp/"));
++		search = arg;
+ 	}
+ 	else
+ 	{
+-		return openDatabases_(dbName, retrieved);
+-	}
+-}
+-
+-bool ConduitAction::changeSync(SyncMode::Mode m)
+-{
+-	FUNCTIONSETUP;
+-
+-	if ( fSyncDirection.isSync() && SyncMode::eFullSync == m)
+-	{
+-		fSyncDirection.setMode(m);
+-		return true;
++		search = CSL1("--") + arg;
+ 	}
+-	return false;
+-}
++	search.append( CSL1("=") );
+ 
+-int PluginUtility::findHandle(const QStringList &a)
+-{
+-	FUNCTIONSETUP;
+ 
+-	int handle = -1;
+-	for (QStringList::ConstIterator i = a.begin();
+-		i != a.end(); ++i)
++	QStringList::ConstIterator end = a.end();
++	for (QStringList::ConstIterator i = a.begin(); i != end; ++i)
+ 	{
+-		if ((*i).left(7) == CSL1("handle="))
++		if ((*i).startsWith( search ))
+ 		{
+-			QString s = (*i).mid(7);
+-			if (s.isEmpty()) continue;
+-
+-			handle = s.toInt();
+-#ifdef DEBUG
+-			DEBUGCONDUIT << fname
+-				<< ": Got handle "
+-				<< handle
+-				<< endl;
+-#endif
+-			if (handle<1)
+-			{
+-				kdWarning() << k_funcinfo
+-					<< ": Improbable handle value found."
+-					<< endl;
+-			}
+-			return handle;
++			QString s = (*i).mid(search.length());
++			return s;
+ 		}
+ 	}
+ 
+-#ifdef DEBUG
+-	DEBUGCONDUIT << fname
+-		<< ": No handle= parameter found."
+-		<< endl;
+-#endif
+-
+-	return -1;
++	return QString::null;
+ }
+ 
+-bool PluginUtility::isModal(const QStringList &a)
+-{
+-	return a.contains(CSL1("modal"));
+-}
+-
+-/* static */ bool PluginUtility::isRunning(const QCString &n)
++/* static */ bool isRunning(const QCString &n)
+ {
+ 	DCOPClient *dcop = KApplication::kApplication()->dcopClient();
+ 	QCStringList apps = dcop->registeredApplications();
+@@ -390,19 +291,19 @@ bool PluginUtility::isModal(const QStrin
+ }
+ 
+ 
+-/* static */ long PluginUtility::pluginVersion(const KLibrary *lib)
++/* static */ unsigned long pluginVersion(const KLibrary *lib)
+ {
+ 	QString symbol = CSL1("version_");
+ 	symbol.append(lib->name());
+ 
+ 	if (!lib->hasSymbol(symbol.latin1())) return 0;
+ 
+-	long *p = (long *)(lib->symbol(symbol.latin1()));
++	unsigned long *p = (unsigned long *)(lib->symbol(symbol.latin1()));
+ 	return *p;
+ }
+ 
+ 
+-/* static */ QString PluginUtility::pluginVersionString(const KLibrary *lib)
++/* static */ QString pluginVersionString(const KLibrary *lib)
+ {
+ 	QString symbol= CSL1("id_");
+ 	symbol.append(lib->name());
+@@ -413,3 +314,5 @@ bool PluginUtility::isModal(const QStrin
+ }
+ 
+ 
++}
++
+diff -pruN kpilot/lib/pluginfactory.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/pluginfactory.h
+--- kpilot/lib/pluginfactory.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/pluginfactory.h	2006-11-26 23:53:25.000000000 +0100
+@@ -1,6 +1,6 @@
+-#ifndef _KPILOT_PLUGIN_FACTORY_H
+-#define _KPILOT_PLUGIN_FACTORY_H
+-/* plugin_factory.h                        KPilot
++#ifndef _KPILOT_PLUGINFACTORY_H
++#define _KPILOT_PLUGINFACTORY_H
++/* pluginfactory.h                        KPilot
+ **
+ ** Copyright (C) 2005 by Adriaan de Groot
+ **
+@@ -33,7 +33,7 @@
+ #include <klibloader.h>
+ #include <kdebug.h>
+ 
+-class KPilotDeviceLink;
++class KPilotLink;
+ 
+ /** Template class that defines a conduit's factory. */
+ 
+@@ -68,8 +68,8 @@ protected:
+ 
+ 		if (qstrcmp(classname,"SyncAction")==0)
+ 		{
+-			KPilotDeviceLink *d = 0L;
+-			if (parent) d = dynamic_cast<KPilotDeviceLink *>(parent);
++			KPilotLink *d = 0L;
++			if (parent) d = dynamic_cast<KPilotLink *>(parent);
+ 
+ 			if (d || !parent)
+ 			{
+@@ -82,7 +82,7 @@ protected:
+ 			else
+ 			{
+ 				kdError() << k_funcinfo
+-					<< ": Couldn't cast parent to KPilotDeviceLink"
++					<< ": Couldn't cast parent to KPilotLink"
+ 					<< endl;
+ 				return 0L;
+ 			}
+diff -pruN kpilot/lib/plugin.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/plugin.h
+--- kpilot/lib/plugin.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/plugin.h	2006-11-26 23:53:25.000000000 +0100
+@@ -41,7 +41,10 @@
+ class PilotDatabase;
+ class KLibrary;
+ 
+-#define KPILOT_PLUGIN_API	(20050401)
++namespace Pilot
++{
++	static const unsigned int PLUGIN_API = 20061118;
++}
+ 
+ /**
+ * The first classe here: ConduitConfigBase is for configuration purposes.
+@@ -135,7 +138,7 @@ class KDE_EXPORT ConduitAction : public 
+ {
+ Q_OBJECT
+ public:
+-	ConduitAction(KPilotDeviceLink *,
++	ConduitAction(KPilotLink *,
+ 		const char *name=0L,
+ 		const QStringList &args = QStringList());
+ 	virtual ~ConduitAction();
+@@ -188,12 +191,16 @@ protected:
+ 	} ;
+ 	void setFirstSync(bool first) { fFirstSync=first; } ;
+ 
+-	PilotDatabase *fDatabase,*fLocalDatabase;
++	PilotDatabase *fDatabase;
++	PilotDatabase *fLocalDatabase; // Guaranteed to be a PilotLocalDatabase
+ 
+ 	/**
+-	* See openDatabases_ for info on the @p retrieved
+-	* parameter. In local mode, @p retrieved is left
+-	* unchanged.
++	* Open both the local copy of database @p dbName
++	* and the version on the Pilot. Return true only
++	* if both opens succeed. If the local copy of the database
++	* does not exist, it is retrieved from the handheld. In this
++	* case, retrieved is set to true, otherwise it is left alone
++	* (i.e. retains its value and is not explicitly set to false).
+ 	*
+ 	* @param dbName database name to open.
+ 	* @param retrieved indicator whether the database had to be loaded
+@@ -210,38 +217,14 @@ protected:
+ 	QString fConduitName;
+ private:
+ 	bool fFirstSync;
+-
+-private:
+-	/**
+-	* Open both the local copy of database @p dbName
+-	* and the version on the Pilot. Return true only
+-	* if both opens succeed. If the local copy of the database
+-	* does not exist, it is retrieved from the handheld. In this
+-	* case, retrieved is set to true, otherwise it is left alone
+-	* (i.e. retains its value and is not explicitly set to false).
+-	*/
+-	bool openDatabases_(const QString &dbName, bool*retrieved=0L);
+-
+-	/**
+-	* Open both databases, but get the fDatabase not from
+-	* the Pilot, but from a local database in an alternate
+-	* directory. For testing only.
+-	*
+-	* If @p localPath is QString::null, don't even try to open
+-	* fDatabase (the one that is supposed to be on the HH).
+-	* Just open the one inteded to be on the PC (fLocalDatabase).
+-	*/
+-	bool openDatabases_(const QString &dbName,const QString &localPath);
+ } ;
+ 
+-/** A class containing only static helper methods. */
+-class KDE_EXPORT PluginUtility
++/** A namespace containing only static helper methods. */
++namespace PluginUtility
+ {
+-public:
+-	/** Searches the string list for --handle=NN and returns the number. */
+-	static int findHandle(const QStringList &);
+-	/** Searches the string list for --modal and returns true if found. */
+-	static bool isModal(const QStringList &a);
++	/** Searches the argument list for --foo=bar and returns bar, QString::null if not found.
++	* Don't include the -- in the argname. */
++	QString findArgument(const QStringList &a, const QString argname);
+ 
+ 	/**
+ 	* This function attempts to detect whether or not the given
+@@ -251,14 +234,14 @@ public:
+ 	* The current approach is to ask the DCOP server if the application
+ 	* has registered.
+ 	*/
+-	static bool isRunning(const QCString &appName);
++	bool isRunning(const QCString &appName);
+ 
+ 	/**
+ 	* Check a given library for its version, returning 0 if no
+ 	* version symbol is found.
+ 	*/
+-	static long pluginVersion(const KLibrary *);
+-	static QString pluginVersionString(const KLibrary *);
++	unsigned long pluginVersion(const KLibrary *);
++	QString pluginVersionString(const KLibrary *);
+ } ;
+ 
+ /**
+diff -pruN kpilot/lib/recordConduit.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/recordConduit.cc
+--- kpilot/lib/recordConduit.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/recordConduit.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -38,7 +38,6 @@
+ #include "options.h"
+ 
+ #include <qtimer.h>
+-#include <qtextcodec.h>
+ #include <qfile.h>
+ 
+ #include "pilotAppCategory.h"
+@@ -53,8 +52,7 @@
+ //
+ extern "C"
+ {
+-long version_record_conduit = KPILOT_PLUGIN_API;
+-const char *id_record_conduit="$Id: recordConduit.cc 437980 2005-07-23 19:53:57Z kainhofe $";
++long version_record_conduit = Pilot::PLUGIN_API;
+ }
+ 
+ 
+@@ -79,7 +77,7 @@ const char *id_record_conduit="$Id: reco
+ 
+ 	fTimer = new QTimer(this);
+ 	connect(fTimer,SIGNAL(timeout()),this,SLOT(process()));
+-	fTimer->start(0,true); // Fire as often as possible to prompt processing
++	fTimer->start(0,false); // Fire as often as possible to prompt processing
+ 	return true;
+ }
+ 
+@@ -88,6 +86,10 @@ const char *id_record_conduit="$Id: reco
+ 	FUNCTIONSETUP;
+ 	SyncProgress p = Error;
+ 
++#ifdef DEBUG
++	DEBUGLIBRARY << fname << ": From state " << name(fState) << endl;
++#endif
++
+ 	switch(fState)
+ 	{
+ 	case Initialize :
+@@ -96,11 +98,18 @@ const char *id_record_conduit="$Id: reco
+ 	case PalmToPC :
+ 		p = palmRecToPC();
+ 		break;
++	case PCToPalm :
++		p = pcRecToPalm();
++		break;
+ 	case Cleanup :
+ 		p = cleanup();
+ 		break;
+ 	}
+ 
++#ifdef DEBUG
++	DEBUGLIBRARY << fname << ": Step returned " << name(p) << endl;
++#endif
++
+ 	switch(p)
+ 	{
+ 	case Error :
+@@ -115,21 +124,36 @@ const char *id_record_conduit="$Id: reco
+ 		break;
+ 	}
+ 
++#ifdef DEBUG
++	DEBUGLIBRARY << fname << ": Step is done, moving to next state." << endl;
++#endif
++
+ 	// Here the previous call was done.
+ 	switch(fState)
+ 	{
+ 	case Initialize :
+-		if ( ( syncMode().mode() == SyncMode::eCopyPCToHH ) ||
+-			( syncMode().mode() == SyncMode::eRestore ) )
+-		{
+-			fState = Cleanup;
+-		}
+-		else
++		switch (syncMode().mode())
+ 		{
++		case SyncMode::eRestore :
++		case SyncMode::eCopyPCToHH : /* These two don't copy Palm records to the PC */
++			fState = PCToPalm;
++			break;
++		default :
+ 			fState = PalmToPC;
+ 		}
+ 		break;
+ 	case PalmToPC :
++		switch (syncMode().mode())
++		{
++		case SyncMode::eBackup :
++		case SyncMode::eCopyHHToPC : /* These modes don't copy PC records back */
++			fState = Cleanup;
++			break;
++		default :
++			fState = PCToPalm;
++		}
++		break;
++	case PCToPalm :
+ 		fState = Cleanup;
+ 		break;
+ 	case Cleanup :
+@@ -138,6 +162,41 @@ const char *id_record_conduit="$Id: reco
+ 		// No change in state, timer stopped and we're done.
+ 		break;
+ 	}
++
++#ifdef DEBUG
++	DEBUGLIBRARY << fname << ": Next state is " << name(fState) << endl;
++#endif
++
++}
++
++
++QString RecordConduitBase::name(RecordConduitBase::SyncProgress s)
++{
++	switch(s)
++	{
++	case RecordConduitBase::NotDone:
++		return CSL1("NotDone");
++	case RecordConduitBase::Done:
++		return CSL1("Done");
++	case RecordConduitBase::Error:
++		return CSL1("Error");
++	}
++}
++
++
++QString RecordConduitBase::name(RecordConduitBase::States s)
++{
++	switch(s)
++	{
++	case RecordConduitBase::Initialize:
++		return CSL1("Initialize");
++	case RecordConduitBase::PalmToPC:
++		return CSL1("Handheld-to-PC");
++	case RecordConduitBase::PCToPalm:
++		return CSL1("PC-to-Handheld");
++	case RecordConduitBase::Cleanup:
++		return CSL1("Cleanup");
++	}
+ }
+ 
+ 
+@@ -174,7 +233,7 @@ bool RecordConduit::PCData::mapContactsT
+ 		++it;
+ 	}
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Loaded " << idContactMap.size() <<
++	DEBUGLIBRARY << fname << ": Loaded " << idContactMap.size() <<
+ 	    " Entries on the pc and mapped them to records on the handheld. " << endl;
+ #endif
+ 	return true;
+@@ -196,9 +255,6 @@ RecordConduit::RecordConduit(QString nam
+ 		mEntryMap(), mSyncedIds(), mAllIds()
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_record_conduit << endl;
+-#endif
+ 	fConduitName = name;
+ }
+ 
+@@ -223,9 +279,6 @@ RecordConduit::~RecordConduit()
+ /* virtual */ bool RecordConduit::exec()
+ {
+ 	FUNCTIONSETUP;
+-#ifdef DEBUG
+-	DEBUGCONDUIT << id_record_conduit << endl;
+-#endif
+ 
+ 	if ( !_prepare() ) return false;
+ 
+@@ -255,13 +308,13 @@ RecordConduit::~RecordConduit()
+ 	mPalmIndex = 0;
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": fullsync=" << isFullSync() << ", firstSync=" << isFirstSync() << endl;
+-	DEBUGCONDUIT << fname << ": "
++	DEBUGLIBRARY << fname << ": fullsync=" << isFullSync() << ", firstSync=" << isFirstSync() << endl;
++	DEBUGLIBRARY << fname << ": "
+ 		<< "syncDirection=" << getSyncDirection() << ", "
+ //		<< "archive = " << AbbrowserSettings::archiveDeleted()
+ 		<< endl;
+-	DEBUGCONDUIT << fname << ": conflictRes="<< getConflictResolution() << endl;
+-//	DEBUGCONDUIT << fname << ": PilotStreetHome=" << AbbrowserSettings::pilotStreet() << ", PilotFaxHOme" << AbbrowserSettings::pilotFax() << endl;
++	DEBUGLIBRARY << fname << ": conflictRes="<< getConflictResolution() << endl;
++//	DEBUGLIBRARY << fname << ": PilotStreetHome=" << AbbrowserSettings::pilotStreet() << ", PilotFaxHOme" << AbbrowserSettings::pilotFax() << endl;
+ #endif
+ 
+ 	if ( !isFirstSync() )
+@@ -361,7 +414,7 @@ void RecordConduit::slotPCRecToPalm()
+ 	if ( isArchived( pcEntry ) )
+ 	{
+ #ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": address with id " << pcEntry->uid() <<
++		DEBUGLIBRARY << fname << ": address with id " << pcEntry->uid() <<
+ 			" marked archived, so don't sync." << endl;
+ #endif
+ 		KPILOT_DELETE( pcEntry );
+@@ -383,7 +436,7 @@ void RecordConduit::slotPCRecToPalm()
+ 	if ( mSyncedIds.contains( recID ) )
+ 	{
+ #ifdef DEBUG
+-		DEBUGCONDUIT << ": address with id " << recID << " already synced." << endl;
++		DEBUGLIBRARY << ": address with id " << recID << " already synced." << endl;
+ #endif
+ 		KPILOT_DELETE( pcEntry );
+ 		QTimer::singleShot( 0, this, SLOT( slotPCRecToPalm() ) );
+@@ -487,7 +540,7 @@ void RecordConduit::slotDeleteUnsyncedPC
+ 			if ( !uids.contains( *uidit ) )
+ 			{
+ #ifdef DEBUG
+-				DEBUGCONDUIT << "Deleting PCEntry with uid " << (*uidit) << " from PC (is not on HH, and syncing with HH->PC direction)" << endl;
++				DEBUGLIBRARY << "Deleting PCEntry with uid " << (*uidit) << " from PC (is not on HH, and syncing with HH->PC direction)" << endl;
+ #endif
+ 				mPCData->removeEntry( *uidit );
+ 			}
+@@ -510,7 +563,7 @@ void RecordConduit::slotDeleteUnsyncedHH
+ 			if ( !mSyncedIds.contains(*it) )
+ 			{
+ #ifdef DEBUG
+-				DEBUGCONDUIT << "Deleting record with ID " << *it << " from handheld (is not on PC, and syncing with PC->HH direction)" << endl;
++				DEBUGLIBRARY << "Deleting record with ID " << *it << " from handheld (is not on PC, and syncing with PC->HH direction)" << endl;
+ #endif
+ 				fDatabase->deleteRecord(*it);
+ 				fLocalDatabase->deleteRecord(*it);
+@@ -552,7 +605,7 @@ void RecordConduit::slotCleanup()
+ const QStringList RecordConduit::categories() const
+ {
+ 	QStringList cats;
+-	for ( int j = 0; j < PILOT_CATEGORY_MAX; j++ ) {
++	for ( unsigned int j = 0; j < Pilot::CATEGORY_COUNT; j++ ) {
+ 		QString catName( category( j ) );
+ 		if ( !catName.isEmpty() ) cats << catName;
+ 	}
+@@ -607,8 +660,8 @@ void RecordConduit::_getAppInfo()
+ {
+ 	FUNCTIONSETUP;
+ 	// get the address application header information
+-	unsigned char *buffer = new unsigned char[PilotRecord::APP_BUFFER_SIZE];
+-	int appLen=fDatabase->readAppBlock(buffer, PilotRecord::APP_BUFFER_SIZE);
++	unsigned char *buffer = new unsigned char[Pilot::MAX_APPINFO_SIZE];
++	int appLen=fDatabase->readAppBlock(buffer, Pilot::MAX_APPINFO_SIZE);
+ 
+ 	doUnpackAppInfo( buffer, appLen );
+ 	delete[] buffer;
+@@ -651,14 +704,13 @@ int RecordConduit::compareStr( const QSt
+ QString RecordConduit::getCatForHH( const QStringList cats, const QString curr ) const
+ {
+ 	FUNCTIONSETUP;
+-	int j;
+ 	if ( cats.size() < 1 )
+ 		return QString::null;
+ 	if ( cats.contains( curr ) )
+ 		return curr;
+ 	for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it)
+ 	{
+-		for ( j = 0; j < PILOT_CATEGORY_MAX; j++ )
++		for ( unsigned int j = 0; j < Pilot::CATEGORY_COUNT; j++ )
+ 		{
+ 			QString catnm( category( j ) );
+ 			if ( !(*it).isEmpty() && ( (*it)==catnm ) )
+@@ -668,7 +720,7 @@ QString RecordConduit::getCatForHH( cons
+ 		}
+ 	}
+ 	// If we have a free label, return the first possible cat
+-	QString lastCat( category( PILOT_CATEGORY_MAX-1 ) );
++	QString lastCat( category( Pilot::CATEGORY_COUNT-1 ) );
+ 	return ( lastCat.isEmpty() ) ? ( cats.first() ) : ( QString::null );
+ }
+ 
+@@ -811,7 +863,7 @@ bool RecordConduit::syncEntry( PCEntry *
+ 		else if ( _equal( backupEntry, pcEntry ) )
+ 		{
+ #ifdef DEBUG
+-			DEBUGCONDUIT << "Flags: " << palmEntry->getAttrib() << ", isDeleted=" <<
++			DEBUGLIBRARY << "Flags: " << palmEntry->getAttrib() << ", isDeleted=" <<
+ 				isDeleted( palmEntry ) << ", isArchived=" << isArchived( palmEntry )
+ 				<< endl;
+ #endif
+@@ -852,14 +904,14 @@ bool RecordConduit::pcCopyToPalm( PCEntr
+ 	}
+ 	_copy( hhEntry, pcEntry );
+ #ifdef DEBUG
+-	DEBUGCONDUIT << "palmEntry->id=" << hhEntry->id() << ", pcEntry.ID=" <<
++	DEBUGLIBRARY << "palmEntry->id=" << hhEntry->id() << ", pcEntry.ID=" <<
+ 		pcEntry->uid() << endl;
+ #endif
+ 
+ 	if( palmSaveEntry( hhEntry, pcEntry ) )
+ 	{
+ #ifdef DEBUG
+-		DEBUGCONDUIT << "Entry palmEntry->id=" <<
++		DEBUGLIBRARY << "Entry palmEntry->id=" <<
+ 		hhEntry->id() << "saved to palm, now updating pcEntry->uid()=" << pcEntry->uid() << endl;
+ #endif
+ 		pcSaveEntry( pcEntry, backupEntry, hhEntry );
+@@ -899,13 +951,13 @@ bool RecordConduit::palmSaveEntry( Pilot
+ 	FUNCTIONSETUP;
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << "Saving to pilot " << palmEntry->id() << endl;
++	DEBUGLIBRARY << "Saving to pilot " << palmEntry->id() << endl;
+ #endif
+ 
+ 	PilotRecord *pilotRec = palmEntry->pack();
+ 	recordid_t pilotId = fDatabase->writeRecord(pilotRec);
+ #ifdef DEBUG
+-	DEBUGCONDUIT << "PilotRec nach writeRecord (" << pilotId <<
++	DEBUGLIBRARY << "PilotRec nach writeRecord (" << pilotId <<
+ 		": ID=" << pilotRec->id() << endl;
+ #endif
+ 	fLocalDatabase->writeRecord( pilotRec );
+@@ -956,7 +1008,7 @@ bool RecordConduit::pcSaveEntry( PCEntry
+ 	FUNCTIONSETUP;
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << "Before _savepcEntry, pcEntry->uid()=" <<
++	DEBUGLIBRARY << "Before _savepcEntry, pcEntry->uid()=" <<
+ 		pcEntry->uid() << endl;
+ #endif
+ 	if ( pcEntry->recid() != 0 )
+@@ -1007,7 +1059,7 @@ bool RecordConduit::pcDeleteEntry( PCEnt
+ 	if ( !pcEntry->isEmpty() )
+ 	{
+ #ifdef DEBUG
+-		DEBUGCONDUIT << fname << " removing " << pcEntry->uid() << endl;
++		DEBUGLIBRARY << fname << " removing " << pcEntry->uid() << endl;
+ #endif
+ 		mPCData->removeEntry( pcEntry );
+ 	}
+@@ -1046,7 +1098,7 @@ RecordConduit::PCEntry *RecordConduit::f
+ 	{
+ 		QString id( mEntryMap[palmEntry->id()] );
+ #ifdef DEBUG
+-		DEBUGCONDUIT << fname << ": PilotRecord has id " << palmEntry->id() << ", mapped to " << id << endl;
++		DEBUGLIBRARY << fname << ": PilotRecord has id " << palmEntry->id() << ", mapped to " << id << endl;
+ #endif
+ 		if( !id.isEmpty() )
+ 		{
+@@ -1054,7 +1106,7 @@ RecordConduit::PCEntry *RecordConduit::f
+ 			if ( !res && !res->isEmpty() ) return res;
+ 			KPILOT_DELETE( res );
+ #ifdef DEBUG
+-			DEBUGCONDUIT << fname << ": PilotRecord has id " << palmEntry->id() <<
++			DEBUGLIBRARY << fname << ": PilotRecord has id " << palmEntry->id() <<
+ 				", but could not be found on the PC side" << endl;
+ #endif
+ 		}
+@@ -1079,7 +1131,7 @@ RecordConduit::PCEntry *RecordConduit::f
+ 		KPILOT_DELETE( abEntry );
+ 	}
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Could not find any entry matching Palm record with id " << QString::number( palmEntry->id() ) << endl;
++	DEBUGLIBRARY << fname << ": Could not find any entry matching Palm record with id " << QString::number( palmEntry->id() ) << endl;
+ #endif
+ 	return 0;
+ }
+diff -pruN kpilot/lib/recordConduit.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/recordConduit.h
+--- kpilot/lib/recordConduit.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/recordConduit.h	2006-11-26 23:53:25.000000000 +0100
+@@ -1,5 +1,5 @@
+-#ifndef _RECORD_CONDUIT_H
+-#define _RECORD_CONDUIT_H
++#ifndef _KPILOT_RECORDCONDUIT_H
++#define _KPILOT_RECORDCONDUIT_H
+ /* record-conduit.h                           KPilot
+ **
+ ** Copyright (C) 2005 by Adriaan de Groot
+@@ -70,19 +70,20 @@ public:
+ 		// delete fTimer; // Timer is a child object
+ 	} ;
+ 
+-	/** The different directions that a pair of records (one on the PC, one
+-	* on the Pilot) can be synced. These correspond to special sync directions
+-	* and the most general "sync both ways". Values of this type are passed
+-	* to the single-record syncer functions.
+-	*/
+-	typedef enum { HHtoPC=0, PCtoHH=1, Both=2 } SyncDirection;
+-
+ 	/** Return values for the processing functions. Each should return
+ 	* NotDone if it needs to be called again (e.g. to process another record),
+ 	* Done if it is finished and something else should be done, and
+ 	* Error if the sync cannot be completed.
+ 	*/
+-	typedef enum { NotDone=0, Done=1, Error=2 } SyncProgress;
++	enum SyncProgress { NotDone=0, Done=1, Error=2 } ;
++
++	/** Returns a human-readable name for the progress indicator @p s */
++	static QString name(SyncProgress s);
++
++	/** State of the conduit's sync. This is changed by process(). */
++	enum States { Initialize, PalmToPC, PCToPalm, Cleanup } ;
++
++	static QString name(States s);
+ 
+ protected:
+ 	/** Function called at the beginning of a sync to load data from the PC.
+@@ -94,16 +95,24 @@ protected:
+ 	/** Function called repeatedly to fetch the next modified entry from the Palm and
+ 	* sync it with the PC by looking up the record, and calling the syncer for it.
+ 	*
+-	* @return true when there are no more modified records on the Palm
+-	* @see process
++	* @return Dome when there are no more modified records on the Palm
++	* @see process()
+ 	*/
+ 	virtual SyncProgress palmRecToPC() = 0;
+ 
++	/** Function called repeatedly to fetch the next modified entry from the PC and
++	* sync it with the Palm by looking up the record and calling the syncer for it.
++	*
++	* @return Done when there are no more modified records on the PC
++	* @see process()
++	*/
++	virtual SyncProgress pcRecToPalm() = 0;
++
+ 	/** Function called at the end of this conduit's sync, which should reset DB flags
+ 	* and write changed config data out to disk.
+ 	*
+-	* @return true if the cleanup succeeds.
+-	* @see process
++	* @return Done when the cleanup is complete.
++	* @see process()
+ 	*/
+ 	virtual SyncProgress cleanup() = 0;
+ 
+@@ -120,10 +129,8 @@ private:
+ 	/** Timer to signal the process() slot. Used to keep the UI responsive. */
+ 	QTimer *fTimer;
+ 
+-	/** State of the conduit's sync. This is changed by process. */
+-	enum { Initialize, PalmToPC, Cleanup } fState;
++	States fState;
+ 
+-	QMap<recordid_t,QString> fUIDMap;
+ 	RecordIDList fIDList;
+ 	RecordIDList::Iterator fIDListIterator;
+ 
+@@ -135,13 +142,12 @@ class RecordConduit : public RecordCondu
+ {
+ public:
+ 	/** Construct a record conduit on a given device link. */
+-	RecordConduit(const QString &name /**< Name presented to user */,
++	RecordConduit(
+ 		KPilotDeviceLink *o /**< Connection to HH */,
+ 		const char *n /**< Name for QObject */,
+ 		const QStringList a = QStringList() /**< Flags */) :
+ 		RecordConduitBase(o,n,a)
+ 	{
+-		fConduitName=name;
+ 	} ;
+ 	virtual ~RecordConduit()
+ 	{
+@@ -149,78 +155,23 @@ public:
+ 
+ 	virtual SyncProgress loadPC()
+ 	{
+-		fAppInfo = new HHAppInfo(fDatabase) ;
+-		fContainer = new PCContainer();
+-		if (!fContainer->load())
+-		{
+-			emit logError(i18n("Unable to load the %1 database on the PC.").arg(fConduitName));
+-			return Error;
+-		}
+-		if (fContainer->isEmpty()) setFirstSync(true); /* And leave UID map empty */
+-		else fContainer->mapToRecords(fUIDMap);
+-
+ 		return Done;
+ 	} ;
+ 
+ 	virtual SyncProgress palmRecToPC()
+ 	{
+-		if ( fIDListIterator == fIDList.end() )
+-		{
+-			return Done;
+-		}
+-
+-		recordid_t currentID = *fIDListIterator++;
+-		PilotRecord *rec = fDatabase->readRecordById(currentID);
+-		HHEntry *currentHH = 0;
+-		PCEntry *currentPC = 0;
+-		Q_ASSERT(rec);
+-		if (fUIDMap.contains(currentID))
+-		{
+-			QString currentUID = fUIDMap[currentID];
+-			// This is a modified entry or it is deleted on the HH
+-			if (rec->isDeleted())
+-			{
+-				fContainer->remove(currentUID);
+-			}
+-			else
+-			{
+-				currentHH = new HHEntry(rec);
+-				currentPC = fContainer->get(currentUID);
+-				Syncer::sync(currentPC,currentHH,fAppInfo,HHtoPC);
+-			}
+-		}
+-		else
+-		{
+-			// Deleted on HH, unknown on PC -> Ignore it.
+-			// Not deleted, unknown -> New record.
+-			if (!rec->isDeleted())
+-			{
+-				currentHH = new HHEntry(rec);
+-				currentPC = new PCEntry();
+-				Syncer::sync(currentPC,currentHH,fAppInfo,HHtoPC);
+-				fContainer->insert(currentPC);
+-			}
+-		}
+-		delete rec;
+-		delete currentHH;
+-		// delete currentPC; Ownership passed to the container
++		return Done;
++	}
+ 
+-		return NotDone;
++	virtual SyncProgress pcRecToPalm()
++	{
++		return Done;
+ 	}
+ 
+ 	virtual SyncProgress cleanup()
+ 	{
+-		delete fAppInfo;
+-		fContainer->save();
+-		delete fContainer;
+ 		return Done;
+ 	}
+-
+-	virtual bool getAppInfo( unsigned char *buffer, int appLen ) { return true; } ;
+-
+-protected:
+-	HHAppInfo *fAppInfo;
+-	PCContainer *fContainer;
+ } ;
+ 
+ 
+diff -pruN kpilot/lib/syncAction.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/syncAction.cc
+--- kpilot/lib/syncAction.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/syncAction.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -26,8 +26,6 @@
+ /*
+ ** Bug reports and questions can be sent to kde-pim at kde.org
+ */
+-static const char *syncAction_id =
+-	"$Id: syncAction.cc 449688 2005-08-16 12:55:22Z adridg $";
+ 
+ #include "options.h"
+ 
+@@ -57,17 +55,16 @@ static const char *syncAction_id =
+ #include "syncAction.moc"
+ #include "kpilotlibSettings.h"
+ 
+-SyncAction::SyncAction(KPilotDeviceLink  *p,
++SyncAction::SyncAction(KPilotLink  *p,
+ 	const char *name) :
+ 	QObject(p, name),
+ 	fHandle(p),
+ 	fParent(0L)
+ {
+ 	FUNCTIONSETUP;
+-	(void) syncAction_id;
+ }
+ 
+-SyncAction::SyncAction(KPilotDeviceLink *p,
++SyncAction::SyncAction(KPilotLink *p,
+ 	QWidget * visibleparent,
+ 	const char *name) :
+ 	QObject(p, name),
+@@ -95,14 +92,14 @@ SyncAction::~SyncAction()
+ 	FUNCTIONSETUP;
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname
++	DEBUGLIBRARY << fname
+ 		<< ": Running conduit " << name() << endl;
+ #endif
+ 
+ 	bool r = this->exec();
+ 
+ #ifdef DEBUG
+-	DEBUGCONDUIT << fname << ": Exec returned " << r << endl;
++	DEBUGLIBRARY << fname << ": Exec returned " << r << endl;
+ #endif
+ 
+ 	if (!r)
+@@ -131,20 +128,18 @@ static struct
+ } maps[] =
+ {
+ 	{ SyncAction::SyncMode::eHotSync, "--hotsync" },
+-	{ SyncAction::SyncMode::eFastSync, "--fast" },
+ 	{ SyncAction::SyncMode::eFullSync, "--full" },
+ 	{ SyncAction::SyncMode::eCopyPCToHH, "--copyPCToHH" },
+ 	{ SyncAction::SyncMode::eCopyHHToPC, "--copyHHToPC" },
+ 	{ SyncAction::SyncMode::eBackup, "--backup" },
+ 	{ SyncAction::SyncMode::eRestore, "--restore" },
+-	{ SyncAction::SyncMode::eFastSync, "--fastsync" },
+ 	{ SyncAction::SyncMode::eFullSync, "--fullsync" },
+ 	{ SyncAction::SyncMode::eHotSync, (const char *)0 }
+ }
+ ;
+ 
+ SyncAction::SyncMode::SyncMode(const QStringList &args) :
+-	fMode(eFastSync),
++	fMode(eHotSync),
+ 	fTest(args.contains("--test")),
+ 	fLocal(args.contains("--local"))
+ {
+@@ -162,7 +157,7 @@ SyncAction::SyncMode::SyncMode(const QSt
+ 	if (!maps[i].name)
+ 	{
+ 		kdError() << k_funcinfo << "No mode set by arguments "
+-			<< args << ", defaulting to FastSync." << endl;
++			<< args << ", defaulting to HotSync." << endl;
+ 	}
+ }
+ 
+@@ -171,11 +166,11 @@ SyncAction::SyncMode::SyncMode(Mode m, b
+ 	fTest(test),
+ 	fLocal(local)
+ {
+-	if ( ((int)m<(int)eFastSync) || ((int)m>(int)eRestore) )
++	if ( ((int)m<(int)eHotSync) || ((int)m>(int)eRestore) )
+ 	{
+ 		kdError() << k_funcinfo << "Mode value " << (int)m << " is illegal"
+-			", defaulting to FastSync." << endl;
+-		fMode = eFastSync;
++			", defaulting to HotSync." << endl;
++		fMode = eHotSync;
+ 	}
+ }
+ 
+@@ -210,7 +205,6 @@ QStringList SyncAction::SyncMode::list()
+ {
+ 	switch(e)
+ 	{
+-	case eFastSync : return i18n("FastSync");
+ 	case eHotSync : return i18n("HotSync");
+ 	case eFullSync : return i18n("Full Synchronization");
+ 	case eCopyPCToHH : return i18n("Copy PC to Handheld");
+diff -pruN kpilot/lib/syncAction.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/syncAction.h
+--- kpilot/lib/syncAction.h	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/syncAction.h	2006-11-19 22:21:12.000000000 +0100
+@@ -49,9 +49,9 @@ class KDE_EXPORT SyncAction : public QOb
+ Q_OBJECT
+ 
+ public:
+-	SyncAction(KPilotDeviceLink *p,
++	SyncAction(KPilotLink *p,
+ 		const char *name=0L);
+-	SyncAction(KPilotDeviceLink *p,
++	SyncAction(KPilotLink *p,
+ 		QWidget *visibleparent,
+ 		const char *name=0L);
+ 	~SyncAction();
+@@ -113,11 +113,11 @@ public:
+ 	void addLogProgress( const QString &msg, int prog ) { emit logProgress( msg, prog ); }
+ protected:
+ 	/** Connection to the device. @todo make private. */
+-	KPilotDeviceLink *fHandle;
++	KPilotLink *fHandle;
+ 	int fActionStatus;
+ 
+ 	/** Returns a pointer to the connection to the device. */
+-	inline KPilotDeviceLink *deviceLink() const { return fHandle; } ;
++	inline KPilotLink *deviceLink() const { return fHandle; }
+ 
+ 	/** Returns the file descriptor for the device link -- that is,
+ 	* the raw handle to the OS's connection to the device. Use with care.
+@@ -146,13 +146,12 @@ public:
+ 	public:
+ 		/** Available modes for the sync. */
+ 		enum Mode {
+-		eFastSync=1,
+-		eHotSync=2,
+-		eFullSync=3,
+-		eCopyPCToHH=4,
+-		eCopyHHToPC=5,
+-		eBackup=6,
+-		eRestore=7
++		eHotSync=1,
++		eFullSync=2,
++		eCopyPCToHH=3,
++		eCopyHHToPC=4,
++		eBackup=5,
++		eRestore=6
+ 		} ;
+ 
+ 		/** Create a mode with the given Mode @p m and
+@@ -177,7 +176,7 @@ public:
+ 
+ 		/** Sets a mode from an integer @p mode, if possible.
+ 		* If the @p mode is illegal, return false and set the
+-		* mode to Fast Sync. As a side effect, options test and local
++		* mode to Hot Sync. As a side effect, options test and local
+ 		* are reset to false.
+ 		*/
+ 		bool setMode(int);
+@@ -227,8 +226,7 @@ public:
+ 		bool isSync() const
+ 		{
+ 			return ( fMode==eFullSync ) ||
+-				( fMode == eHotSync ) ||
+-				( fMode == eFastSync );
++				( fMode == eHotSync ); 
+ 		} ;
+ 
+ 		/** Classify every mode as either a sync (two-way) or copy (one-way) mode. */
+@@ -277,6 +275,17 @@ public:
+ 		eCROffset=-1
+ 	};
+ 
++	/**
++	 * This MUST stay in sync with the combobox in
++	 * kpilotConfigDialog_backup.ui.  If it does not, you need to
++	 * either change this enum or the combobox.
++	 */
++	enum BackupFrequency
++	{
++		eEveryHotSync=0,
++		eOnRequestOnly
++	};
++
+ protected:
+ 	/**
+ 	* Call startTickle() some time before showing a dialog to the
+diff -pruN kpilot/lib/testactions.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/testactions.cc
+--- kpilot/lib/testactions.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/testactions.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,92 +0,0 @@
+-/* testactions			KPilot
+-**
+-** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org)
+-**
+-** Test the functions related to sync actions.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "options.h"
+-#include "syncAction.h"
+-
+-bool run_modes(bool test, bool local)
+-{
+-	bool ok = true;
+-
+-	kdDebug() << "***\n*** Sync Modes ("
+-		<< ( test ? "" : "no")
+-		<< "test, "
+-		<< ( local ? "" : "no")
+-		<< "local)\n***\n";
+-
+-
+-	for (int m = (int)SyncAction::SyncMode::eFastSync;
+-		m <= (int) SyncAction::SyncMode::eRestore ;
+-		m++)
+-	{
+-		SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
+-		kdDebug() << "* " << mode.name() << endl;
+-		SyncAction::SyncMode mode2(mode.list());
+-		if (!(mode==mode2)) {
+-			kdDebug() << "E " << "Modes mismatch [" << mode.name() << "] ["
+-				<< mode2.name() << "]" << endl;
+-			ok = false;
+-		}
+-	}
+-
+-	return ok;
+-}
+-
+-bool single_mode(int m, bool test, bool local)
+-{
+-	SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
+-
+-	kdDebug() << "* " << m << " " << test << " " << local << endl;
+-
+-	if ((mode.mode() == m) && (mode.isTest() == test) && (mode.isLocal() == local))
+-	{
+-		return true;
+-	}
+-	else
+-	{
+-		kdDebug() << "E " << "Modes mismatch " << m << " " << test << " " << local
+-			<< "[" << mode.name() << "]" << endl;
+-		return false;
+-	}
+-}
+-
+-int main(int argc, char **argv)
+-{
+-	if (!run_modes(false,false)) return 1;
+-	if (!run_modes(false,true)) return 1;
+-	if (!run_modes(true,false)) return 1;
+-	if (!run_modes(true,true)) return 1;
+-
+-	kdDebug() << "***\n*** Sync Modes - misc\n***\n";
+-	if (!single_mode(3,false,false)) return 1;
+-	if (!single_mode(1,true,true)) return 1;
+-
+-	return 0;
+-}
+-
+-
+diff -pruN kpilot/lib/testconstants.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/testconstants.cc
+--- kpilot/lib/testconstants.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/testconstants.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,54 +0,0 @@
+-/* testconstants KPilot
+-**
+-** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org)
+-**
+-** Checks that various data structures are sized properly.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "options.h"
+-
+-#define private public
+-#define protected public
+-
+-#include "pilotDatabase.h"
+-
+-#include <pi-appinfo.h>
+-
+-int main(int argc, char **argv)
+-{
+-	PilotAppInfoBase info;
+-
+-	kdDebug() << "*** Sizes of structures" << endl;
+-	kdDebug() << "AppInfoBase: " << sizeof(PilotAppInfoBase) << endl;
+-	kdDebug() << "CategoryInfo: " << sizeof(info.categoryInfo()) << endl;
+-	kdDebug() << "CategoryInfo: " << sizeof(*info.categoryInfo()) << endl;
+-	kdDebug() << "Category names: " << sizeof(info.categoryInfo()->name) << endl;
+-	kdDebug() << "Single category: " << sizeof(info.categoryInfo()->name[0]) << endl;
+-
+-	if ( sizeof(info.categoryInfo()->name[0]) != 16 ) return 1;
+-	if ( sizeof(info.categoryInfo()->name) / sizeof(info.categoryInfo()->name[0]) != 16 ) return 1;
+-	return 0;
+-}
+-
+-
+diff -pruN kpilot/lib/testdatabase.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/testdatabase.cc
+--- kpilot/lib/testdatabase.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/testdatabase.cc	1970-01-01 01:00:00.000000000 +0100
+@@ -1,315 +0,0 @@
+-/* testdatabase			KPilot
+-**
+-** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org)
+-**
+-** Test the functions related to local databases.
+-*/
+-
+-/*
+-** This program 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.
+-**
+-** This program 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 in a file called COPYING; if not, write to
+-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+-** MA 02110-1301, USA.
+-*/
+-
+-/*
+-** Bug reports and questions can be sent to kde-pim at kde.org
+-*/
+-
+-#include "options.h"
+-
+-#include <kaboutdata.h>
+-#include <kapplication.h>
+-#include <kdebug.h>
+-#include <klocale.h>
+-#include <kcmdlineargs.h>
+-
+-#include "pilotLocalDatabase.h"
+-#include "pilotRecord.h"
+-#include "pilotMemo.h"
+-
+-
+-/* Return values for the various check* functions. They
+-   return OK if all is OK; ERR is for generic errors.
+-   ERR_NO_EXIST is returned if something (usually a database
+-   or other file) doesn't exist that should. The latter
+-   error might be ignored.
+-*/
+-#define OK           (0)
+-#define ERR          (1)
+-#define ERR_NO_EXIST (2)
+-
+-
+-/* Data about the records in a database. The id field is
+-   interpreted specially for the first and last entries.
+-*/
+-typedef struct { int id,size; } recordInfo;
+-
+-/* Use END in the last recordInfo struct describing a database
+-   to indicate you expect the database to end there. Use NO_EXIST
+-   as the ID in the first struct to indicate that the database
+-   is expected _not_ to exist.
+-*/
+-#define NO_EXIST   (-2)
+-#define END        (-1)
+-
+-/* These tables of data are taken from various databases I have
+-   (but which I cannot commit to SVN due to license issues).
+-   The aesop listing is from an eBook of Aesop's fables.
+-   The way to create these tables is to use a third-party
+-   tool such as par to read the database:
+-
+-   ./par l /tmp/Aesop.pdb | awk '{print "{",$3,",",$4,"},";}'
+-
+-*/
+-recordInfo nonexistent[] = {
+-	{ NO_EXIST, 0 }
+-} ;
+-
+-recordInfo aesop[] = {
+-{ 7307264 , 214 },
+-{ 7307265 , 1564 },
+-{ 7307266 , 1575 },
+-{ 7307267 , 2214 },
+-{ 7307268 , 2276 },
+-{ 7307269 , 2148 },
+-{ 7307270 , 2194 },
+-{ 7307271 , 2178 },
+-{ 7307272 , 2220 },
+-{ 7307273 , 2216 },
+-{ 7307274 , 2181 },
+-{ 7307275 , 2183 },
+-{ 7307276 , 2197 },
+-{ 7307277 , 2010 },
+-{ 7307278 , 2198 },
+-{ 7307279 , 2196 },
+-{ 7307280 , 2243 },
+-{ 7307281 , 2211 },
+-{ 7307282 , 2274 },
+-{ 7307283 , 364 },
+-{ 7307284 , 49124 },
+-	{ END, 0 }
+-} ;
+-
+-int checkDatabase(const char *path, recordInfo *info)
+-{
+-	FUNCTIONSETUP;
+-
+-	PilotLocalDatabase db(QString::fromLatin1(path));
+-	if (!db.isDBOpen())
+-	{
+-		kdDebug() << "No database " << path << endl;
+-		if ( info[0].id == NO_EXIST )
+-		{
+-			kdDebug() << "This was expected" << endl;
+-			return OK;
+-		}
+-		else
+-		{
+-			return ERR_NO_EXIST;
+-		}
+-	}
+-
+-	if ( info[0].id == NO_EXIST )
+-	{
+-		kdDebug() << "Database not expected" << endl;
+-		return ERR;
+-	}
+-
+-	int fail = 0;
+-	int index = 0;
+-	PilotRecord *r;
+-	while( (r = db.readRecordByIndex(index) ) )
+-	{
+-		kdDebug() << "[" << index << "] id=" << r->id() << " size=" << r->size() << endl;
+-		if ( ((recordid_t)info[index].id) != r->id() )
+-		{
+-			kdDebug() << "* Bad ID (expected" << r->id() << ")" << endl;
+-			fail++;
+-		}
+-		else if ( info[index].size != r->size() )
+-		{
+-			kdDebug() << "* Bad size (expected " << info[index].size << ")" << endl;
+-			fail++;
+-		}
+-		index++;
+-	}
+-	if ( info[index].id != END )
+-	{
+-		kdDebug() << "* End wasn't expected yet." << endl;
+-		r++;
+-	}
+-
+-	if (fail)
+-	{
+-		kdDebug() << "* " << fail << " failures." << endl;
+-		return ERR;
+-	}
+-	return OK;
+-}
+-
+-const char *categoryNames[4] =
+-{
+-	"aardvarks",
+-	"toolongToBeaCategoryName",
+-	"personal",
+-	"impersonal"
+-} ;
+-
+-QStringList listCategories()
+-{
+-	QStringList cats;
+-	PilotLocalDatabase *l = new PilotLocalDatabase(SOURCE "/data/MemoDB");
+-	PilotMemoInfo *m = new PilotMemoInfo(l);
+-
+-	if (!l->isDBOpen()) return cats;
+-
+-	cats.append(CSL1("Unfiled"));
+-	m->dump();
+-
+-	for (int i=0; i<20; i++)
+-	{
+-		PilotRecord *r = l->readRecordByIndex(i);
+-		kdDebug() << "Read record " << (void *)r << " with id=" << r->id() << endl;
+-		if (!r) break;
+-	}
+-
+-	for (int i=0; i<4; i++)
+-	{
+-		QString s = m->category(i);
+-		kdDebug() << "Category " << i << ": " << (s.isEmpty() ? CSL1("<empty>") : s) << endl;
+-		cats.append(s);
+-/*
+-		if (i<((sizeof(categoryNames) / sizeof(categoryNames[0]))))
+-			m->setCategoryName(i,QString::fromLatin1(categoryNames[i]));
+-*/
+-	}
+-
+-	m->write(l);
+-
+-	delete m;
+-	delete l;
+-
+-	return cats;
+-}
+-
+-int checkCategories()
+-{
+-	QStringList l = listCategories();
+-	QStringList m = listCategories();
+-
+-	if (l.isEmpty() || m.isEmpty()) return ERR;
+-	if (l!=m) return ERR;
+-	return OK;
+-}
+-
+-int checkMemo()
+-{
+-	PilotLocalDatabase *l = new PilotLocalDatabase(SOURCE "/data/MemoDB");
+-	if (!l->isDBOpen()) return ERR_NO_EXIST;
+-
+-	PilotMemoInfo *m = new PilotMemoInfo(l);
+-	m->dump();
+-
+-	QString c = m->category(1);
+-	if (c != CSL1("Business"))
+-	{
+-		kdDebug() << "* Category 1 is not 'Business' but " << c << endl;
+-		return ERR;
+-	}
+-
+-	m->setCategoryName(2,CSL1("Aardvark"));
+-	m->write(l);
+-
+-	c = m->category(2);
+-	if (c != CSL1("Aardvark"))
+-	{
+-		kdDebug() << "* Category 2 is not 'Aardvark' but " << c << endl;
+-		return ERR;
+-	}
+-
+-
+-	delete m;
+-	delete l;
+-	return OK;
+-}
+-
+-static const KCmdLineOptions options[] =
+-{
+-  {"verbose", "Verbose output", 0},
+-  KCmdLineLastOption
+-};
+-
+-
+-int main(int argc, char **argv)
+-{
+-	KAboutData aboutData("testdatabase","Test Databases","0.1");
+-	KCmdLineArgs::init(argc,argv,&aboutData);
+-	KCmdLineArgs::addCmdLineOptions( options );
+-
+-	//  KApplication app( false, false );
+-	KApplication app;
+-
+-	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+-
+-	Q_UNUSED(args)
+-
+-	int r = 0;
+-	int i = 0;
+-#ifdef DEBUG
+-	debug_level=4;
+-#endif
+-
+-	Q_UNUSED(argc);
+-	Q_UNUSED(argv);
+-
+-#define ALLOW_NO_EXIST (1)
+-	static struct { const char *path; recordInfo *info; int flags; } 
+-		tests[] =
+-	{
+-		{ "/tmp/nonexistant/nonexistent", nonexistent,0 },
+-		{ "/tmp/Aesop", aesop, ALLOW_NO_EXIST },
+-		{ 0L, 0L, 0 }
+-	} ;
+-
+-	while ( tests[i].path )
+-	{
+-		kdDebug() << "*** Test " << i << endl;
+-		int ret = checkDatabase( tests[i].path, tests[i].info );
+-		if ( ret )
+-		{
+-			if ( (ret==ERR_NO_EXIST) && 
+-				(tests[i].flags & ALLOW_NO_EXIST) )
+-			{
+-				kdDebug() << "* Test database doesn't exist, ignored." << endl;
+-			}
+-			else
+-			{
+-				r++;
+-			}
+-		}
+-		i++;
+-	}
+-
+-	kdDebug() << "*** Test " << i << endl;
+-	if (checkMemo()) r++;
+-	i++;
+-
+-	if (r)
+-	{
+-		kdDebug() << "***\n*** Failed " << r << " tests." << endl;
+-		return 1;
+-	}
+-	return 0;
+-}
+-
+diff -pruN kpilot/lib/uiDialog.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/lib/uiDialog.cc
+--- kpilot/lib/uiDialog.cc	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/lib/uiDialog.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -63,13 +63,6 @@
+ 	grid->addColSpacing(4, SPACING);
+ 
+ 
+-#ifdef DEBUG
+-	DEBUGKPILOT << fname
+-		<< ": Looking for icon for "
+-		<< p->appName()
+-		<< endl;
+-#endif
+-
+ 	QPixmap applicationIcon =
+ 		l->loadIcon(QString::fromLatin1(p->appName()),
+ 		KIcon::Desktop,
+@@ -78,12 +71,6 @@
+ 
+ 	if (applicationIcon.isNull())
+ 	{
+-#ifdef DEBUG
+-		DEBUGKPILOT << fname
+-			<< ": Looking for icon for "
+-			<< "kpilot"
+-			<< endl;
+-#endif
+ 		applicationIcon = l->loadIcon(QString::fromLatin1("kpilot"),
+ 			KIcon::Desktop);
+ 	}
+@@ -94,14 +81,7 @@
+ 	//
+ 	text->setText(i18n("Send questions and comments to kdepim-users at kde.org"));
+ 	text->adjustSize();
+-#ifdef DEBUG
+-	DEBUGKPILOT << fname
+-		<< ": Text size "
+-		<< text->size().width()
+-		<< ","
+-		<< text->size().height()
+-		<< endl;
+-#endif
++
+ 	int linewidth = text->size().width();
+ 	int lineheight = text->size().height();
+ 
+@@ -113,16 +93,16 @@
+ 
+ 
+ 	KActiveLabel *linktext = new KActiveLabel(w);
+-	grid->addRowSpacing(1,QMAX(100,6*lineheight));
+-	grid->addRowSpacing(2,QMAX(100,6*lineheight));
++	grid->addRowSpacing(1,kMax(100,6*lineheight));
++	grid->addRowSpacing(2,kMax(100,6*lineheight));
+ 	grid->addColSpacing(2,SPACING+linewidth/2);
+ 	grid->addColSpacing(3,SPACING+linewidth/2);
+ 	grid->setRowStretch(1,50);
+ 	grid->setRowStretch(2,50);
+ 	grid->setColStretch(2,50);
+ 	grid->setColStretch(3,50);
+-	linktext->setMinimumSize(linewidth,QMAX(260,60+12*lineheight));
+-	linktext->setFixedHeight(QMAX(260,60+12*lineheight));
++	linktext->setMinimumSize(linewidth,kMax(260,60+12*lineheight));
++	linktext->setFixedHeight(kMax(260,60+12*lineheight));
+ 	linktext->setVScrollBarMode(QScrollView::Auto/*AlwaysOn*/);
+ 	text = new QLabel(w);
+ 	grid->addMultiCellWidget(text,0,0,2,3);
+@@ -203,24 +183,7 @@
+ 	linktext->append(s);
+ 	linktext->ensureVisible(0,0);
+ 
+-#ifdef DEBUG
+-	DEBUGKPILOT << fname
+-		<< ": Size "
+-		<< w->size().width()
+-		<< ","
+-		<< w->size().height()
+-		<< endl;
+-#endif
+-
+ 	w->adjustSize();
+-#ifdef DEBUG
+-	DEBUGKPILOT << fname
+-		<< ": Adjusted size "
+-		<< w->size().width()
+-		<< ","
+-		<< w->size().height()
+-		<< endl;
+-#endif
+ 
+ 	return w;
+ }
+@@ -245,15 +208,6 @@
+ 		sz.setHeight(tw->size().height());
+ 	}
+ 
+-#ifdef DEBUG
+-	DEBUGKPILOT << fname
+-		<< ": Final size "
+-		<< sz.width()
+-		<< ","
+-		<< sz.height()
+-		<< endl;
+-#endif
+-
+ 	tw->resize(sz);
+ 	tw->addTab(w, i18n("About"));
+ 	tw->adjustSize();
+diff -pruN kpilot/Makefile.cmake /home/pusling/kpilot/kdepim-3.5.5+/kpilot/Makefile.cmake
+--- kpilot/Makefile.cmake	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/Makefile.cmake	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,68 @@
++# This is a GNU makefile. You need GNU make to process it.
++# FreeBSD users should use gmake.
++#
++#
++
++# Unusual configuration things:
++#   CMAKE = path to cmake
++#   BUILD_DIR = directory to build things in
++#   CMAKE_FLAGS = extra flags to CMake.  These will get set by
++#      ./configure, saved to CMakeOptions.txt, and read in below...
++#
++
++-include CMakeOptions.txt
++
++BUILD_DIR ?= build-$(shell uname -sr | tr -d [:space:] | tr -Cs a-zA-Z0-9 _ )
++# these come from CMakeOptions.txt (from ./configure)
++CMAKE_FLAGS ?=
++CMAKE ?= cmake
++
++all: app conduit
++
++check: lib
++	@echo "Make check is currently disabled"
++
++check-clean:
++	@echo "Make check is currently disabled"
++
++install: app-install conduit-install
++
++uninstall: app-uninstall conduit-uninstall
++
++lib: $(BUILD_DIR)/lib/libkpilot.so
++
++$(BUILD_DIR)/lib/libkpilot.so: build-check
++	cd "$(BUILD_DIR)/lib" && $(MAKE)
++
++app: build-check
++	cd "$(BUILD_DIR)" && $(MAKE)
++
++conduit: build-check
++	cd "$(BUILD_DIR)/conduits" && $(MAKE)
++
++app-install: app
++	cd "$(BUILD_DIR)" && $(MAKE) install
++
++conduit-install: conduit
++	cd "$(BUILD_DIR)/conduits" && $(MAKE) install
++
++app-uninstall:
++	cd "$(BUILD_DIR)" && $(MAKE) uninstall
++
++conduit-uninstall:
++	cd "$(BUILD_DIR)/conduits" && $(MAKE) uninstall
++
++build-check:
++	test -d "$(BUILD_DIR)" || mkdir -p "$(BUILD_DIR)"
++	test -d "$(BUILD_DIR)"
++	SRC_DIR=`pwd` ; cd "$(BUILD_DIR)" && $(CMAKE) $$SRC_DIR $(CMAKE_FLAGS)
++
++clean:
++	@rm -rf $(BUILD_DIR)
++
++help:
++	@echo "Usage: make ( all | install | uninstall | clean )"
++	@echo ""
++
++.PHONY : all install uninstall lib app conduit app-install conduit-install app-uninstall conduit-uninstall clean help 
++
+diff -pruN kpilot/NEWS /home/pusling/kpilot/kdepim-3.5.5+/kpilot/NEWS
+--- kpilot/NEWS	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/NEWS	2006-11-26 23:53:25.000000000 +0100
+@@ -3,6 +3,8 @@ For more detailed information and musing
+ ChangeLog or the README files. There is also the
+ history page on www.kpilot.org.
+ 
++* November 18, 2006: KDE 3.5.5 is getting KPilot backported
++  to it, and KPilot itself now uses CMake as its buildsystem.
+ * November 4, 2004: KDE 3.3.1 contains KPilot 4.4.5; there is
+   a 4.4.6 available from the website, but it is of dubious
+   quality.
+diff -pruN kpilot/README /home/pusling/kpilot/kdepim-3.5.5+/kpilot/README
+--- kpilot/README	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/README	2006-11-26 23:53:25.000000000 +0100
+@@ -1,36 +1,20 @@
+-KPILOT 4.5.0 by Dan Pilone / Adriaan de Groot
++KPILOT 4.6.0 by Adriaan de Groot
+ =============================================
+ 	Additional work by Robert Ambrose,
+ 	Preston Brown, Adriaan de Groot,
+ 	Heiko Purnhagen, Joerg Habenicht,
+ 	David Bishop, Aaron Seigo,
+-	Reinhold Kainhofer, Joern Ahrens
++	Reinhold Kainhofer, Joern Ahrens,
++	Jason Kasper,
+ 	and probably many more.
+ 
+-	KPilot is software for syncing PalmOne handhelds, the 3Com Palm Pilot 
+-and IBM Workpad (UNTESTED!) with a machine running some flavor of unix.  By 
+-default KPilot attempts to connnect using /dev/pilot which should be a link 
+-to the actual serial port, however this is configurable in the settings dialog.
+-Modern USB-based devices should be accessed by configuring the USB HotPlug 
+-manager for your OS to link /dev/pilot to the correct USB device node.
+-
+-	Release notes can be found in Documentation/README-4.*. These are
+-official announcements of KPilot 4.x releases. There is also a README for
+-3.2.1 which is probably not interesting any more.
++	KPilot is software for syncing PalmOS based handhelds
++such as the 3Com Palm Pilot with a machine running some flavor of UNIX.  
+ 
+ 	Developer's notes are listed in the file ChangeLog. This is
+ probably only of interest if you want to see how certain features developed
+ or if certain bugs have been reported before.
+ 
+-	Generic installation instructions can be found in the file
+-INSTALL, but note that KPilot is part of the kdepim package and you
+-have to configure that package, not KPilot. KPilot does compile and
+-install on its own though, once kdepim is configured. Tarballs are
+-available from www.kpilot.org for standalone compilation.
+-
+-	You NEED pilot-link to compile or install KPilot; KPilot is
+-currently tested using version 0.11.8 of pilot-link.
+-
+ 	http://www.kpilot.org/
+ 
+ 
+@@ -55,4 +39,5 @@ contributions are welcome.  :)  Send mai
+ 
+ 	Adriaan de Groot
+ 	groot at kde.org
+-	April 23, 2005
++	November 18, 2006
++
+diff -pruN kpilot/tests/conduits/vcalconduit/exampletest.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/tests/conduits/vcalconduit/exampletest.cc
+--- kpilot/tests/conduits/vcalconduit/exampletest.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/tests/conduits/vcalconduit/exampletest.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,26 @@
++#include "options.h"
++#include "config.h"
++
++#include "exampletest.h"
++
++CPPUNIT_TEST_SUITE_REGISTRATION( VCalConduitTest );
++
++
++void VCalConduitTest::setUp()
++{
++	device = QString("testdevice");
++	link = new KPilotLocalLink(0, "localLink");
++	syncMode = SyncAction::SyncMode::eHotSync;
++}
++
++
++void VCalConduitTest::tearDown()
++{
++	delete link;
++}
++
++
++void VCalConduitTest::testConstructor()
++{
++	CPPUNIT_ASSERT( true == true );
++}
+diff -pruN kpilot/tests/conduits/vcalconduit/exampletest.h /home/pusling/kpilot/kdepim-3.5.5+/kpilot/tests/conduits/vcalconduit/exampletest.h
+--- kpilot/tests/conduits/vcalconduit/exampletest.h	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/tests/conduits/vcalconduit/exampletest.h	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,28 @@
++#ifndef EXAMPLETEST_H
++#define EXAMPLETEST_H
++
++#include <cppunit/extensions/HelperMacros.h>
++#include <qstring.h>
++
++#include "kpilotlocallink.h"
++#include "syncAction.h"
++
++class VCalConduitTest : public CppUnit::TestFixture
++{
++  CPPUNIT_TEST_SUITE( VCalConduitTest );
++  CPPUNIT_TEST( testConstructor );
++  CPPUNIT_TEST_SUITE_END();
++
++private:
++	QString device;
++	KPilotLocalLink *link;
++	SyncAction::SyncMode::Mode syncMode;
++
++public:
++  void setUp();
++  void tearDown();
++
++  void testConstructor();
++};
++
++#endif
+diff -pruN kpilot/tests/main.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/tests/main.cc
+--- kpilot/tests/main.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/tests/main.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,17 @@
++#include <cppunit/extensions/TestFactoryRegistry.h>
++#include <cppunit/ui/text/TestRunner.h>
++
++int main( int argc, char **argv)
++{
++	CppUnit::TestFactoryRegistry &registry =
++		CppUnit::TestFactoryRegistry::getRegistry();
++
++	CppUnit::TextUi::TestRunner runner;
++	runner.addTest( registry.makeTest() );
++
++	// Run the tests.
++	bool wasSucessful = runner.run();
++
++	// Return error code 1 if the one of test failed.
++	return wasSucessful ? 0 : 1;
++}
+diff -pruN kpilot/tests/testactions.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/tests/testactions.cc
+--- kpilot/tests/testactions.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/tests/testactions.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,92 @@
++/* testactions			KPilot
++**
++** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org)
++**
++** Test the functions related to sync actions.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "options.h"
++#include "syncAction.h"
++
++bool run_modes(bool test, bool local)
++{
++	bool ok = true;
++
++	kdDebug() << "***\n*** Sync Modes ("
++		<< ( test ? "" : "no")
++		<< "test, "
++		<< ( local ? "" : "no")
++		<< "local)\n***\n";
++
++
++	for (int m = (int)SyncAction::SyncMode::eHotSync;
++		m <= (int) SyncAction::SyncMode::eRestore ;
++		m++)
++	{
++		SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
++		kdDebug() << "* " << mode.name() << endl;
++		SyncAction::SyncMode mode2(mode.list());
++		if (!(mode==mode2)) {
++			kdDebug() << "E " << "Modes mismatch [" << mode.name() << "] ["
++				<< mode2.name() << "]" << endl;
++			ok = false;
++		}
++	}
++
++	return ok;
++}
++
++bool single_mode(int m, bool test, bool local)
++{
++	SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
++
++	kdDebug() << "* " << m << " " << test << " " << local << endl;
++
++	if ((mode.mode() == m) && (mode.isTest() == test) && (mode.isLocal() == local))
++	{
++		return true;
++	}
++	else
++	{
++		kdDebug() << "E " << "Modes mismatch " << m << " " << test << " " << local
++			<< "[" << mode.name() << "]" << endl;
++		return false;
++	}
++}
++
++int main(int argc, char **argv)
++{
++	if (!run_modes(false,false)) return 1;
++	if (!run_modes(false,true)) return 1;
++	if (!run_modes(true,false)) return 1;
++	if (!run_modes(true,true)) return 1;
++
++	kdDebug() << "***\n*** Sync Modes - misc\n***\n";
++	if (!single_mode(3,false,false)) return 1;
++	if (!single_mode(1,true,true)) return 1;
++
++	return 0;
++}
++
++
+diff -pruN kpilot/tests/testcategories.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/tests/testcategories.cc
+--- kpilot/tests/testcategories.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/tests/testcategories.cc	2006-11-26 23:53:25.000000000 +0100
+@@ -0,0 +1,196 @@
++/* testcategories			KPilot
++**
++** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org)
++**
++** Test the functions related to category handling.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "options.h"
++
++#include <kaboutdata.h>
++#include <kapplication.h>
++#include <kdebug.h>
++#include <klocale.h>
++#include <kcmdlineargs.h>
++
++#include "pilotLocalDatabase.h"
++#include "pilotRecord.h"
++
++
++// Name of a bogus broken DB
++#define BOGUS_NAME "./data/bogus"
++
++// Name of an actual DB
++#define MEMO_NAME "./data/MemoDB"
++
++QStringList listCategories( const char *dbname )
++{
++	QStringList cats;
++	PilotLocalDatabase *database = new PilotLocalDatabase( dbname );
++	if (!database->isOpen()) return cats;
++
++	PilotAppInfoBase *appinfo = new PilotAppInfoBase( database );
++	appinfo->dump();
++
++	for (unsigned int i=0; i<Pilot::CATEGORY_COUNT; i++)
++	{
++		QString s = appinfo->category(i);
++		cats.append(s);
++	}
++
++	delete appinfo;
++	delete database;
++
++	return cats;
++}
++
++void badAppInfoCreation()
++{
++	FUNCTIONSETUP;
++	PilotAppInfoBase *appinfo = new PilotAppInfoBase( 0L );
++	appinfo->dump();
++	KPILOT_DELETE( appinfo ) ;
++
++	PilotLocalDatabase *database = new PilotLocalDatabase( BOGUS_NAME );
++	appinfo = new PilotAppInfoBase( database );
++	appinfo->dump();
++	KPILOT_DELETE( appinfo );
++}
++
++void categoryNames()
++{
++	FUNCTIONSETUP;
++
++	PilotLocalDatabase *database = new PilotLocalDatabase( MEMO_NAME );
++	if (!database->isOpen())
++	{
++		return;
++	}
++
++	PilotAppInfoBase *appinfo = new PilotAppInfoBase( database );
++	appinfo->dump();
++
++	if (!appinfo->categoryInfo())
++	{
++		kdDebug() << "! Could not read required database" << endl;
++		return;
++	}
++
++	const char *funnyname = "AardvarkWhaleMooseExplosion";
++	const int funnyname_length = strlen(funnyname);
++
++	if (funnyname_length < 20)
++	{
++		kdDebug() << "! String of example category names is too short." << endl;
++		return;
++	}
++
++	for (unsigned int i=0; i<Pilot::CATEGORY_COUNT+2; i++)
++	{
++		QString name = QString::fromLatin1(funnyname+funnyname_length-i-3);
++		if (!appinfo->setCategoryName(i,name))
++		{
++			kdDebug() << "! Failed to set category " << i << " name to <" << name << ">" << endl;
++		}
++		else
++		{
++			QString categoryname = appinfo->category(i);
++			if (categoryname != name)
++			{
++				kdDebug() << "! Category name " << i
++					<< " set to <" << name
++					<< "> and returns <"
++					<< categoryname << ">" << endl;
++			}
++		}
++	}
++
++	appinfo->dump();
++}
++
++static const KCmdLineOptions options[] =
++{
++	{"verbose", "Verbose output", 0},
++	KCmdLineLastOption
++};
++
++
++int main(int argc, char **argv)
++{
++	KAboutData aboutData("","Test Databases","0.1");
++	KCmdLineArgs::init(argc,argv,&aboutData);
++	KCmdLineArgs::addCmdLineOptions( options );
++
++	//  KApplication app( false, false );
++	KApplication app;
++
++	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
++
++	Q_UNUSED(args)
++
++	int r = 0;
++	int i = 0;
++#ifdef DEBUG
++	debug_level= (args->isSet("verbose")) ? 4 : 0;
++#endif
++
++	Q_UNUSED(argc);
++	Q_UNUSED(argv);
++
++	static const char *files[] = {
++		MEMO_NAME,
++		"./data/AddressDB",
++		"./data/MailDB",
++		"./data/ToDoDB",
++		0L
++	};
++
++	kdDebug() << "# Listing categories from database files.\n#" << endl;
++
++	// Include arbitrary break-off point, in case 
++	for (unsigned int i = 0; i<sizeof(files)/sizeof(const char *) ; i++)
++	{
++		if (!files[i])
++		{
++			break;
++		}
++		kdDebug() << "# Categories (" << files[i] << "): "
++			<< listCategories( files[i] ) << endl;
++	}
++	// Should bail, not crash
++	kdDebug() << "# Categories (nonexistent): "
++		<< listCategories( "nonexistent" ) << endl;
++	kdDebug() << "# Categories (bogus): "
++		<< listCategories( BOGUS_NAME ) << endl;
++
++	kdDebug() << "\n# Trying to pass broken pointers to category functions.\n#" << endl;
++	badAppInfoCreation();
++
++	kdDebug() << "\n# Checking category names.\n#" << endl;
++	categoryNames();
++
++	kdDebug() << "\n# OK.\n" << endl;
++	return 0;
++}
++
+diff -pruN kpilot/tests/testconstants.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/tests/testconstants.cc
+--- kpilot/tests/testconstants.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/tests/testconstants.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,67 @@
++/* testconstants KPilot
++**
++** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org)
++**
++** Checks that various data structures are sized properly.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "options.h"
++
++#include "pilot.h"
++
++#include <pi-appinfo.h>
++
++int main(int argc, char **argv)
++{
++#ifdef DEBUG
++	debug_level = 1;
++#endif
++	PilotDatabaseInfo info( 0L );
++
++
++	kdDebug() << "### testconstants\n#" << endl;
++	kdDebug() << "# Sizes of structures\n#" << endl;
++	kdDebug() << "#     AppInfoBase: " << sizeof(PilotDatabaseInfo) << endl;
++	kdDebug() << "#    CategoryInfo: " << sizeof(info.categoryInfo()) << endl;
++	kdDebug() << "#    CategoryInfo: " << sizeof(*info.categoryInfo()) << endl;
++	kdDebug() << "#  Category names: " << sizeof(info.categoryInfo()->name) << endl;
++	kdDebug() << "# Single category: " << sizeof(info.categoryInfo()->name[0]) << endl;
++
++	kdDebug() << "#\n# Sanity checking structure sizes\n#" << endl;
++	if ( sizeof(info.categoryInfo()->name[0]) != Pilot::CATEGORY_SIZE )
++	{
++		kdDebug() << "! Category names are not 16 bytes." << endl;
++		return 1;
++	}
++	if ( sizeof(info.categoryInfo()->name) / sizeof(info.categoryInfo()->name[0]) != Pilot::CATEGORY_COUNT )
++	{
++		kdDebug() << "! There are not " << Pilot::CATEGORY_COUNT << " categories available." << endl;
++		return 1;
++	}
++
++	kdDebug() << "# OK.\n" << endl;
++	return 0;
++}
++
++
+diff -pruN kpilot/tests/testdatabase.cc /home/pusling/kpilot/kdepim-3.5.5+/kpilot/tests/testdatabase.cc
+--- kpilot/tests/testdatabase.cc	1970-01-01 01:00:00.000000000 +0100
++++ kdepim-3.5.5+/kpilot/tests/testdatabase.cc	2006-11-19 22:21:12.000000000 +0100
+@@ -0,0 +1,315 @@
++/* testdatabase			KPilot
++**
++** Copyright (C) 2005 by Adriaan de Groot <groot at kde.org)
++**
++** Test the functions related to local databases.
++*/
++
++/*
++** This program 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.
++**
++** This program 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 in a file called COPYING; if not, write to
++** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
++** MA 02110-1301, USA.
++*/
++
++/*
++** Bug reports and questions can be sent to kde-pim at kde.org
++*/
++
++#include "options.h"
++
++#include <kaboutdata.h>
++#include <kapplication.h>
++#include <kdebug.h>
++#include <klocale.h>
++#include <kcmdlineargs.h>
++
++#include "pilotLocalDatabase.h"
++#include "pilotRecord.h"
++#include "pilotMemo.h"
++
++
++/* Return values for the various check* functions. They
++   return OK if all is OK; ERR is for generic errors.
++   ERR_NO_EXIST is returned if something (usually a database
++   or other file) doesn't exist that should. The latter
++   error might be ignored.
++*/
++#define OK           (0)
++#define ERR          (1)
++#define ERR_NO_EXIST (2)
++
++
++/* Data about the records in a database. The id field is
++   interpreted specially for the first and last entries.
++*/
++typedef struct { int id,size; } recordInfo;
++
++/* Use END in the last recordInfo struct describing a database
++   to indicate you expect the database to end there. Use NO_EXIST
++   as the ID in the first struct to indicate that the database
++   is expected _not_ to exist.
++*/
++#define NO_EXIST   (-2)
++#define END        (-1)
++
++/* These tables of data are taken from various databases I have
++   (but which I cannot commit to SVN due to license issues).
++   The aesop listing is from an eBook of Aesop's fables.
++   The way to create these tables is to use a third-party
++   tool such as par to read the database:
++
++   ./par l /tmp/Aesop.pdb | awk '{print "{",$3,",",$4,"},";}'
++
++*/
++recordInfo nonexistent[] = {
++	{ NO_EXIST, 0 }
++} ;
++
++recordInfo aesop[] = {
++{ 7307264 , 214 },
++{ 7307265 , 1564 },
++{ 7307266 , 1575 },
++{ 7307267 , 2214 },
++{ 7307268 , 2276 },
++{ 7307269 , 2148 },
++{ 7307270 , 2194 },
++{ 7307271 , 2178 },
++{ 7307272 , 2220 },
++{ 7307273 , 2216 },
++{ 7307274 , 2181 },
++{ 7307275 , 2183 },
++{ 7307276 , 2197 },
++{ 7307277 , 2010 },
++{ 7307278 , 2198 },
++{ 7307279 , 2196 },
++{ 7307280 , 2243 },
++{ 7307281 , 2211 },
++{ 7307282 , 2274 },
++{ 7307283 , 364 },
++{ 7307284 , 49124 },
++	{ END, 0 }
++} ;
++
++int checkDatabase(const char *path, recordInfo *info)
++{
++	FUNCTIONSETUP;
++
++	PilotLocalDatabase db(QString::fromLatin1(path));
++	if (!db.isOpen())
++	{
++		kdDebug() << "No database " << path << endl;
++		if ( info[0].id == NO_EXIST )
++		{
++			kdDebug() << "This was expected" << endl;
++			return OK;
++		}
++		else
++		{
++			return ERR_NO_EXIST;
++		}
++	}
++
++	if ( info[0].id == NO_EXIST )
++	{
++		kdDebug() << "Database not expected" << endl;
++		return ERR;
++	}
++
++	int fail = 0;
++	int index = 0;
++	PilotRecord *r;
++	while( (r = db.readRecordByIndex(index) ) )
++	{
++		kdDebug() << "[" << index << "] id=" << r->id() << " size=" << r->size() << endl;
++		if ( ((recordid_t)info[index].id) != r->id() )
++		{
++			kdDebug() << "* Bad ID (expected" << r->id() << ")" << endl;
++			fail++;
++		}
++		else if ( info[index].size != r->size() )
++		{
++			kdDebug() << "* Bad size (expected " << info[index].size << ")" << endl;
++			fail++;
++		}
++		index++;
++	}
++	if ( info[index].id != END )
++	{
++		kdDebug() << "* End wasn't expected yet." << endl;
++		r++;
++	}
++
++	if (fail)
++	{
++		kdDebug() << "* " << fail << " failures." << endl;
++		return ERR;
++	}
++	return OK;
++}
++
++const char *categoryNames[4] =
++{
++	"aardvarks",
++	"toolongToBeaCategoryName",
++	"personal",
++	"impersonal"
++} ;
++
++QStringList listCategories()
++{
++	QStringList cats;
++	PilotLocalDatabase *l = new PilotLocalDatabase("./data/MemoDB");
++	PilotMemoInfo *m = new PilotMemoInfo(l);
++
++	if (!l->isOpen()) return cats;
++
++	cats.append(CSL1("Unfiled"));
++	m->dump();
++
++	for (int i=0; i<20; i++)
++	{
++		PilotRecord *r = l->readRecordByIndex(i);
++		kdDebug() << "Read record " << (void *)r << " with id=" << r->id() << endl;
++		if (!r) break;
++	}
++
++	for (int i=0; i<4; i++)
++	{
++		QString s = m->category(i);
++		kdDebug() << "Category " << i << ": " << (s.isEmpty() ? CSL1("<empty>") : s) << endl;
++		cats.append(s);
++/*
++		if (i<((sizeof(categoryNames) / sizeof(categoryNames[0]))))
++			m->setCategoryName(i,QString::fromLatin1(categoryNames[i]));
++*/
++	}
++
++	m->write(l);
++
++	delete m;
++	delete l;
++
++	return cats;
++}
++
++int checkCategories()
++{
++	QStringList l = listCategories();
++	QStringList m = listCategories();
++
++	if (l.isEmpty() || m.isEmpty()) return ERR;
++	if (l!=m) return ERR;
++	return OK;
++}
++
++int checkMemo()
++{
++	PilotLocalDatabase *l = new PilotLocalDatabase("./data/MemoDB");
++	if (!l->isOpen()) return ERR_NO_EXIST;
++
++	PilotMemoInfo *m = new PilotMemoInfo(l);
++	m->dump();
++
++	QString c = m->category(1);
++	if (c != CSL1("Business"))
++	{
++		kdDebug() << "* Category 1 is not 'Business' but " << c << endl;
++		return ERR;
++	}
++
++	m->setCategoryName(2,CSL1("Aardvark"));
++	m->dump();
++
++	c = m->category(2);
++	if (c != CSL1("Aardvark"))
++	{
++		kdDebug() << "* Category 2 is not 'Aardvark' but " << c << endl;
++		return ERR;
++	}
++
++
++	delete m;
++	delete l;
++	return OK;
++}
++
++static const KCmdLineOptions options[] =
++{
++  {"verbose", "Verbose output", 0},
++  KCmdLineLastOption
++};
++
++
++int main(int argc, char **argv)
++{
++	KAboutData aboutData("testdatabase","Test Databases","0.1");
++	KCmdLineArgs::init(argc,argv,&aboutData);
++	KCmdLineArgs::addCmdLineOptions( options );
++
++	//  KApplication app( false, false );
++	KApplication app;
++
++	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
++
++	Q_UNUSED(args)
++
++	int r = 0;
++	int i = 0;
++#ifdef DEBUG
++	debug_level=4;
++#endif
++
++	Q_UNUSED(argc);
++	Q_UNUSED(argv);
++
++#define ALLOW_NO_EXIST (1)
++	static struct { const char *path; recordInfo *info; int flags; } 
++		tests[] =
++	{
++		{ "/tmp/nonexistant/nonexistent", nonexistent,0 },
++		{ "/tmp/Aesop", aesop, ALLOW_NO_EXIST },
++		{ 0L, 0L, 0 }
++	} ;
++
++	while ( tests[i].path )
++	{
++		kdDebug() << "*** Test " << i << endl;
++		int ret = checkDatabase( tests[i].path, tests[i].info );
++		if ( ret )
++		{
++			if ( (ret==ERR_NO_EXIST) && 
++				(tests[i].flags & ALLOW_NO_EXIST) )
++			{
++				kdDebug() << "* Test database doesn't exist, ignored." << endl;
++			}
++			else
++			{
++				r++;
++			}
++		}
++		i++;
++	}
++
++	kdDebug() << "*** Test " << i << endl;
++	if (checkMemo()) r++;
++	i++;
++
++	if (r)
++	{
++		kdDebug() << "***\n*** Failed " << r << " tests." << endl;
++		return 1;
++	}
++	return 0;
++}
++
+diff -pruN kpilot/TODO /home/pusling/kpilot/kdepim-3.5.5+/kpilot/TODO
+--- kpilot/TODO	2005-09-10 10:24:40.000000000 +0200
++++ kdepim-3.5.5+/kpilot/TODO	2006-11-19 22:21:12.000000000 +0100
+@@ -5,6 +5,12 @@ for details on how an issue is resolved,
+  periodically purged from this list.
+ 
+ 
++* Import pilot-link 0.12 CVS again
++* Implement correct full syncing in memofile conduit.  honestly, we should
++  really have a generic sync engine that knows how to do all of the
++  different sync types and only calls conduits for comparisons, list
++  fetching, pilotid->whateverId persistence and retrieval, etc.  *sigh*  is
++  that what opensync gives us?
+ 
+ Essential
+ =========

Added: trunk/packages/kdepim/debian/patches/26_fix_kpilot_build.diff
===================================================================
--- trunk/packages/kdepim/debian/patches/26_fix_kpilot_build.diff	2006-12-01 20:51:41 UTC (rev 5021)
+++ trunk/packages/kdepim/debian/patches/26_fix_kpilot_build.diff	2006-12-02 01:19:11 UTC (rev 5022)
@@ -0,0 +1,17 @@
+reverted:
+--- kpilot/lib/Makefile.am	(working copy)
++++ kpilot/lib/Makefile.am	(revision 609453)
+@@ -16,9 +16,11 @@
+ 
+ lib_LTLIBRARIES = libkpilot.la
+ 
++libkpilot_la_SOURCES = kpilotlibSettings.kcfgc \
++	options.cc uiDialog.cc plugin.cc syncAction.cc \
+-libkpilot_la_SOURCES = kpilotlibSettings.kcfgc options.cc uiDialog.cc plugin.cc syncAction.cc \
+ 	kpilotlink.cc \
++	pilot.cc \
++	pilotAppInfo.cc pilotRecord.cc pilotDatabase.cc \
+-	pilotRecord.cc pilotDatabase.cc \
+ 	pilotLocalDatabase.cc pilotSerialDatabase.cc \
+ 	pilotMemo.cc pilotAddress.cc \
+ 	pilotDateEntry.cc pilotTodoEntry.cc \




More information about the pkg-kde-commits mailing list