int AB_ImExporterContext_ReadDb(AB_IMEXPORTER_CONTEXT *iec, GWEN_DB_NODE *db) { GWEN_DB_NODE *dbT; int i; dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "accountInfoList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "accountInfo"); while(dbT) { AB_IMEXPORTER_ACCOUNTINFO *iea; iea=AB_ImExporterAccountInfo_fromDb(dbT); assert(iea); AB_ImExporterAccountInfo_List_Add(iea, iec->accountInfoList); dbT=GWEN_DB_FindNextGroup(dbT, "accountInfo"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "securityList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "security"); while(dbT) { AB_SECURITY *sec; sec=AB_Security_fromDb(dbT); assert(sec); AB_Security_List_Add(sec, iec->securityList); dbT=GWEN_DB_FindNextGroup(dbT, "security"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "messageList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "message"); while(dbT) { AB_MESSAGE *msg; msg=AB_Message_fromDb(dbT); assert(msg); AB_Message_List_Add(msg, iec->messageList); dbT=GWEN_DB_FindNextGroup(dbT, "message"); } } for (i=0; ; i++) { const char *s; s=GWEN_DB_GetCharValue(db, "logs", i, NULL); if (!s) break; GWEN_Buffer_AppendString(iec->logs, s); } return 0; }
int LC_Client_GetReaderAndDriverType(const LC_CLIENT *cl, const char *readerName, GWEN_BUFFER *driverType, GWEN_BUFFER *readerType, uint32_t *pReaderFlags) { GWEN_DB_NODE *dbDriver; dbDriver=GWEN_DB_FindFirstGroup(lc_client__driver_db, "driver"); while(dbDriver) { const char *sDriverName; sDriverName=GWEN_DB_GetCharValue(dbDriver, "driverName", 0, NULL); if (sDriverName) { GWEN_DB_NODE *dbReader; dbReader=GWEN_DB_FindFirstGroup(dbDriver, "reader"); while(dbReader) { const char *sReaderName; const char *sTmpl; sReaderName=GWEN_DB_GetCharValue(dbReader, "readerType", 0, NULL); sTmpl=GWEN_DB_GetCharValue(dbReader, "devicePathTmpl", 0, NULL); if (sReaderName && sTmpl) { if (-1!=GWEN_Text_ComparePattern(readerName, sTmpl, 1)) { /* reader found */ GWEN_Buffer_AppendString(driverType, sDriverName); GWEN_Buffer_AppendString(readerType, sReaderName); *pReaderFlags=LC_ReaderFlags_fromDb(dbReader, "flags"); DBG_INFO(LC_LOGDOMAIN, "Reader [%s] is [%s]/[%s], %08x", readerName, sDriverName, sReaderName, *pReaderFlags); return 0; } } else { DBG_INFO(LC_LOGDOMAIN, "Either reader name or template missing"); } dbReader=GWEN_DB_FindNextGroup(dbReader, "reader"); } } else { DBG_INFO(LC_LOGDOMAIN, "Driver name is missing"); } dbDriver=GWEN_DB_FindNextGroup(dbDriver, "driver"); } return GWEN_ERROR_NOT_FOUND; }
int GWEN_PathManager_FindFile(const char *destLib, const char *pathName, const char *fileName, GWEN_BUFFER *fbuf) { GWEN_DB_NODE *dbT; assert(gwen__paths); dbT=GWEN_DB_GetGroup(gwen__paths, GWEN_PATH_FLAGS_NAMEMUSTEXIST, destLib); if (dbT) { dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, pathName); if (dbT) { int i; const char *s; GWEN_DB_NODE *dbN; GWEN_BUFFER *tbuf; tbuf=GWEN_Buffer_new(0, 256, 0, 1); /* check all paths */ dbN=GWEN_DB_FindFirstGroup(dbT, "pair"); while(dbN) { for (i=0; ; i++) { s=GWEN_DB_GetCharValue(dbN, "path", i, 0); if (!s) break; else { FILE *f; GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S); GWEN_Buffer_AppendString(tbuf, fileName); DBG_DEBUG(GWEN_LOGDOMAIN, "Trying \"%s\"", GWEN_Buffer_GetStart(tbuf)); f=fopen(GWEN_Buffer_GetStart(tbuf), "r"); if (f) { fclose(f); DBG_DEBUG(GWEN_LOGDOMAIN, "File \"%s\" found in folder \"%s\"", fileName, s); GWEN_Buffer_AppendBuffer(fbuf, tbuf); GWEN_Buffer_free(tbuf); return 0; } GWEN_Buffer_Reset(tbuf); } } dbN=GWEN_DB_FindNextGroup(dbN, "pair"); } GWEN_Buffer_free(tbuf); } } DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", fileName); return GWEN_ERROR_NOT_FOUND; }
void AH_User_LoadSepaDescriptors(AB_USER *u) { AH_USER *ue; GWEN_DB_NODE *db; int rv; assert(u); ue=GWEN_INHERIT_GETDATA(AB_USER, AH_USER, u); assert(ue); /* read directly from BPD */ GWEN_StringList_Clear(ue->sepaDescriptors); db=GWEN_DB_Group_new("bpd"); rv=AH_Job_SampleBpdVersions("JobGetAccountSepaInfo", u, db); if (rv<0) { DBG_INFO(AQHBCI_LOGDOMAIN, "No BPD for TAN job"); } else { GWEN_DB_NODE *dbV; dbV=GWEN_DB_GetFirstGroup(db); while(dbV) { int version; version=atoi(GWEN_DB_GroupName(dbV)); if (version>0) { GWEN_DB_NODE *dbT; /* always overwrite with latest version received */ GWEN_StringList_Clear(ue->sepaDescriptors); dbT=GWEN_DB_FindFirstGroup(dbV, "SupportedSepaFormats"); if (!dbT) { DBG_INFO(AQHBCI_LOGDOMAIN, "No SEPA descriptor found"); } while(dbT) { int i; for (i=0; i<100; i++) { const char *s; s=GWEN_DB_GetCharValue(dbT, "format", i, NULL); if (! (s && *s)) break; GWEN_StringList_AppendString(ue->sepaDescriptors, s, 0, 1); DBG_INFO(AQHBCI_LOGDOMAIN, "Adding SEPA descriptor [%s] for GV version %d", s, version); } dbT=GWEN_DB_FindNextGroup(dbT, "SupportedSepaFormats"); } } dbV=GWEN_DB_GetNextGroup(dbV); } } GWEN_DB_Group_free(db); }
int GWEN_PathManager_GetMatchingFilesRecursively(const char *destLib, const char *pathName, const char *subFolderName, GWEN_STRINGLIST *sl, const char *mask) { GWEN_DB_NODE *dbT; assert(gwen__paths); dbT=GWEN_DB_GetGroup(gwen__paths, GWEN_PATH_FLAGS_NAMEMUSTEXIST, destLib); if (dbT) { dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, pathName); if (dbT) { int i; const char *s; GWEN_DB_NODE *dbN; GWEN_BUFFER *tbuf; tbuf=GWEN_Buffer_new(0, 256, 0, 1); /* check all paths */ dbN=GWEN_DB_FindFirstGroup(dbT, "pair"); while(dbN) { for (i=0; ; i++) { s=GWEN_DB_GetCharValue(dbN, "path", i, 0); if (!s) break; else { GWEN_Buffer_AppendString(tbuf, s); if (subFolderName && *subFolderName) { GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S); GWEN_Buffer_AppendString(tbuf, subFolderName); } DBG_DEBUG(GWEN_LOGDOMAIN, "Trying \"%s\"", GWEN_Buffer_GetStart(tbuf)); GWEN_Directory_GetMatchingFilesRecursively(GWEN_Buffer_GetStart(tbuf), sl, mask); GWEN_Buffer_Reset(tbuf); } } dbN=GWEN_DB_FindNextGroup(dbN, "pair"); } GWEN_Buffer_free(tbuf); } } return 0; }
int GWEN_PathManager_RemovePath(const char *callingLib, const char *destLib, const char *pathName, const char *pathValue) { GWEN_DB_NODE *dbT; const char *s; const char *p; assert(gwen__paths); dbT=GWEN_DB_GetGroup(gwen__paths, GWEN_PATH_FLAGS_NAMEMUSTEXIST, destLib); if (!dbT) return GWEN_ERROR_NOT_FOUND; dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, pathName); if (!dbT) return GWEN_ERROR_NOT_FOUND; dbT=GWEN_DB_FindFirstGroup(dbT, "pair"); while(dbT) { p=GWEN_DB_GetCharValue(dbT, "path", 0, 0); assert(p); s=GWEN_DB_GetCharValue(dbT, "lib", 0, 0); if ( ( (!callingLib && !s) || (callingLib && s && strcasecmp(s, callingLib)==0) ) && strcasecmp(p, pathValue)==0 ) break; dbT=GWEN_DB_FindNextGroup(dbT, "pair"); } if (dbT) { GWEN_DB_UnlinkGroup(dbT); GWEN_DB_Group_free(dbT); return 0; } else return 1; }
GWEN_STRINGLIST *GWEN_PathManager_GetPaths(const char *destLib, const char *pathName) { GWEN_DB_NODE *dbT; assert(gwen__paths); dbT=GWEN_DB_GetGroup(gwen__paths, GWEN_PATH_FLAGS_NAMEMUSTEXIST, destLib); if (dbT) { dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, pathName); if (dbT) { GWEN_STRINGLIST *sl; int i; const char *s; GWEN_DB_NODE *dbN; sl=GWEN_StringList_new(); /* then add all paths from other libs */ dbN=GWEN_DB_FindFirstGroup(dbT, "pair"); while(dbN) { for (i=0; ; i++) { s=GWEN_DB_GetCharValue(dbN, "path", i, 0); if (!s) break; GWEN_StringList_AppendString(sl, s, 0, 1); } dbN=GWEN_DB_FindNextGroup(dbN, "pair"); } if (GWEN_StringList_Count(sl)==0) { GWEN_StringList_free(sl); DBG_DEBUG(GWEN_LOGDOMAIN, "no entries"); return 0; } return sl; } } return 0; }
int AB_BankInfo_ReadDb(AB_BANKINFO *st, GWEN_DB_NODE *db) { assert(st); assert(db); AB_BankInfo_SetCountry(st, GWEN_DB_GetCharValue(db, "country", 0, 0)); AB_BankInfo_SetBranchId(st, GWEN_DB_GetCharValue(db, "branchId", 0, 0)); AB_BankInfo_SetBankId(st, GWEN_DB_GetCharValue(db, "bankId", 0, 0)); AB_BankInfo_SetBic(st, GWEN_DB_GetCharValue(db, "bic", 0, 0)); AB_BankInfo_SetBankName(st, GWEN_DB_GetCharValue(db, "bankName", 0, 0)); AB_BankInfo_SetLocation(st, GWEN_DB_GetCharValue(db, "location", 0, 0)); AB_BankInfo_SetStreet(st, GWEN_DB_GetCharValue(db, "street", 0, 0)); AB_BankInfo_SetZipcode(st, GWEN_DB_GetCharValue(db, "zipcode", 0, 0)); AB_BankInfo_SetCity(st, GWEN_DB_GetCharValue(db, "city", 0, 0)); AB_BankInfo_SetRegion(st, GWEN_DB_GetCharValue(db, "region", 0, 0)); AB_BankInfo_SetPhone(st, GWEN_DB_GetCharValue(db, "phone", 0, 0)); AB_BankInfo_SetFax(st, GWEN_DB_GetCharValue(db, "fax", 0, 0)); AB_BankInfo_SetEmail(st, GWEN_DB_GetCharValue(db, "email", 0, 0)); AB_BankInfo_SetWebsite(st, GWEN_DB_GetCharValue(db, "website", 0, 0)); st->services=AB_BankInfoService_List_new(); if (1) {/* just for local vars */ GWEN_DB_NODE *dbT; AB_BANKINFO_SERVICE *e; dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "services"); if (dbT) { GWEN_DB_NODE *dbT2; dbT2=GWEN_DB_FindFirstGroup(dbT, "element"); while(dbT2) { e=AB_BankInfoService_fromDb(dbT2); if (!e) { DBG_ERROR(0, "Bad element for type \"AB_BANKINFO_SERVICE\""); if (GWEN_Logger_GetLevel(0)>=GWEN_LoggerLevel_Debug) GWEN_DB_Dump(dbT2, 2); AB_BankInfo_free(st); return 0; } AB_BankInfoService_List_Add(e, st->services); dbT2=GWEN_DB_FindNextGroup(dbT2, "element"); } /* while */ } /* if (dbT) */ } /* if (1) */ return 0; }
int GWEN_PathManager_RemovePaths(const char *callingLib) { GWEN_DB_NODE *dbT; const char *s; assert(gwen__paths); GWEN_DB_DeleteGroup(gwen__paths, callingLib); dbT=GWEN_DB_GetFirstGroup(gwen__paths); while(dbT) { GWEN_DB_NODE *dbN; dbN=GWEN_DB_GetFirstGroup(dbT); while(dbN) { GWEN_DB_NODE *dbNN; dbNN=GWEN_DB_FindFirstGroup(dbN, "pair"); while(dbNN) { GWEN_DB_NODE *dbNext; dbNext=GWEN_DB_FindNextGroup(dbNN, "pair"); s=GWEN_DB_GetCharValue(dbNN, "lib", 0, 0); assert(s); if (s && strcasecmp(s, callingLib)==0) { GWEN_DB_UnlinkGroup(dbNN); GWEN_DB_Group_free(dbNN); } dbNN=dbNext; } /* while pairs */ dbN=GWEN_DB_GetNextGroup(dbN); } /* while paths */ dbT=GWEN_DB_GetNextGroup(dbT); } /* while destLibs */ return 0; }
int AH_Job_GetTransactionsCreditCard_Process(AH_JOB *j, AB_IMEXPORTER_CONTEXT *ctx) { AH_JOB_GETTRANSACTIONS *aj; AB_ACCOUNT *a; AB_IMEXPORTER_ACCOUNTINFO *ai; AB_USER *u; GWEN_DB_NODE *dbResponses; GWEN_DB_NODE *dbCurr; GWEN_BUFFER *tbooked; GWEN_BUFFER *tnoted; int rv; DBG_INFO(AQHBCI_LOGDOMAIN, "Processing JobGetTransactionsCreditCard"); assert(j); aj=GWEN_INHERIT_GETDATA(AH_JOB, AH_JOB_GETTRANSACTIONS, j); assert(aj); tbooked=GWEN_Buffer_new(0, 1024, 0, 1); tnoted=GWEN_Buffer_new(0, 1024, 0, 1); dbResponses=AH_Job_GetResponses(j); assert(dbResponses); DBG_INFO(AQHBCI_LOGDOMAIN, "Response:"); GWEN_DB_Dump(dbResponses, 2); DBG_INFO(AQHBCI_LOGDOMAIN, "Response end"); a=AH_AccountJob_GetAccount(j); assert(a); ai=AB_ImExporterContext_GetOrAddAccountInfo(ctx, AB_Account_GetUniqueId(a), AB_Account_GetIban(a), AB_Account_GetBankCode(a), AB_Account_GetAccountNumber(a), AB_Account_GetAccountType(a)); assert(ai); AB_ImExporterAccountInfo_SetAccountId(ai, AB_Account_GetUniqueId(a)); u=AH_Job_GetUser(j); assert(u); /* search for "Transactions" */ dbCurr=GWEN_DB_GetFirstGroup(dbResponses); while (dbCurr) { GWEN_DB_NODE *dbXA; rv=AH_Job_CheckEncryption(j, dbCurr); if (rv) { DBG_INFO(AQHBCI_LOGDOMAIN, "Compromised security (encryption)"); GWEN_Buffer_free(tbooked); GWEN_Buffer_free(tnoted); AH_Job_SetStatus(j, AH_JobStatusError); return rv; } rv=AH_Job_CheckSignature(j, dbCurr); if (rv) { DBG_INFO(AQHBCI_LOGDOMAIN, "Compromised security (signature)"); GWEN_Buffer_free(tbooked); GWEN_Buffer_free(tnoted); AH_Job_SetStatus(j, AH_JobStatusError); return rv; } dbXA=GWEN_DB_GetGroup(dbCurr, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "data/transactionscreditcard"); if (dbXA) { GWEN_DB_NODE *dbT; GWEN_DB_NODE *dbV; GWEN_DATE *date; GWEN_DATE *valutaDate; const char *p; const char *ref; int i; dbT=GWEN_DB_GetGroup(dbXA, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "entries"); while (dbT) { AB_VALUE *v1; AB_VALUE *v2; GWEN_STRINGLIST *purpose; AB_TRANSACTION *t; /* read date (Buchungsdatum) */ p=GWEN_DB_GetCharValue(dbT, "date", 0, 0); if (p) date=GWEN_Date_fromStringWithTemplate(p, "YYYYMMDD"); else date=NULL; /* read valutaData (Umsatzdatum) */ p=GWEN_DB_GetCharValue(dbT, "valutaDate", 0, 0); if (p) valutaDate=GWEN_Date_fromStringWithTemplate(p, "YYYYMMDD"); else valutaDate=NULL; /* read value */ dbV=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "value"); if (dbV) v1=AB_Value_fromDb(dbV); else v1=NULL; v2=0; if (!v1) { DBG_ERROR(AQHBCI_LOGDOMAIN, "Error parsing value from DB"); } else { p=GWEN_DB_GetCharValue(dbT, "debitMark", 0, 0); if (p) { if (strcasecmp(p, "D")==0 || strcasecmp(p, "RC")==0) { v2=AB_Value_dup(v1); AB_Value_Negate(v2); } else if (strcasecmp(p, "C")==0 || strcasecmp(p, "RD")==0) v2=AB_Value_dup(v1); else { DBG_ERROR(AQHBCI_LOGDOMAIN, "Bad debit mark \"%s\"", p); v2=0; } } AB_Value_free(v1); } /* read purpose */ purpose=GWEN_StringList_new(); for (i=0; i<10; i++) { p=GWEN_DB_GetCharValue(dbT, "purpose", i, 0); if (!p) break; GWEN_StringList_AppendString(purpose, p, 0, 0); } /* read reference */ ref=GWEN_DB_GetCharValue(dbT, "reference", 0, 0); if (ref) GWEN_StringList_AppendString(purpose, ref, 0, 0); t=AB_Transaction_new(); if (ref) AB_Transaction_SetFiId(t, ref); AB_Transaction_SetUniqueAccountId(t, AB_Account_GetUniqueId(a)); AB_Transaction_SetLocalBankCode(t, AB_User_GetBankCode(u)); AB_Transaction_SetLocalAccountNumber(t, AB_Account_GetAccountNumber(a)); AB_Transaction_SetValutaDate(t, valutaDate); AB_Transaction_SetDate(t, date); AB_Transaction_SetValue(t, v2); AB_Transaction_SetPurposeFromStringList(t, purpose); DBG_INFO(AQHBCI_LOGDOMAIN, "Adding transaction"); AB_ImExporterAccountInfo_AddTransaction(ai, t); GWEN_StringList_free(purpose); AB_Value_free(v2); GWEN_Date_free(date); GWEN_Date_free(valutaDate); dbT = GWEN_DB_FindNextGroup(dbT, "entries"); } //while (dbT) } //if (dbXA) dbCurr=GWEN_DB_GetNextGroup(dbCurr); } return 0; }
int AB_TransactionLimits_ReadDb(AB_TRANSACTION_LIMITS *st, GWEN_DB_NODE *db) { assert(st); assert(db); AB_TransactionLimits_SetMaxLenLocalName(st, GWEN_DB_GetIntValue(db, "maxLenLocalName", 0, 0)); AB_TransactionLimits_SetMinLenLocalName(st, GWEN_DB_GetIntValue(db, "minLenLocalName", 0, 0)); AB_TransactionLimits_SetMaxLenRemoteName(st, GWEN_DB_GetIntValue(db, "maxLenRemoteName", 0, 0)); AB_TransactionLimits_SetMinLenRemoteName(st, GWEN_DB_GetIntValue(db, "minLenRemoteName", 0, 0)); AB_TransactionLimits_SetMaxLinesRemoteName(st, GWEN_DB_GetIntValue(db, "maxLinesRemoteName", 0, 0)); AB_TransactionLimits_SetMinLinesRemoteName(st, GWEN_DB_GetIntValue(db, "minLinesRemoteName", 0, 0)); AB_TransactionLimits_SetMaxLenLocalBankCode(st, GWEN_DB_GetIntValue(db, "maxLenLocalBankCode", 0, 0)); AB_TransactionLimits_SetMinLenLocalBankCode(st, GWEN_DB_GetIntValue(db, "minLenLocalBankCode", 0, 0)); AB_TransactionLimits_SetMaxLenLocalAccountNumber(st, GWEN_DB_GetIntValue(db, "maxLenLocalAccountNumber", 0, 0)); AB_TransactionLimits_SetMinLenLocalAccountNumber(st, GWEN_DB_GetIntValue(db, "minLenLocalAccountNumber", 0, 0)); AB_TransactionLimits_SetMaxLenLocalSuffix(st, GWEN_DB_GetIntValue(db, "maxLenLocalSuffix", 0, 0)); AB_TransactionLimits_SetMinLenLocalSuffix(st, GWEN_DB_GetIntValue(db, "minLenLocalSuffix", 0, 0)); AB_TransactionLimits_SetMaxLenRemoteBankCode(st, GWEN_DB_GetIntValue(db, "maxLenRemoteBankCode", 0, 0)); AB_TransactionLimits_SetMinLenRemoteBankCode(st, GWEN_DB_GetIntValue(db, "minLenRemoteBankCode", 0, 0)); AB_TransactionLimits_SetMaxLenRemoteAccountNumber(st, GWEN_DB_GetIntValue(db, "maxLenRemoteAccountNumber", 0, 0)); AB_TransactionLimits_SetMinLenRemoteAccountNumber(st, GWEN_DB_GetIntValue(db, "minLenRemoteAccountNumber", 0, 0)); AB_TransactionLimits_SetMaxLenRemoteSuffix(st, GWEN_DB_GetIntValue(db, "maxLenRemoteSuffix", 0, 0)); AB_TransactionLimits_SetMinLenRemoteSuffix(st, GWEN_DB_GetIntValue(db, "minLenRemoteSuffix", 0, 0)); AB_TransactionLimits_SetMaxLenRemoteIban(st, GWEN_DB_GetIntValue(db, "maxLenRemoteIban", 0, 0)); AB_TransactionLimits_SetMinLenRemoteIban(st, GWEN_DB_GetIntValue(db, "minLenRemoteIban", 0, 0)); AB_TransactionLimits_SetMaxLenTextKey(st, GWEN_DB_GetIntValue(db, "maxLenTextKey", 0, 0)); AB_TransactionLimits_SetMinLenTextKey(st, GWEN_DB_GetIntValue(db, "minLenTextKey", 0, 0)); if (1) { int i; for (i=0; ; i++) { const char *s; s=GWEN_DB_GetCharValue(db, "valuesTextKey", i, 0); if (!s) break; AB_TransactionLimits_AddValuesTextKey(st, s, 0); } /* for */ } st->textKeys=AB_TextKeyDescr_List_new(); if (1) {/* just for local vars */ GWEN_DB_NODE *dbT; AB_TEXTKEY_DESCR *e; dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "textKeys"); if (dbT) { GWEN_DB_NODE *dbT2; dbT2=GWEN_DB_FindFirstGroup(dbT, "element"); while(dbT2) { e=AB_TextKeyDescr_fromDb(dbT2); if (!e) { DBG_ERROR(0, "Bad element for type \"AB_TEXTKEY_DESCR\""); if (GWEN_Logger_GetLevel(0)>=GWEN_LoggerLevel_Debug) GWEN_DB_Dump(dbT2, 2); AB_TransactionLimits_free(st); return 0; } AB_TextKeyDescr_List_Add(e, st->textKeys); dbT2=GWEN_DB_FindNextGroup(dbT2, "element"); } /* while */ } /* if (dbT) */ } /* if (1) */ AB_TransactionLimits_SetMaxLenCustomerReference(st, GWEN_DB_GetIntValue(db, "maxLenCustomerReference", 0, 0)); AB_TransactionLimits_SetMinLenCustomerReference(st, GWEN_DB_GetIntValue(db, "minLenCustomerReference", 0, 0)); AB_TransactionLimits_SetMaxLenBankReference(st, GWEN_DB_GetIntValue(db, "maxLenBankReference", 0, 0)); AB_TransactionLimits_SetMinLenBankReference(st, GWEN_DB_GetIntValue(db, "minLenBankReference", 0, 0)); AB_TransactionLimits_SetMaxLenPurpose(st, GWEN_DB_GetIntValue(db, "maxLenPurpose", 0, 0)); AB_TransactionLimits_SetMinLenPurpose(st, GWEN_DB_GetIntValue(db, "minLenPurpose", 0, 0)); AB_TransactionLimits_SetMaxLinesPurpose(st, GWEN_DB_GetIntValue(db, "maxLinesPurpose", 0, 0)); AB_TransactionLimits_SetMinLinesPurpose(st, GWEN_DB_GetIntValue(db, "minLinesPurpose", 0, 0)); AB_TransactionLimits_SetNeedDate(st, GWEN_DB_GetIntValue(db, "needDate", 0, 0)); AB_TransactionLimits_SetMinValueSetupTime(st, GWEN_DB_GetIntValue(db, "minValueSetupTime", 0, 0)); AB_TransactionLimits_SetMaxValueSetupTime(st, GWEN_DB_GetIntValue(db, "maxValueSetupTime", 0, 0)); AB_TransactionLimits_SetMinValueSetupTimeFirst(st, GWEN_DB_GetIntValue(db, "minValueSetupTimeFirst", 0, 0)); AB_TransactionLimits_SetMaxValueSetupTimeFirst(st, GWEN_DB_GetIntValue(db, "maxValueSetupTimeFirst", 0, 0)); AB_TransactionLimits_SetMinValueSetupTimeOnce(st, GWEN_DB_GetIntValue(db, "minValueSetupTimeOnce", 0, 0)); AB_TransactionLimits_SetMaxValueSetupTimeOnce(st, GWEN_DB_GetIntValue(db, "maxValueSetupTimeOnce", 0, 0)); AB_TransactionLimits_SetMinValueSetupTimeRecurring(st, GWEN_DB_GetIntValue(db, "minValueSetupTimeRecurring", 0, 0)); AB_TransactionLimits_SetMaxValueSetupTimeRecurring(st, GWEN_DB_GetIntValue(db, "maxValueSetupTimeRecurring", 0, 0)); AB_TransactionLimits_SetMinValueSetupTimeFinal(st, GWEN_DB_GetIntValue(db, "minValueSetupTimeFinal", 0, 0)); AB_TransactionLimits_SetMaxValueSetupTimeFinal(st, GWEN_DB_GetIntValue(db, "maxValueSetupTimeFinal", 0, 0)); if (1) { int i; for (i=0; ; i++) { const char *s; s=GWEN_DB_GetCharValue(db, "valuesCycleWeek", i, 0); if (!s) break; AB_TransactionLimits_AddValuesCycleWeek(st, s, 0); } /* for */ } if (1) { int i; for (i=0; ; i++) { const char *s; s=GWEN_DB_GetCharValue(db, "valuesCycleMonth", i, 0); if (!s) break; AB_TransactionLimits_AddValuesCycleMonth(st, s, 0); } /* for */ } if (1) { int i; for (i=0; ; i++) { const char *s; s=GWEN_DB_GetCharValue(db, "valuesExecutionDayWeek", i, 0); if (!s) break; AB_TransactionLimits_AddValuesExecutionDayWeek(st, s, 0); } /* for */ } if (1) { int i; for (i=0; ; i++) { const char *s; s=GWEN_DB_GetCharValue(db, "valuesExecutionDayMonth", i, 0); if (!s) break; AB_TransactionLimits_AddValuesExecutionDayMonth(st, s, 0); } /* for */ } AB_TransactionLimits_SetAllowMonthly(st, GWEN_DB_GetIntValue(db, "allowMonthly", 0, 0)); AB_TransactionLimits_SetAllowWeekly(st, GWEN_DB_GetIntValue(db, "allowWeekly", 0, 0)); AB_TransactionLimits_SetAllowChangeRecipientAccount(st, GWEN_DB_GetIntValue(db, "allowChangeRecipientAccount", 0, 0)); AB_TransactionLimits_SetAllowChangeRecipientName(st, GWEN_DB_GetIntValue(db, "allowChangeRecipientName", 0, 0)); AB_TransactionLimits_SetAllowChangeValue(st, GWEN_DB_GetIntValue(db, "allowChangeValue", 0, 0)); AB_TransactionLimits_SetAllowChangeTextKey(st, GWEN_DB_GetIntValue(db, "allowChangeTextKey", 0, 0)); AB_TransactionLimits_SetAllowChangePurpose(st, GWEN_DB_GetIntValue(db, "allowChangePurpose", 0, 0)); AB_TransactionLimits_SetAllowChangeFirstExecutionDate(st, GWEN_DB_GetIntValue(db, "allowChangeFirstExecutionDate", 0, 0)); AB_TransactionLimits_SetAllowChangeLastExecutionDate(st, GWEN_DB_GetIntValue(db, "allowChangeLastExecutionDate", 0, 0)); AB_TransactionLimits_SetAllowChangeCycle(st, GWEN_DB_GetIntValue(db, "allowChangeCycle", 0, 0)); AB_TransactionLimits_SetAllowChangePeriod(st, GWEN_DB_GetIntValue(db, "allowChangePeriod", 0, 0)); AB_TransactionLimits_SetAllowChangeExecutionDay(st, GWEN_DB_GetIntValue(db, "allowChangeExecutionDay", 0, 0)); return 0; }
AB_IMEXPORTER_ACCOUNTINFO* AB_ImExporterAccountInfo_fromDb(GWEN_DB_NODE *db){ AB_IMEXPORTER_ACCOUNTINFO *iea; const char *s; GWEN_DB_NODE *dbT; iea=AB_ImExporterAccountInfo_new(); #define RESTORE_CHAR(NAME) \ s=GWEN_DB_GetCharValue(db, __STRING(NAME), 0, 0);\ if (s)\ iea->NAME=strdup(s); #define RESTORE_INT(NAME, DEFAULT) \ iea->NAME=GWEN_DB_GetIntValue(db, __STRING(NAME), 0, DEFAULT); RESTORE_CHAR(bankCode); RESTORE_CHAR(bankName); RESTORE_CHAR(accountNumber); RESTORE_CHAR(iban); RESTORE_CHAR(bic); RESTORE_CHAR(owner); RESTORE_CHAR(currency); RESTORE_CHAR(description); RESTORE_INT(accountType, AB_AccountType_Bank); RESTORE_INT(accountId, 0); #undef RESTORE_CHAR #undef RESTORE_INT dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "statusList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "status"); while(dbT) { AB_ACCOUNT_STATUS *ast; ast=AB_AccountStatus_fromDb(dbT); assert(ast); AB_AccountStatus_List_Add(ast, iea->accStatusList); dbT=GWEN_DB_FindNextGroup(dbT, "status"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "transactionList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "transaction"); while(dbT) { AB_TRANSACTION *t; t=AB_Transaction_fromDb(dbT); assert(t); AB_Transaction_List_Add(t, iea->transactions); dbT=GWEN_DB_FindNextGroup(dbT, "transaction"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "standingOrderList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "standingOrder"); while(dbT) { AB_TRANSACTION *t; t=AB_Transaction_fromDb(dbT); assert(t); AB_Transaction_List_Add(t, iea->standingOrders); dbT=GWEN_DB_FindNextGroup(dbT, "standingOrder"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "transferList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "transfer"); while(dbT) { AB_TRANSACTION *t; t=AB_Transaction_fromDb(dbT); assert(t); AB_Transaction_List_Add(t, iea->transfers); dbT=GWEN_DB_FindNextGroup(dbT, "transfer"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "datedTransferList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "datedTransfer"); while(dbT) { AB_TRANSACTION *t; t=AB_Transaction_fromDb(dbT); assert(t); AB_Transaction_List_Add(t, iea->datedTransfers); dbT=GWEN_DB_FindNextGroup(dbT, "datedTransfer"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "notedTransactionList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "notedTransaction"); while(dbT) { AB_TRANSACTION *t; t=AB_Transaction_fromDb(dbT); assert(t); AB_Transaction_List_Add(t, iea->notedTransactions); dbT=GWEN_DB_FindNextGroup(dbT, "notedTransaction"); } } return iea; }
void AH_User_LoadTanMethods(AB_USER *u) { AH_USER *ue; assert(u); ue=GWEN_INHERIT_GETDATA(AB_USER, AH_USER, u); assert(ue); /* read directly from BPD */ if (ue->cryptMode==AH_CryptMode_Pintan) { GWEN_DB_NODE *db; int rv; AH_TanMethod_List_Clear(ue->tanMethodDescriptions); db=GWEN_DB_Group_new("bpd"); rv=AH_Job_SampleBpdVersions("JobTan", u, db); if (rv<0) { DBG_INFO(AQHBCI_LOGDOMAIN, "No BPD for TAN job"); } else { GWEN_DB_NODE *dbV; dbV=GWEN_DB_GetFirstGroup(db); while(dbV) { int version; version=atoi(GWEN_DB_GroupName(dbV)); if (version>0) { GWEN_DB_NODE *dbT; dbT=GWEN_DB_FindFirstGroup(dbV, "tanMethod"); if (!dbT) { DBG_INFO(AQHBCI_LOGDOMAIN, "No tan method found"); } while(dbT) { AH_TAN_METHOD *tm; const char *s; tm=AH_TanMethod_new(); AH_TanMethod_SetFunction(tm, GWEN_DB_GetIntValue(dbT, "function", 0, 0)); AH_TanMethod_SetProcess(tm, GWEN_DB_GetIntValue(dbT, "process", 0, 0)); AH_TanMethod_SetMethodId(tm, GWEN_DB_GetCharValue(dbT, "methodId", 0, 0)); AH_TanMethod_SetMethodName(tm, GWEN_DB_GetCharValue(dbT, "methodName", 0, 0)); AH_TanMethod_SetTanMaxLen(tm, GWEN_DB_GetIntValue(dbT, "tanMaxLen", 0, 0)); AH_TanMethod_SetFormatId(tm, GWEN_DB_GetCharValue(dbT, "formatId", 0, 0)); AH_TanMethod_SetPrompt(tm, GWEN_DB_GetCharValue(dbT, "prompt", 0, 0)); AH_TanMethod_SetReturnMaxLen(tm, GWEN_DB_GetIntValue(dbT, "returnMaxLen", 0, 0)); AH_TanMethod_SetMaxActiveLists(tm, GWEN_DB_GetIntValue(dbT, "maxActiveLists", 0, 0)); AH_TanMethod_SetGvVersion(tm, GWEN_DB_GetIntValue(dbT, "gvVersion", 0, 0)); s=GWEN_DB_GetCharValue(dbT, "multiTanAllowed", 0, NULL); if (s && strcasecmp(s, "j")==0) AH_TanMethod_SetMultiTanAllowed(tm, 1); AH_TanMethod_SetTimeShiftAllowed(tm, GWEN_DB_GetIntValue(dbT, "timeShiftAllowed", 0, 0)); AH_TanMethod_SetTanListMode(tm, GWEN_DB_GetIntValue(dbT, "tanListMode", 0, 0)); s=GWEN_DB_GetCharValue(dbT, "stornoAllowed", 0, NULL); if (s && strcasecmp(s, "j")==0) AH_TanMethod_SetStornoAllowed(tm, 1); s=GWEN_DB_GetCharValue(dbT, "needChallengeClass", 0, NULL); if (s && strcasecmp(s, "j")==0) AH_TanMethod_SetNeedChallengeClass(tm, 1); s=GWEN_DB_GetCharValue(dbT, "needChallengeAmount", 0, NULL); if (s && strcasecmp(s, "j")==0) AH_TanMethod_SetNeedChallengeAmount(tm, 1); AH_TanMethod_SetInitMode(tm, GWEN_DB_GetIntValue(dbT, "initMode", 0, 0)); s=GWEN_DB_GetCharValue(dbT, "tanMediumIdNeeded", 0, NULL); if (s && strcasecmp(s, "j")==0) AH_TanMethod_SetNeedTanMediumId(tm, 1); AH_TanMethod_SetMaxActiveTanMedia(tm, GWEN_DB_GetIntValue(dbT, "maxActiveMedia", 0, 0)); DBG_INFO(AQHBCI_LOGDOMAIN, "Adding TAN method %d [%s] for GV version %d", AH_TanMethod_GetFunction(tm), AH_TanMethod_GetMethodId(tm), version); AH_TanMethod_SetGvVersion(tm, version); AH_TanMethod_List_Add(tm, ue->tanMethodDescriptions); dbT=GWEN_DB_FindNextGroup(dbT, "tanMethod"); } } dbV=GWEN_DB_GetNextGroup(dbV); } } GWEN_DB_Group_free(db); } }
/* --------------------------------------------------------------- FUNCTION */ int AH_Job_GetTransactions__ReadTransactions(AH_JOB *j, AB_IMEXPORTER_ACCOUNTINFO *ai, const char *docType, int noted, GWEN_BUFFER *buf){ GWEN_DBIO *dbio; GWEN_SYNCIO *sio; int rv; GWEN_DB_NODE *db; GWEN_DB_NODE *dbDay; GWEN_DB_NODE *dbParams; AB_ACCOUNT *a; AB_USER *u; uint32_t progressId; uint64_t cnt=0; a=AH_AccountJob_GetAccount(j); assert(a); u=AH_Job_GetUser(j); assert(u); dbio=GWEN_DBIO_GetPlugin("swift"); if (!dbio) { DBG_ERROR(AQHBCI_LOGDOMAIN, "Plugin SWIFT is not found"); GWEN_Gui_ProgressLog(0, GWEN_LoggerLevel_Error, I18N("Plugin \"SWIFT\" not found.")); return AB_ERROR_PLUGIN_MISSING; } GWEN_Buffer_Rewind(buf); sio=GWEN_SyncIo_Memory_new(buf, 0); db=GWEN_DB_Group_new("transactions"); dbParams=GWEN_DB_Group_new("params"); GWEN_DB_SetCharValue(dbParams, GWEN_DB_FLAGS_OVERWRITE_VARS, "type", docType); if (AH_User_GetFlags(u) & AH_USER_FLAGS_KEEP_MULTIPLE_BLANKS) GWEN_DB_SetIntValue(dbParams, GWEN_DB_FLAGS_OVERWRITE_VARS, "keepMultipleBlanks", 1); else GWEN_DB_SetIntValue(dbParams, GWEN_DB_FLAGS_OVERWRITE_VARS, "keepMultipleBlanks", 0); rv=GWEN_DBIO_Import(dbio, sio, db, dbParams, GWEN_PATH_FLAGS_CREATE_GROUP); if (rv<0) { DBG_ERROR(AQHBCI_LOGDOMAIN, "Error parsing SWIFT %s (%d)", docType, rv); GWEN_DB_Group_free(dbParams); GWEN_DB_Group_free(db); GWEN_SyncIo_free(sio); GWEN_DBIO_free(dbio); return rv; } GWEN_DB_Group_free(dbParams); GWEN_SyncIo_free(sio); GWEN_DBIO_free(dbio); /* first count the groups */ dbDay=GWEN_DB_FindFirstGroup(db, "day"); while(dbDay) { GWEN_DB_NODE *dbT; dbT=GWEN_DB_FindFirstGroup(dbDay, "transaction"); while(dbT) { cnt++; dbT=GWEN_DB_FindNextGroup(dbT, "transaction"); } /* while */ dbDay=GWEN_DB_FindNextGroup(dbDay, "day"); } /* while */ progressId=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_DELAY | GWEN_GUI_PROGRESS_ALLOW_EMBED | GWEN_GUI_PROGRESS_SHOW_PROGRESS | GWEN_GUI_PROGRESS_SHOW_ABORT, I18N("Importing transactions..."), NULL, cnt, 0); /* add transactions to list */ dbDay=GWEN_DB_FindFirstGroup(db, "day"); while(dbDay) { GWEN_DB_NODE *dbT; dbT=GWEN_DB_FindFirstGroup(dbDay, "transaction"); while(dbT) { AB_TRANSACTION *t; t=AB_Transaction_fromDb(dbT); if (!t) { DBG_ERROR(AQHBCI_LOGDOMAIN, "Bad transaction data:"); GWEN_DB_Dump(dbT, 2); } else { const char *s; AB_Transaction_SetLocalBankCode(t, AB_User_GetBankCode(u)); AB_Transaction_SetLocalAccountNumber(t, AB_Account_GetAccountNumber(a)); /* some translations */ s=AB_Transaction_GetRemoteIban(t); if (!(s && *s)) { const char *sAid; /* no remote IBAN set, check whether the bank sends this info in the * fields for national account specifications (instead of the SWIFT * field "?38" which was specified for this case) */ sAid=AB_Transaction_GetRemoteAccountNumber(t); if (sAid && *sAid && AB_Banking_CheckIban(sAid)==0) { /* there is a remote account number specification, and that is an IBAN, * so we set that accordingly */ DBG_INFO(AQBANKING_LOGDOMAIN, "Setting remote IBAN from account number"); AB_Transaction_SetRemoteIban(t, sAid); /* set remote BIC if it not already is */ s=AB_Transaction_GetRemoteBic(t); if (!(s && *s)) { const char *sBid; sBid=AB_Transaction_GetRemoteBankCode(t); if (sBid && *sBid) { DBG_INFO(AQBANKING_LOGDOMAIN, "Setting remote BIC from bank code"); AB_Transaction_SetRemoteBic(t, sBid); } } } } DBG_INFO(AQHBCI_LOGDOMAIN, "Adding transaction"); if (noted) AB_ImExporterAccountInfo_AddNotedTransaction(ai, t); else AB_ImExporterAccountInfo_AddTransaction(ai, t); } if (GWEN_ERROR_USER_ABORTED== GWEN_Gui_ProgressAdvance(progressId, GWEN_GUI_PROGRESS_ONE)) { GWEN_Gui_ProgressEnd(progressId); return GWEN_ERROR_USER_ABORTED; } dbT=GWEN_DB_FindNextGroup(dbT, "transaction"); } /* while */ /* read all endsaldos */ if (!noted) { dbT=GWEN_DB_FindFirstGroup(dbDay, "endSaldo"); while (dbT) { GWEN_DB_NODE *dbX; GWEN_TIME *ti=0; dbX=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "date"); if (dbX) ti=GWEN_Time_fromDb(dbX); dbX=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "value"); if (dbX) { AB_VALUE *v; v=AB_Value_fromDb(dbX); if (v) { AB_BALANCE *bal; AB_ACCOUNT_STATUS *as; bal=AB_Balance_new(v, ti); AB_Value_free(v); as=AB_AccountStatus_new(); if (ti) AB_AccountStatus_SetTime(as, ti); AB_AccountStatus_SetNotedBalance(as, bal); AB_Balance_free(bal); AB_ImExporterAccountInfo_AddAccountStatus(ai, as); } } GWEN_Time_free(ti); dbT=GWEN_DB_FindNextGroup(dbT, "endSaldo"); } /* while */ } dbDay=GWEN_DB_FindNextGroup(dbDay, "day"); } /* while */ GWEN_Gui_ProgressEnd(progressId); GWEN_DB_Group_free(db); return 0; }