diff options
author | Denis Kenzior <denkenz@gmail.com> | 2013-03-18 13:42:00 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2013-03-18 13:42:46 -0500 |
commit | c86fcc3a7066646bc04cce9fc3e80fce3fa6029d (patch) | |
tree | 3abe4617b8564a2845e465c2b5c5ba7f36cdfd49 | |
parent | c71f2967f2621b782af2284a7f6725f52b1acb26 (diff) | |
download | ofono-c86fcc3a7066646bc04cce9fc3e80fce3fa6029d.tar.bz2 |
handsfree-audio: Match new card API
-rw-r--r-- | src/handsfree-audio.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c index 9e560ad3..13f7c221 100644 --- a/src/handsfree-audio.c +++ b/src/handsfree-audio.c @@ -52,6 +52,7 @@ struct ofono_handsfree_card { char *remote; char *local; char *path; + const struct ofono_handsfree_card_driver *driver; void *driver_data; }; @@ -253,18 +254,30 @@ static const GDBusSignalTable card_signals[] = { { } }; -struct ofono_handsfree_card *ofono_handsfree_card_create(const char *remote, - const char *local) +struct ofono_handsfree_card *ofono_handsfree_card_create(unsigned int vendor, + const char *driver, + void *data) { struct ofono_handsfree_card *card; + GSList *l; card = g_new0(struct ofono_handsfree_card, 1); - card->remote = g_strdup(remote); - card->local = g_strdup(local); - card_list = g_slist_prepend(card_list, card); + for (l = drivers; l; l = l->next) { + const struct ofono_handsfree_card_driver *drv = l->data; + + if (g_strcmp0(drv->name, driver)) + continue; + + if (drv->probe(card, vendor, data) < 0) + continue; + + card->driver = drv; + break; + } + return card; } @@ -279,6 +292,34 @@ void *ofono_handsfree_card_get_data(struct ofono_handsfree_card *card) return card->driver_data; } +void ofono_handsfree_card_set_remote(struct ofono_handsfree_card *card, + const char *remote) +{ + if (card->remote) + g_free(card->remote); + + card->remote = g_strdup(remote); +} + +const char *ofono_handsfree_card_get_remote(struct ofono_handsfree_card *card) +{ + return card->remote; +} + +void ofono_handsfree_card_set_local(struct ofono_handsfree_card *card, + const char *local) +{ + if (card->local) + g_free(card->local); + + card->local = g_strdup(local); +} + +const char *ofono_handsfree_card_get_local(struct ofono_handsfree_card *card) +{ + return card->local; +} + static void emit_card_added(struct ofono_handsfree_card *card) { DBusMessage *signal; |