Hallo Liste,
Hallo Martin,

angehängt sind noch ein Paar patches für aqhbci-tool gegen aqbanking-svn
r1603:

aqhbci-tool-delaccount.patch: 
  Fügt das Kommando "delaccount" hinzu

aqhbci-tool-deluser.uniqueId+uninitialized.patch: 
  Fügt zu "deluser" den Parameter --user-unique hinzu, mit dem man User
anhand der UniqueId löschen kann. 
  Fügt auch den Parameter --uninitialized hinzu, für den ich schon mal
als patch geschickt hatte.

aqhbci-tool-listusers.patch:
  Fügt den Parameter --xml hinzu, mit dem man die User im XML-Format für
automatische Abarbeitung listen lassen kann.

Über eine Einarbeitung in aqbanking würde ich mich sehr freuen.
Sollten Fragen bestehen, immer her damit, ich beantworte sie gerne.

Schöne Grüße,

Patrick

diff -Nur aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/delaccount.c aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/delaccount.c
--- aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/delaccount.c	1970-01-01 01:00:00.000000000 +0100
+++ aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/delaccount.c	2008-11-06 10:05:33.000000000 +0100
@@ -0,0 +1,343 @@
+/***************************************************************************
+ begin       : Thu Nov 06 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 delAccount(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 *account;
+  uint32_t delAll = 0;
+  uint32_t pretend = 0;
+  uint32_t uniqueId = 0;
+  uint32_t userUniqueId = 0;
+  AB_ACCOUNT_LIST2 *al;
+  AB_ACCOUNT_LIST2 *matches;
+  AB_ACCOUNT_LIST2_ITERATOR *ait;
+  int match_count = 0;
+  int error_count = 0;
+
+  const GWEN_ARGS args[]={
+  {
+    GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+    GWEN_ArgsType_Char,           /* type */
+    "account",                   /* name */
+    0,                            /* minnum */
+    1,                            /* maxnum */
+    "a",                          /* short option */
+    "account",                   /* long option */
+    "Specify the account number", /* short description */
+    "Specify the account number"  /* 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 */
+    "accountUniqueId",                 /* name */
+    0,                            /* minnum */
+    1,                            /* maxnum */
+    "i",                          /* short option */
+    "unique",                   /* long option */
+    "Specify the account unique id",    /* short description */
+    "Specify the account unique id"     /* long description */
+  },
+  {
+    GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+    GWEN_ArgsType_Char,           /* type */
+    "userUniqueId",                 /* name */
+    0,                            /* minnum */
+    1,                            /* maxnum */
+    0,                          /* short option */
+    "user-unique",                   /* long option */
+    "Specify the user unique id",    /* short description */
+    "Specify the user unique id"     /* 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 accounts, do not abort if more than one account matches",    /* short description */
+    "Delete all matching accounts, do not abort if more than one account matches"     /* long description */
+  },
+  {
+    0, /* flags */
+    GWEN_ArgsType_Int,           /* type */
+    "pretend",                 /* name */
+    0,                            /* minnum */
+    1,                            /* maxnum */
+    "p",                          /* short option */
+    "pretend",                   /* long option */
+    "Only print matching accounts, don't delete",    /* short description */
+    "Only print matching accounts, 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);
+  account=GWEN_DB_GetCharValue(db, "account", 0, 0);
+  delAll=GWEN_DB_GetIntValue(db, "all", 0, 0);
+  pretend=GWEN_DB_GetIntValue(db, "pretend", 0, 0);
+  uniqueId=GWEN_DB_GetIntValue(db, "accountUniqueId", 0, 0);
+  userUniqueId=GWEN_DB_GetIntValue(db, "userUniqueId", 0, 0);
+
+  matches = AB_Account_List2_new();
+
+  al=AB_Banking_FindAccounts(ab, AH_PROVIDER_NAME, "*", "*", "*");
+  if (al) {
+
+    ait=AB_Account_List2_First(al);
+    if (ait) {
+      const char *s;
+      AB_ACCOUNT *a;
+      int i=0;
+
+      a=AB_Account_List2Iterator_Data(ait);
+      assert(a);
+      while(a) {
+        int match = 1;
+
+        if (match && bankId) {
+          s=AB_Account_GetBankCode(a);
+          if (!s || !*s || -1==GWEN_Text_ComparePattern(s, bankId, 0))
+            match=0;
+        }
+
+        if (match && account) {
+          s=AB_Account_GetAccountNumber(a);
+          if (!s || !*s || -1==GWEN_Text_ComparePattern(s, account, 0))
+            match=0;
+        }
+
+        if (match && uniqueId) {
+          uint32_t id = AB_Account_GetUniqueId(a);
+          if ( uniqueId != id )
+            match=0;
+        }
+
+        if (match && (userId || customerId || userUniqueId)) 
+        {
+          AB_USER *u;
+          u = AB_Account_GetFirstUser( a );
+          if( !u )
+            match = 0;
+
+          if (match && userUniqueId)
+          {
+            uint32_t id = AB_User_GetUniqueId(u);
+            if ( userUniqueId != id )
+              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 )
+        {
+          match_count++;
+          fprintf(stdout, "Account %d:\tUniqueId: %d\t\tAccount Number: %s\tBank: %s/%s\n",
+                  i++,
+                  AB_Account_GetUniqueId(a),
+                  AB_Account_GetAccountNumber(a),
+                  AB_Account_GetCountry(a),
+                  AB_Account_GetBankCode(a)
+          );
+          AB_Account_List2_PushBack( matches, a );
+        }
+
+        a=AB_Account_List2Iterator_Next(ait);
+      }
+      AB_Account_List2Iterator_free(ait);
+    }
+    AB_Account_List2_free(al);
+  }
+
+
+  if( !match_count )
+  {
+    fprintf( stderr, "ERROR: No matching accounts\n" );
+    return 3;
+  }
+
+  if( match_count > 1 && !delAll )
+  {
+    fprintf( stderr, "ERROR: %d accounts match. Refusing to delete more than one account. Please specify --all to delete all matching accounts.\n", match_count );
+    return 3;
+  }
+
+
+  if( !pretend )
+  {
+    ait=AB_Account_List2_First(matches);
+    if (ait) {
+      AB_ACCOUNT *a;
+      int i=0;
+
+      a=AB_Account_List2Iterator_Data(ait);
+      assert(a);
+      while(a) {
+
+        rv = AB_Banking_DeleteAccount( ab, a );
+        if( rv )
+        {
+          fprintf( stderr, "ERROR: Error deleting account %d (%d).\n", i, rv );
+          error_count++;
+        }
+        else
+          fprintf( stdout, "Account %d deleted.\n", i );
+
+        a=AB_Account_List2Iterator_Next(ait);
+        i++;
+      }
+      AB_Account_List2Iterator_free(ait);
+    }
+    AB_Account_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.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h
--- aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h	2008-10-03 18:41:22.000000000 +0200
+++ aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/globals.h	2008-11-06 08:57:26.000000000 +0100
@@ -61,9 +61,14 @@
                 char **argv);
 
 int addAccount(AB_BANKING *ab,
-	       GWEN_DB_NODE *dbArgs,
-	       int argc,
-	       char **argv);
+             GWEN_DB_NODE *dbArgs,
+             int argc,
+             char **argv);
+
+int delAccount(AB_BANKING *ab,
+             GWEN_DB_NODE *dbArgs,
+             int argc,
+             char **argv);
 
 int getSysId(AB_BANKING *ab,
              GWEN_DB_NODE *dbArgs,
diff -Nur aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c
--- aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c	2008-10-03 18:41:22.000000000 +0200
+++ aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/main.c	2008-11-06 08:56:57.000000000 +0100
@@ -198,6 +198,9 @@
     GWEN_Buffer_AppendString(ubuf,
                              I18N("  addaccount:\n"
                                   "    Manually add account \n\n"));
+    GWEN_Buffer_AppendString(ubuf,
+                             I18N("  delaccount:\n"
+                                  "    Deletes account \n\n"));
 
     fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
     GWEN_Buffer_free(ubuf);
@@ -280,6 +283,9 @@
   else if (strcasecmp(cmd, "addaccount")==0) {
     rv=addAccount(ab, db, argc, argv);
   }
+  else if (strcasecmp(cmd, "delaccount")==0) {
+    rv=delAccount(ab, db, argc, argv);
+  }
   else if (strcasecmp(cmd, "getsysid")==0) {
     rv=getSysId(ab, db, argc, argv);
   }
diff -Nur aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am
--- aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am	2008-10-03 18:41:22.000000000 +0200
+++ aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/Makefile.am	2008-11-06 08:57:37.000000000 +0100
@@ -28,6 +28,7 @@
  changepin.c \
  test.c \
  addaccount.c \
+ delaccount.c \
  getcert.c \
  sethbciversion.c \
  adduserflags.c \
diff -Nur aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c
--- aqbanking-3.8.0.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c	2008-10-11 11:29:29.000000000 +0200
+++ aqbanking-3.8.0/src/plugins/backends/aqhbci/tools/aqhbci-tool/deluser.c	2008-11-06 11:39:12.000000000 +0100
@@ -39,9 +39,11 @@
   const char *userId;
   const char *customerId;
   const char *userName;
+  int uninitialized = -1;
   uint32_t delAll = 0;
   uint32_t delAccounts = 0;
   uint32_t pretend = 0;
+  uint32_t userUniqueId = 0;
   AB_USER_LIST2 *ul;
   AB_USER_LIST2 *matches;
   AB_USER_LIST2_ITERATOR *uit;
@@ -95,6 +97,28 @@
     "Specify the customer id (Kundennummer)"     /* long description */
   },
   {
+    GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+    GWEN_ArgsType_Char,           /* type */
+    "uniqueId",                 /* name */
+    0,                            /* minnum */
+    1,                            /* maxnum */
+    0,                          /* short option */
+    "user-unique",                   /* long option */
+    "Specify the user unique id",    /* short description */
+    "Specify the user unique id"     /* long description */
+  },
+  {
+    GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
+    GWEN_ArgsType_Int,           /* type */
+    "uninitialized",                 /* name */
+    0,                            /* minnum */
+    1,                            /* maxnum */
+    NULL,                          /* short option */
+    "uninitialized",                   /* long option */
+    "Match uninitialized users (PARAM=1) or initialized users (PARAM=0)",    /* short description */
+    "Match uninitialized users (PARAM=1) or initialized users (PARAM=0)"     /* long description */
+  },
+  {
     0, /* flags */
     GWEN_ArgsType_Int,           /* type */
     "all",                 /* name */
@@ -181,9 +205,17 @@
   userId=GWEN_DB_GetCharValue(db, "userId", 0, 0);
   customerId=GWEN_DB_GetCharValue(db, "customerId", 0, 0);
   userName=GWEN_DB_GetCharValue(db, "userName", 0, 0);
+  uninitialized=GWEN_DB_GetIntValue(db, "uninitialized", 0, -1);
   delAll=GWEN_DB_GetIntValue(db, "all", 0, 0);
   delAccounts=GWEN_DB_GetIntValue(db, "withAccounts", 0, 0);
   pretend=GWEN_DB_GetIntValue(db, "pretend", 0, 0);
+  userUniqueId=GWEN_DB_GetIntValue(db, "userUniqueId", 0, 0);
+
+  if( uninitialized != 0 && uninitialized != 1  && uninitialized != -1 )
+  {
+    fprintf( stderr, "Please specify either 0 or 1 for --uninitialized\n" );
+    return 1;
+  }
 
   matches = AB_User_List2_new();
 
@@ -225,6 +257,18 @@
             match=0;
         }
 
+        if (match && userUniqueId) {
+          uint32_t id = AB_User_GetUniqueId(u);
+          if ( userUniqueId != id )
+            match=0;
+        }
+
+        if (match && uninitialized != -1) {
+          s=AH_User_GetSystemId(u);
+          if( (uninitialized == 1 && s != NULL) || (uninitialized == 0 && s == NULL) )
+            match = 0;
+        }
+
         if( match )
         {
           match_count++;
diff -Nur aqbanking-trunk.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/listusers.c aqbanking-trunk/src/plugins/backends/aqhbci/tools/aqhbci-tool/listusers.c
--- aqbanking-trunk.orig/src/plugins/backends/aqhbci/tools/aqhbci-tool/listusers.c	2008-11-06 17:27:05.000000000 +0100
+++ aqbanking-trunk/src/plugins/backends/aqhbci/tools/aqhbci-tool/listusers.c	2008-11-06 17:30:01.000000000 +0100
@@ -33,9 +33,22 @@
   GWEN_DB_NODE *db;
   AB_PROVIDER *pro;
   int rv;
+  int xml=0;
   AB_USER_LIST2 *ul;
+
   const GWEN_ARGS args[]={
   {
+    0,                            /* flags */
+    GWEN_ArgsType_Int,             /* type */
+    "xml",                 /* name */
+    0,                            /* minnum */
+    1,                            /* maxnum */
+    0,                            /* short option */
+    "xml",                /* long option */
+    "Export as xml",  /* short description */
+    0
+  },
+  {
     GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */
     GWEN_ArgsType_Int,            /* type */
     "help",                       /* name */
@@ -82,9 +95,17 @@
     return 2;
   }
 
+  xml=GWEN_DB_VariableExists(db, "xml");
+
   pro=AB_Banking_GetProvider(ab, "aqhbci");
   assert(pro);
 
+  if( xml )
+  {
+    fprintf( stdout, "<?xml version=\"1.0\"?>\n" );
+    fprintf( stdout, "<users>\n" );
+  }
+
   ul=AB_Banking_FindUsers(ab, AH_PROVIDER_NAME, "*", "*", "*", "*");
   if (ul) {
     AB_USER_LIST2_ITERATOR *uit;
@@ -97,12 +118,29 @@
       u=AB_User_List2Iterator_Data(uit);
       assert(u);
       while(u) {
-        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));
+        if( !xml ) {
+          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));
+        }
+        else {
+          char *name = AB_User_GetUserName(u);
+          fprintf( stdout, "  <user>\n" );
+          fprintf( stdout, "    <userUniqueId>%d</userUniqueId>\n", AB_User_GetUniqueId(u) );
+          if( !name )
+            fprintf( stdout, "    <UserName></UserName>\n" );
+          else
+            fprintf( stdout, "    <UserName><![CDATA[%s]]></UserName>\n", name );
+          fprintf( stdout, "    <UserId>%s</UserId>\n", AB_User_GetUserId(u) );
+          fprintf( stdout, "    <CustomerId>%s</CustomerId>\n", AB_User_GetCustomerId(u) );
+          fprintf( stdout, "    <BankCode>%s</BankCode>\n", AB_User_GetBankCode(u) );
+          fprintf( stdout, "    <Country>%s</Country>\n", AB_User_GetCountry(u) );
+          fprintf( stdout, "    <LastSessionId>%d</LastSessionId>\n", AB_User_GetLastSessionId(u) );
+          fprintf( stdout, "  </user>\n\n" );
+        }
         u=AB_User_List2Iterator_Next(uit);
       }
       AB_User_List2Iterator_free(uit);
@@ -113,6 +151,13 @@
     fprintf(stderr, "No users found.\n");
   }
 
+
+  if( xml )
+  {
+    fprintf( stdout, "</users>\n" );
+  }
+
+
   rv=AB_Banking_OnlineFini(ab, 0);
   if (rv) {
     fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv);
-------------------------------------------------------------------------
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

Reply via email to