gui.c File Reference

#include "gui_p.h"
#include "i18n_l.h"
#include <gwenhywfar/debug.h>

Go to the source code of this file.

Functions

void GWEN_Gui_Attach (GWEN_GUI *gui)
int GWEN_Gui_CheckCert (const GWEN_SSLCERTDESCR *cd, GWEN_IO_LAYER *io, uint32_t guiid)
int GWEN_Gui_CheckCertBuiltIn (GWEN_GUI *gui, const GWEN_SSLCERTDESCR *cd, GWEN_IO_LAYER *io, uint32_t guiid)
void GWEN_Gui_free (GWEN_GUI *gui)
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)
void GWEN_Gui_HideBox (uint32_t id)
int GWEN_Gui_InputBox (uint32_t flags, const char *title, const char *text, char *buffer, int minLen, int maxLen, uint32_t guiid)
int GWEN_Gui_KeyDataFromText_OpenSSL (const char *text, unsigned char *buffer, unsigned int bufLength)
int GWEN_Gui_LogHook (const char *logDomain, GWEN_LOGGER_LEVEL priority, const char *s)
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)
GWEN_GUIGWEN_Gui_new ()
int GWEN_Gui_Print (const char *docTitle, const char *docType, const char *descr, const char *text, uint32_t guiid)
int GWEN_Gui_ProgressAdvance (uint32_t id, uint32_t progress)
int GWEN_Gui_ProgressEnd (uint32_t id)
int GWEN_Gui_ProgressLog (uint32_t id, GWEN_LOGGER_LEVEL level, const char *text)
uint32_t GWEN_Gui_ProgressStart (uint32_t progressFlags, const char *title, const char *text, uint64_t total, uint32_t guiid)
GWEN_GUI_CHECKCERT_FN GWEN_Gui_SetCheckCertFn (GWEN_GUI *gui, GWEN_GUI_CHECKCERT_FN f)
GWEN_GUI_GETPASSWORD_FN GWEN_Gui_SetGetPasswordFn (GWEN_GUI *gui, GWEN_GUI_GETPASSWORD_FN f)
void GWEN_Gui_SetGui (GWEN_GUI *gui)
GWEN_GUI_HIDEBOX_FN GWEN_Gui_SetHideBoxFn (GWEN_GUI *gui, GWEN_GUI_HIDEBOX_FN f)
GWEN_GUI_INPUTBOX_FN GWEN_Gui_SetInputBoxFn (GWEN_GUI *gui, GWEN_GUI_INPUTBOX_FN f)
GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN GWEN_Gui_SetKeyDataFromTextOpenSslFn (GWEN_GUI *gui, GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN f)
GWEN_GUI_LOG_HOOK_FN GWEN_Gui_SetLogHookFn (GWEN_GUI *gui, GWEN_GUI_LOG_HOOK_FN f)
GWEN_GUI_MESSAGEBOX_FN GWEN_Gui_SetMessageBoxFn (GWEN_GUI *gui, GWEN_GUI_MESSAGEBOX_FN f)
int GWEN_Gui_SetPasswordStatus (const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS status, uint32_t guiid)
GWEN_GUI_PRINT_FN GWEN_Gui_SetPrintFn (GWEN_GUI *gui, GWEN_GUI_PRINT_FN f)
GWEN_GUI_PROGRESS_ADVANCE_FN GWEN_Gui_SetProgressAdvanceFn (GWEN_GUI *gui, GWEN_GUI_PROGRESS_ADVANCE_FN f)
GWEN_GUI_PROGRESS_END_FN GWEN_Gui_SetProgressEndFn (GWEN_GUI *gui, GWEN_GUI_PROGRESS_END_FN f)
GWEN_GUI_PROGRESS_LOG_FN GWEN_Gui_SetProgressLogFn (GWEN_GUI *gui, GWEN_GUI_PROGRESS_LOG_FN f)
GWEN_GUI_PROGRESS_START_FN GWEN_Gui_SetProgressStartFn (GWEN_GUI *gui, GWEN_GUI_PROGRESS_START_FN f)
GWEN_GUI_SETPASSWORDSTATUS_FN GWEN_Gui_SetSetPasswordStatusFn (GWEN_GUI *gui, GWEN_GUI_SETPASSWORDSTATUS_FN f)
GWEN_GUI_SHOWBOX_FN GWEN_Gui_SetShowBoxFn (GWEN_GUI *gui, GWEN_GUI_SHOWBOX_FN f)
GWEN_GUI_WAITFORSOCKETS_FN GWEN_Gui_SetWaitForSocketsFn (GWEN_GUI *gui, GWEN_GUI_WAITFORSOCKETS_FN f)
uint32_t GWEN_Gui_ShowBox (uint32_t flags, const char *title, const char *text, uint32_t guiid)
int GWEN_Gui_WaitForSockets (GWEN_SOCKET_LIST2 *readSockets, GWEN_SOCKET_LIST2 *writeSockets, uint32_t guiid, int msecs)

