0a29e96eb600817c0cf32d4410bf78b0369a2df9
[apps/native/iot-device-manager.git] / inc / iot-device-manage-type.h
1  /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __IOT_DEVICE_MANAGE_TYPE_H__
18 #define __IOT_DEVICE_MANAGE_TYPE_H__
19
20 #include <tizen_error.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 /**
27 * @brief Enumeration for command type
28 * @since_tizen 5.0
29 */
30 typedef enum {
31         IDM_CMD_REBOOT = 1,      /**< Command for rebooting device */
32         IDM_CMD_GET_LOG_ARCHIVE, /**< Command for getting log archive file for diagnosis */
33         IDM_CMD_GET_TASKINFO,    /**< Command for getting task information */
34         IDM_CMD_GET_SYSINFO,     /**< Command for getting system information */
35         // IDM_CMD_LCDOFF,          /**< TBD : Command for turning LCD off */
36         // IDM_CMD_HIBERNATE,       /**< TBD : Command for hibernating device */
37         // IDM_CMD_HALT,            /**< TBD : Command for halting device */
38         // IDM_CMD_GET_ERR_CODE,    /**< TBD : Command for getting error codes for diagnosis */
39 } idm_cmd_type_e;
40
41 /**
42 * @brief Enumeration for command status
43 * @since_tizen 5.0
44 */
45 typedef enum {
46         IDM_CMD_CREATED = 0,  /**< Command is created */
47         IDM_CMD_INITIALIZED,  /**< Command is initialized */
48         IDM_CMD_RUNNING,      /**< Command is running */
49         IDM_CMD_DONE,         /**< Command is done */
50 } idm_cmd_status_e;
51
52 /**
53 * @brief Enumeration for command result
54 * @since_tizen 5.0
55 */
56 typedef enum {
57         IDM_RESULT_RUNNING,    /**< Command is still running */
58         IDM_RESULT_SUCCESS,    /**< Command succeded */
59         IDM_RESULT_FAILED,     /**< Command failed */
60 } idm_result_e;
61
62 /**
63 * @brief Enumeration for error reason
64 * @since_tizen 5.0
65 */
66 typedef enum {
67         IDM_REASON_NONE = TIZEN_ERROR_NONE,                           /**< No error */
68         IDM_REASON_UNKNOWN = TIZEN_ERROR_UNKNOWN,                     /**< Unknown error */
69         IDM_REASON_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
70         IDM_REASON_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,         /**< Out of memory */
71         IDM_REASON_IO_ERROR = TIZEN_ERROR_IO_ERROR,                   /**< Input/output error */
72         IDM_REASON_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
73         IDM_REASON_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
74         IDM_REASON_STOPPED = TIZEN_ERROR_CANCELED,                    /**< Stopped */
75         IDM_REASON_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,         /**< Not supported */
76 } idm_reason_e;
77
78 /**
79 * @brief Enumeration for error code
80 * @since_tizen 5.0
81 */
82 typedef enum {
83         IDM_ERROR_NONE = TIZEN_ERROR_NONE,                               /**< Successful */
84         IDM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,             /**< Out of memory */
85         IDM_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED,             /**< Operation not permitted */
86         IDM_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR,                       /**< I/O error */
87         IDM_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,     /**< Permission denied */
88         IDM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,     /**< Invalid function parameter */
89         IDM_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA,                         /**< No data available */
90         IDM_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in */
91         IDM_ERROR_CANCELED = TIZEN_ERROR_CANCELED,                       /**< Operation Canceled */
92         IDM_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN,                         /**< Unknown error */
93         IDM_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,             /**< Not supported */
94 } idm_error_e;
95
96 /**
97 * @brief Structure for command
98 * @since_tizen 5.0
99 */
100 typedef struct __idm_command_h *idm_command_h;
101
102 /**
103 * @brief Type definition of result callback function
104 * @since_tizen 5.0
105 * @remarks Format of @p detail for receiving result detail depends on the type of @p command \n
106 *          #IDM_CMD_GET_TASKINFO refers to 'schema/taskResult.json' as JSON schema definition and 'schema/taskResultExample.json' as example\n
107 *          #IDM_CMD_GET_LOG_ARCHIVE refers to 'schema/logArchiveResult.json' as JSON schema definition and 'schema/logArchiveResultExample.json' as example\n
108 * @param command Command handle
109 * @param result Enum value for result
110 * @param reason Enum value for reason
111 * @param detail Detail about result
112 * @param data User data
113 * @pre The callback must be registered using idm_command_run()
114 * @see idm_command_run()
115 * @see idm_command_get_type()
116 */
117 typedef void (*idm_result_cb) (idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data); /* TBD */
118
119 #ifdef __cplusplus
120 }
121 #endif
122 #endif /* __IOT_DEVICE_MANAGE_TYPE_H__ */