LibOFX: context.cpp Source File

LibOFX

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

context.cpp

    00001
    00005 /***************************************************************************
    00006  *                                                                         *
    00007  *   This program is free software; you can redistribute it and/or modify  *
    00008  *   it under the terms of the GNU General Public License as published by  *
    00009  *   the Free Software Foundation; either version 2 of the License, or     *
    00010  *   (at your option) any later version.                                   *
    00011  *                                                                         *
    00012  ***************************************************************************/
    00013 #include <config.h>
    00014 #include "context.hh"
    00015
    00016 using namespace std;
    00017
    00018
    00019
    00020 LibofxContext::LibofxContext()
    00021   : _current_file_type(OFX)
    00022   , _statusCallback(0)
    00023   , _accountCallback(0)
    00024   , _securityCallback(0)
    00025   , _transactionCallback(0)
    00026   , _statementCallback(0)
    00027   , _statementData(0)
    00028   , _accountData(0)
    00029   , _transactionData(0)
    00030   , _securityData(0)
    00031   , _statusData(0)
    00032 {
    00033
    00034 }
    00035
    00036
    00037
    00038 LibofxContext::~LibofxContext()
    00039 {
    00040 }
    00041
    00042
    00043
    00044 LibofxFileFormat LibofxContext::currentFileType() const
    00045 {
    00046   return _current_file_type;
    00047 }
    00048
    00049
    00050
    00051 void LibofxContext::setCurrentFileType(LibofxFileFormat t)
    00052 {
    00053   _current_file_type = t;
    00054 }
    00055
    00056
    00057
    00058 int LibofxContext::statementCallback(const struct OfxStatementData data)
    00059 {
    00060   if (_statementCallback)
    00061     return _statementCallback(data, _statementData);
    00062   return 0;
    00063 }
    00064
    00065
    00066
    00067 int LibofxContext::accountCallback(const struct OfxAccountData data)
    00068 {
    00069   if (_accountCallback)
    00070     return _accountCallback(data, _accountData);
    00071   return 0;
    00072 }
    00073
    00074
    00075
    00076 int LibofxContext::transactionCallback(const struct OfxTransactionData data)
    00077 {
    00078   if (_transactionCallback)
    00079     return _transactionCallback(data, _transactionData);
    00080   return 0;
    00081 }
    00082
    00083
    00084
    00085 int LibofxContext::securityCallback(const struct OfxSecurityData data)
    00086 {
    00087   if (_securityCallback)
    00088     return _securityCallback(data, _securityData);
    00089   return 0;
    00090 }
    00091
    00092
    00093
    00094 int LibofxContext::statusCallback(const struct OfxStatusData data)
    00095 {
    00096   if (_statusCallback)
    00097     return _statusCallback(data, _statusData);
    00098   return 0;
    00099 }
    00100
    00101
    00102 void LibofxContext::setStatusCallback(LibofxProcStatusCallback cb,
    00103                                       void *user_data)
    00104 {
    00105   _statusCallback = cb;
    00106   _statusData = user_data;
    00107 }
    00108
    00109
    00110
    00111 void LibofxContext::setAccountCallback(LibofxProcAccountCallback cb,
    00112                                        void *user_data)
    00113 {
    00114   _accountCallback = cb;
    00115   _accountData = user_data;
    00116 }
    00117
    00118
    00119
    00120 void LibofxContext::setSecurityCallback(LibofxProcSecurityCallback cb,
    00121                                         void *user_data)
    00122 {
    00123   _securityCallback = cb;
    00124   _securityData = user_data;
    00125 }
    00126
    00127
    00128
    00129 void LibofxContext::setTransactionCallback(LibofxProcTransactionCallback cb,
    00130     void *user_data)
    00131 {
    00132   _transactionCallback = cb;
    00133   _transactionData = user_data;
    00134 }
    00135
    00136
    00137
    00138 void LibofxContext::setStatementCallback(LibofxProcStatementCallback cb,
    00139     void *user_data)
    00140 {
    00141   _statementCallback = cb;
    00142   _statementData = user_data;
    00143 }
    00144
    00145
    00146
    00147
    00148
    00149
    00150
    00153 LibofxContextPtr libofx_get_new_context()
    00154 {
    00155   return new LibofxContext();
    00156 }
    00157
    00158 int libofx_free_context( LibofxContextPtr libofx_context_param)
    00159 {
    00160   delete (LibofxContext *)libofx_context_param;
    00161   return 0;
    00162 }
    00163
    00164
    00165
    00166 void libofx_set_dtd_dir(LibofxContextPtr libofx_context,
    00167                         const char *s)
    00168 {
    00169   ((LibofxContext*)libofx_context)->setDtdDir(s);
    00170 }
    00171
    00172
    00173
    00174
    00175
    00176
    00177 extern "C" {
    00178   void ofx_set_status_cb(LibofxContextPtr ctx,
    00179                          LibofxProcStatusCallback cb,
    00180                          void *user_data)
    00181   {
    00182     ((LibofxContext*)ctx)->setStatusCallback(cb, user_data);
    00183   }
    00184
    00185
    00186   void ofx_set_account_cb(LibofxContextPtr ctx,
    00187                           LibofxProcAccountCallback cb,
    00188                           void *user_data)
    00189   {
    00190     ((LibofxContext*)ctx)->setAccountCallback(cb, user_data);
    00191   }
    00192
    00193
    00194
    00195   void ofx_set_security_cb(LibofxContextPtr ctx,
    00196                            LibofxProcSecurityCallback cb,
    00197                            void *user_data)
    00198   {
    00199     ((LibofxContext*)ctx)->setSecurityCallback(cb, user_data);
    00200   }
    00201
    00202
    00203
    00204   void ofx_set_transaction_cb(LibofxContextPtr ctx,
    00205                               LibofxProcTransactionCallback cb,
    00206                               void *user_data)
    00207   {
    00208     ((LibofxContext*)ctx)->setTransactionCallback(cb, user_data);
    00209   }
    00210
    00211
    00212
    00213   void ofx_set_statement_cb(LibofxContextPtr ctx,
    00214                             LibofxProcStatementCallback cb,
    00215                             void *user_data)
    00216   {
    00217     ((LibofxContext*)ctx)->setStatementCallback(cb, user_data);
    00218   }
    00219
    00220
    00221
    00222
    00223 }
    00224
    00225
    00226
    00227
    00228
    00229
    00230
    00231
    00232
    00233