1 /***************************************************************************
2  begin       : Sat Aug 07 2010
3  copyright   : (C) 2018 by Martin Preuss
4  email       : martin@aqbanking.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 #ifdef HAVE_CONFIG_H
12 # include <config.h>
13 #endif
14 
15 
16 
17 #include "dlg_importkeyfile_p.h"
18 #include "aqbanking/i18n_l.h"
19 
20 #include <aqbanking/dialogs/dlg_selectbankinfo.h>
21 #include <aqbanking/backendsupport/user.h>
22 #include <aqbanking/banking_be.h>
23 
24 #include "aqhbci/banking/user.h"
25 #include "aqhbci/banking/provider.h"
26 #include "aqhbci/banking/provider_online.h"
27 #include "aqhbci/banking/provider_iniletter.h"
28 #include "dlg_rdh_special_l.h"
29 
30 #include <gwenhywfar/gwenhywfar.h>
31 #include <gwenhywfar/misc.h>
32 #include <gwenhywfar/pathmanager.h>
33 #include <gwenhywfar/debug.h>
34 #include <gwenhywfar/gui.h>
35 #include <gwenhywfar/ctplugin.h>
36 
37 
38 
39 #define PAGE_BEGIN     0
40 #define PAGE_FILE      1
41 #define PAGE_BANK      2
42 #define PAGE_USER      3
43 #define PAGE_CREATE    4
44 #define PAGE_END       5
45 
46 
47 #define DIALOG_MINWIDTH  400
48 #define DIALOG_MINHEIGHT 200
49 
50 
51 #define MAX_CONTEXT_ID_ENTRIES 64
52 
53 
GWEN_INHERIT(GWEN_DIALOG,AH_IMPORTKEYFILE_DIALOG)54 GWEN_INHERIT(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG)
55 
56 
57 
58 
59 GWEN_DIALOG *AH_ImportKeyFileDialog_new(AB_PROVIDER *pro)
60 {
61   GWEN_DIALOG *dlg;
62   AH_IMPORTKEYFILE_DIALOG *xdlg;
63   GWEN_BUFFER *fbuf;
64   int rv;
65 
66   dlg=GWEN_Dialog_new("ah_setup_importkeyfile");
67   GWEN_NEW_OBJECT(AH_IMPORTKEYFILE_DIALOG, xdlg);
68   GWEN_INHERIT_SETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg, xdlg,
69                        AH_ImportKeyFileDialog_FreeData);
70   GWEN_Dialog_SetSignalHandler(dlg, AH_ImportKeyFileDialog_SignalHandler);
71 
72   /* get path of dialog description file */
73   fbuf=GWEN_Buffer_new(0, 256, 0, 1);
74   rv=GWEN_PathManager_FindFile(AB_PM_LIBNAME, AB_PM_DATADIR,
75                                "aqbanking/backends/aqhbci/dialogs/dlg_importkeyfile.dlg",
76                                fbuf);
77   if (rv<0) {
78     DBG_INFO(AQHBCI_LOGDOMAIN, "Dialog description file not found (%d).", rv);
79     GWEN_Buffer_free(fbuf);
80     GWEN_Dialog_free(dlg);
81     return NULL;
82   }
83 
84   /* read dialog from dialog description file */
85   rv=GWEN_Dialog_ReadXmlFile(dlg, GWEN_Buffer_GetStart(fbuf));
86   if (rv<0) {
87     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d).", rv);
88     GWEN_Buffer_free(fbuf);
89     GWEN_Dialog_free(dlg);
90     return NULL;
91   }
92   GWEN_Buffer_free(fbuf);
93 
94   xdlg->provider=pro;
95   xdlg->banking=AB_Provider_GetBanking(pro);
96   xdlg->contextList=GWEN_Crypt_Token_Context_List_new();
97 
98   /* preset */
99   xdlg->hbciVersion=210;
100   xdlg->rdhVersion=0;
101 
102   /* done */
103   return dlg;
104 }
105 
106 
107 
AH_ImportKeyFileDialog_FreeData(void * bp,void * p)108 void GWENHYWFAR_CB AH_ImportKeyFileDialog_FreeData(void *bp, void *p)
109 {
110   AH_IMPORTKEYFILE_DIALOG *xdlg;
111 
112   xdlg=(AH_IMPORTKEYFILE_DIALOG *) p;
113   GWEN_Crypt_Token_Context_List_free(xdlg->contextList);
114   free(xdlg->fileName);
115   free(xdlg->bankCode);
116   free(xdlg->bankName);
117   free(xdlg->userName);
118   free(xdlg->userId);
119   free(xdlg->customerId);
120   GWEN_FREE_OBJECT(xdlg);
121 }
122 
123 
124 
AH_ImportKeyFileDialog_GetUser(const GWEN_DIALOG * dlg)125 AB_USER *AH_ImportKeyFileDialog_GetUser(const GWEN_DIALOG *dlg)
126 {
127   AH_IMPORTKEYFILE_DIALOG *xdlg;
128 
129   assert(dlg);
130   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
131   assert(xdlg);
132 
133   return xdlg->user;
134 }
135 
136 
137 
AH_ImportKeyFileDialog_GetFileName(const GWEN_DIALOG * dlg)138 const char *AH_ImportKeyFileDialog_GetFileName(const GWEN_DIALOG *dlg)
139 {
140   AH_IMPORTKEYFILE_DIALOG *xdlg;
141 
142   assert(dlg);
143   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
144   assert(xdlg);
145 
146   return xdlg->fileName;
147 }
148 
149 
150 
AH_ImportKeyFileDialog_SetFileName(GWEN_DIALOG * dlg,const char * s)151 void AH_ImportKeyFileDialog_SetFileName(GWEN_DIALOG *dlg, const char *s)
152 {
153   AH_IMPORTKEYFILE_DIALOG *xdlg;
154 
155   assert(dlg);
156   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
157   assert(xdlg);
158 
159   free(xdlg->fileName);
160   if (s)
161     xdlg->fileName=strdup(s);
162   else
163     xdlg->fileName=NULL;
164 }
165 
166 
167 
AH_ImportKeyFileDialog_GetBankCode(const GWEN_DIALOG * dlg)168 const char *AH_ImportKeyFileDialog_GetBankCode(const GWEN_DIALOG *dlg)
169 {
170   AH_IMPORTKEYFILE_DIALOG *xdlg;
171 
172   assert(dlg);
173   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
174   assert(xdlg);
175 
176   return xdlg->bankCode;
177 }
178 
179 
180 
AH_ImportKeyFileDialog_SetBankCode(GWEN_DIALOG * dlg,const char * s)181 void AH_ImportKeyFileDialog_SetBankCode(GWEN_DIALOG *dlg, const char *s)
182 {
183   AH_IMPORTKEYFILE_DIALOG *xdlg;
184 
185   assert(dlg);
186   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
187   assert(xdlg);
188 
189   free(xdlg->bankCode);
190   if (s)
191     xdlg->bankCode=strdup(s);
192   else
193     xdlg->bankCode=NULL;
194 }
195 
196 
197 
AH_ImportKeyFileDialog_GetBankName(const GWEN_DIALOG * dlg)198 const char *AH_ImportKeyFileDialog_GetBankName(const GWEN_DIALOG *dlg)
199 {
200   AH_IMPORTKEYFILE_DIALOG *xdlg;
201 
202   assert(dlg);
203   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
204   assert(xdlg);
205 
206   return xdlg->bankName;
207 }
208 
209 
210 
AH_ImportKeyFileDialog_SetBankName(GWEN_DIALOG * dlg,const char * s)211 void AH_ImportKeyFileDialog_SetBankName(GWEN_DIALOG *dlg, const char *s)
212 {
213   AH_IMPORTKEYFILE_DIALOG *xdlg;
214 
215   assert(dlg);
216   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
217   assert(xdlg);
218 
219   free(xdlg->bankName);
220   if (s)
221     xdlg->bankName=strdup(s);
222   else
223     xdlg->bankName=NULL;
224 }
225 
226 
227 
AH_ImportKeyFileDialog_GetUserName(const GWEN_DIALOG * dlg)228 const char *AH_ImportKeyFileDialog_GetUserName(const GWEN_DIALOG *dlg)
229 {
230   AH_IMPORTKEYFILE_DIALOG *xdlg;
231 
232   assert(dlg);
233   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
234   assert(xdlg);
235 
236   return xdlg->userName;
237 }
238 
239 
240 
AH_ImportKeyFileDialog_SetUserName(GWEN_DIALOG * dlg,const char * s)241 void AH_ImportKeyFileDialog_SetUserName(GWEN_DIALOG *dlg, const char *s)
242 {
243   AH_IMPORTKEYFILE_DIALOG *xdlg;
244 
245   assert(dlg);
246   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
247   assert(xdlg);
248 
249   free(xdlg->userName);
250   if (s)
251     xdlg->userName=strdup(s);
252   else
253     xdlg->userName=NULL;
254 }
255 
256 
257 
AH_ImportKeyFileDialog_GetUserId(const GWEN_DIALOG * dlg)258 const char *AH_ImportKeyFileDialog_GetUserId(const GWEN_DIALOG *dlg)
259 {
260   AH_IMPORTKEYFILE_DIALOG *xdlg;
261 
262   assert(dlg);
263   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
264   assert(xdlg);
265 
266   return xdlg->userId;
267 }
268 
269 
270 
AH_ImportKeyFileDialog_SetUserId(GWEN_DIALOG * dlg,const char * s)271 void AH_ImportKeyFileDialog_SetUserId(GWEN_DIALOG *dlg, const char *s)
272 {
273   AH_IMPORTKEYFILE_DIALOG *xdlg;
274 
275   assert(dlg);
276   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
277   assert(xdlg);
278 
279   free(xdlg->userId);
280   if (s)
281     xdlg->userId=strdup(s);
282   else
283     xdlg->userId=NULL;
284 }
285 
286 
287 
AH_ImportKeyFileDialog_GetCustomerId(const GWEN_DIALOG * dlg)288 const char *AH_ImportKeyFileDialog_GetCustomerId(const GWEN_DIALOG *dlg)
289 {
290   AH_IMPORTKEYFILE_DIALOG *xdlg;
291 
292   assert(dlg);
293   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
294   assert(xdlg);
295 
296   return xdlg->customerId;
297 }
298 
299 
300 
AH_ImportKeyFileDialog_SetCustomerId(GWEN_DIALOG * dlg,const char * s)301 void AH_ImportKeyFileDialog_SetCustomerId(GWEN_DIALOG *dlg, const char *s)
302 {
303   AH_IMPORTKEYFILE_DIALOG *xdlg;
304 
305   assert(dlg);
306   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
307   assert(xdlg);
308 
309   free(xdlg->customerId);
310   if (s)
311     xdlg->customerId=strdup(s);
312   else
313     xdlg->customerId=NULL;
314 }
315 
316 
317 
AH_ImportKeyFileDialog_GetUrl(const GWEN_DIALOG * dlg)318 const char *AH_ImportKeyFileDialog_GetUrl(const GWEN_DIALOG *dlg)
319 {
320   AH_IMPORTKEYFILE_DIALOG *xdlg;
321 
322   assert(dlg);
323   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
324   assert(xdlg);
325 
326   return xdlg->url;
327 }
328 
329 
330 
AH_ImportKeyFileDialog_SetUrl(GWEN_DIALOG * dlg,const char * s)331 void AH_ImportKeyFileDialog_SetUrl(GWEN_DIALOG *dlg, const char *s)
332 {
333   AH_IMPORTKEYFILE_DIALOG *xdlg;
334 
335   assert(dlg);
336   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
337   assert(xdlg);
338 
339   free(xdlg->url);
340   if (s)
341     xdlg->url=strdup(s);
342   else
343     xdlg->url=NULL;
344 }
345 
346 
347 
AH_ImportKeyFileDialog_GetHbciVersion(const GWEN_DIALOG * dlg)348 int AH_ImportKeyFileDialog_GetHbciVersion(const GWEN_DIALOG *dlg)
349 {
350   AH_IMPORTKEYFILE_DIALOG *xdlg;
351 
352   assert(dlg);
353   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
354   assert(xdlg);
355 
356   return xdlg->hbciVersion;
357 }
358 
359 
360 
AH_ImportKeyFileDialog_SetHbciVersion(GWEN_DIALOG * dlg,int i)361 void AH_ImportKeyFileDialog_SetHbciVersion(GWEN_DIALOG *dlg, int i)
362 {
363   AH_IMPORTKEYFILE_DIALOG *xdlg;
364 
365   assert(dlg);
366   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
367   assert(xdlg);
368 
369   xdlg->hbciVersion=i;
370 }
371 
372 
373 
AH_ImportKeyFileDialog_GetRdhVersion(const GWEN_DIALOG * dlg)374 int AH_ImportKeyFileDialog_GetRdhVersion(const GWEN_DIALOG *dlg)
375 {
376   AH_IMPORTKEYFILE_DIALOG *xdlg;
377 
378   assert(dlg);
379   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
380   assert(xdlg);
381 
382   return xdlg->rdhVersion;
383 }
384 
385 
386 
AH_ImportKeyFileDialog_SetRdhVersion(GWEN_DIALOG * dlg,int i)387 void AH_ImportKeyFileDialog_SetRdhVersion(GWEN_DIALOG *dlg, int i)
388 {
389   AH_IMPORTKEYFILE_DIALOG *xdlg;
390 
391   assert(dlg);
392   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
393   assert(xdlg);
394 
395   xdlg->rdhVersion=i;
396 }
397 
398 
399 
AH_ImportKeyFileDialog_GetFlags(const GWEN_DIALOG * dlg)400 uint32_t AH_ImportKeyFileDialog_GetFlags(const GWEN_DIALOG *dlg)
401 {
402   AH_IMPORTKEYFILE_DIALOG *xdlg;
403 
404   assert(dlg);
405   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
406   assert(xdlg);
407 
408   return xdlg->flags;
409 }
410 
411 
412 
AH_ImportKeyFileDialog_SetFlags(GWEN_DIALOG * dlg,uint32_t fl)413 void AH_ImportKeyFileDialog_SetFlags(GWEN_DIALOG *dlg, uint32_t fl)
414 {
415   AH_IMPORTKEYFILE_DIALOG *xdlg;
416 
417   assert(dlg);
418   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
419   assert(xdlg);
420 
421   xdlg->flags=fl;
422 }
423 
424 
425 
AH_ImportKeyFileDialog_AddFlags(GWEN_DIALOG * dlg,uint32_t fl)426 void AH_ImportKeyFileDialog_AddFlags(GWEN_DIALOG *dlg, uint32_t fl)
427 {
428   AH_IMPORTKEYFILE_DIALOG *xdlg;
429 
430   assert(dlg);
431   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
432   assert(xdlg);
433 
434   xdlg->flags&=~fl;
435 }
436 
437 
438 
AH_ImportKeyFileDialog_SubFlags(GWEN_DIALOG * dlg,uint32_t fl)439 void AH_ImportKeyFileDialog_SubFlags(GWEN_DIALOG *dlg, uint32_t fl)
440 {
441   AH_IMPORTKEYFILE_DIALOG *xdlg;
442 
443   assert(dlg);
444   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
445   assert(xdlg);
446 
447   xdlg->flags&=~fl;
448 }
449 
450 
451 
452 
453 
454 
AH_ImportKeyFileDialog_Init(GWEN_DIALOG * dlg)455 void AH_ImportKeyFileDialog_Init(GWEN_DIALOG *dlg)
456 {
457   AH_IMPORTKEYFILE_DIALOG *xdlg;
458   GWEN_DB_NODE *dbPrefs;
459   int i;
460 
461   assert(dlg);
462   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
463   assert(xdlg);
464 
465   dbPrefs=GWEN_Dialog_GetPreferences(dlg);
466 
467   GWEN_Dialog_SetCharProperty(dlg,
468                               "",
469                               GWEN_DialogProperty_Title,
470                               0,
471                               I18N("HBCI Keyfile Import Wizard"),
472                               0);
473 
474   /* select first page */
475   GWEN_Dialog_SetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, 0, 0);
476 
477   /* setup intro page */
478   GWEN_Dialog_SetCharProperty(dlg,
479                               "wiz_begin_label",
480                               GWEN_DialogProperty_Title,
481                               0,
482                               I18N("This dialog assists you in importing a Keyfile User.\n"),
483                               0);
484 
485   /* setup bank page */
486   GWEN_Dialog_SetCharProperty(dlg,
487                               "wiz_bank_label",
488                               GWEN_DialogProperty_Title,
489                               0,
490                               I18N("<html>"
491                                    "<p>Please select the bank.</p>"
492                                    "<p>AqBanking has an internal database which "
493                                    "contains HBCI/FinTS information about many banks.<p>"
494                                    "<p>If there is an entry for your bank this dialog will use the "
495                                    "information from the database.</p>"
496                                    "</html>"
497                                    "Please select the bank.\n"
498                                    "AqBanking has an internal database which contains\n"
499                                    "HBCI/FinTS information about many banks.\n"
500                                    "If there is an entry for your bank this dialog will use the\n"
501                                    "information from the database."),
502                               0);
503 
504   /* setup user page */
505   GWEN_Dialog_SetCharProperty(dlg,
506                               "wiz_user_label",
507                               GWEN_DialogProperty_Title,
508                               0,
509                               I18N("<html>"
510                                    "<p>For most banks the customer id must be the same as the user id.</p>"
511                                    "<p>However, some banks actually use the customer id, so please look into "
512                                    "the documentation provided by your bank to discover whether this is the "
513                                    "case with your bank.</p>"
514                                    "</html>"
515                                    "For most banks the customer id must be the same as the user id.\n"
516                                    "However, some banks actually use the customer id, so please look into\n"
517                                    "the documentation provided by your bank to discover whether this is the\n"
518                                    "case with your bank."),
519                               0);
520 
521   /* setup creation page */
522   GWEN_Dialog_SetCharProperty(dlg,
523                               "wiz_create_label",
524                               GWEN_DialogProperty_Title,
525                               0,
526                               I18N("<html>"
527                                    "<p>We are now ready to create the user and exchange keys with the server.</p>"
528                                    "<p>Click the <i>next</i> button to proceed or <i>abort</i> to abort.</p>"
529                                    "</html>"
530                                    "We are now ready to create the user and exchange keys with the server.\n"
531                                    "Click the NEXT button to proceed or ABORT to abort."),
532                               0);
533 
534   /* setup extro page */
535   GWEN_Dialog_SetCharProperty(dlg,
536                               "wiz_end_label",
537                               GWEN_DialogProperty_Title,
538                               0,
539                               I18N("<html>"
540                                    "<p>The user has been successfully created.</p>"
541                                    "</html>"
542                                    "The user has been successfully created."),
543                               0);
544 
545   /* read width */
546   i=GWEN_DB_GetIntValue(dbPrefs, "dialog_width", 0, -1);
547   if (i>=DIALOG_MINWIDTH)
548     GWEN_Dialog_SetIntProperty(dlg, "", GWEN_DialogProperty_Width, 0, i, 0);
549 
550   /* read height */
551   i=GWEN_DB_GetIntValue(dbPrefs, "dialog_height", 0, -1);
552   if (i>=DIALOG_MINHEIGHT)
553     GWEN_Dialog_SetIntProperty(dlg, "", GWEN_DialogProperty_Height, 0, i, 0);
554 
555   /* disable next and previous buttons */
556   GWEN_Dialog_SetIntProperty(dlg, "wiz_prev_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
557   GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
558 }
559 
560 
561 
AH_ImportKeyFileDialog_Fini(GWEN_DIALOG * dlg)562 void AH_ImportKeyFileDialog_Fini(GWEN_DIALOG *dlg)
563 {
564   AH_IMPORTKEYFILE_DIALOG *xdlg;
565   int i;
566   GWEN_DB_NODE *dbPrefs;
567 
568   assert(dlg);
569   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
570   assert(xdlg);
571 
572   dbPrefs=GWEN_Dialog_GetPreferences(dlg);
573 
574   /* store dialog width */
575   i=GWEN_Dialog_GetIntProperty(dlg, "", GWEN_DialogProperty_Width, 0, -1);
576   GWEN_DB_SetIntValue(dbPrefs,
577                       GWEN_DB_FLAGS_OVERWRITE_VARS,
578                       "dialog_width",
579                       i);
580 
581   /* store dialog height */
582   i=GWEN_Dialog_GetIntProperty(dlg, "", GWEN_DialogProperty_Height, 0, -1);
583   GWEN_DB_SetIntValue(dbPrefs,
584                       GWEN_DB_FLAGS_OVERWRITE_VARS,
585                       "dialog_height",
586                       i);
587 }
588 
589 
590 
AH_ImportKeyFileDialog_GetFilePageData(GWEN_DIALOG * dlg)591 int AH_ImportKeyFileDialog_GetFilePageData(GWEN_DIALOG *dlg)
592 {
593   AH_IMPORTKEYFILE_DIALOG *xdlg;
594   const char *s;
595 
596   assert(dlg);
597   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
598   assert(xdlg);
599 
600   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_filename_edit", GWEN_DialogProperty_Value, 0, NULL);
601   if (s && *s)
602     AH_ImportKeyFileDialog_SetFileName(dlg, s);
603   else {
604     DBG_INFO(AQHBCI_LOGDOMAIN, "Missing file name");
605     return GWEN_ERROR_NO_DATA;
606   }
607 
608   return 0;
609 }
610 
611 
612 
AH_ImportKeyFileDialog_GetBankPageData(GWEN_DIALOG * dlg)613 int AH_ImportKeyFileDialog_GetBankPageData(GWEN_DIALOG *dlg)
614 {
615   AH_IMPORTKEYFILE_DIALOG *xdlg;
616   const char *s;
617 
618   assert(dlg);
619   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
620   assert(xdlg);
621 
622   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_bankcode_edit", GWEN_DialogProperty_Value, 0, NULL);
623   if (s && *s)
624     AH_ImportKeyFileDialog_SetBankCode(dlg, s);
625   else {
626     DBG_INFO(AQHBCI_LOGDOMAIN, "Missing bank code");
627     return GWEN_ERROR_NO_DATA;
628   }
629 
630   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_bankname_edit", GWEN_DialogProperty_Value, 0, NULL);
631   if (s && *s)
632     AH_ImportKeyFileDialog_SetBankName(dlg, s);
633   else
634     AH_ImportKeyFileDialog_SetBankName(dlg, NULL);
635 
636   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_url_edit", GWEN_DialogProperty_Value, 0, NULL);
637   if (s && *s)
638     AH_ImportKeyFileDialog_SetUrl(dlg, s);
639   else {
640     DBG_INFO(AQHBCI_LOGDOMAIN, "Missing URL");
641     return GWEN_ERROR_NO_DATA;
642   }
643 
644   return 0;
645 }
646 
647 
648 
AH_ImportKeyFileDialog_GetUserPageData(GWEN_DIALOG * dlg)649 int AH_ImportKeyFileDialog_GetUserPageData(GWEN_DIALOG *dlg)
650 {
651   AH_IMPORTKEYFILE_DIALOG *xdlg;
652   const char *s;
653 
654   assert(dlg);
655   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
656   assert(xdlg);
657 
658   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_username_edit", GWEN_DialogProperty_Value, 0, NULL);
659   if (s && *s)
660     AH_ImportKeyFileDialog_SetUserName(dlg, s);
661   else {
662     DBG_INFO(AQHBCI_LOGDOMAIN, "Missing user name");
663     return GWEN_ERROR_NO_DATA;
664   }
665 
666   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_userid_edit", GWEN_DialogProperty_Value, 0, NULL);
667   if (s && *s)
668     AH_ImportKeyFileDialog_SetUserId(dlg, s);
669   else {
670     DBG_INFO(AQHBCI_LOGDOMAIN, "Missing user id");
671     return GWEN_ERROR_NO_DATA;
672   }
673 
674   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_customerid_edit", GWEN_DialogProperty_Value, 0, NULL);
675   if (s && *s)
676     AH_ImportKeyFileDialog_SetCustomerId(dlg, s);
677   else
678     AH_ImportKeyFileDialog_SetCustomerId(dlg, NULL);
679 
680   return 0;
681 }
682 
683 
684 
AH_ImportKeyFileDialog_CheckFileType(GWEN_DIALOG * dlg)685 int AH_ImportKeyFileDialog_CheckFileType(GWEN_DIALOG *dlg)
686 {
687   AH_IMPORTKEYFILE_DIALOG *xdlg;
688   GWEN_PLUGIN_MANAGER *pm;
689   GWEN_PLUGIN *pl;
690   GWEN_BUFFER *tnBuf;
691   GWEN_BUFFER *ttBuf;
692   GWEN_CRYPT_TOKEN *ct;
693   int rv;
694 
695   assert(dlg);
696   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
697   assert(xdlg);
698 
699   GWEN_Crypt_Token_Context_List_Clear(xdlg->contextList);
700 
701   /* create CryptToken */
702   pm=GWEN_PluginManager_FindPluginManager(GWEN_CRYPT_TOKEN_PLUGIN_TYPENAME);
703   if (pm==NULL) {
704     DBG_ERROR(AQHBCI_LOGDOMAIN, "Plugin manager not found");
705     GWEN_Gui_ShowError(I18N("Error"),
706                        I18N("CryptToken plugin for type %s is not available. Did you install all necessary packages?"),
707                        GWEN_CRYPT_TOKEN_PLUGIN_TYPENAME);
708     return GWEN_ERROR_INTERNAL;
709   }
710 
711   tnBuf=GWEN_Buffer_new(0, 256, 0, 1);
712   GWEN_Buffer_AppendString(tnBuf, xdlg->fileName);
713   ttBuf=GWEN_Buffer_new(0, 256, 0, 1);
714   rv=GWEN_Crypt_Token_PluginManager_CheckToken(pm, GWEN_Crypt_Token_Device_File, ttBuf, tnBuf, 0);
715   if (rv<0) {
716     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
717     GWEN_Buffer_free(ttBuf);
718     GWEN_Buffer_free(tnBuf);
719     return rv;
720   }
721 
722   pl=GWEN_PluginManager_GetPlugin(pm, GWEN_Buffer_GetStart(ttBuf));
723   if (pl==NULL) {
724     DBG_ERROR(AQHBCI_LOGDOMAIN, "Plugin not found");
725     GWEN_Gui_ShowError(I18N("Error"),
726                        I18N("CryptToken plugin for type %s is not available. Did you install all necessary packages?"),
727                        GWEN_Buffer_GetStart(ttBuf));
728     GWEN_Buffer_free(ttBuf);
729     GWEN_Buffer_free(tnBuf);
730     return GWEN_ERROR_NOT_SUPPORTED;
731   }
732   DBG_INFO(AQHBCI_LOGDOMAIN, "Plugin found");
733 
734   ct=GWEN_Crypt_Token_Plugin_CreateToken(pl, GWEN_Buffer_GetStart(tnBuf));
735   if (ct==NULL) {
736     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not create crypt token");
737     GWEN_Buffer_free(ttBuf);
738     GWEN_Buffer_free(tnBuf);
739     return GWEN_ERROR_INTERNAL;
740   }
741   GWEN_Buffer_free(ttBuf);
742   GWEN_Buffer_free(tnBuf);
743 
744   /* create crypt token */
745   rv=GWEN_Crypt_Token_Open(ct, 0, 0);
746   if (rv<0) {
747     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not open token");
748     GWEN_Gui_ShowError(I18N("Error"),
749                        I18N("The keyfile %s could not be opened. Please check permissions (%d)."),
750                        GWEN_Crypt_Token_GetTokenName(ct),
751                        rv);
752     GWEN_Crypt_Token_free(ct);
753     return rv;
754   }
755 
756   GWEN_Dialog_SetIntProperty(dlg, "wiz_context_combo", GWEN_DialogProperty_ClearValues, 0, 0, 0);
757   GWEN_Dialog_SetCharProperty(dlg, "wiz_context_combo", GWEN_DialogProperty_AddValue, 0, I18N("-- custom --"), 0);
758   if (1) {
759     uint32_t idList[MAX_CONTEXT_ID_ENTRIES];
760     uint32_t idCount;
761     uint32_t i;
762 
763     idCount=MAX_CONTEXT_ID_ENTRIES;
764     rv=GWEN_Crypt_Token_GetContextIdList(ct, idList, &idCount, 0);
765     if (rv<0) {
766       DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not read context id list");
767       GWEN_Gui_ShowError(I18N("Error"),
768                          I18N("Could not read context id list (%d)."),
769                          rv);
770       GWEN_Crypt_Token_Close(ct, 1, 0);
771       GWEN_Crypt_Token_free(ct);
772       return rv;
773     }
774 
775     for (i=0; i<idCount; i++) {
776       const GWEN_CRYPT_TOKEN_CONTEXT *ctx;
777 
778       ctx=GWEN_Crypt_Token_GetContext(ct, idList[i], 0);
779       if (ctx) {
780         GWEN_CRYPT_TOKEN_CONTEXT *nctx;
781         char numbuf[64];
782         GWEN_BUFFER *tbuf;
783         const char *s;
784 
785         nctx=GWEN_Crypt_Token_Context_dup(ctx);
786         GWEN_Crypt_Token_Context_List_Add(nctx, xdlg->contextList);
787 
788         tbuf=GWEN_Buffer_new(0, 256, 0, 1);
789         snprintf(numbuf, sizeof(numbuf)-1, I18N("Context %d:"), i+1);
790         numbuf[sizeof(numbuf)-1]=0;
791         GWEN_Buffer_AppendString(tbuf, numbuf);
792 
793         s=GWEN_Crypt_Token_Context_GetServiceId(nctx);
794         if (s && *s && strcasecmp(s, "20202020")!=0)
795           GWEN_Buffer_AppendString(tbuf, s);
796         else
797           GWEN_Buffer_AppendString(tbuf, I18N("<no bank code>"));
798         GWEN_Buffer_AppendString(tbuf, "-");
799 
800         s=GWEN_Crypt_Token_Context_GetUserId(nctx);
801         if (s && *s)
802           GWEN_Buffer_AppendString(tbuf, s);
803         else
804           GWEN_Buffer_AppendString(tbuf, I18N("<no user id>"));
805         GWEN_Dialog_SetCharProperty(dlg, "wiz_context_combo", GWEN_DialogProperty_AddValue, 0, GWEN_Buffer_GetStart(tbuf), 0);
806         GWEN_Buffer_free(tbuf);
807         DBG_INFO(AQHBCI_LOGDOMAIN, "Added context %08x", idList[i]);
808       }
809     }
810   } /* for */
811 
812   /* close crypt token */
813   rv=GWEN_Crypt_Token_Close(ct, 0, 0);
814   if (rv<0) {
815     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not close token");
816     GWEN_Gui_ShowError(I18N("Error"),
817                        I18N("The keyfile %s could not be closed. Please check disc space."),
818                        GWEN_Crypt_Token_GetTokenName(ct),
819                        rv);
820     GWEN_Crypt_Token_free(ct);
821     return rv;
822   }
823 
824   GWEN_Crypt_Token_free(ct);
825 
826   return 0;
827 }
828 
829 
830 
AH_ImportKeyFileDialog_EnterPage(GWEN_DIALOG * dlg,int page,int forwards)831 int AH_ImportKeyFileDialog_EnterPage(GWEN_DIALOG *dlg, int page, int forwards)
832 {
833   AH_IMPORTKEYFILE_DIALOG *xdlg;
834   int rv;
835 
836   assert(dlg);
837   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
838   assert(xdlg);
839 
840   switch (page) {
841   case PAGE_BEGIN:
842     GWEN_Dialog_SetIntProperty(dlg, "wiz_prev_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
843     GWEN_Dialog_SetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, page, 0);
844     return GWEN_DialogEvent_ResultHandled;
845 
846   case PAGE_FILE:
847     GWEN_Dialog_SetIntProperty(dlg, "wiz_prev_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
848     rv=AH_ImportKeyFileDialog_GetFilePageData(dlg);
849     if (rv<0)
850       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
851     else
852       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
853     GWEN_Dialog_SetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, page, 0);
854     return GWEN_DialogEvent_ResultHandled;
855 
856   case PAGE_BANK:
857     if (forwards) {
858       /* leaving FILE page, check whether we can open the file */
859       rv=AH_ImportKeyFileDialog_GetFilePageData(dlg);
860       if (rv<0) {
861         DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
862         return GWEN_DialogEvent_ResultHandled;
863       }
864       rv=AH_ImportKeyFileDialog_CheckFileType(dlg);
865       if (rv<0) {
866         DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
867         return GWEN_DialogEvent_ResultHandled;
868       }
869     }
870     GWEN_Dialog_SetIntProperty(dlg, "wiz_prev_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
871     rv=AH_ImportKeyFileDialog_GetBankPageData(dlg);
872     if (rv<0)
873       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
874     else
875       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
876     GWEN_Dialog_SetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, page, 0);
877     return GWEN_DialogEvent_ResultHandled;
878 
879   case PAGE_USER:
880     GWEN_Dialog_SetIntProperty(dlg, "wiz_prev_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
881     rv=AH_ImportKeyFileDialog_GetUserPageData(dlg);
882     if (rv<0)
883       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
884     else
885       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
886     GWEN_Dialog_SetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, page, 0);
887     return GWEN_DialogEvent_ResultHandled;
888 
889   case PAGE_CREATE:
890     if (!forwards)
891       GWEN_Dialog_SetCharProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Title, 0, I18N("Next"), 0);
892     GWEN_Dialog_SetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, page, 0);
893     return GWEN_DialogEvent_ResultHandled;
894 
895   case PAGE_END:
896     GWEN_Dialog_SetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, page, 0);
897     GWEN_Dialog_SetCharProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Title, 0, I18N("Finish"), 0);
898     GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
899     GWEN_Dialog_SetIntProperty(dlg, "wiz_prev_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
900     GWEN_Dialog_SetIntProperty(dlg, "wiz_abort_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
901     return GWEN_DialogEvent_ResultHandled;
902 
903   default:
904     return GWEN_DialogEvent_ResultHandled;
905   }
906 
907   return GWEN_DialogEvent_ResultHandled;
908 }
909 
910 
911 
AH_ImportKeyFileDialog_DoIt(GWEN_DIALOG * dlg)912 int AH_ImportKeyFileDialog_DoIt(GWEN_DIALOG *dlg)
913 {
914   AH_IMPORTKEYFILE_DIALOG *xdlg;
915   AB_USER *u;
916   GWEN_URL *url;
917   int rv;
918   uint32_t pid;
919   AB_IMEXPORTER_CONTEXT *ctx;
920   int contextId=1;
921   int i;
922 
923   assert(dlg);
924   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
925   assert(xdlg);
926 
927   rv=AH_ImportKeyFileDialog_GetFilePageData(dlg);
928   if (rv<0) {
929     DBG_ERROR(AQHBCI_LOGDOMAIN, "No file?");
930     // TODO: show error message
931     return GWEN_DialogEvent_ResultHandled;
932   }
933 
934   i=GWEN_Dialog_GetIntProperty(dlg, "wiz_context_combo", GWEN_DialogProperty_Value, 0, -1);
935   if (i>0) {
936     GWEN_CRYPT_TOKEN_CONTEXT *tctx;
937 
938     tctx=GWEN_Crypt_Token_Context_List_First(xdlg->contextList);
939     while (tctx && --i)
940       tctx=GWEN_Crypt_Token_Context_List_Next(tctx);
941 
942     if (tctx)
943       contextId=GWEN_Crypt_Token_Context_GetId(tctx);
944   }
945 
946   DBG_NOTICE(0, "Creating user");
947   u=AB_Provider_CreateUserObject(xdlg->provider);
948   if (u==NULL) {
949     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not create user, maybe backend missing?");
950     GWEN_Gui_ShowError(I18N("Error"),
951                        "%s",
952                        I18N("Could not create HBCI user (internal error)"));
953     return GWEN_DialogEvent_ResultHandled;
954   }
955 
956   /* generic setup */
957   AB_User_SetUserName(u, xdlg->userName);
958   AB_User_SetUserId(u, xdlg->userId);
959   if (xdlg->customerId && *(xdlg->customerId))
960     AB_User_SetCustomerId(u, xdlg->customerId);
961   else
962     AB_User_SetCustomerId(u, xdlg->userId);
963   AB_User_SetCountry(u, "de");
964 
965   AB_User_SetBankCode(u, xdlg->bankCode);
966 
967   /* HBCI setup */
968   AH_User_SetTokenType(u, "ohbci");
969   AH_User_SetTokenName(u, AH_ImportKeyFileDialog_GetFileName(dlg));
970   AH_User_SetTokenContextId(u, contextId);
971   AH_User_SetCryptMode(u, AH_CryptMode_Rdh);
972   AH_User_SetStatus(u, AH_UserStatusPending);
973   AH_User_SetHbciVersion(u, xdlg->hbciVersion);
974   AH_User_SetRdhType(u, xdlg->rdhVersion);
975   AH_User_SetFlags(u, xdlg->flags);
976 
977   url=GWEN_Url_fromString(xdlg->url);
978   assert(url);
979   GWEN_Url_SetProtocol(url, "hbci");
980   if (GWEN_Url_GetPort(url)==0)
981     GWEN_Url_SetPort(url, 3000);
982   AH_User_SetServerUrl(u, url);
983   GWEN_Url_free(url);
984 
985   rv=AB_Provider_AddUser(xdlg->provider, u);
986   if (rv<0) {
987     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not add user (%d)", rv);
988     AB_User_free(u);
989     GWEN_Gui_ShowError(I18N("Error"),
990                        I18N("Could not add HBCI user, maybe there already is a user of that id (%d)"),
991                        rv);
992     return GWEN_DialogEvent_ResultHandled;
993   }
994 
995   pid=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_DELAY |
996                              GWEN_GUI_PROGRESS_ALLOW_EMBED |
997                              GWEN_GUI_PROGRESS_SHOW_PROGRESS |
998                              GWEN_GUI_PROGRESS_SHOW_ABORT,
999                              I18N("Setting Up Keyfile User"),
1000                              I18N("The server keys and system id will now be retrieved."),
1001                              2, /* getkeys, getsysid */
1002                              0);
1003   /* lock new user */
1004   rv=AB_Provider_BeginExclUseUser(xdlg->provider, u);
1005   if (rv<0) {
1006     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not lock user (%d)", rv);
1007     GWEN_Gui_ProgressLog2(pid,
1008                           GWEN_LoggerLevel_Error,
1009                           I18N("Unable to lock users (%d)"), rv);
1010     AB_Provider_DeleteUser(xdlg->provider, AB_User_GetUniqueId(u));
1011     GWEN_Gui_ProgressEnd(pid);
1012     return GWEN_DialogEvent_ResultHandled;
1013   }
1014 
1015   /* get server keys id */
1016   GWEN_Gui_ProgressLog(pid,
1017                        GWEN_LoggerLevel_Notice,
1018                        I18N("Retrieving server keys"));
1019   ctx=AB_ImExporterContext_new();
1020   rv=AH_Provider_GetServerKeys(xdlg->provider, u, ctx, 0, 1, 0);
1021   AB_ImExporterContext_free(ctx);
1022   if (rv<0) {
1023     AB_Provider_EndExclUseUser(xdlg->provider, u, 1);
1024     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1025     AB_Provider_DeleteUser(xdlg->provider, AB_User_GetUniqueId(u));
1026     GWEN_Gui_ProgressEnd(pid);
1027     return GWEN_DialogEvent_ResultHandled;
1028   }
1029 
1030   /* TODO: show bank key hash */
1031 
1032   rv=GWEN_Gui_ProgressAdvance(pid, GWEN_GUI_PROGRESS_ONE);
1033   if (rv==GWEN_ERROR_USER_ABORTED) {
1034     AB_Provider_EndExclUseUser(xdlg->provider, u, 1);
1035     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1036     AB_Provider_DeleteUser(xdlg->provider, AB_User_GetUniqueId(u));
1037     GWEN_Gui_ProgressLog(pid,
1038                          GWEN_LoggerLevel_Error,
1039                          I18N("Aborted by user."));
1040     GWEN_Gui_ProgressEnd(pid);
1041     return GWEN_DialogEvent_ResultHandled;
1042   }
1043 
1044   /* get sysid keys id */
1045   GWEN_Gui_ProgressLog(pid,
1046                        GWEN_LoggerLevel_Notice,
1047                        I18N("Retrieving system id"));
1048   ctx=AB_ImExporterContext_new();
1049   rv=AH_Provider_GetSysId(xdlg->provider, u, ctx, 0, 1, 0);
1050   AB_ImExporterContext_free(ctx);
1051   if (rv<0) {
1052     AB_Provider_EndExclUseUser(xdlg->provider, u, 1);
1053     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1054     AB_Provider_DeleteUser(xdlg->provider, AB_User_GetUniqueId(u));
1055     GWEN_Gui_ProgressEnd(pid);
1056     return GWEN_DialogEvent_ResultHandled;
1057   }
1058 
1059   rv=GWEN_Gui_ProgressAdvance(pid, GWEN_GUI_PROGRESS_ONE);
1060   if (rv==GWEN_ERROR_USER_ABORTED) {
1061     AB_Provider_EndExclUseUser(xdlg->provider, u, 1);
1062     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1063     AB_Provider_DeleteUser(xdlg->provider, AB_User_GetUniqueId(u));
1064     GWEN_Gui_ProgressLog(pid,
1065                          GWEN_LoggerLevel_Error,
1066                          I18N("Aborted by user."));
1067     GWEN_Gui_ProgressEnd(pid);
1068     return GWEN_DialogEvent_ResultHandled;
1069   }
1070 
1071   /* unlock user */
1072   rv=AB_Provider_EndExclUseUser(xdlg->provider, u, 0);
1073   if (rv<0) {
1074     DBG_INFO(AQHBCI_LOGDOMAIN,
1075              "Could not unlock customer [%s] (%d)",
1076              AB_User_GetCustomerId(u), rv);
1077     GWEN_Gui_ProgressLog2(pid,
1078                           GWEN_LoggerLevel_Error,
1079                           I18N("Could not unlock user %s (%d)"),
1080                           AB_User_GetUserId(u), rv);
1081     AB_Provider_EndExclUseUser(xdlg->provider, u, 1);
1082     AB_Provider_DeleteUser(xdlg->provider, AB_User_GetUniqueId(u));
1083     GWEN_Gui_ProgressEnd(pid);
1084     return GWEN_DialogEvent_ResultHandled;
1085   }
1086 
1087   GWEN_Gui_ProgressEnd(pid);
1088   AH_ImportKeyFileDialog_EnterPage(dlg, PAGE_END, 1);
1089 
1090   xdlg->user=u;
1091 
1092   return GWEN_DialogEvent_ResultHandled;
1093 }
1094 
1095 
1096 
AH_ImportKeyFileDialog_Next(GWEN_DIALOG * dlg)1097 int AH_ImportKeyFileDialog_Next(GWEN_DIALOG *dlg)
1098 {
1099   AH_IMPORTKEYFILE_DIALOG *xdlg;
1100   int page;
1101 
1102   assert(dlg);
1103   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1104   assert(xdlg);
1105 
1106   page=GWEN_Dialog_GetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, -1);
1107   if (page==PAGE_CREATE) {
1108     return AH_ImportKeyFileDialog_DoIt(dlg);
1109   }
1110   else if (page<PAGE_END) {
1111     page++;
1112     return AH_ImportKeyFileDialog_EnterPage(dlg, page, 1);
1113   }
1114   else if (page==PAGE_END)
1115     return GWEN_DialogEvent_ResultAccept;
1116 
1117   return GWEN_DialogEvent_ResultHandled;
1118 }
1119 
1120 
1121 
AH_ImportKeyFileDialog_Previous(GWEN_DIALOG * dlg)1122 int AH_ImportKeyFileDialog_Previous(GWEN_DIALOG *dlg)
1123 {
1124   AH_IMPORTKEYFILE_DIALOG *xdlg;
1125   int page;
1126 
1127   assert(dlg);
1128   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1129   assert(xdlg);
1130 
1131   page=GWEN_Dialog_GetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, -1);
1132   if (page>PAGE_BEGIN) {
1133     page--;
1134     return AH_ImportKeyFileDialog_EnterPage(dlg, page, 0);
1135   }
1136 
1137   return GWEN_DialogEvent_ResultHandled;
1138 }
1139 
1140 
1141 
AH_ImportKeyFileDialog_HandleActivatedBankCode(GWEN_DIALOG * dlg)1142 int AH_ImportKeyFileDialog_HandleActivatedBankCode(GWEN_DIALOG *dlg)
1143 {
1144   AH_IMPORTKEYFILE_DIALOG *xdlg;
1145   GWEN_DIALOG *dlg2;
1146   int rv;
1147 
1148   assert(dlg);
1149   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1150   assert(xdlg);
1151 
1152   dlg2=AB_SelectBankInfoDialog_new(xdlg->banking, "de", NULL);
1153   if (dlg2==NULL) {
1154     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not create dialog");
1155     GWEN_Gui_ShowError(I18N("Error"), "%s", I18N("Could not create dialog, maybe an installation error?"));
1156     return GWEN_DialogEvent_ResultHandled;
1157   }
1158 
1159   rv=GWEN_Gui_ExecDialog(dlg2, 0);
1160   if (rv==0) {
1161     /* rejected */
1162     GWEN_Dialog_free(dlg2);
1163     return GWEN_DialogEvent_ResultHandled;
1164   }
1165   else {
1166     const AB_BANKINFO *bi;
1167 
1168     bi=AB_SelectBankInfoDialog_GetSelectedBankInfo(dlg2);
1169     if (bi) {
1170       const char *s;
1171       AB_BANKINFO_SERVICE *sv;
1172 
1173       s=AB_BankInfo_GetBankId(bi);
1174       GWEN_Dialog_SetCharProperty(dlg,
1175                                   "wiz_bankcode_edit",
1176                                   GWEN_DialogProperty_Value,
1177                                   0,
1178                                   (s && *s)?s:"",
1179                                   0);
1180 
1181       s=AB_BankInfo_GetBankName(bi);
1182       GWEN_Dialog_SetCharProperty(dlg,
1183                                   "wiz_bankname_edit",
1184                                   GWEN_DialogProperty_Value,
1185                                   0,
1186                                   (s && *s)?s:"",
1187                                   0);
1188       sv=AB_BankInfoService_List_First(AB_BankInfo_GetServices(bi));
1189       while (sv) {
1190         const char *s;
1191 
1192         s=AB_BankInfoService_GetType(sv);
1193         if (s && *s && strcasecmp(s, "HBCI")==0) {
1194           s=AB_BankInfoService_GetMode(sv);
1195           if (s && *s && strncasecmp(s, "RDH", 3)==0)
1196             break;
1197         }
1198         sv=AB_BankInfoService_List_Next(sv);
1199       }
1200 
1201       if (sv) {
1202         /* RDH service found */
1203         s=AB_BankInfoService_GetMode(sv);
1204         if (s && *s) {
1205           if (strcasecmp(s, "RDH1")==0)
1206             xdlg->rdhVersion=1;
1207           else if (strcasecmp(s, "RDH2")==0)
1208             xdlg->rdhVersion=2;
1209           else if (strcasecmp(s, "RDH3")==0)
1210             xdlg->rdhVersion=3;
1211           else if (strcasecmp(s, "RDH4")==0)
1212             xdlg->rdhVersion=4;
1213           else if (strcasecmp(s, "RDH5")==0)
1214             xdlg->rdhVersion=5;
1215           else if (strcasecmp(s, "RDH6")==0)
1216             xdlg->rdhVersion=6;
1217           else if (strcasecmp(s, "RDH7")==0)
1218             xdlg->rdhVersion=7;
1219           else if (strcasecmp(s, "RDH8")==0)
1220             xdlg->rdhVersion=8;
1221           else if (strcasecmp(s, "RDH9")==0)
1222             xdlg->rdhVersion=9;
1223           else if (strcasecmp(s, "RDH10")==0)
1224             xdlg->rdhVersion=10;
1225           else if (strcasecmp(s, "RDH")==0)
1226             xdlg->rdhVersion=1;
1227         }
1228 
1229         s=AB_BankInfoService_GetAddress(sv);
1230         GWEN_Dialog_SetCharProperty(dlg,
1231                                     "wiz_url_edit",
1232                                     GWEN_DialogProperty_Value,
1233                                     0,
1234                                     (s && *s)?s:"",
1235                                     0);
1236         s=AB_BankInfoService_GetPversion(sv);
1237         if (s && *s) {
1238           if (strcasecmp(s, "2.01")==0 ||
1239               strcasecmp(s, "2")==0)
1240             xdlg->hbciVersion=201;
1241           else if (strcasecmp(s, "2.10")==0 ||
1242                    strcasecmp(s, "2.1")==0)
1243             xdlg->hbciVersion=210;
1244           else if (strcasecmp(s, "2.20")==0 ||
1245                    strcasecmp(s, "2.2")==0)
1246             xdlg->hbciVersion=220;
1247           else if (strcasecmp(s, "3.00")==0 ||
1248                    strcasecmp(s, "3.0")==0 ||
1249                    strcasecmp(s, "3")==0)
1250             xdlg->hbciVersion=300;
1251           else if (strcasecmp(s, "4.00")==0 ||
1252                    strcasecmp(s, "4.0")==0 ||
1253                    strcasecmp(s, "4")==0)
1254             xdlg->hbciVersion=400;
1255         }
1256       }
1257     }
1258   }
1259 
1260   GWEN_Dialog_free(dlg2);
1261 
1262   if (AH_ImportKeyFileDialog_GetBankPageData(dlg)<0)
1263     GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
1264   else
1265     GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
1266 
1267   return GWEN_DialogEvent_ResultHandled;
1268 }
1269 
1270 
1271 
AH_ImportKeyFileDialog_HandleActivatedSpecial(GWEN_DIALOG * dlg)1272 int AH_ImportKeyFileDialog_HandleActivatedSpecial(GWEN_DIALOG *dlg)
1273 {
1274   AH_IMPORTKEYFILE_DIALOG *xdlg;
1275   GWEN_DIALOG *dlg2;
1276   int rv;
1277 
1278   assert(dlg);
1279   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1280   assert(xdlg);
1281 
1282   dlg2=AH_RdhSpecialDialog_new(xdlg->provider);
1283   if (dlg2==NULL) {
1284     DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not create dialog");
1285     GWEN_Gui_ShowError(I18N("Error"), "%s", I18N("Could not create dialog, maybe an installation error?"));
1286     return GWEN_DialogEvent_ResultHandled;
1287   }
1288 
1289   AH_RdhSpecialDialog_SetFlags(dlg2, xdlg->flags);
1290 
1291   rv=GWEN_Gui_ExecDialog(dlg2, 0);
1292   if (rv==0) {
1293     /* rejected */
1294     GWEN_Dialog_free(dlg2);
1295     return GWEN_DialogEvent_ResultHandled;
1296   }
1297   else {
1298     xdlg->hbciVersion=AH_RdhSpecialDialog_GetHbciVersion(dlg2);
1299     xdlg->rdhVersion=AH_RdhSpecialDialog_GetRdhVersion(dlg2);
1300     xdlg->flags=AH_RdhSpecialDialog_GetFlags(dlg2);
1301   }
1302 
1303   GWEN_Dialog_free(dlg2);
1304 
1305   return GWEN_DialogEvent_ResultHandled;
1306 }
1307 
1308 
1309 
AH_ImportKeyFileDialog_HandleActivatedFileButton(GWEN_DIALOG * dlg)1310 int AH_ImportKeyFileDialog_HandleActivatedFileButton(GWEN_DIALOG *dlg)
1311 {
1312   AH_IMPORTKEYFILE_DIALOG *xdlg;
1313   int rv;
1314   const char *s;
1315   GWEN_BUFFER *pathBuffer;
1316 
1317   assert(dlg);
1318   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1319   assert(xdlg);
1320 
1321   pathBuffer=GWEN_Buffer_new(0, 256, 0, 1);
1322   s=GWEN_Dialog_GetCharProperty(dlg, "wiz_filename_edit", GWEN_DialogProperty_Value, 0, NULL);
1323   if (s && *s)
1324     GWEN_Buffer_AppendString(pathBuffer, s);
1325   rv=GWEN_Gui_GetFileName(I18N("Select Keyfile"),
1326                           GWEN_Gui_FileNameType_OpenFileName,
1327                           0,
1328                           I18N("All Files (*)\tOHBCI Files (*ohbci;*.medium)"),
1329                           pathBuffer,
1330                           GWEN_Dialog_GetGuiId(dlg));
1331   if (rv==0) {
1332     GWEN_Dialog_SetCharProperty(dlg,
1333                                 "wiz_filename_edit",
1334                                 GWEN_DialogProperty_Value,
1335                                 0,
1336                                 GWEN_Buffer_GetStart(pathBuffer),
1337                                 0);
1338     rv=AH_ImportKeyFileDialog_GetFilePageData(dlg);
1339     if (rv<0)
1340       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
1341     else
1342       GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
1343   }
1344   else {
1345     DBG_NOTICE(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1346   }
1347   GWEN_Buffer_free(pathBuffer);
1348   return GWEN_DialogEvent_ResultHandled;
1349 }
1350 
1351 
1352 
AH_ImportKeyFileDialog_HandleActivatedIniLetter(GWEN_DIALOG * dlg)1353 static int AH_ImportKeyFileDialog_HandleActivatedIniLetter(GWEN_DIALOG *dlg)
1354 {
1355   AH_IMPORTKEYFILE_DIALOG *xdlg;
1356   int rv;
1357   GWEN_BUFFER *tbuf;
1358 
1359   assert(dlg);
1360   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1361   assert(xdlg);
1362 
1363   tbuf=GWEN_Buffer_new(0, 1024, 0, 1);
1364 
1365   /* add HTML version of the INI letter */
1366   GWEN_Buffer_AppendString(tbuf, "<html>");
1367   rv=AH_Provider_GetIniLetterHtml(AB_User_GetProvider(xdlg->user),
1368                                   xdlg->user,
1369                                   0,
1370                                   0,
1371                                   tbuf,
1372                                   1);
1373   if (rv<0) {
1374     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1375     // TODO: show error message
1376     AB_Banking_ClearCryptTokenList(xdlg->banking);
1377     GWEN_Buffer_free(tbuf);
1378     return GWEN_DialogEvent_ResultHandled;
1379   }
1380   GWEN_Buffer_AppendString(tbuf, "</html>");
1381 
1382 
1383   /* add ASCII version of the INI letter for frontends which don't support HTML */
1384   rv=AH_Provider_GetIniLetterTxt(AB_User_GetProvider(xdlg->user),
1385                                  xdlg->user,
1386                                  0,
1387                                  0,
1388                                  tbuf,
1389                                  0);
1390   if (rv<0) {
1391     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1392     // TODO: show error message
1393     AB_Banking_ClearCryptTokenList(xdlg->banking);
1394     GWEN_Buffer_free(tbuf);
1395     return GWEN_DialogEvent_ResultHandled;
1396   }
1397 
1398   rv=GWEN_Gui_Print(I18N("INI Letter"),
1399                     "HBCI-INILETTER",
1400                     I18N("INI Letter for HBCI"),
1401                     GWEN_Buffer_GetStart(tbuf),
1402                     0);
1403   if (rv<0) {
1404     DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv);
1405     // TODO: show error message
1406     GWEN_Buffer_free(tbuf);
1407     return GWEN_DialogEvent_ResultHandled;
1408   }
1409 
1410   GWEN_Buffer_free(tbuf);
1411   return GWEN_DialogEvent_ResultHandled;
1412 }
1413 
1414 
1415 
AH_ImportKeyFileDialog_HandleActivatedContext(GWEN_DIALOG * dlg)1416 int AH_ImportKeyFileDialog_HandleActivatedContext(GWEN_DIALOG *dlg)
1417 {
1418   AH_IMPORTKEYFILE_DIALOG *xdlg;
1419   int i;
1420 
1421   assert(dlg);
1422   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1423   assert(xdlg);
1424 
1425   i=GWEN_Dialog_GetIntProperty(dlg, "wiz_context_combo", GWEN_DialogProperty_Value, 0, -1);
1426   if (i>0) {
1427     GWEN_CRYPT_TOKEN_CONTEXT *ctx;
1428 
1429     ctx=GWEN_Crypt_Token_Context_List_First(xdlg->contextList);
1430     while (ctx && --i)
1431       ctx=GWEN_Crypt_Token_Context_List_Next(ctx);
1432 
1433     if (ctx) {
1434       const char *s;
1435 
1436       s=GWEN_Crypt_Token_Context_GetServiceId(ctx);
1437       GWEN_Dialog_SetCharProperty(dlg,
1438                                   "wiz_bankcode_edit",
1439                                   GWEN_DialogProperty_Value,
1440                                   0,
1441                                   (s && *s)?s:"",
1442                                   0);
1443 
1444       s=GWEN_Crypt_Token_Context_GetAddress(ctx);
1445       GWEN_Dialog_SetCharProperty(dlg,
1446                                   "wiz_url_edit",
1447                                   GWEN_DialogProperty_Value,
1448                                   0,
1449                                   (s && *s)?s:"",
1450                                   0);
1451 
1452       s=GWEN_Crypt_Token_Context_GetUserId(ctx);
1453       GWEN_Dialog_SetCharProperty(dlg,
1454                                   "wiz_userid_edit",
1455                                   GWEN_DialogProperty_Value,
1456                                   0,
1457                                   (s && *s)?s:"",
1458                                   0);
1459       GWEN_Dialog_SetCharProperty(dlg,
1460                                   "wiz_customerid_edit",
1461                                   GWEN_DialogProperty_Value,
1462                                   0,
1463                                   (s && *s)?s:"",
1464                                   0);
1465 
1466     }
1467   }
1468 
1469   return GWEN_DialogEvent_ResultHandled;
1470 }
1471 
1472 
1473 
AH_ImportKeyFileDialog_HandleActivated(GWEN_DIALOG * dlg,const char * sender)1474 int AH_ImportKeyFileDialog_HandleActivated(GWEN_DIALOG *dlg, const char *sender)
1475 {
1476   if (strcasecmp(sender, "wiz_filename_button")==0)
1477     return AH_ImportKeyFileDialog_HandleActivatedFileButton(dlg);
1478   else if (strcasecmp(sender, "wiz_bankcode_button")==0)
1479     return AH_ImportKeyFileDialog_HandleActivatedBankCode(dlg);
1480   else if (strcasecmp(sender, "wiz_prev_button")==0)
1481     return AH_ImportKeyFileDialog_Previous(dlg);
1482   else if (strcasecmp(sender, "wiz_next_button")==0)
1483     return AH_ImportKeyFileDialog_Next(dlg);
1484   else if (strcasecmp(sender, "wiz_abort_button")==0)
1485     return GWEN_DialogEvent_ResultReject;
1486   else if (strcasecmp(sender, "wiz_special_button")==0)
1487     return AH_ImportKeyFileDialog_HandleActivatedSpecial(dlg);
1488   else if (strcasecmp(sender, "wiz_iniletter_button")==0)
1489     return AH_ImportKeyFileDialog_HandleActivatedIniLetter(dlg);
1490   else if (strcasecmp(sender, "wiz_help_button")==0) {
1491     /* TODO: open a help dialog */
1492   }
1493   else if (strcasecmp(sender, "wiz_context_combo")==0)
1494     return AH_ImportKeyFileDialog_HandleActivatedContext(dlg);
1495 
1496   return GWEN_DialogEvent_ResultNotHandled;
1497 }
1498 
1499 
1500 
AH_ImportKeyFileDialog_HandleValueChanged(GWEN_DIALOG * dlg,const char * sender)1501 int AH_ImportKeyFileDialog_HandleValueChanged(GWEN_DIALOG *dlg, const char *sender)
1502 {
1503   if (strcasecmp(sender, "wiz_filename_edit")==0 ||
1504       strcasecmp(sender, "wiz_bankcode_edit")==0 ||
1505       strcasecmp(sender, "wiz_url_edit")==0 ||
1506       strcasecmp(sender, "wiz_username_edit")==0 ||
1507       strcasecmp(sender, "wiz_userid_edit")==0 ||
1508       strcasecmp(sender, "wiz_customerid_edit")==0) {
1509     int rv;
1510 
1511     if (GWEN_Dialog_GetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, -1)==PAGE_FILE) {
1512       rv=AH_ImportKeyFileDialog_GetFilePageData(dlg);
1513       if (rv<0)
1514         GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
1515       else
1516         GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
1517     }
1518     else if (GWEN_Dialog_GetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, -1)==PAGE_BANK) {
1519       rv=AH_ImportKeyFileDialog_GetBankPageData(dlg);
1520       if (rv<0)
1521         GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
1522       else
1523         GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
1524     }
1525     else if (GWEN_Dialog_GetIntProperty(dlg, "wiz_stack", GWEN_DialogProperty_Value, 0, -1)==PAGE_USER) {
1526       rv=AH_ImportKeyFileDialog_GetUserPageData(dlg);
1527       if (rv<0)
1528         GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
1529       else
1530         GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
1531     }
1532     return GWEN_DialogEvent_ResultHandled;
1533   }
1534   return GWEN_DialogEvent_ResultNotHandled;
1535 }
1536 
1537 
1538 
AH_ImportKeyFileDialog_SignalHandler(GWEN_DIALOG * dlg,GWEN_DIALOG_EVENTTYPE t,const char * sender)1539 int GWENHYWFAR_CB AH_ImportKeyFileDialog_SignalHandler(GWEN_DIALOG *dlg,
1540                                                        GWEN_DIALOG_EVENTTYPE t,
1541                                                        const char *sender)
1542 {
1543   AH_IMPORTKEYFILE_DIALOG *xdlg;
1544 
1545   assert(dlg);
1546   xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_IMPORTKEYFILE_DIALOG, dlg);
1547   assert(xdlg);
1548 
1549   switch (t) {
1550   case GWEN_DialogEvent_TypeInit:
1551     AH_ImportKeyFileDialog_Init(dlg);
1552     return GWEN_DialogEvent_ResultHandled;;
1553 
1554   case GWEN_DialogEvent_TypeFini:
1555     AH_ImportKeyFileDialog_Fini(dlg);
1556     return GWEN_DialogEvent_ResultHandled;;
1557 
1558   case GWEN_DialogEvent_TypeValueChanged:
1559     return AH_ImportKeyFileDialog_HandleValueChanged(dlg, sender);
1560 
1561   case GWEN_DialogEvent_TypeActivated:
1562     return AH_ImportKeyFileDialog_HandleActivated(dlg, sender);
1563 
1564   case GWEN_DialogEvent_TypeEnabled:
1565   case GWEN_DialogEvent_TypeDisabled:
1566   case GWEN_DialogEvent_TypeClose:
1567 
1568   case GWEN_DialogEvent_TypeLast:
1569     return GWEN_DialogEvent_ResultNotHandled;
1570 
1571   }
1572 
1573   return GWEN_DialogEvent_ResultNotHandled;
1574 }
1575 
1576 
1577 
1578 
1579