gwenhywfar  4.6.0beta
cppgui.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Mon Mar 01 2004
3  copyright : (C) 2004-2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 #ifdef HAVE_CONFIG_H
12 # include <config.h>
13 #endif
14 
15 #include "cppgui_p.hpp"
16 #include <assert.h>
17 
18 #include <gwenhywfar/inherit.h>
19 #include <gwenhywfar/debug.h>
20 #include <gwenhywfar/gui_be.h>
21 #include <gwenhywfar/i18n.h>
22 
23 #include <gwenhywfar/text.h>
24 #include <gwenhywfar/mdigest.h>
25 #include <gwenhywfar/debug.h>
26 
27 
28 
30 
31 
32 
33 
34 int CppGuiLinker::Print(GWEN_GUI *gui,
35  const char *docTitle,
36  const char *docType,
37  const char *descr,
38  const char *text,
39  uint32_t guiid){
40  CppGui *xgui;
41 
42  assert(gui);
44  assert(xgui);
45 
46  return xgui->print(docTitle, docType, descr, text, guiid);
47 }
48 
49 
50 
51 int CppGuiLinker::GetPassword(GWEN_GUI *gui,
52  uint32_t flags,
53  const char *token,
54  const char *title,
55  const char *text,
56  char *buffer,
57  int minLen,
58  int maxLen,
59  uint32_t guiid) {
60  CppGui *xgui;
61 
62  assert(gui);
64  assert(xgui);
65 
66  return xgui->getPassword(flags, token, title, text, buffer, minLen, maxLen, guiid);
67 }
68 
69 
70 
71 int CppGuiLinker::SetPasswordStatus(GWEN_GUI *gui,
72  const char *token,
73  const char *pin,
75  uint32_t guiid) {
76  CppGui *xgui;
77 
78  assert(gui);
80  assert(xgui);
81 
82  return xgui->setPasswordStatus(token, pin, status, guiid);
83 }
84 
85 
86 
87 int CppGuiLinker::CheckCert(GWEN_GUI *gui,
88  const GWEN_SSLCERTDESCR *cert,
89  GWEN_SYNCIO *sio,
90  uint32_t guiid) {
91  CppGui *xgui;
92 
93  assert(gui);
95  assert(xgui);
96 
97  return xgui->checkCert(cert, sio, guiid);
98 }
99 
100 
101 
102 int CppGuiLinker::LogHook(GWEN_GUI *gui,
103  const char *logDomain,
104  GWEN_LOGGER_LEVEL priority, const char *s) {
105  CppGui *xgui;
106 
107  assert(gui);
109  assert(xgui);
110 
111  return xgui->logHook(logDomain, priority, s);
112 }
113 
114 
115 
116 int CppGuiLinker::ExecDialog(GWEN_GUI *gui,
117  GWEN_DIALOG *dlg,
118  uint32_t guiid) {
119  CppGui *xgui;
120 
121  assert(gui);
123  assert(xgui);
124 
125  return xgui->execDialog(dlg, guiid);
126 }
127 
128 
129 
130 int CppGuiLinker::OpenDialog(GWEN_GUI *gui,
131  GWEN_DIALOG *dlg,
132  uint32_t guiid) {
133  CppGui *xgui;
134 
135  assert(gui);
137  assert(xgui);
138 
139  DBG_ERROR(0, "CppGuiLinker::OpenDialog");
140 
141  return xgui->openDialog(dlg, guiid);
142 }
143 
144 
145 
146 int CppGuiLinker::CloseDialog(GWEN_GUI *gui,
147  GWEN_DIALOG *dlg) {
148  CppGui *xgui;
149 
150  assert(gui);
152  assert(xgui);
153 
154  return xgui->closeDialog(dlg);
155 }
156 
157 
158 
159 int CppGuiLinker::RunDialog(GWEN_GUI *gui,
160  GWEN_DIALOG *dlg,
161  int untilEnd) {
162  CppGui *xgui;
163 
164  assert(gui);
166  assert(xgui);
167 
168  return xgui->runDialog(dlg, untilEnd);
169 }
170 
171 
172 
173 int CppGuiLinker::GetFileName(GWEN_GUI *gui,
174  const char *caption,
176  uint32_t flags,
177  const char *patterns,
178  GWEN_BUFFER *pathBuffer,
179  uint32_t guiid) {
180  CppGui *xgui;
181 
182  assert(gui);
184  assert(xgui);
185 
186  return xgui->getFileName(caption, fnt, flags, patterns, pathBuffer, guiid);
187 }
188 
189 
190 
192 void CppGuiLinker::freeData(void *bp, void *p) {
193  CppGui *xgui;
194 
195  DBG_NOTICE(0, "CppGuiLinker: Freeing CppGui");
196  xgui=(CppGui*)p;
197  if (xgui->_gui) {
198  xgui->_gui=0;
199  }
200  delete xgui;
201 }
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
215 :_checkCertFn(NULL)
216 ,_gui(NULL) {
217  _gui=GWEN_Gui_new();
218 
220  _gui, this,
221  CppGuiLinker::freeData);
223  _checkCertFn=GWEN_Gui_SetCheckCertFn(_gui, CppGuiLinker::CheckCert);
224  _printFn=GWEN_Gui_SetPrintFn(_gui, CppGuiLinker::Print);
225  _getPasswordFn=GWEN_Gui_SetGetPasswordFn(_gui, CppGuiLinker::GetPassword);
226  _setPasswordStatusFn=GWEN_Gui_SetSetPasswordStatusFn(_gui, CppGuiLinker::SetPasswordStatus);
227  GWEN_Gui_SetLogHookFn(_gui, CppGuiLinker::LogHook);
228  _execDialogFn=GWEN_Gui_SetExecDialogFn(_gui, CppGuiLinker::ExecDialog);
229  _openDialogFn=GWEN_Gui_SetOpenDialogFn(_gui, CppGuiLinker::OpenDialog);
230  _closeDialogFn=GWEN_Gui_SetCloseDialogFn(_gui, CppGuiLinker::CloseDialog);
231  _runDialogFn=GWEN_Gui_SetRunDialogFn(_gui, CppGuiLinker::RunDialog);
232  _getFileNameFn=GWEN_Gui_SetGetFileNameFn(_gui, CppGuiLinker::GetFileName);
233 }
234 
235 
236 
238  if (_gui) {
241  }
242 }
243 
244 
245 
247  GWEN_SYNCIO *sio,
248  uint32_t guiid) {
249  return checkCertBuiltIn(cd, sio, guiid);
250 }
251 
252 
253 
254 int CppGui::logHook(const char *logDomain,
255  GWEN_LOGGER_LEVEL priority, const char *s) {
256  /* not hooked */
257  return 0;
258 }
259 
260 
261 
262 int CppGui::execDialog(GWEN_DIALOG *dlg, uint32_t guiid) {
264 }
265 
266 
267 
268 int CppGui::openDialog(GWEN_DIALOG *dlg, uint32_t guiid) {
269  DBG_ERROR(0, "CppGui::OpenDialog");
270 
272 }
273 
274 
275 
278 }
279 
280 
281 
282 int CppGui::runDialog(GWEN_DIALOG *dlg, int untilEnd) {
284 }
285 
286 
287 
288 int CppGui::getFileName(const char *caption,
290  uint32_t flags,
291  const char *patterns,
292  GWEN_BUFFER *pathBuffer,
293  uint32_t guiid) {
294  DBG_ERROR(0, "Not supported");
296 }
297 
298 
299 
300 int CppGui::print(const char *docTitle,
301  const char *docType,
302  const char *descr,
303  const char *text,
304  uint32_t guiid){
305  if (_printFn)
306  return _printFn(_gui, docTitle, docType, descr, text, guiid);
307  else
309 }
310 
311 
312 
313 
315  GWEN_SYNCIO *sio,
316  uint32_t guiid) {
317  if (_checkCertFn)
318  return _checkCertFn(_gui, cert, sio, guiid);
319  else {
320  DBG_ERROR(0, "No built-in checkcert function?");
322  }
323 }
324 
325 
326 
327 int CppGui::getPassword(uint32_t flags,
328  const char *token,
329  const char *title,
330  const char *text,
331  char *buffer,
332  int minLen,
333  int maxLen,
334  uint32_t guiid) {
335  if (_getPasswordFn)
336  return _getPasswordFn(_gui, flags, token, title, text, buffer, minLen, maxLen, guiid);
337  else
339 }
340 
341 
342 
343 int CppGui::setPasswordStatus(const char *token,
344  const char *pin,
346  uint32_t guiid) {
347  if (_setPasswordStatusFn)
348  return _setPasswordStatusFn(_gui, token, pin, status, guiid);
349  else
351 }
352 
353 
354 
355 
356 
357 void CppGui::setPasswordDb(GWEN_DB_NODE *dbPasswords, int persistent) {
358  GWEN_Gui_SetPasswordDb(_gui, dbPasswords, persistent);
359 }
360 
361 
362 
365 }
366 
367 
368 
370  return _gui;
371 }
372 
373 
374 
376  GWEN_GUI *gui;
377  CppGui *xgui;
378 
379  gui=GWEN_Gui_GetGui();
380  if (gui==NULL)
381  return NULL;
383  return xgui;
384 }
385 
386 
387 
388 
389