File 0001-aqbanking5-support.patch of Package kmymoney

From 90153841a06712b0cc9b30190b9f1adc189a3f45 Mon Sep 17 00:00:00 2001
From: Sebastian Held <sebastian.held@gmx.de>
Date: Mon, 6 Sep 2010 21:09:43 +0200
Subject: [PATCH] aqbanking5 support

---
diff --git a/cmake/modules/FindAqBanking.cmake b/cmake/modules/FindAqBanking.cmake
index e2afa127bd8224a70d03211d2c96bd100be4a0ae..de0058a16cfe066d139dac19cdef1538c7b78213 100644
--- a/cmake/modules/FindAqBanking.cmake
+++ b/cmake/modules/FindAqBanking.cmake
@@ -13,9 +13,12 @@ endif(NOT AQBANKING_MIN_VERSION)
 
 if(NOT AQBANKING_MAX_VERSION)
   # for some unknown reason, we need to give a micro version number
-  # with an offset of 1 to the PKG_CHECK_MODULES macro. The actual
-  # version KBanking will work with is 4.99.8
-  set(AQBANKING_MAX_VERSION "4.99.9")
+  # with an offset of 1 to the PKG_CHECK_MODULES macro.
+  # The actual version of KBanking will work with is 4.99.8
+
+  # set(AQBANKING_MAX_VERSION "4.99.9")
+  
+  # Currently there is no max version necessary
 endif(NOT AQBANKING_MAX_VERSION)
 
 if(AQBANKING_INCLUDE_DIRS AND AQBANKING_LIBRARIES)
@@ -23,11 +26,15 @@ if(AQBANKING_INCLUDE_DIRS AND AQBANKING_LIBRARIES)
   set(AQBANKING_FIND_QUIETLY TRUE)
 endif(AQBANKING_INCLUDE_DIRS AND AQBANKING_LIBRARIES)
 
-PKG_CHECK_MODULES(AQBANKING aqbanking>=${AQBANKING_MIN_VERSION} aqbanking<=${AQBANKING_MAX_VERSION})
+if(AQBANKING_MIN_VERSION AND AQBANKING_MAX_VERSION)
+  PKG_CHECK_MODULES(AQBANKING aqbanking>=${AQBANKING_MIN_VERSION} aqbanking<=${AQBANKING_MAX_VERSION})
+else (AQBANKING_MIN_VERSION AND AQBANKING_MAX_VERSION)
+  PKG_CHECK_MODULES(AQBANKING aqbanking>=${AQBANKING_MIN_VERSION})
+endif (AQBANKING_MIN_VERSION AND AQBANKING_MAX_VERSION)
 
 if(${AQBANKING_FOUND})
-  # if AqBanking has been found make sure to add the q4banking lib
-  set(AQBANKING_LIBRARIES ${AQBANKING_LIBRARIES} q4banking)
+  # the plugin requires Qt3Support and kde3support
+  set(AQBANKING_LIBRARIES ${AQBANKING_LIBRARIES} Qt3Support kde3support)
 endif(${AQBANKING_FOUND})
 
 mark_as_advanced(AQBANKING_INCLUDE_DIRS AQBANKING_LIBRARIES)
diff --git a/cmake/modules/FindGwenhywfar.cmake b/cmake/modules/FindGwenhywfar.cmake
index 600570e838b861d4121f2b854a16eb729c46f744..2702812890bb02e5d70239794576b30e1d7b18df 100644
--- a/cmake/modules/FindGwenhywfar.cmake
+++ b/cmake/modules/FindGwenhywfar.cmake
@@ -19,12 +19,25 @@ endif(GWENHYWFAR_INCLUDE_DIRS AND GWENHYWFAR_LIBRARIES)
 PKG_CHECK_MODULES(GWENHYWFAR gwenhywfar>=${GWENHYWFAR_MIN_VERSION})
 
 if(${GWENHYWFAR_FOUND})
-  find_library(GWENHYWFAR_GUI_LIBRARY NAMES gwengui-qt4 libgwengui-qt4
-    HINTS ${GWENHYWFAR_LIBRARY_DIRS})
-  if(GWENHYWFAR_GUI_LIBRARY STREQUAL "GWENHYWFAR_GUI_LIBRARY-NOTFOUND")
-    set(GWENHYWFAR_GUI_LIBRARY "")
-  endif(GWENHYWFAR_GUI_LIBRARY STREQUAL "GWENHYWFAR_GUI_LIBRARY-NOTFOUND")
-  set(GWENHYWFAR_LIBRARIES ${GWENHYWFAR_LIBRARIES} ${GWENHYWFAR_GUI_LIBRARY})
+  if(${GWENHYWFAR_VERSION} VERSION_GREATER 4.0.0)
+    PKG_CHECK_MODULES(QT4GUI gwengui-qt4)
+     if (NOT ${QT4GUI_FOUND})
+        set(GWENHYWFAR_FOUND FALSE)
+        unset(GWENHYWFAR_INCLUDE_DIRS)
+        unset(GWENHYWFAR_LIBRARIES)
+        unset(GWENHYWFAR_VERSION)
+        message(STATUS "Gwenhywfar does not have the Q4Banking frontend enabled")
+     endif (NOT ${QT4GUI_FOUND})
+  endif(${GWENHYWFAR_VERSION} VERSION_GREATER 4.0.0)
+
+  if(${GWENHYWFAR_FOUND})
+    find_library(GWENHYWFAR_GUI_LIBRARY NAMES gwengui-qt4 libgwengui-qt4
+      HINTS ${GWENHYWFAR_LIBRARY_DIRS})
+    if(GWENHYWFAR_GUI_LIBRARY STREQUAL "GWENHYWFAR_GUI_LIBRARY-NOTFOUND")
+      set(GWENHYWFAR_GUI_LIBRARY "")
+    endif(GWENHYWFAR_GUI_LIBRARY STREQUAL "GWENHYWFAR_GUI_LIBRARY-NOTFOUND")
+    set(GWENHYWFAR_LIBRARIES ${GWENHYWFAR_LIBRARIES} ${GWENHYWFAR_GUI_LIBRARY})
+  endif(${GWENHYWFAR_FOUND})
 endif(${GWENHYWFAR_FOUND})
 
 mark_as_advanced(GWENHYWFAR_INCLUDE_DIRS GWENHYWFAR_LIBRARIES)
diff --git a/kmymoney/plugins/kbanking/CMakeLists.txt b/kmymoney/plugins/kbanking/CMakeLists.txt
index df1469c39886e5a07fb9cfba97892eeea47856fa..b10822a1cd67faf65e9e591940a4710a123a0816 100644
--- a/kmymoney/plugins/kbanking/CMakeLists.txt
+++ b/kmymoney/plugins/kbanking/CMakeLists.txt
@@ -17,7 +17,11 @@ ADD_SUBDIRECTORY( widgets )
 
 ########### next target ###############
 
-SET(kmm_kbanking_PART_SRCS kbanking.cpp mymoneybanking.cpp)
+SET(kmm_kbanking_PART_SRCS 
+    kbanking.cpp 
+    mymoneybanking.cpp
+    banking.cpp
+    )
 
 KDE4_ADD_PLUGIN(kmm_kbanking ${kmm_kbanking_PART_SRCS})
 
