From cc70d5349a190ef73c5b1b4ad4caf2bf6e39dc8c Mon Sep 17 00:00:00 2001 From: Rajendraprasad K J Date: Mon, 30 Mar 2020 08:20:38 +0200 Subject: ilmCommon: Implement a shutdown notification for ilm Added new ilm API using which user could register for the shutdown notification. Signed-off-by: Rajendraprasad K J --- ivi-layermanagement-api/ilmCommon/include/ilm_common.h | 13 +++++++++++++ ivi-layermanagement-api/ilmCommon/include/ilm_types.h | 17 +++++++++++++++++ ivi-layermanagement-api/ilmCommon/src/ilm_common.c | 9 +++++++++ 3 files changed, 39 insertions(+) diff --git a/ivi-layermanagement-api/ilmCommon/include/ilm_common.h b/ivi-layermanagement-api/ilmCommon/include/ilm_common.h index fa86824..61e240a 100644 --- a/ivi-layermanagement-api/ilmCommon/include/ilm_common.h +++ b/ivi-layermanagement-api/ilmCommon/include/ilm_common.h @@ -64,6 +64,19 @@ t_ilm_bool ilm_isInitialized(void); */ ilmErrorTypes ilm_commitChanges(void); +/** + * \brief register for notification on an event of ilm shutdown + * \ingroup ilmCommon + * \param[in] callback pointer to function to be called for notification + callback function is defined as: + void cb(t_ilm_shutdown_error_type error_type, int errornum, void *user_data) + * \param[in] user_data pointer to data which will be passed to a notification callback + * \return ILM_SUCCESS if the method call was successful + * \return ILM_FAILED if the client can not call the method on the service. + */ +ilmErrorTypes ilm_registerShutdownNotification(shutdownNotificationFunc callback, + void *user_data); + /** * \brief Destroys the IVI LayerManagement Client. * \ingroup ilmCommon diff --git a/ivi-layermanagement-api/ilmCommon/include/ilm_types.h b/ivi-layermanagement-api/ilmCommon/include/ilm_types.h index a88f2b0..98a8e62 100644 --- a/ivi-layermanagement-api/ilmCommon/include/ilm_types.h +++ b/ivi-layermanagement-api/ilmCommon/include/ilm_types.h @@ -248,6 +248,16 @@ typedef enum ILM_NOTIFICATION_ALL = 0xffff } t_ilm_notification_mask; +/** + * enum representing types of possible unrecoverable errors that could lead to ilm shutdown. + */ +typedef enum +{ + ILM_ERROR_WAYLAND = 1, /*!< ErrorCode if Wayland API returns an error */ + ILM_ERROR_POLL = 2 /*!< ErrorCode if Poll returns an error */ +}t_ilm_shutdown_error_type; + + /** * Typedef for notification callback on property changes of a layer */ @@ -270,4 +280,11 @@ typedef void(*notificationFunc)(ilmObjectType object, t_ilm_bool created, void* user_data); +/** + * Typedef for notification callback on ilm shutdown due to unrecoverable + * errors + */ +typedef void(*shutdownNotificationFunc)(t_ilm_shutdown_error_type error_type, + int errornum, + void* user_data); #endif /* _ILM_TYPES_H_*/ diff --git a/ivi-layermanagement-api/ilmCommon/src/ilm_common.c b/ivi-layermanagement-api/ilmCommon/src/ilm_common.c index b4f8818..63342b9 100644 --- a/ivi-layermanagement-api/ilmCommon/src/ilm_common.c +++ b/ivi-layermanagement-api/ilmCommon/src/ilm_common.c @@ -26,6 +26,9 @@ #include "ilm_types.h" ILM_EXPORT ilmErrorTypes ilmControl_init(t_ilm_nativedisplay); +ILM_EXPORT ilmErrorTypes ilmControl_registerShutdownNotification( + shutdownNotificationFunc callback, + void *user_data); ILM_EXPORT void ilmControl_destroy(void); static pthread_mutex_t g_initialize_lock = PTHREAD_MUTEX_INITIALIZER; @@ -97,6 +100,12 @@ ilm_isInitialized(void) return ILM_FALSE; } +ILM_EXPORT ilmErrorTypes +ilm_registerShutdownNotification(shutdownNotificationFunc callback, void *user_data) +{ + return ilmControl_registerShutdownNotification(callback, user_data); +} + ILM_EXPORT ilmErrorTypes ilm_destroy(void) { -- cgit v1.2.1