|
1 /* |
|
2 * Copyright (c) 2000 - 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 * WML Script Proxy Callback implementation. This file implements |
|
21 * all the wml script proxy callbacks. Most of the functions are |
|
22 * trivial they just invoke the script interfaces on the WML Script |
|
23 * content handler. The dialog libraries and the error api are not |
|
24 * currently under a interface; the content handlers should exhibit |
|
25 * the same behaviour for these. TODO : hook up the dialog libraries |
|
26 * and the error dialog to the generic dialog api. |
|
27 *****************************************************************/ |
|
28 |
|
29 /* |
|
30 **------------------------------------------------------------------------- |
|
31 ** Include Files |
|
32 **------------------------------------------------------------------------- |
|
33 */ |
|
34 |
|
35 #include "nwx_string.h" |
|
36 #include "nwx_logger.h" |
|
37 #include "nw_errnotify.h" |
|
38 #include "nwx_http_header.h" |
|
39 #include "nw_wmlscriptch_wmlscriptcontenthandler.h" |
|
40 #include "BrsrStatusCodes.h" |
|
41 #include "MemoryManager.h" |
|
42 |
|
43 /* |
|
44 **------------------------------------------------------------------------- |
|
45 ** Internal Prototypes |
|
46 **------------------------------------------------------------------------- |
|
47 */ |
|
48 /* WMLS browser library routines called by the script proxy */ |
|
49 static TBrowserStatusCode WmlScrCh_GetVar(void *ctx, const NW_Ucs2 *var, |
|
50 NW_Ucs2 ** ret_string); |
|
51 |
|
52 static TBrowserStatusCode WmlScrCh_SetVar(void *ctx, const NW_Ucs2 *var, |
|
53 const NW_Ucs2 *value); |
|
54 |
|
55 static TBrowserStatusCode WmlScrCh_Go(void *ctx, const NW_Ucs2 *url, |
|
56 const NW_Ucs2 *param, NW_Http_Header_t *header); |
|
57 |
|
58 static TBrowserStatusCode WmlScrCh_Prev(void *ctx); |
|
59 |
|
60 static TBrowserStatusCode WmlScrCh_NewContext(void *ctx); |
|
61 |
|
62 static TBrowserStatusCode WmlScrCh_Refresh(void *ctx); |
|
63 |
|
64 |
|
65 /* WMLS load progess routines called by the script proxy */ |
|
66 static TBrowserStatusCode |
|
67 WmlScrCh_ScriptStart(void *ctx, const NW_Ucs2 *url); |
|
68 |
|
69 static TBrowserStatusCode |
|
70 WmlScrCh_ScriptComplete(void *ctx, TBrowserStatusCode status, |
|
71 const NW_Ucs2 *message); |
|
72 |
|
73 /* |
|
74 **------------------------------------------------------------------------- |
|
75 ** File Scoped Static Variables |
|
76 **------------------------------------------------------------------------- |
|
77 */ |
|
78 |
|
79 static const NW_Scr_ProgressApi_t ScrProgressApi = |
|
80 { |
|
81 WmlScrCh_ScriptStart, |
|
82 WmlScrCh_ScriptComplete, |
|
83 }; |
|
84 |
|
85 static const NW_Scr_WmlBrowserApi_t ScrWmlBrowserApi = |
|
86 { |
|
87 WmlScrCh_GetVar, |
|
88 WmlScrCh_SetVar, |
|
89 WmlScrCh_Go, |
|
90 WmlScrCh_Prev, |
|
91 WmlScrCh_NewContext, |
|
92 WmlScrCh_Refresh, |
|
93 }; |
|
94 |
|
95 |
|
96 /* |
|
97 **------------------------------------------------------------------------- |
|
98 ** Internal Functions |
|
99 **------------------------------------------------------------------------- |
|
100 */ |
|
101 static TBrowserStatusCode WmlScrCh_ScriptStart(void *ctx, const NW_Ucs2 *url) |
|
102 { |
|
103 NW_WmlScript_ContentHandler_t *thisObj; |
|
104 TBrowserStatusCode status = KBrsrSuccess; |
|
105 |
|
106 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
107 if (thisObj->wmlScrListener != NULL) { |
|
108 status = NW_WmlsCh_IWmlScriptListener_Start(thisObj->wmlScrListener, url); |
|
109 } |
|
110 return status; |
|
111 } |
|
112 |
|
113 |
|
114 static TBrowserStatusCode |
|
115 WmlScrCh_ScriptComplete(void *ctx, TBrowserStatusCode status, |
|
116 const NW_Ucs2 *message) |
|
117 { |
|
118 NW_WmlScript_ContentHandler_t *thisObj; |
|
119 TBrowserStatusCode ret_status = KBrsrSuccess; |
|
120 |
|
121 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
122 |
|
123 if (thisObj->wmlScrListener != NULL) { |
|
124 ret_status = NW_WmlsCh_IWmlScriptListener_Finish(thisObj->wmlScrListener, |
|
125 status, message); |
|
126 } |
|
127 return ret_status; |
|
128 } |
|
129 |
|
130 static TBrowserStatusCode |
|
131 WmlScrCh_GetVar(void *ctx, const NW_Ucs2 *var, NW_Ucs2 ** ret_string) |
|
132 { |
|
133 NW_WmlScript_ContentHandler_t *thisObj; |
|
134 |
|
135 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
136 |
|
137 NW_ASSERT(thisObj->wmlBrowserLib != NULL); |
|
138 return NW_WmlsCh_IWmlBrowserLib_GetVar(thisObj->wmlBrowserLib, var, ret_string); |
|
139 } |
|
140 |
|
141 static TBrowserStatusCode WmlScrCh_SetVar(void *ctx, const NW_Ucs2 *var, |
|
142 const NW_Ucs2 *value) |
|
143 { |
|
144 NW_WmlScript_ContentHandler_t *thisObj; |
|
145 |
|
146 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
147 |
|
148 NW_ASSERT(thisObj->wmlBrowserLib != NULL); |
|
149 return NW_WmlsCh_IWmlBrowserLib_SetVar(thisObj->wmlBrowserLib, var, value); |
|
150 } |
|
151 |
|
152 static TBrowserStatusCode WmlScrCh_Go(void *ctx, const NW_Ucs2 *url, |
|
153 const NW_Ucs2 *param, |
|
154 NW_Http_Header_t *header) |
|
155 { |
|
156 NW_WmlScript_ContentHandler_t *thisObj; |
|
157 |
|
158 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
159 |
|
160 NW_ASSERT(thisObj->wmlBrowserLib != NULL); |
|
161 return NW_WmlsCh_IWmlBrowserLib_Go(thisObj->wmlBrowserLib, url, param, header); |
|
162 } |
|
163 |
|
164 static TBrowserStatusCode WmlScrCh_Prev(void *ctx) |
|
165 { |
|
166 NW_WmlScript_ContentHandler_t *thisObj; |
|
167 |
|
168 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
169 |
|
170 NW_ASSERT(thisObj->wmlBrowserLib != NULL); |
|
171 return NW_WmlsCh_IWmlBrowserLib_Prev(thisObj->wmlBrowserLib); |
|
172 } |
|
173 |
|
174 static TBrowserStatusCode WmlScrCh_NewContext(void *ctx) |
|
175 { |
|
176 NW_WmlScript_ContentHandler_t *thisObj; |
|
177 |
|
178 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
179 |
|
180 NW_ASSERT(thisObj->wmlBrowserLib != NULL); |
|
181 return NW_WmlsCh_IWmlBrowserLib_NewContext(thisObj->wmlBrowserLib); |
|
182 } |
|
183 |
|
184 static TBrowserStatusCode WmlScrCh_Refresh(void *ctx) |
|
185 { |
|
186 NW_WmlScript_ContentHandler_t *thisObj; |
|
187 |
|
188 thisObj = NW_WmlScript_ContentHandlerOf(ctx); |
|
189 |
|
190 NW_ASSERT(thisObj->wmlBrowserLib != NULL); |
|
191 return NW_WmlsCh_IWmlBrowserLib_Refresh(thisObj->wmlBrowserLib); |
|
192 } |
|
193 |
|
194 |
|
195 /* |
|
196 **------------------------------------------------------------------------- |
|
197 ** External Public (Exported) Functions |
|
198 **------------------------------------------------------------------------- |
|
199 */ |
|
200 const NW_Scr_ProgressApi_t* NW_Api_GetScriptProgressCB() |
|
201 { |
|
202 return &ScrProgressApi; |
|
203 } |
|
204 |
|
205 const NW_Scr_WmlBrowserApi_t* NW_Api_GetScriptBrowserCB() |
|
206 { |
|
207 return &ScrWmlBrowserApi; |
|
208 } |