diff options
| -rw-r--r-- | audio/headset.c | 16 | ||||
| -rw-r--r-- | audio/telephony-dummy.c | 6 | ||||
| -rw-r--r-- | audio/telephony-maemo.c | 29 | ||||
| -rw-r--r-- | audio/telephony.h | 2 | 
4 files changed, 49 insertions, 4 deletions
diff --git a/audio/headset.c b/audio/headset.c index 38c4b012..54e4da29 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -728,9 +728,15 @@ static int call_hold(struct audio_device *dev, const char *buf)  	return 0;  } -static int button_press(struct audio_device *device, const char *buf) +int telephony_key_press_rsp(void *telephony_device, cme_error_t err)  { -	struct headset *hs = device->headset; +	return telephony_generic_rsp(telephony_device, err); +} + +static int key_press(struct audio_device *device, const char *buf) +{ +	if (strlen(buf) < 9) +		return -EINVAL;  	g_dbus_emit_signal(device->conn, device->path,  			AUDIO_HEADSET_INTERFACE, "AnswerRequested", @@ -741,7 +747,9 @@ static int button_press(struct audio_device *device, const char *buf)  		ag.ring_timer = 0;  	} -	return headset_send(hs, "\r\nOK\r\n"); +	telephony_key_press_req(device, &buf[8]); + +	return 0;  }  int telephony_answer_call_rsp(void *telephony_device, cme_error_t err) @@ -1077,7 +1085,7 @@ static struct event event_callbacks[] = {  	{ "AT+CMER", event_reporting },  	{ "AT+CHLD", call_hold },  	{ "AT+CHUP", terminate_call }, -	{ "AT+CKPD", button_press }, +	{ "AT+CKPD", key_press },  	{ "AT+CLIP", cli_notification },  	{ "AT+BTRH", response_and_hold },  	{ "AT+BLDN", last_dialed_number }, diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c index 0d960910..8db25c72 100644 --- a/audio/telephony-dummy.c +++ b/audio/telephony-dummy.c @@ -205,6 +205,12 @@ void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)  	telephony_nr_and_ec_rsp(telephony_device, CME_ERROR_NONE);  } +void telephony_key_press_req(void *telephony_device, const char *keys) +{ +	debug("telephony-dummy: got key press request for %s", keys); +	telephony_key_press_rsp(telephony_device, CME_ERROR_NONE); +} +  /* D-Bus method handlers */  static DBusMessage *outgoing_call(DBusConnection *conn, DBusMessage *msg,  					void *data) diff --git a/audio/telephony-maemo.c b/audio/telephony-maemo.c index b2849a8c..34136838 100644 --- a/audio/telephony-maemo.c +++ b/audio/telephony-maemo.c @@ -802,6 +802,35 @@ void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)  	telephony_nr_and_ec_rsp(telephony_device, CME_ERROR_NONE);  } +void telephony_key_press_req(void *telephony_device, const char *keys) +{ +	struct csd_call *active, *waiting; +	int err; + +	debug("telephony-maemo: got key press request for %s", keys); + +	waiting = find_call_with_status(CSD_CALL_STATUS_COMING); +	if (!waiting) +		waiting = find_call_with_status(CSD_CALL_STATUS_MT_ALERTING); +	if (!waiting) +		waiting = find_call_with_status(CSD_CALL_STATUS_PROCEEDING); + +	active = find_call_with_status(CSD_CALL_STATUS_ACTIVE); + +	if (waiting) +		err = answer_call(waiting); +	else if (active) +		err = release_call(active); +	else +		err = 0; + +	if (err < 0) +		telephony_key_press_rsp(telephony_device, +							CME_ERROR_AG_FAILURE); +	else +		telephony_key_press_rsp(telephony_device, CME_ERROR_NONE); +} +  static void handle_incoming_call(DBusMessage *msg)  {  	const char *number, *call_path; diff --git a/audio/telephony.h b/audio/telephony.h index 050ed330..b33741eb 100644 --- a/audio/telephony.h +++ b/audio/telephony.h @@ -154,6 +154,7 @@ void telephony_list_current_calls_req(void *telephony_device);  void telephony_operator_selection_req(void *telephony_device);  void telephony_call_hold_req(void *telephony_device, const char *cmd);  void telephony_nr_and_ec_req(void *telephony_device, gboolean enable); +void telephony_key_press_req(void *telephony_device, const char *keys);  /* AG responses to HF requests. These are implemented by headset.c */  int telephony_event_reporting_rsp(void *telephony_device, cme_error_t err); @@ -168,6 +169,7 @@ int telephony_list_current_calls_rsp(void *telephony_device, cme_error_t err);  int telephony_operator_selection_rsp(void *telephony_device, cme_error_t err);  int telephony_call_hold_rsp(void *telephony_device, cme_error_t err);  int telephony_nr_and_ec_rsp(void *telephony_device, cme_error_t err); +int telephony_key_press_rsp(void *telephony_device, cme_error_t err);  /* Event indications by AG. These are implemented by headset.c */  int telephony_event_ind(int index);  | 