Variables

static GWEN_GUIgwenhywfar_gui = NULL


Function Documentation

void GWEN_Gui_Attach ( GWEN_GUI gui  ) 

Definition at line 74 of file gui.c.

Referenced by GWEN_Gui_SetGui().

int GWEN_Gui_CheckCert ( const GWEN_SSLCERTDESCR cd,
GWEN_IO_LAYER io,
uint32_t  guiid 
)

Definition at line 532 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

Referenced by GWEN_Io_LayerTls_WorkOnRequests().

int GWEN_Gui_CheckCertBuiltIn ( GWEN_GUI gui,
const GWEN_SSLCERTDESCR cd,
GWEN_IO_LAYER io,
uint32_t  guiid 
)

void GWEN_Gui_free ( GWEN_GUI gui  ) 

Definition at line 62 of file gui.c.

References GWEN_FREE_OBJECT, and GWEN_INHERIT_FINI.

Referenced by GWEN_Gui_SetGui(), and test_gui().

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 
)

Definition at line 404 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

Referenced by GWEN_Crypt_Token_GetPin().

void GWEN_Gui_HideBox ( uint32_t  id  ) 

Hides a message box previously shown by a call to GWEN_Gui_ShowBox.

This function MUST return immediately (non-blocking).

Parameters:
ab banking interface
id id returned by GWEN_Gui_ShowBox. If 0 then the last message shown is referred to.

Definition at line 334 of file gui.c.

References gwenhywfar_gui.

Referenced by GWEN_Crypt_Token_EndEnterPin(), and test_gui().

int GWEN_Gui_InputBox ( uint32_t  flags,
const char *  title,
const char *  text,
char *  buffer,
int  minLen,
int  maxLen,
uint32_t  guiid 
)

Ask the user for input.

This function is blocking.

Parameters:
ab banking interface
flags flags, see GWEN_GUI_INPUT_FLAGS_CONFIRM ff.
title title of the input box
text Text of the box: UTF-8, with both a normal text and a HTML variant of the text in the same string. See text restrictions note above.
buffer buffer to store the response in. Must have at least room for maxLen bytes
minLen minimal length of input (if 0 then there is no low limit)
maxLen size of the buffer including the trailing NULL character. This means that if you want to ask the user for a PIN of at most 4 characters you need to supply a buffer of at least 5 bytes and provide a 5 as maxLen.
Returns:
Zero on success, nonzero when the user requested abort or there was any error. The special value AB_ERROR_DEFAULT_VALUE should be returned if the flag GWEN_GUI_INPUT_FLAGS_ALLOW_DEFAULT was given and the user has chosen to use the default value (e.g. pressed the "default" button in a GUI).

Definition at line 300 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

Referenced by GWEN_Gui_CGui_GetPassword(), and test_gui().

int GWEN_Gui_KeyDataFromText_OpenSSL ( const char *  text,
unsigned char *  buffer,
unsigned int  bufLength 
)

This function is not officially part of the API but is needed for some ancient OpenHBCI keyfiles. License issues forbid us to link against OpenSSL so we leave it up to the application to implement this function. A converter tool might use this function once to convert an anciant OpenHBCI key file.

Definition at line 718 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

