gwenhywfar  4.12.0beta
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>
34 #include <gwenhywfar/syncio.h>
35 #include <gwenhywfar/dialog.h>
36 #include <gwenhywfar/passwdstore.h>
37 
38 #include <inttypes.h>
39 
40 
107 
108 #ifdef __cplusplus
109 extern "C" {
110 #endif
111 
112 
113 typedef struct GWEN_GUI GWEN_GUI;
115 
116 
117 #define GWEN_GUI_CPU_TIMEOUT 200
118 
119 #define GWEN_GUI_CHECK_PERIOD 750
120 #define GWEN_GUI_DELAY_SECS 2
121 
122 
129 #define GWEN_GUI_PROGRESS_DELAY 0x00000001
130 #define GWEN_GUI_PROGRESS_SHOW_LOG 0x00000002
131 #define GWEN_GUI_PROGRESS_SHOW_ABORT 0x00000004
132 #define GWEN_GUI_PROGRESS_ALLOW_SUBLEVELS 0x00000008
133 #define GWEN_GUI_PROGRESS_ALLOW_EMBED 0x00000010
134 #define GWEN_GUI_PROGRESS_SHOW_PROGRESS 0x00000020
135 #define GWEN_GUI_PROGRESS_KEEP_OPEN 0x00000040
136 #define GWEN_GUI_PROGRESS_ALWAYS_SHOW_LOG 0x00000080
137 
148 #define GWEN_GUI_INPUT_FLAGS_CONFIRM 0x00000001
149 
150 #define GWEN_GUI_INPUT_FLAGS_SHOW 0x00000002
151 
152 #define GWEN_GUI_INPUT_FLAGS_NUMERIC 0x00000004
153 
154 #define GWEN_GUI_INPUT_FLAGS_RETRY 0x00000008
155 
157 #define GWEN_GUI_INPUT_FLAGS_ALLOW_DEFAULT 0x00000010
158 
159 #define GWEN_GUI_INPUT_FLAGS_TAN 0x00000020
160 
161 #define GWEN_GUI_INPUT_FLAGS_OPTICAL 0x00000040
162 
163 #define GWEN_GUI_INPUT_FLAGS_DIRECT 0x00000080
164 
216 #define GWEN_GUI_MSG_FLAGS_TYPE_MASK 0x07
217 
218 #define GWEN_GUI_MSG_FLAGS_TYPE_INFO 0
219 
220 #define GWEN_GUI_MSG_FLAGS_TYPE_IS_INFO(fl) \
221  ((fl & GWEN_GUI_MSG_FLAGS_TYPE_MASK)==GWEN_GUI_MSG_FLAGS_TYPE_INFO)
222 
224 #define GWEN_GUI_MSG_FLAGS_TYPE_WARN 1
225 
226 #define GWEN_GUI_MSG_FLAGS_TYPE_IS_WARN(fl) \
227  ((fl & GWEN_GUI_MSG_FLAGS_TYPE_MASK)==GWEN_GUI_MSG_FLAGS_TYPE_WARN)
228 
230 #define GWEN_GUI_MSG_FLAGS_TYPE_ERROR 2
231 
232 #define GWEN_GUI_MSG_FLAGS_TYPE_IS_ERROR \
233  ((fl & GWEN_GUI_MSG_FLAGS_TYPE_MASK)==GWEN_GUI_MSG_FLAGS_TYPE_ERROR)
234 
236 #define GWEN_GUI_MSG_FLAGS_CONFIRM_B1 (1<<3)
237 
238 #define GWEN_GUI_MSG_FLAGS_CONFIRM_B2 (2<<3)
239 
240 #define GWEN_GUI_MSG_FLAGS_CONFIRM_B3 (3<<3)
241 
242 #define GWEN_GUI_MSG_FLAGS_CONFIRM_BUTTON(fl) (((fl)>>3) & 0x3)
243 
244 
266 #define GWEN_GUI_MSG_FLAGS_SEVERITY_MASK (0x7<<5)
267 
268 #define GWEN_GUI_MSG_FLAGS_SEVERITY_NORMAL (0x0<<5)
269 #define GWEN_GUI_MSG_FLAGS_SEVERITY_IS_NORMAL(fl) \
270  ((fl & GWEN_GUI_MSG_FLAGS_SEVERITY_MASK)==\
271  GWEN_GUI_MSG_FLAGS_SEVERITY_NORMAL)
272 
274 #define GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS (0x1<<5)
275 #define GWEN_GUI_MSG_FLAGS_SEVERITY_IS_DANGEROUS(fl) \
276  ((fl & GWEN_GUI_MSG_FLAGS_SEVERITY_MASK)==\
277  GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS)
278 
290 #define GWEN_GUI_SHOWBOX_FLAGS_BEEP 0x00000001
291 
305 #define GWEN_GUI_PROGRESS_NONE (0xffffffffUL)
306 
313 #define GWEN_GUI_PROGRESS_ONE (0xfffffffeUL)
314 
323 typedef enum {
331 
332 
333 
339 GWEN_GUI *GWEN_Gui_new(void);
340 
342 void GWEN_Gui_free(GWEN_GUI *gui);
343 
345 void GWEN_Gui_Attach(GWEN_GUI *gui);
346 
348 void GWEN_Gui_SetGui(GWEN_GUI *gui);
349 
352 
366 const char *GWEN_Gui_GetCharSet(const GWEN_GUI *gui);
367 
369 void GWEN_Gui_SetCharSet(GWEN_GUI *gui, const char *s);
445 int GWEN_Gui_MessageBox(uint32_t flags,
446  const char *title,
447  const char *text,
448  const char *b1,
449  const char *b2,
450  const char *b3,
451  uint32_t guiid);
452 
459 void GWEN_Gui_ShowError(const char *title, const char *text, ...);
460 
461 
490 int GWEN_Gui_InputBox(uint32_t flags,
491  const char *title,
492  const char *text,
493  char *buffer,
494  int minLen,
495  int maxLen,
496  uint32_t guiid);
497 
522 uint32_t GWEN_Gui_ShowBox(uint32_t flags,
523  const char *title,
524  const char *text,
525  uint32_t guiid);
526 
537 void GWEN_Gui_HideBox(uint32_t id);
538 
539 
572 uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags,
573  const char *title,
574  const char *text,
575  uint64_t total,
576  uint32_t guiid);
577 
599 int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress);
600 
602 int GWEN_Gui_ProgressSetTotal(uint32_t id, uint64_t total);
603 
615 int GWEN_Gui_ProgressLog(uint32_t id,
616  GWEN_LOGGER_LEVEL level,
617  const char *text);
618 
632 int GWEN_Gui_ProgressLog2(uint32_t id,
633  GWEN_LOGGER_LEVEL level,
634  const char *text, ...);
635 
661 int GWEN_Gui_ProgressEnd(uint32_t id);
662 
663 
678 int GWEN_Gui_Print(const char *docTitle,
679  const char *docType,
680  const char *descr,
681  const char *text,
682  uint32_t guiid);
683 
704 int GWEN_Gui_GetPassword(uint32_t flags,
705  const char *token,
706  const char *title,
707  const char *text,
708  char *buffer,
709  int minLen,
710  int maxLen,
711  uint32_t guiid);
712 
718 int GWEN_Gui_SetPasswordStatus(const char *token,
719  const char *pin,
721  uint32_t guiid);
722 
734 int GWEN_Gui_LogHook(const char *logDomain,
735  GWEN_LOGGER_LEVEL priority, const char *s);
736 
737 
748  GWEN_SOCKET_LIST2 *writeSockets,
749  uint32_t guiid,
750  int msecs);
751 
761 int GWEN_Gui_CheckCert(const GWEN_SSLCERTDESCR *cert,
762  GWEN_SYNCIO *sio,
763  uint32_t guiid);
764 
765 
777 int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text,
778  unsigned char *buffer,
779  unsigned int bufLength);
780 
789 int GWEN_Gui_ExecDialog(GWEN_DIALOG *dlg, uint32_t guiid);
790 
791 
792 
794 int GWEN_Gui_OpenDialog(GWEN_DIALOG *dlg, uint32_t guiid);
795 
798 
800 int GWEN_Gui_RunDialog(GWEN_DIALOG *dlg, int untilEnd);
801 
802 
803 typedef enum {
807 
809 
810 
829 int GWEN_Gui_GetFileName(const char *caption,
831  uint32_t flags,
832  const char *patterns,
833  GWEN_BUFFER *pathBuffer,
834  uint32_t guiid);
835 
846 int GWEN_Gui_GetSyncIo(const char *url,
847  const char *defaultProto,
848  int defaultPort,
849  GWEN_SYNCIO **pSio);
850 
851 
862 
864 #define GWEN_GUI_FLAGS_NONINTERACTIVE 0x00000001
865 
866 #define GWEN_GUI_FLAGS_ACCEPTVALIDCERTS 0x00000002
867 
868 #define GWEN_GUI_FLAGS_REJECTINVALIDCERTS 0x00000004
869 
870 #define GWEN_GUI_FLAGS_PERMPASSWORDS 0x00000008
871 
873 #define GWEN_GUI_FLAGS_DIALOGSUPPORTED 0x80000000
874 
875 GWENHYWFAR_API uint32_t GWEN_Gui_GetFlags(const GWEN_GUI *gui);
876 GWENHYWFAR_API void GWEN_Gui_SetFlags(GWEN_GUI *gui, uint32_t fl);
877 GWENHYWFAR_API void GWEN_Gui_AddFlags(GWEN_GUI *gui, uint32_t fl);
878 GWENHYWFAR_API void GWEN_Gui_SubFlags(GWEN_GUI *gui, uint32_t fl);
882 GWENHYWFAR_API const char *GWEN_Gui_GetName(void);
883 
884 
904  GWEN_DB_NODE *dbPasswords,
905  int persistent);
906 
918 
919 
923 
924 
925 #ifdef __cplusplus
926 }
927 #endif
928 
932 #endif
933 
934 
935 
936 
GWENHYWFAR_API int GWEN_Gui_GetPassword(uint32_t flags, const char *token, const char *title, const char *text, char *buffer, int minLen, int maxLen, uint32_t guiid)
GWENHYWFAR_API int GWEN_Gui_ProgressLog(uint32_t id, GWEN_LOGGER_LEVEL level, const char *text)
GWENHYWFAR_API void GWEN_Gui_SubFlags(GWEN_GUI *gui, uint32_t fl)
struct GWEN_SSLCERTDESCR GWEN_SSLCERTDESCR
GWENHYWFAR_API int GWEN_Gui_OpenDialog(GWEN_DIALOG *dlg, uint32_t guiid)
GWENHYWFAR_API void GWEN_Gui_SetFlags(GWEN_GUI *gui, uint32_t fl)
GWENHYWFAR_API int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress)
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
GWENHYWFAR_API int GWEN_Gui_WaitForSockets(GWEN_SOCKET_LIST2 *readSockets, GWEN_SOCKET_LIST2 *writeSockets, uint32_t guiid, int msecs)
struct GWEN_SOCKET_LIST2 GWEN_SOCKET_LIST2
Definition: listdoc.h:3787
GWENHYWFAR_API int GWEN_Gui_LogHook(const char *logDomain, GWEN_LOGGER_LEVEL priority, const char *s)
GWENHYWFAR_API int GWEN_Gui_ProgressSetTotal(uint32_t id, uint64_t total)
GWEN_LOGGER_LEVEL
Definition: logger.h:64
GWENHYWFAR_API void GWEN_Gui_SetCharSet(GWEN_GUI *gui, const char *s)
GWENHYWFAR_API void GWEN_Gui_SetMinProgressLogLevel(GWEN_GUI *gui, GWEN_LOGGER_LEVEL ll)
GWENHYWFAR_API void GWEN_Gui_AddFlags(GWEN_GUI *gui, uint32_t fl)
This file contains sockets and socket sets.
GWENHYWFAR_API int GWEN_Gui_MessageBox(uint32_t flags, const char *title, const char *text, const char *b1, const char *b2, const char *b3, uint32_t guiid)
GWENHYWFAR_API int GWEN_Gui_ExecDialog(GWEN_DIALOG *dlg, uint32_t guiid)
GWENHYWFAR_API int GWEN_Gui_Print(const char *docTitle, const char *docType, const char *descr, const char *text, uint32_t guiid)
GWENHYWFAR_API GWEN_LOGGER_LEVEL GWEN_Gui_GetMinProgressLogLevel(const GWEN_GUI *gui)
struct GWEN_DIALOG GWEN_DIALOG
Definition: dialog.h:54
GWENHYWFAR_API int GWEN_Gui_GetSyncIo(const char *url, const char *defaultProto, int defaultPort, GWEN_SYNCIO **pSio)
GWENHYWFAR_API const char * GWEN_Gui_GetName(void)
GWEN_GUI_FILENAME_TYPE
Definition: gui.h:803
GWEN_GUI_PASSWORD_STATUS
Definition: gui.h:323
struct GWEN_SYNCIO GWEN_SYNCIO
Definition: syncio.h:41
#define GWEN_INHERIT_FUNCTION_LIB_DEFS(t, decl)
Definition: inherit.h:125
GWENHYWFAR_API int GWEN_Gui_InputBox(uint32_t flags, const char *title, const char *text, char *buffer, int minLen, int maxLen, uint32_t guiid)
GWENHYWFAR_API uint32_t GWEN_Gui_ShowBox(uint32_t flags, const char *title, const char *text, uint32_t guiid)
GWENHYWFAR_API int GWEN_Gui_ProgressLog2(uint32_t id, GWEN_LOGGER_LEVEL level, const char *text,...)
GWENHYWFAR_API void GWEN_Gui_HideBox(uint32_t id)
GWENHYWFAR_API GWEN_GUI * GWEN_Gui_GetGui(void)
GWENHYWFAR_API GWEN_PASSWD_STORE * GWEN_Gui_GetPasswdStore(const GWEN_GUI *gui)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:41
#define GWENHYWFAR_API
Definition: gwenhywfarapi.h:67
GWENHYWFAR_API uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags, const char *title, const char *text, uint64_t total, uint32_t guiid)
GWENHYWFAR_API int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text, unsigned char *buffer, unsigned int bufLength)
GWENHYWFAR_API int GWEN_Gui_ProgressEnd(uint32_t id)
GWENHYWFAR_API int GWEN_Gui_CloseDialog(GWEN_DIALOG *dlg)
struct GWEN_PASSWD_STORE GWEN_PASSWD_STORE
Definition: passwdstore.h:36
GWENHYWFAR_API void GWEN_Gui_SetPasswordDb(GWEN_GUI *gui, GWEN_DB_NODE *dbPasswords, int persistent)
GWENHYWFAR_API GWEN_GUI * GWEN_Gui_new(void)
GWENHYWFAR_API void GWEN_Gui_SetPasswdStore(GWEN_GUI *gui, GWEN_PASSWD_STORE *sto)
GWENHYWFAR_API GWEN_DB_NODE * GWEN_Gui_GetPasswordDb(const GWEN_GUI *gui)
GWENHYWFAR_API void GWEN_Gui_Attach(GWEN_GUI *gui)
struct GWEN_GUI GWEN_GUI
Definition: gui.h:113
GWENHYWFAR_API int GWEN_Gui_SetPasswordStatus(const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS status, uint32_t guiid)
GWENHYWFAR_API void GWEN_Gui_free(GWEN_GUI *gui)
GWENHYWFAR_API void GWEN_Gui_SetGui(GWEN_GUI *gui)
GWENHYWFAR_API int GWEN_Gui_GetFileName(const char *caption, GWEN_GUI_FILENAME_TYPE fnt, uint32_t flags, const char *patterns, GWEN_BUFFER *pathBuffer, uint32_t guiid)
GWENHYWFAR_API void GWEN_Gui_ShowError(const char *title, const char *text,...)
GWENHYWFAR_API int GWEN_Gui_CheckCert(const GWEN_SSLCERTDESCR *cert, GWEN_SYNCIO *sio, uint32_t guiid)
GWENHYWFAR_API int GWEN_Gui_RunDialog(GWEN_DIALOG *dlg, int untilEnd)
GWENHYWFAR_API uint32_t GWEN_Gui_GetFlags(const GWEN_GUI *gui)
GWENHYWFAR_API const char * GWEN_Gui_GetCharSet(const GWEN_GUI *gui)