Fix coverity issue 1149129
[apps/native/volume-app.git] / src / view.c
index 594a024..7f25b1e 100755 (executable)
@@ -164,13 +164,15 @@ sound_type_e volume_view_pre_sound_type_get(void)
        return view_info.pre_sound_type;
 }
 
-volume_error_e volume_view_set_default_slider(){
+volume_error_e volume_view_set_default_slider()
+{
        Evas_Object *slider = volume_view_slider_get();
        elm_object_style_set(slider, "default");
        return VOLUME_ERROR_OK;
 }
 
-volume_error_e volume_view_set_warning_slider(){
+volume_error_e volume_view_set_warning_slider()
+{
        Evas_Object *slider = volume_view_slider_get();
        elm_object_style_set(slider, "warning");
        Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
@@ -196,12 +198,11 @@ int volume_mute_toggle_set()
                volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 0);
                volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0);
 
-               if(VOLUME_ERROR_OK != volume_view_slider_value_set(0))
+               if (VOLUME_ERROR_OK != volume_view_slider_value_set(0))
                        _E("Failed to set slider value");
 
                return 0;
-       }
-       else {
+       } else {
                volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 1);
                volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0);
 
@@ -295,9 +296,8 @@ volume_error_e volume_view_open_warning_popup(void)
 void volume_view_destroy_warning_popup(void)
 {
        _D("Destroy warning popup");
-       if (VOLUME_ERROR_OK != volume_view_send_warning_signal(EINA_FALSE)) {
+       if (VOLUME_ERROR_OK != volume_view_send_warning_signal(EINA_FALSE))
                _E("Failed to set warning status");
-       }
 
        evas_object_del(view_info.warning_popup);
        view_info.warning_popup = NULL;
@@ -312,7 +312,7 @@ volume_error_e volume_view_slider_value_set(int val)
 {
        _D("Slider value set : %d", val);
        retv_if(view_info.is_slider_touching, VOLUME_ERROR_FAIL);
-       retv_if(val<0, VOLUME_ERROR_FAIL);
+       retv_if(val < 0, VOLUME_ERROR_FAIL);
 
        elm_slider_value_set(view_info.slider, val);
 
@@ -331,8 +331,7 @@ void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int vibrati
                return;
        }
 
-       switch (sound_type)
-       {
+       switch (sound_type) {
        case SOUND_TYPE_ALARM:
        case SOUND_TYPE_RINGTONE:
                if (sound)
@@ -357,7 +356,7 @@ void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int vibrati
        case SOUND_TYPE_NOTIFICATION:
                if (sound)
                        img = IMG_VOLUME_ICON_NOTI;
-               else if(vibration)
+               else if (vibration)
                        img = IMG_VOLUME_ICON_NOTI_VIB;
                else
                        img = IMG_VOLUME_ICON_NOTI_MUTE;
@@ -376,8 +375,7 @@ void volume_view_volume_icon_name_set_for_access(sound_type_e sound_type)
        _D("Volume icon name set");
        char buf[2056];
 
-       switch (sound_type)
-       {
+       switch (sound_type) {
        case SOUND_TYPE_RINGTONE:
                snprintf(buf, sizeof(buf), "%s%s", _("IDS_ST_HEADER_RINGTONES"), "volume");
                break;
@@ -408,7 +406,7 @@ void volume_view_setting_icon_set(const char *file)
        ret_if(!icon_setting);
 
        if (EINA_TRUE != elm_image_file_set(icon_setting, volume_view_get_file_path(EDJ_APP), file)) {
-               _E("Failed to set image file : %s, Group", EDJ_APP, file);
+               _E("Failed to set image file : %s, Group", file);
        };
 }
 
@@ -465,17 +463,17 @@ volume_error_e volume_view_send_warning_signal(Eina_Bool warning)
        } else {
                int current_angle = volume_control_get_current_angle();
                _D("Current angle: %d", current_angle);
-        switch(current_angle){
-        case 90 :
-        case 270 :
-            _D("show,landscape");
-            elm_object_signal_emit(view_info.ly_outer, "show,landscape", "bg");
-            break;
-        default :
-            _D("show,portrait");
-            elm_object_signal_emit(view_info.ly_outer, "show,portrait", "bg");
-            break;
-        }
+               switch (current_angle) {
+               case 90:
+               case 270:
+                       _D("show,landscape");
+                       elm_object_signal_emit(view_info.ly_outer, "show,landscape", "bg");
+                       break;
+               default:
+                       _D("show,portrait");
+                       elm_object_signal_emit(view_info.ly_outer, "show,portrait", "bg");
+                       break;
+               }
        }
        return VOLUME_ERROR_OK;
 }
@@ -484,13 +482,12 @@ volume_error_e volume_view_window_show(sound_type_e type)
 {
        _D("Volume view window SHOW is [%p]", view_info.win);
 
-       elm_win_iconified_set(view_info.win, EINA_FALSE);
+       elm_win_activate(view_info.win);
 
-       if (type == SOUND_TYPE_CALL) {
+       if (type == SOUND_TYPE_CALL)
                _D("Sound type is Call");
-       } else {
+       else
                volume_view_setting_icon_callback_add();
-       }
 
        return VOLUME_ERROR_OK;
 }
@@ -533,14 +530,12 @@ void _connect_to_wm(Evas_Object *win)
        tzsh_window tz_win;
 
        view_info.tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL);
-       if (!view_info.tzsh) {
+       if (!view_info.tzsh)
                _E("Failed to get connection to Tizen window manager");
-       }
 
        tz_win = elm_win_window_id_get(win);
-       if (!tz_win) {
+       if (!tz_win)
                _E("Failed to get Tizen window manager");
-       }
 
        /*
         * Tizen SDK do not support tzsh yet
@@ -548,9 +543,8 @@ void _connect_to_wm(Evas_Object *win)
         */
 #if 0
        view_info.volume_service = tzsh_volume_service_create(view_info.tzsh, tz_win);
-       if (!view_info.volume_service) {
+       if (!view_info.volume_service)
                _E("Failed to get volume service");
-       }
 #endif
 }
 