int GWEN_Gui_LogHook ( const char *  logDomain,
GWEN_LOGGER_LEVEL  priority,
const char *  s 
)

This function is called internally by GWEN_Logger_Log.

Definition at line 450 of file gui.c.

References gwenhywfar_gui.

Referenced by GWEN_Logger_Log().

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 
)

Show a message box with optional buttons. The message box may either contain 1, 2 or three buttons. If only one button is wanted then b1 should hold a pointer to the button text (b2 and b3 must be NULL) In two-button mode b1 and b2 must be valid (b3 must be NULL) In three-button-mode b1, b2 and b3 must be valid pointers. The return value tells which button the user pressed:

  • 1: button 1
  • 2: button 2
  • 3: button 3
If the frontend can not determine which button has been pressed (e.g. if no button was pressed but the user rather aborted the dialog by simply closing the box) it should return 0.

This function is blocking.

Returns:
the number of the button pressed (1=b1, 2=b2, 3=b3), any other value should be considered an error, including 0)
Parameters:
flags flags, see GWEN_GUI_MSG_FLAGS_TYPE_MASK ff.
title title of the message box
text Text of the box: UTF-8, with both a normal text and a HTML variant of the text in the same string. See text restrictions note above.
b1 text for the first button (required), should be something like "Ok" (see text restrictions note above)
b2 text for the optional second button
b3 text for the optional third button

Definition at line 282 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

Referenced by GWEN_Crypt_Token_InsertCorrectToken(), GWEN_Crypt_Token_InsertToken(), GWEN_Gui_CGui__input(), GWEN_Gui_CGui_GetPassword(), GWEN_Gui_CheckCertBuiltIn(), and test_gui().

GWEN_GUI* GWEN_Gui_new (  ) 

Definition at line 48 of file gui.c.

References GWEN_Gui_CheckCertBuiltIn(), GWEN_INHERIT_INIT, and GWEN_NEW_OBJECT.

Referenced by GWEN_Gui_CGui_new().

int GWEN_Gui_Print ( const char *  docTitle,
const char *  docType,
const char *  descr,
const char *  text,
uint32_t  guiid 
)

This function makes the application print something.

Parameters:
docTitle title of the document. This might be presented to the user
docType an unique identifier of the document to be printed. This can be used by the application to separate printer settings for different document types. The name itself has no meaning and can be choosen freely by the caller. However, backends should append their name and a colon to keep this argument unique. This argument should not be translated.
descr an optional description about what the document contains. This might be shown to the user (see text restriction notes above).
text text to be printed (see text restriction notes above).

Definition at line 387 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

int GWEN_Gui_ProgressAdvance ( uint32_t  id,
uint32_t  progress 
)

Advances the progress bar an application might present to the user and checks whether the user wants to abort the operation currently in progress.

On graphical user interfaces this function should also check for user interaction and/or update the GUI (e.g. by calling qApp->processEvents() when using QT/KDE).

This function MUST return immediately (non-blocking).

Returns:
0 if ok, !=0 if the current operation is to be aborted
Parameters:
id id assigned by GWEN_Gui_ProgressStart (if 0 then the last started progress dialog is referred to)
progress new value for progress. A special value is GWEN_GUI_PROGRESS_NONE which means that the progress is unchanged. This might be used as a keepalive call to a GUI.

Definition at line 358 of file gui.c.

References gwenhywfar_gui.

Referenced by GWEN_BufferedIO_ReadRawForced(), GWEN_BufferedIO_WriteRawForced(), and GWEN_Crypt_Token_PluginManager_CheckToken().

int GWEN_Gui_ProgressEnd ( uint32_t  id  ) 

Flags the end of the current operation. In graphical user interfaces this call should allow the user to close the progress dialog window.

On graphical user interfaces a call to this function should disable the abort button. It would be best not to close the dialog on receiption of this call but to simply enable a dialog closing (otherwise the user will not be able to see the log messages).

This function MUST return immediately (non-blocking).

Parameters:
id id assigned by GWEN_Gui_ProgressStart (if 0 then the last started progress dialog is referred to)

Definition at line 379 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

