Exemple #1
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;
}
Exemple #2
0
void AB_SelectBankInfoDialog_UpdateList(GWEN_DIALOG *dlg)
{
  AB_SELECTBANKINFO_DIALOG *xdlg;
  AB_BANKINFO *tbi;
  const char *s;
  AB_BANKINFO_LIST2 *bl;
  int rv;

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

  /* clear bank info list */
  GWEN_Dialog_SetIntProperty(dlg, "listBox", GWEN_DialogProperty_ClearValues, 0, 0, 0);
  if (xdlg->matchingBankInfos)
    AB_BankInfo_List2_freeAll(xdlg->matchingBankInfos);
  xdlg->matchingBankInfos=NULL;

  /* setup template */
  tbi=AB_BankInfo_new();

  /* set country */
  AB_BankInfo_SetCountry(tbi, xdlg->country);

  /* set bank code */
  s=GWEN_Dialog_GetCharProperty(dlg, "blzEdit", GWEN_DialogProperty_Value, 0, NULL);
  if (s && *s) {
    int len;
    char *cpy;

    len=strlen(s);
    cpy=(char *) malloc(len+2);
    assert(cpy);
    memmove(cpy, s, len+1); /* copy including terminating zero char */
    removeAllSpaces((uint8_t *)cpy);
    len=strlen(cpy);
    if (len) {
      /* append joker */
      cpy[len]='*';
      cpy[len+1]=0;
    }
    AB_BankInfo_SetBankId(tbi, cpy);
    free(cpy);
  }

  /* set bank code */
  s=GWEN_Dialog_GetCharProperty(dlg, "bicEdit", GWEN_DialogProperty_Value, 0, NULL);
  if (s && *s) {
    int len;
    char *cpy;

    len=strlen(s);
    cpy=(char *) malloc(len+2);
    assert(cpy);
    memmove(cpy, s, len+1); /* copy including terminating zero char */
    removeAllSpaces((uint8_t *)cpy);
    len=strlen(cpy);
    if (len) {
      /* append joker */
      cpy[len]='*';
      cpy[len+1]=0;
    }
    AB_BankInfo_SetBic(tbi, cpy);
    free(cpy);
  }

  /* set bank name */
  s=GWEN_Dialog_GetCharProperty(dlg, "nameEdit", GWEN_DialogProperty_Value, 0, NULL);
  if (s && *s) {
    GWEN_BUFFER *tbuf;

    tbuf=GWEN_Buffer_new(0, 256, 0, 1);
    GWEN_Buffer_AppendString(tbuf, s);
    GWEN_Text_CondenseBuffer(tbuf);
    GWEN_Buffer_AppendString(tbuf, "*");
    AB_BankInfo_SetBankName(tbi, GWEN_Buffer_GetStart(tbuf));
    GWEN_Buffer_free(tbuf);
  }

  /* set bank name */
  s=GWEN_Dialog_GetCharProperty(dlg, "locationEdit", GWEN_DialogProperty_Value, 0, NULL);
  if (s && *s) {
    GWEN_BUFFER *tbuf;

    tbuf=GWEN_Buffer_new(0, 256, 0, 1);
    GWEN_Buffer_AppendString(tbuf, s);
    GWEN_Text_CondenseBuffer(tbuf);
    GWEN_Buffer_AppendString(tbuf, "*");
    AB_BankInfo_SetLocation(tbi, GWEN_Buffer_GetStart(tbuf));
    GWEN_Buffer_free(tbuf);
  }

  bl=AB_BankInfo_List2_new();
  rv=AB_Banking_GetBankInfoByTemplate(xdlg->banking, xdlg->country, tbi, bl);
  if (rv<0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
    AB_BankInfo_List2_freeAll(bl);
  }
  else {
    AB_BANKINFO_LIST2_ITERATOR *it;

    it=AB_BankInfo_List2_First(bl);
    if (it) {
      AB_BANKINFO *bi;
      GWEN_BUFFER *tbuf;

      tbuf=GWEN_Buffer_new(0, 256, 0, 1);
      bi=AB_BankInfo_List2Iterator_Data(it);
      while (bi) {
        createListBoxString(bi, tbuf);

        GWEN_Dialog_SetCharProperty(dlg,
                                    "listBox",
                                    GWEN_DialogProperty_AddValue,
                                    0,
                                    GWEN_Buffer_GetStart(tbuf),
                                    0);
        GWEN_Buffer_Reset(tbuf);
        bi=AB_BankInfo_List2Iterator_Next(it);
      }

      GWEN_Buffer_free(tbuf);
      AB_BankInfo_List2Iterator_free(it);
    }
    xdlg->matchingBankInfos=bl;
  }

  AB_BankInfo_free(tbi);

  if (GWEN_Dialog_GetIntProperty(dlg, "listBox", GWEN_DialogProperty_Value, 0, -1)>=0)
    GWEN_Dialog_SetIntProperty(dlg, "okButton", GWEN_DialogProperty_Enabled, 0, 1, 0);
  else
    GWEN_Dialog_SetIntProperty(dlg, "okButton", GWEN_DialogProperty_Enabled, 0, 0, 0);
}