modules/connection/connection: Code style fixed.
authorRadoslaw Czerski <r.czerski@samsung.com>
Thu, 3 Mar 2016 13:45:24 +0000 (14:45 +0100)
committerRadoslaw Czerski <r.czerski@samsung.com>
Thu, 10 Mar 2016 14:12:13 +0000 (15:12 +0100)
Change-Id: I05a7023b1f1302dfb567ead80f151b6d04f7b9be
Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
src/modules/connection/connection.c

index a7c84d7..cc1c677 100644 (file)
@@ -17,8 +17,6 @@
  *
  */
 
-
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <wifi.h>
@@ -90,21 +88,18 @@ static const char *icon_path[LEVEL_LAST] = {
        [LEVEL_BT_TETHERING] = "Bluetooth, NFC, GPS/B03_BT_tethering_network.png"
 };
 
-
-
-static void set_app_state(void* data)
+static void set_app_state(void *data)
 {
        conn.ad = data;
 }
 
-
-
-static void show_connection_transfer_icon(void* data)
+static void show_connection_transfer_icon(void *data)
 {
        int state = 0;
        int ret = 0;
 
        ret = vconf_get_int(VCONFKEY_PACKET_STATE, &state);
+
        if (ret == OK) {
 
                if (transfer_state == state) {
@@ -117,16 +112,16 @@ static void show_connection_transfer_icon(void* data)
 
                switch (state) {
                case VCONFKEY_PACKET_RX:
-                       util_signal_emit(conn.ad,"indicator.connection.updown.download","indicator.prog");
+                       util_signal_emit(conn.ad, "indicator.connection.updown.download", "indicator.prog");
                        break;
                case VCONFKEY_PACKET_TX:
-                       util_signal_emit(conn.ad,"indicator.connection.updown.upload","indicator.prog");
+                       util_signal_emit(conn.ad, "indicator.connection.updown.upload", "indicator.prog");
                        break;
                case VCONFKEY_PACKET_RXTX:
-                       util_signal_emit(conn.ad,"indicator.connection.updown.updownload","indicator.prog");
+                       util_signal_emit(conn.ad, "indicator.connection.updown.updownload", "indicator.prog");
                        break;
                case VCONFKEY_PACKET_NORMAL:
-                       util_signal_emit(conn.ad,"indicator.connection.updown.none","indicator.prog");
+                       util_signal_emit(conn.ad, "indicator.connection.updown.none", "indicator.prog");
                        break;
                default:
                        break;
@@ -134,32 +129,26 @@ static void show_connection_transfer_icon(void* data)
        }
 }
 
-
-
 static void show_image_icon(int type)
 {
-       if(prevIndex == type)
-       {
+       if (prevIndex == type)
                return;
-       }
 
        conn.img_obj.data = icon_path[type];
        icon_show(&conn);
 
        prevIndex = type;
-       util_signal_emit(conn.ad,"indicator.connection.show","indicator.prog");
+       util_signal_emit(conn.ad, "indicator.connection.show", "indicator.prog");
 }
 
-
-
 static void hide_image_icon(void)
 {
        transfer_state = -1;
 
        icon_hide(&conn);
 
-       util_signal_emit(conn.ad,"indicator.connection.hide","indicator.prog");
-       util_signal_emit(conn.ad,"indicator.connection.updown.hide","indicator.prog");
+       util_signal_emit(conn.ad, "indicator.connection.hide", "indicator.prog");
+       util_signal_emit(conn.ad, "indicator.connection.updown.hide", "indicator.prog");
 
        prevIndex = -1;
 }
@@ -200,16 +189,16 @@ static icon_e _icon_level_for_ps_network_type(telephony_network_ps_type_e net_ty
 static void _view_icon_update_ps_network(telephony_network_ps_type_e ps_type, void *data)
 {
        icon_e icon = _icon_level_for_ps_network_type(ps_type);
+
        if (icon != LEVEL_LAST) {
                show_image_icon(icon);
                show_connection_transfer_icon(data);
-       }
-       else {
+       } else
                hide_image_icon();
-       }
 }
 
-static void _view_icon_update_network(telephony_network_service_state_e state, telephony_network_type_e network_type, void *data)
+static void _view_icon_update_network(telephony_network_service_state_e state,
+               telephony_network_type_e network_type, void *data)
 {
        icon_e icon;
 
@@ -219,10 +208,8 @@ static void _view_icon_update_network(telephony_network_service_state_e state, t
                        if (icon != LEVEL_LAST) {
                                show_image_icon(icon);
                                show_connection_transfer_icon(data);
-                       }
-                       else {
+                       } else
                                hide_image_icon();
-                       }
                        break;
                case TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE:
                case TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY:
@@ -238,23 +225,24 @@ static void _view_icon_update(telephony_h handle, void *data)
        telephony_network_service_state_e service_state;
        telephony_network_type_e network_type;
 
-       retif(data == NULL, , "Invalid parameter!");
+       retm_if(data == NULL, "Invalid parameter!");
 
        int ret = telephony_network_get_ps_type(handle, &ps_type);
-       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_ps_type failed %s", get_error_message(ret));
+       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_ps_type failed %s",
+                       get_error_message(ret));
 
        ret = telephony_network_get_type(handle, &network_type);
-       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_type failed %s", get_error_message(ret));
+       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_type failed %s",
+                       get_error_message(ret));
 
        ret = telephony_network_get_service_state(handle, &service_state);
-       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_service_state failed %s", get_error_message(ret));
+       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_service_state failed %s",
+                       get_error_message(ret));
 
