comparison src/aci2/bmi/AUIPinEditor.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*******************************************************************************
2
3 CONDAT (UK)
4
5 ********************************************************************************
6
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.
9
10 ********************************************************************************
11
12 $Project name: Basic MMI
13 $Project code: BMI (6349)
14 $Module: MMI
15 $File: AUIPinEditor.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 22/02/01
20
21 ********************************************************************************
22
23 Description: Editor for PIN entry
24
25
26 ********************************************************************************
27
28 $History: AUIPinEditor.c
29
30 July 09, 2005 REF : MMI - 22565 - a0876501
31 Description: Proper display of IMEI with CD byte.
32 Solution: Increased the IMEI length from 16 to 18.
33
34 June 16, 2005 REF: CRR 31267 x0021334
35 Description: Handset ignore the initializtion of the PIN1/PIN2
36 Fix: Cheking is done to ascertain if PIN1/PIN2 are initialised. If not, appropriate
37 message is displayed to the user.
38
39 May 02, 2005 REF : LOCOSTO-ENH-30818 - xpradipg
40 Description: IMEI retreival by posting a call to ACI sAT_xx API
41 Solution: The direct call to cl_get_imeisv() is replaced with the
42 call to the mmi_imei_retrieve() which inturn calls sAT_Dn() and
43 retrieves the IMEI info and stores it onto the global
44 variable "imei"
45 14/11/02 Original Condat(UK) BMI version.
46 $End
47
48 *******************************************************************************/
49
50 #define ENTITY_MFW
51
52 /* includes */
53 #include <string.h>
54 #include <stdio.h>
55 #include <stdlib.h>
56
57 #if defined (NEW_FRAME)
58
59 #include "typedefs.h"
60 #include "vsi.h"
61 #include "pei.h"
62 #include "custom.h"
63 #include "gsm.h"
64
65 #else
66
67 #include "STDDEFS.H"
68 #include "custom.h"
69 #include "gsm.h"
70 #include "vsi.h"
71
72 #endif
73
74 #include "mfw_mfw.h"
75 #include "mfw_win.h"
76 #include "mfw_kbd.h"
77 #include "mfw_tim.h"
78 #include "mfw_phb.h"
79 #include "mfw_sms.h"
80 #include "mfw_ss.h"
81 #include "mfw_icn.h"
82 #include "mfw_mnu.h"
83 #include "mfw_lng.h"
84 #include "mfw_sat.h"
85 #include "mfw_kbd.h"
86 #include "mfw_nm.h"
87 #include "mfw_cm.h"
88 #include "mfw_sim.h"
89 #include "mfw_ssi.h"
90
91 #include "dspl.h"
92
93 #include "ksd.h"
94 #include "psa.h"
95
96 #include "MmiDummy.h"
97 #include "MmiMmi.h"
98
99 #include "MmiDialogs.h"
100 #include "MmiLists.h"
101 #include "MmiMenu.h"
102 #include "MmiSoftKeys.h"
103 #include "MmiIdle.h"
104 #include "MmiResources.h"
105
106 #include "cus_aci.h"
107 #include "prim.h"
108 #ifndef PCM_2_FFS
109 #include "pcm.h"
110 #endif
111
112
113 #include "mmiColours.h"
114
115 #include "ATBCommon.h"
116 #include "ATBDisplay.h"
117 #include "ATBEditor.h"
118 #include "AUIEditor.h"
119 #include "AUITextEntry.h"
120
121 #include "AUIPinEditor.h"
122
123 //Nov 17, 2005 REF : OMAPS00045901 - a0876501
124 #define IMEI_DISP_LEN 18 /* IMEI display now includes CD byte. Hence the size has been increased from 16 to 18 */
125
126 typedef struct
127 {
128 T_MMI_CONTROL mmi_control;
129 T_MFW_HND parent; // The parent window
130 T_MFW_HND win; // The edit window
131 T_MFW_HND kbd; // The keyboard handler
132 T_MFW_HND kbd_long; // The longpress keyboard handler
133 T_MFW_HND timer; // The timer for timeouts
134
135 T_ED_DATA *editor; /* The ATB editor */
136 T_AUI_EDITOR_DATA editor_data; /* The MMI editor data, provided by caller */
137 T_AUI_ENTRY_DATA *entry_data; /* The MMI text entry data */
138
139 BOOL haveTitle; /* TRUE if a title is supplied */
140 T_ATB_TEXT title; /* Title of editor */
141
142 BOOL hidden;
143
144 BOOL doNextLongPress; /* Flag used to notice/not notice long keypress */
145 BOOL enteredMinChars; /* Set to TRUE when at least min_enter characters have been entered */
146 BOOL enteredSomeChars; /* Set to TRUE if the length of the entered data is non-zero */
147 UBYTE emergency_call; /* Set to TRUE if number is an emergency call number */
148 UBYTE ss_string;
149 char imei[IMEI_DISP_LEN];/* IMEI display now includes CD byte. Hence the size has been increased from 16 to 18 */
150 }
151 T_AUI_PIN_DATA;
152
153 #define AUI_MAX_PIN 16
154
155 // June 16, 2005 REF: CRR 31267 x0021334
156 extern BOOL pin1Flag; // This flag will be needed here
157
158 typedef struct
159 {
160 U8 pin_id;
161 char puk_code[AUI_MAX_PIN + 1];
162 char new_pin[AUI_MAX_PIN + 1];
163 char cnf_pin[AUI_MAX_PIN + 1];
164 }
165 T_AUI_PINS;
166 /* LOCAL FUNCTION PROTOTYPES */
167 static T_MFW_HND AUI_pin_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data);
168 static void AUI_pin_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
169 static int AUI_pin_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data);
170 static int AUI_pin_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard);
171 static int AUI_pin_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard);
172 static UBYTE AUI_pin_CheckEmergency(T_AUI_PIN_DATA *data);
173 T_MFW_SS_RETURN AUI_pin_CheckSSString(T_AUI_PIN_DATA *data);
174 static BOOL AUI_pin_StripSSUnblock(char *cmd_string, T_AUI_PINS *pin_data);
175
176
177
178
179 /*******************************************************************************
180
181 $Function: AUI_pin_Start
182
183 $Description: Start the PIN editor.
184
185 $Returns: None.
186
187 $Arguments: None.
188
189 *******************************************************************************/
190
191 T_MFW_HND AUI_pin_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
192 {
193 T_MFW_HND win;
194
195 TRACE_FUNCTION ("AUI_pin_Start()");
196
197 win = AUI_pin_Create(parent, editor_data);
198
199 return win;
200 }
201
202
203 /*******************************************************************************
204
205 $Function: AUI_pin_Create
206
207 $Description: Create the PIN editor.
208
209 $Returns: Pointer to the editor's window.
210
211 $Arguments: parent - The parent window.
212
213 *******************************************************************************/
214
215 static T_MFW_HND AUI_pin_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
216 {
217 T_AUI_PIN_DATA *data;
218 T_MFW_WIN *win_data;
219
220 TRACE_FUNCTION ("AUI_pin_Create()");
221 TRACE_EVENT_P1("Memory left (start): %d", mfwCheckMemoryLeft());
222
223 data = (T_AUI_PIN_DATA *)ALLOC_MEMORY(sizeof (T_AUI_PIN_DATA));
224 TRACE_EVENT_P1("Memory left (data): %d", mfwCheckMemoryLeft());
225
226 /* Create window handler */
227
228 data->win = win_create(parent, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_pin_WinCb); // Create window
229 TRACE_EVENT_P1("Memory left (win): %d", mfwCheckMemoryLeft());
230
231 if (data->win==NULL) // Make sure window exists
232 {
233 return NULL;
234 }
235
236 /* Connect the dialog data to the MFW-window */
237
238 data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_pin_ExecCb; /* Setup the destination for events */
239 data->mmi_control.data = data;
240 data->parent = parent;
241 win_data = ((T_MFW_HDR *)data->win)->data;
242 win_data->user = (void *)data;
243
244 data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_pin_KbdCb);
245 data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_pin_KbdLongCb);
246 data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0);
247 TRACE_EVENT_P1("Memory left (editor): %d", mfwCheckMemoryLeft());
248 data->editor_data = *editor_data;
249 data->entry_data = AUI_entry_Create(data->win, data->editor, E_PIN_UPDATE);
250 TRACE_EVENT_P1("Memory left (entry): %d", mfwCheckMemoryLeft());
251 SEND_EVENT(data->win, E_PIN_INIT, 0, 0);
252
253 /* Return window handle */
254
255 return data->win;
256 }
257
258
259 /*******************************************************************************
260
261 $Function: AUI_pin_Destroy
262
263 $Description: Destroy the PIN editor.
264
265 $Returns: None.
266
267 $Arguments: window - The editor window.
268
269 *******************************************************************************/
270
271 void AUI_pin_Destroy(T_MFW_HND win)
272 {
273 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
274 T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
275
276 TRACE_FUNCTION("AUI_pin_Destroy");
277 TRACE_EVENT_P1("Memory left at start: %d", mfwCheckMemoryLeft());
278 if (data)
279 {
280 /* Free memory allocated for title */
281
282 if (data->haveTitle)
283 {
284 FREE_MEMORY(data->title.data, (data->title.len+1)*ATB_string_Size(&data->title));
285 TRACE_EVENT_P1("Memory left (title dest): %d", mfwCheckMemoryLeft());
286 }
287
288 /* Free text entry memory */
289
290 AUI_entry_Destroy(data->entry_data);
291 TRACE_EVENT_P1("Memory left (entry dest): %d", mfwCheckMemoryLeft());
292 /* Delete window */
293
294 win_delete (data->win);
295 TRACE_EVENT_P1("Memory left (win dest): %d", mfwCheckMemoryLeft());
296 /* Free editor memory */
297
298 ATB_edit_Destroy(data->editor);
299 TRACE_EVENT_P1("Memory left (editor dest): %d", mfwCheckMemoryLeft());
300 /* Free Memory */
301
302 FREE_MEMORY ((void *)data, sizeof (T_AUI_PIN_DATA));
303 TRACE_EVENT_P1("Memory left (data dest): %d", mfwCheckMemoryLeft());
304 }
305
306 return;
307 }
308
309
310 /*******************************************************************************
311
312 $Function: AUI_pin_ExecCb
313
314 $Description: Dialog function for PIN editor.
315
316 $Returns: None.
317
318 $Arguments: None.
319
320 *******************************************************************************/
321
322 static void AUI_pin_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter)
323 {
324 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
325 T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
326 T_MFW_HND parent_win = data->parent;
327 T_ATB_TEXT text;
328 /* Store these in case editor is destroyed on callback */
329 USHORT Identifier = data->editor_data.Identifier;
330 T_AUI_EDIT_CB Callback = data->editor_data.Callback;
331 UBYTE destroyEditor = data->editor_data.destroyEditor;
332 T_AUI_PINS *pin_unblock_data;
333
334 TRACE_FUNCTION ("AUI_pin_ExecCb()");
335
336 switch (event)
337 {
338 /* Initialise */
339
340 case E_PIN_INIT:
341 TRACE_EVENT("E_PIN_INIT");
342 ATB_edit_Init(data->editor);
343
344 data->haveTitle = FALSE;
345
346 /* If we require an output line, shrink editor to fit it at bottom
347 * NB TitleString is assumed here to be a numeric string of ascii digits */
348
349 if (data->editor_data.TitleString)
350 {
351 data->haveTitle = TRUE;
352 text.data = data->editor_data.TitleString;
353 }
354
355 /* Set up title */
356
357 if (data->editor_data.TitleId!=NULL)
358 {
359 data->haveTitle = TRUE;
360 text.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId);
361 }
362
363 /* If title exists, get its dcs and length */
364
365 if (data->haveTitle)
366 {
367 if (text.data[0]==0x80)
368 {
369 text.data += 2; /* Skip over two unicode indicator bytes */
370 text.dcs = ATB_DCS_UNICODE;
371 }
372 #ifdef EASY_TEXT_ENABLED
373 else if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
374 {
375 text.dcs = ATB_DCS_UNICODE;
376 }
377 #endif
378 else
379 {
380 text.dcs = ATB_DCS_ASCII;
381 }
382
383 text.len = ATB_string_Length(&text);
384 /* Allocate memory for the title and copy the text there */
385 data->title.data = (UBYTE *)ALLOC_MEMORY((text.len+1)*ATB_string_Size(&text));
386 TRACE_EVENT_P1("Memory left (title): %d", mfwCheckMemoryLeft());
387 ATB_string_Copy(&data->title, &text);
388 }
389
390 /* Set flag if min_enter characters are in buffer */
391
392 if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
393 data->enteredMinChars = TRUE;
394 else
395 data->enteredMinChars = FALSE;
396
397 /* Set flag if some characters are in the buffer */
398 if (data->editor_data.editor_attr.text.len > 0 )
399 data->enteredSomeChars = TRUE;
400 else
401 data->enteredSomeChars = FALSE;
402
403 /* Show the window */
404 win_show(data->win);
405 break;
406
407 case E_PIN_UPDATE:
408 TRACE_EVENT("E_PIN_UPDATE");
409 win_show(data->win);
410 break;
411
412 case E_PIN_DEINIT:
413 TRACE_EVENT("E_PIN_DEINIT");
414
415 if (Callback)
416 (Callback) (parent_win, Identifier, value);
417
418 if (destroyEditor)
419 AUI_pin_Destroy(data->win);
420
421 break;
422
423 case E_PUK1_COMPLETE:
424 TRACE_EVENT("E_PIN_COMPLETE");
425
426 pin_unblock_data = (T_AUI_PINS *)parameter;
427
428 sim_unblock_pin(pin_unblock_data->pin_id,
429 pin_unblock_data->puk_code,
430 pin_unblock_data->new_pin); /* unblock pin1 */
431
432 if (destroyEditor)
433 AUI_pin_Destroy(data->win);
434
435 break;
436
437 }
438
439 return;
440 }
441
442 /*******************************************************************************
443
444 $Function: AUI_pin_WinCb
445
446 $Description: PIN editor window event handler.
447
448 $Returns: None.
449
450 $Arguments: event - the event
451 win - the editor window
452
453 *******************************************************************************/
454
455 static int AUI_pin_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data)
456 {
457 T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
458 T_ED_DATA *editor = data->editor;
459 T_ATB_WIN_SIZE *win_size = &data->editor->attr->win_size;
460 T_ATB_TEXT text;
461 T_DS_TEXTFORMAT format;
462 // USHORT titleLen; // RAVI
463
464 if (!data)
465 return MFW_EVENT_CONSUMED;
466
467 switch(event)
468 {
469 case E_WIN_VISIBLE: /* window is visible */
470 if (win_data->flags & E_WIN_VISIBLE)
471 {
472 if (editor->update==ED_UPDATE_TRIVIAL)
473 {
474 TRACE_EVENT("Only updating editor.");
475 ATB_edit_Show(data->editor);
476 }
477 else
478 {
479 TRACE_EVENT("Updating whole screen.");
480
481 ATB_edit_Show(data->editor);
482
483 /* Set the colour for drawing title */
484
485 resources_setTitleColour(COLOUR_EDITOR);
486
487 /* TITLE - only display if update type is FULL or DEFAULT*/
488
489 if (editor->update!=ED_UPDATE_PARTIAL)
490 {
491 dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1);
492
493 if (data->haveTitle)
494 {
495 ATB_display_SetFormatAttr(&format, 0, FALSE);
496
497 /* Display "Emergency?" prompt in title if emergency call */
498 if (data->emergency_call)
499 {
500 text.dcs = data->title.dcs;
501 text.data = (UBYTE *)MmiRsrcGetText(TxtEmergency);
502 text.len = ATB_string_Length(&text);
503 ATB_display_Text(0,0,&format, &text);
504 }
505 /* Otherwise, show title */
506 else
507 {
508 ATB_display_Text(0,0,&format, &data->title);
509 }
510 }
511 }
512
513 /* Display Soft Keys */
514
515 if (data->emergency_call)
516 {
517 displaySoftKeys(TxtSoftCall, data->editor_data.RightSoftKey);
518 }
519 else
520 {
521 if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter)
522 {
523 /* entered less than the required number of chars: Alternate Softkey appears */
524 if (data->editor_data.editor_attr.text.len > 0)
525 displaySoftKeys(data->editor_data.AltLeftSoftKey,data->editor_data.RightSoftKey);
526 else
527 displaySoftKeys(data->editor_data.AltLeftSoftKey,TxtNull);
528 }
529 else
530 {
531 /* entered sufficient number of chars: Normal Softkey appears */
532
533 if (data->editor_data.editor_attr.text.len > 0)
534 displaySoftKeys(data->editor_data.LeftSoftKey,data->editor_data.RightSoftKey);
535 else
536 displaySoftKeys(data->editor_data.LeftSoftKey, TxtNull);
537 }
538 }
539 }
540 }
541 break;
542 }
543
544 data->editor->update = ED_UPDATE_DEFAULT;
545
546 return;
547 }
548
549
550 /*******************************************************************************
551
552 $Function: AUI_pin_KbdCb
553
554 $Description: PIN editor keyboard event handler
555
556 $Returns: None.
557
558 $Arguments: event - the keyboard event
559 keyboard
560
561 *******************************************************************************/
562
563 static int AUI_pin_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
564 {
565 T_MFW_HND win = mfw_parent (mfw_header());
566 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
567 T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
568 // ED_RES result; // RAVI
569 UBYTE *edit_data_buf;
570 BOOL bRetVal;
571 T_AUI_PINS pin_unblock_data;
572 T_DISPLAY_DATA display_info;
573
574 TRACE_FUNCTION("AUI_pin_KbdCb()");
575
576 /* Suppress unwanted long keypresses */
577
578 data->doNextLongPress = TRUE; /* next Key_long event is correct */
579 data->editor->update = ED_UPDATE_DEFAULT; /* Default behaviour is just to update text */
580
581 switch (keyboard->code)
582 {
583 case KCD_STAR:
584 /* Only possible when the first digit is a '*' */
585 if ((data->editor_data.editor_attr.text.len==0) ||
586 (data->ss_string))
587 {
588 if (data->editor_data.editor_attr.text.len==0)
589 {
590 data->hidden = FALSE;
591 data->ss_string = TRUE;
592 /* The string should now be visible on screen */
593 if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
594 {
595 data->hidden = TRUE;
596 ATB_edit_ResetMode(data->editor, ED_MODE_HIDDEN);
597 }
598 }
599
600 AUI_entry_EventKey(data->entry_data, event, keyboard);
601 win_show(data->win);
602 }
603 break;
604
605 case KCD_HASH:
606 /* Send SS string if we're entering one */
607 if(data->ss_string)
608 {
609 AUI_entry_EventKey(data->entry_data, event, keyboard);
610
611 edit_data_buf = ALLOC_MEMORY(data->editor_data.editor_attr.size);
612
613 strcpy((char *)edit_data_buf, (char *)data->editor_data.editor_attr.text.data);
614
615 switch (AUI_pin_CheckSSString(data))
616 {
617 case MFW_SS_MMI:
618 // May 02, 2005 REF : LOCOSTO-ENH-30818 - xpradipg
619 // replace the call to get_imei() with callNumber
620 #ifdef FF_MMI_ATC_MIGRATION
621 mmi_imei_retrieve();
622 #else
623 get_imei((char*)data->imei);
624 showIMEI(win,(char*)data->imei);
625 #endif
626 ATB_edit_ClearAll(data->editor);
627
628 /* Set back to the default */
629 data->ss_string = FALSE;
630
631 if (data->hidden == TRUE)
632 {
633 /* go back in the hide mode */
634 ATB_edit_SetMode(data->editor, ED_MODE_HIDDEN);
635 }
636
637 FREE_MEMORY((void *)edit_data_buf, data->editor_data.editor_attr.size);
638 win_show(data->win);
639 return MFW_EVENT_CONSUMED;
640 // break; // RAVI
641
642 case MFW_SS_SIM_UNBLCK_PIN:
643 bRetVal = AUI_pin_StripSSUnblock((char *)edit_data_buf, &pin_unblock_data);
644
645 FREE_MEMORY((void *)edit_data_buf, data->editor_data.editor_attr.size);
646
647 if (bRetVal == FALSE)
648 {
649 /*
650 ** Clear the entered string, reset the editor and display a "failed" dialog
651 */
652 ATB_edit_ClearAll(data->editor);
653
654 /* Set back to the default */
655 data->ss_string = FALSE;
656
657 if (data->hidden == TRUE)
658 {
659 /* go back in the hide mode */
660 ATB_edit_SetMode(data->editor, ED_MODE_HIDDEN);
661 }
662
663 dlg_initDisplayData_TextId(&display_info, TxtNull, TxtNull, TxtFailed, TxtNull, COLOUR_POPUP);
664 dlg_initDisplayData_events(&display_info, NULL, THREE_SECS, 0);
665 info_dialog(0, &display_info);
666
667 }
668 else
669 {
670 SEND_EVENT (win, E_PUK1_COMPLETE, INFO_KCD_LEFT, &pin_unblock_data);
671 }
672
673 return MFW_EVENT_CONSUMED;
674 // break; // RAVI
675
676 default:
677 FREE_MEMORY((void *)edit_data_buf, data->editor_data.editor_attr.size);
678 break;
679 }
680 win_show(data->win);
681
682 }
683 else if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
684 {
685 if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
686 {
687 ATB_edit_HiddenExit(data->editor);
688 }
689 SEND_EVENT (win, E_PIN_DEINIT, INFO_KCD_LEFT, NULL);
690 }
691
692 break;
693
694 #ifdef COLOURDISPLAY
695 /* Menu select has same effect as left soft key */
696 case KCD_MNUSELECT:
697 #endif /* COLOURDISPLAY */
698
699 case KCD_LEFT:
700 /* Make an emergency call if an appropriate number entered */
701 if ( data->emergency_call )
702 {
703 /* Copy the actual typed text into the buffer */
704 if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
705 {
706 ATB_edit_HiddenExit(data->editor);
707 }
708 SEND_EVENT (win, E_PIN_DEINIT, INFO_EMERGENCY, NULL);
709 }
710 /* Submit PIN if sufficient characters entered */
711 else if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
712 {
713 // June 16, 2005 REF: CRR 31267 x0021334
714 // If PIN1/PUK1 =0, Show info dialog that SIM is blocked
715 if (pin1Flag EQ TRUE)
716 {
717 dlg_initDisplayData_TextId(&display_info, NULL, NULL, TxtSimBlocked, TxtDealer, COLOUR_STATUS);
718 dlg_initDisplayData_events(&display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_LEFT | KEY_RIGHT);
719 info_dialog (NULL, &display_info);
720 break;
721 }
722 /* Left Softkey is enabled (and entered sufficient number of chars): execute it. */
723 /* Copy the actual typed text into the buffer */
724 if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
725 {
726 ATB_edit_HiddenExit(data->editor);
727 }
728 SEND_EVENT (win, E_PIN_DEINIT, INFO_KCD_LEFT, NULL);
729 }
730 break;
731
732 case KCD_HUP:
733 break;
734
735 case KCD_CALL:
736 /* Make an emergency call if an appropriate number entered */
737 if ( data->emergency_call )
738 {
739 /* Copy the actual typed text into the buffer */
740 if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
741 {
742 ATB_edit_HiddenExit(data->editor);
743 }
744 SEND_EVENT (win, E_PIN_DEINIT, INFO_EMERGENCY, NULL);
745 }
746 break;
747
748 case KCD_RIGHT:
749 if(data->editor_data.editor_attr.text.len!=0)
750 {
751 ATB_edit_DeleteLeft(data->editor, TRUE); /* SPR#2342 - SH */
752
753 /* For a SS string */
754 if ( !ATB_edit_Mode(data->editor,ED_MODE_HIDDEN) )
755 {
756 if (data->editor_data.editor_attr.text.len==0 && data->ss_string)
757 {
758 data->ss_string = FALSE;
759 if (data->hidden == TRUE)
760 {
761 /* The string should not be visible on screen */
762 ATB_edit_SetMode(data->editor, ED_MODE_HIDDEN);
763 }
764 }
765 }
766
767 /* is it a emergency call number ?!*/
768 AUI_pin_CheckEmergency(data);
769 win_show(data->win);
770 }
771 break;
772
773 case KCD_0:
774 case KCD_1:
775 case KCD_2:
776 case KCD_3:
777 case KCD_4:
778 case KCD_5:
779 case KCD_6:
780 case KCD_7:
781 case KCD_8:
782 case KCD_9:
783 AUI_entry_EventKey(data->entry_data, event, keyboard);
784 /* is it a emergency call number ?!*/
785 AUI_pin_CheckEmergency(data);
786 win_show(data->win);
787 break;
788 }
789
790 return MFW_EVENT_CONSUMED;
791 }
792
793
794 /*******************************************************************************
795
796 $Function: AUI_pin_KbdLongCb
797
798 $Description: PIN editor long keypress keyboard event handler
799
800 $Returns: None.
801
802 $Arguments: event - the keyboard event
803 keyboard
804
805 *******************************************************************************/
806
807 static int AUI_pin_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
808 {
809 T_MFW_HND win = mfw_parent (mfw_header());
810 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
811 T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
812 ED_RES result;
813
814 /* Suppress unwanted long keypresses */
815
816 if ( data->doNextLongPress )
817 data->doNextLongPress = FALSE; /* mark Key_long event as consumed but do current long press */
818 else
819 return MFW_EVENT_CONSUMED; /* don't do current long press */
820
821 switch (keyboard->code)
822 {
823 case KCD_RIGHT:
824 /* Long press of RSK deletes buffer */
825 result = ATB_edit_ClearAll(data->editor);
826
827 /* If we've deleted on an empty buffer, exit editor */
828 if (result==ED_DONE)
829 {
830 SEND_EVENT(data->win, E_PIN_DEINIT, INFO_KCD_RIGHT, 0);
831 }
832 else
833 {
834 win_show(data->win);
835 }
836 break;
837 }
838
839 return MFW_EVENT_CONSUMED;
840
841 }
842
843
844 /*******************************************************************************
845
846 $Function: AUI_pin_CheckEmergency
847
848 $Description: Check number to see if it's an emergency number
849
850 $Returns: None.
851
852 $Arguments: data - The editor data
853
854 *******************************************************************************/
855
856 static UBYTE AUI_pin_CheckEmergency(T_AUI_PIN_DATA *data)
857 {
858 UBYTE previous_emergency = data->emergency_call;
859 UBYTE previous_entered = data->enteredMinChars;
860 UBYTE previous_someentered = data->enteredSomeChars;
861 UBYTE emergency_call;
862
863 /*SPR#2235 - DS - If the edit mode is 'hidden' then pass
864 *the 'hidden buffer' as the parameter to cm_check_emergency.
865 *If the edit mode is not 'hidden' then pass the normal editor
866 *text buffer as the parameter.
867 */
868 if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
869 emergency_call = cm_check_emergency(data->editor->hiddenText->data);
870 else
871 emergency_call = cm_check_emergency(data->editor_data.editor_attr.text.data);
872
873 if(emergency_call == TRUE)
874 {
875 TRACE_EVENT(" it is a emergency number !");
876 data->emergency_call = TRUE;
877 }
878 else
879 {
880 data->emergency_call = FALSE;
881 }
882
883 /* Check if we've entered min_enter characters */
884
885 if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
886 data->enteredMinChars = TRUE;
887 else
888 data->enteredMinChars = FALSE;
889
890 if (data->editor_data.editor_attr.text.len > 0)
891 data->enteredSomeChars = TRUE;
892 else
893 data->enteredSomeChars = FALSE;
894
895 /* Check if the softkeys have changed */
896
897 if (data->emergency_call!=previous_emergency)
898 {
899 data->editor->update = ED_UPDATE_FULL; /* Update softkeys, title and editor */
900 }
901 else if (data->enteredMinChars!=previous_entered || data->enteredSomeChars!=previous_someentered)
902 {
903 data->editor->update = ED_UPDATE_PARTIAL; /* Update softkeys and editor */
904 }
905 else
906 {
907 data->editor->update = ED_UPDATE_TRIVIAL; /* Just update editor */
908 }
909
910 return data->emergency_call;
911 }
912
913
914 /*******************************************************************************
915
916 $Function: AUI_pin_CheckSSString
917
918 $Description: Check number to see if it's an ss string
919
920 $Returns: None.
921
922 $Arguments: event - the keyboard event
923 keyboard
924
925 *******************************************************************************/
926
927 T_MFW_SS_RETURN AUI_pin_CheckSSString(T_AUI_PIN_DATA *data)
928 {
929 return ss_check_ss_string(data->editor_data.editor_attr.text.data);
930 }
931
932
933 static BOOL AUI_pin_StripSSUnblock(char *cmd_string, T_AUI_PINS *pin_data)
934 {
935 T_MFW_SS_RETURN retVal;
936 char *rest;
937 T_KSD_SEQPARAM ss_params;
938
939 TRACE_EVENT_P2("AUI_pin_StripSSUnblock : &cmd_string = 0x%08lx, &pin_data = 0x%08lx", cmd_string, pin_data);
940
941 /*
942 ** The incoming parameters chould not be NULL
943 */
944 if ((cmd_string == NULL) ||
945 (pin_data == NULL))
946 return FALSE;
947
948 retVal = ss_decode((UBYTE *)cmd_string, &rest, &ss_params);
949
950 if (retVal == MFW_SS_SIM_UNBLCK_PIN)
951 {
952 if (ss_params.ublk.ssCd == KSD_SS_PIN1)
953 {
954 pin_data->pin_id = MFW_SIM_PUK1;
955 strcpy(pin_data->puk_code, (char *)ss_params.ublk.puk);
956 strcpy(pin_data->new_pin, (char *)ss_params.ublk.pin);
957 strcpy(pin_data->cnf_pin, (char *)ss_params.ublk.pin);
958
959 return TRUE;
960 }
961 else
962 {
963 TRACE_EVENT("AUI_pin_StripSSUnblock : Not unblocking PIN1");
964 return FALSE;
965 }
966 }
967 else
968 {
969 TRACE_EVENT_P1("AUI_pin_StripSSUnblock : ss_decode returned %d", retVal);
970 return FALSE;
971 }
972 }
973