|
1 /* |
|
2 * Copyright (c) 1999 - 2001 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /*************************************************************************** |
|
20 ** File: nw_scr_api.h |
|
21 ** Subsystem Name: WAE User Agent |
|
22 ** Purpose: This module is responsible for coordinating the WML Script Engine |
|
23 ** with the WML Interpreter and the User Interface. |
|
24 **************************************************************************/ |
|
25 #ifndef NW_SCR_API_H |
|
26 #define NW_SCR_API_H |
|
27 |
|
28 #ifdef __cplusplus |
|
29 extern "C" { |
|
30 #endif |
|
31 |
|
32 /* |
|
33 ** Includes |
|
34 */ |
|
35 #include "nw_wtai_api.h" |
|
36 #include "nwx_http_header.h" |
|
37 #include "nw_errnotify.h" |
|
38 #include "nwx_generic_dlg.h" |
|
39 #include "BrsrStatusCodes.h" |
|
40 |
|
41 /* |
|
42 ** Type Declarations |
|
43 */ |
|
44 |
|
45 /** |
|
46 * The context of the script proxy. |
|
47 * Created by NW_ScrProxy_New(). |
|
48 * Destroyed by NW_ScrProxy_Free(). |
|
49 **/ |
|
50 typedef struct _NW_ScrProxy_t NW_ScrProxy_t; |
|
51 |
|
52 /** |
|
53 * The callback to call when done displaying a script confirm dialog. |
|
54 **/ |
|
55 |
|
56 //#define NW_Dlg_ConfirmCB_t NW_ScrProxy_DlgConfirmCB_t; |
|
57 /** |
|
58 * The callback to call when done displaying a script alert dialog. |
|
59 **/ |
|
60 typedef TBrowserStatusCode (NW_ScrProxy_DlgAlertCB_t) (void *callback_ctx, |
|
61 TBrowserStatusCode status, |
|
62 NW_Dlg_Confirm_Result_t result); |
|
63 |
|
64 /** |
|
65 * The callback to call when done displaying a script prompt dialog. |
|
66 **/ |
|
67 typedef TBrowserStatusCode (NW_ScrProxy_DlgPromptCB_t) (void *callback_ctx, TBrowserStatusCode status, |
|
68 const NW_Ucs2 *input, NW_Bool endPressed); |
|
69 |
|
70 /** |
|
71 * The callback functions will be invoked by the script proxy to inform the user agent that a |
|
72 * WML Script has started and completed. |
|
73 **/ |
|
74 typedef struct { |
|
75 |
|
76 /* WML Script NW_Byte code has been downloaded and its about to execute. */ |
|
77 TBrowserStatusCode (*start)(void *wae, const NW_Ucs2 *url); |
|
78 |
|
79 /* script execution has completed. */ |
|
80 TBrowserStatusCode (*finish)(void *wae, TBrowserStatusCode status, |
|
81 const NW_Ucs2 *message); |
|
82 } NW_Scr_ProgressApi_t; /* Script progress, UI interface */ |
|
83 |
|
84 /** |
|
85 * The callback functions will be invoked by the script proxy to inform the user agent that a dialog |
|
86 * has to displayed. |
|
87 **/ |
|
88 typedef struct { |
|
89 |
|
90 /* display a alert dialog to the user */ |
|
91 void (*dlgAlert)(void *wae, const NW_Ucs2 *message, |
|
92 void *callback_ctx, |
|
93 NW_ScrProxy_DlgAlertCB_t *callback); |
|
94 |
|
95 /* display a confirm dialog to the user */ |
|
96 void (*dlgConfirm)(void *wae, |
|
97 const NW_Ucs2 *message, |
|
98 const NW_Ucs2 *yesMessage, |
|
99 const NW_Ucs2 *noMessage, |
|
100 void *callback_ctx, |
|
101 NW_Dlg_ConfirmCB_t *callback); |
|
102 |
|
103 /* display a prompt dialog to the user */ |
|
104 void (*dlgPrompt)(void *wae, |
|
105 const NW_Ucs2 *message, |
|
106 const NW_Ucs2 *defaultInput, |
|
107 void *callback_ctx, |
|
108 NW_ScrProxy_DlgPromptCB_t *callback); |
|
109 } NW_Scr_DialogApi_t; /* Script dialog libraries, UI interface */ |
|
110 |
|
111 |
|
112 |
|
113 typedef struct { |
|
114 |
|
115 /* retreive a variable */ |
|
116 TBrowserStatusCode (*getVar) (void *ctx, const NW_Ucs2 *var, NW_Ucs2 ** ret_string); |
|
117 |
|
118 /* set a variable */ |
|
119 TBrowserStatusCode (*setVar) (void *ctx, const NW_Ucs2 *var, const NW_Ucs2 *value); |
|
120 |
|
121 TBrowserStatusCode (*go) (void *ctx, const NW_Ucs2 *url, const NW_Ucs2 *param, |
|
122 NW_Http_Header_t *header); |
|
123 |
|
124 TBrowserStatusCode (*prev) (void *ctx); |
|
125 |
|
126 TBrowserStatusCode (*newContext) (void *ctx); |
|
127 |
|
128 TBrowserStatusCode (*refresh) (void *ctx); |
|
129 |
|
130 } NW_Scr_WmlBrowserApi_t; /* WMLBrowser Library Api */ |
|
131 |
|
132 typedef struct { |
|
133 |
|
134 /* script suspend/resume api */ |
|
135 TBrowserStatusCode (*scriptSuspResQuery) (void *ctx); |
|
136 |
|
137 } NW_Scr_SuspResQueryApi_t; |
|
138 |
|
139 /* |
|
140 ** Global Function Declarations |
|
141 */ |
|
142 |
|
143 NW_ScrProxy_t *NW_ScrProxy_New(); |
|
144 |
|
145 void NW_ScrProxy_Free(NW_ScrProxy_t *proxy); |
|
146 |
|
147 /* initialize the script proxy */ |
|
148 TBrowserStatusCode |
|
149 NW_ScrProxy_Initialize(NW_ScrProxy_t *scrProxy, void *ctx, |
|
150 const NW_Scr_WmlBrowserApi_t *scrBrowserApi, |
|
151 const NW_Scr_ProgressApi_t *scrProgressApi, |
|
152 const NW_Scr_DialogApi_t *scrDlgApi, |
|
153 const NW_WtaiApi_t *wtaiApi, |
|
154 const NW_Scr_SuspResQueryApi_t *scrSuspResQueryApi, |
|
155 NW_NotifyError_t errApi); |
|
156 |
|
157 /* run a script */ |
|
158 TBrowserStatusCode |
|
159 NW_ScrProxy_RunScript(NW_ScrProxy_t *scrProxy, |
|
160 NW_Ucs2 *url, NW_Ucs2 *postfields, NW_Ucs2 *referer, |
|
161 NW_Byte *content, const NW_Uint32 len, |
|
162 const NW_Http_CharSet_t charset); |
|
163 |
|
164 /** |
|
165 * This function abort's the currently running WML Script. |
|
166 **/ |
|
167 TBrowserStatusCode NW_ScrProxy_AbortScript(NW_ScrProxy_t *scrProxy); |
|
168 |
|
169 #ifdef __cplusplus |
|
170 } /* extern "C" */ |
|
171 #endif |
|
172 |
|
173 #endif /* NW_SCR_API_H */ |