int AB_Provider_AccountToAccountSpec(AB_PROVIDER *pro, const AB_ACCOUNT *acc, AB_ACCOUNT_SPEC *as, int doLock) { int rv; assert(acc); assert(as); AB_AccountSpec_SetType(as, AB_Account_GetAccountType(acc)); AB_AccountSpec_SetUniqueId(as, AB_Account_GetUniqueId(acc)); AB_AccountSpec_SetBackendName(as, AB_Account_GetBackendName(acc)); AB_AccountSpec_SetOwnerName(as, AB_Account_GetOwnerName(acc)); AB_AccountSpec_SetAccountName(as, AB_Account_GetAccountName(acc)); AB_AccountSpec_SetCurrency(as, AB_Account_GetCurrency(acc)); AB_AccountSpec_SetIban(as, AB_Account_GetIban(acc)); AB_AccountSpec_SetBic(as, AB_Account_GetBic(acc)); AB_AccountSpec_SetCountry(as, AB_Account_GetCountry(acc)); AB_AccountSpec_SetBankCode(as, AB_Account_GetBankCode(acc)); AB_AccountSpec_SetAccountNumber(as, AB_Account_GetAccountNumber(acc)); AB_AccountSpec_SetSubAccountNumber(as, AB_Account_GetSubAccountId(acc)); rv=AB_Provider_UpdateAccountSpec(pro, as, doLock); if (rv<0 && rv!=GWEN_ERROR_NOT_IMPLEMENTED) { DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv); return rv; } return 0; }
static void createAccountListBoxString(const AB_ACCOUNT *a, GWEN_BUFFER *tbuf) { const char *s; char numbuf[32]; uint32_t uid; /* column 1 */ uid=AB_Account_GetUniqueId(a); snprintf(numbuf, sizeof(numbuf)-1, "%06d", uid); numbuf[sizeof(numbuf)-1]=0; GWEN_Buffer_AppendString(tbuf, numbuf); GWEN_Buffer_AppendString(tbuf, "\t"); /* column 2 */ s=AB_Account_GetBankCode(a); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); /* column 3 */ s=AB_Account_GetBankName(a); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); /* column 4 */ s=AB_Account_GetAccountNumber(a); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); /* column 5 */ s=AB_Account_GetAccountName(a); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); /* column 6 */ s=AB_Account_GetOwnerName(a); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); /* column 7 */ s=AB_Account_GetBackendName(a); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); }
int AB_Banking_LoadAllAccounts(AB_BANKING *ab) { GWEN_STRINGLIST *sl; int rv; sl=GWEN_StringList_new(); rv=GWEN_ConfigMgr_ListSubGroups(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, sl); if (rv<0) { DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv); GWEN_StringList_free(sl); return rv; } if (GWEN_StringList_Count(sl)) { GWEN_STRINGLISTENTRY *se; se=GWEN_StringList_FirstEntry(sl); while(se) { const char *t; GWEN_DB_NODE *db=NULL; t=GWEN_StringListEntry_Data(se); assert(t); rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, t, &db); if (rv<0) { DBG_WARN(AQBANKING_LOGDOMAIN, "Could not load account group [%s] (%d), ignoring", t, rv); } else { AB_ACCOUNT *a=NULL; uint32_t uid; assert(db); uid=GWEN_DB_GetIntValue(db, "uniqueId", 0, 0); if (uid) a=AB_Banking_GetAccount(ab, uid); if (a) { /* account already exists, reload existing account */ const char *s; AB_PROVIDER *pro; AB_Account_SetDbId(a, t); s=AB_Account_GetBackendName(a); assert(s && *s); pro=AB_Banking_GetProvider(ab, s); if (!pro) { DBG_WARN(AQBANKING_LOGDOMAIN, "Provider \"%s\" not found, ignoring account [%s/%s]", s, AB_Account_GetBankCode(a), AB_Account_GetAccountNumber(a)); } else { int rv; GWEN_DB_NODE *dbP; /* reload account from DB */ AB_Account_ReadDb(a, db); /* let provider also reload account data */ dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "data/backend"); rv=AB_Provider_ExtendAccount(pro, a, AB_ProviderExtendMode_Reload, dbP); if (rv<0) { DBG_WARN(AQBANKING_LOGDOMAIN, "Could not extend account [%s/%s] (%d)", AB_Account_GetBankCode(a), AB_Account_GetAccountNumber(a), rv); } } } else { /* account is new, load and add it */ a=AB_Account_fromDb(ab, db); if (a) { const char *s; AB_PROVIDER *pro; AB_Account_SetDbId(a, t); s=AB_Account_GetBackendName(a); assert(s && *s); pro=AB_Banking_GetProvider(ab, s); if (!pro) { DBG_WARN(AQBANKING_LOGDOMAIN, "Provider \"%s\" not found, ignoring account [%s/%s]", s, AB_Account_GetBankCode(a), AB_Account_GetAccountNumber(a)); } else { int rv; GWEN_DB_NODE *dbP; dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "data/backend"); rv=AB_Provider_ExtendAccount(pro, a, AB_ProviderExtendMode_Extend, dbP); if (rv) { DBG_INFO(AQBANKING_LOGDOMAIN, "here"); AB_Account_free(a); } else { DBG_DEBUG(AQBANKING_LOGDOMAIN, "Adding account"); AB_Account_List_Add(a, ab->accounts); } } } } GWEN_DB_Group_free(db); } se=GWEN_StringListEntry_Next(se); } } GWEN_StringList_free(sl); return 0; }