Release Tizen 2.0 beta
[framework/connectivity/net-config.git] / src / main.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #include <unistd.h>
21
22 #include "log.h"
23 #include "wifi.h"
24 #include "emulator.h"
25 #include "netdbus.h"
26 #include "network-state.h"
27 #include "network-statistics.h"
28 #include "signal-handler.h"
29
30 static GMainLoop *main_loop = NULL;
31
32 int main(int argc, char* argv[])
33 {
34         DBusGConnection *connection;
35
36         DBG("Network Configuration Module");
37
38         if (daemon(0, 0) != 0)
39                 DBG("Cannot start daemon");
40
41         g_type_init();
42
43         main_loop = g_main_loop_new(NULL, FALSE);
44
45         connection = netconfig_setup_dbus();
46         if (connection == NULL)
47                 return -1;
48
49         if (netconfig_network_state_create_and_init(connection) == NULL)
50                 return -1;
51
52         netconfig_register_signal();
53
54         if (netconfig_wifi_create_and_init(connection) == NULL)
55                 return -1;
56
57         if (netconfig_network_statistics_create_and_init(connection) == NULL)
58                 return -1;
59
60         /* If its environment uses Emulator, network configuration is set by emulator default */
61         netconfig_emulator_test_and_start();
62
63         g_main_loop_run(main_loop);
64
65         netconfig_wifi_state_notifier_cleanup();
66         netconfig_deregister_signal();
67
68         return 0;
69 }