@@ -558,7 +552,8 @@ static void _down_for_hide(void *data, Evas_Object *obj, const char* emission, c
 {
        _D("Down for HIDE");
 
-       volume_control_hide_view();
+       if (VOLUME_ERROR_OK != volume_control_hide_view())
+               _E("Failed to close volume");
 }
 
 volume_error_e volume_view_layout_create(Evas_Object *win)
@@ -698,7 +693,9 @@ void _lock_sound_check(void)
                }
                _D("lock type : %d", lock_type);
 
-               feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_LOCK);
+               if (FEEDBACK_ERROR_NONE != feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_LOCK)) {
+                       _E("Failed to play vibration");
+               }
        }
 }
 
@@ -718,10 +715,10 @@ Evas_Object* show_lockscreen_splash(const char* bg_path)
        _lock_sound_check();
 
        /* hide volume window */
-       if(VOLUME_ERROR_OK != volume_view_window_hide())
+       if (VOLUME_ERROR_OK != volume_view_window_hide())
                _E("Failed to hide window");
 
-       Evas_Object *win_splash = elm_win_add(NULL,"lockscreen_splash", ELM_WIN_NOTIFICATION);
+       Evas_Object *win_splash = elm_win_add(NULL, "lockscreen_splash", ELM_WIN_NOTIFICATION);
 
        if (!win_splash) {
                _E("Failed to add splash window");
@@ -785,7 +782,7 @@ static void _slider_changed_cb(void *data, Evas_Object *obj, void *event_info)
 
        val = elm_slider_value_get(view_info.slider);
        val += 0.5;
-       _D("slider value : %d", val);
+       _D("slider value : %lf", val);
 
        if (view_info.is_slider_touching)
                return;
@@ -836,21 +833,20 @@ static void _button_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *e
 static void _app_control_error_check(int ret)
 {
        if (ret != APP_CONTROL_ERROR_NONE) {
-               switch (ret)
-               {
-               case APP_CONTROL_ERROR_INVALID_PARAMETER :
+               switch (ret) {
+               case APP_CONTROL_ERROR_INVALID_PARAMETER:
                        _E("error : APP_CONTROL_ERROR_INVALID_PARAMETER");
                        break;
-               case APP_CONTROL_ERROR_OUT_OF_MEMORY :
+               case APP_CONTROL_ERROR_OUT_OF_MEMORY:
                        _E("error : APP_CONTROL_ERROR_OUT_OF_MEMORY");
                        break;
-               case APP_CONTROL_ERROR_APP_NOT_FOUND :
+               case APP_CONTROL_ERROR_APP_NOT_FOUND:
                        _E("error : APP_CONTROL_ERROR_APP_NOT_FOUND");
                        break;
-               case APP_CONTROL_ERROR_LAUNCH_REJECTED :
+               case APP_CONTROL_ERROR_LAUNCH_REJECTED:
                        _E("error : APP_CONTROL_ERROR_LAUNCH_REJECTED");
                        break;
-               default :
+               default:
                        _E("error : %d", ret);
                        break;
                }