summaryrefslogtreecommitdiffstats
path: root/kmymoney2/plugins/ofximport/ofximporterplugin.h
blob: 2103ccba73d2bcea901b20f8682d892e65d55b6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/***************************************************************************
                          ofxiimporterplugin.h
                             -------------------
    begin                : Sat Jan 01 2005
    copyright            : (C) 2005 by Ace Jones
    email                : Ace Jones <acejones@users.sourceforge.net>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef OFXIMPORTERPLUGIN_H
#define OFXIMPORTERPLUGIN_H

// ----------------------------------------------------------------------------
// KDE Includes

// ----------------------------------------------------------------------------
// QT Includes

#include <tqstringlist.h>

// ----------------------------------------------------------------------------
// Library Includes

#include <libofx/libofx.h>

// ----------------------------------------------------------------------------
// Project Includes

#include "../kmymoneyplugin.h"
class KOnlineBankingtqStatus;

/**
@author Ace Jones
*/
class OfxImporterPlugin : public KMyMoneyPlugin::Plugin, public KMyMoneyPlugin::ImporterPlugin, public KMyMoneyPlugin::OnlinePlugin
{
Q_OBJECT
  TQ_OBJECT
public:
    OfxImporterPlugin(TQObject *parent = 0, const char *name = 0, const TQStringList& = TQStringList());

    ~OfxImporterPlugin();

  /**
    * This method returns the english-language name of the format
    * this plugin imports, e.g. "OFX"
    *
    * @return TQString Name of the format
    */
  virtual TQString formatName(void) const;

  /**
    * This method returns the filename filter suitable for passing to
    * KFileDialog::setFilter(), e.g. "*.ofx *.qfx" which describes how
    * files of this format are likely to be named in the file system
    *
    * @return TQString Filename filter string
    */
  virtual TQString formatFilenameFilter(void) const;

  /**
    * This method returns whether this plugin is able to import
    * a particular file.
    *
    * @param filename Fully-qualified pathname to a file
    *
    * @return bool Whether the indicated file is importable by this plugin
    */
  virtual bool isMyFormat( const TQString& filename ) const;

  /**
    * Import a file
    *
    * @param filename File to import
    *
    * @return bool Whether the import was successful.
    */
  virtual bool import( const TQString& filename );

  /**
    * Returns the error result of the last import
    *
    * @return TQString English-language name of the error encountered in the
    *  last import, or TQString() if it was successful.
    *
    */
  virtual TQString lastError(void) const;

  TQWidget* accountConfigTab(const MyMoneyAccount& acc, TQString& name);

  MyMoneyKeyValueContainer onlineBankingSettings(const MyMoneyKeyValueContainer& current);

  const MyMoneyAccount& account(const TQString& key, const TQString& value) const;

  void protocols(TQStringList& protocolList) const;

  bool mapAccount(const MyMoneyAccount& acc, MyMoneyKeyValueContainer& settings);
  bool updateAccount(const MyMoneyAccount& acc, bool moreAccounts);

protected slots:
  void slotImportFile(void);
  void slotImportFile(const TQString& url);

protected:
    void createActions(void);
    void addnew(void) { m_statementlist.push_back(MyMoneyStatement()); }
    MyMoneyStatement& back(void) { return m_statementlist.back(); }
    bool isValid(void) const { return m_valid; }
    void setValid(void) { m_valid = true; }
    void addInfo(const TQString& _msg ) { m_infos+=_msg; }
    void addWarning(const TQString& _msg )  { m_warnings+=_msg; }
    void addError(const TQString& _msg )  { m_errors+=_msg; }
    const TQStringList& infos(void) const { return m_infos; }
    const TQStringList& warnings(void) const { return m_warnings; }
    const TQStringList& errors(void) const { return m_errors; }
    bool storeStatements(TQValueList<MyMoneyStatement>& statements);
    bool importStatement(const MyMoneyStatement& s);


    static int ofxTransactionCallback( struct OfxTransactionData, void* );
    static int ofxStatementCallback( struct OfxStatementData, void* );
    static int ofxAccountCallback( struct OfxAccountData, void* );
    static int ofxStatusCallback( struct OfxStatusData, void* );
    static int ofxSecurityCallback( struct OfxSecurityData, void* );

private:
  bool m_valid;
  bool m_preferName;
  TQValueList<MyMoneyStatement> m_statementlist;
  TQValueList<MyMoneyStatement::Security> m_securitylist;
  TQString m_fatalerror;
  TQStringList m_infos;
  TQStringList m_warnings;
  TQStringList m_errors;
  KOnlineBankingtqStatus* m_statusDlg;
};

#endif