Referenced by GWEN_BufferedIO_ReadRawForced(), GWEN_BufferedIO_WriteRawForced(), GWEN_Crypt_Token_PluginManager_CheckToken(), and GWEN_Io_Manager_WaitForRequest().

int GWEN_Gui_ProgressLog ( uint32_t  id,
GWEN_LOGGER_LEVEL  level,
const char *  text 
)

Adds a log message to the referred process dialog.

This function MUST return immediately (non-blocking).

Parameters:
id id assigned by GWEN_Gui_ProgressStart (if 0 then the last started progress dialog is referred to)
level log level (see GWEN_Gui_LogLevelPanic ff.)
text Text of the box: UTF-8, with both a normal text and a HTML variant of the text in the same string. See text restrictions note above.

Definition at line 368 of file gui.c.

References gwenhywfar_gui.

Referenced by GWEN_BufferedIO_ReadRawForced(), GWEN_Crypt_Token_InsertCorrectToken(), GWEN_Crypt_Token_InsertToken(), GWEN_Crypt_Token_PluginManager_CheckToken(), GWEN_Crypt_TokenFile__CloseFile(), GWEN_Crypt_TokenFile__GenerateKey(), GWEN_Crypt_TokenFile__SetKeyInfo(), GWEN_HttpSession__RecvPacket(), GWEN_HttpSession__SetAddress(), GWEN_HttpSession_Init(), GWEN_HttpSession_RecvPacket(), GWEN_HttpSession_SendPacket(), GWEN_Io_LayerTls_GetPeerCert(), and GWEN_Io_Manager_WaitForRequest().

uint32_t GWEN_Gui_ProgressStart ( uint32_t  progressFlags,
const char *  title,
const char *  text,
uint64_t  total,
uint32_t  guiid 
)

This function is called when a long term operation is started. Theoretically nesting is allowed, however, you should refrain from opening multiple progress dialogs to avoid confusion of the user.

This function must return immediately (i.e. it MUST NOT wait for user interaction).

On graphical user interfaces such a dialog should contain a widget for the text presented here, a progress bar, a text widget to collect the log messages received via GWEN_Gui_ProgressLog and a button to allow the user to abort the current operation monitored by this dialog window.

Between a call to this function and one to GWEN_Gui_ProgressEnd the user should not be allowed to close the dialog window.

This function MUST return immediately (non-blocking).

Returns:
id to be used with the other GWEN_Gui_Progress functions.
Parameters:
title title of the dialog
text Text of the box: UTF-8, with both a normal text and a HTML variant of the text in the same string. See text restrictions note above.
total total number of steps of the operation started (i.e. value which represents 100%)

Definition at line 341 of file gui.c.

References gwenhywfar_gui.

Referenced by GWEN_BufferedIO_ReadRawForced(), GWEN_BufferedIO_WriteRawForced(), GWEN_Crypt_Token_PluginManager_CheckToken(), and GWEN_Io_Manager_WaitForRequest().

GWEN_GUI_CHECKCERT_FN GWEN_Gui_SetCheckCertFn ( GWEN_GUI gui,
GWEN_GUI_CHECKCERT_FN  f 
)

Definition at line 251 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_GETPASSWORD_FN GWEN_Gui_SetGetPasswordFn ( GWEN_GUI gui,
GWEN_GUI_GETPASSWORD_FN  f 
)

Definition at line 200 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

void GWEN_Gui_SetGui ( GWEN_GUI gui  ) 

Definition at line 82 of file gui.c.

References GWEN_Gui_Attach(), GWEN_Gui_free(), and gwenhywfar_gui.

Referenced by test_gui().

GWEN_GUI_HIDEBOX_FN GWEN_Gui_SetHideBoxFn ( GWEN_GUI gui,
GWEN_GUI_HIDEBOX_FN  f 
)

Definition at line 128 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_INPUTBOX_FN GWEN_Gui_SetInputBoxFn ( GWEN_GUI gui,
GWEN_GUI_INPUTBOX_FN  f 
)

Definition at line 104 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN GWEN_Gui_SetKeyDataFromTextOpenSslFn ( GWEN_GUI gui,
GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN  f 
)

Definition at line 264 of file gui.c.

