summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-01-30 07:43:12 -0800
committerMarcel Holtmann <marcel@holtmann.org>2010-01-30 07:43:12 -0800
commit3e46541dd42b970b51cd9468f008d14c95ae3c1d (patch)
tree482e8db68a650d89ac8ce0df3e482ef14c8a4426
parente690a3ac26e3f51c9e2cc36d4bdfb7616ee94958 (diff)
downloadofono-3e46541dd42b970b51cd9468f008d14c95ae3c1d.tar.bz2
Use simple driver table for modem configuration setup helpers
-rw-r--r--plugins/modemconf.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 932d6102..aedaad0e 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -113,10 +113,24 @@ static int set_device(struct ofono_modem *modem,
return 0;
}
+static struct {
+ const char *driver;
+ int (*func) (struct ofono_modem *modem,
+ GKeyFile *keyfile, const char *group);
+} setup_helpers[] = {
+ { "phonesim", set_address },
+ { "atgen", set_device },
+ { "g1", set_device },
+ { "calypso", set_device },
+ { "palmpre", set_device },
+ { NULL }
+};
+
static struct ofono_modem *create_modem(GKeyFile *keyfile, const char *group)
{
struct ofono_modem *modem;
char *driver;
+ int i;
driver = g_key_file_get_string(keyfile, group, "Driver", NULL);
if (!driver)
@@ -124,13 +138,10 @@ static struct ofono_modem *create_modem(GKeyFile *keyfile, const char *group)
modem = ofono_modem_create(group, driver);
- if (!g_strcmp0(driver, "phonesim"))
- set_address(modem, keyfile, group);
-
- if (!g_strcmp0(driver, "atgen") || !g_strcmp0(driver, "g1") ||
- !g_strcmp0(driver, "calypso") ||
- !g_strcmp0(driver, "palmpre"))
- set_device(modem, keyfile, group);
+ for (i = 0; setup_helpers[i].driver; i++) {
+ if (!g_strcmp0(driver, setup_helpers[i].driver))
+ setup_helpers[i].func(modem, keyfile, group);
+ }
g_free(driver);