diff --git a/kmymoney/plugins/kbanking/banking.cpp b/kmymoney/plugins/kbanking/banking.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5e0793676d8d301ae22f789bff547581523a75e6
--- /dev/null
+++ b/kmymoney/plugins/kbanking/banking.cpp
@@ -0,0 +1,435 @@
+/***************************************************************************
+    begin       : Mon Mar 01 2004
+    copyright   : (C) 2004 by Martin Preuss
+    email       : martin@libchipcard.de
+
+ ***************************************************************************
+ * This file is part of the project "AqBanking".                           *
+ * Please see toplevel file COPYING of that project for license details.   *
+ ***************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+# include <config-kmymoney.h>
+#endif
+
+
+#include "banking.hpp"
+#include <aqbanking/banking_be.h>
+#include <aqbanking/banking_cfg.h>
+#include <assert.h>
+
+#include <gwenhywfar/inherit.h>
+#include <gwenhywfar/debug.h>
+
+
+
+AB_Banking::AB_Banking(const char *appname, const char *fname) {
+  assert(appname);
+  _banking=AB_Banking_new(appname, fname, 0);
+}
+
+
+
+AB_Banking::~AB_Banking(){
+  DBG_NOTICE(AQBANKING_LOGDOMAIN, "~AB_Banking: Freeing AB_Banking");
+  AB_Banking_free(_banking);
+}
+
+
+
+int AB_Banking::init(){
+  return AB_Banking_Init(_banking);
+}
+
+
+
+int AB_Banking::fini(){
+  return AB_Banking_Fini(_banking);
+}
+
+
+
+int AB_Banking::onlineInit(){
+  return AB_Banking_OnlineInit(_banking);
+}
+
+
+
+int AB_Banking::onlineFini(){
+  return AB_Banking_OnlineFini(_banking);
+}
+
+
+
+const char *AB_Banking::getAppName(){
+  return AB_Banking_GetAppName(_banking);
+}
+
+
+
+std::list<AB_ACCOUNT*> AB_Banking::getAccounts(){
+  AB_ACCOUNT_LIST2 *ll;
+  std::list<AB_ACCOUNT*> rl;
+
+  ll=AB_Banking_GetAccounts(_banking);
+  if (ll) {
+    AB_ACCOUNT *a;
+    AB_ACCOUNT_LIST2_ITERATOR *it;
+
+    it=AB_Account_List2_First(ll);
+    assert(it);
+    a=AB_Account_List2Iterator_Data(it);
+    assert(a);
+    while(a) {
+      rl.push_back(a);
+      a=AB_Account_List2Iterator_Next(it);
+    }
+    AB_Account_List2Iterator_free(it);
+    AB_Account_List2_free(ll);
+  }
+  return rl;
+}
+
+
+
+AB_ACCOUNT *AB_Banking::getAccount(uint32_t uniqueId){
+  return AB_Banking_GetAccount(_banking, uniqueId);
+}
+
+
+
+std::list<AB_USER*> AB_Banking::getUsers() {
+  AB_USER_LIST2 *ll;
+  std::list<AB_USER*> rl;
+
+  ll=AB_Banking_GetUsers(_banking);
+  if (ll) {
+    AB_USER *a;
+    AB_USER_LIST2_ITERATOR *it;
+
+    it=AB_User_List2_First(ll);
+    assert(it);
+    a=AB_User_List2Iterator_Data(it);
+    assert(a);
+    while(a) {
+      rl.push_back(a);
+      a=AB_User_List2Iterator_Next(it);
+    }
+    AB_User_List2Iterator_free(it);
+    AB_User_List2_free(ll);
+  }
+  return rl;
+}
+
+
+
+int AB_Banking::getUserDataDir(GWEN_BUFFER *buf) const{
+  return AB_Banking_GetUserDataDir(_banking, buf);
+}
+
+
+
+int AB_Banking::getAppUserDataDir(GWEN_BUFFER *buf) const{
+  return AB_Banking_GetAppUserDataDir(_banking, buf);
+}
+
+
+
+AB_BANKING *AB_Banking::getCInterface(){
+  return _banking;
+}
+
+
+
+std::list<std::string> AB_Banking::getActiveProviders(){
+  const GWEN_STRINGLIST *sl;
+  std::list<std::string> l;
+
+  sl=AB_Banking_GetActiveProviders(_banking);
+  if (sl) {
+    GWEN_STRINGLISTENTRY *se;
+
+    se=GWEN_StringList_FirstEntry(sl);
+    assert(se);
+    while(se) {
+      const char *p;
+
+      p=GWEN_StringListEntry_Data(se);
+      assert(p);
+      l.push_back(p);
+      se=GWEN_StringListEntry_Next(se);
+    } /* while */
+  }
+  return l;
+}
+
+
+AB_PROVIDER *AB_Banking::getProvider(const char *name){
+  return AB_Banking_GetProvider(_banking, name);
+}
+
+
+
+bool AB_Banking::importContext(AB_IMEXPORTER_CONTEXT *ctx, uint32_t flags) {
+  AB_IMEXPORTER_ACCOUNTINFO *ai;
+
+  ai=AB_ImExporterContext_GetFirstAccountInfo(ctx);
+  while(ai) {
+    if (!importAccountInfo(ai, flags))
+      return false;
+    ai=AB_ImExporterContext_GetNextAccountInfo(ctx);
+  }
+
+  return true;
+}
+
+
+
+bool AB_Banking::importAccountInfo(AB_IMEXPORTER_ACCOUNTINFO*, uint32_t) {
+  return false;
+}
+
+
+
+int AB_Banking::executeJobs(AB_JOB_LIST2 *jl, AB_IMEXPORTER_CONTEXT *ctx) {
+  return AB_Banking_ExecuteJobs(_banking, jl, ctx);
+}
+
+
+
+int AB_Banking::loadSharedConfig(const char *name, GWEN_DB_NODE **pDb) {
+  return AB_Banking_LoadSharedConfig(_banking, name, pDb);
+}
+
+
+
+int AB_Banking::saveSharedConfig(const char *name, GWEN_DB_NODE *db) {
+  return AB_Banking_SaveSharedConfig(_banking, name, db);
+}
+
+
+
+int AB_Banking::lockSharedConfig(const char *name) {
+  return AB_Banking_LockSharedConfig(_banking, name);
+}
+
+
+
+int AB_Banking::unlockSharedConfig(const char *name) {
+  return AB_Banking_UnlockSharedConfig(_banking, name);
+}
+
+
+
+int AB_Banking::loadSharedSubConfig(const char *name,
+				    const char *subGroup,
+				    GWEN_DB_NODE **pDb) {
+  GWEN_DB_NODE *dbShared=NULL;
+  int rv;
+
+  rv=loadSharedConfig(name, &dbShared);
+  if (rv<0) {
+    DBG_ERROR(0, "Unable to load config (%d)", rv);
+    GWEN_DB_Group_free(dbShared);
+    return rv;
+  }
+  else {
+    GWEN_DB_NODE *dbSrc;
+
+    dbSrc=GWEN_DB_GetGroup(dbShared,
+			   GWEN_PATH_FLAGS_NAMEMUSTEXIST,
+			   subGroup);
+    if (dbSrc) {
+      *pDb=GWEN_DB_Group_dup(dbSrc);
+    }
+    else {
+      *pDb=GWEN_DB_Group_new("config");
+    }
+    GWEN_DB_Group_free(dbShared);
+
+    return 0;
+  }
+}
+
+
+
+int AB_Banking::saveSharedSubConfig(const char *name,
+				    const char *subGroup,
+				    GWEN_DB_NODE *dbSrc) {
+  GWEN_DB_NODE *dbShared=NULL;
+  int rv;
+
+  rv=lockSharedConfig(name);
+  if (rv<0) {
+    DBG_ERROR(0, "Unable to lock config");
+    return rv;
+  }
+  else {
+    rv=loadSharedConfig(name, &dbShared);
+    if (rv<0) {
+      DBG_ERROR(0, "Unable to load config (%d)", rv);
+      unlockSharedConfig(name);
+      return rv;
+    }
+    else {
+      GWEN_DB_NODE *dbDst;
+
+      dbDst=GWEN_DB_GetGroup(dbShared,
+			     GWEN_DB_FLAGS_OVERWRITE_GROUPS,
+			     subGroup);
+      assert(dbDst);
+      if (dbSrc)
+	GWEN_DB_AddGroupChildren(dbDst, dbSrc);
+      rv=saveSharedConfig(name, dbShared);
+      if (rv<0) {
+	DBG_ERROR(0, "Unable to store config (%d)", rv);
+	unlockSharedConfig(name);
+	GWEN_DB_Group_free(dbShared);
+	return rv;
+      }
+      GWEN_DB_Group_free(dbShared);
+    }
+
+    rv=unlockSharedConfig(name);
+    if (rv<0) {
+      DBG_ERROR(0, "Unable to unlock config (%d)", rv);
+      return rv;
+    }
+  }
+  return 0;
+}
+
+
+int AB_Banking::loadAppConfig(GWEN_DB_NODE **pDb) {
+  return AB_Banking_LoadAppConfig(_banking, pDb);
+}
+
+
+
+int AB_Banking::saveAppConfig(GWEN_DB_NODE *db) {
+  return AB_Banking_SaveAppConfig(_banking, db);
+}
+
+
+
+int AB_Banking::lockAppConfig() {
+  return AB_Banking_LockAppConfig(_banking);
+}
+
+
+
+int AB_Banking::unlockAppConfig() {
+  return AB_Banking_UnlockAppConfig(_banking);
+}
+
+
+
+int AB_Banking::loadAppSubConfig(const char *subGroup,
+				 GWEN_DB_NODE **pDb) {
+  GWEN_DB_NODE *dbApp=NULL;
+  int rv;
+
+  rv=loadAppConfig(&dbApp);
+  if (rv<0) {
+    DBG_ERROR(0, "Unable to load config (%d)", rv);
+    GWEN_DB_Group_free(dbApp);
+    return rv;
+  }
+  else {
+    GWEN_DB_NODE *dbSrc;
+
+    dbSrc=GWEN_DB_GetGroup(dbApp,
+			   GWEN_PATH_FLAGS_NAMEMUSTEXIST,
+			   subGroup);
+    if (dbSrc) {
+      *pDb=GWEN_DB_Group_dup(dbSrc);
+    }
+    else {
+      *pDb=GWEN_DB_Group_new("config");
+    }
+    GWEN_DB_Group_free(dbApp);
+
+    return 0;
+  }
+}
+
+
+
+int AB_Banking::saveAppSubConfig(const char *subGroup,
+				 GWEN_DB_NODE *dbSrc) {
+  GWEN_DB_NODE *dbApp=NULL;
+  int rv;
+
+  rv=lockAppConfig();
+  if (rv<0) {
+    DBG_ERROR(0, "Unable to lock config");
+    return rv;
+  }
+  else {
+    rv=loadAppConfig(&dbApp);
+    if (rv<0) {
+      DBG_ERROR(0, "Unable to load config (%d)", rv);
+      unlockAppConfig();
+      return rv;
+    }
+    else {
+      GWEN_DB_NODE *dbDst;
+
+      dbDst=GWEN_DB_GetGroup(dbApp,
+			     GWEN_DB_FLAGS_OVERWRITE_GROUPS,
+			     subGroup);
+      assert(dbDst);
+      if (dbSrc)
+	GWEN_DB_AddGroupChildren(dbDst, dbSrc);
+      rv=saveAppConfig(dbApp);
+      if (rv<0) {
+	DBG_ERROR(0, "Unable to store config (%d)", rv);
+	unlockAppConfig();
+	GWEN_DB_Group_free(dbApp);
+	return rv;
+      }
+      GWEN_DB_Group_free(dbApp);
+    }
+
+    rv=unlockAppConfig();
+    if (rv<0) {
+      DBG_ERROR(0, "Unable to unlock config (%d)", rv);
+      return rv;
+    }
+  }
+  return 0;
+}
+
+
+int AB_Banking::beginExclUseAccount(AB_ACCOUNT *a) {
+  return AB_Banking_BeginExclUseAccount(_banking, a);
+}
+
+
+
+int AB_Banking::endExclUseAccount(AB_ACCOUNT *a, int abandon) {
+  return AB_Banking_EndExclUseAccount(_banking, a, abandon);
+}
+
+
+
+int AB_Banking::beginExclUseUser(AB_USER *u) {
+  return AB_Banking_BeginExclUseUser(_banking, u);
+}
+
+
+
+int AB_Banking::endExclUseUser(AB_USER *u, int abandon) {
+  return AB_Banking_EndExclUseUser(_banking, u, abandon);
+}
+
+
+void AB_Banking::setAccountAlias(AB_ACCOUNT *a, const char *alias) {
+  AB_Banking_SetAccountAlias(_banking, a, alias);
+}
+
+
+
+
+
diff --git a/kmymoney/plugins/kbanking/banking.hpp b/kmymoney/plugins/kbanking/banking.hpp
new file mode 100644
index 0000000000000000000000000000000000000000..0980416dfcd1d34d4c5bd7be288dee805c9113b0
--- /dev/null
+++ b/kmymoney/plugins/kbanking/banking.hpp
@@ -0,0 +1,185 @@
+/***************************************************************************
+    begin       : Mon Mar 01 2004
+    copyright   : (C) 2004 by Martin Preuss
+    email       : martin@libchipcard.de
+
+ ***************************************************************************
+ * This file is part of the project "AqBanking".                           *
+ * Please see toplevel file COPYING of that project for license details.   *
+ ***************************************************************************/
+
+/** @file 
+ * @short A C++ wrapper of the main aqbanking interface
+ */
+
+#ifndef AQ_BANKING_CPP_H
+#define AQ_BANKING_CPP_H
+
+
+#include <aqbanking/banking.h>
+#include <aqbanking/system.h>
+
+#include <list>
+#include <string>
+
+
+/**
+ * @brief A C++ binding for the C module @ref AB_BANKING
+ *
+ * This class simply is a C++ binding for the C module @ref AB_BANKING.
+ * It redirects C callbacks used by AB_BANKING to virtual functions in
+ * this class. It als transforms some return values inconveniant for
+ * C++ into STL objects (such as "list<T>").
+ *
+ * @ingroup G_AB_CPP_INTERFACE
+ *
+ * @author Martin Preuss<martin@aquamaniac.de>
+ */
+class AB_Banking {
+private:
+  AB_BANKING *_banking;
+
+public:
+  AB_Banking(const char *appname,
+          const char *fname);
+  virtual ~AB_Banking();
+
+
+  AB_BANKING *getCInterface();
+
+
+  /**
+   * See @ref AB_Banking_Init
+   */
+  virtual int init();
+
+  /**
+   * See @ref AB_Banking_Fini
+   */
+  virtual int fini();
+
+
+  /**
+   * See @ref AB_Banking_OnlineInit
+   */
+  int onlineInit();
+
+  /**
+   * See @ref AB_Banking_OnlineFini
+   */
+  int onlineFini();
+
+  /**
+   * Loads a backend with the given name. You can use
+   * @ref AB_Banking_GetProviderDescrs to retrieve a list of available
+   * backends. Such a backend can then be asked to return an account list.
+   */
+  AB_PROVIDER *getProvider(const char *name);
+
+
+  /**
+   * Returns the application name as given to @ref AB_Banking_new.
+   */
+  const char *getAppName();
+
+  /**
+   * Returns a list of pointers to currently known accounts.
+   * Please note that the pointers in this list are still owned by
+   * AqBanking, so you MUST NOT free them.
+   * However, destroying the list will not free the accounts, so it is
+   * safe to do that.
+   */
+  std::list<AB_ACCOUNT*> getAccounts();
+
+  /**
+   * This function does an account lookup based on the given unique id.
+   * This id is assigned by AqBanking when an account is created.
+   * The pointer returned is still owned by AqBanking, so you MUST NOT free
+   * it.
+   */
+  AB_ACCOUNT *getAccount(uint32_t uniqueId);
+
+  /**
+   * Returns a list of pointers to currently known users.
+   * Please note that the pointers in this list are still owned by
+   * AqBanking, so you MUST NOT free them.
+   * However, destroying the list will not free the users, so it is
+   * safe to do that.
+   */
+  std::list<AB_USER*> getUsers();
+
+  int getUserDataDir(GWEN_BUFFER *buf) const ;
+  int getAppUserDataDir(GWEN_BUFFER *buf) const ;
+
+  int loadAppConfig(GWEN_DB_NODE **pDb);
+  int saveAppConfig(GWEN_DB_NODE *db);
+  int lockAppConfig();
+  int unlockAppConfig();
+
+  int loadAppSubConfig(const char *subGroup,
+		       GWEN_DB_NODE **pDb);
+
+  int saveAppSubConfig(const char *subGroup,
+		       GWEN_DB_NODE *dbSrc);
+
+
+  int loadSharedConfig(const char *name, GWEN_DB_NODE **pDb);
+  int saveSharedConfig(const char *name, GWEN_DB_NODE *db);
+  int lockSharedConfig(const char *name);
+  int unlockSharedConfig(const char *name);
+
+  int loadSharedSubConfig(const char *name,
+			  const char *subGroup,
+			  GWEN_DB_NODE **pDb);
+
+  int saveSharedSubConfig(const char *name,
+			  const char *subGroup,
+			  GWEN_DB_NODE *dbSrc);
+
+  int beginExclUseAccount(AB_ACCOUNT *a);
+  int endExclUseAccount(AB_ACCOUNT *a, int abandon);
+
+  int beginExclUseUser(AB_USER *u);
+  int endExclUseUser(AB_USER *u, int abandon);
+
+  std::list<std::string> getActiveProviders();
+
+  void setAccountAlias(AB_ACCOUNT *a, const char *alias);
+
+
+  /** @name Enqueueing, Dequeueing and Executing Jobs
+   *
+   * Enqueued jobs are preserved across shutdowns. As soon as a job has been
+   * sent to the appropriate backend it will be removed from the queue.
+   * Only those jobs are saved/reloaded which have been enqueued but never
+   * presented to the backend. This means after calling
+   * @ref AB_Banking_ExecuteQueue only those jobs are still in the queue which
+   * have not been processed (e.g. because they belonged to a second backend
+   * but the user aborted while the jobs for a first backend were in process).
+   */
+  /*@{*/
+  /**
+   * This function sends all jobs in the list to their corresponding backends
+   * and allows that backend to process it.
+   */
+  virtual int executeJobs(AB_JOB_LIST2 *jl,
+			  AB_IMEXPORTER_CONTEXT *ctx);
+
+  /*@}*/
+
+  /**
+   * Let the application import a given statement context.
+   */
+  virtual bool importContext(AB_IMEXPORTER_CONTEXT *ctx,
+                             uint32_t flags);
+
+  virtual bool importAccountInfo(AB_IMEXPORTER_ACCOUNTINFO *ai, uint32_t flags);
+
+};
+
+
+
+
+#endif /* AQ_BANKING_CPP_H */
+
+
diff --git a/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt b/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt
index 28a666ca3c310ee9ebfc355480dca05f37a25f22..6ad7fb16437b15bd015fdd81dc8e2fa37ebf53c8 100644
--- a/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt
+++ b/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt
@@ -5,11 +5,13 @@ SET(kmm_kbanking_dialogs_la_SOURCES
     kbaccountsettings.cpp
     kbpickstartdate.cpp
     kbsettings.cpp
+    kbmapaccount.cpp
     )
 
 SET(kmm_kbanking_dialogs_UI
     kbaccountsettings.ui
     kbpickstartdate.ui
+    kbmapaccount.ui
     )
 
 KDE4_ADD_UI_FILES(kmm_kbanking_dialogs_la_SOURCES
diff --git a/kmymoney/plugins/kbanking/dialogs/kbmapaccount.cpp b/kmymoney/plugins/kbanking/dialogs/kbmapaccount.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f39afd47cbd5aa82321a706c1a925d5d91a27ade
--- /dev/null
+++ b/kmymoney/plugins/kbanking/dialogs/kbmapaccount.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+    begin       : Mon Mar 01 2004
+    copyright   : (C) 2004 by Martin Preuss
+    email       : martin@libchipcard.de
+
+ ***************************************************************************
+ *          Please see toplevel file COPYING for license details           *
+ ***************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+# include <config-kmymoney.h>
+#endif
+
+
+// QBanking includes
+#include "kbmapaccount.h"
+#include "kbaccountlist.h"
+#include "kbanking.h"
+
+// QT includes
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qmessagebox.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+
+
+
+
+KBMapAccount::KBMapAccount(KBanking *kb,
+			   const char *bankCode,
+			   const char *accountId,
+			   QWidget* parent,
+                           Qt::WFlags fl)
+:QDialog(parent, fl)
+,_banking(kb)
+,_account(0) {
+  _ui.setupUi(this);
+
+  _ui.accountList->setSelectionMode(Q3ListView::Single);
+  _ui.accountList->setAllColumnsShowFocus(true);
+
+  if (bankCode)
+    _ui.bankCodeEdit->setText(QString::fromUtf8(bankCode));
+  else
+    _ui.bankCodeEdit->setEnabled(false);
+  if (accountId)
+    _ui.accountIdEdit->setText(QString::fromUtf8(accountId));
+  else
+    _ui.accountIdEdit->setEnabled(false);
+
+  QObject::connect(_ui.accountList, SIGNAL(selectionChanged()),
+                   this, SLOT(slotSelectionChanged()));
+  QObject::connect(_ui.helpButton, SIGNAL(clicked()),
+                   this, SLOT(slotHelpClicked()));
+
+  _ui.accountList->addAccounts(_banking->getAccounts());
+}
+
+
+KBMapAccount::~KBMapAccount(){
+}
+
+
+
+AB_ACCOUNT *KBMapAccount::getAccount(){
+  return _account;
+}
+
+
+
+void KBMapAccount::accept(){
+  if (_account)
+    QDialog::accept();
+}
+
+
+
+void KBMapAccount::slotSelectionChanged(){
+  std::list<AB_ACCOUNT*> al;
+  AB_ACCOUNT *a;
+
+  al=_ui.accountList->getSelectedAccounts();
+  if (al.empty()) {
+    _ui.assignButton->setEnabled(false);
+    _account=0;
+    return;
+  }
+  a=al.front();
+  if (AB_Account_GetUniqueId(a)!=0) {
+    _account=a;
+    _ui.assignButton->setEnabled(true);
+  }
+  else
+    _ui.assignButton->setEnabled(false);
+}
+
+
+
+void KBMapAccount::slotHelpClicked() {
+}
+
+
+
+
diff --git a/kmymoney/plugins/kbanking/dialogs/kbmapaccount.h b/kmymoney/plugins/kbanking/dialogs/kbmapaccount.h
new file mode 100644
index 0000000000000000000000000000000000000000..29c364d57f1452456826b7a58115f5b770421ee4
--- /dev/null
+++ b/kmymoney/plugins/kbanking/dialogs/kbmapaccount.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+    begin       : Mon Mar 01 2004
+    copyright   : (C) 2004 by Martin Preuss
+    email       : martin@libchipcard.de
+
+ ***************************************************************************
+ *          Please see toplevel file COPYING for license details           *
+ ***************************************************************************/
+
+#ifndef QBANKING_MAPACCOUNT_H
+#define QBANKING_MAPACCOUNT_H
+
+#include "kbaccountlist.h"
+#include "ui_kbmapaccount.h"
+
+#include <aqbanking/account.h>
+
+
+class KBanking;
+
+
+class KBMapAccount: public QDialog {
+  Q_OBJECT
+public:
+  KBMapAccount(KBanking *kb,
+	       const char *bankCode,
+               const char *accountId,
+               QWidget* parent=0,
+               Qt::WFlags fl=0);
+  ~KBMapAccount();
+
+  AB_ACCOUNT *getAccount();
+
+  void accept();
+
+protected slots:
+  void slotSelectionChanged();
+  void slotHelpClicked();
+
+private:
+  Ui_KBMapAccountUi _ui;
+  KBanking *_banking;
+  AB_ACCOUNT *_account;
+  KBAccountListView *_accountList;
+};
+
+
+
+
+
+#endif /* QBANKING_MAPACCOUNT_H */
+
diff --git a/kmymoney/plugins/kbanking/dialogs/kbmapaccount.ui b/kmymoney/plugins/kbanking/dialogs/kbmapaccount.ui
new file mode 100644
index 0000000000000000000000000000000000000000..d144f445b6cf0dd68bf76208facd6ad89a011b09
--- /dev/null
+++ b/kmymoney/plugins/kbanking/dialogs/kbmapaccount.ui
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>KBMapAccountUi</class>
+ <widget class="QDialog" name="KBMapAccountUi">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>747</width>
+    <height>538</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Account Mapping</string>
+  </property>
+  <layout class="QVBoxLayout">
+   <item>
+    <widget class="QLabel" name="textLabel1">
+     <property name="text">
+      <string>&lt;qt&gt;
+Please choose the &lt;b&gt;online&lt;/b&gt; account you want the 
+&lt;b&gt;application&lt;/b&gt; account to be mapped to from the list below.
+&lt;/qt&gt;</string>
+     </property>
+     <property name="wordWrap">
+      <bool>false</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="Q3GroupBox" name="groupBox1">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title">
+      <string>Application Account</string>
+     </property>
+     <layout class="QHBoxLayout">
+      <item>
+       <widget class="QLabel" name="textLabel2">
+        <property name="text">
+         <string>Bank Code</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLineEdit" name="bankCodeEdit">
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="textLabel2_2">
+        <property name="text">
+         <string>Account Number</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLineEdit" name="accountIdEdit">
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="Q3GroupBox" name="accountBox">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title">
+      <string>Online Accounts</string>
+     </property>
+     <layout class="QHBoxLayout">
+      <item>
+       <widget class="KBAccountListView" name="accountList" native="true"/>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout">
+     <item>
+      <widget class="QPushButton" name="helpButton">
+       <property name="text">
+        <string>Help</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="spacer1">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Expanding</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>326</width>
+         <height>29</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="assignButton">
+       <property name="text">
+        <string>Assign</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="abortButton">
+       <property name="text">
+        <string>Abort</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+  <customwidget>
+   <class>Q3GroupBox</class>
+   <extends>QGroupBox</extends>
+   <header>Qt3Support/Q3GroupBox</header>
+   <container>1</container>
+  </customwidget>
+  <customwidget>
+   <class>KBAccountListView</class>
+   <extends>QWidget</extends>
+   <header location="local">kbaccountlist.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>abortButton</sender>
+   <signal>clicked()</signal>
+   <receiver>KBMapAccountUi</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>20</x>
+     <y>20</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>20</x>
+     <y>20</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>assignButton</sender>
+   <signal>clicked()</signal>
+   <receiver>KBMapAccountUi</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>20</x>
+     <y>20</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>20</x>
+     <y>20</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp b/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp
index e1c8cf48ea3d9e342151540127dbcc3e4b9e03df..7cdf10941e39a7e70dde5b73aa89a7e41c070862 100644
--- a/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp
+++ b/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp
@@ -25,7 +25,6 @@
 
 // QBanking includes
 #include "kbpickstartdate.h"
-#include <q4banking/qbanking.h>
 
 // Gwenhywfar includes
 #include <gwenhywfar/debug.h>
@@ -46,14 +45,12 @@
 
 
 
-KBPickStartDate::KBPickStartDate(QBanking *qb,
-                                 const QDate &firstPossible,
+KBPickStartDate::KBPickStartDate(const QDate &firstPossible,
                                  const QDate &lastUpdate,
                                  const QString& accountName,
                                  int defaultChoice,
                                  QWidget* parent, bool modal) :
     QDialog(parent),
-    _banking(qb),
     _firstPossible(firstPossible),
     _lastUpdate(lastUpdate)
 {
@@ -139,6 +136,5 @@ QDate KBPickStartDate::date()
 
 void KBPickStartDate::slotHelpClicked()
 {
-  _banking->invokeHelp("KBPickStartDate", "none");
 }
 
diff --git a/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h b/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h
index 428dee1ab28300955d1c1f687abff484f82c4d7d..36ea601601aac63f01c211b7a62dc5da805c3224 100644
--- a/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h
+++ b/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h
@@ -43,8 +43,7 @@ private:
   const QDate &_firstPossible;
   const QDate &_lastUpdate;
 public:
-  KBPickStartDate(QBanking *banking,
-                  const QDate &firstPossible,
+  KBPickStartDate(const QDate &firstPossible,
                   const QDate &lastUpdate,
                   const QString& accountName,
                   int defaultChoice,
diff --git a/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp b/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp
index 4454e88b68537caa56f1eb99b473e61dfa292595..b588797bd8d9a3f40dcb08abb3c2d92f7204de95 100644
--- a/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp
+++ b/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp
@@ -22,6 +22,9 @@
 # include <config-kmymoney.h>
 #endif
 
+
+#if 0
+
 #include "kbsettings.h"
 
 #include <gwenhywfar/debug.h>
@@ -56,3 +59,6 @@ int KBankingSettings::fini()
     return -1;
   return 0;
 }
+
+#endif
+
diff --git a/kmymoney/plugins/kbanking/dialogs/kbsettings.h b/kmymoney/plugins/kbanking/dialogs/kbsettings.h
index fc4dc87fbd964ea6d9f1b330af880dbd82196a1f..c0db9244ff97b69af0eb52868cb87837f6476971 100644
--- a/kmymoney/plugins/kbanking/dialogs/kbsettings.h
+++ b/kmymoney/plugins/kbanking/dialogs/kbsettings.h
@@ -21,6 +21,8 @@
 #ifndef KBANKING_KBSETTINGS_H
 #define KBANKING_KBSETTINGS_H
 
+#if 0
+
 #include "kbanking.h"
 #include <q4banking/qbcfgtabsettings.h>
 
@@ -37,4 +39,7 @@ public:
   int fini();
 };
 
+
+#endif
+
 #endif /* KBANKING_KBSETTINGS_H */
diff --git a/kmymoney/plugins/kbanking/kbanking.cpp b/kmymoney/plugins/kbanking/kbanking.cpp
index c18cd701fcc5285211386afa0c2156153e01d3f6..6730bd180a2feaf76c3ce7a53612e03b43f54b7d 100644
--- a/kmymoney/plugins/kbanking/kbanking.cpp
+++ b/kmymoney/plugins/kbanking/kbanking.cpp
@@ -24,6 +24,7 @@
 
 
 #include "kbanking.h"
+#include "kbmapaccount.h"
 
 #include <assert.h>
 #include <QString>
@@ -33,12 +34,15 @@
 #include <QDateTime>
 #include <QWidget>
 
+#include <aqbanking/dlg_importer.h>
+
 #include <gwenhywfar/debug.h>
 #include <gwenhywfar/text.h>
+#include <gwenhywfar/gui.h>
 
 KBanking::KBanking(const char *appname,
                    const char *cfgDir) :
-    QBanking(appname, cfgDir),
+	AB_Banking(appname, cfgDir),
     _jobQueue(0)
 {
 }
@@ -55,14 +59,14 @@ int KBanking::init()
 {
   int rv;
 
-  rv = QBanking::init();
+  rv = AB_Banking::init();
   if (rv < 0)
     return rv;
 
   rv = onlineInit();
   if (rv) {
     fprintf(stderr, "Error on online init (%d).\n", rv);
-    QBanking::fini();
+    AB_Banking::fini();
     return rv;
   }
 
@@ -84,10 +88,10 @@ int KBanking::fini()
 
   rv = onlineFini();
   if (rv) {
-    QBanking::fini();
+    AB_Banking::fini();
     return rv;
   }
-  return QBanking::fini();
+  return AB_Banking::fini();
 }
 
 
@@ -100,8 +104,11 @@ int KBanking::executeQueue(AB_IMEXPORTER_CONTEXT *ctx)
   rv = AB_BANKING_QBANKING_EXECUTE_JOBS(_jobQueue, ctx);
   oldQ = _jobQueue;
   _jobQueue = AB_Job_List2_new();
-  flagStaff()->queueUpdated();
   AB_Job_List2_FreeAll(oldQ);
+
+  /* clear password DB */
+  GWEN_Gui_SetPasswordStatus(NULL, NULL, GWEN_Gui_PasswordStatus_Remove, 0);
+
   return rv;
 }
 
@@ -138,7 +145,6 @@ int KBanking::enqueueJob(AB_JOB *j)
   assert(j);
   AB_Job_Attach(j);
   AB_Job_List2_PushBack(_jobQueue, j);
-  flagStaff()->queueUpdated();
   return 0;
 }
 
@@ -149,13 +155,71 @@ int KBanking::dequeueJob(AB_JOB *j)
   assert(_jobQueue);
   AB_Job_List2_Remove(_jobQueue, j);
   AB_Job_free(j);
-  flagStaff()->queueUpdated();
   return 0;
 }
 
 
 
