MHEG5  18.9.0
MHEG5 Documentation
mh5entryfield.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
30 /*---includes for this file--------------------------------------------------*/
31 #include "mh5entryfield.h"
32 #include "mh5scene.h"
33 #include "mh5object.h" /* for actions */
34 #include "mh5variable.h" /* for actions */
35 #include "mh5display.h" /* for actions */
36 #include "mh5application.h" /* Default Colour */
37 #include "mh5queue.h" /* Events */
38 #include "glue_memory.h" /*for constructor/destructor */
39 #include "glue_debug.h"
40 #include "mh5support.h"
41 #include "stb_os.h"
42 #include "glue_queue.h"
43 #include "glue_timers.h"
44 #include "mh5drawtext.h"
45 #include "mh5keypress.h"
46 
47 #ifdef MH5PRINTOUT
48 #include <string.h>
49 #endif
50 
51 /*---constant definitions for this file--------------------------------------*/
52 #define SMS_KEY_CYCLE_DELAY 1500
53 
54 /*---local typedef structs for this file-------------------------------------*/
55 
56 /*state information for SMS-style entry*/
57 typedef struct entry_state_s
58 {
66 
67 /*---local (static) variable declarations for this file----------------------*/
68 
69 /*list of the numeric-key mappings for SMS style entry*/
70 static MHEG5String SMS_map[10] = {
71  {4, (MHEG5Byte *)"&@_0"},
72  {11, (MHEG5Byte *)" .,-?!':;/1"},
73  {7, (MHEG5Byte *)"abcABC2"},
74  {7, (MHEG5Byte *)"defDEF3"},
75  {7, (MHEG5Byte *)"ghiGHI4"},
76  {7, (MHEG5Byte *)"jklJKL5"},
77  {7, (MHEG5Byte *)"mnoMNO6"},
78  {9, (MHEG5Byte *)"pqrsPQRS7"},
79  {7, (MHEG5Byte *)"tuvTUV8"},
80  {9, (MHEG5Byte *)"wxyzWXYZ9"}
81 };
82 
83 
84 /*profile-determined permitted character lists*/
85 #ifdef INCLUDE_IC
86 static const MHEG5String char_list_any = {76, (MHEG5Byte *)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&@_0 .,-?!':;/0123456789"};
87 
88 static const MHEG5String char_list_alpha = {52, (MHEG5Byte *)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
89 #endif /*INCLUDE_IC*/
90 static const MHEG5String char_list_numeric = {10, (MHEG5Byte *)"0123456789"};
91 
92 static entry_state_t entry_state;
93 
94 static H_Timer SMSTimer;
95 
96 /*---local function definitions----------------------------------------------*/
97 
98 /*---global function definitions---------------------------------------------*/
99 static char SMS_GetNextEnabledChar(MHEG5Entryfield *entryfield, int key);
100 static int SMS_CharsListedForKey(MHEG5Entryfield *entryfield, int key );
101 static void SMS_TimerCallback(BOOLEAN triggered, void *callerRef, H_Timer timerHandle);
102 
108 #ifdef MH5PRINTOUT
109 
110 void MHEG5entryfieldPrint(MHEG5Entryfield *entryfield, char *out)
111 {
112  MHEG5textPrint(&entryfield->text, out);
113  MHEG5interactiblePrint(&entryfield->interactible, out);
114  MHEG5indent(out);
115  MHEG5indent(out);
116  MHEG_PRINT(out, ":InputType ");
117  switch (entryfield->inputType)
118  {
119  case mh5alpha:
120  MHEG_PRINT(out, "Alpha");
121  break;
122  case mh5numeric:
123  MHEG_PRINT(out, "Numeric");
124  break;
125  case mh5any:
126  MHEG_PRINT(out, "Any");
127  break;
128  case mh5listed:
129  MHEG_PRINT(out, "Listed");
130  break;
131  default:
132  MHEG_PRINT(out, "Internal Error");
133  break;
134  }
135  MHEG5newLine(out);
136  MHEG5indent(out);
137  MHEG_PRINT(out, ":Charlist ");
138  MHEG5stringPrint(entryfield->charList, out);
139  MHEG5newLine(out);
140  MHEG5indent(out);
141  MHEG_PRINT(out, ":ObscuredInput ");
142  MHEG5boolPrint(entryfield->obscuredInput, out);
143  MHEG5newLine(out);
144  MHEG5indent(out);
145  MHEG_PRINT(out, ":Maxlength ");
146  MHEG5intPrint(entryfield->maxlength, out);
147  MHEG5newLine(out);
148  MHEG5indent(out);
149  MHEG_PRINT(out, ":OverwriteMode ");
150  MHEG5boolPrint(entryfield->overwriteMode, out);
151  MHEG5newLine(out);
152  MHEG5indent(out);
153  MHEG_PRINT(out, "// EntryPoint:\t");
154  MHEG5intPrint(entryfield->entryPoint, out);
155  MHEG5newLine(out);
156 }
157 
158 #endif
159 
166 static void MHEG5entryfieldAppend(MHEG5Entryfield *entryfield)
167 {
168  unsigned char *save;
169 
170  /* Keep the old data */
171  save = entryfield->text.visible.ingredient.data;
172 
173  /* Allocate memory for the new data (one char longer than previous) */
174  entryfield->text.visible.ingredient.data =
175  MHEG5getMem((entryfield->text.visible.ingredient.dataLen + 1) * sizeof(unsigned short));
176 
177  if (entryfield->text.visible.ingredient.data)
178  {
179  /* Memory allocate suceeded */
180 
181  /* Copy the old data into the new memory */
182  memcpy(entryfield->text.visible.ingredient.data,
183  save, entryfield->text.visible.ingredient.dataLen * sizeof(unsigned short));
184 
185  /* Indicate the new data length */
186  entryfield->text.visible.ingredient.dataLen++;
187 
188  if (entryfield->text.visible.ingredient.dataLen > 1)
189  {
190  /* Free off the old saved data */
191  MHEG5freeMem(save);
192  }
193  }
194  else
195  {
196  /* Memory allocate failed */
197 
198  /* Reuse the old (saved) data. Length of the entryfield is not increased
199  */
200  entryfield->text.visible.ingredient.data = save;
201  }
202 }
203 
211 void MHEG5entryfieldInsert(MHEG5Entryfield *entryfield, unsigned short c)
212 {
213  int i;
214  unsigned short *data;
215 
216  if ((entryfield->maxlength > 0) && (entryfield->entryPoint >= entryfield->maxlength))
217  {
218  return;
219  }
220 
221  if (entryfield->entryPoint < 0)
222  {
223  entryfield->entryPoint = 0;
224  }
225 
226  if (entryfield->entryPoint >= entryfield->text.visible.ingredient.dataLen)
227  {
228  entryfield->entryPoint = entryfield->text.visible.ingredient.dataLen;
229  }
230  else if (entryfield->overwriteMode)
231  {
232  data = (unsigned short *)entryfield->text.visible.ingredient.data;
233  data[entryfield->entryPoint] = c;
234  entryfield->entryPoint++;
235  return;
236  }
237 
238  if ((entryfield->maxlength > 0) && (entryfield->text.visible.ingredient.dataLen >= entryfield->maxlength))
239  {
240  /* No room to insert further characters into this entryfield */
241  return;
242  }
243 
244  /* Grow the length of the entryfield data by 1 character */
245  MHEG5entryfieldAppend(entryfield);
246 
247  /* Set pointer to the character data */
248  data = (unsigned short *)entryfield->text.visible.ingredient.data;
249 
250  /* Shuffle up all characters after the entry point (if any) */
251  for (i = entryfield->text.visible.ingredient.dataLen - 1; i > entryfield->entryPoint; i--)
252  {
253  data[i] = data[i - 1];
254  }
255 
256  /* Add the new character at the entry point */
257  data[entryfield->entryPoint] = c;
258  entryfield->entryPoint++;
259 }
260 
267 {
268  assert(entryfield);
269 
270  MHEG5textInit(&entryfield->text);
271  MHEG5interactibleInit(&entryfield->interactible);
272 }
273 
282 {
283  assert(entryfield);
284 
285  if (SMSTimer != NULL)
286  {
287  mhegTimerDestroy(SMSTimer);
288  SMSTimer = NULL;
289  }
290  MHEG5textFree(&entryfield->text);
291  MHEG5interactibleFree(&entryfield->interactible);
292 #ifdef INCLUDE_IC
293  switch (entryfield->inputType)
294  {
295  case mh5alpha:
296  case mh5any:
297  case mh5numeric:
298  break;
299  case mh5listed:
300  MHEG5stringDestruct(&entryfield->charList);
301  break;
302  default:
303  assert(0);
304  }
305 #endif /*INCLUDE_IC*/
306 }
307 
308 /*
309  Internal behaviours
310  */
311 
322 {
323  assert(entryfield);
325 
326  entryfield->entryPoint = 0;
327  entryfield->overwriteMode = MHEG5FALSE;
328 
329 #ifdef INCLUDE_IC
331  {
332  switch (entryfield->inputType)
333  {
334  case mh5alpha:
335  MHEG5stringDestruct(&entryfield->charList);
336  entryfield->charList = char_list_alpha;
337  break;
338  case mh5any:
339  MHEG5stringDestruct(&entryfield->charList);
340  entryfield->charList = char_list_any;
341  break;
342  case mh5listed:
343  break;
344  case mh5numeric:
345  MHEG5stringDestruct(&entryfield->charList);
346  entryfield->charList = char_list_numeric;
347  break;
348  default:
349  assert(0);
350  }
351  }
352  else
353 #endif /*INCLUDE_IC*/
354  { /* IC is not supported then just use numeric*/
355  MHEG5stringDestruct(&entryfield->charList);
356  entryfield->charList = char_list_numeric;
357  }
358  MHEG5textPrepare(&entryfield->text);
359 }
360 
370 {
371  assert(entryfield);
372  if (!entryfield->text.visible.ingredient.root.availabilityStatus)
373  {
374  MHEG5entryfieldPrepare(entryfield);
375  entryfield->entryPoint = 0;
376  entryfield->overwriteMode = MHEG5FALSE;
377  }
378  MHEG5textActivate(&entryfield->text);
379 }
380 
390 {
391  assert(entryfield);
392 
393  MHEG5textDeactivate(&entryfield->text);
394 
395  /* Apply deactivation behaviour inherrited from Interactible class */
397 }
398 
406 {
407  assert(entryfield);
408 
409  MHEG5textDestruct(&entryfield->text);
411 }
412 
413 /*
414  Actions
415  */
426 {
427  MHEG5Bool newMode;
428  MHEG5Entryfield *item;
429 
430  assert(target);
431 
432  if (target->clazz != MHEG5ENTRYFIELD)
433  {
434  return MHEG5ERR_WRONGTARGET;
435  }
436  if (!params)
437  {
439  }
440  item = (MHEG5Entryfield *) target;
441  MHEG5resolveGenericBoolean(params, &newMode);
442 
443  item->overwriteMode = newMode;
444 
445  MHEG5displayRedraw((MHEG5Visible *) target);
446 
447  return MHEG5ERR_NOERROR;
448 }
449 
460 {
461  MHEG5Root *boolVar = 0;
462  MHEG5BooleanVariable *rc = 0;
463  MHEG5Entryfield *item;
464 
465  assert(target);
466 
467  if (target->clazz != MHEG5ENTRYFIELD)
468  {
469  return MHEG5ERR_WRONGTARGET;
470  }
471  if (!params)
472  {
474  }
475  item = (MHEG5Entryfield *) target;
476  MHEG5resolveORef(params, &boolVar);
477  if (!boolVar)
478  {
479  return MHEG5ERR_WRONGPARAM;
480  }
481  if (boolVar->clazz != MHEG5BOOLEANVARIABLE)
482  {
483  return MHEG5ERR_WRONGPARAM;
484  }
485  if (!boolVar->runningStatus)
486  {
488  }
489  rc = (MHEG5BooleanVariable *)boolVar;
490  rc->value = item->overwriteMode;
491 
492  return MHEG5ERR_NOERROR;
493 }
494 
505 {
506  MHEG5Int newPoint;
507  MHEG5Entryfield *item;
508 
509  assert(target);
510 
511  if (target->clazz != MHEG5ENTRYFIELD)
512  {
513  return MHEG5ERR_WRONGTARGET;
514  }
515  if (!params)
516  {
518  }
519  item = (MHEG5Entryfield *) target;
520  MHEG5resolveGenericInteger(params, &newPoint);
521 
522  if (newPoint > item->text.visible.ingredient.dataLen)
523  {
524  newPoint = item->text.visible.ingredient.dataLen;
525  }
526  if (newPoint < 0)
527  {
528  newPoint = 0;
529  }
530  if (item->entryPoint != newPoint)
531  {
532  item->entryPoint = newPoint;
533 
535 
536  MHEG5displayRedraw((MHEG5Visible *) target);
537  }
538  return MHEG5ERR_NOERROR;
539 }
540 
551 {
552  MHEG5Root *intVar = 0;
553  MHEG5IntegerVariable *rc = 0;
554  MHEG5Entryfield *item;
555 
556  assert(target);
557 
558  if (target->clazz != MHEG5ENTRYFIELD)
559  {
560  return MHEG5ERR_WRONGTARGET;
561  }
562  if (!params)
563  {
565  }
566  item = (MHEG5Entryfield *) target;
567  MHEG5resolveORef(params, &intVar);
568  if (!intVar)
569  {
570  return MHEG5ERR_WRONGPARAM;
571  }
572  if (intVar->clazz != MHEG5INTEGERVARIABLE)
573  {
574  return MHEG5ERR_WRONGPARAM;
575  }
576  if (!intVar->runningStatus)
577  {
579  }
580  rc = (MHEG5IntegerVariable *)intVar;
581  rc->value = item->entryPoint;
582 
583  return MHEG5ERR_NOERROR;
584 }
585 
592 {
593  if (entryfield->entryPoint > entryfield->text.visible.ingredient.dataLen)
594  {
595  entryfield->entryPoint = entryfield->text.visible.ingredient.dataLen;
596  }
597 
598  if (entryfield->entryPoint > 0)
599  {
600  int i;
601  unsigned short *data;
602 
603  data = (unsigned short *)entryfield->text.visible.ingredient.data;
604 
605  for (i = entryfield->entryPoint; i < entryfield->text.visible.ingredient.dataLen; i++)
606  {
607  data[i - 1] = data[i];
608  }
609  entryfield->entryPoint--;
610  entryfield->text.visible.ingredient.dataLen--;
611 
612  if (entryfield->text.visible.ingredient.dataLen == 0)
613  {
614  /* Entry field is empty - free off the data */
615  MHEG5freeMem(entryfield->text.visible.ingredient.data);
616  entryfield->text.visible.ingredient.data = 0;
617  }
618  }
619 }
620 
627 {
628  if (entryfield->entryPoint > 0)
629  {
630  entryfield->entryPoint--;
631  }
632 }
633 
640 {
641  if (entryfield->entryPoint < entryfield->text.visible.ingredient.dataLen)
642  {
643  entryfield->entryPoint++;
644  }
645 }
646 
653 {
654  MHEG5Scene *scene;
655 
656  scene = MHEG5getCurrentScene();
657 
659  scene->currentInteractible = 0;
660 
661  MHEG5interactibleInteractionCompleted(&entryfield->interactible, (MHEG5Root *)entryfield);
662 }
663 
670 {
671  if (entryfield->text.visible.ingredient.dataLen)
672  {
673  entryfield->text.visible.ingredient.dataLen = 0;
674  MHEG5freeMem(entryfield->text.visible.ingredient.data);
675  }
676  entryfield->text.visible.ingredient.data = 0;
677  entryfield->entryPoint = 0;
678 }
679 
687 static void MHEG5entryfieldSMSEntry(MHEG5Entryfield *entryfield,
688  E_MHEG5_KEY ui, int key_number)
689 {
690  U32BIT current_time;
691  char next_char;
692  MHEG5Int current_position;
693 
694  assert( ui >= MHEG5_KEY_0 && ui <= MHEG5_KEY_9 );
695 
696  /*reset state if we have moved to another field*/
697  if (entry_state.entryfield != entryfield)
698  {
699  entry_state.entryfield = entryfield;
700  entry_state.state = chosen;
701  entry_state.current_key = (E_MHEG5_KEY)-1;
702  }
703  current_position = entryfield->text.visible.ingredient.dataLen;
704  /*stop the timer if it is running*/
705  if (SMSTimer != NULL)
706  {
707  mhegTimerDestroy(SMSTimer);
708  SMSTimer = NULL;
709  }
710  current_time = STB_OSGetClockMilliseconds();
711 
712  /*if the key pressed is the same as the last one, and it hasn't timed out*/
713  if (entry_state.current_key == ui &&
714  entry_state.state == choosing &&
715  entry_state.last_press_time + SMS_KEY_CYCLE_DELAY > current_time)
716  {
717  /*find the next listed character for the key*/
718  next_char = SMS_GetNextEnabledChar(entryfield, key_number);
719 
720  /*replace the previous character with the new one*/
721  if (!entryfield->overwriteMode)
722  {
723  MHEG5entryfieldBACKSPACE(entryfield);
724  }
725  else
726  {
727  MHEG5entryfieldLEFT(entryfield);
728  }
729  MHEG5entryfieldInsert(entryfield, next_char);
730  entry_state.previous_character = next_char;
731  }
732  else /*different key pressed or timed out*/
733  {
734  char backup_char = entry_state.previous_character;
735 
736  entry_state.current_key = ui;
737  entry_state.key_map_index = -1; /*reset the map index*/
738 
739  /*if there is space for new characters, go back to choosing*/
740  if (entryfield->overwriteMode ||
741  entryfield->maxlength == 0 ||
742  entryfield->maxlength > entryfield->text.visible.ingredient.dataLen)
743  {
744  entry_state.state = choosing;
745 
746  next_char = SMS_GetNextEnabledChar(entryfield, key_number);
747  if (next_char)
748  {
749  int char_count;
750  MHEG5entryfieldInsert(entryfield, next_char);
751  entry_state.previous_character = next_char;
752 
753  char_count = SMS_CharsListedForKey(entryfield, key_number);
754  if (char_count == 1) /*If the key has only one character listed*/
755  {
756  entry_state.state = chosen;
757  if (current_position < entryfield->maxlength &&
758  entryfield->maxlength > 0 &&
759  entryfield->text.visible.ingredient.dataLen >= entryfield->maxlength)
760  {
761  /* Entry point reached the end of the field - generate an
762  * EntryFieldFull event
763  */
764  MHEG5sendEvent((MHEG5Root *)entryfield, MHEG5ENTRYFIELDFULL, 0);
765  }
766  }
767  }
768  else
769  {
770  /*ignore keypress if no allowed characters associated with it*/
771  next_char = backup_char;
772  entry_state.state = chosen;
773  }
774  }
775  else
776  {
777  entry_state.previous_character = backup_char;
778  if (current_position < entryfield->maxlength &&
779  entryfield->maxlength > 0 &&
780  entryfield->text.visible.ingredient.dataLen >= entryfield->maxlength)
781  {
782  /* Entry point reached the end of the field - generate an
783  * EntryFieldFull event
784  */
785  MHEG5sendEvent((MHEG5Root *)entryfield, MHEG5ENTRYFIELDFULL, 0);
786  }
787  }
788  }
789 
790 
791  entry_state.last_press_time = current_time;
792 
793  if (entry_state.state == choosing)
794  {
795  /*start timer*/
796  mhegTimerCreate(SMS_KEY_CYCLE_DELAY, (F_TimerCallback)SMS_TimerCallback, (void *)entryfield, &SMSTimer);
797  }
798 }
799 
807 {
808  switch (ui)
809  {
810  /*numeric keys enter text into the field*/
811  case MHEG5_KEY_0:
812  case MHEG5_KEY_1:
813  case MHEG5_KEY_2:
814  case MHEG5_KEY_3:
815  case MHEG5_KEY_4:
816  case MHEG5_KEY_5:
817  case MHEG5_KEY_6:
818  case MHEG5_KEY_7:
819  case MHEG5_KEY_8:
820  case MHEG5_KEY_9:
821  MHEG5entryfieldSMSEntry(entryfield, ui, (int)ui - (int)MHEG5_KEY_0);
822  break;
823  /*control keys reset the SMS-entry state and do their action*/
824  case MHEG5_KEY_LEFT:
825  entry_state.state = chosen;
826  MHEG5entryfieldBACKSPACE(entryfield);
827  break;
828  case MHEG5_KEY_UP:
829  entry_state.state = chosen;
830  MHEG5entryfieldLEFT(entryfield);
831  break;
832  case MHEG5_KEY_DOWN:
833  case MHEG5_KEY_RIGHT:
834  entry_state.state = chosen;
835  MHEG5entryfieldRIGHT(entryfield);
836  break;
837  case MHEG5_KEY_CANCEL:
838  MHEG5entryfieldEXIT(entryfield);
839  /*drop through to perform SELECT action as well*/
840  case MHEG5_KEY_SELECT:
841  entry_state.state = chosen;
842  MHEG5entryfieldSELECT(entryfield);
843  break;
844  default:
845  /*other keys just reset the SMS-entry state*/
846  entry_state.state = chosen;
847  break;
848  }
849 
850  /*redraw*/
851  if (entry_state.state == chosen)
852  {
853  MHEG5drawEntry( entryfield, CURSOR_INSERT);
854  }
855  else
856  {
857  MHEG5drawEntry( entryfield, CURSOR_REPLACE);
858  }
859  MHEG5displayRedraw((MHEG5Visible *)entryfield );
860 }
861 
870 static char SMS_GetNextEnabledChar(MHEG5Entryfield *entryfield, int key)
871 {
872  MHEG5String *map_string;
873  MHEG5String *permitted_list;
874  char next_char = 0;
875  int idx;
876  int i, j;
877  MHEG5Bool found;
878 
879  map_string = &(SMS_map[key]);
880  permitted_list = &(entryfield->charList);
881 
882  /*start from the previous position in the map*/
883  idx = entry_state.key_map_index;
884 
885  /*loop through the key map*/
886  for (i = 0; i < map_string->len; i++)
887  {
888  idx++;
889  /*wrap around if we get to the end of the string*/
890  if (idx >= map_string->len)
891  {
892  idx = 0;
893  }
894 
895  /*search the permitted char list*/
896  found = FALSE;
897  for (j = 0; j < permitted_list->len; j++)
898  {
899  if (permitted_list->data[j] == map_string->data[idx])
900  {
901  found = TRUE;
902  break;
903  }
904  }
905 
906  if (found == TRUE)
907  {
908  next_char = map_string->data[idx];
909  entry_state.key_map_index = idx;
910  break;
911  }
912  }
913  return next_char;
914 }
915 
923 static int SMS_CharsListedForKey(MHEG5Entryfield *entryfield, int key )
924 {
925  MHEG5String *map_string;
926  MHEG5String *permitted_list;
927  int i, j;
928  int count = 0;
929 
930  map_string = &(SMS_map[key]);
931  permitted_list = &(entryfield->charList);
932 
933 
934  /*loop through the key map*/
935  for (i = 0; i < map_string->len; i++)
936  {
937  /*search the permitted char list*/
938  for (j = 0; j < permitted_list->len; j++)
939  {
940  if (permitted_list->data[j] == map_string->data[i])
941  {
942  count++;
943  break;
944  }
945  }
946  }
947  return count;
948 }
949 
951 {
953  MHEG5Entryfield *field_ref = (MHEG5Entryfield *)param->callerRef;
954  U32BIT current_time;
955  int time;
956 
957  if (param->triggered)
958  {
959  current_time = STB_OSGetClockMilliseconds();
960  /*check the time to ensure the timeout is correct*/
961  if (entry_state.last_press_time + SMS_KEY_CYCLE_DELAY <= current_time)
962  {
963  entry_state.state = chosen;
964  mhegTimerDestroy(SMSTimer);
965 
966  /*redraw*/
967  MHEG5drawEntry( field_ref, CURSOR_INSERT);
968  MHEG5displayRedraw((MHEG5Visible *) field_ref);
969 
970  if ((field_ref->maxlength > 0) && (field_ref->text.visible.ingredient.dataLen >= field_ref->maxlength))
971  {
972  /* Entry point reached the end of the field - generate an
973  * EntryFieldFull event
974  */
975  MHEG5sendEvent((MHEG5Root *)field_ref, MHEG5ENTRYFIELDFULL, 0);
976  }
977  }
978  else
979  {
980  /*if the timer fired too soon, start it again with the remaining time*/
981  time = (entry_state.last_press_time + SMS_KEY_CYCLE_DELAY) - current_time;
982  mhegTimerCreate(time, (F_TimerCallback) SMS_TimerCallback, (void *)field_ref, &SMSTimer);
983  }
984  }
985 }
986 
987 static void SMS_TimerCallback(BOOLEAN triggered, void *callerRef,
988  H_Timer timerHandle)
989 {
990  MHEG5eventMessage_t event;
991  E_MhegErr err;
992 
993  /* Send event to component task */
995  event.data_type = DT_VALUE;
996  event.data.timer.triggered = triggered;
997  event.data.timer.callerRef = callerRef;
998  event.data.timer.timerHandle = (void *)timerHandle;
999  err = VQ_PutMsg(&event, PRTY_NORMAL);
1000  if (err != MHERR_OK)
1001  {
1002  TRACE(TERROR, ("VQ_PutMsg returned Error %d", err))
1003  }
1004 }
1005 
MHEG5Bool availabilityStatus
Definition: mh5root.h:52
void MHEG5entryfieldDestruct(MHEG5Entryfield *entryfield)
Destruct a entryfield object.
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
void MHEG5entryfieldSELECT(MHEG5Entryfield *entryfield)
Perform action of select key on interacting Entryfield.
MHEG5Visible visible
Definition: mh5text.h:62
E_MhegErr VQ_PutMsg(S_MhegMessage *pMsg, E_PRIORITY priority)
Post event or section message on queue. Copies data into queue.
Definition: glue_queue.c:248
MHEG5Byte * data
Definition: mh5ingredient.h:80
F_MSG_PROCESS proc_msg_func
Definition: glue_queue.h:198
void MHEG5entryfieldEXIT(MHEG5Entryfield *entryfield)
Perform action of exit key on interacting Entryfield.
const char * data
Definition: mh5gate.c:56
void * H_Timer
Definition: glue_timers.h:58
enum entry_state_s::@4 state
Debug tracing.
MHEG5 queue.
MHEG5GList * MHEG5resolveGenericInteger(MHEG5GList *params, MHEG5Int *value)
Definition: mh5object.c:510
void MHEG5entryfieldActivate(MHEG5Entryfield *entryfield)
Apply the activation behaviour of the entryfield class. As this class has no own activation behaviour...
void MHEG5textDestruct(MHEG5Text *text)
Destruct a text object.
Definition: mh5text.c:365
#define MHEG5getMem
Definition: glue_memory.h:93
MHEG5Final clazz
Definition: mh5root.h:55
void MHEG5interactibleDestruct(MHEG5Interactible *interactible)
void MHEG5drawEntry(MHEG5Entryfield *entry, entryfieldCursor_t cursor)
Definition: mh5drawtext.c:502
void MHEG5entryfieldDeactivate(MHEG5Entryfield *entryfield)
Apply the deactivation behaviour of the entryfield class. As this class has no own deactivation behav...
#define mhegTimerCreate
Definition: glue_timers.h:85
E_MhegErr
Definition: mherrors.h:28
E_MHEG5_KEY
void MHEG5textPrepare(MHEG5Text *text)
Apply the preparation behaviour of the text class Apply the preparation behaviour of the text class...
Definition: mh5text.c:293
MHEG5String charList
Definition: mh5entryfield.h:52
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
MHEG5Bool obscuredInput
Definition: mh5entryfield.h:53
void MHEG5stringDestruct(MHEG5String *item)
Destruct a MHEG5String.
Definition: mh5base.c:686
U32BIT last_press_time
Definition: mh5entryfield.c:62
long MHEG5Int
Definition: mh5base.h:73
void MHEG5entryfieldPrepare(MHEG5Entryfield *entryfield)
Apply the preparation behaviour of the entryfield class Apply the preparation behaviour of the entryf...
void(* F_TimerCallback)(BOOLEAN triggered, void *callerRef, H_Timer timerHandle)
Definition: glue_timers.h:77
MHEG5Int entryPoint
Definition: mh5entryfield.h:57
MHEG5ErrorCode MHEG5getOverwriteMode(MHEG5Root *target, MHEG5GList *params)
Retrieve the overwrite mode of the entryfield Implementation of the GetOverwriteMode action of the en...
Memory functions.
void MHEG5entryfieldRIGHT(MHEG5Entryfield *entryfield)
Perform action of right arrow key on interacting Entryfield.
#define MHEG5freeMem
Definition: glue_memory.h:94
void MHEG5interactibleDeactivate(MHEG5Interactible *interactible)
Implementation of the deactivation behaviour of the interactible class. This behaviour was introduced...
MHEG5ErrorCode MHEG5setOverwriteMode(MHEG5Root *target, MHEG5GList *params)
Set the overwrite mode of the entryfield to the new value of the parameter Implementation of the SetO...
#define SMS_KEY_CYCLE_DELAY
Definition: mh5entryfield.c:52
#define MHEG5displayRedraw(v)
Definition: mh5display.h:47
void MHEG5entryfieldUserInput(MHEG5Entryfield *entryfield, E_MHEG5_KEY ui)
Test user input and perform required actions.
void MHEG5entryfieldInsert(MHEG5Entryfield *entryfield, unsigned short c)
Add the character |c| to the Entryfield.
MHEG5Entryfield * entryfield
Definition: mh5entryfield.c:64
MHEG5Int maxlength
Definition: mh5entryfield.h:54
short MHEG5Bool
Definition: mh5base.h:71
MHEG5ErrorCode
Definition: mh5base.h:222
unsigned char MHEG5Byte
Definition: mh5base.h:74
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
struct entry_state_s entry_state_t
MHEG5Byte * data
Definition: mh5base.h:85
void MHEG5textDeactivate(MHEG5Text *text)
Apply the deactivation behaviour of the text class. As this class has no own deactivation behaviour t...
Definition: mh5text.c:348
MHEG5ErrorCode MHEG5getEntryPoint(MHEG5Root *target, MHEG5GList *params)
Retrieve the current entrypoint of the entryfield Implementation of the GetEntryPoint action of the e...
void MHEG5textInit(MHEG5Text *text)
<Function description>="">
Definition: mh5text.c:190
MHEG5Bool overwriteMode
Definition: mh5entryfield.h:58
MHEG5Bool interactionStatus
Implement functions to retrieve MHEG5objects by GroupID and ID.
MHEG5Text text
Definition: mh5entryfield.h:47
Implementation of the MHEG5 Application Class Defines a set of Ingredient objects, which are shared within an application scope. Base class: Group Subclasses: None Status: Concrete class.
char previous_character
Definition: mh5entryfield.c:63
Implementation of the MHEG5 Scene Class Scene Class Defines a set of Ingredient objects to be activat...
void MHEG5interactibleInteractionCompleted(MHEG5Interactible *interactible, MHEG5Root *item)
void MHEG5textActivate(MHEG5Text *text)
Apply the activation behaviour of the text class. As this class has no own activation behaviour this ...
Definition: mh5text.c:330
MHEG class interface to graphics text render.
MHEG5Bool runningStatus
Definition: mh5root.h:51
MHEG5Ingredient ingredient
Definition: mh5visible.h:49
void entryfieldSMSTimeout(void *data)
void MHEG5interactibleInit(MHEG5Interactible *interactible)
<Function description>="">
MHEG5Scene * MHEG5getCurrentScene(void)
<Function description>="">
Definition: mh5scene.c:207
void MHEG5sendEvent(MHEG5Root *source, MHEG5EventType event, MHEG5Int data)
Store an event in the asynchronous event queue.
Definition: mh5queue.c:1540
#define FALSE
Definition: techtype.h:68
MHEG5ErrorCode MHEG5setEntryPoint(MHEG5Root *target, MHEG5GList *params)
Set the entrypoint for the entryfield Implementation of the SetEntryPoint action of the entryfield cl...
The timer module allows the use of timers within the MHEG5 component. These timers can be set by othe...
MHEG5Root * currentInteractible
Definition: mh5scene.h:56
MHEG5GList * MHEG5resolveGenericBoolean(MHEG5GList *params, MHEG5Bool *value)
Definition: mh5object.c:454
MHEG5Bool MH5_SupportInteractionChannel(void)
Return whether Interaction channel is supported by current profile.
Definition: mh5support.c:423
MHEG5Int len
Definition: mh5base.h:84
void MHEG5interactibleFree(MHEG5Interactible *interactible)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
void MHEG5entryfieldLEFT(MHEG5Entryfield *entryfield)
Perform action of left arrow key on interacting Entryfield.
void MHEG5entryfieldFree(MHEG5Entryfield *entryfield)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
U8BIT BOOLEAN
Definition: techtype.h:99
#define TRUE
Definition: techtype.h:69
enum MHEG5Entryfield::@1 inputType
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
void MHEG5entryfieldInit(MHEG5Entryfield *entryfield)
Initialise an entryfield object with default values.
#define mhegTimerDestroy
Definition: glue_timers.h:86
void MHEG5textFree(MHEG5Text *text)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5text.c:204
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
E_MHEG5_KEY current_key
Definition: mh5entryfield.c:60
void MHEG5interactiblePrepare(MHEG5Interactible *interactible)
Sets all internal attributes for the specified object to their default values.
MHEG5Interactible interactible
Definition: mh5entryfield.h:48
void MHEG5entryfieldBACKSPACE(MHEG5Entryfield *entryfield)
Perform action of backspace key on interacting Entryfield.
#define MHEG5FALSE
Definition: mh5base.h:48
uint32_t U32BIT
Definition: techtype.h:86
Key Press related functionality.
Engine support utility functions for MHEG5.
Implement the MHEG5 EntryField Class. Defines an interaction widget used by the final user to edit an...
#define TRACE(t, x)
Definition: glue_debug.h:118
Header file - Function prototypes for operating system.