From 76def030ca7283648236f768ed763c916dd1d769 Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Wed, 5 Jun 2019 08:42:44 +0900 Subject: [PATCH] [ACR-1411] Add new error for ability not supported Change-Id: I7cd47f659b30873664315fabce17474ef49075ae --- include/media_controller_client.h | 32 ++++++++++++++++++++++++-------- include/media_controller_type.h | 3 +++ src/media_controller_client.c | 36 +++++++++++++++++++++++++++++------- 3 files changed, 56 insertions(+), 15 deletions(-) mode change 100755 => 100644 include/media_controller_client.h diff --git a/include/media_controller_client.h b/include/media_controller_client.h old mode 100755 new mode 100644 index 2977445..c45f680 --- a/include/media_controller_client.h +++ b/include/media_controller_client.h @@ -844,7 +844,8 @@ int mc_client_unset_custom_event_received_cb(mc_client_h client); * * @remarks The media controller client get the @a server_name and @a request_id through the mc_client_custom_event_received_cb(). \n * If @a request_id is not null there, the media controller client should send the reply to the media controller server with the @a request_id. \n - * If @a request_id is null, this function will return #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER. + * If @a request_id is null, this function will return #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER.\n + * If the @a server_name application doesn't support receiving the event reply, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -858,6 +859,7 @@ int mc_client_unset_custom_event_received_cb(mc_client_h client); * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller server handle by calling mc_server_create(). * @see mc_client_create() @@ -1406,7 +1408,8 @@ int mc_client_foreach_server_playlist(mc_client_h client, const char *server_nam * @privilege %http://tizen.org/privilege/mediacontroller.client * * @remarks The @a request_id should be released using free().\n - * If the @a request_id is null, the server will not send the reply of the command. + * If the @a request_id is null, the server will not send the reply of the command.\n + * If the @a server_name application doesn't support the playback action command, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -1419,6 +1422,7 @@ int mc_client_foreach_server_playlist(mc_client_h client, const char *server_nam * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller client handle by calling mc_client_create(). * @see mc_client_create() @@ -1435,7 +1439,8 @@ int mc_client_send_playback_action_cmd(mc_client_h client, const char *server_na * @privilege %http://tizen.org/privilege/mediacontroller.client * * @remarks The @a request_id should be released using free().\n - * If the @a request_id is null, the server will not send the reply of the command. + * If the @a request_id is null, the server will not send the reply of the command.\n + * If the @a server_name application doesn't support the playback position command, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -1448,6 +1453,7 @@ int mc_client_send_playback_action_cmd(mc_client_h client, const char *server_na * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller client handle by calling mc_client_create(). * @see mc_client_create() @@ -1464,7 +1470,8 @@ int mc_client_send_playback_position_cmd(mc_client_h client, const char *server_ * @privilege %http://tizen.org/privilege/mediacontroller.client * * @remarks The @a request_id should be released using free().\n - * If the @a request_id is null, the server will not send the reply of the command. + * If the @a request_id is null, the server will not send the reply of the command.\n + * If the @a server_name application doesn't support the shuffle mode, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -1477,6 +1484,7 @@ int mc_client_send_playback_position_cmd(mc_client_h client, const char *server_ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller client handle by calling mc_client_create(). * @see mc_client_create() @@ -1493,7 +1501,8 @@ int mc_client_send_shuffle_mode_cmd(mc_client_h client, const char *server_name, * @privilege %http://tizen.org/privilege/mediacontroller.client * * @remarks The @a request_id should be released using free().\n - * If the @a request_id is null, the server will not send the reply of the command. + * If the @a request_id is null, the server will not send the reply of the command.\n + * If the @a server_name application doesn't support the repeat mode, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -1506,6 +1515,7 @@ int mc_client_send_shuffle_mode_cmd(mc_client_h client, const char *server_name, * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller client handle by calling mc_client_create(). * @see mc_client_create() @@ -1523,7 +1533,8 @@ int mc_client_send_repeat_mode_cmd(mc_client_h client, const char *server_name, * @privilege %http://tizen.org/privilege/mediacontroller.client * * @remarks The @a request_id should be released using free().\n - * If the @a request_id is null, the server will not send the reply of the command. + * If the @a request_id is null, the server will not send the reply of the command.\n + * If the @a server_name application doesn't support the playlist command, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -1539,6 +1550,7 @@ int mc_client_send_repeat_mode_cmd(mc_client_h client, const char *server_name, * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller client handle by calling mc_client_create(). * @see mc_client_create() @@ -1555,7 +1567,8 @@ int mc_client_send_playlist_cmd(mc_client_h client, const char *server_name, con * @privilege %http://tizen.org/privilege/mediacontroller.client * * @remarks The @a request_id should be released using free().\n - * If the @a request_id is null, the server will not send the reply of the command. + * If the @a request_id is null, the server will not send the reply of the command.\n + * If the @a server_name application doesn't support the custom command, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -1569,6 +1582,7 @@ int mc_client_send_playlist_cmd(mc_client_h client, const char *server_name, con * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller client handle by calling mc_client_create(). * @see mc_client_create() @@ -1585,7 +1599,8 @@ int mc_client_send_custom_cmd(mc_client_h client, const char *server_name, const * @privilege %http://tizen.org/privilege/mediacontroller.client * * @remarks The @a request_id should be released using free().\n - * If the @a request_id is null, the server will not send the reply of the command. + * If the @a request_id is null, the server will not send the reply of the command.\n + * If the @a server_name application doesn't support the search command, this function will return #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP since 5.5. * * @param[in] client The handle of the media controller client * @param[in] server_name The app_id of the media controller server @@ -1598,6 +1613,7 @@ int mc_client_send_custom_cmd(mc_client_h client, const char *server_name, const * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTROLLER_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP Limited by server application * * @pre Create a media controller client handle by calling mc_client_create(). * @pre Create search handle and set data by calling mc_search_create() and mc_search_set_condition(). diff --git a/include/media_controller_type.h b/include/media_controller_type.h index 438e2cd..40f0c30 100755 --- a/include/media_controller_type.h +++ b/include/media_controller_type.h @@ -34,6 +34,8 @@ extern "C" { * @{ */ +#define MEDIA_CONTROLLER_ERROR_CLASS TIZEN_ERROR_MEDIA_CONTROLLER + /** * @brief The structure type for the media server handle. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif @@ -87,6 +89,7 @@ typedef enum { MEDIA_CONTROLLER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */ MEDIA_CONTROLLER_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */ MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP = MEDIA_CONTROLLER_ERROR_CLASS | 0x01, /**< Limited by server application (since 5.5) */ } mc_error_e; /** diff --git a/src/media_controller_client.c b/src/media_controller_client.c index 8b74686..81e007d 100644 --- a/src/media_controller_client.c +++ b/src/media_controller_client.c @@ -1019,16 +1019,34 @@ int mc_client_foreach_server(mc_client_h client, mc_activated_server_cb callback return ret; } +static int __mc_client_verify_ability(mc_client_h client, const char *server_name, int ability) +{ + int ret = MEDIA_CONTROLLER_ERROR_NONE; + media_controller_client_s *mc_client = (media_controller_client_s *)client; + mc_ability_support_e supported = MC_ABILITY_SUPPORTED_UNDECIDED; + + mc_retvm_if(!mc_client, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid handle"); + mc_retvm_if(!mc_db_is_server_table_exist(mc_client->db_handle, server_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid server_name"); + + ret = mc_db_get_ability_supported(mc_client->db_handle, server_name, ability, &supported); + mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail to get ability"); + mc_retvm_if(supported == MC_ABILITY_SUPPORTED_NO, MEDIA_CONTROLLER_ERROR_ABILITY_LIMITED_BY_SERVER_APP, "Not Supported ability"); + + return MEDIA_CONTROLLER_ERROR_NONE; +} + int mc_client_send_playback_action_cmd(mc_client_h client, const char *server_name, mc_playback_action_e action, char **request_id) { int ret = MEDIA_CONTROLLER_ERROR_NONE; char *message = NULL; media_controller_client_s *mc_client = (media_controller_client_s *)client; - mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - mc_retvm_if(!MC_STRING_VALID(server_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid server_name"); + mc_retvm_if(!mc_client, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid handle"); mc_retvm_if(!_mc_util_is_valid_playback_action(action), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid action"); + ret = __mc_client_verify_ability(client, server_name, PLAYBACK_ACTION_ABILITY + action); + mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail to verify ability"); + message = g_strdup_printf("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, action); mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret); @@ -1064,9 +1082,11 @@ int mc_client_send_shuffle_mode_cmd(mc_client_h client, const char *server_name, char *message = NULL; media_controller_client_s *mc_client = (media_controller_client_s *)client; - mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - mc_retvm_if(!MC_STRING_VALID(server_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid server_name"); - mc_retvm_if(((shuffle_mode < MC_SHUFFLE_MODE_ON) || (shuffle_mode > MC_SHUFFLE_MODE_OFF)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "shuffle is invalid"); + mc_retvm_if(!mc_client, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid handle"); + mc_retvm_if(((shuffle_mode < MC_SHUFFLE_MODE_ON) || (shuffle_mode > MC_SHUFFLE_MODE_OFF)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid shuffle mode [%d]", shuffle_mode); + + ret = __mc_client_verify_ability(client, server_name, MC_SERVER_EVENT_SHUFFLE); + mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail to verify ability"); message = g_strdup_printf("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, shuffle_mode); mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret); @@ -1085,8 +1105,10 @@ int mc_client_send_repeat_mode_cmd(mc_client_h client, const char *server_name, media_controller_client_s *mc_client = (media_controller_client_s *)client; mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - mc_retvm_if(!MC_STRING_VALID(server_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid server_name"); - mc_retvm_if(((repeat_mode < MC_REPEAT_MODE_ON) || (repeat_mode > MC_REPEAT_MODE_ONE_MEDIA)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "repeat is invalid [%d]", repeat_mode); + mc_retvm_if(((repeat_mode < MC_REPEAT_MODE_ON) || (repeat_mode > MC_REPEAT_MODE_ONE_MEDIA)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid repeat mode [%d]", repeat_mode); + + ret = __mc_client_verify_ability(client, server_name, MC_SERVER_EVENT_REPEAT); + mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail to verify ability"); message = g_strdup_printf("%s%s%d", mc_client->client_name, MC_STRING_DELIMITER, repeat_mode); mc_retvm_if(message == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making message [%d]", ret); -- 2.7.4