summaryrefslogtreecommitdiffstats
path: root/src/handsfree-audio.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2013-02-26 14:03:04 -0600
committerDenis Kenzior <denkenz@gmail.com>2013-02-26 14:14:46 -0600
commitdfacb14968a2f1d229359671da65ed3ce61c2fa8 (patch)
tree90ac80a585215baa3395b76b9239b0c82627d01d /src/handsfree-audio.c
parentb76bb56daef4d649f339d742c8d11120682ad9ba (diff)
downloadofono-dfacb14968a2f1d229359671da65ed3ce61c2fa8.tar.bz2
handsfree-audio: Implement CardAdded signal
Diffstat (limited to 'src/handsfree-audio.c')
-rw-r--r--src/handsfree-audio.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 6be23634..9e9a7a2c 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -130,6 +130,33 @@ struct ofono_handsfree_card *ofono_handsfree_card_create(const char *remote,
return card;
}
+static void emit_card_added(struct ofono_handsfree_card *card)
+{
+ DBusMessage *signal;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ const char *path;
+
+ signal = dbus_message_new_signal(OFONO_MANAGER_PATH,
+ HFP_AUDIO_MANAGER_INTERFACE,
+ "CardAdded");
+
+ if (signal == NULL)
+ return;
+
+ dbus_message_iter_init_append(signal, &iter);
+
+ path = card->path;
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+ card_append_properties(card, &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ g_dbus_send_message(ofono_dbus_get_connection(), signal);
+}
+
int ofono_handsfree_card_register(struct ofono_handsfree_card *card)
{
static int next_card_id = 1;
@@ -147,6 +174,7 @@ int ofono_handsfree_card_register(struct ofono_handsfree_card *card)
return -EIO;
card->path = g_strdup(path);
+ emit_card_added(card);
return 0;
}
@@ -340,6 +368,12 @@ static const GDBusMethodTable am_methods[] = {
{ }
};
+static const GDBusSignalTable am_signals[] = {
+ { GDBUS_SIGNAL("CardAdded",
+ GDBUS_ARGS({ "path", "o" }, { "properties", "a{sv}" })) },
+ { }
+};
+
void ofono_handsfree_audio_ref(void)
{
ref_count += 1;
@@ -350,7 +384,8 @@ void ofono_handsfree_audio_ref(void)
if (!g_dbus_register_interface(ofono_dbus_get_connection(),
OFONO_MANAGER_PATH,
HFP_AUDIO_MANAGER_INTERFACE,
- am_methods, NULL, NULL, NULL, NULL))
+ am_methods, am_signals, NULL,
+ NULL, NULL))
ofono_error("Unable to register Handsfree Audio Manager");
}