All pastes #821127 Raw Edit

Alok

public c v1 · immutable
·published 2007-12-17 22:46 UTC
rendered paste body
diff --git a/audio/headset.c b/audio/headset.cindex 89d0174..123339b 100644--- a/audio/headset.c+++ b/audio/headset.c@@ -215,16 +215,46 @@ static int call_hold(struct device *device, const char *buf)  static int answer_call(struct device *device, const char *buf) {+	struct headset *hs = device->headset;+	int err;+ 	dbus_connection_emit_signal(device->conn, device->path, 			AUDIO_HEADSET_INTERFACE, "AnswerRequested", 			DBUS_TYPE_INVALID); -	return headset_send(device->headset, "\r\nOK\r\n");+	if (hs->enable_hfp){+		g_source_remove(hs->ring_timer);+		hs->ring_timer = 0;+		err = headset_send(hs, "\r\nOK\r\n");++		if (err < 0)+			return err;+		/*+CIEV: (call = 1)*/+		err = headset_send(hs, "\r\n+CIEV:2, 1\r\n");++		if (err < 0)+			return err;+		/*+CIEV: (callsetup = 0)*/+		return headset_send(device->headset, "\r\n+CIEV:3, 0\r\n");++	} else+		return headset_send(device->headset, "\r\nOK\r\n"); }  static int terminate_call(struct device *device, const char *buf) {-	return headset_send(device->headset, "\r\nOK\r\n");+	struct headset *hs = device->headset;+	int err;++	dbus_connection_emit_signal(device->conn, device->path,+			AUDIO_HEADSET_INTERFACE, "TerminateCall",+			DBUS_TYPE_INVALID);++	err = headset_send(hs, "\r\nOK\r\n");+	if (err < 0)+	  return err;+	/*+CIEV: (call = 0)*/+	return headset_send(device->headset, "\r\n+CIEV:2, 0\r\n"); }  static int signal_gain_setting(struct device *device, const char *buf)@@ -1354,6 +1384,49 @@ static DBusHandlerResult hs_set_mic_gain(DBusConnection *conn, 	return hs_set_gain(conn, msg, data, HEADSET_GAIN_MICROPHONE); } +static DBusHandlerResult hs_call_setup(DBusConnection *conn,+						DBusMessage *msg,+						void *data)+{+	struct device *device = data;+	struct headset *hs = device->headset;+	DBusMessage *reply;+	DBusError derr;+	dbus_uint16_t value;+	int err;++	if (hs->state < HEADSET_STATE_CONNECTED)+		return error_not_connected(conn, msg);++	dbus_error_init(&derr);+	dbus_message_get_args(msg, &derr, DBUS_TYPE_UINT16, &value,+				DBUS_TYPE_INVALID);++	if (dbus_error_is_set(&derr)) {+		error_invalid_arguments(conn, msg, derr.message);+		dbus_error_free(&derr);+		return DBUS_HANDLER_RESULT_HANDLED;+	}++	if (value > 3)+		return error_invalid_arguments(conn, msg,+					"Must be less than or equal to 3");++	reply = dbus_message_new_method_return(msg);+	if (!reply)+		return DBUS_HANDLER_RESULT_NEED_MEMORY;++	err = headset_send(device->headset, "\r\n+CIEV:3, %u\r\n", value);+	if (err) {+		dbus_message_unref(reply);+		return error_failed(conn, msg, "Unable to send to headset");+	}++	send_message_and_unref(conn, reply);++	return DBUS_HANDLER_RESULT_HANDLED;+}+ static DBusMethodVTable headset_methods[] = { 	{ "Connect",		hs_connect,		"",	""	}, 	{ "Disconnect",		hs_disconnect,		"",	""	},@@ -1367,6 +1440,7 @@ static DBusMethodVTable headset_methods[] = { 	{ "GetMicrophoneGain",	hs_get_mic_gain,	"",	"q"	}, 	{ "SetSpeakerGain",	hs_set_speaker_gain,	"q",	""	}, 	{ "SetMicrophoneGain",	hs_set_mic_gain,	"q",	""	},+	{ "CallSetup",		hs_call_setup,		"q",	""	}, 	{ NULL, NULL, NULL, NULL } }; @@ -1378,6 +1452,7 @@ static DBusSignalVTable headset_signals[] = { 	{ "Playing",			""	}, 	{ "SpeakerGainChanged",		"q"	}, 	{ "MicrophoneGainChanged",	"q"	},+	{ "TerminateCall",		""	}, 	{ NULL, NULL } };