Ejemplo n.º 1
0
AB_USER *AB_Banking_FindUser(const AB_BANKING *ab,
                             const char *backendName,
                             const char *country,
                             const char *bankId,
                             const char *userId,
                             const char *customerId) {
  AB_USER *u;

  assert(ab);
  if (AB_User_List_GetCount(ab->users)==0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "No users");
    return 0;
  }
  u=AB_User_List_First(ab->users);
  assert(u);

  if (!backendName) backendName="*";
  if (!country) country="*";
  if (!bankId) bankId="*";
  if (!userId) userId="*";
  if (!customerId) customerId="*";

  while(u) {
    const char *lCountry;
    const char *lBankCode;
    const char *lUserId;
    const char *lCustomerId;

    lCountry=AB_User_GetCountry(u);
    if (!lCountry)
      lCountry="";
    lBankCode=AB_User_GetBankCode(u);
    if (!lBankCode)
      lBankCode="";
    lUserId=AB_User_GetUserId(u);
    if (!lUserId)
      lUserId="";
    lCustomerId=AB_User_GetCustomerId(u);
    if (!lCustomerId)
      lCustomerId="";

    if ((-1!=GWEN_Text_ComparePattern(AB_User_GetBackendName(u),
                                      backendName, 0)) &&
        (-1!=GWEN_Text_ComparePattern(lCountry,
                                      country, 0)) &&
        (-1!=GWEN_Text_ComparePattern(lBankCode,
                                      bankId, 0)) &&
        (-1!=GWEN_Text_ComparePattern(lUserId,
                                      userId, 0)) &&
        (-1!=GWEN_Text_ComparePattern(lCustomerId,
                                      customerId, 0)))
      break;
    u=AB_User_List_Next(u);
  } /* while */

  return u;
}
Ejemplo n.º 2
0
AB_USER *AB_Banking_GetUser(const AB_BANKING *ab, uint32_t uniqueId){
  AB_USER *u;

  assert(ab);
  if (AB_User_List_GetCount(ab->users)==0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "No users");
    return 0;
  }
  u=AB_User_List_First(ab->users);
  assert(u);
  while(u) {
    if (AB_User_GetUniqueId(u)==uniqueId)
      break;
    u=AB_User_List_Next(u);
  } /* while */

  return u;
}
Ejemplo n.º 3
0
AB_USER_LIST2 *AB_Banking_GetUsers(const AB_BANKING *ab){
  AB_USER_LIST2 *ul;
  AB_USER *u;

  assert(ab);
  if (AB_User_List_GetCount(ab->users)==0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "No users");
    return 0;
  }
  ul=AB_User_List2_new();
  u=AB_User_List_First(ab->users);
  assert(u);
  while(u) {
    AB_User_List2_PushBack(ul, u);
    u=AB_User_List_Next(u);
  } /* while */

  return ul;
}
Ejemplo n.º 4
0
static void AB_SetupDialog_Reload(GWEN_DIALOG *dlg)
{
  AB_SETUP_DIALOG *xdlg;
  AB_USER *u;
  AB_ACCOUNT *a;
  int i;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg);
  assert(xdlg);

  /* user list */
  i=0;
  GWEN_Dialog_SetIntProperty(dlg, "userListBox", GWEN_DialogProperty_ClearValues, 0, 0, 0);
  if (xdlg->currentUserList)
    AB_User_List_free(xdlg->currentUserList);
  xdlg->currentUserList=AB_User_List_new();
  AB_SetupDialog_LoadUsers(dlg, xdlg->currentUserList);
  if (AB_User_List_GetCount(xdlg->currentUserList)) {
    GWEN_BUFFER *tbuf;

    tbuf=GWEN_Buffer_new(0, 256, 0, 1);

    u=AB_User_List_First(xdlg->currentUserList);
    while (u) {
      createUserListBoxString(u, tbuf);
      GWEN_Dialog_SetCharProperty(dlg,
                                  "userListBox",
                                  GWEN_DialogProperty_AddValue,
                                  0,
                                  GWEN_Buffer_GetStart(tbuf),
                                  0);
      i++;
      GWEN_Buffer_Reset(tbuf);

      u=AB_User_List_Next(u);
    }
    GWEN_Buffer_free(tbuf);
  } /* if user list not empty */
  GWEN_Dialog_SetIntProperty(dlg, "userListBox", GWEN_DialogProperty_Sort, 0, 0, 0);
  if (i)
    GWEN_Dialog_SetIntProperty(dlg, "userListBox", GWEN_DialogProperty_Value, 0, 0, 0);

  /* account list */
  i=0;
  GWEN_Dialog_SetIntProperty(dlg, "accountListBox", GWEN_DialogProperty_ClearValues, 0, 0, 0);
  if (xdlg->currentAccountList)
    AB_Account_List_free(xdlg->currentAccountList);
  xdlg->currentAccountList=AB_Account_List_new();
  AB_SetupDialog_LoadAccounts(dlg, xdlg->currentAccountList);
  if (AB_Account_List_GetCount(xdlg->currentAccountList)) {
    GWEN_BUFFER *tbuf;

    tbuf=GWEN_Buffer_new(0, 256, 0, 1);

    a=AB_Account_List_First(xdlg->currentAccountList);
    while (a) {
      createAccountListBoxString(a, tbuf);
      GWEN_Dialog_SetCharProperty(dlg,
                                  "accountListBox",
                                  GWEN_DialogProperty_AddValue,
                                  0,
                                  GWEN_Buffer_GetStart(tbuf),
                                  0);
      i++;
      GWEN_Buffer_Reset(tbuf);

      a=AB_Account_List_Next(a);
    }
    GWEN_Buffer_free(tbuf);
  } /* if account list not empty */
  GWEN_Dialog_SetIntProperty(dlg, "accountListBox", GWEN_DialogProperty_Sort, 0, 0, 0);
  if (i)
    GWEN_Dialog_SetIntProperty(dlg, "accountListBox", GWEN_DialogProperty_Value, 0, 0, 0);

  AB_SetupDialog_UserChanged(dlg);
  AB_SetupDialog_AccountChanged(dlg);
}
Ejemplo n.º 5
0
int AB_Banking_AddUser(AB_BANKING *ab, AB_USER *u) {
  int rv;
  AB_USER *uTmp;
  char groupName[32];
  GWEN_DB_NODE *db;
  GWEN_DB_NODE *dbP;
  const char *s;

  assert(ab);
  assert(u);

  s=AB_User_GetUserId(u);
  if (!s || *s==0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN,
	      "Missing user id");
    return GWEN_ERROR_INVALID;
  }

  uTmp=AB_User_List_First(ab->users);
  while(uTmp) {
    if (uTmp==u) {
      DBG_INFO(AQBANKING_LOGDOMAIN,
	       "User already added!");
      return GWEN_ERROR_INVALID;
    }
    uTmp=AB_User_List_Next(uTmp);
  }

  rv=AB_Provider_ExtendUser(AB_User_GetProvider(u), u,
			    AB_ProviderExtendMode_Add,
			    NULL);
  if (rv)
    return rv;

  db=GWEN_DB_Group_new("user");
  AB_User_toDb(u, db);
  dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT,
		       "data/backend");
  rv=AB_Provider_ExtendUser(AB_User_GetProvider(u), u,
			    AB_ProviderExtendMode_Save,
			    dbP);
  if (rv) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
    GWEN_DB_Group_free(db);
    return rv;
  }

  rv=GWEN_ConfigMgr_GetUniqueId(ab->configMgr,
				AB_CFG_GROUP_USERS,
				groupName, sizeof(groupName)-1);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN,
	      "Unable to create a unique id for user [%08x] (%d)",
	      AB_User_GetUniqueId(u), rv);
    GWEN_DB_Group_free(db);
    return rv;
  }
  groupName[sizeof(groupName)-1]=0;

  rv=GWEN_ConfigMgr_LockGroup(ab->configMgr,
			      AB_CFG_GROUP_USERS,
			      groupName);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN,
	      "Unable to lock user config [%08x] (%d)",
	      AB_User_GetUniqueId(u), rv);
    GWEN_DB_Group_free(db);
    return rv;
  }

  rv=GWEN_ConfigMgr_SetGroup(ab->configMgr,
			     AB_CFG_GROUP_USERS,
			     groupName,
			     db);
  GWEN_DB_Group_free(db);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN,
	      "Unable to save user config [%08x] (%d)",
	      AB_User_GetUniqueId(u), rv);
    GWEN_ConfigMgr_UnlockGroup(ab->configMgr,
			       AB_CFG_GROUP_USERS,
			       groupName);
    return rv;
  }

  /* unlock */
  rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr,
				AB_CFG_GROUP_USERS,
				groupName);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN,
	      "Unable to unlock user config [%08x] (%d)",
	      AB_User_GetUniqueId(u), rv);
    return rv;
  }

  AB_User_SetDbId(u, groupName);
  AB_User_List_Add(u, ab->users);
  return 0;
}