+bool KBanking::askMapAccount(const char *id,
+			     const char *bankCode,
+			     const char *accountId){
+  KBMapAccount *w;
 
+  w=new KBMapAccount(this, bankCode, accountId);
+  if (w->exec()==QDialog::Accepted) {
+    AB_ACCOUNT *a;
+
+    a=w->getAccount();
+    assert(a);
+    DBG_NOTICE(0,
+               "Mapping application account \"%s\" to "
+               "online account \"%s/%s\"",
+               id,
+               AB_Account_GetBankCode(a),
+               AB_Account_GetAccountNumber(a));
+    setAccountAlias(a, id);
+    delete w;
+    return true;
+  }
+
+  delete w;
+  return false;
+}
+
+
+
+bool KBanking::interactiveImport() {
+  AB_IMEXPORTER_CONTEXT *ctx;
+  GWEN_DIALOG *dlg;
+  int rv;
+
+  ctx=AB_ImExporterContext_new();
+  dlg=AB_ImporterDialog_new(getCInterface(), ctx, NULL);
+  if (dlg==NULL) {
+    DBG_ERROR(0, "Could not create importer dialog.");
+    AB_ImExporterContext_free(ctx);
+    return false;
+  }
+
+  rv=GWEN_Gui_ExecDialog(dlg, 0);
+  if (rv==0) {
+    DBG_ERROR(0, "Aborted by user");
+    GWEN_Dialog_free(dlg);
+    AB_ImExporterContext_free(ctx);
+    return false;
+  }
+
+  if (!importContext(ctx, 0)) {
+    DBG_ERROR(0, "Error on importContext");
+    GWEN_Dialog_free(dlg);
+    AB_ImExporterContext_free(ctx);
+    return false;
+  }
+
+  GWEN_Dialog_free(dlg);
+  AB_ImExporterContext_free(ctx);
+  return true;
+}
 
 
 
