1 /*************************************************************************** 2 copyright : (C) 2004 by Martin Preuss 3 email : martin@libchipcard.de 4 5 *************************************************************************** 6 * Please see toplevel file COPYING for license details * 7 ***************************************************************************/ 8 9 #ifndef CPPGUI_HPP 10 #define CPPGUI_HPP 11 12 13 #include <gwenhywfar/gui_be.h> 14 #include <gwenhywfar/i18n.h> 15 //#include <gwenhywfar/db.h> 16 //#include <gwenhywfar/passwdstore.h> 17 18 #define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) 19 #define I18S(msg) msg 20 21 #include <list> 22 #include <string> 23 24 class CppGui; 25 26 #include <gwen-gui-cpp/api.h> 27 #include <gwen-gui-cpp/cppdialog.hpp> 28 29 30 /** 31 * @brief A C++ binding for the C module @ref GWEN_GUI 32 * 33 * This class simply is a C++ binding for the C module @ref GWEN_GUI. 34 * It redirects C callbacks used by GWEN_GUI to virtual functions in 35 * this class. 36 * 37 * @author Martin Preuss<martin@aquamaniac.de> 38 */ 39 class CPPGUI_API CppGui { 40 friend class CppGuiLinker; 41 42 private: 43 GWEN_GUI_CHECKCERT_FN _checkCertFn; 44 GWEN_GUI_PRINT_FN _printFn; 45 GWEN_GUI_GETPASSWORD_FN _getPasswordFn; 46 GWEN_GUI_SETPASSWORDSTATUS_FN _setPasswordStatusFn; 47 GWEN_GUI_EXEC_DIALOG_FN _execDialogFn; 48 GWEN_GUI_OPEN_DIALOG_FN _openDialogFn; 49 GWEN_GUI_CLOSE_DIALOG_FN _closeDialogFn; 50 GWEN_GUI_RUN_DIALOG_FN _runDialogFn; 51 52 GWEN_GUI_GET_FILENAME_FN _getFileNameFn; 53 54 55 public: 56 CppGui(); 57 virtual ~CppGui(); 58 59 static CPPGUI_API CppGui *getCppGui(); 60 61 GWEN_GUI *getCInterface(); 62 63 void setPasswordDb(GWEN_DB_NODE *dbPasswords, int persistent); 64 void setPasswordStore(GWEN_PASSWD_STORE *sto); 65 66 protected: 67 GWEN_GUI *_gui; 68 69 /** @name User Interaction 70 * 71 */ 72 /*@{*/ 73 74 /** 75 * See @ref CppGui_Print 76 */ 77 virtual int print(const char *docTitle, 78 const char *docType, 79 const char *descr, 80 const char *text, 81 uint32_t guiid); 82 83 virtual int getPassword(uint32_t flags, 84 const char *token, 85 const char *title, 86 const char *text, 87 char *buffer, 88 int minLen, 89 int maxLen, 90 GWEN_GUI_PASSWORD_METHOD methodId, 91 GWEN_DB_NODE *methodParams, 92 uint32_t guiid); 93 94 virtual int setPasswordStatus(const char *token, 95 const char *pin, 96 GWEN_GUI_PASSWORD_STATUS status, 97 uint32_t guiid); 98 99 virtual int checkCert(const GWEN_SSLCERTDESCR *cert, 100 GWEN_SYNCIO *sio, 101 uint32_t guiid); 102 103 virtual int logHook(const char *logDomain, 104 GWEN_LOGGER_LEVEL priority, const char *s); 105 106 virtual int execDialog(GWEN_DIALOG *dlg, uint32_t guiid); 107 108 virtual int openDialog(GWEN_DIALOG *dlg, uint32_t guiid); 109 virtual int closeDialog(GWEN_DIALOG *dlg); 110 virtual int runDialog(GWEN_DIALOG *dlg, int untilEnd); 111 112 virtual int getFileName(const char *caption, 113 GWEN_GUI_FILENAME_TYPE fnt, 114 uint32_t flags, 115 const char *patterns, 116 GWEN_BUFFER *pathBuffer, 117 uint32_t guiid); 118 119 120 int checkCertBuiltIn(const GWEN_SSLCERTDESCR *cert, 121 GWEN_SYNCIO *sio, 122 uint32_t guiid); 123 124 125 }; 126 127 128 129 130 #endif /* CPPGUI_HPP */ 131 132 133