-       if (ps_type != TELEPHONY_NETWORK_PS_TYPE_UNKNOWN) {
+       if (ps_type != TELEPHONY_NETWORK_PS_TYPE_UNKNOWN)
                _view_icon_update_ps_network(ps_type, data);
-       }
-       else {
+       else
                _view_icon_update_network(service_state, network_type, data);
-       }
 }
 
 static void on_noti(telephony_h handle, const char *noti_id, void *data, void *user_data)
@@ -264,48 +252,50 @@ static void on_noti(telephony_h handle, const char *noti_id, void *data, void *u
 
        int ret = 0;
        bool val;
-       retif(user_data == NULL, , "invalid parameter!!");
+       retm_if(user_data == NULL, "invalid parameter!!");
 
        ret = wifi_get_connection_state(&state);
-       DBG("WIFI Status : %d", state);
-       retm_if(ret != WIFI_ERROR_NONE, "wifi_get_connection_state failed: %s", get_error_message(ret));
+       _D("WIFI Status : %d", state);
+       retm_if(ret != WIFI_ERROR_NONE, "wifi_get_connection_state failed: %s",
+                       get_error_message(ret));
 
        if (state == WIFI_CONNECTION_STATE_CONNECTED) {
-               DBG("WIFI connected, so hide connection icon");
+               _D("WIFI connected, so hide connection icon");
                hide_image_icon();
                return;
        }
 
        ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, &val);
-       retm_if(ret != SYSTEM_SETTINGS_ERROR_NONE, "system_settings_get_value_bool failed: %s", get_error_message(ret));
+       retm_if(ret != SYSTEM_SETTINGS_ERROR_NONE, "system_settings_get_value_bool failed: %s",
+                       get_error_message(ret));
 
        if (val) {
-               DBG("FLIGHT MODE ON");
+               _D("FLIGHT MODE ON");
                hide_image_icon();
                return;
        }
 
        ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BLUETOOTH_TETHERING_ENABLED, &val);
