Update copyright information
[framework/connectivity/connman.git] / src / timeserver.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 <glib.h>
27
28 #include "connman.h"
29
30 static GSList *driver_list = NULL;
31
32 static gint compare_priority(gconstpointer a, gconstpointer b)
33 {
34         const struct connman_timeserver_driver *driver1 = a;
35         const struct connman_timeserver_driver *driver2 = b;
36
37         return driver2->priority - driver1->priority;
38 }
39
40 /**
41  * connman_timeserver_driver_register:
42  * @driver: timeserver driver definition
43  *
44  * Register a new timeserver driver
45  *
46  * Returns: %0 on success
47  */
48 int connman_timeserver_driver_register(struct connman_timeserver_driver *driver)
49 {
50         DBG("driver %p name %s", driver, driver->name);
51
52         driver_list = g_slist_insert_sorted(driver_list, driver,
53                                                         compare_priority);
54
55         return 0;
56 }
57
58 /**
59  * connman_timeserver_driver_unregister:
60  * @driver: timeserver driver definition
61  *
62  * Remove a previously registered timeserver driver
63  */
64 void connman_timeserver_driver_unregister(struct connman_timeserver_driver *driver)
65 {
66         DBG("driver %p name %s", driver, driver->name);
67
68         driver_list = g_slist_remove(driver_list, driver);
69 }
70
71 /**
72  * connman_timeserver_append:
73  * @server: server address
74  *
75  * Append time server server address to current list
76  */
77 int connman_timeserver_append(const char *server)
78 {
79         DBG("server %s", server);
80
81         if (server == NULL)
82                 return -EINVAL;
83
84         connman_info("Adding time server %s", server);
85
86         return 0;
87 }
88
89 /**
90  * connman_timeserver_remove:
91  * @server: server address
92  *
93  * Remover time server server address from current list
94  */
95 int connman_timeserver_remove(const char *server)
96 {
97         DBG("server %s", server);
98
99         if (server == NULL)
100                 return -EINVAL;
101
102         connman_info("Removing time server %s", server);
103
104         return 0;
105 }