[73414] trunk/dports/kde/kmymoney4
mk at macports.org
mk at macports.org
Fri Nov 12 15:08:46 PST 2010
Revision: 73414
http://trac.macports.org/changeset/73414
Author: mk at macports.org
Date: 2010-11-12 15:08:42 -0800 (Fri, 12 Nov 2010)
Log Message:
-----------
kmymoney4: supply patch to make HBCI work (kbanking plugin)
Modified Paths:
--------------
trunk/dports/kde/kmymoney4/Portfile
Added Paths:
-----------
trunk/dports/kde/kmymoney4/files/
trunk/dports/kde/kmymoney4/files/patch_for_kbanking.diff
Modified: trunk/dports/kde/kmymoney4/Portfile
===================================================================
--- trunk/dports/kde/kmymoney4/Portfile 2010-11-12 23:01:48 UTC (rev 73413)
+++ trunk/dports/kde/kmymoney4/Portfile 2010-11-12 23:08:42 UTC (rev 73414)
@@ -8,7 +8,7 @@
name kmymoney4
version 4.5
-revision 3
+revision 4
categories kde finance
maintainers mk pixilla.com:brad openmaintainer
@@ -49,9 +49,15 @@
- some reports let the app hang \n \
- some fonts seem to be missing, since \n \
layout looks inhomogenious \n \
- - kmm_banking plugin doesn't work yet \n \
\n \
============================================== \n \
"
}
+patchfiles patch_for_kbanking.diff
+
+patch.dir ${workpath}/${distname}
+patch.pre_args -p1
+
+configure.args-append -DENABLE_KBANKING=ON
+
Added: trunk/dports/kde/kmymoney4/files/patch_for_kbanking.diff
===================================================================
--- trunk/dports/kde/kmymoney4/files/patch_for_kbanking.diff (rev 0)
+++ trunk/dports/kde/kmymoney4/files/patch_for_kbanking.diff 2010-11-12 23:08:42 UTC (rev 73414)
@@ -0,0 +1,3587 @@
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/cmake/modules/FindAqBanking.cmake kmymoney-4.5.patched/cmake/modules/FindAqBanking.cmake
+--- kmymoney-4.5/cmake/modules/FindAqBanking.cmake 2010-11-12 02:27:25.000000000 +0100
++++ kmymoney-4.5.patched/cmake/modules/FindAqBanking.cmake 2010-11-12 02:09:27.000000000 +0100
+@@ -8,14 +8,17 @@
+ set(AQBANKING_FOUND FALSE)
+
+ if(NOT AQBANKING_MIN_VERSION)
+- set(AQBANKING_MIN_VERSION "4.2.4")
++ set(AQBANKING_MIN_VERSION "5.0.0")
+ 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,10 @@
+ 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_FOUND})
+- # if AqBanking has been found make sure to add the q4banking lib
+- set(AQBANKING_LIBRARIES ${AQBANKING_LIBRARIES} q4banking)
+-endif(${AQBANKING_FOUND})
++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)
+
+ mark_as_advanced(AQBANKING_INCLUDE_DIRS AQBANKING_LIBRARIES)
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/cmake/modules/FindGwenhywfar.cmake kmymoney-4.5.patched/cmake/modules/FindGwenhywfar.cmake
+--- kmymoney-4.5/cmake/modules/FindGwenhywfar.cmake 2010-11-12 02:27:25.000000000 +0100
++++ kmymoney-4.5.patched/cmake/modules/FindGwenhywfar.cmake 2010-11-12 02:09:27.000000000 +0100
+@@ -8,7 +8,7 @@
+ set(GWENHYWFAR_FOUND FALSE)
+
+ if(NOT GWENHYWFAR_MIN_VERSION)
+- set(GWENHYWFAR_MIN_VERSION "3.10.1")
++ set(GWENHYWFAR_MIN_VERSION "4.0.0")
+ endif(NOT GWENHYWFAR_MIN_VERSION)
+
+ if(GWENHYWFAR_INCLUDE_DIRS AND GWENHYWFAR_LIBRARIES)
+@@ -19,12 +19,23 @@
+ 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})
++ 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})
++
++ 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 --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/CMakeLists.txt kmymoney-4.5.patched/kmymoney/plugins/kbanking/CMakeLists.txt
+--- kmymoney-4.5/kmymoney/plugins/kbanking/CMakeLists.txt 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/CMakeLists.txt 2010-11-12 02:09:27.000000000 +0100
+@@ -17,7 +17,10 @@
+
+ ########### next target ###############
+
+-SET(kmm_kbanking_PART_SRCS kbanking.cpp mymoneybanking.cpp)
++SET(kmm_kbanking_PART_SRCS
++ mymoneybanking.cpp
++ banking.cpp
++ )
+
+ KDE4_ADD_PLUGIN(kmm_kbanking ${kmm_kbanking_PART_SRCS})
+
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/banking.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/banking.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/banking.cpp 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/banking.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,462 @@
++/***************************************************************************
++ begin : Mon Mar 01 2004
++ copyright : (C) 2004 by Martin Preuss
++ email : martin at 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 --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/banking.hpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/banking.hpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/banking.hpp 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/banking.hpp 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,185 @@
++/***************************************************************************
++ begin : Mon Mar 01 2004
++ copyright : (C) 2004 by Martin Preuss
++ email : martin at 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 at 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 --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/CMakeLists.txt 2010-11-12 02:09:27.000000000 +0100
+@@ -4,12 +4,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 --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbmapaccount.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbmapaccount.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbmapaccount.cpp 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbmapaccount.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,111 @@
++/***************************************************************************
++ begin : Mon Mar 01 2004
++ copyright : (C) 2004 by Martin Preuss
++ email : martin at 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 "mymoneybanking.h"
++
++// QT includes
++#include <qlabel.h>
++#include <qpushbutton.h>
++#include <qmessagebox.h>
++#include <qlayout.h>
++#include <qpushbutton.h>
++#include <qlineedit.h>
++
++
++
++
++KBMapAccount::KBMapAccount(KMyMoneyBanking *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(QAbstractItemView::SingleSelection);
++
++ 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(itemSelectionChanged()),
++ 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 --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbmapaccount.h kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbmapaccount.h
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbmapaccount.h 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbmapaccount.h 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,54 @@
++/***************************************************************************
++ begin : Mon Mar 01 2004
++ copyright : (C) 2004 by Martin Preuss
++ email : martin at libchipcard.de
++
++ ***************************************************************************
++ * Please see toplevel file COPYING for license details *
++ ***************************************************************************/
++
++#ifndef QBANKING_MAPACCOUNT_H
++#define QBANKING_MAPACCOUNT_H
++
++#include "mymoneybanking.h"
++#include "kbaccountlist.h"
++#include "ui_kbmapaccount.h"
++
++#include <aqbanking/account.h>
++
++
++class KMyMoneyBanking;
++
++
++class KBMapAccount: public QDialog
++{
++ Q_OBJECT
++public:
++ KBMapAccount(KMyMoneyBanking *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;
++ KMyMoneyBanking *_banking;
++ AB_ACCOUNT *_account;
++ KBAccountListView *_accountList;
++};
++
++
++
++
++
++#endif /* QBANKING_MAPACCOUNT_H */
++
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbmapaccount.ui kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbmapaccount.ui
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbmapaccount.ui 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbmapaccount.ui 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,183 @@
++<?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>743</width>
++ <height>534</height>
++ </rect>
++ </property>
++ <property name="windowTitle">
++ <string>Account Mapping</string>
++ </property>
++ <layout class="QVBoxLayout">
++ <item>
++ <widget class="QLabel" name="textLabel1">
++ <property name="text">
++ <string><qt>
++Please choose the <b>online</b> account you want the
++<b>application</b> account to be mapped to from the list below.
++</qt></string>
++ </property>
++ <property name="wordWrap">
++ <bool>false</bool>
++ </property>
++ </widget>
++ </item>
++ <item>
++ <widget class="QGroupBox" 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="QGroupBox" 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>KBAccountListView</class>
++ <extends>QWidget</extends>
++ <header>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>676</x>
++ <y>521</y>
++ </hint>
++ <hint type="destinationlabel">
++ <x>512</x>
++ <y>430</y>
++ </hint>
++ </hints>
++ </connection>
++ <connection>
++ <sender>assignButton</sender>
++ <signal>clicked()</signal>
++ <receiver>KBMapAccountUi</receiver>
++ <slot>accept()</slot>
++ <hints>
++ <hint type="sourcelabel">
++ <x>590</x>
++ <y>521</y>
++ </hint>
++ <hint type="destinationlabel">
++ <x>452</x>
++ <y>459</y>
++ </hint>
++ </hints>
++ </connection>
++ </connections>
++</ui>
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -25,7 +25,6 @@
+
+ // QBanking includes
+ #include "kbpickstartdate.h"
+-#include <q4banking/qbanking.h>
+
+ // Gwenhywfar includes
+ #include <gwenhywfar/debug.h>
+@@ -46,7 +45,7 @@
+
+
+
+-KBPickStartDate::KBPickStartDate(QBanking *qb,
++KBPickStartDate::KBPickStartDate(KMyMoneyBanking* qb,
+ const QDate &firstPossible,
+ const QDate &lastUpdate,
+ const QString& accountName,
+@@ -139,6 +138,5 @@
+
+ void KBPickStartDate::slotHelpClicked()
+ {
+- _banking->invokeHelp("KBPickStartDate", "none");
+ }
+
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbpickstartdate.h 2010-11-12 02:09:27.000000000 +0100
+@@ -25,8 +25,7 @@
+ #include <QDateTime>
+ #include <QDialog>
+
+-
+-class QBanking;
++#include "mymoneybanking.h"
+
+ /**
+ * Class derived from QBPickStartDate and modified to
+@@ -39,11 +38,11 @@
+ {
+ Q_OBJECT
+ private:
+- QBanking *_banking;
++ KMyMoneyBanking *_banking;
+ const QDate &_firstPossible;
+ const QDate &_lastUpdate;
+ public:
+- KBPickStartDate(QBanking *banking,
++ KBPickStartDate(KMyMoneyBanking* qb,
+ const QDate &firstPossible,
+ const QDate &lastUpdate,
+ const QString& accountName,
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbsettings.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -1,58 +0,0 @@
+-/***************************************************************************
+- * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
+- * Copyright 2004 Martin Preuss aquamaniac at users.sourceforge.net *
+- * *
+- * 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) version 3 or any later version *
+- * accepted by the membership of KDE e.V. (or its successor approved *
+- * by the membership of KDE e.V.), which shall act as a proxy *
+- * defined in Section 14 of version 3 of the license. *
+- * *
+- * 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. If not, see <http://www.gnu.org/licenses/> *
+- ***************************************************************************/
+-#ifdef HAVE_CONFIG_H
+-# include <config-kmymoney.h>
+-#endif
+-
+-#include "kbsettings.h"
+-
+-#include <gwenhywfar/debug.h>
+-
+-KBankingSettings::KBankingSettings(KBanking *ab,
+- QWidget* parent,
+- const char* name,
+- Qt::WFlags fl)
+- : QBCfgTabSettings(ab, parent, name, fl)
+-{
+- addUsersPage();
+- addAccountsPage();
+- addBackendsPage();
+-}
+-
+-KBankingSettings::~KBankingSettings()
+-{
+-}
+-
+-int KBankingSettings::init()
+-{
+- if (!toGui()) {
+- DBG_ERROR(0, "Could not init dialog");
+- return -1;
+- }
+- return 0;
+-}
+-
+-int KBankingSettings::fini()
+-{
+- if (!fromGui())
+- return -1;
+- return 0;
+-}
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbsettings.h kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbsettings.h
+--- kmymoney-4.5/kmymoney/plugins/kbanking/dialogs/kbsettings.h 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/dialogs/kbsettings.h 2010-11-12 02:09:27.000000000 +0100
+@@ -1,40 +0,0 @@
+-/***************************************************************************
+- * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
+- * Copyright 2004 Martin Preuss aquamaniac at users.sourceforge.net *
+- * *
+- * 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) version 3 or any later version *
+- * accepted by the membership of KDE e.V. (or its successor approved *
+- * by the membership of KDE e.V.), which shall act as a proxy *
+- * defined in Section 14 of version 3 of the license. *
+- * *
+- * 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. If not, see <http://www.gnu.org/licenses/> *
+- ***************************************************************************/
+-#ifndef KBANKING_KBSETTINGS_H
+-#define KBANKING_KBSETTINGS_H
+-
+-#include "kbanking.h"
+-#include <q4banking/qbcfgtabsettings.h>
+-
+-class KBankingSettings: public QBCfgTabSettings
+-{
+-private:
+-public:
+- explicit KBankingSettings(KBanking *ab,
+- QWidget* parent = 0,
+- const char* name = 0, Qt::WFlags fl = 0);
+- ~KBankingSettings();
+-
+- int init();
+- int fini();
+-};
+-
+-#endif /* KBANKING_KBSETTINGS_H */
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/kbanking.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/kbanking.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/kbanking.cpp 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/kbanking.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -1,162 +0,0 @@
+-/***************************************************************************
+- * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
+- * Copyright 2004 Martin Preuss aquamaniac at users.sourceforge.net *
+- * *
+- * 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) version 3 or any later version *
+- * accepted by the membership of KDE e.V. (or its successor approved *
+- * by the membership of KDE e.V.), which shall act as a proxy *
+- * defined in Section 14 of version 3 of the license. *
+- * *
+- * 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. If not, see <http://www.gnu.org/licenses/> *
+- ***************************************************************************/
+-#ifdef HAVE_CONFIG_H
+-# include <config-kmymoney.h>
+-#endif
+-
+-
+-#include "kbanking.h"
+-
+-#include <assert.h>
+-#include <QString>
+-#include <QMessageBox>
+-#include <QInputDialog>
+-#include <QApplication>
+-#include <QDateTime>
+-#include <QWidget>
+-
+-#include <gwenhywfar/debug.h>
+-#include <gwenhywfar/text.h>
+-
+-KBanking::KBanking(const char *appname,
+- const char *cfgDir) :
+- QBanking(appname, cfgDir),
+- _jobQueue(0)
+-{
+-}
+-
+-
+-
+-KBanking::~KBanking()
+-{
+-}
+-
+-
+-
+-int KBanking::init()
+-{
+- int rv;
+-
+- rv = QBanking::init();
+- if (rv < 0)
+- return rv;
+-
+- rv = onlineInit();
+- if (rv) {
+- fprintf(stderr, "Error on online init (%d).\n", rv);
+- QBanking::fini();
+- return rv;
+- }
+-
+- _jobQueue = AB_Job_List2_new();
+-
+- return 0;
+-}
+-
+-
+-
+-int KBanking::fini()
+-{
+- int rv;
+-
+- if (_jobQueue) {
+- AB_Job_List2_FreeAll(_jobQueue);
+- _jobQueue = 0;
+- }
+-
+- rv = onlineFini();
+- if (rv) {
+- QBanking::fini();
+- return rv;
+- }
+- return QBanking::fini();
+-}
+-
+-
+-
+-int KBanking::executeQueue(AB_IMEXPORTER_CONTEXT *ctx)
+-{
+- int rv;
+- AB_JOB_LIST2 *oldQ;
+-
+- rv = AB_BANKING_QBANKING_EXECUTE_JOBS(_jobQueue, ctx);
+- oldQ = _jobQueue;
+- _jobQueue = AB_Job_List2_new();
+- flagStaff()->queueUpdated();
+- AB_Job_List2_FreeAll(oldQ);
+- return rv;
+-}
+-
+-
+-
+-std::list<AB_JOB*> KBanking::getEnqueuedJobs()
+-{
+- AB_JOB_LIST2 *ll;
+- std::list<AB_JOB*> rl;
+-
+- ll = _jobQueue;
+- if (ll && AB_Job_List2_GetSize(ll)) {
+- AB_JOB *j;
+- AB_JOB_LIST2_ITERATOR *it;
+-
+- it = AB_Job_List2_First(ll);
+- assert(it);
+- j = AB_Job_List2Iterator_Data(it);
+- assert(j);
+- while (j) {
+- rl.push_back(j);
+- j = AB_Job_List2Iterator_Next(it);
+- }
+- AB_Job_List2Iterator_free(it);
+- }
+- return rl;
+-}
+-
+-
+-
+-int KBanking::enqueueJob(AB_JOB *j)
+-{
+- assert(_jobQueue);
+- assert(j);
+- AB_Job_Attach(j);
+- AB_Job_List2_PushBack(_jobQueue, j);
+- flagStaff()->queueUpdated();
+- return 0;
+-}
+-
+-
+-
+-int KBanking::dequeueJob(AB_JOB *j)
+-{
+- assert(_jobQueue);
+- AB_Job_List2_Remove(_jobQueue, j);
+- AB_Job_free(j);
+- flagStaff()->queueUpdated();
+- return 0;
+-}
+-
+-
+-
+-
+-
+-
+-
+-
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/kbanking.h kmymoney-4.5.patched/kmymoney/plugins/kbanking/kbanking.h
+--- kmymoney-4.5/kmymoney/plugins/kbanking/kbanking.h 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/kbanking.h 2010-11-12 02:09:27.000000000 +0100
+@@ -1,86 +0,0 @@
+-/***************************************************************************
+- * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
+- * Copyright 2004 Martin Preuss aquamaniac at users.sourceforge.net *
+- * *
+- * 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) version 3 or any later version *
+- * accepted by the membership of KDE e.V. (or its successor approved *
+- * by the membership of KDE e.V.), which shall act as a proxy *
+- * defined in Section 14 of version 3 of the license. *
+- * *
+- * 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. If not, see <http://www.gnu.org/licenses/> *
+- ***************************************************************************/
+-#ifndef KBANKING_KBANKING_H
+-#define KBANKING_KBANKING_H
+-
+-#include <aqbanking/version.h>
+-#include <aqbanking/banking.h>
+-#include <q4banking/qbanking.h>
+-
+-#ifndef AQB_MAKE_VERSION
+-#define AQB_MAKE_VERSION(a,b,c,d) (((a)<<24) | ((b)<<16) | (c<<8) | (d))
+-#endif
+-
+-#ifndef AQBANKING_VERSION
+-#define AQBANKING_VERSION AQB_MAKE_VERSION(AQBANKING_VERSION_MAJOR,AQBANKING_VERSION_MINOR,AQBANKING_VERSION_PATCHLEVEL,AQBANKING_VERSION_BUILD)
+-#endif
+-
+-#ifndef AQB_IS_VERSION
+-#define AQB_IS_VERSION(a,b,c,d) (AQBANKING_VERSION >= AQB_MAKE_VERSION(a,b,c,d))
+-#endif
+-
+-#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_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_GETACCOUNTBYALIAS(a, b) AB_Banking_GetAccountByAlias(a, b, 0)
+-# define AB_BANKING_JOB_CHECKAVAILABILITY(a) AB_Job_CheckAvailability(a, 0)
+-#else
+-# define AB_BANKING_GETACCOUNTBYALIAS(a, b) AB_Banking_GetAccountByAlias(a, b)
+-#endif
+-#endif
+-
+-
+-#include <list>
+-
+-
+-class KBanking: public QBanking
+-{
+-private:
+- AB_JOB_LIST2 *_jobQueue;
+-
+-public:
+- explicit KBanking(const char *appname,
+- const char *cfgDir = 0);
+- virtual ~KBanking();
+-
+- int init();
+- int fini();
+-
+- int executeQueue(AB_IMEXPORTER_CONTEXT *ctx);
+-
+- int enqueueJob(AB_JOB *j);
+- int dequeueJob(AB_JOB *j);
+- std::list<AB_JOB*> getEnqueuedJobs();
+-
+-};
+-
+-
+-
+-
+-#endif /* KBANKING_KBANKING_H */
+-
+-
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/kmm_kbanking.desktop kmymoney-4.5.patched/kmymoney/plugins/kbanking/kmm_kbanking.desktop
+--- kmymoney-4.5/kmymoney/plugins/kbanking/kmm_kbanking.desktop 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/kmm_kbanking.desktop 2010-11-12 02:08:54.000000000 +0100
+@@ -1,9 +1,13 @@
+ [Desktop Entry]
+ Name=KBanking
++Name[ca]=KBanking
+ Name[cs]=KBanking
++Name[da]=KBanking
+ Name[de]=KBanking
++Name[el]=KBanking
+ Name[en_GB]=KBanking
+ Name[es]=KBanking
++Name[eu]=KBanking
+ Name[fr]=KBanking
+ Name[it]=KBanking
+ Name[nds]=KBanking
+@@ -14,9 +18,13 @@
+ Name[uk]=KBanking
+ Name[x-test]=xxKBankingxx
+ Comment=Add online banking to KMyMoney
++Comment[ca]=Afegeix la banca en línia al KMyMoney
++Comment[da]=Føj netbank til KMyMoney
+ Comment[de]=Fügt Onlinebanking zu KMyMoney hinzu
++Comment[el]=Προσθήκη τραπεζικών διαδικτυακών υπηρεσιών στο KMyMoney
+ Comment[en_GB]=Add online banking to KMyMoney
+ Comment[es]=Añade banca en línea a KMyMoney
++Comment[eu]=Erantsi lerroko bankua KMyMoney-ri
+ Comment[fr]=Ajoute des capacités de banque en ligne à KMyMoney
+ Comment[it]=Aggiungi l'online banking a KMyMoney
+ Comment[nl]=Voegt online bankieren toe aan KMyMoney
+@@ -32,7 +40,7 @@
+ X-KDE-PluginInfo-Name=KBanking
+ X-KDE-PluginInfo-Author=Martin Preuss,Thomas Baumgart
+ X-KDE-PluginInfo-Email=aquamaniac at users.sourceforge.net,ipwizard at users.sourceforge.net
+-X-KDE-PluginInfo-Version=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}
++X-KDE-PluginInfo-Version=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX}
+ X-KDE-PluginInfo-Website=http://kmymoney.org/plugins.html
+ X-KDE-PluginInfo-License=GPL
+ X-KDE-PluginInfo-EnabledByDefault=true
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.cpp 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -1,6 +1,7 @@
+ /***************************************************************************
+- * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
+ * Copyright 2004 Martin Preuss aquamaniac at users.sourceforge.net *
++ * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
++ * Copyright 2010 Thomas Baumgart ipwizard at users.sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+@@ -33,6 +34,7 @@
+ #include <QRegExp>
+ #include <QCheckBox>
+ #include <QLabel>
++#include <QTimer>
+
+ // ----------------------------------------------------------------------------
+ // KDE Includes
+@@ -59,9 +61,12 @@
+ #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 <aqbanking/dlg_importer.h>
+ #include <gwenhywfar/logger.h>
+ #include <gwenhywfar/debug.h>
++#include <gwen-gui-qt4/qt4_gui.hpp>
+
+ // ----------------------------------------------------------------------------
+ // Project Includes
+@@ -69,6 +74,7 @@
+ #include "kbjobview.h"
+ #include "kbsettings.h"
+ #include "kbaccountsettings.h"
++#include "kbmapaccount.h"
+ #include <kmymoney/mymoneyfile.h>
+ #include <kmymoney/kmymoneyview.h>
+ #include <kmymoney/mymoneykeyvaluecontainer.h>
+@@ -80,7 +86,7 @@
+ class KBankingPlugin::Private
+ {
+ public:
+- Private() {
++ Private() : passwordCacheTimer(0) {
+ QString gwenProxy = QString::fromLocal8Bit(qgetenv("GWEN_PROXY"));
+ if (gwenProxy.isEmpty()) {
+ KConfig *cfg = new KConfig("kioslaverc");
+@@ -112,6 +118,8 @@
+ delete cfg;
+ }
+ }
++
++ QTimer *passwordCacheTimer;
+ };
+
+ KBankingPlugin::KBankingPlugin(QObject *parent, const QStringList&) :
+@@ -122,10 +130,14 @@
+ {
+ m_kbanking = new KMyMoneyBanking(this, "KMyMoney");
+
++ d->passwordCacheTimer = new QTimer(this);
++ d->passwordCacheTimer->setSingleShot(true);
++ d->passwordCacheTimer->setInterval(60000);
++ connect(d->passwordCacheTimer, SIGNAL(timeout()), this, SLOT(slotClearPasswordCache()));
++
+ if (m_kbanking) {
+- QBGui *gui;
++ QT4_Gui *gui;
+
+-#if AQB_IS_VERSION(4,99,0,0)
+ if (AB_Banking_HasConf4(m_kbanking->getCInterface())) {
+ qDebug("KBankingPlugin: No AqB4 config found.");
+ if (AB_Banking_HasConf3(m_kbanking->getCInterface())) {
+@@ -139,33 +151,20 @@
+ AB_Banking_ImportConf3(m_kbanking->getCInterface());
+ }
+ }
+-#elif AQB_IS_VERSION(3,9,0,0)
+- if (AB_Banking_HasConf4(m_kbanking->getCInterface(), 0)) {
+- qDebug("KBankingPlugin: No AqB4 config found.");
+- if (AB_Banking_HasConf3(m_kbanking->getCInterface(), 0)) {
+- qDebug("KBankingPlugin: No AqB3 config found.");
+- if (!AB_Banking_HasConf2(m_kbanking->getCInterface(), 0)) {
+- qDebug("KBankingPlugin: AqB2 config found - converting.");
+- AB_Banking_ImportConf2(m_kbanking->getCInterface(), 0);
+- }
+- } else {
+- qDebug("KBankingPlugin: AqB3 config found - converting.");
+- AB_Banking_ImportConf3(m_kbanking->getCInterface(), 0);
+- }
+- }
+-#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();
+
+@@ -281,6 +280,7 @@
+ QWidget* w = new KBJobView(m_kbanking, view, "JobView");
+ viewInterface()->addWidget(view, w);
+ connect(viewInterface(), SIGNAL(viewStateChanged(bool)), view, SLOT(setEnabled(bool)));
++ connect(this, SIGNAL(queueChanged()), w, SLOT(slotQueueUpdated()));
+ }
+
+ void KBankingPlugin::createActions(void)
+@@ -298,15 +298,24 @@
+
+ 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)
+@@ -346,7 +355,7 @@
+ // at this point, the account should be mapped
+ // so we search it and setup the account reference in the KMyMoney object
+ AB_ACCOUNT* ab_acc;
+- ab_acc = AB_BANKING_GETACCOUNTBYALIAS(m_kbanking->getCInterface(), acc.id().toUtf8().data());
++ ab_acc = AB_Banking_GetAccountByAlias(m_kbanking->getCInterface(), acc.id().toUtf8().data());
+ if (ab_acc) {
+ MyMoneyAccount a(acc);
+ setupAccountReference(a, ab_acc);
+@@ -402,7 +411,7 @@
+ {
+ AB_ACCOUNT* ab_acc = 0;
+ if (m_kbanking)
+- ab_acc = AB_BANKING_GETACCOUNTBYALIAS(m_kbanking->getCInterface(), acc.id().toUtf8().data());
++ ab_acc = AB_Banking_GetAccountByAlias(m_kbanking->getCInterface(), acc.id().toUtf8().data());
+ return ab_acc != 0;
+ }
+
+@@ -427,7 +436,7 @@
+ QDate qd;
+
+ /* get AqBanking account */
+- ba = AB_BANKING_GETACCOUNTBYALIAS(m_kbanking->getCInterface(), acc.id().toUtf8().data());
++ ba = AB_Banking_GetAccountByAlias(m_kbanking->getCInterface(), acc.id().toUtf8().data());
+ if (!ba) {
+ KMessageBox::error(0,
+ i18n("<qt>"
+@@ -448,7 +457,7 @@
+ if (acc.onlineBankingSettings().value("kbanking-txn-download") != "no") {
+ /* create getTransactions job */
+ job = AB_JobGetTransactions_new(ba);
+- rv = AB_BANKING_JOB_CHECKAVAILABILITY(job);
++ rv = AB_Job_CheckAvailability(job);
+ if (rv) {
+ DBG_ERROR(0, "Job \"GetTransactions\" is not available (%d)", rv);
+ KMessageBox::error(0,
+@@ -540,7 +549,7 @@
+
+ /* create getBalance job */
+ job = AB_JobGetBalance_new(ba);
+- rv = AB_BANKING_JOB_CHECKAVAILABILITY(job);
++ rv = AB_Job_CheckAvailability(job);
+ if (!rv)
+ rv = m_kbanking->enqueueJob(job);
+ else
+@@ -559,6 +568,7 @@
+
+ // make sure, we have at least one job in the queue before we continue.
+ if (m_kbanking->getEnqueuedJobs().size() > 0) {
++ emit queueChanged();
+
+ // ask if the user want's to execute this job right away or spool it
+ // for later execution
+@@ -607,9 +617,6 @@
+ DBG_ERROR(0, "Error: %d", rv);
+ }
+ AB_ImExporterContext_free(ctx);
+-
+- // let application emit signals to inform views
+- m_kbanking->accountsUpdated();
+ }
+ rc = true;
+ }
+@@ -617,7 +624,17 @@
+ return rc;
+ }
+
++void KBankingPlugin::startPasswordTimer(void)
++{
++ if (d->passwordCacheTimer->isActive())
++ d->passwordCacheTimer->stop();
++ d->passwordCacheTimer->start();
++}
+
++void KBankingPlugin::slotClearPasswordCache(void)
++{
++ m_kbanking->clearPasswordCache();
++}
+
+ void KBankingPlugin::slotImport(void)
+ {
+@@ -644,11 +661,176 @@
+
+
+ KMyMoneyBanking::KMyMoneyBanking(KBankingPlugin* parent, const char* appname, const char* fname)
+- : KBanking(appname, fname)
++ : AB_Banking(appname, fname)
+ , m_parent(parent)
++ , _jobQueue(0)
++{
++}
++
++int KMyMoneyBanking::init()
++{
++ int rv;
++
++ rv = AB_Banking::init();
++ if (rv < 0)
++ return rv;
++
++ rv = onlineInit();
++ if (rv) {
++ fprintf(stderr, "Error on online init (%d).\n", rv);
++ AB_Banking::fini();
++ return rv;
++ }
++
++ _jobQueue = AB_Job_List2_new();
++
++ return 0;
++}
++
++int KMyMoneyBanking::fini()
+ {
++ int rv;
++
++ if (_jobQueue) {
++ AB_Job_List2_FreeAll(_jobQueue);
++ _jobQueue = 0;
++ }
++
++ rv = onlineFini();
++ if (rv) {
++ AB_Banking::fini();
++ return rv;
++ }
++ return AB_Banking::fini();
+ }
+
++int KMyMoneyBanking::executeQueue(AB_IMEXPORTER_CONTEXT *ctx)
++{
++ int rv;
++ AB_JOB_LIST2 *oldQ;
++
++ m_parent->startPasswordTimer();
++
++ rv = AB_Banking::executeJobs(_jobQueue, ctx);
++ oldQ = _jobQueue;
++ _jobQueue = AB_Job_List2_new();
++ AB_Job_List2_FreeAll(oldQ);
++
++ emit m_parent->queueChanged();
++ m_parent->startPasswordTimer();
++
++ return rv;
++}
++
++void KMyMoneyBanking::clearPasswordCache(void)
++{
++ /* clear password DB */
++ GWEN_Gui_SetPasswordStatus(NULL, NULL, GWEN_Gui_PasswordStatus_Remove, 0);
++}
++
++std::list<AB_JOB*> KMyMoneyBanking::getEnqueuedJobs()
++{
++ AB_JOB_LIST2 *ll;
++ std::list<AB_JOB*> rl;
++
++ ll = _jobQueue;
++ if (ll && AB_Job_List2_GetSize(ll)) {
++ AB_JOB *j;
++ AB_JOB_LIST2_ITERATOR *it;
++
++ it = AB_Job_List2_First(ll);
++ assert(it);
++ j = AB_Job_List2Iterator_Data(it);
++ assert(j);
++ while (j) {
++ rl.push_back(j);
++ j = AB_Job_List2Iterator_Next(it);
++ }
++ AB_Job_List2Iterator_free(it);
++ }
++ return rl;
++}
++
++int KMyMoneyBanking::enqueueJob(AB_JOB *j)
++{
++ assert(_jobQueue);
++ assert(j);
++ AB_Job_Attach(j);
++ AB_Job_List2_PushBack(_jobQueue, j);
++ return 0;
++}
++
++
++
++int KMyMoneyBanking::dequeueJob(AB_JOB *j)
++{
++ assert(_jobQueue);
++ AB_Job_List2_Remove(_jobQueue, j);
++ AB_Job_free(j);
++ emit m_parent->queueChanged();
++ return 0;
++}
++
++bool KMyMoneyBanking::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 KMyMoneyBanking::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;
++}
+
+
+ const AB_ACCOUNT_STATUS* KMyMoneyBanking::_getAccountStatus(AB_IMEXPORTER_ACCOUNTINFO *ai)
+@@ -716,11 +898,12 @@
+ GWEN_STRINGLISTENTRY *se;
+
+ se = GWEN_StringList_FirstEntry(sl);
+- if (se) {
++ while (se) {
+ p = GWEN_StringListEntry_Data(se);
+ assert(p);
+ s = QString::fromUtf8(p);
+- }
++ se = GWEN_StringListEntry_Next(se);
++ } // while
+ }
+ kt.m_strPayee = s;
+ h = MyMoneyTransaction::hash(s.trimmed());
+@@ -777,8 +960,8 @@
+ // - remove leading blanks
+ // - remove trailing blanks
+ // - reduce multiple blanks to one
+- kt.m_strMemo = kt.m_strMemo.trimmed();
+- kt.m_strPayee = kt.m_strPayee.trimmed();
++ kt.m_strMemo = kt.m_strMemo.simplified();
++ kt.m_strPayee = kt.m_strPayee.simplified();
+
+ // date
+ ti = AB_Transaction_GetDate(t);
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.cpp.orig kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.cpp.orig
+--- kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.cpp.orig 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.cpp.orig 2010-11-12 02:08:54.000000000 +0100
+@@ -0,0 +1,986 @@
++/***************************************************************************
++ * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
++ * Copyright 2004 Martin Preuss aquamaniac at users.sourceforge.net *
++ * *
++ * 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) version 3 or any later version *
++ * accepted by the membership of KDE e.V. (or its successor approved *
++ * by the membership of KDE e.V.), which shall act as a proxy *
++ * defined in Section 14 of version 3 of the license. *
++ * *
++ * 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. If not, see <http://www.gnu.org/licenses/> *
++ ***************************************************************************/
++#ifdef HAVE_CONFIG_H
++# include <config-kmymoney.h>
++#endif
++
++#include "mymoneybanking.h"
++
++// ----------------------------------------------------------------------------
++// QT Includes
++
++#include <QLayout>
++#include <QRadioButton>
++#include <QStringList>
++#include <QRegExp>
++#include <QCheckBox>
++#include <QLabel>
++
++// ----------------------------------------------------------------------------
++// KDE Includes
++
++#include <KLocale>
++#include <KMessageBox>
++#include <KGenericFactory>
++#include <KAction>
++#include <KActionCollection>
++#include <KGlobal>
++#include <KStandardDirs>
++#include <KMenu>
++#include <KIconLoader>
++#include <KGuiItem>
++#include <KLineEdit>
++#include <KEditListBox>
++#include <KComboBox>
++#include <KConfig>
++
++// ----------------------------------------------------------------------------
++// Library Includes
++
++#include <aqbanking/imexporter.h>
++#include <aqbanking/jobgettransactions.h>
++#include <aqbanking/jobgetbalance.h>
++#include <aqbanking/job.h>
++#include <q4banking/qbgui.h>
++#include <gwenhywfar/logger.h>
++#include <gwenhywfar/debug.h>
++
++// ----------------------------------------------------------------------------
++// Project Includes
++
++#include "kbjobview.h"
++#include "kbsettings.h"
++#include "kbaccountsettings.h"
++#include <kmymoney/mymoneyfile.h>
++#include <kmymoney/kmymoneyview.h>
++#include <kmymoney/mymoneykeyvaluecontainer.h>
++#include <kbpickstartdate.h>
++
++K_EXPORT_COMPONENT_FACTORY(kmm_kbanking,
++ KGenericFactory<KBankingPlugin>("kmm_kbanking"))
++
++class KBankingPlugin::Private
++{
++public:
++ Private() {
++ QString gwenProxy = QString::fromLocal8Bit(qgetenv("GWEN_PROXY"));
++ if (gwenProxy.isEmpty()) {
++ KConfig *cfg = new KConfig("kioslaverc");
++ QRegExp exp("(\\w+://)?([^/]{2}.+:\\d+)");
++ QString proxy;
++
++ KConfigGroup grp = cfg->group("Proxy Settings");
++ int type = grp.readEntry("ProxyType", 0);
++ switch (type) {
++ case 0: // no proxy
++ break;
++
++ case 1: // manual specified
++ proxy = grp.readEntry("httpsProxy");
++ qDebug("KDE https proxy setting is '%s'", qPrintable(proxy));
++ if (exp.exactMatch(proxy) != -1) {
++ proxy = exp.cap(2);
++ qDebug("Setting GWEN_PROXY to '%s'", qPrintable(proxy));
++ if (setenv("GWEN_PROXY", qPrintable(proxy), 1) == -1) {
++ qDebug("Unable to setup GWEN_PROXY");
++ }
++ }
++ break;
++
++ default: // other currently not supported
++ qDebug("KDE proxy setting of type %d not supported", type);
++ break;
++ }
++ delete cfg;
++ }
++ }
++};
++
++KBankingPlugin::KBankingPlugin(QObject *parent, const QStringList&) :
++ KMyMoneyPlugin::Plugin(parent, "KBanking"/*must be the same as X-KDE-PluginInfo-Name*/),
++ KMyMoneyPlugin::OnlinePlugin(),
++ d(new Private),
++ m_accountSettings(0)
++{
++ m_kbanking = new KMyMoneyBanking(this, "KMyMoney");
++
++ if (m_kbanking) {
++ QBGui *gui;
++
++#if AQB_IS_VERSION(4,99,0,0)
++ if (AB_Banking_HasConf4(m_kbanking->getCInterface())) {
++ qDebug("KBankingPlugin: No AqB4 config found.");
++ if (AB_Banking_HasConf3(m_kbanking->getCInterface())) {
++ qDebug("KBankingPlugin: No AqB3 config found.");
++ if (!AB_Banking_HasConf2(m_kbanking->getCInterface())) {
++ qDebug("KBankingPlugin: AqB2 config found - converting.");
++ AB_Banking_ImportConf2(m_kbanking->getCInterface());
++ }
++ } else {
++ qDebug("KBankingPlugin: AqB3 config found - converting.");
++ AB_Banking_ImportConf3(m_kbanking->getCInterface());
++ }
++ }
++#elif AQB_IS_VERSION(3,9,0,0)
++ if (AB_Banking_HasConf4(m_kbanking->getCInterface(), 0)) {
++ qDebug("KBankingPlugin: No AqB4 config found.");
++ if (AB_Banking_HasConf3(m_kbanking->getCInterface(), 0)) {
++ qDebug("KBankingPlugin: No AqB3 config found.");
++ if (!AB_Banking_HasConf2(m_kbanking->getCInterface(), 0)) {
++ qDebug("KBankingPlugin: AqB2 config found - converting.");
++ AB_Banking_ImportConf2(m_kbanking->getCInterface(), 0);
++ }
++ } else {
++ qDebug("KBankingPlugin: AqB3 config found - converting.");
++ AB_Banking_ImportConf3(m_kbanking->getCInterface(), 0);
++ }
++ }
++#endif
++
++ gui = new QBGui(m_kbanking);
++ 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");
++
++ // create view
++ createJobView();
++
++ // create actions
++ createActions();
++
++ // load protocol conversion list
++ loadProtocolConversion();
++ } else {
++ qWarning("Could not initialize KBanking online banking interface");
++ delete m_kbanking;
++ m_kbanking = 0;
++ }
++ }
++}
++
++
++
++KBankingPlugin::~KBankingPlugin()
++{
++ if (m_kbanking) {
++ m_kbanking->fini();
++ delete m_kbanking;
++ }
++ delete d;
++}
++
++
++void KBankingPlugin::loadProtocolConversion(void)
++{
++ if (m_kbanking) {
++ m_protocolConversionMap.clear();
++ m_protocolConversionMap["aqhbci"] = "HBCI";
++ m_protocolConversionMap["aqofxconnect"] = "OFX";
++ m_protocolConversionMap["aqyellownet"] = "YellowNet";
++ m_protocolConversionMap["aqgeldkarte"] = "Geldkarte";
++ m_protocolConversionMap["aqdtaus"] = "DTAUS";
++ }
++}
++
++void KBankingPlugin::protocols(QStringList& protocolList) const
++{
++ if (m_kbanking) {
++ std::list<std::string> list = m_kbanking->getActiveProviders();
++ std::list<std::string>::iterator it;
++ for (it = list.begin(); it != list.end(); ++it) {
++ // skip the dummy
++ if (*it == "aqnone")
++ continue;
++ QMap<QString, QString>::const_iterator it_m;
++ it_m = m_protocolConversionMap.find((*it).c_str());
++ if (it_m != m_protocolConversionMap.end())
++ protocolList << (*it_m);
++ else
++ protocolList << (*it).c_str();
++ }
++ }
++}
++
++QWidget* KBankingPlugin::accountConfigTab(const MyMoneyAccount& acc, QString& name)
++{
++ const MyMoneyKeyValueContainer& kvp = acc.onlineBankingSettings();
++ name = i18n("Online settings");
++ if (m_kbanking) {
++ m_accountSettings = new KBAccountSettings(acc, 0);
++ m_accountSettings->m_usePayeeAsIsButton->setChecked(true);
++ m_accountSettings->m_transactionDownload->setChecked(kvp.value("kbanking-txn-download") != "no");
++ m_accountSettings->m_preferredJobMethod->setCurrentIndex(kvp.value("kbanking-jobexec").toInt());
++ m_accountSettings->m_preferredStatementDate->setCurrentIndex(kvp.value("kbanking-statementDate").toInt());
++ if (!kvp.value("kbanking-payee-regexp").isEmpty()) {
++ m_accountSettings->m_extractPayeeButton->setChecked(true);
++ m_accountSettings->m_payeeRegExpEdit->setText(kvp.value("kbanking-payee-regexp"));
++ m_accountSettings->m_memoRegExpEdit->setText(kvp.value("kbanking-memo-regexp"));
++ m_accountSettings->m_payeeExceptions->clear();
++ m_accountSettings->m_payeeExceptions->insertStringList(kvp.value("kbanking-payee-exceptions").split(';', QString::SkipEmptyParts));
++ }
++ return m_accountSettings;
++ }
++ QLabel* label = new QLabel(i18n("KBanking module not correctly initialized"), 0);
++ label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
++ return label;
++}
++
++MyMoneyKeyValueContainer KBankingPlugin::onlineBankingSettings(const MyMoneyKeyValueContainer& current)
++{
++ MyMoneyKeyValueContainer kvp(current);
++ kvp["provider"] = objectName();
++ if (m_accountSettings) {
++ kvp.deletePair("kbanking-payee-regexp");
++ kvp.deletePair("kbanking-memo-regexp");
++ kvp.deletePair("kbanking-payee-exceptions");
++ kvp.deletePair("kbanking-txn-download");
++ if (m_accountSettings->m_extractPayeeButton->isChecked()
++ && !m_accountSettings->m_payeeRegExpEdit->text().isEmpty()
++ && !m_accountSettings->m_memoRegExpEdit->text().isEmpty()) {
++ kvp["kbanking-payee-regexp"] = m_accountSettings->m_payeeRegExpEdit->text();
++ kvp["kbanking-memo-regexp"] = m_accountSettings->m_memoRegExpEdit->text();
++ kvp["kbanking-payee-exceptions"] = m_accountSettings->m_payeeExceptions->items().join(";");
++ } else if (m_accountSettings->m_extractPayeeButton->isChecked()) {
++ KMessageBox::information(0, i18n("You selected to extract the payee from the memo field but did not supply a regular expression for payee and memo extraction. The option will not be activated."), i18n("Missing information"));
++ }
++ if (!m_accountSettings->m_transactionDownload->isChecked())
++ kvp["kbanking-txn-download"] = "no";
++ kvp["kbanking-jobexec"] = QString("%1").arg(m_accountSettings->m_preferredJobMethod->currentIndex());
++ kvp["kbanking-statementDate"] = QString("%1").arg(m_accountSettings->m_preferredStatementDate->currentIndex());
++ }
++ return kvp;
++}
++
++void KBankingPlugin::createJobView(void)
++{
++ KMyMoneyViewBase* view = viewInterface()->addPage(i18nc("Label for icon in KMyMoney's view pane", "Outbox"), "online-banking");
++ QWidget* w = new KBJobView(m_kbanking, view, "JobView");
++ viewInterface()->addWidget(view, w);
++ connect(viewInterface(), SIGNAL(viewStateChanged(bool)), view, SLOT(setEnabled(bool)));
++}
++
++void KBankingPlugin::createActions(void)
++{
++ KAction *settings_aqbanking = actionCollection()->addAction("settings_aqbanking");
++ settings_aqbanking->setText(i18n("Configure Aq&Banking..."));
++ connect(settings_aqbanking, SIGNAL(triggered()), this, SLOT(slotSettings()));
++
++ KAction *file_import_aqbanking = actionCollection()->addAction("file_import_aqbanking");
++ file_import_aqbanking->setText(i18n("AqBanking importer..."));
++ connect(file_import_aqbanking, SIGNAL(triggered()), this, SLOT(slotImport()));
++
++ connect(viewInterface(), SIGNAL(viewStateChanged(bool)), action("file_import_aqbanking"), SLOT(setEnabled(bool)));
++}
++
++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.");
++ }
++ delete bs;
++}
++
++bool KBankingPlugin::mapAccount(const MyMoneyAccount& acc, MyMoneyKeyValueContainer& settings)
++{
++ bool rc = false;
++ if (m_kbanking && !acc.id().isEmpty()) {
++ MyMoneyFile* file = MyMoneyFile::instance();
++
++ QString bankId;
++ QString accountId;
++ // extract some information about the bank. if we have a sortcode
++ // (BLZ) we display it, otherwise the name is enough.
++ try {
++ const MyMoneyInstitution &bank = file->institution(acc.institutionId());
++ bankId = bank.name();
++ if (!bank.sortcode().isEmpty())
++ bankId = bank.sortcode();
++ } catch (MyMoneyException *e) {
++ // no bank assigned, we just leave the field emtpy
++ delete e;
++ }
++
++ // extract account information. if we have an account number
++ // we show it, otherwise the name will be displayed
++ accountId = acc.number();
++ if (accountId.isEmpty())
++ accountId = m_account.name();
++
++ // do the mapping. the return value of this method is either
++ // true, when the user mapped the account or false, if he
++ // decided to quit the dialog. So not really a great thing
++ // to present some more information.
++ m_kbanking->askMapAccount(acc.id().toUtf8().data(),
++ bankId.toUtf8().data(),
++ accountId.toUtf8().data());
++
++ // at this point, the account should be mapped
++ // so we search it and setup the account reference in the KMyMoney object
++ AB_ACCOUNT* ab_acc;
++ ab_acc = AB_BANKING_GETACCOUNTBYALIAS(m_kbanking->getCInterface(), acc.id().toUtf8().data());
++ if (ab_acc) {
++ MyMoneyAccount a(acc);
++ setupAccountReference(a, ab_acc);
++ settings = a.onlineBankingSettings();
++ rc = true;
++ }
++ }
++ return rc;
++}
++
++QString KBankingPlugin::stripLeadingZeroes(const QString& s) const
++{
++ QString rc(s);
++ QRegExp exp("(0*)(.*)");
++ if (exp.exactMatch(s) != -1) {
++ rc = exp.cap(2);
++ }
++ return rc;
++}
++
++void KBankingPlugin::setupAccountReference(const MyMoneyAccount& acc, AB_ACCOUNT* ab_acc)
++{
++ MyMoneyKeyValueContainer kvp;
++
++ if (ab_acc) {
++ QString accountNumber = stripLeadingZeroes(AB_Account_GetAccountNumber(ab_acc));
++ QString routingNumber = stripLeadingZeroes(AB_Account_GetBankCode(ab_acc));
++
++ QString val = QString("%1-%2").arg(routingNumber, accountNumber);
++ if (val != acc.onlineBankingSettings().value("kbanking-acc-ref")) {
++ MyMoneyKeyValueContainer kvp;
++
++ // make sure to keep our own previous settings
++ const QMap<QString, QString>& vals = acc.onlineBankingSettings().pairs();
++ QMap<QString, QString>::const_iterator it_p;
++ for (it_p = vals.begin(); it_p != vals.end(); ++it_p) {
++ if (QString(it_p.key()).startsWith("kbanking-")) {
++ kvp.setValue(it_p.key(), *it_p);
++ }
++ }
++
++ kvp.setValue("kbanking-acc-ref", val);
++ kvp.setValue("provider", objectName());
++ setAccountOnlineParameters(acc, kvp);
++ }
++ } else {
++ // clear the connection
++ setAccountOnlineParameters(acc, kvp);
++ }
++}
++
++bool KBankingPlugin::accountIsMapped(const MyMoneyAccount& acc)
++{
++ AB_ACCOUNT* ab_acc = 0;
++ if (m_kbanking)
++ ab_acc = AB_BANKING_GETACCOUNTBYALIAS(m_kbanking->getCInterface(), acc.id().toUtf8().data());
++ return ab_acc != 0;
++}
++
++bool KBankingPlugin::updateAccount(const MyMoneyAccount& acc)
++{
++ return updateAccount(acc, false);
++}
++
++bool KBankingPlugin::updateAccount(const MyMoneyAccount& acc, bool moreAccounts)
++{
++ if (!m_kbanking)
++ return false;
++
++ bool rc = false;
++
++ if (!acc.id().isEmpty()) {
++ AB_ACCOUNT *ba = 0;
++ AB_JOB *job = 0;
++ int rv;
++ int days;
++ int year, month, day;
++ QDate qd;
++
++ /* get AqBanking account */
++ ba = AB_BANKING_GETACCOUNTBYALIAS(m_kbanking->getCInterface(), acc.id().toUtf8().data());
++ if (!ba) {
++ KMessageBox::error(0,
++ i18n("<qt>"
++ "The given application account <b>%1</b> "
++ "has not been mapped to an online "
++ "account."
++ "</qt>",
++ acc.name()),
++ i18n("Account Not Mapped"));
++ // clear the connection between the KMyMoney account
++ // and the AqBanking equivalent
++ setupAccountReference(acc, 0);
++ }
++
++ if (ba) {
++ setupAccountReference(acc, ba);
++
++ if (acc.onlineBankingSettings().value("kbanking-txn-download") != "no") {
++ /* create getTransactions job */
++ job = AB_JobGetTransactions_new(ba);
++ rv = AB_BANKING_JOB_CHECKAVAILABILITY(job);
++ if (rv) {
++ DBG_ERROR(0, "Job \"GetTransactions\" is not available (%d)", rv);
++ KMessageBox::error(0,
++ i18n("<qt>"
++ "The update job is not supported by the "
++ "bank/account/backend.\n"
++ "</qt>"),
++ i18n("Job not Available"));
++ AB_Job_free(job);
++ job = 0;
++ }
++
++ if (job) {
++ days = AB_JobGetTransactions_GetMaxStoreDays(job);
++ if (days > 0) {
++ GWEN_TIME *ti1;
++ GWEN_TIME *ti2;
++
++ ti1 = GWEN_CurrentTime();
++ ti2 = GWEN_Time_fromSeconds(GWEN_Time_Seconds(ti1) - (60 * 60 * 24 * days));
++ GWEN_Time_free(ti1);
++ ti1 = ti2;
++
++ if (GWEN_Time_GetBrokenDownDate(ti1, &day, &month, &year)) {
++ DBG_ERROR(0, "Bad date");
++ qd = QDate();
++ } else
++ qd = QDate(year, month + 1, day);
++ GWEN_Time_free(ti1);
++ }
++
++ // get last statement request date from application account object
++ // and start from the next day if the date is valid
++ QDate lastUpdate = QDate::fromString(acc.value("lastImportedTransactionDate"), Qt::ISODate);
++ if (lastUpdate.isValid())
++ lastUpdate = lastUpdate.addDays(-3);
++
++ int dateOption = acc.onlineBankingSettings().value("kbanking-statementDate").toInt();
++ switch (dateOption) {
++ case 0: // Ask user
++ break;
++ case 1: // No date
++ qd = QDate();
++ break;
++ case 2: // Last download
++ qd = lastUpdate;
++ break;
++ case 3: // First possible
++ // qd is already setup
++ break;
++ }
++
++ // the pick start date option dialog is needed in
++ // case the dateOption is 0 or the date option is > 1
++ // 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);
++ if (psd->exec() != QDialog::Accepted) {
++ AB_Job_free(job);
++ delete psd;
++ return rc;
++ }
++ qd = psd->date();
++ delete psd;
++ }
++
++ if (qd.isValid()) {
++ GWEN_TIME *ti1;
++
++ ti1 = GWEN_Time_new(qd.year(), qd.month() - 1, qd.day(), 0, 0, 0, 0);
++ AB_JobGetTransactions_SetFromTime(job, ti1);
++ GWEN_Time_free(ti1);
++ }
++
++ rv = m_kbanking->enqueueJob(job);
++ AB_Job_free(job);
++ if (rv) {
++ DBG_ERROR(0, "Error %d", rv);
++ KMessageBox::error(0,
++ i18n("<qt>"
++ "Could not enqueue the job.\n"
++ "</qt>"),
++ i18n("Error"));
++ }
++ }
++ }
++
++ /* create getBalance job */
++ job = AB_JobGetBalance_new(ba);
++ rv = AB_BANKING_JOB_CHECKAVAILABILITY(job);
++ if (!rv)
++ rv = m_kbanking->enqueueJob(job);
++ else
++ rv = 0;
++
++ AB_Job_free(job);
++ if (rv) {
++ DBG_ERROR(0, "Error %d", rv);
++ KMessageBox::error(0,
++ i18n("<qt>"
++ "Could not enqueue the job.\n"
++ "</qt>"),
++ i18n("Error"));
++ }
++ }
++
++ // make sure, we have at least one job in the queue before we continue.
++ if (m_kbanking->getEnqueuedJobs().size() > 0) {
++
++ // ask if the user want's to execute this job right away or spool it
++ // for later execution
++ KIconLoader *ic = KIconLoader::global();
++ KGuiItem executeButton(i18n("&Execute"),
++ KIcon(ic->loadIcon("tools-wizard",
++ KIconLoader::Small, KIconLoader::SizeSmall)),
++ i18n("Close this window"),
++ i18n("Use this button to close the window"));
++
++ KGuiItem queueButton(i18n("&Queue"),
++ KIcon(ic->loadIcon("document-export",
++ KIconLoader::Small, KIconLoader::SizeSmall)),
++ i18n("Close this window"),
++ i18n("Use this button to close the window"));
++
++ KMessageBox::ButtonCode result = KMessageBox::Cancel;
++ if (!moreAccounts) {
++ switch (acc.onlineBankingSettings().value("kbanking-jobexec").toInt()) {
++ case 1:
++ result = KMessageBox::Yes;
++ break;
++ case 2:
++ result = KMessageBox::No;
++ break;
++ default:
++ result = static_cast<KMessageBox::ButtonCode>(KMessageBox::questionYesNo(0,
++ i18n("Do you want to execute or queue this job in the outbox?"),
++ i18n("Execution"), executeButton, queueButton));
++ break;
++ }
++ } else {
++ result = KMessageBox::No;
++ }
++
++
++ if (result == KMessageBox::Yes) {
++
++ AB_IMEXPORTER_CONTEXT *ctx;
++
++ ctx = AB_ImExporterContext_new();
++ rv = m_kbanking->executeQueue(ctx);
++ if (!rv)
++ m_kbanking->importContext(ctx, 0);
++ else {
++ DBG_ERROR(0, "Error: %d", rv);
++ }
++ AB_ImExporterContext_free(ctx);
++
++ // let application emit signals to inform views
++ m_kbanking->accountsUpdated();
++ }
++ rc = true;
++ }
++ }
++ return rc;
++}
++
++
++
++void KBankingPlugin::slotImport(void)
++{
++ if (!m_kbanking->interactiveImport())
++ qWarning("Error on import dialog");
++}
++
++
++
++bool KBankingPlugin::importStatement(const MyMoneyStatement& s)
++{
++ return statementInterface()->import(s);
++}
++
++const MyMoneyAccount& KBankingPlugin::account(const QString& key, const QString& value) const
++{
++ return statementInterface()->account(key, value);
++}
++
++void KBankingPlugin::setAccountOnlineParameters(const MyMoneyAccount& acc, const MyMoneyKeyValueContainer& kvps) const
++{
++ return statementInterface()->setAccountOnlineParameters(acc, kvps);
++}
++
++
++KMyMoneyBanking::KMyMoneyBanking(KBankingPlugin* parent, const char* appname, const char* fname)
++ : KBanking(appname, fname)
++ , m_parent(parent)
++{
++}
++
++
++
++const AB_ACCOUNT_STATUS* KMyMoneyBanking::_getAccountStatus(AB_IMEXPORTER_ACCOUNTINFO *ai)
++{
++ const AB_ACCOUNT_STATUS *ast;
++ const AB_ACCOUNT_STATUS *best;
++
++ best = 0;
++ ast = AB_ImExporterAccountInfo_GetFirstAccountStatus(ai);
++ while (ast) {
++ if (!best)
++ best = ast;
++ else {
++ const GWEN_TIME *tiBest;
++ const GWEN_TIME *ti;
++
++ tiBest = AB_AccountStatus_GetTime(best);
++ ti = AB_AccountStatus_GetTime(ast);
++
++ if (!tiBest) {
++ best = ast;
++ } else {
++ if (ti) {
++ double d;
++
++ /* we have two times, compare them */
++ d = GWEN_Time_Diff(ti, tiBest);
++ if (d > 0)
++ /* newer */
++ best = ast;
++ }
++ }
++ }
++ ast = AB_ImExporterAccountInfo_GetNextAccountStatus(ai);
++ } /* while */
++ return best;
++}
++
++
++
++void KMyMoneyBanking::_xaToStatement(MyMoneyStatement &ks,
++ const MyMoneyAccount& acc,
++ const AB_TRANSACTION *t)
++{
++ const GWEN_STRINGLIST *sl;
++ QString s;
++ const char *p;
++ const AB_VALUE *val;
++ const GWEN_TIME *ti;
++ const GWEN_TIME *startTime = 0;
++ MyMoneyStatement::Transaction kt;
++ unsigned long h;
++
++ kt.m_fees = MyMoneyMoney();
++
++ // bank's transaction id
++ p = AB_Transaction_GetFiId(t);
++ if (p)
++ kt.m_strBankID = QString("ID ") + QString::fromUtf8(p);
++
++ // payee
++ s.truncate(0);
++ sl = AB_Transaction_GetRemoteName(t);
++ if (sl) {
++ GWEN_STRINGLISTENTRY *se;
++
++ se = GWEN_StringList_FirstEntry(sl);
++ while (se) {
++ p = GWEN_StringListEntry_Data(se);
++ assert(p);
++ s = QString::fromUtf8(p);
++ se = GWEN_StringListEntry_Next(se);
++ } // while
++ }
++ kt.m_strPayee = s;
++ h = MyMoneyTransaction::hash(s.trimmed());
++
++ // memo
++ s.truncate(0);
++ sl = AB_Transaction_GetPurpose(t);
++ if (sl) {
++ GWEN_STRINGLISTENTRY *se;
++ bool insertSpace = false;
++
++ se = GWEN_StringList_FirstEntry(sl);
++ while (se) {
++ p = GWEN_StringListEntry_Data(se);
++ assert(p);
++ if (insertSpace)
++ s += ' ';
++ insertSpace = true;
++ s += QString::fromUtf8(p);
++ se = GWEN_StringListEntry_Next(se);
++ } // while
++ }
++ kt.m_strMemo = s;
++ h = MyMoneyTransaction::hash(s.trimmed(), h);
++
++ // see, if we need to extract the payee from the memo field
++ const MyMoneyKeyValueContainer& kvp = acc.onlineBankingSettings();
++ QString rePayee = kvp.value("kbanking-payee-regexp");
++ if (!rePayee.isEmpty() && kt.m_strPayee.isEmpty()) {
++ QString reMemo = kvp.value("kbanking-memo-regexp");
++ QStringList exceptions = kvp.value("kbanking-payee-exceptions").split(';', QString::SkipEmptyParts);
++
++ bool needExtract = true;
++ QStringList::const_iterator it_s;
++ for (it_s = exceptions.constBegin(); needExtract && it_s != exceptions.constEnd(); ++it_s) {
++ QRegExp exp(*it_s, Qt::CaseInsensitive);
++ if (exp.indexIn(kt.m_strMemo) != -1) {
++ needExtract = false;
++ }
++ }
++ if (needExtract) {
++ QRegExp expPayee(rePayee, Qt::CaseInsensitive);
++ QRegExp expMemo(reMemo, Qt::CaseInsensitive);
++ if (expPayee.indexIn(kt.m_strMemo) != -1) {
++ kt.m_strPayee = expPayee.cap(1);
++ if (expMemo.indexIn(kt.m_strMemo) != -1) {
++ kt.m_strMemo = expMemo.cap(1);
++ }
++ }
++ }
++ }
++
++ // massage whitespaces a bit:
++ // - remove leading blanks
++ // - remove trailing blanks
++ // - reduce multiple blanks to one
++ kt.m_strMemo = kt.m_strMemo.simplified();
++ kt.m_strPayee = kt.m_strPayee.simplified();
++
++ // date
++ ti = AB_Transaction_GetDate(t);
++ if (!ti)
++ ti = AB_Transaction_GetValutaDate(t);
++ if (ti) {
++ int year, month, day;
++
++ if (!startTime)
++ startTime = ti;
++ else {
++ if (GWEN_Time_Diff(ti, startTime) < 0)
++ startTime = ti;
++ }
++
++ if (!GWEN_Time_GetBrokenDownDate(ti, &day, &month, &year)) {
++ kt.m_datePosted = QDate(year, month + 1, day);
++ }
++ } else {
++ DBG_WARN(0, "No date for transaction");
++ }
++
++ // value
++ val = AB_Transaction_GetValue(t);
++ if (val) {
++ if (ks.m_strCurrency.isEmpty()) {
++ p = AB_Value_GetCurrency(val);
++ if (p)
++ ks.m_strCurrency = p;
++ } else {
++ p = AB_Value_GetCurrency(val);
++ if (p)
++ s = p;
++ if (ks.m_strCurrency.toLower() != s.toLower()) {
++ // TODO: handle currency difference
++ DBG_ERROR(0, "Mixed currencies currently not allowed");
++ }
++ }
++
++ kt.m_amount = MyMoneyMoney(AB_Value_GetValueAsDouble(val));
++ h = MyMoneyTransaction::hash(kt.m_amount.toString(), h);
++ } else {
++ DBG_WARN(0, "No value for transaction");
++ }
++
++ if (startTime) {
++ int year, month, day;
++
++ if (!GWEN_Time_GetBrokenDownDate(startTime, &day, &month, &year)) {
++ QDate d(year, month + 1, day);
++
++ if (!ks.m_dateBegin.isValid())
++ ks.m_dateBegin = d;
++ else if (d < ks.m_dateBegin)
++ ks.m_dateBegin = d;
++
++ if (!ks.m_dateEnd.isValid())
++ ks.m_dateEnd = d;
++ else if (d > ks.m_dateEnd)
++ ks.m_dateEnd = d;
++ }
++ } else {
++ DBG_WARN(0, "No date in current transaction");
++ }
++
++ // make hash value unique in case we don't have one already
++ if (kt.m_strBankID.isEmpty()) {
++ QString hashBase;
++ hashBase.sprintf("%s-%07lx", qPrintable(kt.m_datePosted.toString(Qt::ISODate)), h);
++ int idx = 1;
++ QString hash;
++ for (;;) {
++ hash = QString("%1-%2").arg(hashBase).arg(idx);
++ QMap<QString, bool>::const_iterator it;
++ it = m_hashMap.constFind(hash);
++ if (it == m_hashMap.constEnd()) {
++ m_hashMap[hash] = true;
++ break;
++ }
++ ++idx;
++ }
++ kt.m_strBankID = QString("%1-%2").arg(acc.id()).arg(hash);
++ }
++
++ // store transaction
++ ks.m_listTransactions += kt;
++}
++
++
++
++bool KMyMoneyBanking::importAccountInfo(AB_IMEXPORTER_ACCOUNTINFO *ai,
++ uint32_t /*flags*/)
++{
++ QString s;
++ const char *p;
++ const AB_TRANSACTION *t;
++ MyMoneyStatement ks;
++ MyMoneyAccount kacc;
++ const AB_ACCOUNT_STATUS *ast;
++ const AB_VALUE *val;
++ const GWEN_TIME *ti;
++
++ DBG_INFO(0, "Importing account...");
++
++ // account number
++ p = AB_ImExporterAccountInfo_GetAccountNumber(ai);
++ if (p) {
++ ks.m_strAccountNumber = m_parent->stripLeadingZeroes(p);
++ }
++
++ p = AB_ImExporterAccountInfo_GetBankCode(ai);
++ if (p) {
++ ks.m_strRoutingNumber = m_parent->stripLeadingZeroes(p);
++ }
++
++ kacc = m_parent->account("kbanking-acc-ref", QString("%1-%2").arg(ks.m_strRoutingNumber, ks.m_strAccountNumber));
++ ks.m_accountId = kacc.id();
++
++ // account name
++ p = AB_ImExporterAccountInfo_GetAccountName(ai);
++ if (p)
++ ks.m_strAccountName = p;
++
++ // account type
++ switch (AB_ImExporterAccountInfo_GetType(ai)) {
++ case AB_AccountType_Bank:
++ ks.m_eType = MyMoneyStatement::etSavings;
++ break;
++ case AB_AccountType_CreditCard:
++ ks.m_eType = MyMoneyStatement::etCreditCard;
++ break;
++ case AB_AccountType_Checking:
++ ks.m_eType = MyMoneyStatement::etCheckings;
++ break;
++ case AB_AccountType_Savings:
++ ks.m_eType = MyMoneyStatement::etSavings;
++ break;
++ case AB_AccountType_Investment:
++ ks.m_eType = MyMoneyStatement::etInvestment;
++ break;
++ case AB_AccountType_Cash:
++ ks.m_eType = MyMoneyStatement::etNone;
++ break;
++ default:
++ ks.m_eType = MyMoneyStatement::etNone;
++ }
++
++ // account status
++ ast = _getAccountStatus(ai);
++ if (ast) {
++ const AB_BALANCE *bal;
++
++ bal = AB_AccountStatus_GetBookedBalance(ast);
++ if (!bal)
++ bal = AB_AccountStatus_GetNotedBalance(ast);
++ if (bal) {
++ val = AB_Balance_GetValue(bal);
++ if (val) {
++ DBG_INFO(0, "Importing balance");
++ ks.m_closingBalance = MyMoneyMoney(AB_Value_GetValueAsDouble(val));
++ p = AB_Value_GetCurrency(val);
++ if (p)
++ ks.m_strCurrency = p;
++ }
++ ti = AB_Balance_GetTime(bal);
++ if (ti) {
++ int year, month, day;
++
++ if (!GWEN_Time_GetBrokenDownDate(ti, &day, &month, &year))
++ ks.m_dateEnd = QDate(year, month + 1, day);
++ } else {
++ DBG_WARN(0, "No time for balance");
++ }
++ } else {
++ DBG_WARN(0, "No account balance");
++ }
++ } else {
++ DBG_WARN(0, "No account status");
++ }
++
++ // clear hash map
++ m_hashMap.clear();
++
++ // get all transactions
++ t = AB_ImExporterAccountInfo_GetFirstTransaction(ai);
++ while (t) {
++ _xaToStatement(ks, kacc, t);
++ t = AB_ImExporterAccountInfo_GetNextTransaction(ai);
++ }
++
++ // import them
++ if (!m_parent->importStatement(ks)) {
++ if (KMessageBox::warningYesNo(0,
++ i18n("Error importing statement. Do you want to continue?"),
++ i18n("Critical Error")) == KMessageBox::No) {
++ DBG_ERROR(0, "User aborted");
++ return false;
++ }
++ }
++ return true;
++}
++
++
++#include "mymoneybanking.moc"
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.cpp.rej kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.cpp.rej
+--- kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.cpp.rej 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.cpp.rej 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,43 @@
++***************
++*** 716,725 ****
++ GWEN_STRINGLISTENTRY *se;
++
++ se = GWEN_StringList_FirstEntry(sl);
++- if (se) {
++ p = GWEN_StringListEntry_Data(se);
++ assert(p);
++- s = QString::fromUtf8(p);
++ }
++ }
++ kt.m_strPayee = s;
++--- 898,908 ----
++ GWEN_STRINGLISTENTRY *se;
++
++ se = GWEN_StringList_FirstEntry(sl);
+++ while (se) {
++ p = GWEN_StringListEntry_Data(se);
++ assert(p);
+++ s += QString::fromUtf8(p);
+++ se = GWEN_StringListEntry_Next(se);
++ }
++ }
++ kt.m_strPayee = s;
++***************
++*** 777,784 ****
++ // - remove leading blanks
++ // - remove trailing blanks
++ // - reduce multiple blanks to one
++- kt.m_strMemo = kt.m_strMemo.trimmed();
++- kt.m_strPayee = kt.m_strPayee.trimmed();
++
++ // date
++ ti = AB_Transaction_GetDate(t);
++--- 960,967 ----
++ // - remove leading blanks
++ // - remove trailing blanks
++ // - reduce multiple blanks to one
+++ kt.m_strMemo = kt.m_strMemo.simplified();
+++ kt.m_strPayee = kt.m_strPayee.simplified();
++
++ // date
++ ti = AB_Transaction_GetDate(t);
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.h kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.h
+--- kmymoney-4.5/kmymoney/plugins/kbanking/mymoneybanking.h 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/mymoneybanking.h 2010-11-12 02:09:27.000000000 +0100
+@@ -1,6 +1,7 @@
+ /***************************************************************************
+- * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
+ * Copyright 2004 Martin Preuss aquamaniac at users.sourceforge.net *
++ * Copyright 2009 Cristian Onet onet.cristian at gmail.com *
++ * Copyright 2010 Thomas Baumgart ipwizard at users.sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+@@ -25,6 +26,22 @@
+ #include <config-kmymoney.h>
+ #endif
+
++#include <aqbanking/version.h>
++#include <aqbanking/banking.h>
++#include "banking.hpp"
++
++#ifndef AQB_MAKE_VERSION
++#define AQB_MAKE_VERSION(a,b,c,d) (((a)<<24) | ((b)<<16) | (c<<8) | (d))
++#endif
++
++#ifndef AQBANKING_VERSION
++#define AQBANKING_VERSION AQB_MAKE_VERSION(AQBANKING_VERSION_MAJOR,AQBANKING_VERSION_MINOR,AQBANKING_VERSION_PATCHLEVEL,AQBANKING_VERSION_BUILD)
++#endif
++
++#ifndef AQB_IS_VERSION
++#define AQB_IS_VERSION(a,b,c,d) (AQBANKING_VERSION >= AQB_MAKE_VERSION(a,b,c,d))
++#endif
++
+ // ----------------------------------------------------------------------------
+ // QT Includes
+
+@@ -39,7 +56,6 @@
+ // ----------------------------------------------------------------------------
+ // Project Includes
+
+-#include "kbanking.h"
+ #include <kmymoney/kmymoneyplugin.h>
+ #include <kmymoney/mymoneyaccount.h>
+ #include <kmymoney/mymoneykeyvaluecontainer.h>
+@@ -146,9 +162,18 @@
+ */
+ bool updateAccount(const MyMoneyAccount& acc);
+
++ /**
++ * Trigger the password cache timer
++ */
++ void startPasswordTimer(void);
++
+ protected slots:
+ void slotSettings(void);
+ void slotImport(void);
++ void slotClearPasswordCache(void);
++
++signals:
++ void queueChanged(void);
+
+ private:
+ class Private;
+@@ -162,27 +187,45 @@
+ };
+
+ /**
+- * This class is the special implementation to glue the KBanking class
++ * This class is the special implementation to glue the AB_Banking class
+ * with the KMyMoneyPlugin structure.
+ */
+-class KMyMoneyBanking : public KBanking
++class KMyMoneyBanking : public AB_Banking
+ {
++ friend class KBankingPlugin;
+
+ public:
+ KMyMoneyBanking(KBankingPlugin* parent, const char* appname, const char* fname = 0);
+ virtual ~KMyMoneyBanking() {};
+
+- bool importAccountInfo(AB_IMEXPORTER_ACCOUNTINFO *ai, uint32_t flags);
++ int executeQueue(AB_IMEXPORTER_CONTEXT *ctx);
++
++ int enqueueJob(AB_JOB *j);
++ int dequeueJob(AB_JOB *j);
++ std::list<AB_JOB*> getEnqueuedJobs();
++
++ bool askMapAccount(const char *id,
++ const char *bankCode,
++ const char *accountId);
++
++ virtual bool interactiveImport();
+
+ protected:
++ int init();
++ int fini();
++
++ bool importAccountInfo(AB_IMEXPORTER_ACCOUNTINFO *ai, uint32_t flags);
+ const AB_ACCOUNT_STATUS* _getAccountStatus(AB_IMEXPORTER_ACCOUNTINFO *ai);
+ void _xaToStatement(MyMoneyStatement &ks,
+ const MyMoneyAccount&,
+ const AB_TRANSACTION *t);
++ void clearPasswordCache(void);
+
+ private:
+ KBankingPlugin* m_parent;
+ QMap<QString, bool> m_hashMap;
++ AB_JOB_LIST2 *_jobQueue;
++
+ };
+
+ #endif
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/views/kbjobview.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/views/kbjobview.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/views/kbjobview.cpp 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/views/kbjobview.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -38,14 +38,13 @@
+ #include <KIconLoader>
+ #include <KMessageBox>
+
+-#include "kbanking.h"
+ #include <aqbanking/jobgetbalance.h>
+ #include <aqbanking/jobgettransactions.h>
+
+ #include <gwenhywfar/debug.h>
+
+
+-KBJobView::KBJobView(KBanking *kb,
++KBJobView::KBJobView(KMyMoneyBanking *kb,
+ QWidget* parent,
+ const char* name,
+ Qt::WFlags fl) :
+@@ -64,8 +63,6 @@
+ 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 +151,6 @@
+ DBG_ERROR(0, "Error: %d", rv);
+ }
+ AB_ImExporterContext_free(ctx);
+-
+- // let App emit signals to inform account views
+- m_app->accountsUpdated();
+ }
+
+
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/views/kbjobview.h kmymoney-4.5.patched/kmymoney/plugins/kbanking/views/kbjobview.h
+--- kmymoney-4.5/kmymoney/plugins/kbanking/views/kbjobview.h 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/views/kbjobview.h 2010-11-12 02:09:27.000000000 +0100
+@@ -32,14 +32,14 @@
+
+
+ #include "kbjoblist.h"
+-#include "kbanking.h"
++#include "mymoneybanking.h"
+
+
+ class KBJobView: public QWidget, public Ui::KBJobViewUi
+ {
+ Q_OBJECT
+ public:
+- explicit KBJobView(KBanking *kb,
++ explicit KBJobView(KMyMoneyBanking *kb,
+ QWidget* parent = 0, const char* name = 0, Qt::WFlags fl = 0);
+ ~KBJobView();
+
+@@ -47,7 +47,7 @@
+ bool fini();
+
+ private:
+- KBanking *m_app;
++ KMyMoneyBanking *m_app;
+ KBJobListView *m_jobList;
+
+ protected slots:
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/widgets/CMakeLists.txt kmymoney-4.5.patched/kmymoney/plugins/kbanking/widgets/CMakeLists.txt
+--- kmymoney-4.5/kmymoney/plugins/kbanking/widgets/CMakeLists.txt 2010-11-12 02:27:38.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/widgets/CMakeLists.txt 2010-11-12 02:09:27.000000000 +0100
+@@ -2,6 +2,7 @@
+ ########### next target ###############
+
+ SET(kmm_kbanking_widgets_la_SOURCES
++ kbaccountlist.cpp
+ kbjoblist.cpp
+ )
+
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/widgets/kbaccountlist.cpp kmymoney-4.5.patched/kmymoney/plugins/kbanking/widgets/kbaccountlist.cpp
+--- kmymoney-4.5/kmymoney/plugins/kbanking/widgets/kbaccountlist.cpp 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/widgets/kbaccountlist.cpp 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,253 @@
++/***************************************************************************
++ begin : Mon Mar 01 2004
++ copyright : (C) 2004 by Martin Preuss
++ email : martin at 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)
++ : QTreeWidgetItem(parent)
++ , _account(acc)
++{
++ assert(acc);
++ _populate();
++}
++
++
++
++KBAccountListViewItem::KBAccountListViewItem(const KBAccountListViewItem &item)
++ : QTreeWidgetItem(item)
++ , _account(0)
++{
++
++ if (item._account) {
++ _account = item._account;
++ }
++}
++
++
++KBAccountListViewItem::KBAccountListViewItem(KBAccountListView *parent,
++ QTreeWidgetItem *after,
++ AB_ACCOUNT *acc)
++ : QTreeWidgetItem(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);
++
++}
++
++bool KBAccountListViewItem::operator< (const QTreeWidgetItem & other) const
++{
++ bool ok1, ok2;
++ int column = treeWidget() ? treeWidget()->sortColumn() : 0;
++ int a = text(column).toInt(&ok1);
++ int b = other.text(column).toInt(&ok2);
++ if (ok1 && ok2)
++ return a < b;
++ return QTreeWidgetItem::operator<(other);
++}
++
++
++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)
++ : QTreeWidget(parent)
++{
++ setAllColumnsShowFocus(true);
++ setColumnCount(7);
++ QStringList header;
++ header << QWidget::tr("Id");
++ header << QWidget::tr("Institute Code");
++ header << QWidget::tr("Institute Name");
++ header << QWidget::tr("Account Number");
++ header << QWidget::tr("Account Name");
++ header << QWidget::tr("Owner");
++ header << QWidget::tr("Backend");
++ setHeaderLabels(header);
++
++ setSortingEnabled(true);
++ sortItems(0, Qt::AscendingOrder);
++}
++
++
++
++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
++ QTreeWidgetItemIterator it(this);
++ // iterate through all items of the listview
++ for (; *it; ++it) {
++ if ((*it)->isSelected()) {
++ entry = dynamic_cast<KBAccountListViewItem*>(*it);
++ 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
++ QTreeWidgetItemIterator it(this);
++ // iterate through all items of the listview
++ for (; *it; ++it) {
++ entry = dynamic_cast<KBAccountListViewItem*>(*it);
++ if (entry)
++ accs.push_back(entry->getAccount());
++ } // for
++
++ return accs;
++}
++
++
++
+diff --unidirectional-new-file -r -x .svn -u kmymoney-4.5/kmymoney/plugins/kbanking/widgets/kbaccountlist.h kmymoney-4.5.patched/kmymoney/plugins/kbanking/widgets/kbaccountlist.h
+--- kmymoney-4.5/kmymoney/plugins/kbanking/widgets/kbaccountlist.h 1970-01-01 01:00:00.000000000 +0100
++++ kmymoney-4.5.patched/kmymoney/plugins/kbanking/widgets/kbaccountlist.h 2010-11-12 02:09:27.000000000 +0100
+@@ -0,0 +1,71 @@
++/***************************************************************************
++ begin : Mon Mar 01 2004
++ copyright : (C) 2004 by Martin Preuss
++ email : martin at libchipcard.de
++
++ ***************************************************************************
++ * Please see toplevel file COPYING for license details *
++ ***************************************************************************/
++
++#ifndef Q4BANKING_ACCOUNTLIST_H
++#define Q4BANKING_ACCOUNTLIST_H
++
++
++#include <QTreeWidget>
++
++#include <aqbanking/account.h>
++
++#include <list>
++
++class KBAccountListView;
++class KBAccountListViewItem;
++
++
++class KBAccountListViewItem: public QTreeWidgetItem
++{
++private:
++ AB_ACCOUNT *_account;
++
++ void _populate();
++ bool operator< (const QTreeWidgetItem & other) const; //!< correctly sort text columns, which contain numbers
++
++public:
++ KBAccountListViewItem(KBAccountListView *parent, AB_ACCOUNT *acc);
++ KBAccountListViewItem(KBAccountListView *parent,
++ QTreeWidgetItem *after,
++ AB_ACCOUNT *acc);
++ KBAccountListViewItem(const KBAccountListViewItem &item);
++
++ virtual ~KBAccountListViewItem();
++
++ AB_ACCOUNT *getAccount();
++
++ QString key(int column, bool ascending) const;
++};
++
++
++
++class KBAccountListView: public QTreeWidget
++{
++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 */
++
++
++
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20101112/14db48e5/attachment-0001.html>
More information about the macports-changes
mailing list