diff --git a/kmymoney/plugins/kbanking/kbanking.h b/kmymoney/plugins/kbanking/kbanking.h
index 2df2aed40750b514c3f8e2c79785e97b278cada8..330c16abbb73cb7f50b3dff46bbc443dd72211ca 100644
--- a/kmymoney/plugins/kbanking/kbanking.h
+++ b/kmymoney/plugins/kbanking/kbanking.h
@@ -23,7 +23,7 @@
 
 #include <aqbanking/version.h>
 #include <aqbanking/banking.h>
-#include <q4banking/qbanking.h>
+#include "banking.hpp"
 
 #ifndef AQB_MAKE_VERSION
 #define AQB_MAKE_VERSION(a,b,c,d) (((a)<<24) | ((b)<<16) | (c<<8) | (d))
@@ -39,13 +39,13 @@
 
 #ifndef KBANKING_GUIID
 #if AQB_IS_VERSION(4,99,0,0)
-#  define AB_BANKING_QBANKING_EXECUTE_JOBS(a, b) QBanking::executeJobs(a, b)
+#  define AB_BANKING_QBANKING_EXECUTE_JOBS(a, b) AB_Banking::executeJobs(a, b)
 #  define AB_BANKING_JOB_CHECKAVAILABILITY(a) AB_Job_CheckAvailability(a)
 #  define AB_BANKING_GETACCOUNTBYALIAS(a, b) AB_Banking_GetAccountByAlias(a, b)
 #elif AQB_IS_VERSION(3,9,0,0)
 #  define onlineInit() onlineInit(0)
 #  define onlineFini() onlineFini(0)
