1 /***************************************************************************
2  begin       : Mon Mar 01 2004
3  copyright   : (C) 2018 by Martin Preuss
4  email       : martin@libchipcard.de
5 
6  ***************************************************************************
7  * This file is part of the project "AqBanking".                           *
8  * Please see toplevel file COPYING of that project for license details.   *
9  ***************************************************************************/
10 
11 
12 #ifndef AQBANKING_IMEXPORTER_H
13 #define AQBANKING_IMEXPORTER_H
14 
15 #include <aqbanking/error.h>
16 
17 #include <gwenhywfar/inherit.h>
18 #include <gwenhywfar/syncio.h>
19 #include <gwenhywfar/db.h>
20 #include <gwenhywfar/types.h>
21 #include <gwenhywfar/dialog.h>
22 
23 
24 /** @addtogroup G_AB_IMEXPORTER Generic Im- and Exporter
25  *
26  * @short Generic Financial Data Importer/Exporter
27  * <p>
28  * This group contains a generic importer/exporter.
29  * </p>
30  * <h2>Importing</h2>
31  * <p>
32  * When importing this group reads transactions and accounts from a
33  * given stream (in most cases a file) and stores them in a given
34  * importer context.
35  * </p>
36  * <p>
37  * The application can later browse through all transactions stored within the
38  * given context and import them into its own database as needed.
39  * </p>
40  */
41 /*@{*/
42 
43 
44 
45 /** @name Flags returned by @ref AB_ImExporter_GetFlags
46  *
47  */
48 /*@{*/
49 
50 /** This module supports the function @ref AB_ImExporter_GetEditProfileDialog */
51 #define AB_IMEXPORTER_FLAGS_GETPROFILEEDITOR_SUPPORTED 0x00000001
52 
53 
54 /*@}*/
55 
56 
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 typedef struct AB_IMEXPORTER AB_IMEXPORTER;
63 GWEN_INHERIT_FUNCTION_DEFS(AB_IMEXPORTER)
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 
70 #include <aqbanking/types/imexporter_context.h>
71 #include <aqbanking/types/imexporter_accountinfo.h>
72 #include <aqbanking/banking.h>
73 
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 
80 /** @name Virtual Functions for Backends
81  *
82  */
83 /*@{*/
84 
85 /**
86  * Reads the given stream and imports all data from it. This imported
87  * data is stored within the given context.
88  * @param ie pointer to the importer/exporter
89  * @param ctx import context
90  * @param bio stream to read from (usually a file, see
91  *   @ref GWEN_BufferedIO_File_new)
92  * @param dbProfile configuration data for the importer. You can get this
93  *   using @ref AB_Banking_GetImExporterProfiles.
94  */
95 int AB_ImExporter_Import(AB_IMEXPORTER *ie,
96                          AB_IMEXPORTER_CONTEXT *ctx,
97                          GWEN_SYNCIO *sio,
98                          GWEN_DB_NODE *dbProfile);
99 
100 /**
101  * Writes all data to the given stream.
102  * @param ie pointer to the importer/exporter
103  * @param ctx export context
104  * @param bio stream to write to (usually a file, see
105  *   @ref GWEN_BufferedIO_File_new)
106  * @param dbProfile configuration data for the exporter. You can get this
107  *   using @ref AB_Banking_GetImExporterProfiles.
108  */
109 int AB_ImExporter_Export(AB_IMEXPORTER *ie,
110                          AB_IMEXPORTER_CONTEXT *ctx,
111                          GWEN_SYNCIO *sio,
112                          GWEN_DB_NODE *dbProfile);
113 
114 /**
115  * This function should return a dialog (see @ref GWEN_DIALOG) which
116  * allows editing of the given profile.
117  * You can use @ref AB_ImExporter_GetFlags to determine beforehand whether
118  * this function is supported (look for
119  * @ref AB_IMEXPORTER_FLAGS_GETPROFILEEDITOR_SUPPORTED).
120  * (introduced in AqBanking 4.3.0)
121  *
122  * @param ie pointer to the importer/exporter
123  *
124  * @param dbProfile configuration data for the exporter. You can get this
125  *   using @ref AB_Banking_GetImExporterProfiles.
126  *
127  * @param pDlg pointer to a dialog pointer (receives the created dialog if any)
128  *
129  * @return 0 on success, error code otherwise
130  */
131 int AB_ImExporter_GetEditProfileDialog(AB_IMEXPORTER *ie,
132                                        GWEN_DB_NODE *dbProfile,
133                                        const char *testFileName,
134                                        GWEN_DIALOG **pDlg);
135 
136 
137 /**
138  * This function checks whether the given importer supports the given file.
139  */
140 int AB_ImExporter_CheckFile(AB_IMEXPORTER *ie, const char *fname);
141 
142 /*@}*/
143 
144 
145 /**
146  * Returns the AB_BANKING object to which the im/exporter belongs.
147  */
148 AB_BANKING *AB_ImExporter_GetBanking(const AB_IMEXPORTER *ie);
149 
150 /**
151  * Returns the name of the im/exporter.
152  */
153 const char *AB_ImExporter_GetName(const AB_IMEXPORTER *ie);
154 
155 
156 /**
157  * Returns the flags if this im/exporter which specify the supported
158  * features.
159  */
160 uint32_t AB_ImExporter_GetFlags(const AB_IMEXPORTER *ie);
161 
162 
163 /*@}*/ /* defgroup */
164 
165 
166 
167 
168 
169 /** @name Helper Functions
170  *
171  * These functions are most likely used by implementations of im/exporters.
172  */
173 /*@{*/
174 /**
175  * Transforms an UTF-8 string to a DTA string. Untranslateable characters
176  * are replaced by a space (chr 32).
177  */
178 void AB_ImExporter_Utf8ToDta(const char *p, int size, GWEN_BUFFER *buf);
179 
180 /**
181  * Transforms a DTA string to an UTF-8 string.
182  */
183 void AB_ImExporter_DtaToUtf8(const char *p, int size, GWEN_BUFFER *buf);
184 
185 void AB_ImExporter_Iso8859_1ToUtf8(const char *p, int size, GWEN_BUFFER *buf);
186 
187 /**
188  * This function call @ref AB_ImExporter_Iso8859_1ToUtf8 on all char
189  * values in the given db.
190  */
191 int AB_ImExporter_DbFromIso8859_1ToUtf8(GWEN_DB_NODE *db);
192 
193 GWEN_TIME *AB_ImExporter_DateFromString(const char *p, const char *tmpl, int inUtc);
194 
195 
196 /*@}*/
197 
198 
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 
205 
206 
207 #endif /* AQBANKING_IMEXPORTER_H */
208 
209 
210