GWEN_GUI_LOG_HOOK_FN GWEN_Gui_SetLogHookFn ( GWEN_GUI gui,
GWEN_GUI_LOG_HOOK_FN  f 
)

Definition at line 225 of file gui.c.

GWEN_GUI_MESSAGEBOX_FN GWEN_Gui_SetMessageBoxFn ( GWEN_GUI gui,
GWEN_GUI_MESSAGEBOX_FN  f 
)

Definition at line 92 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

int GWEN_Gui_SetPasswordStatus ( const char *  token,
const char *  pin,
GWEN_GUI_PASSWORD_STATUS  status,
uint32_t  guiid 
)

This functions sets the status of a password.

Definition at line 438 of file gui.c.

References GWEN_ERROR_NOT_IMPLEMENTED, and gwenhywfar_gui.

Referenced by GWEN_Crypt_Token_SetPinStatus().

GWEN_GUI_PRINT_FN GWEN_Gui_SetPrintFn ( GWEN_GUI gui,
GWEN_GUI_PRINT_FN  f 
)

Definition at line 188 of file gui.c.

GWEN_GUI_PROGRESS_ADVANCE_FN GWEN_Gui_SetProgressAdvanceFn ( GWEN_GUI gui,
GWEN_GUI_PROGRESS_ADVANCE_FN  f 
)

Definition at line 153 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_PROGRESS_END_FN GWEN_Gui_SetProgressEndFn ( GWEN_GUI gui,
GWEN_GUI_PROGRESS_END_FN  f 
)

Definition at line 177 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_PROGRESS_LOG_FN GWEN_Gui_SetProgressLogFn ( GWEN_GUI gui,
GWEN_GUI_PROGRESS_LOG_FN  f 
)

Definition at line 165 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_PROGRESS_START_FN GWEN_Gui_SetProgressStartFn ( GWEN_GUI gui,
GWEN_GUI_PROGRESS_START_FN  f 
)

Definition at line 141 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_SETPASSWORDSTATUS_FN GWEN_Gui_SetSetPasswordStatusFn ( GWEN_GUI gui,
GWEN_GUI_SETPASSWORDSTATUS_FN  f 
)

Definition at line 213 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_SHOWBOX_FN GWEN_Gui_SetShowBoxFn ( GWEN_GUI gui,
GWEN_GUI_SHOWBOX_FN  f 
)

Definition at line 116 of file gui.c.

Referenced by GWEN_Gui_CGui_new().

GWEN_GUI_WAITFORSOCKETS_FN GWEN_Gui_SetWaitForSocketsFn ( GWEN_GUI gui,
GWEN_GUI_WAITFORSOCKETS_FN  f 
)

Definition at line 238 of file gui.c.

uint32_t GWEN_Gui_ShowBox ( uint32_t  flags,
const char *  title,
const char *  text,
uint32_t  guiid 
)

Shows a box with the given text. This function should return immediately, it should especially NOT wait for user input. This is used to show very important notices the user should see but which don't need user interaction. The message box will be removed later via GWEN_Gui_HideBox. It is ok to allow the user to prematurely close the box.

It is required for every call to this function to be followed later by a corresponding call to GWEN_Gui_HideBox.

This function MUST return immediately (non-blocking).

Returns:
returns an id to be presented to GWEN_Gui_HideBox.
Parameters:
ab banking interface
flags flags, see GWEN_GUI_SHOWBOX_FLAGS_BEEP ff
title title of the box
text Text of the box: UTF-8, with both a normal text and a HTML variant of the text in the same string. See text restrictions note above.

Definition at line 319 of file gui.c.

References gwenhywfar_gui.

Referenced by GWEN_Crypt_Token_BeginEnterPin(), and test_gui().

int GWEN_Gui_WaitForSockets ( GWEN_SOCKET_LIST2 readSockets,
GWEN_SOCKET_LIST2 writeSockets,
uint32_t  guiid,
int  msecs 
)


Variable Documentation

GWEN_GUI* gwenhywfar_gui = NULL [static]


Generated on Fri Apr 11 01:53:48 2008 for gwenhywfar by  doxygen 1.5.5