00001
00002
00003
00004
00005
00006
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifdef HAVE_CONFIG_H
00023
#include <config.h>
00024
#endif
00025
00026
#include <iostream>
00027
#include <stdlib.h>
00028
#include <string>
00029
#include "messages.hh"
00030
#include "libofx.h"
00031
#include "ofx_error_msg.hh"
00032
#include "ofx_utilities.hh"
00033
#include "ofx_containers.hh"
00034
00035
extern OfxMainContainer * MainContainer;
00036
00037
00038
00039
00040
00041 OfxDummyContainer::OfxDummyContainer(LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
00042
OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
00043 {
00044
type=
"DUMMY";
00045
message_out(INFO,
"Created OfxDummyContainer to hold unsupported aggregate "+para_tag_identifier);
00046 }
00047 void OfxDummyContainer::add_attribute(
const string identifier,
const string value)
00048 {
00049
message_out(
DEBUG,
"OfxDummyContainer for "+tag_identifier+
" ignored a "+identifier+
" ("+value+
")");
00050 }
00051
00052
00053
00054
00055
00056 OfxPushUpContainer::OfxPushUpContainer(LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
00057
OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
00058 {
00059 type=
"PUSHUP";
00060
message_out(DEBUG,
"Created OfxPushUpContainer to hold aggregate "+tag_identifier);
00061 }
00062 void OfxPushUpContainer::add_attribute(
const string identifier,
const string value)
00063 {
00064
00065 parentcontainer->
add_attribute(identifier, value);
00066 }
00067
00068
00069
00070
00071
00072 OfxStatusContainer::OfxStatusContainer(LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
00073
OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
00074 {
00075 memset(&data,0,
sizeof(data));
00076 type=
"STATUS";
00077
if (parentcontainer!=NULL){
00078 strncpy(data.ofx_element_name, parentcontainer->
tag_identifier.c_str(), OFX_ELEMENT_NAME_LENGTH);
00079 data.ofx_element_name_valid=
true;
00080 }
00081
00082 }
00083 OfxStatusContainer::~OfxStatusContainer()
00084 {
00085 libofx_context->statusCallback(data);
00086 }
00087 void OfxStatusContainer::add_attribute(
const string identifier,
const string value)
00088 {
00089
ErrorMsg error_msg;
00090
00091
if( identifier==
"CODE"){
00092 data.
code=atoi(value.c_str());
00093 error_msg =
find_error_msg(data.
code);
00094 data.
name = error_msg.
name;
00095 data.
description = error_msg.
description;
00096 data.
code_valid =
true;
00097 }
00098
else if(identifier==
"SEVERITY"){
00099 data.
severity_valid =
true;
00100
if(value==
"INFO") {
00101 data.
severity=OfxStatusData::INFO;
00102 }
00103
else if(value==
"WARN") {
00104 data.
severity=OfxStatusData::WARN;
00105 }
00106
else if(value==
"ERROR") {
00107 data.
severity=OfxStatusData::ERROR;
00108 }
00109
else{
00110
message_out(
ERROR,
"WRITEME: Unknown severity "+value+
" inside a "+type+
" container");
00111 data.
severity_valid =
false;
00112 }
00113 }
00114
else if((identifier==
"MESSAGE")||(identifier==
"MESSAGE2")){
00115 data.
server_message=
new char[value.length()];
00116 strcpy(data.
server_message,value.c_str());
00117 data.
server_message_valid=
true;
00118 }
00119
else{
00120
00121 OfxGenericContainer::add_attribute(identifier, value);
00122 }
00123 }
00124
00125
00126
00127
00128
00129
00130
00131 OfxBalanceContainer::OfxBalanceContainer(LibofxContext *p_libofx_context,
OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
00132
OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
00133 {
00134 amount_valid=
false;
00135 date_valid=
false;
00136 type=
"BALANCE";
00137 }
00138
00139 OfxBalanceContainer::~OfxBalanceContainer()
00140 {
00141
if (parentcontainer->
type ==
"STATEMENT")
00142 {
00143 ((
OfxStatementContainer*)parentcontainer)->add_balance(
this);
00144 }
00145
else
00146 {
00147
message_out (ERROR,
"I completed a " + type +
" element, but I havent found a suitable parent to save it");
00148 }
00149 }
00150 void OfxBalanceContainer::add_attribute(
const string identifier,
const string value)
00151 {
00152
if(identifier==
"BALAMT"){
00153
amount=
ofxamount_to_double(value);
00154 amount_valid=
true;
00155 }
00156
else if(identifier==
"DTASOF"){
00157
date =
ofxdate_to_time_t(value);
00158 date_valid =
true;
00159 }
00160
else{
00161
00162 OfxGenericContainer::add_attribute(identifier, value);
00163 }
00164 }