From: Zhang zhengguang Date: Mon, 17 Nov 2014 05:25:16 +0000 (+0800) Subject: Optimize tethering powered changed callback functions X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00ad1a5d23c4aab0562004c7aa9053a77624173f;p=platform%2Fcore%2Fapi%2Ftethering.git Optimize tethering powered changed callback functions Change-Id: I2193d5f1a762be98c7494c23e2aaf3ace35bd224 --- diff --git a/src/tethering.c b/src/tethering.c index bbeda12..31240ed 100644 --- a/src/tethering.c +++ b/src/tethering.c @@ -149,57 +149,53 @@ static tethering_error_e __get_error(int agent_error) return err; } */ -static void set_connman_tethering_powered_changed_cb(tethering_type_e type, void *user_data) + +static void set_connman_usb_tethering_powered_changed_cb(void *user_data) { - struct connman_technology *technology; + struct connman_technology *technology = connman_get_technology(TECH_TYPE_GADGET); + if (technology != NULL) + connman_technology_set_property_changed_cb(technology, + TECH_PROP_TETHERING, + __handle_usb_tether_changed, + user_data); +} + +static void set_connman_wifi_tethering_powered_changed_cb(void *user_data) +{ + struct connman_technology *technology = connman_get_technology(TECH_TYPE_WIFI); + if (technology != NULL) + connman_technology_set_property_changed_cb(technology, + TECH_PROP_TETHERING, + __handle_wifi_tether_changed, + user_data); +} + +static void set_connman_bt_tethering_powered_changed_cb(void *user_data) +{ + struct connman_technology *technology = connman_get_technology(TECH_TYPE_BLUETOOTH); + if (technology != NULL) + connman_technology_set_property_changed_cb(technology, + TECH_PROP_TETHERING, + __handle_bt_tether_changed, + user_data); +} +static void set_connman_tethering_powered_changed_cb(tethering_type_e type, void *user_data) +{ if (type == TETHERING_TYPE_ALL) { /* TETHERING_TYPE_ALL */ - technology = connman_get_technology(TECH_TYPE_GADGET); - if (technology != NULL) - connman_technology_set_property_changed_cb(technology, - TECH_PROP_TETHERING, - __handle_usb_tether_changed, - user_data); - technology = connman_get_technology(TECH_TYPE_WIFI); - if (technology != NULL) - connman_technology_set_property_changed_cb(technology, - TECH_PROP_TETHERING, - __handle_wifi_tether_changed, - user_data); - technology = connman_get_technology(TECH_TYPE_BLUETOOTH); - if (technology != NULL) - connman_technology_set_property_changed_cb(technology, - TECH_PROP_TETHERING, - __handle_bt_tether_changed, - user_data); + set_connman_usb_tethering_powered_changed_cb(user_data); + set_connman_wifi_tethering_powered_changed_cb(user_data); + set_connman_bt_tethering_powered_changed_cb(user_data); return; } - if (type == TETHERING_TYPE_USB) { - technology = connman_get_technology(TECH_TYPE_GADGET); - if (technology != NULL) - connman_technology_set_property_changed_cb(technology, - TECH_PROP_TETHERING, - __handle_usb_tether_changed, - user_data); - } - else if (type == TETHERING_TYPE_WIFI) { - technology = connman_get_technology(TECH_TYPE_WIFI); - if (technology != NULL) - connman_technology_set_property_changed_cb(technology, - TECH_PROP_TETHERING, - __handle_wifi_tether_changed, - user_data); - } - else if (type == TETHERING_TYPE_BT) { - technology = connman_get_technology(TECH_TYPE_BLUETOOTH); - if (technology != NULL) - connman_technology_set_property_changed_cb(technology, - TECH_PROP_TETHERING, - __handle_bt_tether_changed, - user_data); - } + if (type == TETHERING_TYPE_USB) + set_connman_usb_tethering_powered_changed_cb(user_data); + else if (type == TETHERING_TYPE_WIFI) + set_connman_wifi_tethering_powered_changed_cb(user_data); + else if (type == TETHERING_TYPE_BT) + set_connman_bt_tethering_powered_changed_cb(user_data); } static void __handle_tether_connection_changed(struct connman_technology *technology,