gwenhywfar  4.13.1
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);
370 
372 int GWEN_Gui_ConvertString(const char *text, size_t len, GWEN_BUFFER *tbuf,
373  const char *fromCs, const char *toCs);
374 
375 
451 int GWEN_Gui_MessageBox(uint32_t flags,
452  const char *title,
453  const char *text,
454  const char *b1,
455  const char *b2,
456  const char *b3,
457  uint32_t guiid);
458 
465 void GWEN_Gui_ShowError(const char *title, const char *text, ...);
466 
467 
496 int GWEN_Gui_InputBox(uint32_t flags,
497  const char *title,
498  const char *text,
499  char *buffer,
500  int minLen,
501  int maxLen,
502  uint32_t guiid);
503 
528 uint32_t GWEN_Gui_ShowBox(uint32_t flags,
529  const char *title,
530  const char *text,
531  uint32_t guiid);
532 
543 void GWEN_Gui_HideBox(uint32_t id);
544 
545 
578 uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags,
579  const char *title,
580  const char *text,
581  uint64_t total,
582  uint32_t guiid);
583 
605 int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress);
606 
608 int GWEN_Gui_ProgressSetTotal(uint32_t id, uint64_t total);
609 
621 int GWEN_Gui_ProgressLog(uint32_t id,
622  GWEN_LOGGER_LEVEL level,
623  const char *text);
624 
638 int GWEN_Gui_ProgressLog2(uint32_t id,
639  GWEN_LOGGER_LEVEL level,
640  const char *text, ...);
641 
667 int GWEN_Gui_ProgressEnd(uint32_t id);
668 
669 
684 int GWEN_Gui_Print(const char *docTitle,
685  const char *docType,
686  const char *descr,
687  const char *text,
688  uint32_t guiid);
689 
710 int GWEN_Gui_GetPassword(uint32_t flags,
711  const char *token,
712  const char *title,
713  const char *text,
714  char *buffer,
715  int minLen,
716  int maxLen,
717  uint32_t guiid);
718 
724 int GWEN_Gui_SetPasswordStatus(const char *token,
725  const char *pin,
727  uint32_t guiid);
728 
740 int GWEN_Gui_LogHook(const char *logDomain,
741  GWEN_LOGGER_LEVEL priority, const char *s);
742 
743 
754  GWEN_SOCKET_LIST2 *writeSockets,
755  uint32_t guiid,
756  int msecs);
757 
767 int GWEN_Gui_CheckCert(const GWEN_SSLCERTDESCR *cert,
768  GWEN_SYNCIO *sio,
769  uint32_t guiid);
770 
771 
783 int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text,
784  unsigned char *buffer,
785  unsigned int bufLength);
786 
795 int GWEN_Gui_ExecDialog(GWEN_DIALOG *dlg, uint32_t guiid);
796 
797 
798 
800 int GWEN_Gui_OpenDialog(GWEN_DIALOG *dlg, uint32_t guiid);
801 
804 
806 int GWEN_Gui_RunDialog(GWEN_DIALOG *dlg, int untilEnd);
807 
808 
809 typedef enum {
813 
815 
816 
835 int GWEN_Gui_GetFileName(const char *caption,
837  uint32_t flags,
838  const char *patterns,
839  GWEN_BUFFER *pathBuffer,
840  uint32_t guiid);
841 
852 int GWEN_Gui_GetSyncIo(const char *url,
853  const char *defaultProto,
854  int defaultPort,
855  GWEN_SYNCIO **pSio);
856 
857 
868 
870 #define GWEN_GUI_FLAGS_NONINTERACTIVE 0x00000001
871 
872 #define GWEN_GUI_FLAGS_ACCEPTVALIDCERTS 0x00000002
873 
874 #define GWEN_GUI_FLAGS_REJECTINVALIDCERTS 0x00000004
875 
876 #define GWEN_GUI_FLAGS_PERMPASSWORDS 0x00000008
877 
879 #define GWEN_GUI_FLAGS_DIALOGSUPPORTED 0x80000000
880 
881 GWENHYWFAR_API uint32_t GWEN_Gui_GetFlags(const GWEN_GUI *gui);
882 GWENHYWFAR_API void GWEN_Gui_SetFlags(GWEN_GUI *gui, uint32_t fl);
883 GWENHYWFAR_API void GWEN_Gui_AddFlags(GWEN_GUI *gui, uint32_t fl);
884 GWENHYWFAR_API void GWEN_Gui_SubFlags(GWEN_GUI *gui, uint32_t fl);
888 GWENHYWFAR_API const char *GWEN_Gui_GetName(void);
889 
890 
910  GWEN_DB_NODE *dbPasswords,
911  int persistent);
912 
924 
925 
929 
930 
931 #ifdef __cplusplus
932 }
933 #endif
934 
938 #endif
939 
940 
941 
942 
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:3058
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:809
GWEN_GUI_PASSWORD_STATUS
Definition: gui.h:323
struct GWEN_SYNCIO GWEN_SYNCIO
Definition: syncio.h:40
#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 int GWEN_Gui_ConvertString(const char *text, size_t len, GWEN_BUFFER *tbuf, const char *fromCs, const char *toCs)
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)