upload tizen1.0 source
[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  * Contact: Danny JS Seo <S.Seo@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <unistd.h>
23
24 #include "log.h"
25 #include "dbus.h"
26 #include "wifi.h"
27 #include "emulator.h"
28 #include "network-state.h"
29 #include "signal-handler.h"
30
31 static GMainLoop *main_loop = NULL;
32
33 int main(int argc, char* argv[])
34 {
35         DBusGConnection *connection;
36
37         DBG("Network Configuration Module");
38
39         if (daemon(0, 0) != 0)
40                 DBG("Cannot start daemon");
41
42         g_type_init();
43
44         main_loop = g_main_loop_new(NULL, FALSE);
45
46         connection = netconfig_setup_dbus();
47         if (connection == NULL)
48                 return -1;
49
50         if (netconfig_network_state_create_and_init(connection) == NULL)
51                 return -1;
52
53         netconfig_register_signal();
54
55         if (netconfig_wifi_create_and_init(connection) == NULL)
56                 return -1;
57
58         /* If its environment uses Emulator, network configuration is set by emulator default */
59         netconfig_emulator_test_and_start();
60
61         g_main_loop_run(main_loop);
62
63         netconfig_deregister_signal();
64
65         return 0;
66 }