Update copyright information
[connman] / plugins / fake.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  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/plugin.h>
27 #include <connman/driver.h>
28 #include <connman/element.h>
29 #include <connman/log.h>
30
31 static void create_network(struct connman_element *parent, const char *name)
32 {
33         struct connman_element *element;
34
35         element = connman_element_create(name);
36         element->type = CONNMAN_ELEMENT_TYPE_NETWORK;
37         element->subtype = CONNMAN_ELEMENT_SUBTYPE_FAKE;
38
39         connman_element_register(element, parent);
40         connman_element_unref(element);
41 }
42
43 static int fake_device_probe(struct connman_element *element)
44 {
45         DBG("");
46
47         return 0;
48 }
49
50 static void fake_device_remove(struct connman_element *element)
51 {
52         DBG("");
53 }
54
55 static int fake_device_update(struct connman_element *element)
56 {
57         DBG("");
58
59         create_network(element, "network_new");
60
61         return 0;
62 }
63
64 static int fake_device_enable(struct connman_element *element)
65 {
66         DBG("");
67
68         create_network(element, "network_one");
69         create_network(element, "network_two");
70
71         return 0;
72 }
73
74 static int fake_device_disable(struct connman_element *element)
75 {
76         DBG("");
77
78         connman_element_unregister_children(element);
79
80         return 0;
81 }
82
83 static struct connman_driver fake_device_driver = {
84         .name           = "fake-device",
85         .type           = CONNMAN_ELEMENT_TYPE_DEVICE,
86         .subtype        = CONNMAN_ELEMENT_SUBTYPE_FAKE,
87         .probe          = fake_device_probe,
88         .remove         = fake_device_remove,
89         .update         = fake_device_update,
90         .enable         = fake_device_enable,
91         .disable        = fake_device_disable,
92 };
93
94 static void create_device(const char *name)
95 {
96         struct connman_element *element;
97
98         element = connman_element_create(name);
99         element->type = CONNMAN_ELEMENT_TYPE_DEVICE;
100         element->subtype = CONNMAN_ELEMENT_SUBTYPE_FAKE;
101
102         //connman_element_define_properties(element,
103         //                              CONNMAN_PROPERTY_ID_IPV4_METHOD,
104         //                              CONNMAN_PROPERTY_ID_INVALID);
105
106         connman_element_register(element, NULL);
107         connman_element_unref(element);
108 }
109
110 static int fake_init(void)
111 {
112         create_device("fakeone");
113         create_device("faketwo");
114
115         return connman_driver_register(&fake_device_driver);
116 }
117
118 static void fake_exit(void)
119 {
120         connman_driver_unregister(&fake_device_driver);
121 }
122
123 CONNMAN_PLUGIN_DEFINE(fake, "Tesing plugin", VERSION, fake_init, fake_exit)