FreeCalypso > hg > fc-tourmaline
comparison src/ui/mfw/mfw_lng.c @ 3:67bfe9f274f6
src/ui: import of src/ui3 from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:33:10 +0000 |
parents | |
children | 92abb46dc1ba |
comparison
equal
deleted
inserted
replaced
2:3a14ee9a9843 | 3:67bfe9f274f6 |
---|---|
1 /* | |
2 +--------------------------------------------------------------------+ | |
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_lng.c $| | |
4 | $Author:: Kk $ CONDAT GmbH $Revision:: 3 $| | |
5 | CREATED: 27.08.99 $Modtime:: 14.03.00 13:59 $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 MODULE : MFW_LNG | |
10 | |
11 PURPOSE : language handling functions | |
12 | |
13 EXPORT : | |
14 | |
15 TO DO : | |
16 | |
17 $History:: mfw_lng.c $ | |
18 * | |
19 * ***************** Version 3 ***************** | |
20 * User: Kk Date: 14.03.00 Time: 15:48 | |
21 * Updated in $/GSM/Condat/MS/SRC/MFW | |
22 * added handling of various texts | |
23 * | |
24 * ***************** Version 2 ***************** | |
25 * User: Kk Date: 10.01.00 Time: 14:03 | |
26 * Updated in $/GSM/Condat/MS/SRC/MFW | |
27 * | |
28 * ***************** Version 3 ***************** | |
29 * User: Rm Date: 12/22/99 Time: 4:34p | |
30 * Updated in $/GSM/Condat/SND-MMI/MFW | |
31 * | |
32 * ***************** Version 2 ***************** | |
33 * User: Es Date: 22.11.99 Time: 10:29 | |
34 * Updated in $/GSM/Condat/SND-MMI/MFW | |
35 * | |
36 * ***************** Version 1 ***************** | |
37 * User: Es Date: 18.11.99 Time: 16:35 | |
38 * Created in $/GSM/Condat/SND-MMI/MFW | |
39 * Initial | |
40 */ | |
41 | |
42 #if defined (NEW_FRAME) | |
43 | |
44 #include "typedefs.h" | |
45 #include "vsi.h" | |
46 #include "pei.h" | |
47 #include "custom.h" | |
48 #include "gsm.h" | |
49 | |
50 #else | |
51 | |
52 #include "STDDEFS.H" | |
53 #include "custom.h" | |
54 #include "gsm.h" | |
55 #include "vsi.h" | |
56 | |
57 #endif | |
58 | |
59 #include <stdio.h> | |
60 | |
61 #include "mfw_mfw.h" | |
62 #include "mfw_sys.h" | |
63 #include "drv_key.h" | |
64 #include "mfw_kbd.h" | |
65 #include "mfw_lng.h" | |
66 | |
67 | |
68 static int lngCommand (U32 cmd, void *h); | |
69 | |
70 EXTERN MfwHdr * current_mfw_elem; | |
71 | |
72 | |
73 /* | |
74 +--------------------------------------------------------------------+ | |
75 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
76 | STATE : code ROUTINE : lngInit | | |
77 +--------------------------------------------------------------------+ | |
78 | |
79 PURPOSE : initialize language handler | |
80 | |
81 */ | |
82 | |
83 MfwRes lngInit (void) | |
84 { | |
85 mfwCommand[MfwTypLng] = (MfwCb) lngCommand; | |
86 | |
87 return MfwResOk; | |
88 } | |
89 | |
90 | |
91 /* | |
92 +--------------------------------------------------------------------+ | |
93 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
94 | STATE : code ROUTINE : lngExit | | |
95 +--------------------------------------------------------------------+ | |
96 | |
97 PURPOSE : finalize language handler | |
98 | |
99 */ | |
100 | |
101 MfwRes lngExit (void) | |
102 { | |
103 mfwCommand[MfwTypLng] = 0; | |
104 | |
105 return MfwResOk; | |
106 } | |
107 | |
108 | |
109 /* | |
110 +--------------------------------------------------------------------+ | |
111 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
112 | STATE : code ROUTINE : lngCreate | | |
113 +--------------------------------------------------------------------+ | |
114 | |
115 PURPOSE : create language control | |
116 | |
117 */ | |
118 | |
119 MfwHnd lngCreate (MfwHnd w, MfwEvt e, LngInfo *l, MfwCb f) | |
120 { | |
121 MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr)); | |
122 MfwLng *lng = (MfwLng *) mfwAlloc(sizeof(MfwLng)); | |
123 MfwHdr *insert_status =0; | |
124 | |
125 if (!hdr || !lng) | |
126 { | |
127 TRACE_ERROR("ERROR: lngCreate() Mem Alloc Failed."); | |
128 | |
129 if(hdr) | |
130 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
131 if(lng) | |
132 mfwFree((U8*)lng,sizeof(MfwLng)); | |
133 | |
134 return 0; | |
135 } | |
136 | |
137 lng->map = e; | |
138 lng->evt = 0; | |
139 lng->handler = f; | |
140 lng->lng = l; | |
141 | |
142 hdr->data = lng; | |
143 hdr->type = MfwTypLng; | |
144 | |
145 insert_status = mfwInsert(w,hdr); | |
146 if(!insert_status) | |
147 { | |
148 TRACE_ERROR("ERROR: lngCreate() Failed to Install Handler. "); | |
149 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
150 mfwFree((U8*)lng ,sizeof(MfwLng)); | |
151 return 0; | |
152 } | |
153 return insert_status; | |
154 } | |
155 | |
156 | |
157 /* | |
158 +--------------------------------------------------------------------+ | |
159 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
160 | STATE : code ROUTINE : lngDelete | | |
161 +--------------------------------------------------------------------+ | |
162 | |
163 PURPOSE : delete language control | |
164 | |
165 */ | |
166 | |
167 MfwRes lngDelete (MfwHnd h) | |
168 { | |
169 MfwRes res; | |
170 | |
171 if (!h) | |
172 return MfwResIllHnd; | |
173 | |
174 res = (mfwRemove(h)) ? MfwResOk : MfwResIllHnd; | |
175 | |
176 mfwFree(((MfwHdr *) h)->data,sizeof(MfwLng)); | |
177 mfwFree(h,sizeof(MfwHdr)); | |
178 | |
179 return res; | |
180 } | |
181 | |
182 | |
183 /* | |
184 +--------------------------------------------------------------------+ | |
185 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
186 | STATE : code ROUTINE : lngText | | |
187 +--------------------------------------------------------------------+ | |
188 | |
189 PURPOSE : get prmpt text in current language | |
190 | |
191 */ | |
192 | |
193 char* lngText (MfwHnd h, unsigned int t) | |
194 { | |
195 char *err = "lngText: Fatal"; | |
196 MfwHdr *hp = h; | |
197 LngInfo *lc; | |
198 const char* const* lt; | |
199 | |
200 if (!hp || hp->type != MfwTypLng) | |
201 return err; | |
202 | |
203 lc = ((MfwLng *) (hp->data))->lng; | |
204 | |
205 if (!lc || !lc->prompts) | |
206 return err; | |
207 | |
208 if (t >= lc->nPrompts) | |
209 return ((char *) t); | |
210 | |
211 lt = lc->prompts[lc->language]; | |
212 | |
213 return ((char *) (lt[t])); | |
214 } | |
215 | |
216 | |
217 /* | |
218 +--------------------------------------------------------------------+ | |
219 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
220 | STATE : code ROUTINE : sigExec | | |
221 +--------------------------------------------------------------------+ | |
222 | |
223 PURPOSE : execute language control related signal | |
224 | |
225 */ | |
226 | |
227 static int sigExec (MfwHdr *curElem, U32 event/*, U8 key*/) | |
228 { | |
229 MfwLng *lc; | |
230 | |
231 while (curElem) | |
232 { | |
233 if (curElem->type == MfwTypLng) | |
234 { | |
235 lc = curElem->data; | |
236 if (lc->map & event) | |
237 { | |
238 if (lc->handler) /* handler valid */ | |
239 { | |
240 // PATCH LE 06.06.00 | |
241 // store current mfw elem | |
242 current_mfw_elem = curElem; | |
243 // END PATCH LE 06.06.00 | |
244 if ((*(lc->handler))(event,lc)) | |
245 return 1; /* event consumed */ | |
246 } | |
247 } | |
248 } | |
249 curElem = curElem->next; | |
250 } | |
251 | |
252 return 0; | |
253 } | |
254 | |
255 | |
256 /* | |
257 +--------------------------------------------------------------------+ | |
258 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
259 | STATE : code ROUTINE : lngSignal | | |
260 +--------------------------------------------------------------------+ | |
261 | |
262 PURPOSE : language control related event | |
263 | |
264 */ | |
265 | |
266 void lngSignal (void /*char make, char key*/) | |
267 {/*MC, SPR 1389, we have to enable the display whenever | |
268 we send an event up to the MMI*/ | |
269 UBYTE temp = dspl_Enable(0); | |
270 U32 event = 0; // RAVI | |
271 | |
272 if (mfwFocus) | |
273 if (sigExec(mfwFocus,event/*,(U8) key)*/)) | |
274 { dspl_Enable(temp);/*MC, SPR 1389*/ | |
275 return; | |
276 } | |
277 if (mfwRoot) | |
278 sigExec(mfwRoot,event/*,(U8) key*/); | |
279 | |
280 dspl_Enable(temp);/*MC, SPR 1389*/ | |
281 return; | |
282 } | |
283 | |
284 | |
285 /* | |
286 +--------------------------------------------------------------------+ | |
287 | PROJECT : MMI-Framework (8417) MODULE : MFW_LNG | | |
288 | STATE : code ROUTINE : lngCommand | | |
289 +--------------------------------------------------------------------+ | |
290 | |
291 PURPOSE : handle mfw windows command | |
292 | |
293 */ | |
294 | |
295 static int lngCommand (U32 cmd, void *h) | |
296 { | |
297 switch (cmd) | |
298 { | |
299 case MfwCmdDelete: /* delete me */ | |
300 if (!h) | |
301 return 0; | |
302 lngDelete(h); | |
303 return 1; | |
304 default: | |
305 break; | |
306 } | |
307 | |
308 return 0; | |
309 } | |
310 |