src/dbus/netdbus.c
src/network-clock.c
src/network-state.c
+ src/network-dpm.c
src/network-monitor.c
src/wifi-firmware.c
src/wifi-indicator.c
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 __NETCONFIG_NETWORK_DPM_H__
+#define __NETCONFIG_NETWORK_DPM_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void netconfig_dpm_init(void);
+void netconfig_dpm_deinit(void);
+int netconfig_dpm_update_from_wifi(void);
+int netconfig_dpm_update_from_wifi_profile(void);
+
+gboolean handle_device_policy_set_wifi(
+ Network *object, GDBusMethodInvocation *context, gint state);
+gboolean handle_device_policy_get_wifi(
+ Network *object, GDBusMethodInvocation *context);
+
+gboolean handle_device_policy_set_wifi_profile(
+ Network *object, GDBusMethodInvocation *context, gint state);
+gboolean handle_device_policy_get_wifi_profile(
+ Network *object, GDBusMethodInvocation *context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_NETWORK_DPM_H__ */
gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * data);
int netconfig_send_message_to_net_popup(const char *title,
const char *content, const char *type, const char *ssid);
+int netconfig_send_restriction_to_net_popup(const char *title,
+ const char *type, const char *restriction);
void netconfig_set_system_event(const char * sys_evt, const char * evt_key, const char * evt_val);
#if defined TIZEN_WEARABLE
int wc_launch_syspopup(netconfig_wcpopup_type_e type);
<arg type="s" name="netmask" direction="in"/>
<arg type="s" name="interface" direction="in"/>
<arg type="s" name="gateway" direction="in"/>
- <arg type="i" name="address_family" direction="in"/>
+ <arg type="i" name="address_family" direction="in"/>
<arg type="b" name="result" direction="out"/>
</method>
<method name="RemoveRoute">
<arg type="s" name="netmask" direction="in"/>
<arg type="s" name="interface" direction="in"/>
<arg type="s" name="gateway" direction="in"/>
- <arg type="i" name="address_family" direction="in"/>
+ <arg type="i" name="address_family" direction="in"/>
<arg type="b" name="result" direction="out"/>
</method>
<method name="EthernetCableState">
<method name="LaunchMdns"></method>
<method name="RefMdns"></method>
<method name="UnrefMdns"></method>
+ <method name="DevicePolicySetWifi">
+ <arg type="i" name="state" direction="in"/>
+ </method>
+ <method name="DevicePolicyGetWifi">
+ <arg type="i" name="state" direction="out"/>
+ </method>
+ <method name="DevicePolicySetWifiProfile">
+ <arg type="i" name="state" direction="in"/>
+ </method>
+ <method name="DevicePolicyGetWifiProfile">
+ <arg type="i" name="state" direction="out"/>
+ </method>
</interface>
-</node>
\ No newline at end of file
+</node>
#include "wifi-agent.h"
#include "wifi-power.h"
#include "network-clock.h"
+#include "network-dpm.h"
#include "network-state.h"
#include "network-monitor.h"
#include "signal-handler.h"
/* If its environment uses Emulator, network configuration is set by emulator default */
emulator_test_and_start();
+ /* For device policy manager */
+ netconfig_dpm_init();
/*In case no emulator, set the ETH0 Mac address*/
#if defined TIZEN_TV
deregister_gdbus_signal();
+ netconfig_dpm_deinit();
+
#if !defined TIZEN_TELEPHONY_ENABLE
netconfig_clock_deinit();
#endif
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 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 <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "wifi-power.h"
+#include "network-dpm.h"
+#include "network-state.h"
+
+#define NETCONFIG_SIGNAL_DPM_WIFI "DPMWifi"
+#define NETCONFIG_SIGNAL_DPM_WIFI_PROFILE "DPMWifiProfile"
+
+static int dpm_policy_wifi = 1;
+static int dpm_policy_wifi_profile = 1;
+
+static void __netconfig_dpm_notify_result(const char *sig_name, const char *key)
+{
+ gboolean reply;
+ GVariant *params;
+ GVariantBuilder *builder = NULL;
+ GDBusConnection *connection = NULL;
+ GError *error = NULL;
+ const char *prop_key = "key";
+
+ INFO("[Signal] %s %s", sig_name, key);
+
+ connection = netdbus_get_connection();
+ if (connection == NULL) {
+ ERR("Failed to get GDBus Connection");
+ return;
+ }
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(builder, "{sv}", prop_key, g_variant_new_string(key));
+ params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+
+ g_variant_builder_unref(builder);
+
+ reply = g_dbus_connection_emit_signal(connection,
+ NULL,
+ NETCONFIG_NETWORK_PATH,
+ NETCONFIG_NETWORK_INTERFACE,
+ sig_name,
+ params,
+ &error);
+
+ if (reply != TRUE) {
+ if (error != NULL) {
+ ERR("Failed to send signal [%s]", error->message);
+ g_error_free(error);
+ }
+ return;
+ }
+
+ INFO("Sent signal (%s), key (%s)", sig_name, key);
+ return;
+}
+
+void netconfig_dpm_init(void)
+{
+ INFO("DPM initialized");
+ return;
+}
+
+void netconfig_dpm_deinit(void)
+{
+ INFO("DPM deinitialized");
+ return;
+}
+
+int netconfig_dpm_update_from_wifi(void)
+{
+ INFO("DPM update from wifi [%d]", dpm_policy_wifi);
+
+ if (!dpm_policy_wifi) {
+ int wifi_state = 0;
+ vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+ if (wifi_state != VCONFKEY_WIFI_OFF) {
+ int err = wifi_power_off();
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ ERR("wifi power off : InProgress");
+ else if (err == -EALREADY)
+ ERR("wifi power off : AlreadyExists");
+ else if (err == -EPERM)
+ ERR("wifi power off : PermissionDenied");
+ else
+ ERR("wifi power off : WifiDriverFailed");
+ } else
+ DBG("wifi power off : ErrorNone");
+
+ netconfig_set_vconf_int(VCONFKEY_NETWORK_WIFI_OFF_BY_AIRPLANE, 0);
+ netconfig_send_restriction_to_net_popup("Wi-Fi unavailable",
+ "toast_popup", "wifi");
+ }
+ }
+
+ return dpm_policy_wifi;
+}
+
+int netconfig_dpm_update_from_wifi_profile(void)
+{
+ INFO("DPM update from wifi profile [%d]", dpm_policy_wifi_profile);
+ return dpm_policy_wifi_profile;
+}
+
+gboolean handle_device_policy_set_wifi(
+ Network *object,
+ GDBusMethodInvocation *context,
+ gint state)
+{
+ INFO("DPM device policy wifi changed : [%d -> %d]",
+ dpm_policy_wifi, state);
+
+ dpm_policy_wifi = state;
+ netconfig_dpm_update_from_wifi();
+ __netconfig_dpm_notify_result(NETCONFIG_SIGNAL_DPM_WIFI,
+ state ? "allowed" : "disallowed");
+
+ network_complete_device_policy_set_wifi(object, context);
+ return TRUE;
+}
+
+gboolean handle_device_policy_get_wifi(
+ Network *object,
+ GDBusMethodInvocation *context)
+{
+ INFO("Successfully get wifi device policy [%d]",
+ dpm_policy_wifi);
+
+ network_complete_device_policy_get_wifi(object,
+ context, dpm_policy_wifi);
+ return TRUE;
+}
+
+gboolean handle_device_policy_set_wifi_profile(
+ Network *object,
+ GDBusMethodInvocation *context,
+ gint state)
+{
+ INFO("DPM device policy wifi profile changed : [%d -> %d]",
+ dpm_policy_wifi_profile, state);
+
+ dpm_policy_wifi_profile = state;
+ netconfig_dpm_update_from_wifi_profile();
+ __netconfig_dpm_notify_result(NETCONFIG_SIGNAL_DPM_WIFI_PROFILE,
+ state ? "allowed" : "disallowed");
+
+ network_complete_device_policy_set_wifi_profile(object, context);
+ return TRUE;
+}
+
+gboolean handle_device_policy_get_wifi_profile(
+ Network *object,
+ GDBusMethodInvocation *context)
+{
+ INFO("Successfully get wifi profile device policy [%d]",
+ dpm_policy_wifi_profile);
+
+ network_complete_device_policy_get_wifi(object,
+ context, dpm_policy_wifi_profile);
+ return TRUE;
+}
#include "wifi-state.h"
#include "wifi-power.h"
#include "network-state.h"
+#include "network-dpm.h"
#include "network-monitor.h"
#include "netsupplicant.h"
#include "wifi-tel-intf.h"
G_CALLBACK(handle_ref_mdns), NULL);
g_signal_connect(netconfigstate, "handle-unref-mdns",
G_CALLBACK(handle_unref_mdns), NULL);
+ g_signal_connect(netconfigstate, "handle-device-policy-set-wifi",
+ G_CALLBACK(handle_device_policy_set_wifi), NULL);
+ g_signal_connect(netconfigstate, "handle-device-policy-get-wifi",
+ G_CALLBACK(handle_device_policy_get_wifi), NULL);
+ g_signal_connect(netconfigstate, "handle-device-policy-set-wifi-profile",
+ G_CALLBACK(handle_device_policy_set_wifi_profile), NULL);
+ g_signal_connect(netconfigstate, "handle-device-policy-get-wifi-profile",
+ G_CALLBACK(handle_device_policy_get_wifi_profile), NULL);
if (!g_dbus_interface_skeleton_export(interface_network, connection,
NETCONFIG_NETWORK_STATE_PATH, NULL)) {
return ret;
}
+int netconfig_send_restriction_to_net_popup(const char *title,
+ const char *type, const char *restriction)
+{
+ int ret = 0;
+ bundle *b = bundle_create();
+
+ bundle_add(b, "_SYSPOPUP_TITLE_", title);
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "security restriction");
+ bundle_add(b, "_SYSPOPUP_TYPE_", type);
+ bundle_add(b, "_RESTRICTED_TYPE_", restriction);
+
+ ret = syspopup_launch("net-popup", b);
+
+ bundle_free(b);
+
+ return ret;
+}
+
void netconfig_set_system_event(const char * sys_evt, const char * evt_key, const char * evt_val)
{
bundle *b = NULL;
#include "wifi-tel-intf.h"
#include "netsupplicant.h"
#include "network-state.h"
+#include "network-dpm.h"
#include "wifi-firmware.h"
#include "wifi-background-scan.h"
g_return_val_if_fail(wifi != NULL, FALSE);
+ if (!netconfig_dpm_update_from_wifi()) {
+ DBG("DPM policy restricts Wi-Fi");
+ netconfig_error_permission_denied(context);
+ return TRUE;
+ }
+
#if defined TIZEN_WEARABLE
err = wifi_power_on_wearable(device_picker_test);
#else
if (result != TRUE)
netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSpecificScan");
else
- wifi_complete_request_wps_scan(wifi, context);
+ wifi_complete_request_specific_scan(wifi, context);
return result;
}