-#  define AB_BANKING_QBANKING_EXECUTE_JOBS(a, b) QBanking::executeJobs(a, b, 0)
+#  define AB_BANKING_QBANKING_EXECUTE_JOBS(a, b) AB_Banking::executeJobs(a, b, 0)
 #  define AB_BANKING_GETACCOUNTBYALIAS(a, b) AB_Banking_GetAccountByAlias(a, b, 0)
 #  define AB_BANKING_JOB_CHECKAVAILABILITY(a) AB_Job_CheckAvailability(a, 0)
 #else
@@ -57,7 +57,7 @@
 #include <list>
 
 
-class KBanking: public QBanking
+class KBanking: public AB_Banking
 {
 private:
   AB_JOB_LIST2 *_jobQueue;
@@ -76,6 +76,11 @@ public:
   int dequeueJob(AB_JOB *j);
   std::list<AB_JOB*> getEnqueuedJobs();
 
+  bool askMapAccount(const char *id,
+		     const char *bankCode,
+		     const char *accountId);
+
+  virtual bool interactiveImport();
 };
 
 
diff --git a/kmymoney/plugins/kbanking/mymoneybanking.cpp b/kmymoney/plugins/kbanking/mymoneybanking.cpp
index 9e9c97bfeda3afc066c6bdde562220df6332f15d..ab8569093191821a9c7099e153d5371362f6ca9e 100644
--- a/kmymoney/plugins/kbanking/mymoneybanking.cpp
+++ b/kmymoney/plugins/kbanking/mymoneybanking.cpp
@@ -59,9 +59,11 @@
 #include <aqbanking/jobgettransactions.h>
 #include <aqbanking/jobgetbalance.h>
 #include <aqbanking/job.h>
