gwenhywfar  4.3.3
gui.h
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Tue Oct 02 2002
3  copyright : (C) 2002-2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * Lesser General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU Lesser General Public *
19  * License along with this library; if not, write to the Free Software *
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21  * MA 02111-1307 USA *
22  * *
23  ***************************************************************************/
24 
25 #ifndef GWENHYWFAR_GUI_GUI_H
26 #define GWENHYWFAR_GUI_GUI_H
27 
28 
29 
30 #include <gwenhywfar/inherit.h>
31 #include <gwenhywfar/logger.h>
32 #include <gwenhywfar/inetsocket.h>
33 #include <gwenhywfar/ssl_cert_descr.h>
34 #include <gwenhywfar/syncio.h>
35 #include <gwenhywfar/dialog.h>
36 
37 #include <inttypes.h>
38 
39 
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
111 
112 typedef struct GWEN_GUI GWEN_GUI;
114 
115 
116 #define GWEN_GUI_CPU_TIMEOUT 200
117 
118 #define GWEN_GUI_CHECK_PERIOD 750
119 #define GWEN_GUI_DELAY_SECS 2
120 
121 
128 #define GWEN_GUI_PROGRESS_DELAY 0x00000001
129 #define GWEN_GUI_PROGRESS_SHOW_LOG 0x00000002
130 #define GWEN_GUI_PROGRESS_SHOW_ABORT 0x00000004
131 #define GWEN_GUI_PROGRESS_ALLOW_SUBLEVELS 0x00000008
132 #define GWEN_GUI_PROGRESS_ALLOW_EMBED 0x00000010
133 #define GWEN_GUI_PROGRESS_SHOW_PROGRESS 0x00000020
134 #define GWEN_GUI_PROGRESS_KEEP_OPEN 0x00000040
135 #define GWEN_GUI_PROGRESS_ALWAYS_SHOW_LOG 0x00000080
136 
147 #define GWEN_GUI_INPUT_FLAGS_CONFIRM 0x00000001
148 
149 #define GWEN_GUI_INPUT_FLAGS_SHOW 0x00000002
150 
151 #define GWEN_GUI_INPUT_FLAGS_NUMERIC 0x00000004
152 
153 #define GWEN_GUI_INPUT_FLAGS_RETRY 0x00000008
154 
156 #define GWEN_GUI_INPUT_FLAGS_ALLOW_DEFAULT 0x00000010
157 
158 #define GWEN_GUI_INPUT_FLAGS_TAN 0x00000020
159 
160 #define GWEN_GUI_INPUT_FLAGS_OPTICAL 0x00000040
161 
213 #define GWEN_GUI_MSG_FLAGS_TYPE_MASK 0x07
214 
215 #define GWEN_GUI_MSG_FLAGS_TYPE_INFO 0
216 
217 #define GWEN_GUI_MSG_FLAGS_TYPE_IS_INFO(fl) \
218  ((fl & GWEN_GUI_MSG_FLAGS_TYPE_MASK)==GWEN_GUI_MSG_FLAGS_TYPE_INFO)
219 
221 #define GWEN_GUI_MSG_FLAGS_TYPE_WARN 1
222 
223 #define GWEN_GUI_MSG_FLAGS_TYPE_IS_WARN(fl) \
224  ((fl & GWEN_GUI_MSG_FLAGS_TYPE_MASK)==GWEN_GUI_MSG_FLAGS_TYPE_WARN)
225 
227 #define GWEN_GUI_MSG_FLAGS_TYPE_ERROR 2
228 
229 #define GWEN_GUI_MSG_FLAGS_TYPE_IS_ERROR \
230  ((fl & GWEN_GUI_MSG_FLAGS_TYPE_MASK)==GWEN_GUI_MSG_FLAGS_TYPE_ERROR)
231 
233 #define GWEN_GUI_MSG_FLAGS_CONFIRM_B1 (1<<3)
234 
235 #define GWEN_GUI_MSG_FLAGS_CONFIRM_B2 (2<<3)
236 
237 #define GWEN_GUI_MSG_FLAGS_CONFIRM_B3 (3<<3)
238 
239 #define GWEN_GUI_MSG_FLAGS_CONFIRM_BUTTON(fl) (((fl)>>3) & 0x3)
240 
241 
263 #define GWEN_GUI_MSG_FLAGS_SEVERITY_MASK (0x7<<5)
264 
265 #define GWEN_GUI_MSG_FLAGS_SEVERITY_NORMAL (0x0<<5)
266 #define GWEN_GUI_MSG_FLAGS_SEVERITY_IS_NORMAL(fl) \
267  ((fl & GWEN_GUI_MSG_FLAGS_SEVERITY_MASK)==\
268  GWEN_GUI_MSG_FLAGS_SEVERITY_NORMAL)
269 
271 #define GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS (0x1<<5)
272 #define GWEN_GUI_MSG_FLAGS_SEVERITY_IS_DANGEROUS(fl) \
273  ((fl & GWEN_GUI_MSG_FLAGS_SEVERITY_MASK)==\
274  GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS)
275 
287 #define GWEN_GUI_SHOWBOX_FLAGS_BEEP 0x00000001
288 
302 #define GWEN_GUI_PROGRESS_NONE (0xffffffffUL)
303 
310 #define GWEN_GUI_PROGRESS_ONE (0xfffffffeUL)
311 
320 typedef enum {
328 
329 
330 
336 GWEN_GUI *GWEN_Gui_new(void);
337 
339 void GWEN_Gui_free(GWEN_GUI *gui);
340 
342 void GWEN_Gui_Attach(GWEN_GUI *gui);
343 
345 void GWEN_Gui_SetGui(GWEN_GUI *gui);
346 
349 
363 const char *GWEN_Gui_GetCharSet(const GWEN_GUI *gui);
364 
366 void GWEN_Gui_SetCharSet(GWEN_GUI *gui, const char *s);
442 int GWEN_Gui_MessageBox(uint32_t flags,
443  const char *title,
444  const char *text,
445  const char *b1,
446  const char *b2,
447  const char *b3,
448  uint32_t guiid);
449 
456 void GWEN_Gui_ShowError(const char *title, const char *text, ...);
457 
458 
485 int GWEN_Gui_InputBox(uint32_t flags,
486  const char *title,
487  const char *text,
488  char *buffer,
489  int minLen,
490  int maxLen,
491  uint32_t guiid);
492 
517 uint32_t GWEN_Gui_ShowBox(uint32_t flags,
518  const char *title,
519  const char *text,
520  uint32_t guiid);
521 
532 void GWEN_Gui_HideBox(uint32_t id);
533 
534 
567 uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags,
568  const char *title,
569  const char *text,
570  uint64_t total,
571  uint32_t guiid);
572 
594 int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress);
595 
597 int GWEN_Gui_ProgressSetTotal(uint32_t id, uint64_t total);
598 
610 int GWEN_Gui_ProgressLog(uint32_t id,
611  GWEN_LOGGER_LEVEL level,
612  const char *text);
613 
627 int GWEN_Gui_ProgressLog2(uint32_t id,
628  GWEN_LOGGER_LEVEL level,
629  const char *text, ...);
630 
656 int GWEN_Gui_ProgressEnd(uint32_t id);
657 
658 
673 int GWEN_Gui_Print(const char *docTitle,
674  const char *docType,
675  const char *descr,
676  const char *text,
677  uint32_t guiid);
678 
699 int GWEN_Gui_GetPassword(uint32_t flags,
700  const char *token,
701  const char *title,
702  const char *text,
703  char *buffer,
704  int minLen,
705  int maxLen,
706  uint32_t guiid);
707 
713 int GWEN_Gui_SetPasswordStatus(const char *token,
714  const char *pin,
716  uint32_t guiid);
717 
729 int GWEN_Gui_LogHook(const char *logDomain,
730  GWEN_LOGGER_LEVEL priority, const char *s);
731 
732 
742 int GWEN_Gui_WaitForSockets(GWEN_SOCKET_LIST2 *readSockets,
743  GWEN_SOCKET_LIST2 *writeSockets,
744  uint32_t guiid,
745  int msecs);
746 
756 int GWEN_Gui_CheckCert(const GWEN_SSLCERTDESCR *cert,
757  GWEN_SYNCIO *sio,
758  uint32_t guiid);
759 
760 
772 int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text,
773  unsigned char *buffer,
774  unsigned int bufLength);
775 
784 int GWEN_Gui_ExecDialog(GWEN_DIALOG *dlg, uint32_t guiid);
785 
786 
787 
789 int GWEN_Gui_OpenDialog(GWEN_DIALOG *dlg, uint32_t guiid);
790 
793 
795 int GWEN_Gui_RunDialog(GWEN_DIALOG *dlg, int untilEnd);
796 
797 
798 typedef enum {
802 
804 
805 
824 int GWEN_Gui_GetFileName(const char *caption,
826  uint32_t flags,
827  const char *patterns,
828  GWEN_BUFFER *pathBuffer,
829  uint32_t guiid);
830 
841 int GWEN_Gui_GetSyncIo(const char *url,
842  const char *defaultProto,
843  int defaultPort,
844  GWEN_SYNCIO **pSio);
845 
846 
857 
859 #define GWEN_GUI_FLAGS_NONINTERACTIVE 0x00000001
860 
861 #define GWEN_GUI_FLAGS_ACCEPTVALIDCERTS 0x00000002
862 
863 #define GWEN_GUI_FLAGS_REJECTINVALIDCERTS 0x00000004
864 
865 #define GWEN_GUI_FLAGS_DIALOGSUPPORTED 0x80000000
866 
867 GWENHYWFAR_API uint32_t GWEN_Gui_GetFlags(const GWEN_GUI *gui);
868 GWENHYWFAR_API void GWEN_Gui_SetFlags(GWEN_GUI *gui, uint32_t fl);
869 GWENHYWFAR_API void GWEN_Gui_AddFlags(GWEN_GUI *gui, uint32_t fl);
870 GWENHYWFAR_API void GWEN_Gui_SubFlags(GWEN_GUI *gui, uint32_t fl);
874 GWENHYWFAR_API const char *GWEN_Gui_GetName(void);
875 
876 
877 #ifdef __cplusplus
878 }
879 #endif
880 
884 #endif
885 
886 
887 
888