Hallo alle Miteinander,
nachdem ich des öfteren meine settings.conf mit dem manuellen
"herumfrickeln" geschossen habe, ist hier angehängt ein Patch für
aqhbci-tool.
Dieser fügt die commands deluser, addaccountflags und subaccountflags
hinzu.
Das Command deluser unterstützt die Löschung aller Accounts des users.
Über eine Einarbeitung in aqbanking würde ich mich freuen. Die
Lizensierung des Patches ist mir egal, sprich ich stelle ihn unter die
Lizenz, unter der aqbanking gerade steht.
Patch ist gegen aqbanking-3.7.2.
Sollten Fragen bestehen -> gerne fragen.
Schöne Grüße,
Patrick
diff -Nur aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am
--- aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am 2008-07-31 20:13:32.000000000 +0200
+++ aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am 2008-09-21 17:12:04.000000000 +0200
@@ -14,6 +14,8 @@
aqhbci_tool3_SOURCES=main.c \
mkpinlist.c \
adduser.c \
+ deluser.c \
+ addsubaccountflags.c \
getsysid.c \
getkeys.c \
createkeys.c \
diff -Nur aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/addsubaccountflags.c aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/addsubaccountflags.c
--- aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/addsubaccountflags.c 1970-01-01 01:00:00.000000000 +0100
+++ aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/addsubaccountflags.c 2008-09-21 17:15:13.000000000 +0200
@@ -0,0 +1,184 @@
+/***************************************************************************
+ $RCSfile$
+ -------------------
+ cvs : $Id$
+ begin : Tue Sep 20 2008
+ copyright : (C) 2008 by Patrick Prasse
+ email : [EMAIL PROTECTED]
+
+ ***************************************************************************
+ * Please see toplevel file COPYING for license details *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+
+#include "globals.h"
+
+#include <gwenhywfar/text.h>
+
+#include <aqhbci/user.h>
+#include <aqhbci/account.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+
+int addsubAccountFlags(AB_BANKING *ab,
+ GWEN_DB_NODE *dbArgs,
+ int argc,
+ char **argv, int is_add ) {
+ GWEN_DB_NODE *db;
+ AB_PROVIDER *pro;
+ AB_ACCOUNT_LIST2 *al;
+ AB_ACCOUNT *a=0;
+ int rv;
+ const char *bankId;
+ const char *accountId;
+ const GWEN_ARGS args[]={
+ {
+ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+ GWEN_ArgsType_Char, /* type */
+ "bankId", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "b", /* short option */
+ "bank", /* long option */
+ "Specify the bank code", /* short description */
+ "Specify the bank code" /* long description */
+ },
+ {
+ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+ GWEN_ArgsType_Char, /* type */
+ "accountId", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "a", /* short option */
+ "account", /* long option */
+ "Specify the account id (Kontonummer)", /* short description */
+ "Specify the account id (Kontonummer)" /* long description */
+ },
+ {
+ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+ GWEN_ArgsType_Char, /* type */
+ "flags", /* name */
+ 1, /* minnum */
+ 99, /* maxnum */
+ "f", /* short option */
+ "flags", /* long option */
+ "Specify the user flags", /* short description */
+ "Specify the user flags" /* long description */
+ },
+ {
+ GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */
+ GWEN_ArgsType_Int, /* type */
+ "help", /* name */
+ 0, /* minnum */
+ 0, /* maxnum */
+ "h", /* short option */
+ "help", /* long option */
+ "Show this help screen", /* short description */
+ "Show this help screen" /* long description */
+ }
+ };
+
+ db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
+ rv=GWEN_Args_Check(argc, argv, 1,
+ 0 /*GWEN_ARGS_MODE_ALLOW_FREEPARAM*/,
+ args,
+ db);
+ if (rv==GWEN_ARGS_RESULT_ERROR) {
+ fprintf(stderr, "ERROR: Could not parse arguments\n");
+ return 1;
+ }
+ else if (rv==GWEN_ARGS_RESULT_HELP) {
+ GWEN_BUFFER *ubuf;
+
+ ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
+ if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
+ fprintf(stderr, "ERROR: Could not create help string\n");
+ return 1;
+ }
+ fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
+ GWEN_Buffer_free(ubuf);
+ return 0;
+ }
+
+ rv=AB_Banking_Init(ab);
+ if (rv) {
+ DBG_ERROR(0, "Error on init (%d)", rv);
+ return 2;
+ }
+
+ rv=AB_Banking_OnlineInit(ab);
+ if (rv) {
+ DBG_ERROR(0, "Error on init (%d)", rv);
+ return 2;
+ }
+
+ pro=AB_Banking_GetProvider(ab, "aqhbci");
+ assert(pro);
+
+ bankId=GWEN_DB_GetCharValue(db, "bankId", 0, "*");
+ accountId=GWEN_DB_GetCharValue(db, "accountId", 0, "*");
+
+ al=AB_Banking_FindAccounts(ab, AH_PROVIDER_NAME, "de",
+ bankId, accountId);
+ if (al) {
+ if (AB_Account_List2_GetSize(al)!=1) {
+ DBG_ERROR(0, "Ambiguous account specification");
+ return 3;
+ }
+ else {
+ AB_ACCOUNT_LIST2_ITERATOR *ait;
+
+ ait=AB_Account_List2_First(al);
+ assert(ait);
+ a=AB_Account_List2Iterator_Data(ait);
+ AB_Account_List2Iterator_free(ait);
+ }
+ AB_Account_List2_free(al);
+ }
+ if (!a) {
+ DBG_ERROR(0, "No matching customer");
+ return 3;
+ }
+ else {
+ uint32_t flags;
+
+ flags=AH_Account_Flags_fromDb(db, "flags");
+ if( is_add )
+ {
+ fprintf(stderr, "Adding flags: %08x\n", flags);
+ AH_Account_AddFlags(a, flags);
+ }
+ else
+ {
+ fprintf(stderr, "Removing flags: %08x\n", flags);
+ AH_Account_SubFlags(a, flags);
+ }
+ }
+
+ rv=AB_Banking_OnlineFini(ab);
+ if (rv) {
+ fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv);
+ return 5;
+ }
+
+ rv=AB_Banking_Fini(ab);
+ if (rv) {
+ fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv);
+ return 5;
+ }
+
+ return 0;
+}
+
+
+
+
diff -Nur aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c
--- aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c 1970-01-01 01:00:00.000000000 +0100
+++ aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c 2008-09-22 08:56:06.000000000 +0200
@@ -0,0 +1,346 @@
+/***************************************************************************
+ $RCSfile$
+ -------------------
+ cvs : $Id$
+ begin : Tue Sep 20 2008
+ copyright : (C) 2008 by Patrick Prasse
+ email : [EMAIL PROTECTED]
+
+ ***************************************************************************
+ * Please see toplevel file COPYING for license details *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+
+#include "globals.h"
+#include <aqhbci/user.h>
+
+#include <gwenhywfar/text.h>
+#include <gwenhywfar/url.h>
+#include <gwenhywfar/ct.h>
+#include <gwenhywfar/ctplugin.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+
+
+int delUser(AB_BANKING *ab,
+ GWEN_DB_NODE *dbArgs,
+ int argc,
+ char **argv) {
+ GWEN_DB_NODE *db;
+ AB_PROVIDER *pro;
+ int rv;
+ const char *bankId;
+ const char *userId;
+ const char *customerId;
+ const char *userName;
+ uint32_t delAll = 0;
+ uint32_t delAccounts = 0;
+ uint32_t pretend = 0;
+ AB_USER_LIST2 *ul;
+ AB_USER_LIST2 *matches;
+ AB_USER_LIST2_ITERATOR *uit;
+ int match_count = 0;
+ int haveaccounts_count = 0;
+ int error_count = 0;
+
+ const GWEN_ARGS args[]={
+ {
+ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+ GWEN_ArgsType_Char, /* type */
+ "userName", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "N", /* short option */
+ "username", /* long option */
+ "Specify the user name", /* short description */
+ "Specify the user name (not the userid!)" /* long description */
+ },
+ {
+ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+ GWEN_ArgsType_Char, /* type */
+ "bankId", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "b", /* short option */
+ "bank", /* long option */
+ "Specify the bank code", /* short description */
+ "Specify the bank code" /* long description */
+ },
+ {
+ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+ GWEN_ArgsType_Char, /* type */
+ "userId", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "u", /* short option */
+ "user", /* long option */
+ "Specify the user id (Benutzerkennung)", /* short description */
+ "Specify the user id (Benutzerkennung)" /* long description */
+ },
+ {
+ GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+ GWEN_ArgsType_Char, /* type */
+ "customerId", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "c", /* short option */
+ "customer", /* long option */
+ "Specify the customer id (Kundennummer)", /* short description */
+ "Specify the customer id (Kundennummer)" /* long description */
+ },
+ {
+ 0, /* flags */
+ GWEN_ArgsType_Int, /* type */
+ "all", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "A", /* short option */
+ "all", /* long option */
+ "Delete all matching users, do not abort if more than one user matches", /* short description */
+ "Delete all matching users, do not abort if more than one user matches" /* long description */
+ },
+ {
+ 0, /* flags */
+ GWEN_ArgsType_Int, /* type */
+ "withAccounts", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "a", /* short option */
+ "with-accounts", /* long option */
+ "Delete all accounts of user", /* short description */
+ "Delete all accounts of user" /* long description */
+ },
+ {
+ 0, /* flags */
+ GWEN_ArgsType_Int, /* type */
+ "pretend", /* name */
+ 0, /* minnum */
+ 1, /* maxnum */
+ "p", /* short option */
+ "pretend", /* long option */
+ "Only print matching users, don't delete", /* short description */
+ "Only print matching users, don't delete" /* long description */
+ },
+ {
+ GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */
+ GWEN_ArgsType_Int, /* type */
+ "help", /* name */
+ 0, /* minnum */
+ 0, /* maxnum */
+ "h", /* short option */
+ "help", /* long option */
+ "Show this help screen", /* short description */
+ "Show this help screen" /* long description */
+ }
+ };
+
+ db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
+ rv=GWEN_Args_Check(argc, argv, 1,
+ 0 /*GWEN_ARGS_MODE_ALLOW_FREEPARAM*/,
+ args,
+ db);
+ if (rv==GWEN_ARGS_RESULT_ERROR) {
+ fprintf(stderr, "ERROR: Could not parse arguments\n");
+ return 1;
+ }
+ else if (rv==GWEN_ARGS_RESULT_HELP) {
+ GWEN_BUFFER *ubuf;
+
+ ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
+ if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
+ fprintf(stderr, "ERROR: Could not create help string\n");
+ return 1;
+ }
+ fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
+ GWEN_Buffer_free(ubuf);
+ return 0;
+ }
+
+ rv=AB_Banking_Init(ab);
+ if (rv) {
+ DBG_ERROR(0, "Error on init (%d)", rv);
+ return 2;
+ }
+
+ rv=AB_Banking_OnlineInit(ab);
+ if (rv) {
+ DBG_ERROR(0, "Error on init (%d)", rv);
+ return 2;
+ }
+
+ pro=AB_Banking_GetProvider(ab, "aqhbci");
+ assert(pro);
+
+ bankId=GWEN_DB_GetCharValue(db, "bankId", 0, 0);
+ userId=GWEN_DB_GetCharValue(db, "userId", 0, 0);
+ customerId=GWEN_DB_GetCharValue(db, "customerId", 0, 0);
+ userName=GWEN_DB_GetCharValue(db, "userName", 0, 0);
+ delAll=GWEN_DB_GetIntValue(db, "all", 0, 0);
+ delAccounts=GWEN_DB_GetIntValue(db, "withAccounts", 0, 0);
+ pretend=GWEN_DB_GetIntValue(db, "pretend", 0, 0);
+
+ matches = AB_User_List2_new();
+
+ ul=AB_Banking_FindUsers(ab, AH_PROVIDER_NAME, "*", "*", "*", "*");
+ if (ul) {
+
+ uit=AB_User_List2_First(ul);
+ if (uit) {
+ const char *s;
+ AB_USER *u;
+ int i=0;
+
+ u=AB_User_List2Iterator_Data(uit);
+ assert(u);
+ while(u) {
+ int match = 1;
+
+ if (match && bankId) {
+ s=AB_User_GetBankCode(u);
+ if (!s || !*s || -1==GWEN_Text_ComparePattern(s, bankId, 0))
+ match=0;
+ }
+
+ if (match && userId) {
+ s=AB_User_GetUserId(u);
+ if (!s || !*s || -1==GWEN_Text_ComparePattern(s, userId, 0))
+ match=0;
+ }
+
+ if (match && customerId) {
+ s=AB_User_GetCustomerId(u);
+ if (!s || !*s || -1==GWEN_Text_ComparePattern(s, customerId, 0))
+ match=0;
+ }
+
+ if (match && userName) {
+ s=AB_User_GetUserName(u);
+ if (!s || !*s || -1==GWEN_Text_ComparePattern(s, userName, 0))
+ match=0;
+ }
+
+ if( match )
+ {
+ match_count++;
+ fprintf(stdout, "User %d: Bank: %s/%s User Id: %s Customer Id: %s\n",
+ i++,
+ AB_User_GetCountry(u),
+ AB_User_GetBankCode(u),
+ AB_User_GetUserId(u),
+ AB_User_GetCustomerId(u));
+ AB_User_List2_PushBack( matches, u );
+
+ haveaccounts_count += (AB_Banking_FindFirstAccountOfUser(ab, u) != NULL ? 1 : 0 );
+ }
+
+ u=AB_User_List2Iterator_Next(uit);
+ }
+ AB_User_List2Iterator_free(uit);
+ }
+ AB_User_List2_free(ul);
+ }
+
+
+ if( !match_count )
+ {
+ fprintf( stderr, "ERROR: No matching users\n" );
+ return 3;
+ }
+
+ if( match_count > 1 && !delAll )
+ {
+ fprintf( stderr, "ERROR: %d users match. Refusing to delete more than one user. Please specify --all to delete all matching users.\n", match_count );
+ return 3;
+ }
+
+ if( haveaccounts_count && !delAccounts )
+ {
+ fprintf( stderr, "ERROR: %d users still have accounts. Refusing to delete those users. Please specify --with-accounts to delete all accounts of matching users.\n", haveaccounts_count );
+ return 3;
+ }
+
+ if( !pretend )
+ {
+ uit=AB_User_List2_First(matches);
+ if (uit) {
+ AB_USER *u;
+ int i=0;
+
+ u=AB_User_List2Iterator_Data(uit);
+ assert(u);
+ while(u) {
+ int error = 0;
+
+ if( delAccounts )
+ {
+ AB_ACCOUNT *a;
+ a = AB_Banking_FindFirstAccountOfUser( ab, u );
+ while( a )
+ {
+ rv = AB_Banking_DeleteAccount( ab, a );
+ if( rv )
+ {
+ fprintf( stderr, "ERROR: Error deleting account %d for user %d (%d), aborting this user.\n", AB_Account_GetUniqueId(a), i, rv );
+ error++;
+ error_count++;
+ }
+ else
+ fprintf( stdout, "Account %d deleted.\n", AB_Account_GetUniqueId(a) );
+ a = AB_Banking_FindFirstAccountOfUser( ab, u );
+ }
+ }
+
+ if( !error )
+ {
+ rv = AB_Banking_DeleteUser( ab, u );
+ if( rv )
+ {
+ fprintf( stderr, "ERROR: Error deleting user %d (%d).\n", i, rv );
+ error++;
+ error_count++;
+ }
+ else
+ fprintf( stdout, "User %d deleted.\n", i );
+ }
+
+ u=AB_User_List2Iterator_Next(uit);
+ i++;
+ }
+ AB_User_List2Iterator_free(uit);
+ }
+ AB_User_List2_free(matches);
+ } // !pretend
+ else
+ {
+ fprintf( stdout, "Nothing deleted.\n" );
+ }
+
+ rv=AB_Banking_OnlineFini(ab);
+ if (rv) {
+ fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv);
+ return 5;
+ }
+
+
+ rv=AB_Banking_Fini(ab);
+ if (rv) {
+ fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv);
+ return 5;
+ }
+
+ return error_count > 0 ? 3 : 0;
+}
+
+
+
+
+
diff -Nur aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h
--- aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h 2008-07-31 20:13:32.000000000 +0200
+++ aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h 2008-09-21 17:12:59.000000000 +0200
@@ -50,6 +50,11 @@
int argc,
char **argv);
+int delUser(AB_BANKING *ab,
+ GWEN_DB_NODE *dbArgs,
+ int argc,
+ char **argv);
+
int getAccounts(AB_BANKING *ab,
GWEN_DB_NODE *dbArgs,
int argc,
@@ -125,6 +130,12 @@
int argc,
char **argv);
+int addsubAccountFlags(AB_BANKING *ab,
+ GWEN_DB_NODE *dbArgs,
+ int argc,
+ char **argv,
+ int is_add );
+
int test1(AB_BANKING *ab,
diff -Nur aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c
--- aqbanking-3.7.2.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c 2008-07-31 20:13:32.000000000 +0200
+++ aqbanking-3.7.2/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c 2008-09-22 08:42:13.000000000 +0200
@@ -156,6 +156,9 @@
" Adds a user "
"(-> setup HBCI for a bank)\n\n"));
GWEN_Buffer_AppendString(ubuf,
+ I18N(" deluser:\n"
+ " Deletes a user.\n\n"));
+ GWEN_Buffer_AppendString(ubuf,
I18N(" getkeys:\n"
" Requests the server's key\n\n"));
GWEN_Buffer_AppendString(ubuf,
@@ -268,6 +271,9 @@
else if (strcasecmp(cmd, "adduser")==0) {
rv=addUser(ab, db, argc, argv);
}
+ else if (strcasecmp(cmd, "deluser")==0) {
+ rv=delUser(ab, db, argc, argv);
+ }
else if (strcasecmp(cmd, "getaccounts")==0) {
rv=getAccounts(ab, db, argc, argv);
}
@@ -313,6 +319,12 @@
else if (strcasecmp(cmd, "subuserflags")==0) {
rv=subUserFlags(ab, db, argc, argv);
}
+ else if (strcasecmp(cmd, "addaccountflags")==0) {
+ rv=addsubAccountFlags(ab, db, argc, argv, 1);
+ }
+ else if (strcasecmp(cmd, "subaccountflags")==0) {
+ rv=addsubAccountFlags(ab, db, argc, argv, 0);
+ }
else if (strcasecmp(cmd, "test1")==0) {
rv=test1(ab, db, argc, argv);
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Aqbanking-devel mailing list
Aqbanking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/aqbanking-devel