Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

# fx-0.8.0/lib/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 LibofxFileFormat LibofxContext::currentFileType() const{
    00044   return _current_file_type;
    00045 }
    00046
    00047
    00048
    00049 void LibofxContext::setCurrentFileType(LibofxFileFormat t) {
    00050   _current_file_type=t;
    00051 }
    00052
    00053
    00054
    00055 int LibofxContext::statementCallback(const struct OfxStatementData data){
    00056   if (_statementCallback)
    00057     return _statementCallback(data, _statementData);
    00058   return 0;
    00059 }
    00060
    00061
    00062
    00063 int LibofxContext::accountCallback(const struct OfxAccountData data){
    00064   if (_accountCallback)
    00065     return _accountCallback(data, _accountData);
    00066   return 0;
    00067 }
    00068
    00069
    00070
    00071 int LibofxContext::transactionCallback(const struct OfxTransactionData data){
    00072   if (_transactionCallback)
    00073     return _transactionCallback(data, _transactionData);
    00074   return 0;
    00075 }
    00076
    00077
    00078
    00079 int LibofxContext::securityCallback(const struct OfxSecurityData data) {
    00080   if (_securityCallback)
    00081     return _securityCallback(data, _securityData);
    00082   return 0;
    00083 }
    00084
    00085
    00086
    00087 int LibofxContext::statusCallback(const struct OfxStatusData data) {
    00088   if (_statusCallback)
    00089     return _statusCallback(data, _statusData);
    00090   return 0;
    00091 }
    00092
    00093
    00094 void LibofxContext::setStatusCallback(LibofxProcStatusCallback cb,
    00095                                       void *user_data){
    00096   _statusCallback=cb;
    00097   _statusData=user_data;
    00098 }
    00099
    00100
    00101
    00102 void LibofxContext::setAccountCallback(LibofxProcAccountCallback cb,
    00103                                        void *user_data){
    00104   _accountCallback=cb;
    00105   _accountData=user_data;
    00106 }
    00107
    00108
    00109
    00110 void LibofxContext::setSecurityCallback(LibofxProcSecurityCallback cb,
    00111                                         void *user_data){
    00112   _securityCallback=cb;
    00113   _securityData=user_data;
    00114 }
    00115
    00116
    00117
    00118 void LibofxContext::setTransactionCallback(LibofxProcTransactionCallback cb,
    00119                                            void *user_data){
    00120   _transactionCallback=cb;
    00121   _transactionData=user_data;
    00122 }
    00123
    00124
    00125
    00126 void LibofxContext::setStatementCallback(LibofxProcStatementCallback cb,
    00127                                          void *user_data){
    00128   _statementCallback=cb;
    00129   _statementData=user_data;
    00130 }
    00131
    00132
    00133
    00134
    00135
    00136
    00137
    00140 CFCT LibofxContextPtr libofx_get_new_context(){
    00141   return new LibofxContext();
    00142 }
    00143
    00144 CFCT int libofx_free_context( LibofxContextPtr libofx_context_param){
    00145   delete (LibofxContext *)libofx_context_param;
    00146   return 0;
    00147 }
    00148
    00149
    00150
    00151
    00152 extern "C" {
    00153   void ofx_set_status_cb(LibofxContextPtr ctx,
    00154                          LibofxProcStatusCallback cb,
    00155                          void *user_data){
    00156     ((LibofxContext*)ctx)->setStatusCallback(cb, user_data);
    00157   }
    00158
    00159
    00160   void ofx_set_account_cb(LibofxContextPtr ctx,
    00161                           LibofxProcAccountCallback cb,
    00162                           void *user_data){
    00163     ((LibofxContext*)ctx)->setAccountCallback(cb, user_data);
    00164   }
    00165
    00166
    00167
    00168   void ofx_set_security_cb(LibofxContextPtr ctx,
    00169                            LibofxProcSecurityCallback cb,
    00170                            void *user_data){
    00171     ((LibofxContext*)ctx)->setSecurityCallback(cb, user_data);
    00172   }
    00173
    00174
    00175
    00176   void ofx_set_transaction_cb(LibofxContextPtr ctx,
    00177                               LibofxProcTransactionCallback cb,
    00178                               void *user_data){
    00179     ((LibofxContext*)ctx)->setTransactionCallback(cb, user_data);
    00180   }
    00181
    00182
    00183
    00184   void ofx_set_statement_cb(LibofxContextPtr ctx,
    00185                             LibofxProcStatementCallback cb,
    00186                             void *user_data){
    00187     ((LibofxContext*)ctx)->setStatementCallback(cb, user_data);
    00188   }
    00189
    00190
    00191
    00192
    00193 }
    00194
    00195
    00196
    00197
    00198
    00199
    00200
    00201
    00202
    00203