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_device_class_pima.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_pictbridge_dpsclient_input_get_capability */
38 /* PORTABLE C */
39 /* 6.1 */
40 /* */
41 /* AUTHOR */
42 /* */
43 /* Chaoqiong Xiao, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function creates the tag lines of the capability */
48 /* request. */
49 /* */
50 /* INPUT */
51 /* */
52 /* pictbridge Pictbridge instance */
53 /* pima_object_buffer Pointer to object buffer */
54 /* object_length Length of the object */
55 /* pima_object_buffer_updated Updated Address of the object */
56 /* object_length_updated Updated length */
57 /* */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* Completion Status */
62 /* */
63 /* CALLS */
64 /* */
65 /* */
66 /* CALLED BY */
67 /* */
68 /* _ux_pictbridge_dpsclient_input_object_prepare */
69 /* */
70 /* RELEASE HISTORY */
71 /* */
72 /* DATE NAME DESCRIPTION */
73 /* */
74 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
75 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
76 /* resulting in version 6.1 */
77 /* */
78 /**************************************************************************/
_ux_pictbridge_dpsclient_input_object_get_capability(UX_PICTBRIDGE * pictbridge,ULONG input_subcode,ULONG input_parameter,UCHAR * pima_object_buffer,ULONG object_length,UCHAR ** pima_object_buffer_updated,ULONG * object_length_updated)79 UINT _ux_pictbridge_dpsclient_input_object_get_capability(UX_PICTBRIDGE *pictbridge,
80 ULONG input_subcode,
81 ULONG input_parameter,
82 UCHAR *pima_object_buffer,
83 ULONG object_length,
84 UCHAR **pima_object_buffer_updated,
85 ULONG *object_length_updated)
86 {
87
88 UINT status;
89
90
91 /* Add the line <getcapability> */
92 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_getcapability,
93 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_LF,
94 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
95 if (status != UX_SUCCESS)
96 return(status);
97
98 /* Add the line <capability> */
99 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_capability,
100 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_LF,
101 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
102 if (status != UX_SUCCESS)
103 return(status);
104
105 /* Check was subcode we need to for this request. The API might be sending one or multiple requests. */
106 if (input_subcode & UX_PICTBRIDGE_API_QUALITIES)
107 {
108 /* Add the line <qualities/> */
109 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_qualities,
110 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
111 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
112 if (status != UX_SUCCESS)
113 return(status);
114 }
115
116 /* Check was subcode we need to for this request. The API might be sending one or multiple requests. */
117 if (input_subcode & UX_PICTBRIDGE_API_PAPER_SIZES)
118 {
119 /* Add the line <paperSizes/> */
120 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_papersizes,
121 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
122 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
123 if (status != UX_SUCCESS)
124 return(status);
125 }
126
127 /* Check was subcode we need to for this request. The API might be sending one or multiple requests. */
128 if (input_subcode & UX_PICTBRIDGE_API_PAPER_SIZES)
129 {
130
131 /* Check if we had a paper size value specified in the input report. */
132 if (input_parameter != 0)
133 {
134 /* Add the line <paperTypes paperSize = "xxxxxxxx"/> */
135 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_papertypes,
136 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
137 _ux_pictbridge_xml_variable_papersize,
138 input_parameter,
139 UX_NULL, &pima_object_buffer, &object_length);
140 if (status != UX_SUCCESS)
141 return(status);
142 }
143 else
144 {
145 /* Add the line <paperTypes/> */
146 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_papertypes,
147 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
148 UX_NULL, 0,
149 (VOID *) &pictbridge -> ux_pictbridge_dpslocal.ux_pictbridge_devinfo_papertypes, &pima_object_buffer, &object_length);
150 if (status != UX_SUCCESS)
151 return(status);
152 }
153 }
154
155 /* Parse the tag code that was memorized during the input. */
156 if (input_subcode & UX_PICTBRIDGE_API_FILE_TYPES)
157 {
158 /* Add the line <fileTypes/> */
159 _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_filetypes,
160 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
161 UX_NULL, 0, UX_NULL , &pima_object_buffer, &object_length);
162 if (status != UX_SUCCESS)
163 return(status);
164 }
165
166 /* Parse the tag code that was memorized during the input. */
167 if (input_subcode & UX_PICTBRIDGE_API_DATE_PRINTS)
168 {
169 /* Add the line <datePrints/> */
170 _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_dateprints,
171 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
172 UX_NULL, 0, UX_NULL , &pima_object_buffer, &object_length);
173 if (status != UX_SUCCESS)
174 return(status);
175 }
176
177 /* Parse the tag code that was memorized during the input. */
178 if (input_subcode & UX_PICTBRIDGE_API_FILE_NAME_PRINTS)
179 {
180 /* Add the line <namePrints/> */
181 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_filenameprints,
182 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
183 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
184 if (status != UX_SUCCESS)
185 return(status);
186 }
187
188 /* Parse the tag code that was memorized during the input. */
189 if (input_subcode & UX_PICTBRIDGE_API_IMAGE_OPTIMIZES)
190 {
191 /* Add the line <imageOptimizes/> */
192 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_imageoptimizes,
193 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
194 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
195 if (status != UX_SUCCESS)
196 return(status);
197 }
198
199 /* Parse the tag code that was memorized during the input. */
200 if (input_subcode & UX_PICTBRIDGE_API_LAYOUTS)
201 {
202
203 /* Check if we had a paper size value specified in the input report. */
204 if (input_parameter != 0)
205 {
206 /* Add the line <layouts paperSize = "xxxxxxxx"/> */
207 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_layouts,
208 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END | UX_PICTBRIDGE_TAG_FLAG_VARIABLE_HEXA,
209 _ux_pictbridge_xml_variable_papersize,
210 input_parameter,
211 UX_NULL, &pima_object_buffer, &object_length);
212 if (status != UX_SUCCESS)
213 return(status);
214 }
215 else
216 {
217 /* Add the line <layouts/> */
218 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_layouts,
219 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
220 UX_NULL, 0,
221 UX_NULL, &pima_object_buffer, &object_length);
222 if (status != UX_SUCCESS)
223 return(status);
224 }
225 }
226
227 /* Parse the tag code that was memorized during the input. */
228 if (input_subcode & UX_PICTBRIDGE_API_FIXED_SIZES)
229 {
230 /* Add the line <fixedSizes/> */
231 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_fixedsizes,
232 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
233 UX_NULL, 0,
234 UX_NULL, &pima_object_buffer, &object_length);
235 if (status != UX_SUCCESS)
236 return(status);
237 }
238
239 /* Parse the tag code that was memorized during the input. */
240 if (input_subcode & UX_PICTBRIDGE_API_CROPPINGS)
241 {
242 /* Add the line <croppings/> */
243 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_croppings,
244 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
245 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
246 if (status != UX_SUCCESS)
247 return(status);
248 }
249
250 /* Parse the tag code that was memorized during the input. */
251 if (input_subcode & UX_PICTBRIDGE_API_CHAR_REPERTOIRES)
252 {
253 /* Add the line <charRepertoires/> */
254 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_charrepertoires,
255 UX_PICTBRIDGE_TAG_FLAG_BEGIN | UX_PICTBRIDGE_TAG_FLAG_FORCE_SLASH_AT_END,
256 UX_NULL, 0,
257 UX_NULL, &pima_object_buffer, &object_length);
258 if (status != UX_SUCCESS)
259 return(status);
260 }
261
262 /* Add the line </capability> */
263 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_capability,
264 UX_PICTBRIDGE_TAG_FLAG_END,
265 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
266 if (status != UX_SUCCESS)
267 return(status);
268
269 /* Add the line </getcapability> */
270 status = _ux_pictbridge_object_tag_line_add(pima_object_buffer, object_length, _ux_pictbridge_xml_tag_line_getcapability,
271 UX_PICTBRIDGE_TAG_FLAG_END,
272 UX_NULL, 0, UX_NULL, &pima_object_buffer, &object_length);
273 if (status != UX_SUCCESS)
274 return(status);
275
276 /* Update the caller's object position. */
277 *pima_object_buffer_updated = pima_object_buffer;
278
279 /* Update the caller's object length . */
280 *object_length_updated = object_length;
281
282 /* Return completion status. */
283 return(UX_SUCCESS);
284 }
285
286