2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include <vconf-keys.h>
27 #include "wifi-state.h"
28 #include "wifi-scan.h"
29 #include "wifi-background-scan.h"
31 void netconfig_wifi_bgscan_start(const char *interface_name, gboolean immediate_scan)
33 wifi_tech_state_e wifi_tech_state;
34 wifi_service_state_e wifi_service_state;
36 if (netconfig_wifi_bgscan_get_timer_id(interface_name) > 0)
37 netconfig_wifi_bgscan_stop_timer(interface_name);
39 wifi_tech_state = wifi_state_get_technology_state(interface_name);
40 wifi_service_state = wifi_state_get_service_state(interface_name);
41 DBG("[%s] Wi-Fi tech state [%s] service state [%s]", interface_name,
42 _convert_wifi_technology_state_to_string(wifi_tech_state),
43 _convert_wifi_service_state_to_string(wifi_service_state));
45 if (wifi_tech_state < NETCONFIG_WIFI_TECH_POWERED)
48 if (netconfig_wifi_bgscan_get_mode(interface_name) == WIFI_BGSCAN_MODE_EXPONENTIAL &&
49 wifi_service_state == NETCONFIG_WIFI_CONNECTED)
52 DBG("[%s] Wi-Fi background scan started or re-started(%d)",
53 interface_name, immediate_scan);
55 netconfig_wifi_bgscan_start_timer(interface_name, immediate_scan);
58 void netconfig_wifi_bgscan_stop(const char *interface_name)
60 netconfig_wifi_bgscan_stop_timer(interface_name);
63 gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
64 const gchar *ifname, guint scan_mode)
67 int pm_state = VCONFKEY_PM_STATE_NORMAL;
69 old_mode = netconfig_wifi_bgscan_get_mode(ifname);
70 if (old_mode == scan_mode) {
71 wifi_complete_set_bgscan(wifi, context);
75 if (netconfig_wifi_bgscan_set_mode(ifname, scan_mode) != TRUE) {
76 ERR("Invalid mode [%d]", scan_mode);
77 netconfig_error_invalid_parameter(context);
81 INFO("[%s] Wi-Fi scan mode is changed [%d]", ifname, scan_mode);
83 /* In case of LCD off, we don't need Wi-Fi scan right now */
84 netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
85 if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
86 netconfig_wifi_bgscan_start(ifname, FALSE);
88 netconfig_wifi_bgscan_start(ifname, TRUE);
90 wifi_complete_set_bgscan(wifi, context);
94 gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
97 netconfig_wifi_bgscan_set_pause(ifname, FALSE);
99 wifi_complete_resume_bgscan(wifi, context);
103 gboolean handle_pause_bgscan(Wifi *wifi, GDBusMethodInvocation *context,
106 netconfig_wifi_bgscan_set_pause(ifname, TRUE);
108 wifi_complete_pause_bgscan(wifi, context);
112 gboolean handle_reset_bgscan_interval(Wifi *wifi, GDBusMethodInvocation *context,
115 netconfig_wifi_bgscan_set_interval(ifname, SCAN_EXPONENTIAL_MIN);
117 wifi_complete_reset_bgscan_interval(wifi, context);
121 gboolean handle_get_autoscan(Wifi *wifi, GDBusMethodInvocation *context,
125 gboolean autoscan = 0;
127 autoscan = netconfig_wifi_bgscan_is_paused(ifname);
129 wifi_complete_get_autoscan(wifi, context, autoscan);
133 gboolean handle_get_autoscanmode(Wifi *wifi, GDBusMethodInvocation *context,
136 guint autoscanmode = 0;
138 autoscanmode = netconfig_wifi_bgscan_get_mode(ifname);
140 wifi_complete_get_autoscanmode(wifi, context, autoscanmode);