Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
static int readTestData(GWEN_DIALOG *dlg)
{
  AB_CSV_EDIT_PROFILE_DIALOG *xdlg;
  GWEN_SYNCIO *sio;
  GWEN_SYNCIO *baseIo;
  GWEN_BUFFER *dbuf;
  int i;
  int ignoreLines=0;
  int rv;
  const char *delimiter;
  GWEN_BUFFER *wbuffer;
  const char *s;

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

  GWEN_StringList_Clear(xdlg->columns);

  /* create file IO */
  sio=GWEN_SyncIo_File_new(xdlg->testFileName, GWEN_SyncIo_File_CreationMode_OpenExisting);
  GWEN_SyncIo_AddFlags(sio, GWEN_SYNCIO_FILE_FLAGS_READ);
  baseIo=sio;

  /* create buffered IO on top of file io to allow for reading of lines below */
  sio=GWEN_SyncIo_Buffered_new(baseIo);

  dbuf=GWEN_Buffer_new(0, 1024, 0, 1);

  /* skip lines */
  ignoreLines=GWEN_Dialog_GetIntProperty(dlg, "ignoreLinesSpin", GWEN_DialogProperty_Value, 0, 0);
  i=GWEN_Dialog_GetIntProperty(dlg, "headerCheck", GWEN_DialogProperty_Value, 0, 0);
  if (i)
    ignoreLines++;

  delimiter=getCharValueFromDoubleStringsCombo(dlg, "delimiterCombo", csv_delimiters);
  if (!(delimiter && *delimiter))
    delimiter="TAB";
  if (strcasecmp(delimiter, "TAB")==0)
    delimiter="\t";
  else if (strcasecmp(delimiter, "SPACE")==0)
    delimiter=" ";

  /* open file */
  rv=GWEN_SyncIo_Connect(sio);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_Buffer_free(dbuf);
    GWEN_SyncIo_free(sio);
    return rv;
  }

  for (i=0; i<ignoreLines; i++) {
    rv=GWEN_SyncIo_Buffered_ReadLineToBuffer(sio, dbuf);
    if (rv<0) {
      DBG_ERROR(AQBANKING_LOGDOMAIN, "Error reading: %d", rv);
      GWEN_Buffer_free(dbuf);
      GWEN_SyncIo_Disconnect(sio);
      GWEN_SyncIo_free(sio);
      return rv;
    }
    GWEN_Buffer_Reset(dbuf);
  }

  /* read single data line */
  rv=GWEN_SyncIo_Buffered_ReadLineToBuffer(sio, dbuf);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Error reading: %d", rv);
    GWEN_Buffer_free(dbuf);
    GWEN_SyncIo_Disconnect(sio);
    GWEN_SyncIo_free(sio);
    return rv;
  }

  GWEN_Dialog_SetCharProperty(dlg, "dataEdit", GWEN_DialogProperty_Value, 0,
                              GWEN_Buffer_GetStart(dbuf), 0);

  /* we don't need the io layer any longer */
  GWEN_SyncIo_Disconnect(sio);
  GWEN_SyncIo_free(sio);

  wbuffer=GWEN_Buffer_new(0, 256, 0, 1);
  s=GWEN_Buffer_GetStart(dbuf);
  while (*s) {
    rv=GWEN_Text_GetWordToBuffer(s, delimiter, wbuffer,
                                 GWEN_TEXT_FLAGS_DEL_LEADING_BLANKS |
                                 GWEN_TEXT_FLAGS_DEL_TRAILING_BLANKS |
                                 GWEN_TEXT_FLAGS_NULL_IS_DELIMITER |
                                 GWEN_TEXT_FLAGS_DEL_QUOTES,
                                 &s);
    if (rv) {
      DBG_DEBUG(AQBANKING_LOGDOMAIN, "here (%d)", rv);
      GWEN_Buffer_free(wbuffer);
      GWEN_Buffer_free(dbuf);
      return rv;
    }
    GWEN_StringList_AppendString(xdlg->columns, GWEN_Buffer_GetStart(wbuffer), 0, 0);
    GWEN_Buffer_Reset(wbuffer);
    if (*s) {
      if (strchr(delimiter, *s))
        s++;
    }
  } /* while */
  GWEN_Buffer_free(wbuffer);

  for (i=0; i<DIALOG_MAX_COLUMNS; i++) {
    char editName[32];

    snprintf(editName, sizeof(editName)-1, "col%dDataEdit", i+1);
    s=GWEN_StringList_StringAt(xdlg->columns, i);
    if (s==NULL)
      break;
    GWEN_Dialog_SetCharProperty(dlg, editName, GWEN_DialogProperty_Value, 0, s, 0);
  }

  return 0;
}
Ejemplo n.º 3
0
void AB_TransactionLimits_ClearValuesTextKey(AB_TRANSACTION_LIMITS *st) {
  if (GWEN_StringList_Count(st->valuesTextKey)) {
    GWEN_StringList_Clear(st->valuesTextKey);
    st->_modified=1;
  }
}
Ejemplo n.º 4
0
void AB_TransactionLimits_ClearValuesExecutionDayMonth(AB_TRANSACTION_LIMITS *st) {
  if (GWEN_StringList_Count(st->valuesExecutionDayMonth)) {
    GWEN_StringList_Clear(st->valuesExecutionDayMonth);
    st->_modified=1;
  }
}
Ejemplo n.º 5
0
int AB_Banking_HasConf4(AB_BANKING *ab) {
  int rv;
  GWEN_DB_NODE *db=NULL;
  int backends=0;
  int users=0;
  int accounts=0;
  GWEN_STRINGLIST *sl;

  /* 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 correctly?");
    return GWEN_ERROR_GENERIC;
  }

  /* load main group, check version */
  rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, AB_CFG_GROUP_MAIN, "config", &db);
  if (rv<0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "Could not load main config group (%d)", rv);
    return rv;
  }
  GWEN_DB_Group_free(db);

  sl=GWEN_StringList_new();

  /* count backends */
  rv=GWEN_ConfigMgr_ListSubGroups(ab->configMgr, AB_CFG_GROUP_BACKENDS, sl);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not list backend groups (%d)", rv);
    GWEN_StringList_free(sl);
    return rv;
  }
  backends=GWEN_StringList_Count(sl);
  GWEN_StringList_Clear(sl);

  /* count users */
  rv=GWEN_ConfigMgr_ListSubGroups(ab->configMgr, AB_CFG_GROUP_USERS, sl);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not list user groups (%d)", rv);
    GWEN_StringList_free(sl);
    return rv;
  }
  users=GWEN_StringList_Count(sl);
  GWEN_StringList_Clear(sl);

  /* count accounts */
  rv=GWEN_ConfigMgr_ListSubGroups(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, sl);
  if (rv<0) {
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not list account groups (%d)", rv);
    GWEN_StringList_free(sl);
    return rv;
  }
  accounts=GWEN_StringList_Count(sl);

  GWEN_StringList_free(sl);

  if (users)
    return 0;
  if (backends || accounts)
    return GWEN_ERROR_PARTIAL;

  return GWEN_ERROR_NO_DATA;
}