/******************************************************************************
 *
 *    Name: UIDialogLibCall.h
 *
 *    $Id$
 *
 *    Purpose: UI Dialog Library Load header.
 *
 *    Copyright 2013-2017 Citrix Systems, Inc. All rights reserved.
 *
 *****************************************************************************/

#ifndef UI_DIALOG_LIB_CALL_H
#define UI_DIALOG_LIB_CALL_H

#ifdef __cplusplus
extern "C" {
#endif

#include "UIDialogLib.h"
#include "UIDialogLibUtil.h"

struct UIDialogCallTable
{
    UIDIALOG*    (*UIDialogAllocate)(void);
    void         (*UIDialogInit)(const char *icaroot);
    void         (*UIDialogLoopInit)(int *argc, char ***argv);
    void         (*UIDialogSetOptions)(unsigned int);
    const char*  (*UIDialogDisplay)(UIDIALOG *dialog,
                                    struct formsElement **form,
                                    enum dialogStyle style,
                                    UIDIALOG *parent,
                                    const char *window_title,
                                    const char *default_response,
                                    unsigned int timeout,
                                    const char *timeout_response);
    const char*  (*UIDialogDisplayWMClass)(UIDIALOG *dialog,
                                           struct formsElement **form,
                                           enum dialogStyle style,
                                           UIDIALOG *parent,
                                           const char *window_title,
                                           const char *default_response,
                                           unsigned int timeout,
                                           const char *timeout_response,
                                           const char *wmclass_name,
                                           const char *wmclass_class);
    const char*  (*UIDialogDisplayVarg)(UIDIALOG*, struct formsElement**,
                                        const char*, const char*, ...);
    void         (*UIDialogClose)(UIDIALOG *dialog);
    void         (*UIDialogDeInit)(void);
    char*        (*UIDialogMnemonicAtChar)(char *mnemonicString, const char marker);
    void         (*UIDialogVersion)(unsigned int *major, unsigned int *minor);
    const char** (*UIDialogDisplayWebview)(const char *url,
                                           const char *window_title,
                                           const char *post_data,
                                           UIDIALOG *parent);
    void         (*UIDialogClearWebviewCookies)(void);
};

extern struct UIDialogCallTable dialogFunctions;

/* Function Table Macros. */
#define UI_DIALOG_ALLOCATE              dialogFunctions.UIDialogAllocate
#define UI_DIALOG_INIT                  dialogFunctions.UIDialogInit
#define UI_DIALOG_SET_OPTIONS           dialogFunctions.UIDialogSetOptions
#define UI_DIALOG_LOOP_INIT             dialogFunctions.UIDialogLoopInit
#define UI_DIALOG_DISPLAY               dialogFunctions.UIDialogDisplay
#define UI_DIALOG_DISPLAY_WM_CLASS      dialogFunctions.UIDialogDisplayWMClass
#define UI_DIALOG_DISPLAY_VARG          dialogFunctions.UIDialogDisplayVarg
#define UI_DIALOG_CLOSE                 dialogFunctions.UIDialogClose
#define UI_DIALOG_DEINIT                dialogFunctions.UIDialogDeInit
#define UI_DIALOG_MNEMONIC_AT_CHAR      dialogFunctions.UIDialogMnemonicAtChar
#define UI_DIALOG_VERSION               dialogFunctions.UIDialogVersion
#define UI_DIALOG_DISPLAY_WEBVIEW       dialogFunctions.UIDialogDisplayWebview
#define UI_DIALOG_CLEAR_WEBVIEW_COOKIES dialogFunctions.UIDialogClearWebviewCookies



/* Load the UIDialogLib.so and setup all the function pointers. 
 * Returns -1 on error, 1 on success and 0 if it was already loaded.
 */
int UIDialogLibLoad(const char *icaroot);

#ifdef __cplusplus
} /* End extern "C". */
#endif

#endif /* ! UI_DIALOG_LIB_CALL_H */

