summaryrefslogtreecommitdiffstats
path: root/src/private-network.c
blob: 4da68f88718349db5f17eb7825b884d12642d599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 *
 *  oFono - Open Source Telephony
 *
 *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <glib.h>
#include "ofono.h"

static GSList *g_drivers = NULL;

void __ofono_private_network_release(int id)
{
	GSList *d;

	DBG("");

	for (d = g_drivers; d; d = d->next) {
		const struct ofono_private_network_driver *driver = d->data;

		if (!driver->release)
			continue;

		driver->release(id);

		break;
	}
}

ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
						int *id, void *data)
{
	GSList *d;
	int uid;

	DBG("");

	for (d = g_drivers; d; d = d->next) {
		const struct ofono_private_network_driver *driver = d->data;

		if (!driver->request)
			continue;

		uid = driver->request(cb, data);
		if (uid <= 0)
			continue;

		*id = uid;
		return TRUE;
	}

	return FALSE;
}

int ofono_private_network_driver_register(
			const struct ofono_private_network_driver *d)
{
	DBG("driver: %p, name: %s", d, d->name);

	g_drivers = g_slist_prepend(g_drivers, (void *) d);

	return 0;
}

void ofono_private_network_driver_unregister(
			const struct ofono_private_network_driver *d)
{
	DBG("driver: %p, name: %s", d, d->name);

	g_drivers = g_slist_remove(g_drivers, (void *) d);
}