LibOFX: ofx_request.cpp Source File

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

# ofx_request.cpp

Go to the documentation of this file.

    00001 /***************************************************************************
    00002          ofx_request.cpp
    00003                              -------------------
    00004     copyright            : (C) 2005 by Ace Jones
    00005     email                : acejones@users.sourceforge.net
    00006 ***************************************************************************/
    00011 /***************************************************************************
    00012  *                                                                         *
    00013  *   This program is free software; you can redistribute it and/or modify  *
    00014  *   it under the terms of the GNU General Public License as published by  *
    00015  *   the Free Software Foundation; either version 2 of the License, or     *
    00016  *   (at your option) any later version.                                   *
    00017  *                                                                         *
    00018  ***************************************************************************/
    00019
    00020 #ifdef HAVE_CONFIG_H
    00021 #include <config.h>
    00022 #endif
    00023
    00024 #include <string>
    00025 #include "messages.hh"
    00026 #include "libofx.h"
    00027 #include "ofx_request.hh"
    00028
    00029 using namespace std;
    00030
    00031 string time_t_to_ofxdatetime( time_t time )
    00032 {
    00033   static char buffer[51];
    00034
    00035   strftime( buffer, 50, "%Y%m%d%H%M%S.000", localtime(&time) );
    00036   buffer[50] = 0;
    00037
    00038   return string(buffer);
    00039 }
    00040
    00041 string time_t_to_ofxdate( time_t time )
    00042 {
    00043   static char buffer[51];
    00044
    00045   strftime( buffer, 50, "%Y%m%d", localtime(&time) );
    00046   buffer[50] = 0;
    00047
    00048   return string(buffer);
    00049 }
    00050
    00051 string OfxHeader(void)
    00052 {
    00053   return string("OFXHEADER:100\r\n"
    00054                  "DATA:OFXSGML\r\n"
    00055                  "VERSION:102\r\n"
    00056                  "SECURITY:NONE\r\n"
    00057                  "ENCODING:USASCII\r\n"
    00058                  "CHARSET:1252\r\n"
    00059                  "COMPRESSION:NONE\r\n"
    00060                  "OLDFILEUID:NONE\r\n"
    00061                  "NEWFILEUID:")
    00062                  + time_t_to_ofxdatetime( time(NULL) )
    00063                  + string("\r\n\r\n");
    00064 }
    00065
    00066 OfxAggregate OfxRequest::SignOnRequest(void) const
    00067 {
    00068   OfxAggregate fiTag("FI");
    00069   fiTag.Add( "ORG", m_login.org );
    00070   if ( strlen(m_login.fid) > 0 )
    00071     fiTag.Add( "FID", m_login.fid );
    00072
    00073   OfxAggregate sonrqTag("SONRQ");
    00074   sonrqTag.Add( "DTCLIENT", time_t_to_ofxdatetime( time(NULL) ) );
    00075   sonrqTag.Add( "USERID", m_login.userid);
    00076   sonrqTag.Add( "USERPASS", m_login.userpass);
    00077   sonrqTag.Add( "LANGUAGE","ENG");
    00078   sonrqTag.Add( fiTag );
    00079   sonrqTag.Add( "APPID","QWIN");
    00080   sonrqTag.Add( "APPVER","1200");
    00081
    00082   OfxAggregate signonmsgTag("SIGNONMSGSRQV1");
    00083   signonmsgTag.Add( sonrqTag );
    00084
    00085   return signonmsgTag;
    00086 }
    00087
    00088 OfxAggregate OfxRequest::RequestMessage(const string& _msgType, const string& _trnType, const OfxAggregate& _request) const
    00089 {
    00090   OfxAggregate trnrqTag( _trnType+"TRNRQ" );
    00091   trnrqTag.Add( "TRNUID", time_t_to_ofxdatetime( time(NULL) ) );
    00092   trnrqTag.Add( "CLTCOOKIE","1" );
    00093   trnrqTag.Add( _request );
    00094
    00095   OfxAggregate result( _msgType+"MSGSRQV1" );
    00096   result.Add( trnrqTag );
    00097
    00098   return result;
    00099 }