comparison src/ui/bmi/mmiBand.c @ 137:63dffa10b00a

mmiBand.c: bogotab fixes
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 14 Nov 2020 03:35:49 +0000
parents c0052fe355d3
children
comparison
equal deleted inserted replaced
136:db101b57af2d 137:63dffa10b00a
1 /******************************************************************************* 1 /*******************************************************************************
2 2
3 CONDAT (UK) 3 CONDAT (UK)
4 4
5 ******************************************************************************** 5 ********************************************************************************
6 6
7 This software product is the property of Condat (UK) Ltd and may not be 7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner. 8 disclosed to any third party without the express permission of the owner.
9 9
10 ******************************************************************************** 10 ********************************************************************************
11 11
12 $Project name: Basic MMI 12 $Project name: Basic MMI
13 $Project code: BMI 13 $Project code: BMI
14 $Module: Frequency band selection 14 $Module: Frequency band selection
15 $File: MmiBand.c 15 $File: MmiBand.c
16 $Revision: 1.0 16 $Revision: 1.0
17 17
18 $Author: Condat(UK) 18 $Author: Condat(UK)
19 $Date: 03/04/02 19 $Date: 03/04/02
20 20
21 ******************************************************************************** 21 ********************************************************************************
22 22
23 Description: 23 Description:
24 24
26 band used. 26 band used.
27 27
28 ******************************************************************************** 28 ********************************************************************************
29 $History: MmiBand.c 29 $History: MmiBand.c
30 30
31 03/04/02 Original Condat(UK) BMI version. 31 03/04/02 Original Condat(UK) BMI version.
32 32
33 $End 33 $End
34 34
35 *******************************************************************************/ 35 *******************************************************************************/
36
37 36
38 37
39 38
40 /******************************************************************************* 39 /*******************************************************************************
41 40
104 #include "MmiCPHS.h" 103 #include "MmiCPHS.h"
105 #include "mmiColours.h" 104 #include "mmiColours.h"
106 105
107 /***********************************Macros**********************************************/ 106 /***********************************Macros**********************************************/
108 107
109 #define MAX_NUMBER_OF_FREQS 5 108 #define MAX_NUMBER_OF_FREQS 5
110 #define NO_OF_BAND_MODES 2 109 #define NO_OF_BAND_MODES 2
111 #define BAND_INIT 1 110 #define BAND_INIT 1
112 #define BAND_DESTROY 2 111 #define BAND_DESTROY 2
113 112
114 113
115 114
116 /*********************Structure Definitions********************************************************/ 115 /*********************Structure Definitions********************************************************/
117 typedef struct 116 typedef struct
118 { 117 {
119 T_MMI_CONTROL mmi_control; 118 T_MMI_CONTROL mmi_control;
120 T_MFW_HND freq_win; /* MFW win handler */ 119 T_MFW_HND freq_win; /* MFW win handler */
121 T_MFW_HND parent; 120 T_MFW_HND parent;
122 UBYTE available_freqs; 121 UBYTE available_freqs;
123 UBYTE selected_freqs; /* SPR#998 - SH - Used to store list of selected frequencies */ 122 UBYTE selected_freqs; /* SPR#998 - SH - Used to store list of selected frequencies */
124 T_MFW_BAND_MODE mode; /* SPR#998 - SH */ 123 T_MFW_BAND_MODE mode; /* SPR#998 - SH */
125 UBYTE type[MAX_NUMBER_OF_FREQS]; 124 UBYTE type[MAX_NUMBER_OF_FREQS];
126 ListMenuData * menu_list_data; 125 ListMenuData * menu_list_data;
127 UBYTE no_of_entries; 126 UBYTE no_of_entries;
128 } T_FREQ_INFO; 127 } T_FREQ_INFO;
129 128
130 129
131 static const MfwMnuAttr Freq_menuAttrib = 130 static const MfwMnuAttr Freq_menuAttrib =
132 { 131 {
133 &melody_menuArea, 132 &melody_menuArea,
134 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */ 133 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
135 (U8)-1, /* use default font */ 134 (U8)-1, /* use default font */
136 NULL, /* with these items */ 135 NULL, /* with these items */
137 0, /* number of items */ 136 0, /* number of items */
138 COLOUR_LIST_SMS, 137 COLOUR_LIST_SMS,
139 TxtNull, 138 TxtNull,
140 MNUATTRSPARE}; 139 MNUATTRSPARE};
141 140
142 /* List of all possible frequencies */ 141 /* List of all possible frequencies */
143 142
144 static const int band_list[MAX_NUMBER_OF_FREQS] = { 143 static const int band_list[MAX_NUMBER_OF_FREQS] = {
145 MFW_BAND_GSM_900, 144 MFW_BAND_GSM_900,
146 MFW_BAND_DCS_1800, 145 MFW_BAND_DCS_1800,
147 MFW_BAND_PCS_1900, 146 MFW_BAND_PCS_1900,
148 MFW_BAND_E_GSM, 147 MFW_BAND_E_GSM,
149 MFW_BAND_GSM_850 148 MFW_BAND_GSM_850
150 }; 149 };
151 150
152 /* SPR#998 - SH - Static handle to allow callback functions to access data */ 151 /* SPR#998 - SH - Static handle to allow callback functions to access data */
153 static T_FREQ_INFO *current_data = NULL; 152 static T_FREQ_INFO *current_data = NULL;
154 153
155 /*********************************Function Prototypes*****************************/ 154 /*********************************Function Prototypes*****************************/
156 155
157 char* Freq2Str(int freq); 156 char* Freq2Str(int freq);
158 157
159 int Freq2StrID(int freq); 158 int Freq2StrID(int freq);
160 static T_MFW_HND mmi_band_build_freq_list( MfwHnd parent_window, UBYTE available_freqs); 159 static T_MFW_HND mmi_band_build_freq_list( MfwHnd parent_window, UBYTE available_freqs);
161 static int mmi_band_display_status(T_MFW_HND parent); 160 static int mmi_band_display_status(T_MFW_HND parent);
162 static int mmi_band_display_status_cb(T_MFW_HND parent, USHORT identifier, USHORT reason); 161 static int mmi_band_display_status_cb(T_MFW_HND parent, USHORT identifier, USHORT reason);
163 void mmi_band_freq_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter); 162 void mmi_band_freq_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
164 void mmi_band_freq_list_cb(T_MFW_HND * Parent, ListMenuData * ListData); 163 void mmi_band_freq_list_cb(T_MFW_HND * Parent, ListMenuData * ListData);
165 static void mmi_band_freq_list_destroy(MfwHnd own_window); 164 static void mmi_band_freq_list_destroy(MfwHnd own_window);
166 static int mmi_band_freq_win_cb (MfwEvt e, MfwWin *w); 165 static int mmi_band_freq_win_cb (MfwEvt e, MfwWin *w);
167 /* SPR#998 - SH - Functions used by new checkbox menus */ 166 /* SPR#998 - SH - Functions used by new checkbox menus */
168 int mmi_band_menu_func(MfwMnu* menu, MfwMnuItem* item); 167 int mmi_band_menu_func(MfwMnu* menu, MfwMnuItem* item);
169 USHORT mmi_band_menu_flag( struct MfwMnuTag *menu, struct MfwMnuAttrTag *attr, struct MfwMnuItemTag *item ); 168 USHORT mmi_band_menu_flag( struct MfwMnuTag *menu, struct MfwMnuAttrTag *attr, struct MfwMnuItemTag *item );
170 169
171 170
172 /************************************Public Functions************************/ 171 /************************************Public Functions************************/
173 172
174 173
175 /************************************************************************* 174 /*************************************************************************
176 175
177 $Function: mmi_band_radio_mode_change_auto 176 $Function: mmi_band_radio_mode_change_auto
178 177
179 $Description: Changes multiband mode to automatic. Selected from menu. 178 $Description: Changes multiband mode to automatic. Selected from menu.
180 179
181 $Returns: status int 180 $Returns: status int
182 181
183 $Arguments: menu and menu item (not used) 182 $Arguments: menu and menu item (not used)
184 183
185 184
186 *******************************************************************************/ 185 *******************************************************************************/
187 186
188 int mmi_band_radio_mode_change_auto(MfwMnu* m, MfwMnuItem* i) 187 int mmi_band_radio_mode_change_auto(MfwMnu* m, MfwMnuItem* i)
189 { 188 {
190 T_MFW_HND parent = mfwParent( mfw_header()); 189 T_MFW_HND parent = mfwParent( mfw_header());
191 // T_MFW_BAND_MODE mode; // RAVI 190 // T_MFW_BAND_MODE mode; // RAVI
192 191
193 TRACE_FUNCTION("mmi_band_radio_mode_change_auto"); 192 TRACE_FUNCTION("mmi_band_radio_mode_change_auto");
194 193
195 if (band_radio_mode_switch(MFW_BAND_MODE_Auto, 0) >= MFW_BAND_OK) 194 if (band_radio_mode_switch(MFW_BAND_MODE_Auto, 0) >= MFW_BAND_OK)
196 { 195 {
197 ShowMessage(parent, TxtDone, TxtNull); 196 ShowMessage(parent, TxtDone, TxtNull);
198 } 197 }
199 else 198 else
200 ShowMessage(parent, TxtFailed, TxtNull); 199 ShowMessage(parent, TxtFailed, TxtNull);
201 200
202 return MFW_EVENT_CONSUMED; 201 return MFW_EVENT_CONSUMED;
203 } 202 }
204 203
205 204
206 /******************************************************************************* 205 /*******************************************************************************
207 206
208 $Function: mmi_band_radio_mode_change_manual 207 $Function: mmi_band_radio_mode_change_manual
209 208
210 $Description: Gets a list of available manual bands. Selected from menu. 209 $Description: Gets a list of available manual bands. Selected from menu.
211 210
212 $Returns: status int 211 $Returns: status int
213 212
214 $Arguments: menu and menu item (not used) 213 $Arguments: menu and menu item (not used)
215 214
216 215
217 *******************************************************************************/ 216 *******************************************************************************/
218 217
219 int mmi_band_radio_mode_change_manual(MfwMnu* m, MfwMnuItem* i) 218 int mmi_band_radio_mode_change_manual(MfwMnu* m, MfwMnuItem* i)
220 { 219 {
221 T_MFW_HND parent = mfwParent( mfw_header()); 220 T_MFW_HND parent = mfwParent( mfw_header());
222 T_MFW_BAND_MODE maxMode; 221 T_MFW_BAND_MODE maxMode;
223 UBYTE available_freqs; 222 UBYTE available_freqs;
224 T_MFW_HND win; 223 T_MFW_HND win;
225 224
226 if (band_get_radio_modes(&maxMode, &available_freqs) >= MFW_BAND_OK) 225 if (band_get_radio_modes(&maxMode, &available_freqs) >= MFW_BAND_OK)
227 { 226 {
228 if (maxMode >= MFW_BAND_MODE_Manual) /* Make sure manual is an accepted mode */ 227 if (maxMode >= MFW_BAND_MODE_Manual) /* Make sure manual is an accepted mode */
229 { 228 {
230 win = mmi_band_build_freq_list(parent, available_freqs); 229 win = mmi_band_build_freq_list(parent, available_freqs);
231 if (win NEQ NULL) 230 if (win NEQ NULL)
232 { 231 {
233 SEND_EVENT (win, BAND_INIT, 0, 0); 232 SEND_EVENT (win, BAND_INIT, 0, 0);
234 } 233 }
235 else 234 else
236 ShowMessage(parent, TxtManual, TxtNotSupported); 235 ShowMessage(parent, TxtManual, TxtNotSupported);
237 } 236 }
238 } 237 }
239 238
240 return MFW_EVENT_CONSUMED; 239 return MFW_EVENT_CONSUMED;
241 } 240 }
242 241
243 242
244 /******************************************************************************* 243 /*******************************************************************************
245 244
246 $Function: mmi_band_radio_mode_info 245 $Function: mmi_band_radio_mode_info
247 246
248 $Description: Get current band setting 247 $Description: Get current band setting
249 248
250 $Returns: status int 249 $Returns: status int
251 250
252 $Arguments: menu and menu item (not used) 251 $Arguments: menu and menu item (not used)
253 252
254 253
255 *******************************************************************************/ 254 *******************************************************************************/
256 255
257 int mmi_band_radio_mode_info(MfwMnu* m, MfwMnuItem* i) 256 int mmi_band_radio_mode_info(MfwMnu* m, MfwMnuItem* i)
258 { T_MFW_HND parent = mfwParent( mfw_header()); 257 { T_MFW_HND parent = mfwParent( mfw_header());
259 258
260 mmi_band_display_status(parent); 259 mmi_band_display_status(parent);
261 260
262 return MFW_EVENT_CONSUMED; 261 return MFW_EVENT_CONSUMED;
263 } 262 }
264 263
265 264
266 /*******************************Private Functions**********************************/ 265 /*******************************Private Functions**********************************/
267 266
268 267
269 268 /*******************************************************************************
270 /******************************************************************************* 269
271 270 $Function: Freq2Str
272 $Function: Freq2Str 271
273 272 $Description: Converts the band enum into an appropraite string
274 $Description: Converts the band enum into an appropraite string 273
275 274 $Returns: string
276 $Returns: string 275
277 276 $Arguments: Band (integer)
278 $Arguments: Band (integer)
279 277
280 278
281 *******************************************************************************/ 279 *******************************************************************************/
282 280
283 char* Freq2Str(int freq) 281 char* Freq2Str(int freq)
284 { 282 {
285 switch (freq) 283 switch (freq)
286 { 284 {
287 case MFW_BAND_DCS_1800: return MmiRsrcGetText(TxtDCS_1800); //break; // RAVI 285 case MFW_BAND_DCS_1800: return MmiRsrcGetText(TxtDCS_1800); //break; // RAVI
288 case MFW_BAND_PCS_1900: return MmiRsrcGetText(TxtPCS_1900); //break; // RAVI 286 case MFW_BAND_PCS_1900: return MmiRsrcGetText(TxtPCS_1900); //break; // RAVI
289 case MFW_BAND_E_GSM: return MmiRsrcGetText(TxtE_GSM); //break; // RAVI 287 case MFW_BAND_E_GSM: return MmiRsrcGetText(TxtE_GSM); //break; // RAVI
290 case MFW_BAND_GSM_850: return MmiRsrcGetText(TxtGSM_850); // break; // RAVI 288 case MFW_BAND_GSM_850: return MmiRsrcGetText(TxtGSM_850); // break; // RAVI
291 case MFW_BAND_GSM_900: return MmiRsrcGetText(TxtGSM_900); // break; // RAVI 289 case MFW_BAND_GSM_900: return MmiRsrcGetText(TxtGSM_900); // break; // RAVI
292 default: return MmiRsrcGetText(TxtError); // break; // RAVI 290 default: return MmiRsrcGetText(TxtError); // break; // RAVI
293 } 291 }
294 } 292 }
295 293
296 294
297 /******************************************************************************* 295 /*******************************************************************************
298 296
299 $Function: Freq2Str 297 $Function: Freq2Str
300 298
301 $Description: Converts the band enum into an appropraite string ID 299 $Description: Converts the band enum into an appropraite string ID
302 300
303 $Returns: string ID 301 $Returns: string ID
304 302
305 $Arguments: Band (integer) 303 $Arguments: Band (integer)
306 304
307 305
308 *******************************************************************************/ 306 *******************************************************************************/
309 307
310 int Freq2StrID(int freq) 308 int Freq2StrID(int freq)
311 { 309 {
312 switch (freq) 310 switch (freq)
313 { 311 {
314 case MFW_BAND_DCS_1800: return TxtDCS_1800; //break; // RAVI 312 case MFW_BAND_DCS_1800: return TxtDCS_1800; //break; // RAVI
315 case MFW_BAND_PCS_1900: return TxtPCS_1900; //break; // RAVI 313 case MFW_BAND_PCS_1900: return TxtPCS_1900; //break; // RAVI
316 case MFW_BAND_E_GSM: return TxtE_GSM; //break; // RAVI 314 case MFW_BAND_E_GSM: return TxtE_GSM; //break; // RAVI
317 case MFW_BAND_GSM_850: return TxtGSM_850; // break; // RAVI 315 case MFW_BAND_GSM_850: return TxtGSM_850; // break; // RAVI
318 case MFW_BAND_GSM_900: return TxtGSM_900; //break; // RAVI 316 case MFW_BAND_GSM_900: return TxtGSM_900; //break; // RAVI
319 default: return TxtError; //break; // RAVI 317 default: return TxtError; //break; // RAVI
320 } 318 }
321 } 319 }
322 320
323 321
324 /******************************************************************************* 322 /*******************************************************************************
325 323
326 $Function: mmi_band_display_status 324 $Function: mmi_band_display_status
327 $Description: Displays the current band status 325 $Description: Displays the current band status
328 $Returns: none 326 $Returns: none
329 $Arguments: parent - parent window 327 $Arguments: parent - parent window
330 328
331 *******************************************************************************/ 329 *******************************************************************************/
332 330
333 static int mmi_band_display_status(T_MFW_HND parent) 331 static int mmi_band_display_status(T_MFW_HND parent)
334 { 332 {
335 /* SPR#998 - SH - Now store mode in data->mode */ 333 /* SPR#998 - SH - Now store mode in data->mode */
336 T_MFW_WIN *win_data = ((T_MFW_HDR *) parent)->data; 334 T_MFW_WIN *win_data = ((T_MFW_HDR *) parent)->data;
337 T_FREQ_INFO *data = (T_FREQ_INFO *)win_data->user; 335 T_FREQ_INFO *data = (T_FREQ_INFO *)win_data->user;
338 336
339 if (band_get_current_radio_mode(&data->mode, &data->selected_freqs) >= MFW_BAND_OK) 337 if (band_get_current_radio_mode(&data->mode, &data->selected_freqs) >= MFW_BAND_OK)
340 { 338 {
341 if (data->mode == MFW_BAND_MODE_Auto) 339 if (data->mode == MFW_BAND_MODE_Auto)
342 { 340 {
343 ShowMessage(parent, TxtAutomatic, TxtNull); 341 ShowMessage(parent, TxtAutomatic, TxtNull);
344 } 342 }
345 else 343 else
346 { 344 {
347 ShowMessage(parent, TxtManual, TxtNull); 345 ShowMessage(parent, TxtManual, TxtNull);
348 } 346 }
349 } 347 }
350 else 348 else
351 { 349 {
352 ShowMessage(parent, TxtReadError, TxtNull); 350 ShowMessage(parent, TxtReadError, TxtNull);
353 } 351 }
354 352
355 return 1; // RAVI - Changed return to return 1. 353 return 1; // RAVI - Changed return to return 1.
356 } 354 }
357 355
358 #if(0) /* x0039298 - Lint warning fix */ 356 #if(0) /* x0039298 - Lint warning fix */
359 /******************************************************************************* 357 /*******************************************************************************
360 358
361 $Function: mmi_band_display_status_cb 359 $Function: mmi_band_display_status_cb
362 $Description: Callback for status list window - currently does nothing 360 $Description: Callback for status list window - currently does nothing
363 $Returns: none 361 $Returns: none
364 $Arguments: parent - parent window 362 $Arguments: parent - parent window
365 identifier - length of status string 363 identifier - length of status string
366 reason - not used 364 reason - not used
367 365
368 *******************************************************************************/ 366 *******************************************************************************/
369 367
370 static int mmi_band_display_status_cb(T_MFW_HND parent, USHORT identifier, USHORT reason) 368 static int mmi_band_display_status_cb(T_MFW_HND parent, USHORT identifier, USHORT reason)
371 { 369 {
372 return 1; // RAVI - Changed return to return 1. 370 return 1; // RAVI - Changed return to return 1.
373 } 371 }
374 #endif 372 #endif
375 373
376 /******************************************************************************* 374 /*******************************************************************************
377 375
378 $Function: mmi_band_build_freq_list 376 $Function: mmi_band_build_freq_list
379 $Description: Creates window for frequency list 377 $Description: Creates window for frequency list
380 $Returns: window created 378 $Returns: window created
381 $Arguments: parent window 379 $Arguments: parent window
382 380
383 *******************************************************************************/ 381 *******************************************************************************/
384 382
385 static T_MFW_HND mmi_band_build_freq_list( MfwHnd parent_window, UBYTE available_freqs) 383 static T_MFW_HND mmi_band_build_freq_list( MfwHnd parent_window, UBYTE available_freqs)
386 { 384 {
387 T_FREQ_INFO *data = (T_FREQ_INFO *)ALLOC_MEMORY (sizeof (T_FREQ_INFO)); 385 T_FREQ_INFO *data = (T_FREQ_INFO *)ALLOC_MEMORY (sizeof (T_FREQ_INFO));
388 T_MFW_WIN *win; 386 T_MFW_WIN *win;
389 // int index; // RAVI 387 // int index; // RAVI
390 388
391 TRACE_FUNCTION("mmi_band_build_freq_list()"); 389 TRACE_FUNCTION("mmi_band_build_freq_list()");
392 /* 390 /*
393 * Create window handler 391 * Create window handler
394 */ 392 */
395 393
396 data->freq_win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)mmi_band_freq_win_cb); 394 data->freq_win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)mmi_band_freq_win_cb);
397 if (data->freq_win EQ NULL) 395 if (data->freq_win EQ NULL)
398 { 396 {
399 return NULL; 397 return NULL;
400 } 398 }
401 399
402 current_data = data; /* SPR#998 - SH - Store handle for data; used by callbacks */ 400 current_data = data; /* SPR#998 - SH - Store handle for data; used by callbacks */
403 401
404 /* 402 /*
405 * connect the dialog data to the MFW-window 403 * connect the dialog data to the MFW-window
406 */ 404 */
407 405
408 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_band_freq_exec_cb; 406 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_band_freq_exec_cb;
409 data->mmi_control.data = data; 407 data->mmi_control.data = data;
410 win = ((T_MFW_HDR *)data->freq_win)->data; 408 win = ((T_MFW_HDR *)data->freq_win)->data;
411 win->user = (void *)data; 409 win->user = (void *)data;
412 data->parent = parent_window; 410 data->parent = parent_window;
413 data->available_freqs = available_freqs; 411 data->available_freqs = available_freqs;
414 412
415 winShow(data->freq_win); 413 winShow(data->freq_win);
416 /* 414 /*
417 * return window handle 415 * return window handle
418 */ 416 */
419 417
420 return data->freq_win; 418 return data->freq_win;
421 } 419 }
422 420
423 421
424 /******************************************************************************* 422 /*******************************************************************************
425 423
426 $Function: mmi_band_freq_exec_cb 424 $Function: mmi_band_freq_exec_cb
427 425
428 $Description: Exec callback function of the information Numbers window 426 $Description: Exec callback function of the information Numbers window
429 427
430 $Returns: none 428 $Returns: none
431 429
432 $Arguments: win - window handler 430 $Arguments: win - window handler
433 event - mfw event 431 event - mfw event
434 parameter - optional data. 432 parameter - optional data.
435 433
436 *******************************************************************************/ 434 *******************************************************************************/
437 435
438 void mmi_band_freq_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter) 436 void mmi_band_freq_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
439 { 437 {
440 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data; 438 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
441 T_FREQ_INFO *data = (T_FREQ_INFO *)win_data->user; 439 T_FREQ_INFO *data = (T_FREQ_INFO *)win_data->user;
442 UBYTE numberOfEntries; 440 UBYTE numberOfEntries;
443 int index; 441 int index;
444 T_MFW_BAND_MODE maxMode; 442 T_MFW_BAND_MODE maxMode;
445 // char *menuItem; // RAVI 443 // char *menuItem; // RAVI
446 /* SPR#998 - SH - Remove code that implements custom checkbox implementaton, 444 /* SPR#998 - SH - Remove code that implements custom checkbox implementaton,
447 * as checkboxes now handled by mfw */ 445 * as checkboxes now handled by mfw */
448 446
449 TRACE_FUNCTION ("mmi_band_freq_exec_cb()"); 447 TRACE_FUNCTION ("mmi_band_freq_exec_cb()");
450 448
451 switch (event) 449 switch (event)
452 { 450 {
453 case BAND_INIT: 451 case BAND_INIT:
454 452
455 TRACE_EVENT("mmi_band_freq_exec_cb() Event:BAND_INIT"); 453 TRACE_EVENT("mmi_band_freq_exec_cb() Event:BAND_INIT");
456 454
457 /* initialization of administrative data */ 455 /* initialization of administrative data */
458 456
459 data->menu_list_data = (ListMenuData *)ALLOC_MEMORY(sizeof(ListMenuData)); 457 data->menu_list_data = (ListMenuData *)ALLOC_MEMORY(sizeof(ListMenuData));
460 458
461 if(!data->menu_list_data) 459 if(!data->menu_list_data)
462 { 460 {
463 TRACE_EVENT("Failed memory alloc 1 "); 461 TRACE_EVENT("Failed memory alloc 1 ");
464 return; 462 return;
465 } 463 }
466 464
467 band_get_radio_modes(&maxMode, &data->available_freqs); 465 band_get_radio_modes(&maxMode, &data->available_freqs);
468 466
469 /* Run through the list of possible frequencies first to obtain 467 /* Run through the list of possible frequencies first to obtain
470 the number of frequencies permitted (how many will be in the menu) */ 468 the number of frequencies permitted (how many will be in the menu) */
471 /* SPR#998 - SH - Removed custom checkbox implementation */ 469 /* SPR#998 - SH - Removed custom checkbox implementation */
472 470
473 numberOfEntries = 0; 471 numberOfEntries = 0;
474 472
475 for (index=0; index<MAX_NUMBER_OF_FREQS; index++) 473 for (index=0; index<MAX_NUMBER_OF_FREQS; index++)
476 { 474 {
477 if (data->available_freqs & band_list[index]) 475 if (data->available_freqs & band_list[index])
478 { 476 {
479 data->type[numberOfEntries] = band_list[index]; 477 data->type[numberOfEntries] = band_list[index];
480 numberOfEntries++; 478 numberOfEntries++;
481 } 479 }
482 } 480 }
483 481
484 /* If there are no entries, show "Empty List" message and exit */ 482 /* If there are no entries, show "Empty List" message and exit */
485 483
486 if (numberOfEntries==0) 484 if (numberOfEntries==0)
487 { 485 {
488 ShowMessage(data->parent, TxtEmptyList, TxtNull); 486 ShowMessage(data->parent, TxtEmptyList, TxtNull);
489 mmi_band_freq_list_destroy(win); 487 mmi_band_freq_list_destroy(win);
490 return; 488 return;
491 } 489 }
492 490
493 /* Get the status of all the frequencies */ 491 /* Get the status of all the frequencies */
494 /* SPR#998 - SH - Use data->mode */ 492 /* SPR#998 - SH - Use data->mode */
495 493
496 if (band_get_current_radio_mode(&data->mode, &data->selected_freqs) >= MFW_BAND_OK) 494 if (band_get_current_radio_mode(&data->mode, &data->selected_freqs) >= MFW_BAND_OK)
497 { 495 {
498 /* If we're not in manual choose manual */ 496 /* If we're not in manual choose manual */
499 497
500 if (data->mode!=MFW_BAND_MODE_Manual) 498 if (data->mode!=MFW_BAND_MODE_Manual)
501 { 499 {
502 data->selected_freqs = data->available_freqs; /* SH - default when choosing manual is all */ 500 data->selected_freqs = data->available_freqs; /* SH - default when choosing manual is all */
503 band_radio_mode_switch(MFW_BAND_MODE_Manual, data->selected_freqs); 501 band_radio_mode_switch(MFW_BAND_MODE_Manual, data->selected_freqs);
504 } 502 }
505 503
506 /* Allocate the memory for the list structure */ 504 /* Allocate the memory for the list structure */
507 505
508 data->no_of_entries = numberOfEntries; 506 data->no_of_entries = numberOfEntries;
509 507
510 data->menu_list_data->List = (T_MFW_MNU_ITEM *)ALLOC_MEMORY( numberOfEntries * sizeof(T_MFW_MNU_ITEM) ); 508 data->menu_list_data->List = (T_MFW_MNU_ITEM *)ALLOC_MEMORY( numberOfEntries * sizeof(T_MFW_MNU_ITEM) );
511 509
512 if(!data->menu_list_data->List) 510 if(!data->menu_list_data->List)
513 { 511 {
514 TRACE_EVENT("Failed memory alloc 2"); 512 TRACE_EVENT("Failed memory alloc 2");
515 return; 513 return;
516 } 514 }
517 515
518 /* Allocate memory for the menu texts, and populate the list structure */ 516 /* Allocate memory for the menu texts, and populate the list structure */
519 517
520 numberOfEntries = 0; 518 numberOfEntries = 0;
521 519
522 for (index=0; index<MAX_NUMBER_OF_FREQS; index++) 520 for (index=0; index<MAX_NUMBER_OF_FREQS; index++)
523 { 521 {
524 if (data->available_freqs & band_list[index]) 522 if (data->available_freqs & band_list[index])
525 { 523 {
526 /* SPR#998 - SH - Removed code, checkboxes now handled by MFW */ 524 /* SPR#998 - SH - Removed code, checkboxes now handled by MFW */
527 mnuInitDataItem(&data->menu_list_data->List[numberOfEntries]); 525 mnuInitDataItem(&data->menu_list_data->List[numberOfEntries]);
528 /* Here we specify the function that checks and unchecks the checkboxes */ 526 /* Here we specify the function that checks and unchecks the checkboxes */
529 data->menu_list_data->List[numberOfEntries].func = mmi_band_menu_func; 527 data->menu_list_data->List[numberOfEntries].func = mmi_band_menu_func;
530 data->menu_list_data->List[numberOfEntries].str = (char *)Freq2StrID(band_list[index]); 528 data->menu_list_data->List[numberOfEntries].str = (char *)Freq2StrID(band_list[index]);
531 /* Here we specify the function that returns the checkbox status of any menu item */ 529 /* Here we specify the function that returns the checkbox status of any menu item */
532 data->menu_list_data->List[numberOfEntries].flagFunc = mmi_band_menu_flag; 530 data->menu_list_data->List[numberOfEntries].flagFunc = mmi_band_menu_flag;
533 numberOfEntries++; 531 numberOfEntries++;
534 } 532 }
535 } 533 }
536 534
537 data->menu_list_data->ListLength =numberOfEntries; 535 data->menu_list_data->ListLength =numberOfEntries;
538 data->menu_list_data->ListPosition = 1; 536 data->menu_list_data->ListPosition = 1;
539 data->menu_list_data->CursorPosition = 1; 537 data->menu_list_data->CursorPosition = 1;
540 data->menu_list_data->SnapshotSize = numberOfEntries; 538 data->menu_list_data->SnapshotSize = numberOfEntries;
541 data->menu_list_data->Font = 0; 539 data->menu_list_data->Font = 0;
542 data->menu_list_data->LeftSoftKey = TxtSoftSelect; 540 data->menu_list_data->LeftSoftKey = TxtSoftSelect;
543 data->menu_list_data->RightSoftKey = TxtSoftBack; 541 data->menu_list_data->RightSoftKey = TxtSoftBack;
544 data->menu_list_data->KeyEvents = KEY_ALL; 542 data->menu_list_data->KeyEvents = KEY_ALL;
545 data->menu_list_data->Reason = 0; 543 data->menu_list_data->Reason = 0;
546 data->menu_list_data->Strings = FALSE; /* SPR#998 - SH - We no longer alter the menu strings */ 544 data->menu_list_data->Strings = FALSE; /* SPR#998 - SH - We no longer alter the menu strings */
547 data->menu_list_data->Attr = (MfwMnuAttr*)&Freq_menuAttrib; 545 data->menu_list_data->Attr = (MfwMnuAttr*)&Freq_menuAttrib;
548 data->menu_list_data->autoDestroy = FALSE; 546 data->menu_list_data->autoDestroy = FALSE;
549 547
550 /* Create the dynamic menu window */ 548 /* Create the dynamic menu window */
551 listDisplayListMenu(win, data->menu_list_data,(ListCbFunc)mmi_band_freq_list_cb,0); 549 listDisplayListMenu(win, data->menu_list_data,(ListCbFunc)mmi_band_freq_list_cb,0);
552 } 550 }
553 else /* We haven't been able to read the status */ 551 else /* We haven't been able to read the status */
554 { 552 {
555 ShowMessage(win, TxtReadError, TxtNull); 553 ShowMessage(win, TxtReadError, TxtNull);
556 } 554 }
557 555
558 break; 556 break;
559 557
560 case BAND_DESTROY: 558 case BAND_DESTROY:
561 TRACE_EVENT("mmi_band_freq_exec_cb() Event:BAND_DESTROY"); 559 TRACE_EVENT("mmi_band_freq_exec_cb() Event:BAND_DESTROY");
562 /* 560 /*
563 * Free Memory 561 * Free Memory
564 */ 562 */
565 563
566 /* SPR#998 - SH - No longer free allocated strings here */ 564 /* SPR#998 - SH - No longer free allocated strings here */
567 565
568 numberOfEntries = data->no_of_entries; 566 numberOfEntries = data->no_of_entries;
569 567
570 if (data->menu_list_data != NULL) 568 if (data->menu_list_data != NULL)
571 { 569 {
572 FREE_MEMORY ((void *)data->menu_list_data->List, numberOfEntries * sizeof (T_MFW_MNU_ITEM)); 570 FREE_MEMORY ((void *)data->menu_list_data->List, numberOfEntries * sizeof (T_MFW_MNU_ITEM));
573 FREE_MEMORY ((void *)data->menu_list_data, sizeof (ListMenuData)); 571 FREE_MEMORY ((void *)data->menu_list_data, sizeof (ListMenuData));
574 } 572 }
575 573
576 FREE_MEMORY ((void *)data, sizeof (T_FREQ_INFO)); 574 FREE_MEMORY ((void *)data, sizeof (T_FREQ_INFO));
577 break; 575 break;
578 576
579 default: 577 default:
580 break; 578 break;
581 } 579 }
582 } 580 }
583 581
584 582
585 /******************************************************************************* 583 /*******************************************************************************
586 584
587 $Function: mmi_band_freq_list_cb 585 $Function: mmi_band_freq_list_cb
588 586
589 $Description: Callback function for the info num list. 587 $Description: Callback function for the info num list.
590 588
591 $Returns: none 589 $Returns: none
592 590
593 $Arguments: Parent - parent window. 591 $Arguments: Parent - parent window.
594 ListData - Menu item list 592 ListData - Menu item list
595 *******************************************************************************/ 593 *******************************************************************************/
596 594
597 void mmi_band_freq_list_cb(T_MFW_HND * Parent, ListMenuData * ListData) 595 void mmi_band_freq_list_cb(T_MFW_HND * Parent, ListMenuData * ListData)
598 { 596 {
599 /* SPR#998 - SH - Selecting a checkbox is handled now by the checkbox functions, 597 /* SPR#998 - SH - Selecting a checkbox is handled now by the checkbox functions,
600 * so much less is required here */ 598 * so much less is required here */
601 599
602 T_MFW_WIN *win_data = ((T_MFW_HDR *)Parent)->data; 600 T_MFW_WIN *win_data = ((T_MFW_HDR *)Parent)->data;
603 T_FREQ_INFO *data = (T_FREQ_INFO *)win_data->user; 601 T_FREQ_INFO *data = (T_FREQ_INFO *)win_data->user;
604 602
605 TRACE_FUNCTION("mmi_band_freq_list_cb"); 603 TRACE_FUNCTION("mmi_band_freq_list_cb");
606 604
607 if ((ListData->Reason EQ LISTS_REASON_BACK) || (ListData->Reason EQ LISTS_REASON_CLEAR)) 605 if ((ListData->Reason EQ LISTS_REASON_BACK) || (ListData->Reason EQ LISTS_REASON_CLEAR))
608 { 606 {
609 listsDestroy(ListData->win); 607 listsDestroy(ListData->win);
610 mmi_band_freq_list_destroy(data->freq_win); 608 mmi_band_freq_list_destroy(data->freq_win);
611 } 609 }
612 else if(ListData->Reason EQ LISTS_REASON_SELECT) 610 else if(ListData->Reason EQ LISTS_REASON_SELECT)
613 { 611 {
614 winShow(Parent); 612 winShow(Parent);
615 } 613 }
616 } 614 }
617 615
618 616
619 /******************************************************************************* 617 /*******************************************************************************
620 618
621 $Function: mmi_band_freq_list_destroy 619 $Function: mmi_band_freq_list_destroy
622 620
623 $Description: Destroy the info num window. 621 $Description: Destroy the info num window.
624 622
625 $Returns: none 623 $Returns: none
626 624
627 $Arguments: own_window- current window 625 $Arguments: own_window- current window
628 *******************************************************************************/ 626 *******************************************************************************/
629 627
630 static void mmi_band_freq_list_destroy(MfwHnd own_window) 628 static void mmi_band_freq_list_destroy(MfwHnd own_window)
631 { 629 {
632 T_MFW_WIN *win_data; 630 T_MFW_WIN *win_data;
633 T_FREQ_INFO *data; 631 T_FREQ_INFO *data;
634 632
635 TRACE_FUNCTION ("mmi_band_freq_list_destroy()"); 633 TRACE_FUNCTION ("mmi_band_freq_list_destroy()");
636 634
637 if (own_window) 635 if (own_window)
638 { 636 {
639 win_data = ((T_MFW_HDR *)own_window)->data; 637 win_data = ((T_MFW_HDR *)own_window)->data;
640 data = (T_FREQ_INFO *)win_data->user; 638 data = (T_FREQ_INFO *)win_data->user;
641 639
642 if (data) 640 if (data)
643 { 641 {
644 /* 642 /*
645 * Free Memory 643 * Free Memory
646 */ 644 */
647 SEND_EVENT (own_window, BAND_DESTROY, 0, 0); 645 SEND_EVENT (own_window, BAND_DESTROY, 0, 0);
648 /* 646 /*
649 * Delete WIN handler 647 * Delete WIN handler
650 */ 648 */
651 win_delete (own_window); 649 win_delete (own_window);
652 650
653 current_data = NULL; /* SPR#998 - SH - Set the data handle to NULL */ 651 current_data = NULL; /* SPR#998 - SH - Set the data handle to NULL */
654 } 652 }
655 else 653 else
656 { 654 {
657 TRACE_EVENT ("mmi_band_freq_list_destroy() called twice"); 655 TRACE_EVENT ("mmi_band_freq_list_destroy() called twice");
658 } 656 }
659 } 657 }
660 } 658 }
661 659
662 660
663 /******************************************************************************* 661 /*******************************************************************************
664 662
665 $Function: mmi_band_freq_win_cb 663 $Function: mmi_band_freq_win_cb
666 664
667 $Description: Window callback function for the info numbers window. 665 $Description: Window callback function for the info numbers window.
668 666
669 $Returns: none 667 $Returns: none
670 668
671 $Arguments: w - mfw window handler 669 $Arguments: w - mfw window handler
672 e - mfw event 670 e - mfw event
673 671
674 *******************************************************************************/ 672 *******************************************************************************/
675 673
676 static int mmi_band_freq_win_cb (MfwEvt e, MfwWin *w) /* yyy window event handler */ 674 static int mmi_band_freq_win_cb (MfwEvt e, MfwWin *w) /* yyy window event handler */
677 { 675 {
678 TRACE_FUNCTION ("mmi_band_freq_win_cb()"); 676 TRACE_FUNCTION ("mmi_band_freq_win_cb()");
679 switch (e) 677 switch (e)
680 { 678 {
681 case MfwWinVisible: /* window is visible */ 679 case MfwWinVisible: /* window is visible */
682 break; 680 break;
683 case MfwWinFocussed: /* input focus / selected */ 681 case MfwWinFocussed: /* input focus / selected */
684 case MfwWinDelete: /* window will be deleted */ 682 case MfwWinDelete: /* window will be deleted */
685 683
686 default: 684 default:
687 return MFW_EVENT_REJECTED; 685 return MFW_EVENT_REJECTED;
688 } 686 }
689 return MFW_EVENT_CONSUMED; 687 return MFW_EVENT_CONSUMED;
690 } 688 }
691
692 689
693 690
694 /******************************************************************************* 691 /*******************************************************************************
695 692
696 $Function: mmi_band_menu_func 693 $Function: mmi_band_menu_func
697 694
698 $Description: SPR#998 - SH - Added 695 $Description: SPR#998 - SH - Added
699 Select or deselect a checkbox item. The appropriate band function is 696 Select or deselect a checkbox item. The appropriate band function is
700 called, to ensure that the selection is valid. 697 called, to ensure that the selection is valid.
701 698
702 $Returns: None. 699 $Returns: None.
703 700
704 $Arguments: m, ma, mi - not used 701 $Arguments: m, ma, mi - not used
705 702
707 704
708 int mmi_band_menu_func(MfwMnu* menu, MfwMnuItem* item) 705 int mmi_band_menu_func(MfwMnu* menu, MfwMnuItem* item)
709 { 706 {
710 T_FREQ_INFO *data = current_data; 707 T_FREQ_INFO *data = current_data;
711 708
712 TRACE_FUNCTION("mmi_band_menu_func"); 709 TRACE_FUNCTION("mmi_band_menu_func");
713 710
714 data->selected_freqs ^= data->type[menu->lCursor[menu->level]]; /* Toggle this band */ 711 data->selected_freqs ^= data->type[menu->lCursor[menu->level]]; /* Toggle this band */
715 712
716 if (band_radio_mode_switch(MFW_BAND_MODE_Manual, data->selected_freqs) >= MFW_BAND_OK) 713 if (band_radio_mode_switch(MFW_BAND_MODE_Manual, data->selected_freqs) >= MFW_BAND_OK)
717 { 714 {
718 mnuUpdate(menu); 715 mnuUpdate(menu);
719 } 716 }
720 else 717 else
721 { 718 {
722 data->selected_freqs ^= data->type[menu->lCursor[menu->level]]; /* Undo change */ 719 data->selected_freqs ^= data->type[menu->lCursor[menu->level]]; /* Undo change */
723 ShowMessage(data->freq_win, TxtFailed, TxtNull); 720 ShowMessage(data->freq_win, TxtFailed, TxtNull);
724 } 721 }
725 722
726 return 1; 723 return 1;
727 } 724 }
728 725
729 726
730 /******************************************************************************* 727 /*******************************************************************************
731 728
739 736
740 *******************************************************************************/ 737 *******************************************************************************/
741 738
742 USHORT mmi_band_menu_flag( struct MfwMnuTag *menu, struct MfwMnuAttrTag *attr, struct MfwMnuItemTag *item ) 739 USHORT mmi_band_menu_flag( struct MfwMnuTag *menu, struct MfwMnuAttrTag *attr, struct MfwMnuItemTag *item )
743 { 740 {
744 T_FREQ_INFO *data = current_data; /* SPR#998 - SH - Get data from static handle */ 741 T_FREQ_INFO *data = current_data; /* SPR#998 - SH - Get data from static handle */
745 int currentOption; 742 int currentOption;
746 743
747 TRACE_FUNCTION("mmi_band_menu_flag()"); 744 TRACE_FUNCTION("mmi_band_menu_flag()");
748 TRACE_EVENT_P1("Freq info data: %x", data); 745 TRACE_EVENT_P1("Freq info data: %x", data);
749 746
750 /* Identify current menu option */ 747 /* Identify current menu option */
751 748
752 currentOption = mnuIdentify(attr, item); 749 currentOption = mnuIdentify(attr, item);
753 750
754 /* If we find it, work out if it's checked or not */ 751 /* If we find it, work out if it's checked or not */
755 752
756 if (currentOption>-1) 753 if (currentOption>-1)
757 { 754 {
758 if (data->selected_freqs & data->type[currentOption]) 755 if (data->selected_freqs & data->type[currentOption])
759 return MNU_ITEM_CHECKED; 756 return MNU_ITEM_CHECKED;
760 else 757 else
761 return MNU_ITEM_UNCHECKED; 758 return MNU_ITEM_UNCHECKED;
762 } 759 }
763 return 0; 760 return 0;
764 } 761 }
765