diff options
author | saerome.kim <saerome.kim@samsung.com> | 2019-06-26 10:44:40 +0900 |
---|---|---|
committer | saerome kim <saerome.kim@samsung.com> | 2019-07-02 09:52:37 +0900 |
commit | 77767a9e3b42b01932e74b74f304a8f671cf2a61 (patch) | |
tree | 7e5453cfed997d110b88f622ead236d99e0c35c5 | |
parent | 45031aca6c59c937d6d2457a54ba5c299518d3f8 (diff) | |
download | user-awareness-77767a9e3b42b01932e74b74f304a8f671cf2a61.tar.gz user-awareness-77767a9e3b42b01932e74b74f304a8f671cf2a61.tar.bz2 user-awareness-77767a9e3b42b01932e74b74f304a8f671cf2a61.zip |
Removed the return code after error check
Changed API naming
- ua_monitor_start_scan_devices
- ua_monitor_cancel_scan_devices
Change-Id: If5431fe10e831c41e621c3b959ff7f33624a2a6b
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
-rw-r--r-- | include/user-awareness.h | 18 | ||||
-rw-r--r-- | src/user-awareness-monitors.c | 6 | ||||
-rw-r--r-- | test/uat-detections.c | 30 | ||||
-rw-r--r--[-rwxr-xr-x] | test/uat-devices.c | 45 | ||||
-rwxr-xr-x[-rw-r--r--] | test/uat-menu.h | 26 | ||||
-rw-r--r-- | test/uat-sensors.c | 20 | ||||
-rw-r--r-- | test/uat-service.c | 19 | ||||
-rw-r--r--[-rwxr-xr-x] | test/uat-users.c | 51 |
8 files changed, 84 insertions, 131 deletions
diff --git a/include/user-awareness.h b/include/user-awareness.h index 436f524..667f877 100644 --- a/include/user-awareness.h +++ b/include/user-awareness.h @@ -272,9 +272,9 @@ typedef void (*ua_monitor_sensor_state_changed_cb)( * @param[in] handle The monitor handle * @param[in] device_handle The device handle to detected device's information. When scan * is complete, it is set to NULL. - * @param[in] user_data The user data passed in ua_monitor_start_scan_registered_devices() + * @param[in] user_data The user data passed in ua_monitor_start_scan_devices() * - * @see ua_monitor_start_scan_registered_devices() + * @see ua_monitor_start_scan_devices() */ typedef void (*ua_scan_completed_cb)( ua_active_scan_type_e type, @@ -747,8 +747,8 @@ int ua_monitor_unset_user_presence_detected_cb( * * @remarks Only one scan can run at one time. * - * @param[in] scan_time_multiplier A value which we will multiply by UA_SCAN_TIME_MULTIPLIER. This is maximum time for which scan can run, but scan can complete earlier also. * @param[in] handle The monitor handle + * @param[in] scan_time_multiplier A value which we will multiply by UA_SCAN_TIME_MULTIPLIER. This is maximum time for which scan can run, but scan can complete earlier also. * @param[in] callback It will be called for each scanned device one by one, and on scan completion too. * @param[in] user_data The user data to be passed when callback is called. * @@ -761,17 +761,17 @@ int ua_monitor_unset_user_presence_detected_cb( * * @see UA_SCAN_TIME_MULTIPLIER * @see ua_scan_completed_cb() - * @see ua_monitor_cancel_scan_registered_devices() + * @see ua_monitor_cancel_scan_devices() */ -int ua_monitor_start_scan_registered_devices( - int scan_time_multiplier, +int ua_monitor_start_scan_devices( ua_monitor_h handle, + int scan_time_multiplier, ua_scan_completed_cb callback, void *user_data); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Stops ua_monitor_start_scan_registered_devices(). + * @brief Stops ua_monitor_start_scan_devices(). * @since_tizen 5.5 * * @param[in] monitor UA monitor's handle @@ -782,9 +782,9 @@ int ua_monitor_start_scan_registered_devices( * @retval #UA_ERROR_NOT_IN_PROGRESS Operation not in progress * @retval #UA_ERROR_OPERATION_FAILED Operation failed * - * @see ua_monitor_start_scan_registered_devices() + * @see ua_monitor_start_scan_devices() */ -int ua_monitor_cancel_scan_registered_devices(ua_monitor_h monitor); +int ua_monitor_cancel_scan_devices(ua_monitor_h monitor); /** diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index 184259c..f3c6a3d 100644 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -404,9 +404,9 @@ int ua_monitor_remove_sensor( return UA_ERROR_NONE; } -int ua_monitor_start_scan_registered_devices( - int scan_time, +int ua_monitor_start_scan_devices( ua_monitor_h handle, + int scan_time, ua_scan_completed_cb callback, void *user_data) { @@ -442,7 +442,7 @@ int ua_monitor_start_scan_registered_devices( return UA_ERROR_NONE; } -int ua_monitor_cancel_scan_registered_devices(ua_monitor_h handle) +int ua_monitor_cancel_scan_devices(ua_monitor_h handle) { FUNC_ENTRY; int ret; diff --git a/test/uat-detections.c b/test/uat-detections.c index 474b228..2f856e7 100644 --- a/test/uat-detections.c +++ b/test/uat-detections.c @@ -57,6 +57,8 @@ static int run_ua_monitor_start_presence_detection( ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID; + check_if(g_ua_mon_h); + if (strlen(g_presence_type)) detection_mode = (unsigned char)strtol(g_presence_type, NULL, 10); @@ -77,6 +79,8 @@ static int run_ua_monitor_stop_presence_detection( msg("ua_monitor_stop_presence_detectio"); + check_if(g_ua_mon_h); + ret = ua_monitor_stop_presence_detection(g_ua_mon_h); msg(" - ua_monitor_stop_presence_detectio() ret: [0x%X] [%s]", @@ -94,6 +98,8 @@ static int run_ua_monitor_start_absence_detection( ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID; + check_if(g_ua_mon_h); + if (strlen(g_absence_type)) detection_mode = (unsigned char)strtol((g_absence_type), NULL, 10); @@ -114,6 +120,8 @@ static int run_ua_monitor_stop_absence_detection( msg("ua_monitor_stop_absence_detection"); + check_if(g_ua_mon_h); + ret = ua_monitor_stop_absence_detection(g_ua_mon_h); msg(" - ua_monitor_stop_absence_detection() ret: [0x%X] [%s]", @@ -156,18 +164,20 @@ void ua_test_scan_completed_cb(ua_active_scan_type_e result, ua_monitor_h handle msg("SCAN COMPLETED!!"); } -static int run_ua_monitor_start_device_scan( +static int run_ua_monitor_start_scan_devices( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; unsigned int scantimemultiplier = 0; - msg("ua_monitor_start_device_scan"); + msg("ua_monitor_start_scan_devices"); + + check_if(g_ua_mon_h); if (strlen(g_scan_time_multiplier)) scantimemultiplier = (unsigned int)strtol(g_scan_time_multiplier, NULL, 10); - ret = ua_monitor_start_scan_registered_devices(scantimemultiplier, g_ua_mon_h, + ret = ua_monitor_start_scan_devices(g_ua_mon_h, scantimemultiplier ua_test_scan_completed_cb, NULL); msg(" - ua_monitor_stop_absence_detection() ret: [0x%X] [%s]", @@ -176,16 +186,18 @@ static int run_ua_monitor_start_device_scan( return RET_SUCCESS; } -static int run_ua_monitor_cancel_scan_registered_devices( +static int run_ua_monitor_cancel_scan_devices( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; - msg("ua_monitor_cancel_scan_registered_devices,"); + msg("ua_monitor_cancel_scan_devices,"); + + check_if(g_ua_mon_h); - ret = ua_monitor_cancel_scan_registered_devices(g_ua_mon_h); + ret = ua_monitor_cancel_scan_devices(g_ua_mon_h); - msg("ua_monitor_cancel_scan_registered_devices,() ret: [0x%X] [%s]", + msg("ua_monitor_cancel_scan_devices,() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; @@ -210,7 +222,7 @@ struct menu_data menu_ua_detections[] = { NULL, run_ua_monitor_stop_absence_detection, NULL }, { "5", "ua_monitor_start_device_scan", menu_start_device_scan, NULL, NULL }, - { "6", "ua_monitor_cancel_scan_registered_devices", - NULL, run_ua_monitor_cancel_scan_registered_devices, NULL }, + { "6", "ua_monitor_cancel_scan_devices", + NULL, run_ua_monitor_cancel_scan_devices, NULL }, { NULL, NULL, }, }; diff --git a/test/uat-devices.c b/test/uat-devices.c index 381e383..ec8d5e0 100755..100644 --- a/test/uat-devices.c +++ b/test/uat-devices.c @@ -219,7 +219,6 @@ static int run_ua_device_set_mac_type( static void update_device_info(void) { - int ret = UA_ERROR_NONE; ua_mac_type_e mac_type = UA_MAC_TYPE_INVALID; ua_os_type_e ostype = UA_OS_TYPE_NOT_DEFINE; @@ -543,15 +542,8 @@ static int run_ua_user_add_device( msg("ua_user_add_device"); - if (!g_user_h) { - msgb("Add device to default@default.com"); - } - - - if (!g_device_h) { - msgr("Select or create a device first!!"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); + check_if(NULL == g_device_h); ret = ua_user_add_device(g_user_h, g_device_h, __device_added_cb, NULL); @@ -568,15 +560,8 @@ static int run_ua_user_remove_device( msg("ua_user_remove_device"); - if (!g_user_h) { - msgr("Select or create a user first!!"); - return RET_SUCCESS; - } - - if (!g_device_h) { - msgr("Select or create a device first!!"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); + check_if(NULL == g_device_h); ret = ua_user_remove_device(g_user_h, g_device_h); @@ -593,15 +578,8 @@ static int run_ua_service_add_device( msg("ua_service_add_device"); - if (!g_service_h) { - msgr("Select or create a service first!!"); - return RET_SUCCESS; - } - - if (!g_device_h) { - msgr("Select or create a device first!!"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); + check_if(NULL == g_device_h); ret = ua_service_add_device(g_service_h, g_device_h); @@ -618,15 +596,8 @@ static int run_ua_service_remove_device( msg("ua_service_remove_device"); - if (!g_service_h) { - msgr("Select or create a service first!!"); - return RET_SUCCESS; - } - - if (!g_device_h) { - msgr("Select or create a device first!!"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); + check_if(NULL == g_device_h); ret = ua_service_remove_device(g_service_h, g_device_h); diff --git a/test/uat-menu.h b/test/uat-menu.h index 5fedaf3..a26c856 100644..100755 --- a/test/uat-menu.h +++ b/test/uat-menu.h @@ -75,9 +75,31 @@ __BEGIN_DECLS fprintf(stdout, "\e[%dC" fmt "\n", \ 3 + ((n) * 2), ##args); fflush(stdout); } while (0) -#define MENU_DATA_SIZE 255 - +/* Null check */ +#define check_if(expr) \ +do { \ + if (expr) { \ + msgr("(%s) ", #expr); \ + } \ +} while (0) + +#define ret_if(expr) \ +do { \ + if (expr) { \ + msgr("(%s) return", #expr); \ + return; \ + } \ +} while (0) + +#define retv_if(expr, val) \ +do { \ + if (expr) { \ + msgr("(%s) return", #expr); \ + return (val); \ + } \ +} while (0) +#define MENU_DATA_SIZE 255 /* * Horizontal Line - width: 65 diff --git a/test/uat-sensors.c b/test/uat-sensors.c index 86b8472..9451792 100644 --- a/test/uat-sensors.c +++ b/test/uat-sensors.c @@ -134,10 +134,7 @@ static int run_ua_monitor_add_sensor( int ret = UA_ERROR_NONE; msg("ua_monitor_add_sensor"); - if (!g_ua_mon_h) { - msg("Create monitor first"); - return RET_SUCCESS; - } + check_if(g_ua_mon_h); if (strlen(g_sensor_type)) { sensortype = (unsigned char)strtol(g_sensor_type, NULL, 10); @@ -165,10 +162,7 @@ static int run_ua_monitor_remove_sensor( msg("ua_monitor_remove_sensor"); - if (!g_ua_mon_h) { - msg("Create monitor first"); - return RET_SUCCESS; - } + check_if(g_ua_mon_h); if (strlen(g_sensor_type)) { sensortype = (unsigned char)strtol(g_sensor_type, NULL, 10); @@ -198,10 +192,7 @@ static int run_ua_monitor_is_sensor_available( msg("ua_monitor_is_sensor_available"); - if (!g_ua_mon_h) { - msg("Create monitor first"); - return RET_SUCCESS; - } + check_if(g_ua_mon_h); if (strlen(g_sensor_type)) { sensortype = (unsigned char)strtol(g_sensor_type, NULL, 10); @@ -235,10 +226,7 @@ static int run_ua_monitor_set_brightness_threshold( msg("ua_monitor_set_brightness_threshold"); - if (!g_ua_mon_h) { - msg("Create monitor first"); - return RET_SUCCESS; - } + check_if(g_ua_mon_h); if (strlen(g_presence_threshold)) presencethreshold = (unsigned int)strtol(g_presence_threshold, NULL, 10); diff --git a/test/uat-service.c b/test/uat-service.c index 4bf83b8..1f28224 100644 --- a/test/uat-service.c +++ b/test/uat-service.c @@ -59,18 +59,12 @@ static void __update_service_info(void) static void ___free_service(gpointer data) { ua_service_h handle = data; - if (NULL == handle) - return; - ua_service_destroy(handle); handle = NULL; } static void __clear_service_list(void) { - if (NULL == g_service_list) - return; - g_slist_free_full(g_service_list, ___free_service); g_service_list = NULL; g_service_count = 0; @@ -82,8 +76,7 @@ static bool __foreach_added_service_cb( int ret = UA_ERROR_NONE; char *name = NULL; - if (!service_handle) - return true; + check_If(NULL == service_handle) ua_service_get_name(service_handle, &name); if (UA_ERROR_NONE != ret) { @@ -167,10 +160,7 @@ static int run_ua_service_add( msg("ua_service_add"); - if (NULL == g_service_h) { - msg("Create service handlel first"); - return RET_SUCCESS; - } + check_if(g_service_h); ret = ua_service_set_name(g_service_h, g_service_str); @@ -189,10 +179,7 @@ static int run_ua_service_remove( msg("ua_service_remove"); - if (NULL == g_service_h) { - msg("Create service handlel first"); - return RET_SUCCESS; - } + check_if(g_service_h); ret = ua_service_remove(g_service_h); diff --git a/test/uat-users.c b/test/uat-users.c index 337824b..c376710 100755..100644 --- a/test/uat-users.c +++ b/test/uat-users.c @@ -71,17 +71,12 @@ static void update_user_info(void) static void ___free_users(gpointer data) { ua_user_h handle = data; - if (NULL == handle) - return; ua_user_destroy(handle); handle = NULL; } static void __clear_user_list(void) { - if (NULL == user_list) - return; - g_slist_free_full(user_list, ___free_users); user_list = NULL; idx_user = 0; @@ -179,10 +174,7 @@ static int run_ua_user_set_account(MManager *mm, struct menu_data *menu) msg("ua_user_set_account"); - if (NULL == g_user_h) { - msg("Create or select a user first"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); ret = ua_user_set_account(g_user_h, g_user_account_str); @@ -198,10 +190,7 @@ static int run_ua_user_set_name(MManager *mm, struct menu_data *menu) msg("ua_user_set_name"); - if (NULL == g_user_h) { - msg("Create or select a user first"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); ret = ua_user_set_name(g_user_h, g_user_name_str); @@ -217,10 +206,7 @@ static int run_ua_user_add(MManager *mm, struct menu_data *menu) msg("ua_user_add"); - if (NULL == g_user_h) { - msg("Create or select a user first"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); ret = ua_user_add(g_user_h); @@ -236,10 +222,7 @@ static int run_ua_user_remove(MManager *mm, struct menu_data *menu) msg("ua_user_remove"); - if (NULL == g_user_h) { - msg("Create or select a user first"); - return RET_SUCCESS; - } + check_if(NULL == g_user_h); ret = ua_user_remove(g_user_h); @@ -315,15 +298,10 @@ static int run_ua_service_add_user(MManager *mm, struct menu_data *menu) msg("ua_service_add_user"); - if ('\0' == g_user_account_str[0] || NULL == g_user_h) { - msg("Create or select a user first"); - return RET_SUCCESS; - } - - if ('\0' == g_service_str[0] || NULL == g_service_h) { - msg("Create or select a service first"); - return RET_SUCCESS; - } + check_if('\0' == g_user_account_str[0]); + check_if(NULL == g_user_h); + check_if('\0' == g_service_str[0]); + check_if(NULL == g_service_h); ret = ua_service_add_user(g_service_h, g_user_h); @@ -339,15 +317,10 @@ static int run_ua_service_remove_user(MManager *mm, struct menu_data *menu) msg("ua_service_remove_user"); - if ('\0' == g_user_account_str[0] || NULL == g_user_h) { - msg("Create user handlel first"); - return RET_SUCCESS; - } - - if ('\0' == g_service_str[0] || NULL == g_service_h) { - msg("Create or select a service first"); - return RET_SUCCESS; - } + check_if('\0' == g_user_account_str[0]); + check_if(NULL == g_user_h); + check_if('\0' == g_service_str[0]); + check_if(NULL == g_service_h); ret = ua_service_remove_user(g_service_h, g_user_h); |