~ubuntu-branches/ubuntu/utopic/ofono/utopic-proposed

« back to all changes in this revision

Viewing changes to src/cdma-provision.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-08-22 19:59:08 UTC
  • mfrom: (1.4.3)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120822195908-20ccett2uhgcz7f6
Tags: upstream-1.9
ImportĀ upstreamĀ versionĀ 1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 *  oFono - Open Source Telephony
 
4
 *
 
5
 *  Copyright (C) 2008-2011  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 <string.h>
 
27
#include <glib.h>
 
28
#include "ofono.h"
 
29
 
 
30
static GSList *g_drivers = NULL;
 
31
 
 
32
ofono_bool_t __ofono_cdma_provision_get_name(const char *sid, char **name)
 
33
{
 
34
        GSList *d;
 
35
 
 
36
        if (sid == NULL || strlen(sid) == 0)
 
37
                return FALSE;
 
38
 
 
39
        for (d = g_drivers; d != NULL; d = d->next) {
 
40
                const struct ofono_cdma_provision_driver *driver = d->data;
 
41
 
 
42
                if (driver->get_provider_name == NULL)
 
43
                        continue;
 
44
 
 
45
                DBG("Calling cdma provision plugin '%s'", driver->name);
 
46
 
 
47
                if (driver->get_provider_name(sid, name) < 0)
 
48
                        continue;
 
49
 
 
50
                return TRUE;
 
51
        }
 
52
 
 
53
        return FALSE;
 
54
}
 
55
 
 
56
static gint compare_priority(gconstpointer a, gconstpointer b)
 
57
{
 
58
        const struct ofono_cdma_provision_driver *plugin1 = a;
 
59
        const struct ofono_cdma_provision_driver *plugin2 = b;
 
60
 
 
61
        return plugin2->priority - plugin1->priority;
 
62
}
 
63
 
 
64
int ofono_cdma_provision_driver_register(
 
65
                const struct ofono_cdma_provision_driver *driver)
 
66
{
 
67
        DBG("driver: %p name: %s", driver, driver->name);
 
68
 
 
69
        g_drivers = g_slist_insert_sorted(g_drivers, (void *) driver,
 
70
                                                compare_priority);
 
71
        return 0;
 
72
}
 
73
 
 
74
void ofono_cdma_provision_driver_unregister(
 
75
                const struct ofono_cdma_provision_driver *driver)
 
76
{
 
77
        DBG("driver: %p name: %s", driver, driver->name);
 
78
 
 
79
        g_drivers = g_slist_remove(g_drivers, driver);
 
80
}