1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** Pictbridge Application */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29 #include "ux_pictbridge.h"
30 #include "ux_host_class_pima.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_pictbridge_dpshost_output_object_get_capability PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function creates the tag lines of the get_capability request */
46 /* */
47 /* INPUT */
48 /* */
49 /* pictbridge Pictbridge instance */
50 /* pima_object_buffer Pointer to object buffer */
51 /* object_length Length of the object */
52 /* pima_object_buffer_updated Updated Address of the object */
53 /* object_length_updated Updated length */
54 /* */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* Completion Status */
59 /* */
60 /* CALLS */
61 /* */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* _ux_pictbridge_dpshost_object_get */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
72 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
73 /* resulting in version 6.1 */
74 /* */
75 /**************************************************************************/
_ux_pictbridge_dpshost_output_object_get_capability(UX_PICTBRIDGE * pictbridge,UCHAR * pima_object_buffer,ULONG object_length,UCHAR ** pima_object_buffer_updated,ULONG * object_length_updated)76 UINT _ux_pictbridge_dpshost_output_object_get_capability(UX_PICTBRIDGE *pictbridge,
77 UCHAR *pima_object_buffer,
78 ULONG object_length,
79 UCHAR **pima_object_buffer_updated,
80 ULONG *object_length_updated)
81 {
82
83 UINT status;
84
85 /* Add the line <getcapability> */
86 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_getcapability,
87 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_LF,
88 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
89 if (status != UX_SUCCESS)
90 return(status);
91
92
93 /* Add the line <capability> */
94 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_capability,
95 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_LF,
96 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
97 if (status != UX_SUCCESS)
98 return(status);
99
100 /* Parse the tag code that was memorized during the input. */
101 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_QUALITIES)
102 {
103 /* Add the line <qualities> xxxxxxxx </qualities> */
104 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_qualities,
105 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
106 UX_NULL, 0, (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_qualities, &pima_object_buffer, &object_length);
107 if (status != UX_SUCCESS)
108 return(status);
109 }
110
111 /* Parse the tag code that was memorized during the input. */
112 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_PAPER_SIZES)
113 {
114 /* Add the line <paperSizes> xxxxxxxx </paperSizes> */
115 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_papersizes,
116 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
117 UX_NULL, 0, (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_papersizes, &pima_object_buffer, &object_length);
118 if (status != UX_SUCCESS)
119 return(status);
120 }
121
122 /* Parse the tag code that was memorized during the input. */
123 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_PAPER_TYPES)
124 {
125
126 /* Check if we had a paper size value specified in the input report. */
127 if (pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_papertypes_papersize != 0)
128
129 /* Add the line <paperTypes paperSize = "xxxxxxxx"> xxxxxxxx yyyyyyyy </paperTypes> */
130 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_papertypes,
131 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
132 _ux_pictbridge_xml_variable_papersize, pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_papertypes_papersize,
133 (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_papertypes, &pima_object_buffer, &object_length);
134
135 else
136
137 /* Add the line <paperTypes> xxxxxxxx yyyyyyyy </paperTypes> */
138 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_papertypes,
139 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
140 UX_NULL, 0,
141 (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_papertypes, &pima_object_buffer, &object_length);
142
143 if (status != UX_SUCCESS)
144 return(status);
145 }
146
147 /* Parse the tag code that was memorized during the input. */
148 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_FILE_TYPES)
149 {
150 /* Add the line <fileTypes> xxxxxxxx </fileTypes> */
151 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_filetypes,
152 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
153 UX_NULL, 0, (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_filetypes, &pima_object_buffer, &object_length);
154 if (status != UX_SUCCESS)
155 return(status);
156 }
157
158 /* Parse the tag code that was memorized during the input. */
159 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_DATE_PRINTS)
160 {
161 /* Add the line <datePrints> xxxxxxxx </datePrints> */
162 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_dateprints,
163 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
164 UX_NULL, 0, (VOID *) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_dateprints, &pima_object_buffer, &object_length);
165 if (status != UX_SUCCESS)
166 return(status);
167 }
168
169
170 /* Parse the tag code that was memorized during the input. */
171 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_FILE_NAME_PRINTS)
172 {
173 /* Add the line <namePrints> xxxxxxxx </namePrints> */
174 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_filenameprints,
175 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
176 UX_NULL, 0, (VOID *) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_filenameprints, &pima_object_buffer, &object_length);
177 if (status != UX_SUCCESS)
178 return(status);
179 }
180
181 /* Parse the tag code that was memorized during the input. */
182 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_IMAGE_OPTIMIZES)
183 {
184 /* Add the line <imageOptimizes> xxxxxxxx </imageOptimizes> */
185 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_imageoptimizes,
186 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
187 UX_NULL, 0, (VOID *) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_imageoptimizes, &pima_object_buffer, &object_length);
188 if (status != UX_SUCCESS)
189 return(status);
190 }
191
192 /* Parse the tag code that was memorized during the input. */
193 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_LAYOUTS)
194 {
195
196 /* Check if we had a paper size value specified in the input report. */
197 if (pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_layouts_papersize != 0)
198
199
200 /* Add the line <layouts paperSize = "xxxxxxxx"> xxxxxxxx yyyyyyyy </layouts> */
201 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_layouts,
202 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
203 _ux_pictbridge_xml_variable_papersize, pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_layouts_papersize,
204 (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_layouts, &pima_object_buffer, &object_length);
205
206 else
207
208 /* Add the line <layouts> xxxxxxxx yyyyyyyy </layouts> */
209 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_layouts,
210 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
211 UX_NULL, 0,
212 (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_layouts, &pima_object_buffer, &object_length);
213
214 if (status != UX_SUCCESS)
215 return(status);
216 }
217
218 /* Parse the tag code that was memorized during the input. */
219 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_FIXED_SIZES)
220 {
221 /* Add the line <fixedSizes> xxxxxxxx yyyyyyyy </fixedSizes> */
222 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_fixedsizes,
223 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
224 UX_NULL, 0,
225 (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_fixedsizes, &pima_object_buffer, &object_length);
226 if (status != UX_SUCCESS)
227 return(status);
228 }
229
230 /* Parse the tag code that was memorized during the input. */
231 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_CROPPINGS)
232 {
233 /* Add the line <croppings> xxxxxxxx yyyyyyyy</croppings> */
234 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_croppings,
235 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
236 UX_NULL, 0, (VOID *) pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_croppings, &pima_object_buffer, &object_length);
237 if (status != UX_SUCCESS)
238 return(status);
239 }
240
241 /* Parse the tag code that was memorized during the input. */
242 if (pictbridge -> ux_pictbridge_input_tags & UX_PICTBRIDGE_IR_GC_CHAR_REPERTOIRES)
243 {
244 /* Add the line <charRepertoires> xxxxxxxx yyyyyyyy </charRepertoires> */
245 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_charrepertoires,
246 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_ARRAY_HEXA,
247 UX_NULL, 0,
248 (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_charrepertoires, &pima_object_buffer, &object_length);
249 if (status != UX_SUCCESS)
250 return(status);
251 }
252
253 /* Add the line </capability> */
254 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_capability,
255 UX_PICTBRIDGE_TAG_FLAG_END,
256 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
257 if (status != UX_SUCCESS)
258 return(status);
259
260
261 /* Add the line </getcapability> */
262 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_getcapability,
263 UX_PICTBRIDGE_TAG_FLAG_END,
264 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
265 if (status != UX_SUCCESS)
266 return(status);
267
268 /* Update the caller's object position. */
269 *pima_object_buffer_updated = pima_object_buffer;
270
271 /* Update the caller's object length . */
272 *object_length_updated = object_length;
273
274 /* Return completion status. */
275 return(UX_SUCCESS);
276 }
277
278