~phablet-team/ofono/ofono-bug-updates

6830.53.7 by Alfonso Sanchez-Beato
src: Add support for spn-table type plugins
1
/*
2
 *
3
 *  oFono - Open Source Telephony
4
 *
5
 *  Copyright (C) 2011  Nokia Corporation and/or its subsidiary(-ies).
6
 *  Copyright (C) 2014  Canonical Ltd.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License version 2 as
10
 *  published by the Free Software Foundation.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
 *
21
 */
22
23
#ifdef HAVE_CONFIG_H
24
#include <config.h>
25
#endif
26
27
#include <errno.h>
28
#include <string.h>
29
#include <glib.h>
30
#include "ofono.h"
31
#include "spn-table.h"
32
33
static GSList *g_drivers = NULL;
34
35
const char *__ofono_spn_table_get_spn(const char *numeric)
36
{
37
	GSList *d;
38
	const char *spn = NULL;
39
40
	for (d = g_drivers; d != NULL; d = d->next) {
41
		const struct ofono_spn_table_driver *driver = d->data;
42
43
		if (driver->get_spn == NULL)
44
			continue;
45
46
		DBG("Calling spntable plugin '%s'", driver->name);
47
48
		if ((spn = driver->get_spn(numeric)) == NULL)
49
			continue;
50
51
		return spn;
52
	}
53
54
	return spn;
55
}
56
57
int ofono_spn_table_driver_register(struct ofono_spn_table_driver *driver)
58
{
59
	DBG("driver: %p name: %s", driver, driver->name);
60
61
	g_drivers = g_slist_prepend(g_drivers, driver);
62
	return 0;
63
}
64
65
void ofono_spn_table_driver_unregister(
66
			const struct ofono_spn_table_driver *driver)
67
{
68
	DBG("driver: %p name: %s", driver, driver->name);
69
70
	g_drivers = g_slist_remove(g_drivers, driver);
71
}