int AB_Banking_BeginExclUseAccount(AB_BANKING *ab, AB_ACCOUNT *a) { GWEN_DB_NODE *db=NULL; GWEN_DB_NODE *dbP; int rv; assert(ab); /* check for config manager (created by AB_Banking_Init) */ if (ab->configMgr==NULL) { DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?"); return GWEN_ERROR_GENERIC; } /* lock group */ rv=GWEN_ConfigMgr_LockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); if (rv<0) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to lock account config group (%d)", rv); return rv; } /* load group (is locked now) */ rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a), &db); if (rv<0) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not load account group (%d)", rv); GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); return rv; } 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(AB_Account_GetProvider(a), 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); GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); GWEN_DB_Group_free(db); return rv; } GWEN_DB_Group_free(db); return 0; }
int AB_SetupDialog_EditAccount(GWEN_DIALOG *dlg) { AB_SETUP_DIALOG *xdlg; assert(dlg); xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg); assert(xdlg); if (xdlg->currentAccountList) { uint32_t aid; aid=AB_SetupDialog_GetCurrentAccountId(dlg); if (aid) { AB_ACCOUNT *a; a=AB_Account_List_GetByUniqueId(xdlg->currentAccountList, aid); if (a) { AB_PROVIDER *pro; uint32_t flags=0; GWEN_DIALOG *dlg2; int rv; pro=AB_Account_GetProvider(a); assert(pro); flags=AB_Provider_GetFlags(pro); if (flags & AB_PROVIDER_FLAGS_HAS_EDITACCOUNT_DIALOG) dlg2=AB_Provider_GetEditAccountDialog(pro, a); else dlg2=AB_EditAccountDialog_new(pro, a, 1); if (dlg2==NULL) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog"); return GWEN_DialogEvent_ResultHandled; } rv=GWEN_Gui_ExecDialog(dlg2, 0); if (rv==0) { /* rejected */ GWEN_Dialog_free(dlg2); return GWEN_DialogEvent_ResultHandled; } GWEN_Dialog_free(dlg2); AB_SetupDialog_Reload(dlg); } /* if a */ } /* if aid */ else { DBG_ERROR(AQBANKING_LOGDOMAIN, "No current account"); } } /* if xdlg->currentAccountList */ return GWEN_DialogEvent_ResultHandled; }
int AB_Banking_EndExclUseAccount(AB_BANKING *ab, AB_ACCOUNT *a, int abandon) { int rv; if (!abandon) { GWEN_DB_NODE *db=GWEN_DB_Group_new("account"); GWEN_DB_NODE *dbP; AB_Account_toDb(a, db); dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "data/backend"); rv=AB_Provider_ExtendAccount(AB_Account_GetProvider(a), a, AB_ProviderExtendMode_Save, dbP); if (rv) { DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv); GWEN_DB_Group_free(db); return rv; } /* save group (still locked) */ rv=GWEN_ConfigMgr_SetGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a), db); if (rv<0) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not save account group (%d)", rv); GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); GWEN_DB_Group_free(db); return rv; } GWEN_DB_Group_free(db); } /* unlock group */ rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); if (rv<0) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not unlock account group (%d)", rv); return rv; } return 0; }
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 = i18nc("replacement for institution or account w/o name", "(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 = i18nc("replacement for institution or account w/o name", "(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 = i18nc("replacement for institution or account w/o name", "(unnamed)"); setText(i++, tmp); }
static PyObject * aqbanking_listacc(PyObject *self, PyObject *args) { int rv; AB_ACCOUNT_LIST2 *accs; // List of accounts => to return. PyObject *accountList; aqbanking_Account *account; accountList = PyList_New(0); // Initialize aqbanking. rv = AB_create(NULL); if (rv > 0) { return NULL; } /* Get a list of accounts which are known to AqBanking. * There are some pecularities about the list returned: * The list itself is owned by the caller (who must call * AB_Account_List2_free() as we do below), but the elements of that * list (->the accounts) are still owned by AqBanking. * Therefore you MUST NOT free any of the accounts within the list returned. * This also rules out calling AB_Account_List2_freeAll() which not only * frees the list itself but also frees all its elements. * * The rest of this tutorial shows how lists are generally used by * AqBanking. */ accs = AB_Banking_GetAccounts(ab); if (accs) { AB_ACCOUNT_LIST2_ITERATOR *it; /* List2's are traversed using iterators. An iterator is an object * which points to a single element of a list. * If the list is empty NULL is returned. */ it=AB_Account_List2_First(accs); if (it) { AB_ACCOUNT *a; /* this function returns a pointer to the element of the list to * which the iterator currently points to */ a=AB_Account_List2Iterator_Data(it); while(a) { AB_PROVIDER *pro; account = (aqbanking_Account*) PyObject_CallObject((PyObject *) &aqbanking_AccountType, NULL); /* every account is assigned to a backend (sometimes called provider) * which actually performs online banking tasks. We get a pointer * to that provider/backend with this call to show its name in our * example.*/ pro = AB_Account_GetProvider(a); // Populate the object. account->no = PyUnicode_FromString(AB_Account_GetAccountNumber(a)); account->name = PyUnicode_FromString(AB_Account_GetAccountName(a)); account->description = PyUnicode_FromString(AB_Provider_GetName(pro)); account->bank_code = PyUnicode_FromString(AB_Account_GetBankCode(a)); account->bank_name = PyUnicode_FromString(AB_Account_GetBankName(a)); PyList_Append(accountList, (PyObject *)account); Py_DECREF(account); /* this function lets the iterator advance to the next element in * the list, so a following call to AB_Account_List2Iterator_Data() * would return a pointer to the next element. * This function also returns a pointer to the next element of the * list. If there is no next element then NULL is returned. */ a = AB_Account_List2Iterator_Next(it); } /* the iterator must be freed after using it */ AB_Account_List2Iterator_free(it); } /* as discussed the list itself is only a container which has to be freed * after use. This explicitly does not free any of the elements in that * list, and it shouldn't because AqBanking still is the owner of the * accounts */ AB_Account_List2_free(accs); } // Exit aqbanking. rv = AB_free(NULL); if (rv > 0) { Py_DECREF(account); Py_DECREF(accountList); return NULL; } return accountList; }
int main(int argc, char **argv) { AB_BANKING *ab; AB_ACCOUNT_LIST2 *accs; int rv; GWEN_GUI *gui; gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); ab=AB_Banking_new("tutorial2", 0, 0); rv=AB_Banking_Init(ab); if (rv) { fprintf(stderr, "Error on init (%d)\n", rv); return 2; } rv=AB_Banking_OnlineInit(ab); if (rv) { fprintf(stderr, "Error on onlineinit (%d)\n", rv); return 2; } fprintf(stderr, "AqBanking successfully initialized.\n"); /* Get a list of accounts which are known to AqBanking. * There are some pecularities about the list returned: * The list itself is owned by the caller (who must call * AB_Account_List2_free() as we do below), but the elements of that * list (->the accounts) are still owned by AqBanking. * Therefore you MUST NOT free any of the accounts within the list returned. * This also rules out calling AB_Account_List2_freeAll() which not only * frees the list itself but also frees all its elements. * * The rest of this tutorial shows how lists are generally used by * AqBanking. */ accs=AB_Banking_GetAccounts(ab); if (accs) { AB_ACCOUNT_LIST2_ITERATOR *it; /* List2's are traversed using iterators. An iterator is an object * which points to a single element of a list. * If the list is empty NULL is returned. */ it=AB_Account_List2_First(accs); if (it) { AB_ACCOUNT *a; /* this function returns a pointer to the element of the list to * which the iterator currently points to */ a=AB_Account_List2Iterator_Data(it); while(a) { AB_PROVIDER *pro; /* every account is assigned to a backend (sometimes called provider) * which actually performs online banking tasks. We get a pointer * to that provider/backend with this call to show its name in our * example.*/ pro=AB_Account_GetProvider(a); fprintf(stderr, "Account: %s (%s) %s (%s) [%s]\n", AB_Account_GetBankCode(a), AB_Account_GetBankName(a), AB_Account_GetAccountNumber(a), AB_Account_GetAccountName(a), /* the name of the provider/backend as decribed above */ AB_Provider_GetName(pro)); /* this function lets the iterator advance to the next element in * the list, so a following call to AB_Account_List2Iterator_Data() * would return a pointer to the next element. * This function also returns a pointer to the next element of the * list. If there is no next element then NULL is returned. */ a=AB_Account_List2Iterator_Next(it); } /* the iterator must be freed after using it */ AB_Account_List2Iterator_free(it); } /* as discussed the list itself is only a container which has to be freed * after use. This explicitly does not free any of the elements in that * list, and it shouldn't because AqBanking still is the owner of the * accounts */ AB_Account_List2_free(accs); } rv=AB_Banking_OnlineFini(ab); if (rv) { fprintf(stderr, "ERROR: Error on online deinit (%d)\n", rv); return 3; } rv=AB_Banking_Fini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 3; } AB_Banking_free(ab); return 0; }
int AB_SetupDialog_DelUser(GWEN_DIALOG *dlg) { AB_SETUP_DIALOG *xdlg; assert(dlg); xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg); assert(xdlg); if (xdlg->currentUserList) { uint32_t uid; uid=AB_SetupDialog_GetCurrentUserId(dlg); if (uid) { AB_USER *u; u=AB_User_List_GetByUniqueId(xdlg->currentUserList, uid); if (u) { AB_ACCOUNT *a; uint32_t aid; int rv; char nbuf[512]; snprintf(nbuf, sizeof(nbuf)-1, I18N("<html>" "<p>Do you really want to delete the user <i>%s</i>?" "</html>" "Do you really want to delete the user \"%s\"?"), AB_User_GetUserId(u), AB_User_GetUserId(u)); nbuf[sizeof(nbuf)-1]=0; rv=GWEN_Gui_MessageBox(GWEN_GUI_MSG_FLAGS_TYPE_WARN | GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS, I18N("Delete User"), nbuf, I18N("Yes"), I18N("No"), NULL, 0); if (rv!=1) { DBG_INFO(AQBANKING_LOGDOMAIN, "Aborted by user"); return GWEN_DialogEvent_ResultHandled; } xdlg->currentAccountList=AB_Account_List_new(); AB_SetupDialog_LoadAccounts(dlg, xdlg->currentAccountList); if (AB_Account_List_GetCount(xdlg->currentAccountList)) { a=AB_Account_List_First(xdlg->currentAccountList); while (a) { if (AB_Account_GetUserId(a) == uid) { aid=AB_Account_GetUniqueId(a); rv=GWEN_Gui_MessageBox(GWEN_GUI_MSG_FLAGS_TYPE_ERROR | GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS, I18N("Error"), I18N("<html>" "<p>There is at least one account assigned to the selected user.</p>" "<p>Do you want to remove the account(s) and continue removing the user?</p>" "</html>" "There is at least one account assigned to the selected user.\n" "Do you want to remove the account(s) and continue removing the user?"), I18N("Yes"), I18N("No"), NULL, 0); if (rv!=1) { DBG_INFO(AQBANKING_LOGDOMAIN, "Aborted by user"); return GWEN_DialogEvent_ResultHandled; } rv=AB_Provider_DeleteAccount(AB_Account_GetProvider(a), aid); if (rv<0) { GWEN_Gui_ShowError(I18N("Error"), I18N("Error deleting account: %d (%d deleted)"), rv, aid); AB_SetupDialog_Reload(dlg); return GWEN_DialogEvent_ResultHandled; } } a=AB_Account_List_Next(a); } } /* now delete the user */ rv=AB_Provider_DeleteUser(AB_User_GetProvider(u), uid); if (rv<0) { GWEN_Gui_ShowError(I18N("Error"), I18N("Error deleting user: %d"), rv); AB_SetupDialog_Reload(dlg); return GWEN_DialogEvent_ResultHandled; } } /* if u */ } /* if uid */ AB_SetupDialog_Reload(dlg); } /* if currentUserList */ return GWEN_DialogEvent_ResultHandled; }
int AB_SetupDialog_DelAccount(GWEN_DIALOG *dlg) { AB_SETUP_DIALOG *xdlg; assert(dlg); xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg); assert(xdlg); if (xdlg->currentAccountList) { uint32_t aid; aid=AB_SetupDialog_GetCurrentAccountId(dlg); if (aid) { AB_ACCOUNT *a; a=AB_Account_List_GetByUniqueId(xdlg->currentAccountList, aid); if (a) { int rv; char nbuf[512]; char ibuf[32]; const char *an; an=AB_Account_GetAccountName(a); if (!(an && *an)) an=AB_Account_GetAccountNumber(a); if (!(an && *an)) { snprintf(ibuf, sizeof(ibuf)-1, "%d", (int) AB_Account_GetUniqueId(a)); ibuf[sizeof(ibuf)-1]=0; an=ibuf; } snprintf(nbuf, sizeof(nbuf)-1, I18N("<html>" "<p>Do you really want to delete the account <i>%s</i>?" "</html>" "Do you really want to delete the account \"%s\"?"), an, an); nbuf[sizeof(nbuf)-1]=0; rv=GWEN_Gui_MessageBox(GWEN_GUI_MSG_FLAGS_TYPE_WARN | GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS, I18N("Delete Account"), nbuf, I18N("Yes"), I18N("No"), NULL, 0); if (rv!=1) { DBG_INFO(AQBANKING_LOGDOMAIN, "Aborted by user"); return GWEN_DialogEvent_ResultHandled; } rv=AB_Provider_DeleteAccount(AB_Account_GetProvider(a), aid); if (rv<0) { GWEN_Gui_ShowError(I18N("Error"), I18N("Error deleting account: %d"), rv); AB_SetupDialog_Reload(dlg); return GWEN_DialogEvent_ResultHandled; } AB_SetupDialog_Reload(dlg); } /* if a */ } /* if aid */ } /* if xdlg->currentAccountList */ return GWEN_DialogEvent_ResultHandled; }
void KBJobListViewItem::_populate() { QString tmp; int i; AB_ACCOUNT *a; const char *p; assert(_job); i = 0; a = AB_Job_GetAccount(_job); assert(a); // job id setText(i++, QString::number(AB_Job_GetJobId(_job))); // job type switch (AB_Job_GetType(_job)) { case AB_Job_TypeGetBalance: tmp = i18n("Get Balance"); break; case AB_Job_TypeGetTransactions: tmp = i18n("Get Transactions"); break; case AB_Job_TypeTransfer: tmp = i18n("Transfer"); break; case AB_Job_TypeDebitNote: tmp = i18n("Debit Note"); break; default: tmp = i18nc("Unknown job type", "(unknown)"); break; } setText(i++, tmp); // bank name tmp = AB_Account_GetBankName(a); if (tmp.isEmpty()) tmp = AB_Account_GetBankCode(a); if (tmp.isEmpty()) tmp = i18nc("Unknown bank code", "(unknown)"); setText(i++, tmp); // account name tmp = AB_Account_GetAccountName(a); if (tmp.isEmpty()) tmp = AB_Account_GetAccountNumber(a); if (tmp.isEmpty()) tmp = i18nc("Unknown account number", "(unknown)"); setText(i++, tmp); // status switch (AB_Job_GetStatus(_job)) { case AB_Job_StatusNew: tmp = i18nc("Status of the job", "new"); break; case AB_Job_StatusUpdated: tmp = i18nc("Status of the job", "updated"); break; case AB_Job_StatusEnqueued: tmp = i18nc("Status of the job", "enqueued"); break; case AB_Job_StatusSent: tmp = i18nc("Status of the job", "sent"); break; case AB_Job_StatusPending: tmp = i18nc("Status of the job", "pending"); break; case AB_Job_StatusFinished: tmp = i18nc("Status of the job", "finished"); break; case AB_Job_StatusError: tmp = i18nc("Status of the job", "error"); break; default: tmp = i18nc("Status of the job", "(unknown)"); break; } setText(i++, tmp); p = AB_Provider_GetName(AB_Account_GetProvider(a)); if (!p) tmp = i18nc("Unknown account provider", "(unknown)"); else tmp = p; setText(i++, tmp); p = AB_Job_GetCreatedBy(_job); if (!p) tmp = i18nc("Unknown creator of the job", "(unknown)"); else tmp = p; setText(i++, tmp); }
int AB_Banking_SaveAccountConfig(AB_BANKING *ab, AB_ACCOUNT *a, int doLock) { GWEN_DB_NODE *db; GWEN_DB_NODE *dbP; int rv; assert(ab); /* check for config manager (created by AB_Banking_Init) */ if (ab->configMgr==NULL) { DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?"); return GWEN_ERROR_GENERIC; } if (doLock) { /* lock group */ rv=GWEN_ConfigMgr_LockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); if (rv<0) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to lock account config group (%d)", rv); return rv; } } db=GWEN_DB_Group_new("account"); AB_Account_toDb(a, db); /* let backend save its data */ dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "data/backend"); rv=AB_Provider_ExtendAccount(AB_Account_GetProvider(a), a, AB_ProviderExtendMode_Save, dbP); if (rv<0) { DBG_WARN(AQBANKING_LOGDOMAIN, "Could not extend account [%s/%s] (%d)", AB_Account_GetBankCode(a), AB_Account_GetAccountNumber(a), rv); GWEN_DB_Group_free(db); if (doLock) GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); return rv; } /* save group (still locked) */ rv=GWEN_ConfigMgr_SetGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a), db); if (rv<0) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not save account group (%d)", rv); if (doLock) { GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); } GWEN_DB_Group_free(db); return rv; } GWEN_DB_Group_free(db); if (doLock) { /* unlock group */ rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, AB_Account_GetDbId(a)); if (rv<0) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not unlock account group (%d)", rv); return rv; } } return 0; }