summaryrefslogtreecommitdiffstats
path: root/kmymoney2/plugins/ofximport/dialogs/mymoneyofxconnector.h
blob: 70029ff465a9da2ea93c0f7ccd642e2a846932cd (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
/***************************************************************************
                         mymoneyofxconnector.cpp
                             -------------------
    begin                : Sat Nov 13 2004
    copyright            : (C) 2002 by Ace Jones
    email                : 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 MYMONEYOFXCONNECTOR_H
#define MYMONEYOFXCONNECTOR_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


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

#include <libofx/libofx.h>

// if OFX has a major version number defined, we'll take it
// if not, we assume 0.8.3. 0.8.3 was the last version w/o version number info
#ifdef LIBOFX_MAJOR_VERSION
  #define LIBOFX_VERSION TDE_MAKE_VERSION(LIBOFX_MAJOR_VERSION, LIBOFX_MINOR_VERSION, LIBOFX_MICRO_VERSION)
#else
  #define LIBOFX_VERSION TDE_MAKE_VERSION(0,8,3)
#endif
#define LIBOFX_IS_VERSION(a,b,c) (LIBOFX_VERSION >= TDE_MAKE_VERSION(a,b,c))

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

class TQDate;

// ----------------------------------------------------------------------------
// KDE Includes
class KComboBox;

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

#include <kmymoney/mymoneykeyvaluecontainer.h>

class MyMoneyAccount;
class MyMoneyInstitution;
class MyMoneyTransaction;

/**
 * @author Thomas Baumgart
 */
class OfxAppVersion
{
public:
  OfxAppVersion(KComboBox* combo, const TQString& appId);
  /**
   * This method returns the currently selected application id
   * as a colon separated value consisting of the application
   * and version (eg. "QWIN:1700").  If current value is the
   * default, an empty string is returned.
   */
  const TQString& appId(void) const;

private:
  TQMap<TQString, TQString> m_appMap;
  KComboBox*             m_combo;
};

/**
 * @author Thomas Baumgart
 */
class OfxHeaderVersion
{
public:
  OfxHeaderVersion(KComboBox* combo, const TQString& headerVersion);
  TQString headerVersion(void) const;

private:
  KComboBox*             m_combo;
};

/**
@author ace jones
*/
class MyMoneyOfxConnector
{
public:
  MyMoneyOfxConnector(const MyMoneyAccount& _account);
  TQString url(void) const;

  /**
   * Constructs the request for a statement. The first date
   * for which transactions will be requested is determined
   * by statementStartDate()
   */
  const TQByteArray statementRequest(void) const;
  const TQByteArray statementResponse(const TQDate& _dtstart) const;

private:
  void initRequest(OfxFiLogin* fi) const;
  TQDate statementStartDate(void) const;
  TQString iban(void) const;
  TQString fiorg(void) const;
  TQString fiid(void) const;
  TQString username(void) const;
  TQString password(void) const;
  TQString accountnum(void) const;
#if LIBOFX_IS_VERSION(0,9,0)
  OfxAccountData::AccountType accounttype(void) const;
#else
  AccountType accounttype(void) const;
#endif

private:
  const MyMoneyAccount& m_account;
  MyMoneyKeyValueContainer m_fiSettings;
};

#endif // OFXCONNECTOR_H