Example #1
0
int AIO_OfxXmlCtx_AddData(GWEN_XML_CONTEXT *ctx, const char *data) {
  AIO_OFX_XMLCTX *xctx;

  assert(ctx);
  xctx=GWEN_INHERIT_GETDATA(GWEN_XML_CONTEXT, AIO_OFX_XMLCTX, ctx);
  assert(xctx);

  if (xctx->currentGroup) {
    int rv;

    DBG_INFO(AQBANKING_LOGDOMAIN,
	     "Calling %s->AddData()",
	     AIO_OfxGroup_GetGroupName(xctx->currentGroup));
    rv=AIO_OfxGroup_AddData(xctx->currentGroup, data);
    if (rv<0) {
      if (rv!=GWEN_ERROR_NOT_IMPLEMENTED) {
	DBG_INFO(AQBANKING_LOGDOMAIN,
		 "Error in AddData(%s)",
		 AIO_OfxGroup_GetGroupName(xctx->currentGroup));
	return rv;
      }
    }
  }

  return 0;
}
Example #2
0
int AIO_OfxGroup_Generic_EndTag(AIO_OFX_GROUP *g, const char *tagName) {
  assert(g);

  if (strcasecmp(AIO_OfxGroup_GetGroupName(g), tagName)!=0) {
    DBG_INFO(AQBANKING_LOGDOMAIN,
	     "Tag [%s] does not close [%s], ignoring",
	     tagName, AIO_OfxGroup_GetGroupName(g));
    /*return GWEN_ERROR_BAD_DATA;*/
    return 0;
  }

  /* always end this tag */
  return 1;
}
Example #3
0
int AIO_OfxGroup_BUYMF_EndSubGroup(AIO_OFX_GROUP *g, AIO_OFX_GROUP *sg) {
  AIO_OFX_GROUP_BUYMF *xg;
  const char *s;
  GWEN_XML_CONTEXT *ctx;

  assert(g);
  xg=GWEN_INHERIT_GETDATA(AIO_OFX_GROUP, AIO_OFX_GROUP_BUYMF, g);
  assert(xg);

  ctx=AIO_OfxGroup_GetXmlContext(g);
  assert(ctx);

  s=AIO_OfxGroup_GetGroupName(sg);
  if (strcasecmp(s, "INVBUY")==0 ||
      strcasecmp(s, "INVSELL")==0) {
    AB_TRANSACTION *t;

    t=AIO_OfxGroup_INVBUY_TakeTransaction(sg);
    if (t) {
      DBG_INFO(AQBANKING_LOGDOMAIN, "Adding transaction");
      xg->transaction=t;
        /*TODO*/
    }
  }

  return 0;
}
Example #4
0
int AIO_OfxGroup_ACCTINFO_EndSubGroup(AIO_OFX_GROUP *g, AIO_OFX_GROUP *sg)
{
  AIO_OFX_GROUP_ACCTINFO *xg;
  const char *s;
  GWEN_XML_CONTEXT *ctx;

  assert(g);
  xg=GWEN_INHERIT_GETDATA(AIO_OFX_GROUP, AIO_OFX_GROUP_ACCTINFO, g);
  assert(xg);

  ctx=AIO_OfxGroup_GetXmlContext(g);
  assert(ctx);

  s=AIO_OfxGroup_GetGroupName(sg);
  if (strcasecmp(s, "BANKACCTINFO")==0 ||
      strcasecmp(s, "CCACCTINFO")==0 ||
      strcasecmp(s, "BPACCTINFO")==0 ||
      strcasecmp(s, "INVACCTINFO")==0) {
    const char *s;

    s=AIO_OfxGroup_BANKACCTINFO_GetBankId(sg);
    free(xg->bankId);
    if (s)
      xg->bankId=strdup(s);
    else
      xg->bankId=NULL;

    s=AIO_OfxGroup_BANKACCTINFO_GetAccId(sg);
    free(xg->accId);
    if (s)
      xg->accId=strdup(s);
    else
      xg->accId=NULL;

    s=AIO_OfxGroup_BANKACCTINFO_GetAccType(sg);
    free(xg->accType);
    if (s)
      xg->accType=strdup(s);
    else
      xg->accType=NULL;
  }

  return 0;
}
Example #5
0
int AIO_OfxGroup_STATUS_EndTag(AIO_OFX_GROUP *g, const char *tagName)
{
  AIO_OFX_GROUP_STATUS *xg;
  //GWEN_XML_CONTEXT *ctx;

  assert(g);
  xg=GWEN_INHERIT_GETDATA(AIO_OFX_GROUP, AIO_OFX_GROUP_STATUS, g);
  assert(xg);

  //ctx=AIO_OfxGroup_GetXmlContext(g);

  assert(tagName);
  if (strcasecmp(tagName, AIO_OfxGroup_GetGroupName(g))!=0) {
    /* tag does not close this one */
    DBG_DEBUG(AQBANKING_LOGDOMAIN,
              "Tag [%s] does not close [%s], ignoring",
              tagName, AIO_OfxGroup_GetGroupName(g));
    return 0;
  }

  /* show status message */
  if (xg->description) {
    GWEN_BUFFER *buf;
    char numbuf[32];
    const AIO_OFX_GROUP_STATUS_ERROR *e;

    e=AIO_OfxGroup_STATUS__getErrorStruct(xg->code);
    buf=GWEN_Buffer_new(0, 256, 0, 1);
    GWEN_Buffer_AppendString(buf, xg->description);
    GWEN_Buffer_AppendString(buf, ": ");

    /* append error string if available */
    if (e && e->name) {
      GWEN_Buffer_AppendString(buf, I18N(e->name));
      GWEN_Buffer_AppendString(buf, " (");
    }
    GWEN_Buffer_AppendString(buf, I18N("Code"));
    GWEN_Buffer_AppendString(buf, " ");
    snprintf(numbuf, sizeof(numbuf)-1, "%d", xg->code);
    numbuf[sizeof(numbuf)-1]=0;
    GWEN_Buffer_AppendString(buf, numbuf);
    if (xg->severity) {
      GWEN_Buffer_AppendString(buf, ", ");
      GWEN_Buffer_AppendString(buf, I18N("severity"));
      GWEN_Buffer_AppendString(buf, " \"");
      GWEN_Buffer_AppendString(buf, xg->severity);
      GWEN_Buffer_AppendString(buf, "\"");
    }

    if (e && e->name) {
      GWEN_Buffer_AppendString(buf, ")");
    }

    /* append error description if available */
    if (e && e->description) {
      GWEN_Buffer_AppendString(buf, "\n");
      GWEN_Buffer_AppendString(buf, I18N(e->description));
    }
    DBG_INFO(AQBANKING_LOGDOMAIN,
             "%s", GWEN_Buffer_GetStart(buf));
    GWEN_Gui_ProgressLog(0,
                         GWEN_LoggerLevel_Notice,
                         GWEN_Buffer_GetStart(buf));
    GWEN_Buffer_free(buf);
  }
  if (xg->oldEndTagFn)
    return xg->oldEndTagFn(g, tagName);
  else
    return 1;
}
Example #6
0
int AIO_OfxXmlCtx_EndTag(GWEN_XML_CONTEXT *ctx, int closing) {
  AIO_OFX_XMLCTX *xctx;

  assert(ctx);
  xctx=GWEN_INHERIT_GETDATA(GWEN_XML_CONTEXT, AIO_OFX_XMLCTX, ctx);
  assert(xctx);

  if (closing) {
    /* just ignore empty tags which are closed immediately */
    DBG_INFO(AQBANKING_LOGDOMAIN, "Closing empty tag [%s]",
	     (xctx->currentTagName)?xctx->currentTagName:"<noname>");
    return 0;
  }

  if (xctx->currentTagName==NULL) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "No tag name, malformed OFX file");
    return GWEN_ERROR_BAD_DATA;
  }

  DBG_INFO(AQBANKING_LOGDOMAIN, "Completed tag [%s]", xctx->currentTagName);

  if (xctx->currentGroup) {
    if (*(xctx->currentTagName)=='/') {
      int rv;
      int endingOfxDoc=0;

      if (strcasecmp(xctx->currentTagName, "/OFX")==0) {
	DBG_INFO(AQBANKING_LOGDOMAIN, "End of OFX document reached, will reset depth to %d",
		 xctx->startDepthOfOfxElement);
	endingOfxDoc=1;
      }

      /* it is a closing tag, call EndTagFn */
      DBG_INFO(AQBANKING_LOGDOMAIN,
	       "Calling %s->EndTag(%s)",
	       AIO_OfxGroup_GetGroupName(xctx->currentGroup),
	       xctx->currentTagName);
      rv=AIO_OfxGroup_EndTag(xctx->currentGroup, xctx->currentTagName+1);
      if (rv<0) {
	if (rv!=GWEN_ERROR_NOT_IMPLEMENTED) {
	  DBG_INFO(AQBANKING_LOGDOMAIN,
		   "Error in EndTag(%s) for [%s]",
		   AIO_OfxGroup_GetGroupName(xctx->currentGroup),
		   xctx->currentTagName);
	  return rv;
	}
      }
      else if (rv==1) {
        AIO_OFX_GROUP *g;
	AIO_OFX_GROUP *gParent;

	/* pop current group from stack */
	g=xctx->currentGroup;
	gParent=AIO_OfxGroup_GetParent(g);
	xctx->currentGroup=gParent;
	if (gParent) {
	  DBG_INFO(AQBANKING_LOGDOMAIN,
		   "Calling %s->EndSubGroup(%s)",
		   AIO_OfxGroup_GetGroupName(gParent),
                   AIO_OfxGroup_GetGroupName(g));
	  AIO_OfxGroup_EndSubGroup(gParent, g);
	}
	AIO_OfxGroup_free(g);
	GWEN_XmlCtx_DecDepth(ctx);
      }

      if (endingOfxDoc) {
	/* TODO: Tags which have no closing element should decrease the depth by themselves... */
	DBG_INFO(AQBANKING_LOGDOMAIN, "End of OFX document reached, resetting depth to %d",
		 xctx->startDepthOfOfxElement);
	GWEN_XmlCtx_SetDepth(ctx, xctx->startDepthOfOfxElement);
      }
    }
    else {
      int rv;

      if (strcasecmp(xctx->currentTagName, "OFX")==0) {
	DBG_INFO(AQBANKING_LOGDOMAIN, "Start of OFX document reached, storing depth");
	xctx->startDepthOfOfxElement=GWEN_XmlCtx_GetDepth(ctx);
      }

      /* it is an opening tag, call StartTagFn */
      DBG_INFO(AQBANKING_LOGDOMAIN,
	       "Calling %s->StartTag(%s)",
	       AIO_OfxGroup_GetGroupName(xctx->currentGroup),
	       xctx->currentTagName);
      rv=AIO_OfxGroup_StartTag(xctx->currentGroup, xctx->currentTagName);
      if (rv<0) {
	if (rv!=GWEN_ERROR_NOT_IMPLEMENTED) {
	  DBG_INFO(AQBANKING_LOGDOMAIN,
		   "Error in StartTag(%s) for [%s]",
		   AIO_OfxGroup_GetGroupName(xctx->currentGroup),
		   xctx->currentTagName);
	  return rv;
	}
      }
    }
  }

  return 0;
}