OSDN Git Service

Add Connecting property to the Headset interface
authorJohan Hedberg <johan.hedberg@nokia.com>
Tue, 24 Mar 2009 16:28:45 +0000 (18:28 +0200)
committerJohan Hedberg <johan.hedberg@nokia.com>
Tue, 24 Mar 2009 16:28:45 +0000 (18:28 +0200)
This property was requested by pulseaudio developers to be able to anticipate
what profiles will be connected for multi-profile headsets.

audio/headset.c
doc/audio-api.txt

index d0647b3..ba328bf 100644 (file)
@@ -1853,6 +1853,10 @@ static DBusMessage *hs_get_properties(DBusConnection *conn,
        value = (device->headset->state == HEADSET_STATE_PLAYING);
        dict_append_entry(&dict, "Playing", DBUS_TYPE_BOOLEAN, &value);
 
+       /* Connecting */
+       value = (device->headset->state == HEADSET_STATE_CONNECT_IN_PROGRESS);
+       dict_append_entry(&dict, "Connecting", DBUS_TYPE_BOOLEAN, &value);
+
        /* Connected */
        value = (device->headset->state >= HEADSET_STATE_CONNECTED);
        dict_append_entry(&dict, "Connected", DBUS_TYPE_BOOLEAN, &value);
@@ -2382,13 +2386,23 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
                                        AUDIO_HEADSET_INTERFACE,
                                        "Disconnected",
                                        DBUS_TYPE_INVALID);
-               emit_property_changed(dev->conn, dev->path,
+               if (hs->state > HEADSET_STATE_CONNECT_IN_PROGRESS)
+                       emit_property_changed(dev->conn, dev->path,
                                        AUDIO_HEADSET_INTERFACE, "Connected",
                                        DBUS_TYPE_BOOLEAN, &value);
+               else
+                       emit_property_changed(dev->conn, dev->path,
+                                       AUDIO_HEADSET_INTERFACE,
+                                       "Connecting",
+                                       DBUS_TYPE_BOOLEAN, &value);
                telephony_device_disconnected(dev);
                active_devices = g_slist_remove(active_devices, dev);
                break;
        case HEADSET_STATE_CONNECT_IN_PROGRESS:
+               value = TRUE;
+               emit_property_changed(dev->conn, dev->path,
+                                       AUDIO_HEADSET_INTERFACE, "Connecting",
+                                       DBUS_TYPE_BOOLEAN, &value);
                break;
        case HEADSET_STATE_CONNECTED:
                close_sco(dev);
@@ -2402,6 +2416,11 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
                                                AUDIO_HEADSET_INTERFACE,
                                                "Connected",
                                                DBUS_TYPE_BOOLEAN, &value);
+                       value = FALSE;
+                       emit_property_changed(dev->conn, dev->path,
+                                               AUDIO_HEADSET_INTERFACE,
+                                               "Connecting",
+                                               DBUS_TYPE_BOOLEAN, &value);
                        active_devices = g_slist_append(active_devices, dev);
                        telephony_device_connected(dev);
                } else if (hs->state == HEADSET_STATE_PLAYING) {
index a73ba20..3ffc57a 100644 (file)
@@ -122,6 +122,11 @@ properties boolean Connected [readonly]
                        Indicates if there is a active connection to the
                        HSP/HFP connection on the remote device.
 
+               boolean Connecting [readonly]
+
+                       Indicates that there is a HFP or HSP connection attempt
+                       in progress.
+
                boolean Playing  [readonly]
 
                        Indicates if an audio connection to the headset