diff options
| author | Johan Hedberg <johan.hedberg@nokia.com> | 2008-09-05 15:41:57 +0300 | 
|---|---|---|
| committer | Johan Hedberg <johan.hedberg@nokia.com> | 2008-09-05 15:41:57 +0300 | 
| commit | 96cdd87ef17d72053261da7a979ec8627e0a5cd8 (patch) | |
| tree | 12b2c0a470404bca343e3793068eb6c25ba69138 | |
| parent | 6a2ff7dbf3f3b15b0cac10c64ddc82ecf23be68d (diff) | |
Implement call notification
| -rw-r--r-- | audio/headset.c | 52 | ||||
| -rw-r--r-- | audio/telephony-dummy.c | 13 | ||||
| -rw-r--r-- | audio/telephony.h | 4 | 
3 files changed, 68 insertions, 1 deletions
| diff --git a/audio/headset.c b/audio/headset.c index 210d6851..89511f71 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -2126,6 +2126,58 @@ int telephony_response_and_hold_ind(int rh)  	return headset_send(hs, "\r\n+BTRH:%d\r\n", ag.rh);  } +int telephony_notify_call(const char *number) +{ +	struct headset *hs; + +	if (!active_telephony_device) +		return -ENODEV; + +	hs = active_telephony_device->headset; + +	if (hs->ring_timer) { +		debug("telephony_notify_call: already calling"); +		return -EBUSY; +	} + +	if (hs->ph_number) { +		g_free(hs->ph_number); +		hs->ph_number = NULL; +	} + +	if (number) +		hs->ph_number = g_strdup(number); + +	headset_send(hs, "\r\nRING\r\n"); + +	if (hs->cli_active && hs->ph_number) +		headset_send(hs, "\r\n+CLIP:\"%s\",%d\r\n", +				hs->ph_number, hs->type); + +	hs->ring_timer = g_timeout_add(RING_INTERVAL, ring_timer_cb, +					active_telephony_device); + +	return 0; +} + +int telephony_stop_calling(void) +{ +	struct headset *hs; + +	if (!active_telephony_device) +		return -ENODEV; + +	hs = active_telephony_device->headset; + +	if (!hs->ring_timer) +		return -EINVAL; + +	g_source_remove(hs->ring_timer); +	hs->ring_timer = 0; + +	return 0; +} +  int telephony_ready(uint32_t features, const struct indicator *indicators,  			int rh)  { diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c index 0e9673b3..f5c1a0d2 100644 --- a/audio/telephony-dummy.c +++ b/audio/telephony-dummy.c @@ -123,6 +123,9 @@ static DBusMessage *outgoing_call(DBusConnection *conn, DBusMessage *msg,  	debug("telephony-dummy: outgoing call to %s", number); +	telephony_update_indicator(dummy_indicators, "callsetup", +					EV_CALLSETUP_OUTGOING); +  	return dbus_message_new_method_return(msg);;  } @@ -137,6 +140,11 @@ static DBusMessage *incoming_call(DBusConnection *conn, DBusMessage *msg,  	debug("telephony-dummy: incoming call to %s", number); +	telephony_update_indicator(dummy_indicators, "callsetup", +					EV_CALLSETUP_INCOMING); + +	telephony_notify_call(number); +  	return dbus_message_new_method_return(msg);;  } @@ -145,9 +153,12 @@ static DBusMessage *cancel_call(DBusConnection *conn, DBusMessage *msg,  {  	debug("telephony-dummy: cancel call"); -	if (telephony_get_indicator(dummy_indicators, "callsetup") > 0) +	if (telephony_get_indicator(dummy_indicators, "callsetup") > 0) {  		telephony_update_indicator(dummy_indicators, "callsetup",  						EV_CALLSETUP_INACTIVE); +		telephony_stop_calling(); +	} +  	if (telephony_get_indicator(dummy_indicators, "call") > 0)  		telephony_update_indicator(dummy_indicators, "call",  						EV_CALL_INACTIVE); diff --git a/audio/telephony.h b/audio/telephony.h index 8334a3e1..ea4b2eac 100644 --- a/audio/telephony.h +++ b/audio/telephony.h @@ -78,6 +78,10 @@ int telephony_answer_call(void);  int telephony_dial_number(const char *number); +int telephony_notify_call(const char *number); + +int telephony_stop_calling(void); +  int telephony_ready(uint32_t features, const struct indicator *indicators,  			int rh); | 
