MHEG-5  19.3.0
MHEG-5 Documentation
asn1_createButton.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  *******************************************************************************/
27 /*---includes for this file--------------------------------------------------*/
28 #include <stdio.h>
29 #include "vpa1_sys.h"
30 #include "vpa1_tgs.h"
31 #include "fpa1_syn.h"
32 #include "asn1_sys.h"
33 
34 #include "mh5base.h"
35 #include "mh5hotspot.h"
36 #include "mh5switchbutton.h"
37 #include "mh5pushbutton.h"
38 #include "asn1_createExtras.h"
39 #include "asn1_createVisible.h"
41 #include "asn1_createButton.h"
42 
43 /*---constant definitions for this file--------------------------------------*/
44 
45 
46 /*---local typedef structs for this file-------------------------------------*/
47 
48 /*---local (static) variable declarations for this file----------------------*/
49 #define BUTTONSTYLESIZE 4
50 #ifndef ASN1UKPROFILE
51 static MHEG5PushbuttonStyle buttonStyle[BUTTONSTYLESIZE] = {
52  0, MHEG5PUSHBUTTONS, MHEG5RADIOBUTTON, MHEG5CHECKBOX
53 };
54 #endif
55 
56 /*---local function definitions----------------------------------------------*/
57 
58 /*---global function definitions---------------------------------------------*/
59 
68 static asnErr asn1_decodeButton(fpa1_syntaxList *listPtr, MHEG5Button *button)
69 {
70  asnErr errVal = 0;
71  fpa1_syntaxList *currItem;
72 
73  DPL5((">> asn1_decodeButton(%X,%X)\n", listPtr, button));
74 
75  assert(button);
76  if (listPtr == NULL)
77  {
78  DPL5(("<< asn1_decodeButton() Returned early\n"));
79  return 1;
80  }
81 
82  currItem = listPtr->children;
83 
84  /* searches current set of tags for local tags */
85  while (currItem != NULL)
86  {
87  if (currItem->tag == BUTTONREFCOL)
88  {
89  errVal |= asn1_decodeColour(currItem, &button->buttonColour);
90  }
91  currItem = currItem->next;
92  }
93  /* decode inherited tags */
94  errVal |= asn1_decodeVisible(listPtr, &button->visible);
95  errVal |= asn1_decodeInteractible(listPtr, &button->interactible);
96 
97 #if (DPLEVEL >= 2)
98  if (errVal != 0)
99  {
100  DPL2(("WARNING:[ASN.1] asn1_decodeButton() Returns errVal = %d\n", errVal));
101  }
102 #endif /* DPLEVEL >= 2 */
103 
104  DPL5(("<< asn1_decodeButton() Returns %d\n", errVal));
105 
106  return errVal;
107 }
108 
117 {
118  MHEG5Button *button;
119 
120  button = MHEG5getMem( sizeof(MHEG5Hotspot));
121  if (button != NULL)
122  {
123  memset(button, 0, sizeof(MHEG5Hotspot));
124  button->visible.ingredient.root.clazz = MHEG5HOTSPOT;
125  if (asn1_decodeButton( listPtr, button ) != ASN_NO_ERROR)
126  {
127  MHEG5freeMem( button );
128  button = NULL;
129  }
130  }
131  return (MHEG5Ingredient *)button;
132 }
133 
134 #ifndef ASN1UKPROFILE
135 
144  MHEG5Pushbutton *pushbutton)
145 {
146  asnErr errVal = 0;
147  fpa1_syntaxList *currItem;
148 
149  DPL5((">> asn1_decodePushbutton(%X,%X)\n", listPtr, pushbutton));
150 
151  assert(pushbutton);
152  if (listPtr == NULL)
153  {
154  DPL5(("<< asn1_decodePushbutton() Returned early\n"));
155  return 1;
156  }
157 
158  currItem = listPtr->children;
159 
160  /* defaults */
161  pushbutton->characterSet = 10; /* According to UK Profile */
162 
163  /* searches current set of tags for local tags */
164  while (currItem != NULL)
165  {
166  /* most objects will have more than one local tag */
167  switch (currItem->tag)
168  {
169  case OLABEL:
170  errVal |= asn1_decodeOctetString(currItem, &pushbutton->originalLabel);
171  break;
172  case CHARSET:
173  pushbutton->characterSet = currItem->data.intData;
174  break;
175  default:
176  break;
177  }
178  currItem = currItem->next;
179  }
180 
181  /* decode inherited tags */
182  errVal |= asn1_decodeButton(listPtr, &pushbutton->button);
183 
184 #if (DPLEVEL >= 2)
185  if (errVal != 0)
186  {
187  DPL2(("WARNING:[ASN.1] asn1_decodePushbutton() Returns errVal = %d\n", errVal));
188  }
189 #endif /* DPLEVEL >= 2 */
190 
191  DPL5(("<< asn1_decodePushbutton() Returns %d\n", errVal));
192 
193  return errVal;
194 }
195 
204 {
205  MHEG5Pushbutton *button;
206 
207  button = MHEG5getMem( sizeof(MHEG5Pushbutton));
208  if (button != NULL)
209  {
210  memset(button, 0, sizeof(MHEG5Pushbutton));
211  button->button.visible.ingredient.root.class = MHEG5PUSHBUTTON;
212  if (asn1_decodePushbutton( listPtr, button ) != ASN_NO_ERROR)
213  {
214  MHEG5freeMem( button );
215  button = NULL;
216  }
217  }
218  return (MHEG5Ingredient *)button;
219 }
220 
230  MHEG5Switchbutton *swButton)
231 {
232  asnErr errVal = 0;
233  fpa1_syntaxList *currItem;
234  MHEG5Int enumIndex;
235 
236  DPL5((">> asn1_decodeSwitchButton(%X,%X)\n", listPtr, swButton));
237  assert(swButton);
238  if (listPtr == NULL)
239  {
240  DPL5(("<< asn1_decodeSwitchButton() Returned early\n"));
241  return 1;
242  }
243 
244  currItem = listPtr->children;
245 
246  /* searches current set of tags for local tags */
247  while (currItem != NULL)
248  {
249  if (currItem->tag == BSTYLE)
250  {
251  enumIndex = currItem->data.intData;
252  /* check the enumIndex value is in range, if not default to PushButton */
253  if ((enumIndex < 0) || (enumIndex >= BUTTONSTYLESIZE))
254  {
255  enumIndex = MHEG5PUSHBUTTONS;
256  }
257  swButton->style = buttonStyle[enumIndex];
258  }
259  currItem = currItem->next;
260  }
261  /* decode inherited tags */
262  errVal |= asn1_decodePushbutton(listPtr, &swButton->pushbutton);
263 
264 #if (DPLEVEL >= 2)
265  if (errVal != 0)
266  {
267  DPL2(("WARNING:[ASN.1] asn1_decodeSwitchButton() Returns errVal = %d\n", errVal));
268  }
269 #endif /* DPLEVEL >= 2 */
270 
271  DPL5(("<< asn1_decodeSwitchButton() Returns %d\n", errVal));
272 
273  return errVal;
274 }
275 
284 {
285  MHEG5Switchbutton *button;
286 
287  button = MHEG5getMem( sizeof(MHEG5Switchbutton));
288  if (button != NULL)
289  {
290  memset(button, 0, sizeof(MHEG5Switchbutton));
291  button->button.visible.ingredient.root.class = MHEG5SWITCHBUTTON;
292  if (asn1_decodeSwitchButton( listPtr, button ) != ASN_NO_ERROR)
293  {
294  MHEG5freeMem( button );
295  button = NULL;
296  }
297  }
298  return (MHEG5Ingredient *)button;
299 }
300 
301 #endif /* ASN1UKPROFILE */
asnErr asn1_decodeColour(fpa1_syntaxList *listPtr, MHEG5Colour *colour)
Decodes Colour class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
MHEG5Ingredient * asn1_createButton(fpa1_syntaxList *listPtr)
Decodes Button class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Basis MHEG5 data types.
MHEG5Ingredient * asn1_createSwitchButton(fpa1_syntaxList *listPtr)
Decodes SwitchButton class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
asnErr asn1_decodeOctetString(fpa1_syntaxList *listPtr, MHEG5String *decodedString)
decodes String type
asnErr asn1_decodeSwitchButton(fpa1_syntaxList *listPtr, MHEG5Switchbutton *swButton)
Decodes SwitchButton class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Miscellaneous functions for decoding ASN.1 types.
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
Implement the MHEG5 Hotspot Class. Defines invisible unlabelled rectangular areas on the screen that ...
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
asnErr asn1_decodeInteractible(fpa1_syntaxList *listPtr, MHEG5Interactible *interactible)
Decodes interactible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
typedefs etc for the whole object creation section.
Contains macros for MHEG-5 ASN.1 tags and structures.
Functions to create a MHEG5Interactible from a MHEG5 script (in the form of a list of fpa1_syntaxList...
asnErr asn1_decodeVisible(fpa1_syntaxList *listPtr, MHEG5Visible *visible)
Decodes Visible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Functions to create a MHEG5Visible from a MHEG5 script (in the form of a list of fpa1_syntaxList stru...
Implement the MHEG5 PushButton Class. Defines labelled, largely rectangular areas on the screen...
Implement the MHEG5 SwitchButton Class. Defines the behaviour of pressable buttons. Base class: PushButton. Subclasses: None. Status: Concrete class.
Functions to create a MHEG5Button from a MHEG5 script (in the form of a list of fpa1_syntaxList struc...
asnErr asn1_decodePushbutton(fpa1_syntaxList *listPtr, MHEG5Pushbutton *pushbutton)
Decodes Pushbutton class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
MHEG5Ingredient * asn1_createPushbutton(fpa1_syntaxList *listPtr)
Decodes Pushbutton class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...