ipconfig: Removed obsolete parameter from __connman_ipconfig_set_config()
[platform/upstream/connman.git] / src / ondemand.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <connman/service.h>
27 #include <connman/ondemand.h>
28 #include <connman/notifier.h>
29 #include <connman/log.h>
30
31 #include "connman.h"
32
33 static volatile gint started;
34 static gboolean connected;
35 struct connman_service *ondemand_service;
36
37 static void ondemand_default_changed(struct connman_service *service)
38 {
39         DBG("service %p", service);
40
41         if (service == NULL) {
42                 connected = FALSE;
43                 return;
44         }
45
46         connected = TRUE;
47 }
48
49 static struct connman_notifier ondemand_notifier = {
50         .name                   = "ondemand",
51         .default_changed        = ondemand_default_changed,
52 };
53
54 gboolean connman_ondemand_connected(void)
55 {
56         DBG("connected %d", connected);
57
58         return TRUE;
59 //      return connected;
60 }
61
62 int connman_ondemand_start(const char *bearer, unsigned int idle_timeout)
63 {
64         DBG("");
65
66         if (g_atomic_int_get(&started) > 0)
67                 return 0;
68
69         g_atomic_int_inc(&started);
70
71         ondemand_service = __connman_session_request(bearer, "__ondemand__");
72         if (ondemand_service == NULL)
73                 g_atomic_int_set(&started, 0);
74
75         /* TODO:
76          * 1) Set IDLETIMER target.
77          * 2) Listen for the sysfs/netlink event.
78          * 3) Stop the session.
79          */
80
81         return 0;
82 }
83
84 int __connman_ondemand_init(void)
85 {
86         return connman_notifier_register(&ondemand_notifier);
87 }
88
89 void __connman_ondemand_cleanup(void)
90 {
91         connman_notifier_unregister(&ondemand_notifier);
92 }