-       retm_if(ret != RUNTIME_INFO_ERROR_NONE, "runtime_info_get_value_bool failed: %s", get_error_message(ret));
+       retm_if(ret != RUNTIME_INFO_ERROR_NONE, "runtime_info_get_value_bool failed: %s",
+                       get_error_message(ret));
 
        if (val) {
-               DBG("bluetooth tethering On");
+               _D("bluetooth tethering on");
                isBTIconShowing = 1;
                show_image_icon(LEVEL_BT_TETHERING);
-               util_signal_emit(conn.ad,"indicator.connection.updown.hide","indicator.prog");
+               util_signal_emit(conn.ad, "indicator.connection.updown.hide", "indicator.prog");
                return;
-       }
-       else {
-               DBG("bluetooth tethering Off");
-               if(isBTIconShowing == 1)
-               {
+       } else {
+               _D("bluetooth tethering off");
+               if (isBTIconShowing == 1) {
                        isBTIconShowing = 0;
                        hide_image_icon();
                }
        }
 
        ret = telephony_network_get_default_data_subscription(handle, &default_subscription);
-       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_default_data_subscription failed %s", get_error_message(ret));
+       retm_if(ret != TELEPHONY_ERROR_NONE, "telephony_network_get_default_data_subscription failed %s",
+                       get_error_message(ret));
 
        switch (default_subscription) {
                case TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_SIM1:
@@ -321,17 +311,14 @@ static void on_noti(telephony_h handle, const char *noti_id, void *data, void *u
 
 static int wake_up_cb(void *data)
 {
-       if(updated_while_lcd_off==0)
-       {
+       if (updated_while_lcd_off == 0)
                return OK;
-       }
+
        on_noti(tel_list.handle[0], NULL, NULL, data);
        return OK;
 }
 
 
-
-
 static void _update_status_ri(runtime_info_key_e key, void *user_data)
 {
        on_noti(tel_list.handle[0], NULL, NULL, user_data);
@@ -345,25 +332,19 @@ static void _wifi_status_changed_cb(wifi_connection_state_e state, wifi_ap_h ap,
        ret = wifi_get_connection_state(&status);
        if (ret == WIFI_ERROR_NONE) {
                INFO("[CB] WIFI Status: %d", status);
-               if(status == WIFI_CONNECTION_STATE_CONNECTED) {
-                       DBG("[CB] WIFI connected, so hide connection icon");
+               if (status == WIFI_CONNECTION_STATE_CONNECTED) {
+                       _D("[CB] WIFI connected, so hide connection icon");
                        hide_image_icon();
-               }
-               else {
+               } else
                        on_noti(tel_list.handle[0], NULL, NULL, user_data);
-               }
        }
 }
 
-
-
 static void _flight_mode(system_settings_key_e key, void *user_data)
 {
        on_noti(tel_list.handle[0], NULL, NULL, user_data);
 }
 
-
-
 static void _update_status(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
 {
        on_noti(tel_list.handle[0], NULL, NULL, data);
@@ -372,11 +353,11 @@ static void _update_status(telephony_h handle, telephony_noti_e noti_id, void *d
 /* Initialize TAPI */
 static int __init_tel(void *data)
 {
-       DBG("__init_tel");
+       _D("__init_tel");
        int ret, i;
 
        if (!tel_list.count) {
-               DBG("Not SIM handle returned by telephony_init");
+               _D("Not SIM handle returned by telephony_init");
                __deinit_tel();
                return FAIL;
        }
@@ -396,21 +377,25 @@ static int __init_tel(void *data)
 
        ret = util_wifi_set_connection_state_changed_cb(_wifi_status_changed_cb, data);
        if (ret != 0) {
-               ERR("util_wifi_set_connection_state_changed_cb");
+               _E("util_wifi_set_connection_state_changed_cb");
                __deinit_tel();
                return FAIL;
        }
 
-       ret = util_system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, _flight_mode, data);
+       ret = util_system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE,
+                       _flight_mode, data);
+
        if (ret != 0) {
-               ERR("util_system_settings_set_changed_cb failed");
+               _E("util_system_settings_set_changed_cb failed");
                __deinit_tel();
                return FAIL;
        }
 
-       ret = util_runtime_info_set_changed_cb(RUNTIME_INFO_KEY_BLUETOOTH_TETHERING_ENABLED, _update_status_ri, data);
+       ret = util_runtime_info_set_changed_cb(RUNTIME_INFO_KEY_BLUETOOTH_TETHERING_ENABLED,
+                       _update_status_ri, data);
+
        if (ret != 0) {
-               ERR("util_runtime_info_set_changed_cb failed");
+               _E("util_runtime_info_set_changed_cb failed");
                __deinit_tel();
                return FAIL;
        }
@@ -423,7 +408,7 @@ static int __init_tel(void *data)
 /* De-initialize telephony */
 static void __deinit_tel()
 {
-       DBG("__deinit_tel");
+       _D("__deinit_tel");
 
        util_system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, _flight_mode);
        util_wifi_unset_connection_state_changed_cb(_wifi_status_changed_cb);
@@ -438,13 +423,10 @@ static void __deinit_tel()
 
 static void tel_ready_cb(telephony_state_e state, void *user_data)
 {
-       if (state == TELEPHONY_STATE_READY) {    /* Telephony State - READY */
+       if (state == TELEPHONY_STATE_READY)
                __init_tel(user_data);
-       }
-       else if (state == TELEPHONY_STATE_NOT_READY) {                   /* Telephony State – NOT READY */
-               /* De-initialization is optional here (ONLY if required) */
+       else if (state == TELEPHONY_STATE_NOT_READY)
                __deinit_tel();
-       }
 }
 
 static int register_conn_module(void *data)
@@ -452,34 +434,27 @@ static int register_conn_module(void *data)
        int ret;
        telephony_state_e state;
 
-       retif(data == NULL, FAIL, "Invalid parameter!");
+       retvm_if(data == NULL, FAIL, "Invalid parameter!");
 
        set_app_state(data);
 
        ret = telephony_get_state(&state);
-       if (ret != TELEPHONY_ERROR_NONE) {
-               ERR("telephony_get_state failed: %s", get_error_message(ret));
-               return FAIL;
-       }
+       retvm_if(ret != TELEPHONY_ERROR_NONE, FAIL, "telephony_get_state failed: %s",
+                       get_error_message(ret));
 
        ret = telephony_init(&tel_list);
-       if (ret != TELEPHONY_ERROR_NONE) {
-               ERR("telephony_init failed %d", ret);
-               return FAIL;
-       }
+       retvm_if(ret != TELEPHONY_ERROR_NONE, FAIL, "telephony_init failed: %s",
+                       get_error_message(ret));
 
        if (state == TELEPHONY_STATE_READY) {
-               DBG("Telephony ready");
-               if (__init_tel(data) != OK)
-                       return FAIL;
-       }
-       else if (state == TELEPHONY_STATE_NOT_READY) {
-               DBG("Telephony not ready");
-       }
+               _D("Telephony ready");
+               retv_if(__init_tel(data) != OK, FAIL);
+       } else if (state == TELEPHONY_STATE_NOT_READY)
+               _D("Telephony not ready");
 
        ret = telephony_set_state_changed_cb(tel_ready_cb, data);
        if (ret != TELEPHONY_ERROR_NONE) {
-               ERR("telephony_set_state_changed_cb failed: %s", get_error_message(ret));
+               _E("telephony_set_state_changed_cb failed: %s", get_error_message(ret));
                __deinit_tel();
                return FAIL;
        }