--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AIR_SETTINGS_DATA_WIRELESS_H__
+#define __AIR_SETTINGS_DATA_WIRELESS_H__
+
+#include <wifi.h>
+
+struct wifi_ap_info {
+ wifi_ap_h ap;
+ char *essid;
+ wifi_security_type_e secure_type;
+ wifi_connection_state_e connection_state;
+};
+
+struct data_class *get_wireless_data_class(void);
+
+#endif /* __AIR_SETTINGS_DATA_WIRELESS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Elementary.h>
+#include <app_debug.h>
+
+#include "data/data_wireless.h"
+#include "datamgr.h"
+
+static bool _create(struct datamgr *dmgr)
+{
+ if (wifi_initialize() != WIFI_ERROR_NONE) {
+ _ERR("wifi_initialize failed.");
+ return false;
+ }
+
+ return true;
+}
+
+static bool _destroy(struct datamgr *dmgr)
+{
+ struct wifi_ap_info *ap_info;
+
+ if (!dmgr) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ EINA_LIST_FREE(dmgr->list, ap_info) {
+ if (!ap_info)
+ continue;
+
+ free(ap_info->essid);
+ free(ap_info);
+
+ ap_info = NULL;
+ }
+
+ if (wifi_deinitialize() != WIFI_ERROR_NONE) {
+ _ERR("wifi_deinitialize failed.");
+ return false;
+ }
+
+ return true;
+}
+
+static bool _wifi_found_ap_cb(wifi_ap_h ap, void *data)
+{
+ struct wifi_ap_info *ap_info;
+ Eina_List **list;
+ wifi_connection_state_e connection_state;
+ wifi_security_type_e secure_type;
+ bool activated;
+ char *essid;
+ int r;
+
+ if (!data) {
+ _ERR("Invalid argument.");
+ return EINA_FALSE;
+ }
+
+ list = data;
+
+ r = wifi_is_activated(&activated);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_is_activated failed.");
+ return EINA_FALSE;
+ }
+
+ r = wifi_ap_get_essid(ap, &essid);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_ap_get_essid failed.");
+ return EINA_FALSE;
+ }
+
+ r = wifi_ap_get_connection_state(ap, &connection_state);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_ap_get_connection_state failed.");
+ return EINA_FALSE;
+ }
+
+ r = wifi_ap_get_security_type(ap, &secure_type);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_ap_get_security_type failed.");
+ return EINA_FALSE;
+ }
+
+ ap_info = calloc(1, sizeof(*ap_info));
+ if (!ap_info) {
+ _ERR("Calloc failed.");
+ return EINA_FALSE;
+ }
+
+ ap_info->ap = ap;
+ ap_info->essid = strdup(essid);
+ ap_info->connection_state = connection_state;
+ ap_info->secure_type = secure_type;
+
+ *list = eina_list_append(*list, ap_info);
+
+ return EINA_TRUE;
+}
+
+static void _wifi_scan_finished_cb(wifi_error_e err, void *data)
+{
+ struct datamgr *dmgr;
+ int r;
+
+ if (!data) {
+ _ERR("Invalid argument.");
+ return;
+ }
+ dmgr = data;
+
+ r = wifi_foreach_found_aps(_wifi_found_ap_cb, &dmgr->list);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_foreach_found_aps failed.");
+ return;
+ }
+
+ dmgr->update_done_cb(dmgr->user_data);
+}
+
+static void _wifi_activated_cb(wifi_error_e err, void *data)
+{
+ int r;
+
+ if (!data) {
+ _ERR("Invalid argument.");
+ return;
+ }
+
+ if (err != WIFI_ERROR_NONE) {
+ _ERR("wifi activation failed.");
+ return;
+ }
+
+ r = wifi_scan(_wifi_scan_finished_cb, data);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_scan failed.");
+ return;
+ }
+}
+
+static bool _update(struct datamgr *dmgr)
+{
+ bool activated;
+ int r;
+
+ if (!dmgr) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ r = wifi_is_activated(&activated);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_is_activated failed.");
+ return false;
+ }
+
+ if (activated) {
+ r = wifi_scan(_wifi_scan_finished_cb, dmgr);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_scan failed.");
+ return false;
+ }
+ } else {
+ r = wifi_activate(_wifi_activated_cb, dmgr);
+ if (r != WIFI_ERROR_NONE) {
+ _ERR("wifi_activated failed.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static struct data_class _dclass = {
+ .create = _create,
+ .destroy = _destroy,
+ .update = _update,
+};
+
+struct data_class *get_wireless_data_class(void)
+{
+ return &_dclass;
+}