-#include <q4banking/qbgui.h>
+#include <aqbanking/abgui.h>
+#include <aqbanking/dlg_setup.h>
 #include <gwenhywfar/logger.h>
 #include <gwenhywfar/debug.h>
+#include <gwen-gui-qt4/qt4_gui.hpp>
 
 // ----------------------------------------------------------------------------
 // Project Includes
@@ -123,7 +125,7 @@ KBankingPlugin::KBankingPlugin(QObject *parent, const QStringList&) :
   m_kbanking = new KMyMoneyBanking(this, "KMyMoney");
 
   if (m_kbanking) {
-    QBGui *gui;
+    QT4_Gui *gui;
 
 #if AQB_IS_VERSION(4,99,0,0)
     if (AB_Banking_HasConf4(m_kbanking->getCInterface())) {
@@ -155,17 +157,19 @@ KBankingPlugin::KBankingPlugin(QObject *parent, const QStringList&) :
     }
 #endif
 
-    gui = new QBGui(m_kbanking);
+    gui = new QT4_Gui();
     GWEN_Gui_SetGui(gui->getCInterface());
     GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);
     GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Debug);
-    m_kbanking->setGui(gui);
     if (m_kbanking->init() == 0) {
       // Tell the host application to load my GUI component
       setComponentData(KGenericFactory<KBankingPlugin>::componentData());
       setXMLFile("kmm_kbanking.rc");
       qDebug("KMyMoney kbanking plugin loaded");
 
+      // get certificate handling and dialog settings management
+      AB_Gui_Extend(gui->getCInterface(), m_kbanking->getCInterface());
+
       // create view
       createJobView();
 
@@ -298,15 +302,24 @@ void KBankingPlugin::createActions(void)
 
 void KBankingPlugin::slotSettings(void)
 {
-  QPointer<KBankingSettings> bs = new KBankingSettings(m_kbanking);
-  if (bs->init())
-    qWarning("Error on ini of settings dialog.");
-  else {
-    bs->exec();
-    if (bs && bs->fini())
-      qWarning("Error on fini of settings dialog.");
+  if (m_kbanking) {
+    GWEN_DIALOG *dlg;
+    int rv;
+
+    dlg=AB_SetupDialog_new(m_kbanking->getCInterface());
+    if (dlg==NULL) {
+      DBG_ERROR(0, "Could not create setup dialog.");
+      return;
+    }
+
+    rv=GWEN_Gui_ExecDialog(dlg, 0);
+    if (rv==0) {
+      DBG_ERROR(0, "Aborted by user");
+      GWEN_Dialog_free(dlg);
+      return;
+    }
+    GWEN_Dialog_free(dlg);
   }
-  delete bs;
 }
 
 bool KBankingPlugin::mapAccount(const MyMoneyAccount& acc, MyMoneyKeyValueContainer& settings)
@@ -506,8 +519,8 @@ bool KBankingPlugin::updateAccount(const MyMoneyAccount& acc, bool moreAccounts)
           // and the qd is invalid
           if (dateOption == 0
               || (dateOption > 1 && !qd.isValid())) {
-            QPointer<KBPickStartDate> psd = new KBPickStartDate(m_kbanking, qd, lastUpdate, acc.name(),
-                lastUpdate.isValid() ? 2 : 3, 0, true);
+            QPointer<KBPickStartDate> psd = new KBPickStartDate(qd, lastUpdate, acc.name(),
+								lastUpdate.isValid() ? 2 : 3, 0, true);
             if (psd->exec() != QDialog::Accepted) {
               AB_Job_free(job);
               delete psd;
@@ -607,9 +620,6 @@ bool KBankingPlugin::updateAccount(const MyMoneyAccount& acc, bool moreAccounts)
           DBG_ERROR(0, "Error: %d", rv);
         }
         AB_ImExporterContext_free(ctx);
-
-        // let application emit signals to inform views
-        m_kbanking->accountsUpdated();
       }
       rc = true;
     }
diff --git a/kmymoney/plugins/kbanking/views/kbjobview.cpp b/kmymoney/plugins/kbanking/views/kbjobview.cpp
index 39b6f52e6b97efa865aec91ce8b8536564178e87..2fa004b29493f5365b09b06e291f8c0bc768f4ca 100644
--- a/kmymoney/plugins/kbanking/views/kbjobview.cpp
+++ b/kmymoney/plugins/kbanking/views/kbjobview.cpp
@@ -64,8 +64,6 @@ KBJobView::KBJobView(KBanking *kb,
   m_jobList = new KBJobListView(jobBox);
   jobBoxLayout->addWidget(m_jobList);
 
-  QObject::connect(m_app->flagStaff(), SIGNAL(signalQueueUpdated()),
-                   this, SLOT(slotQueueUpdated()));
   QObject::connect(executeButton, SIGNAL(clicked()),
                    this, SLOT(slotExecute()));
   QObject::connect(dequeueButton, SIGNAL(clicked()),
@@ -154,9 +152,6 @@ void KBJobView::slotExecute()
     DBG_ERROR(0, "Error: %d", rv);
   }
   AB_ImExporterContext_free(ctx);
-
-  // let App emit signals to inform account views
-  m_app->accountsUpdated();
 }
 
 
diff --git a/kmymoney/plugins/kbanking/widgets/CMakeLists.txt b/kmymoney/plugins/kbanking/widgets/CMakeLists.txt
index cbc75c2fd8910835e324940009c4b72dc2f87cfb..2e0ba792c670bc32fd8c661cea9bc5f352bc4f9e 100644
--- a/kmymoney/plugins/kbanking/widgets/CMakeLists.txt
+++ b/kmymoney/plugins/kbanking/widgets/CMakeLists.txt
@@ -2,6 +2,7 @@
 ########### next target ###############
 
 SET(kmm_kbanking_widgets_la_SOURCES
+    kbaccountlist.cpp
     kbjoblist.cpp
     )
 
diff --git a/kmymoney/plugins/kbanking/widgets/kbaccountlist.cpp b/kmymoney/plugins/kbanking/widgets/kbaccountlist.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..53e1f4cc383dc6a738bf0d65a8859d317b23640f
--- /dev/null
+++ b/kmymoney/plugins/kbanking/widgets/kbaccountlist.cpp
@@ -0,0 +1,226 @@
+/***************************************************************************
+    begin       : Mon Mar 01 2004
+    copyright   : (C) 2004 by Martin Preuss
+    email       : martin@libchipcard.de
+
+ ***************************************************************************
+ *          Please see toplevel file COPYING for license details           *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config-kmymoney.h>
+#endif
+
+
+#include "kbaccountlist.h"
+#include <assert.h>
+#include <QtCore/qstring.h>
+
+
+
+KBAccountListViewItem::KBAccountListViewItem(KBAccountListView *parent,
+					     AB_ACCOUNT *acc)
+:K3ListViewItem(parent)
+,_account(acc){
+  assert(acc);
+  _populate();
+}
+
+
+
+KBAccountListViewItem::KBAccountListViewItem(const KBAccountListViewItem &item)
+:K3ListViewItem(item)
+,_account(0){
+
+  if (item._account) {
+    _account=item._account;
+  }
+}
+
+
+KBAccountListViewItem::KBAccountListViewItem(KBAccountListView *parent,
+					     K3ListViewItem *after,
+					     AB_ACCOUNT *acc)
+:K3ListViewItem(parent, after)
+,_account(acc){
+  assert(acc);
+  _populate();
+}
+
+
+
+KBAccountListViewItem::~KBAccountListViewItem(){
+}
+
+
+
+AB_ACCOUNT *KBAccountListViewItem::getAccount(){
+  return _account;
+}
+
+
+void KBAccountListViewItem::_populate() {
+  QString tmp;
+  int i;
+
+  assert(_account);
+
+  i=0;
+
+  // unique id
+  setText(i++, QString::number(AB_Account_GetUniqueId(_account)));
+
+  // bank code
+  setText(i++, QString::fromUtf8(AB_Account_GetBankCode(_account)));
+
+  // bank name
+  tmp=AB_Account_GetBankName(_account);
+  if (tmp.isEmpty())
+    tmp="(unnamed)";
+  setText(i++,tmp);
+
+  // account id
+  setText(i++, QString::fromUtf8(AB_Account_GetAccountNumber(_account)));
+
+  // account name
+  tmp=QString::fromUtf8(AB_Account_GetAccountName(_account));
+  if (tmp.isEmpty())
+    tmp="(unnamed)";
+  setText(i++, tmp);
+
+  tmp=QString::fromUtf8(AB_Account_GetOwnerName(_account));
+  if (tmp.isEmpty())
+    tmp="";
+  setText(i++, tmp);
+
+  tmp=QString::fromUtf8(AB_Provider_GetName(AB_Account_GetProvider(_account)));
+  if (tmp.isEmpty())
+    tmp="(unknown)";
+  setText(i++, tmp);
+
+}
+
+
+
+QString KBAccountListViewItem::key(int column, bool) const {
+  QString result;
+
+  if (column==0) {
+    ulong i;
+    bool ok;
+
+    // id
+    i=text(column).toULong(&ok);
+    if (ok) {
+      char numbuf[32];
+
+      snprintf(numbuf, sizeof(numbuf), "%012lu", i);
+      result=QString(numbuf);
+    }
+    else
+      result=text(column);
+  }
+  else
+    result=text(column);
+
+  return result;
+}
+
+
+
+
+
+
+
+
+
+KBAccountListView::KBAccountListView(QWidget *parent)
+:K3ListView(parent){
+  setAllColumnsShowFocus(true);
+  setShowSortIndicator(true);
+  addColumn(QWidget::tr("Id"),-1);
+  addColumn(QWidget::tr("Institute Code"),-1);
+  addColumn(QWidget::tr("Institute Name"),-1);
+  addColumn(QWidget::tr("Account Number"),-1);
+  addColumn(QWidget::tr("Account Name"),-1);
+  addColumn(QWidget::tr("Owner"),-1);
+  addColumn(QWidget::tr("Backend"),-1);
+}
+
+
+
+KBAccountListView::~KBAccountListView(){
+}
+
+
+
+void KBAccountListView::addAccount(AB_ACCOUNT *acc){
+  KBAccountListViewItem *entry;
+
+  entry=new KBAccountListViewItem(this, acc);
+}
+
+
+
+void KBAccountListView::addAccounts(const std::list<AB_ACCOUNT*> &accs){
+  std::list<AB_ACCOUNT*>::const_iterator it;
+
+  for (it=accs.begin(); it!=accs.end(); it++) {
+    KBAccountListViewItem *entry;
+
+    entry=new KBAccountListViewItem(this, *it);
+  } /* for */
+}
+
+
+
+AB_ACCOUNT *KBAccountListView::getCurrentAccount() {
+  KBAccountListViewItem *entry;
+
+  entry=dynamic_cast<KBAccountListViewItem*>(currentItem());
+  if (!entry) {
+    return 0;
+  }
+  return entry->getAccount();
+}
+
+
+
+std::list<AB_ACCOUNT*> KBAccountListView::getSelectedAccounts(){
+  std::list<AB_ACCOUNT*> accs;
+  KBAccountListViewItem *entry;
+
+  // Create an iterator and give the listview as argument
+  Q3ListViewItemIterator it(this);
+  // iterate through all items of the listview
+  for (;it.current();++it) {
+    if (it.current()->isSelected()) {
+      entry=dynamic_cast<KBAccountListViewItem*>(it.current());
+      if (entry)
+        accs.push_back(entry->getAccount());
+    }
+  } // for
+
+  return accs;
+}
+
+
+
+std::list<AB_ACCOUNT*> KBAccountListView::getSortedAccounts() {
+  std::list<AB_ACCOUNT*> accs;
+  KBAccountListViewItem *entry;
+
+  // Create an iterator and give the listview as argument
+  Q3ListViewItemIterator it(this);
+  // iterate through all items of the listview
+  for (;it.current();++it) {
+    entry=dynamic_cast<KBAccountListViewItem*>(it.current());
+    if (entry)
+      accs.push_back(entry->getAccount());
+  } // for
+
+  return accs;
+}
+
+
+
diff --git a/kmymoney/plugins/kbanking/widgets/kbaccountlist.h b/kmymoney/plugins/kbanking/widgets/kbaccountlist.h
new file mode 100644
index 0000000000000000000000000000000000000000..91c72b83bccd4e9ca753760b9301770052759356
--- /dev/null
+++ b/kmymoney/plugins/kbanking/widgets/kbaccountlist.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+    begin       : Mon Mar 01 2004
+    copyright   : (C) 2004 by Martin Preuss
+    email       : martin@libchipcard.de
+
+ ***************************************************************************
+ *          Please see toplevel file COPYING for license details           *
+ ***************************************************************************/
+
+#ifndef Q4BANKING_ACCOUNTLIST_H
+#define Q4BANKING_ACCOUNTLIST_H
+
+
+#include <k3listview.h>
+#include <aqbanking/account.h>
+
+#include <list>
+
+class KBAccountListView;
+class KBAccountListViewItem;
+
+
+class KBAccountListViewItem: public K3ListViewItem {
+private:
+  AB_ACCOUNT *_account;
+
+  void _populate();
+
+public:
+  KBAccountListViewItem(KBAccountListView *parent, AB_ACCOUNT *acc);
+  KBAccountListViewItem(KBAccountListView *parent,
+                        K3ListViewItem *after,
+                        AB_ACCOUNT *acc);
+  KBAccountListViewItem(const KBAccountListViewItem &item);
+
+  virtual ~KBAccountListViewItem();
+
+  AB_ACCOUNT *getAccount();
+
+  QString key(int column, bool ascending) const;
+};
+
+
+
+class KBAccountListView: public K3ListView {
+private:
+public:
+  KBAccountListView(QWidget *parent=0);
+  virtual ~KBAccountListView();
+
+  void addAccount(AB_ACCOUNT *acc);
+  void addAccounts(const std::list<AB_ACCOUNT*> &accs);
+
+  AB_ACCOUNT *getCurrentAccount();
+  std::list<AB_ACCOUNT*> getSelectedAccounts();
+
+  std::list<AB_ACCOUNT*> getSortedAccounts();
+
+};
+
+
+
+
+#endif /* QBANKING_ACCOUNTLIST_H */
+
+
+
openSUSE Build Service is sponsored by