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.
24 #include <system_info.h>
31 #include "wifi-agent.h"
32 #include "wifi-power.h"
34 #include "network-clock.h"
35 #include "network-dpm.h"
36 #include "network-state.h"
37 #include "network-monitor.h"
38 #include "signal-handler.h"
39 #include "network-statistics.h"
41 static GMainLoop *main_loop = NULL;
43 #define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet"
45 /*Poll the ethernet Cable Plug-in /Plug-out status at every 1000 ms*/
46 #define ETH_POLLING_TIME 1000
48 /* Callback to Poll the Ethernet Status*/
49 gboolean __net_ethernet_cable_status_polling_callback(gpointer data)
51 netconfig_ethernet_cable_plugin_status_check();
55 void _got_name_cb(void)
57 wifi_object_create_and_init();
58 state_object_create_and_init();
59 statistics_object_create_and_init();
60 vpnsvc_create_and_init();
62 register_gdbus_signal();
63 connman_register_agent();
66 __netconfig_set_ether_macaddr();
70 static void _objects_deinit(void)
74 state_object_deinit();
75 statistics_object_deinit();
76 vpnsvc_destroy_deinit();
79 int main(int argc, char *argv[])
82 int check_ethernet_monitor_timer = 0;
83 bool ethernet_feature_supported = FALSE;
87 DBG("Network Configuration service");
88 if (daemon(0, 0) != 0)
89 DBG("Cannot start daemon");
91 if (mkdir(WIFI_STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
92 S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
94 ERR("Failed to create Wi-Fi directory");
97 if (mkdir(WIFI_CERT_STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
98 S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
100 ERR("Failed to create cert directory");
103 #if !GLIB_CHECK_VERSION(2, 36, 0)
107 main_loop = g_main_loop_new(NULL, FALSE);
108 if (main_loop == NULL) {
109 ERR("Couldn't create GMainLoop\n");
113 ret = setup_gdbus(_got_name_cb);
115 ERR("_netconfig_setup_gdbus is failed\n");
119 netconfig_error_init();
121 #if !defined TIZEN_TELEPHONY_ENABLE
122 netconfig_clock_init();
125 /* If its environment uses Emulator, network configuration is set by emulator default */
126 emulator_test_and_start();
128 /* For device policy manager */
129 netconfig_dpm_init();
131 #if defined TIZEN_WLAN_BOARD_SPRD
132 wifi_firmware_download();
135 /*In case no emulator, set the ETH0 Mac address*/
137 if (emulator_is_emulated() == FALSE)
138 __netconfig_set_ether_macaddr();
141 if (!system_info_get_platform_bool(ETHERNET_FEATURE, ðernet_feature_supported)) {
142 if (ethernet_feature_supported == TRUE) {
143 /* Register the callback to check the ethernet Plug-in /Plug-out Status */
144 check_ethernet_monitor_timer = g_timeout_add(ETH_POLLING_TIME,
145 __net_ethernet_cable_status_polling_callback,
146 &check_ethernet_monitor_timer);
149 ERR("Error - Feature getting from System Info");
152 g_main_loop_run(main_loop);
158 deregister_gdbus_signal();
160 netconfig_dpm_deinit();
162 #if !defined TIZEN_TELEPHONY_ENABLE
163 netconfig_clock_deinit();
168 if (check_ethernet_monitor_timer > 0)
169 g_source_remove(check_ethernet_monitor_timer);
171 wifi_state_notifier_cleanup();
173 /* Unregistering the agent */
174 connman_unregister_agent();