diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2013-03-27 21:13:01 -0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2013-03-28 09:34:39 -0500 |
commit | 9dd7bb365fb7971ee5aebfbbbc51e7c3ea2df491 (patch) | |
tree | ebc930aabfca348922ce433be7669f1feff0ce19 /src/handsfree-audio.c | |
parent | 4f02f03abb5a9fd2a1805f7aa60304e01a223ebc (diff) | |
download | ofono-9dd7bb365fb7971ee5aebfbbbc51e7c3ea2df491.tar.bz2 |
handsfree-audio: Add .Connect using the card driver
Now each handsfree implementation may be notified that a card wants
its audio to be connected.
Diffstat (limited to 'src/handsfree-audio.c')
-rw-r--r-- | src/handsfree-audio.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c index 571ed54f..3f24a2a0 100644 --- a/src/handsfree-audio.c +++ b/src/handsfree-audio.c @@ -273,10 +273,24 @@ done: return FALSE; } +static void card_connect_reply_cb(const struct ofono_error *error, void *data) +{ + struct ofono_handsfree_card *card = data; + DBusMessage *reply; + + if (error->type == OFONO_ERROR_TYPE_NO_ERROR) + reply = dbus_message_new_method_return(card->msg); + else + reply = __ofono_error_failed(card->msg); + + __ofono_dbus_pending_reply(&card->msg, reply); +} + static DBusMessage *card_connect(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_handsfree_card *card = data; + const struct ofono_handsfree_card_driver *driver = card->driver; const char *sender; int err; @@ -291,6 +305,17 @@ static DBusMessage *card_connect(DBusConnection *conn, if (card->msg) return __ofono_error_busy(msg); + if (!driver || !driver->connect) + goto fallback; + + card->msg = dbus_message_ref(msg); + + driver->connect(card, card_connect_reply_cb, card); + + return NULL; + +fallback: + /* There's no driver, fallback to direct SCO connection */ err = ofono_handsfree_card_connect_sco(card); if (err < 0) return __ofono_error_failed(msg); |