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_object_info_get            PORTABLE C      */
38 /*                                                           6.1.12       */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function returns the information of the object.                */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    pima                                   Pima instance associated     */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    Completion Status                                                   */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    user application                                                    */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
67 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
68 /*                                            resulting in version 6.1    */
69 /*  07-29-2022     Chaoqiong Xiao           Modified comment(s),          */
70 /*                                            added no-callback handling, */
71 /*                                            resulting in version 6.1.12 */
72 /*                                                                        */
73 /**************************************************************************/
_ux_pictbridge_dpsclient_object_info_get(UX_SLAVE_CLASS_PIMA * pima,ULONG object_handle,UX_SLAVE_CLASS_PIMA_OBJECT ** object)74 UINT  _ux_pictbridge_dpsclient_object_info_get(UX_SLAVE_CLASS_PIMA *pima, ULONG object_handle,
75                                                 UX_SLAVE_CLASS_PIMA_OBJECT **object)
76 {
77 
78 UX_PICTBRIDGE               *pictbridge;
79 UX_SLAVE_CLASS_PIMA_OBJECT   *object_info;
80 
81     /* Get the pointer to the Pictbridge instance.  */
82     pictbridge = (UX_PICTBRIDGE *)pima -> ux_device_class_pima_application;
83 
84     /* Check the object handle. If this is handle 1 or 2 , we need to return the XML script object.
85        If the handle is not 1 or 2, this is a JPEG picture or other object to be printed.  */
86     if ((object_handle == UX_PICTBRIDGE_OBJECT_HANDLE_HOST_RESPONSE) || (object_handle == UX_PICTBRIDGE_OBJECT_HANDLE_CLIENT_REQUEST))
87     {
88         /* Check what XML object is requested. It is either a request script or a response.  */
89         if (object_handle == UX_PICTBRIDGE_OBJECT_HANDLE_HOST_RESPONSE)
90             object_info = (UX_SLAVE_CLASS_PIMA_OBJECT *) pictbridge -> ux_pictbridge_object_host;
91         else
92             object_info = (UX_SLAVE_CLASS_PIMA_OBJECT *) pictbridge -> ux_pictbridge_object_client;
93     }
94     else
95     {
96 
97         /* Get the object info from the application (if there is callback).  */
98         if (pictbridge -> ux_pictbridge_jobinfo.ux_pictbridge_jobinfo_object_info_get)
99             return pictbridge -> ux_pictbridge_jobinfo.ux_pictbridge_jobinfo_object_info_get(pima, object_handle, object);
100         else
101         {
102 
103             /* Get the object info from job.  */
104             object_info = pictbridge -> ux_pictbridge_jobinfo.ux_pictbridge_jobinfo_object;
105 
106             /* Object info not available.  */
107             if (object_info == UX_NULL)
108             {
109 
110                 /* Error trap.  */
111                 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_PICTBRIDGE_ERROR_NO_VALID_OBJECT_INFO);
112                 return(UX_PICTBRIDGE_ERROR_NO_VALID_OBJECT_INFO);
113             }
114         }
115     }
116 
117     /* Return the pointer to this object.  */
118     *object = object_info;
119 
120     /* We are done.  */
121     return(UX_SUCCESS);
122 }
123 
124