From: Hwankyu Jhun Date: Mon, 26 Apr 2021 23:50:15 +0000 (+0900) Subject: Fix AppControl API for backward compatibility X-Git-Tag: submit/tizen/20210427.022955~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cb7848c8c9d7564016c78db370fc7c9f442b12a;p=platform%2Fcore%2Fapi%2Fapp-control.git Fix AppControl API for backward compatibility - Use app_control_s structure - Remove DEPRECATED_API definition and Add descpription about deprecated API Change-Id: I3e0c7d5992afb31fd3203bba483eae9fd46e10dc Signed-off-by: Hwankyu Jhun --- diff --git a/include/app_control.h b/include/app_control.h index 2600f0a..751c507 100644 --- a/include/app_control.h +++ b/include/app_control.h @@ -39,7 +39,7 @@ extern "C" { * @brief The application control handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef void *app_control_h; +typedef struct app_control_s *app_control_h; /** diff --git a/include/app_control_internal.h b/include/app_control_internal.h index 5a959e0..9bb5dfb 100644 --- a/include/app_control_internal.h +++ b/include/app_control_internal.h @@ -34,10 +34,6 @@ extern "C" { * @{ */ -#ifndef DEPRECATED_API -#define DEPRECATED_API __attribute__((__visibility__("default"), deprecated)) -#endif - /** * @brief Definition for the app_control data: Connects the previous application with the next application when the sub-application is terminated. * @details If a sub-application is terminated, the framework will connect the previous application with the next application. @@ -152,8 +148,9 @@ int app_control_to_bundle(app_control_h app_control, bundle **data); * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #APP_CONTROL_ERROR_OUT_OF_MEMORY Out of memory * @see app_control_get_window() + * @remarks This function is deprecated from tizen 6.5. */ -int app_control_set_window(app_control_h app_control, unsigned int id) DEPRECATED_API; +int app_control_set_window(app_control_h app_control, unsigned int id); /** * @brief Gets the window ID of the application. @@ -167,8 +164,9 @@ int app_control_set_window(app_control_h app_control, unsigned int id) DEPRECATE * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #APP_CONTROL_ERROR_OUT_OF_MEMORY Out of memory * @see app_control_set_app_id() + * @remarks This function is deprecated from tizen 6.5. */ -int app_control_get_window(app_control_h app_control, unsigned int *id) DEPRECATED_API; +int app_control_get_window(app_control_h app_control, unsigned int *id); typedef int (*app_control_host_res_fn)(void *data); @@ -185,8 +183,9 @@ typedef int (*app_control_host_res_fn)(void *data); * otherwise a negative error value * @retval #APP_CONTROL_ERROR_NONE Successful * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @remarks This function is deprecated from tizen 6.5. */ -int app_control_request_transient_app(app_control_h app_control, unsigned int callee_id, app_control_host_res_fn cbfunc, void *data) DEPRECATED_API; +int app_control_request_transient_app(app_control_h app_control, unsigned int callee_id, app_control_host_res_fn cbfunc, void *data); /** * @platform diff --git a/src/app-control/app_control_broker.cc b/src/app-control/app_control_broker.cc index 5162d4c..7638ece 100644 --- a/src/app-control/app_control_broker.cc +++ b/src/app-control/app_control_broker.cc @@ -145,7 +145,8 @@ void AppControlBroker::AppControlResultBroker(int req_id, int result, if (result < 0) error = Util::AulSvcErrorConvert(result); - result_cb(app_control.get(), static_cast(error), + result_cb(reinterpret_cast(app_control.get()), + static_cast(error), request_context->GetUserData()); } @@ -186,7 +187,9 @@ void AppControlBroker::AppControlReplyBroker(bundle* b, int req_id, auto request = request_context->GetAppControl(); app_control_result_e res = Util::AulSvcResultConvert(result); AppControl reply(tizen_base::Bundle(b), AppControl::Type::Reply); - reply_cb(request.get(), &reply, res, request_context->GetUserData()); + reply_cb(reinterpret_cast(request.get()), + reinterpret_cast(&reply), res, + request_context->GetUserData()); broker->RemoveRequestContext(req_id); } @@ -256,7 +259,9 @@ void AppControlBroker::HandleAppStartedResult(AppControl* app_control, else reply.SetAppId(callee); - reply_cb(app_control.get(), &reply, APP_CONTROL_RESULT_APP_STARTED, + reply_cb(reinterpret_cast(app_control.get()), + reinterpret_cast(&reply), + APP_CONTROL_RESULT_APP_STARTED, request_context->GetUserData()); }, GINT_TO_POINTER(req_id)); diff --git a/src/app-control/stub.cc b/src/app-control/stub.cc index ad45f84..4c79a22 100644 --- a/src/app-control/stub.cc +++ b/src/app-control/stub.cc @@ -45,6 +45,13 @@ using namespace app_control; +struct app_control_s { + void* dummy; +}; + +static_assert(std::is_pod::value, + "app_control_s must be a POD type"); + namespace { class ActionExt : public AppControlAction, @@ -98,7 +105,7 @@ EXPORT int app_control_create_request(bundle* data, return APP_CONTROL_ERROR_OUT_OF_MEMORY; } - *app_control = static_cast(handle); + *app_control = reinterpret_cast(handle); return APP_CONTROL_ERROR_NONE; } @@ -260,7 +267,7 @@ EXPORT int app_control_create_event(bundle* data, handle->SetOperation(APP_CONTROL_OPERATION_DEFAULT); } - *app_control = static_cast(handle); + *app_control = reinterpret_cast(handle); return APP_CONTROL_ERROR_NONE; } @@ -270,7 +277,7 @@ EXPORT int app_control_destroy(app_control_h app_control) { return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); delete handle; return APP_CONTROL_ERROR_NONE; } @@ -281,7 +288,7 @@ EXPORT int app_control_to_bundle(app_control_h app_control, bundle** data) { return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); *data = handle->ToBundle(); return APP_CONTROL_ERROR_NONE; } @@ -293,7 +300,7 @@ EXPORT int app_control_set_operation(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (operation != nullptr) { try { handle->SetOperation(operation); @@ -316,7 +323,7 @@ EXPORT int app_control_get_operation(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string value = handle->GetOperation(); *operation = strdup(value.c_str()); if (*operation == nullptr) { @@ -336,7 +343,7 @@ EXPORT int app_control_set_uri(app_control_h app_control, const char* uri) { return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (uri != nullptr) { try { handle->SetUri(uri); @@ -358,7 +365,7 @@ EXPORT int app_control_get_uri(app_control_h app_control, char** uri) { } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string value = handle->GetUri(); *uri = strdup(value.c_str()); if (*uri == nullptr) { @@ -403,7 +410,7 @@ EXPORT int app_control_set_mime(app_control_h app_control, const char* mime) { return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (mime != nullptr) { try { handle->SetMime(mime); @@ -425,7 +432,7 @@ EXPORT int app_control_get_mime(app_control_h app_control, char** mime) { } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string value = handle->GetMime(); *mime = strdup(value.c_str()); if (*mime == nullptr) { @@ -446,7 +453,7 @@ EXPORT int app_control_set_category(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (category != nullptr) { try { handle->SetCategory(category); @@ -469,7 +476,7 @@ EXPORT int app_control_get_category(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string value = handle->GetCategory(); *category = strdup(value.c_str()); if (*category == nullptr) { @@ -490,7 +497,7 @@ EXPORT int app_control_set_app_id(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (app_id != nullptr) { try { handle->SetAppId(app_id); @@ -512,7 +519,7 @@ EXPORT int app_control_get_app_id(app_control_h app_control, char** app_id) { } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string value = handle->GetAppId(); *app_id = strdup(value.c_str()); if (*app_id == nullptr) { @@ -532,14 +539,14 @@ EXPORT int app_control_clone(app_control_h* clone, app_control_h app_control) { return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* control = static_cast(app_control); + auto* control = reinterpret_cast(app_control); auto* handle = new (std::nothrow) AppControl(*control); if (handle == nullptr) { _E("Out of memory"); return APP_CONTROL_ERROR_OUT_OF_MEMORY; } - *clone = static_cast(handle); + *clone = reinterpret_cast(handle); return APP_CONTROL_ERROR_NONE; } @@ -558,7 +565,7 @@ EXPORT int app_control_set_launch_mode(app_control_h app_control, LaunchMode launch_mode = (mode == APP_CONTROL_LAUNCH_MODE_SINGLE) ? LaunchMode::Single : LaunchMode::Group; - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); handle->SetLaunchMode(launch_mode); return APP_CONTROL_ERROR_NONE; } @@ -571,7 +578,7 @@ EXPORT int app_control_get_launch_mode(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); LaunchMode launch_mode = handle->GetLaunchMode(); if (launch_mode == LaunchMode::Group) *mode = APP_CONTROL_LAUNCH_MODE_GROUP; @@ -597,7 +604,7 @@ EXPORT int app_control_set_defapp(app_control_h app_control, if (ret != APP_CONTROL_ERROR_NONE) return ret; - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); ret = aul_set_default_app_by_operation(handle->ToBundle()); if (ret != AUL_R_OK) { _E("Failed to set default application. app_id(%s), error(%d)", app_id, ret); @@ -636,7 +643,7 @@ EXPORT int app_control_add_extra_data(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); try { handle->AddExtraData(key, value); } catch (Exception& e) { @@ -656,7 +663,7 @@ EXPORT int app_control_add_extra_data_array(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::vector values(value, value + length); handle->AddExtraDataArray(key, values); } catch (Exception& e) { @@ -675,7 +682,7 @@ EXPORT int app_control_remove_extra_data(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); handle->RemoveExtraData(key); } catch (Exception& e) { _E("Failed to remove extra data. error(%d)", e.GetErrorCode()); @@ -693,7 +700,7 @@ EXPORT int app_control_get_extra_data(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string extra_data = handle->GetExtraData(key); *value = strdup(extra_data.c_str()); if (*value == nullptr) { @@ -719,7 +726,7 @@ EXPORT int app_control_get_extra_data_array(app_control_h app_control, char** array_data = nullptr; int array_data_length = 0; try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::vector values = handle->GetExtraDataArray(key); array_data = reinterpret_cast(calloc(values.size(), sizeof(char*))); if (array_data == nullptr) { @@ -748,7 +755,7 @@ EXPORT int app_control_is_extra_data_array(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); *array = handle->IsExtraDataArray(key); } catch (Exception& e) { _E("Failed to check whether the data is array or not. key(%s), error(%d)", @@ -766,7 +773,7 @@ EXPORT int app_control_foreach_extra_data(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); for (auto& key : handle->GetExtraDataKeys()) { if (!callback(app_control, key.c_str(), user_data)) break; @@ -782,7 +789,7 @@ EXPORT int app_control_foreach_app_matched(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); for (auto& app_id : handle->GetMatchedAppIds()) { if (!callback(app_control, app_id.c_str(), user_data)) break; @@ -798,7 +805,7 @@ EXPORT int app_control_get_caller(app_control_h app_control, char** app_id) { } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string caller = handle->GetCaller(); *app_id = strdup(caller.c_str()); if (*app_id == nullptr) { @@ -821,7 +828,7 @@ EXPORT int app_control_is_reply_requested(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); *requested = handle->IsReplyRequested(); } catch (Exception& e) { _E("Invalid app-control handle"); @@ -838,7 +845,7 @@ EXPORT int app_control_import_from_bundle(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); tizen_base::Bundle b(data, true, true); handle->SetBundle(b); return APP_CONTROL_ERROR_NONE; @@ -851,7 +858,7 @@ EXPORT int app_control_export_as_bundle(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); auto* b = handle->ToBundle(); *data = bundle_dup(b); if (*data == nullptr) { @@ -870,7 +877,7 @@ EXPORT int app_control_enable_app_started_result_event( } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); handle->EnableAppStartedResultEvent(); } catch (Exception& e) { return APP_CONTROL_ERROR_INVALID_PARAMETER; @@ -886,7 +893,7 @@ EXPORT int app_control_set_instance_id(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (instance_id != nullptr) { try { handle->SetInstanceId(instance_id); @@ -909,7 +916,7 @@ EXPORT int app_control_get_instance_id(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string value = handle->GetInstanceId(); *instance_id = strdup(value.c_str()); if (*instance_id == nullptr) { @@ -964,7 +971,7 @@ EXPORT int app_control_set_caller_instance_id(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (instance_id != nullptr) { try { handle->SetCallerInstanceId(instance_id); @@ -986,7 +993,7 @@ EXPORT int app_control_set_component_id(app_control_h app_control, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (component_id != nullptr) { try { handle->SetComponentId(component_id); @@ -1009,7 +1016,7 @@ EXPORT int app_control_get_component_id(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); std::string value = handle->GetComponentId(); *component_id = strdup(value.c_str()); if (*component_id == nullptr) { @@ -1038,7 +1045,7 @@ EXPORT int app_control_prepare_app_defined_loader(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); handle->SetAppDefinedLoader(loader_name); handle->SetLoaderId(loader_id); } catch (Exception& e) { @@ -1056,7 +1063,7 @@ EXPORT int app_control_send_terminate_request(app_control_h app_control) { return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); if (handle->GetType() != AppControl::Type::Request || handle->GetLaunchedPid() < 0) { _E("Invalid parameter"); @@ -1080,7 +1087,7 @@ EXPORT int app_control_reply_to_launch_request(app_control_h reply, return APP_CONTROL_ERROR_INVALID_PARAMETER; } - auto* handle = static_cast(request); + auto* handle = reinterpret_cast(request); bundle* reply_data; int ret = aul_svc_create_result_bundle(handle->ToBundle(), &reply_data); if (ret != AUL_SVC_RET_OK) { @@ -1092,7 +1099,7 @@ EXPORT int app_control_reply_to_launch_request(app_control_h reply, } AppControl app_control(tizen_base::Bundle(reply_data, false, true)); - auto* reply_handle = static_cast(reply); + auto* reply_handle = reinterpret_cast(reply); for (auto& key : reply_handle->GetExtraDataKeys()) { if (reply_handle->IsExtraDataArray(key)) { app_control.AddExtraDataArray(key, reply_handle->GetExtraDataArray(key)); @@ -1121,7 +1128,7 @@ EXPORT int app_control_send_launch_request(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); auto request_context = std::make_shared( std::shared_ptr(new AppControl(*handle)), nullptr, callback, user_data); @@ -1143,7 +1150,7 @@ EXPORT int app_control_send_launch_request_async(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); auto request_context = std::make_shared( std::shared_ptr(new AppControl(*handle)), result_cb, reply_cb, user_data); @@ -1165,10 +1172,10 @@ EXPORT int app_control_send_launch_request_sync(app_control_h app_control, try { AppControl* reply_handle = nullptr; - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); auto* broker = AppControlBroker::GetInst(); broker->SendLaunchRequest(handle, &reply_handle, result); - *reply = static_cast(reply_handle); + *reply = reinterpret_cast(reply_handle); } catch (Exception& e) { return e.GetErrorCode(); } @@ -1184,7 +1191,7 @@ EXPORT int app_control_send_resume_request(app_control_h app_control, } try { - auto* handle = static_cast(app_control); + auto* handle = reinterpret_cast(app_control); auto request_context = std::make_shared( std::shared_ptr(new AppControl(*handle)), result_cb, nullptr, user_data);