handsfree-audio: Check CVSD when registering agent

This patch makes CVSD codec mandatory when registering a Handsfree
Audio Agent.
This commit is contained in:
Claudio Takahasi 2013-02-28 15:52:50 -03:00 committed by Denis Kenzior
parent 80212a3db2
commit 4fcd084859
1 changed files with 9 additions and 2 deletions

View File

@ -307,6 +307,7 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
unsigned char *codecs;
DBusMessageIter iter, array;
int length, i;
gboolean has_cvsd = FALSE;
if (agent)
return __ofono_error_in_use(msg);
@ -326,11 +327,17 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
return __ofono_error_invalid_args(msg);
for (i = 0; i < length; i++) {
if (codecs[i] != HFP_CODEC_CVSD &&
codecs[i] != HFP_CODEC_MSBC)
if (codecs[i] == HFP_CODEC_CVSD)
has_cvsd = TRUE;
else if (codecs[i] != HFP_CODEC_MSBC)
return __ofono_error_invalid_args(msg);
}
if (has_cvsd == FALSE) {
ofono_error("CVSD codec is mandatory");
return __ofono_error_invalid_args(msg);
}
agent = g_new0(struct agent, 1);
agent->owner = g_strdup(sender);
agent->path = g_strdup(path);