summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhay Agarwal <ay.agarwal@samsung.com>2022-09-26 13:03:21 +0530
committerAbhay Agarwal <ay.agarwal@samsung.com>2022-09-26 14:28:25 +0530
commit77316e314d75805faaaa0c53a34bff6e52ba79a4 (patch)
treeb92fb2917b48c55c36407a6fa872b25e6a2f1ddd
parent70d3db0a403273973029f9cdd957019919f73a0b (diff)
downloadua-manager-77316e314d75805faaaa0c53a34bff6e52ba79a4.tar.gz
ua-manager-77316e314d75805faaaa0c53a34bff6e52ba79a4.tar.bz2
ua-manager-77316e314d75805faaaa0c53a34bff6e52ba79a4.zip
Remove code duplicacy in ua-api
Change-Id: I491677f3a2fd73c61f369798570576b4512f1209 Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rwxr-xr-xua-api/src/ua-api.c66
1 files changed, 21 insertions, 45 deletions
diff --git a/ua-api/src/ua-api.c b/ua-api/src/ua-api.c
index bc6c63c..69bc64b 100755
--- a/ua-api/src/ua-api.c
+++ b/ua-api/src/ua-api.c
@@ -896,7 +896,8 @@ UAM_EXPORT_API int _uam_deregister_app(const char *app_id, unsigned short uid)
return ret;
}
-UAM_EXPORT_API int _uam_service_add_user(const char *service, const char *account)
+static int __uam_service_add_remove_user(int req_fun,
+ const char *service, const char *account)
{
FUNC_ENTRY;
int ret;
@@ -915,8 +916,8 @@ UAM_EXPORT_API int _uam_service_add_user(const char *service, const char *accoun
g_strlcpy(account_str, account, UAM_USER_ACCOUNT_MAX_STRING_LEN);
g_array_append_vals(in_param2, account_str, sizeof(account_str));
- ret = _uam_sync_request(UAM_REQUEST_ADD_USER_TO_SERVICE,
- in_param1, in_param2, in_param3, in_param4, &out_param);
+ ret = _uam_sync_request(req_fun, in_param1, in_param2,
+ in_param3, in_param4, &out_param);
UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -924,33 +925,17 @@ UAM_EXPORT_API int _uam_service_add_user(const char *service, const char *accoun
return ret;
}
+UAM_EXPORT_API int _uam_service_add_user(const char *service, const char *account)
+{
+ return __uam_service_add_remove_user(
+ UAM_REQUEST_ADD_USER_TO_SERVICE, service, account);
+}
+
UAM_EXPORT_API int _uam_service_remove_user(const char *service,
const char *account)
{
- FUNC_ENTRY;
- int ret;
- char svc_str[UAM_SERVICE_MAX_STRING_LEN];
- char account_str[UAM_USER_ACCOUNT_MAX_STRING_LEN];
-
- UAM_VALIDATE_INPUT_PARAMETER(service);
- UAM_VALIDATE_INPUT_PARAMETER(account);
-
- UAM_INIT_PARAMS();
- UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
- g_strlcpy(svc_str, service, UAM_SERVICE_MAX_STRING_LEN);
- g_array_append_vals(in_param1, svc_str, sizeof(svc_str));
-
- g_strlcpy(account_str, account, UAM_USER_ACCOUNT_MAX_STRING_LEN);
- g_array_append_vals(in_param2, account_str, sizeof(account_str));
-
- ret = _uam_sync_request(UAM_REQUEST_REMOVE_USER_FROM_SERVICE,
- in_param1, in_param2, in_param3, in_param4, &out_param);
-
- UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
- FUNC_EXIT;
- return ret;
+ return __uam_service_add_remove_user(
+ UAM_REQUEST_REMOVE_USER_FROM_SERVICE, service, account);
}
static int __uam_service_sync_request(int req_func, const char *service,
@@ -1109,7 +1094,6 @@ UAM_EXPORT_API int _uam_get_default_service(uam_service_info_s *service)
FUNC_ENTRY;
int ret;
-
UAM_VALIDATE_INPUT_PARAMETER(service);
UAM_INIT_PARAMS();
@@ -1437,7 +1421,7 @@ UAM_EXPORT_API int _uam_get_added_payloads(GPtrArray **payload_list)
return ret;
}
-UAM_EXPORT_API int _uam_request_add_sensor(unsigned int bitmask)
+static int __uam_request_add_remove_sensor(int req_fun, unsigned int bitmask)
{
FUNC_ENTRY;
int ret;
@@ -1446,8 +1430,8 @@ UAM_EXPORT_API int _uam_request_add_sensor(unsigned int bitmask)
UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
g_array_append_vals(in_param1, &bitmask, sizeof(unsigned int));
- ret = _uam_sync_request(UAM_REQUEST_ADD_SENSOR,
- in_param1, in_param2, in_param3, in_param4, &out_param);
+ ret = _uam_sync_request(req_fun, in_param1, in_param2,
+ in_param3, in_param4, &out_param);
UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -1455,20 +1439,12 @@ UAM_EXPORT_API int _uam_request_add_sensor(unsigned int bitmask)
return ret;
}
-UAM_EXPORT_API int _uam_request_remove_sensor(unsigned int bitmask)
+UAM_EXPORT_API int _uam_request_add_sensor(unsigned int bitmask)
{
- FUNC_ENTRY;
- int ret;
-
- UAM_INIT_PARAMS();
- UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-
- g_array_append_vals(in_param1, &bitmask, sizeof(unsigned int));
- ret = _uam_sync_request(UAM_REQUEST_REMOVE_SENSOR,
- in_param1, in_param2, in_param3, in_param4, &out_param);
-
- UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+ return __uam_request_add_remove_sensor(UAM_REQUEST_ADD_SENSOR, bitmask);
+}
- FUNC_EXIT;
- return ret;
+UAM_EXPORT_API int _uam_request_remove_sensor(unsigned int bitmask)
+{
+ return __uam_request_add_remove_sensor(UAM_REQUEST_REMOVE_SENSOR, bitmask);
}