ofono: Merge context_set_in/active()
[framework/connectivity/connman.git] / plugins / fake.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 <stdio.h>
27
28 #define CONNMAN_API_SUBJECT_TO_CHANGE
29 #include <connman/plugin.h>
30 #include <connman/device.h>
31 #include <connman/log.h>
32
33 static void create_network(struct connman_device *device, const char *name)
34 {
35         struct connman_network *network;
36
37         network = connman_network_create(name, CONNMAN_NETWORK_TYPE_VENDOR);
38         if (network == NULL)
39                 return;
40
41         connman_network_register(network);
42
43         connman_device_add_network(device, network);
44         connman_network_unref(network);
45 }
46
47 static int device_probe(struct connman_device *device)
48 {
49         DBG("");
50
51         return 0;
52 }
53
54 static void device_remove(struct connman_device *device)
55 {
56         DBG("");
57 }
58
59 static int device_enable(struct connman_device *device)
60 {
61         DBG("");
62
63         create_network(device, "network_one");
64         create_network(device, "network_two");
65
66         return 0;
67 }
68
69 static int device_disable(struct connman_device *device)
70 {
71         DBG("");
72
73         return 0;
74 }
75
76 static struct connman_device_driver device_driver = {
77         .name           = "fake",
78         .type           = CONNMAN_DEVICE_TYPE_VENDOR,
79         .probe          = device_probe,
80         .remove         = device_remove,
81         .enable         = device_enable,
82         .disable        = device_disable,
83 };
84
85 static void create_device(const char *name)
86 {
87         struct connman_device *device;
88
89         device = connman_device_create(name, CONNMAN_DEVICE_TYPE_VENDOR);
90         if (device == NULL)
91                 return;
92
93         connman_device_register(device);
94         connman_device_unref(device);
95 }
96
97 static int fake_init(void)
98 {
99         create_device("fake");
100
101         return connman_device_driver_register(&device_driver);
102 }
103
104 static void fake_exit(void)
105 {
106         connman_device_driver_unregister(&device_driver);
107 }
108
109 CONNMAN_PLUGIN_DEFINE(fake, "Tesing plugin", VERSION,
110                 CONNMAN_PLUGIN_PRIORITY_DEFAULT, fake_init, fake_exit)