mirror of git://git.sysmocom.de/ofono
handsfree: Simplify logic
This commit is contained in:
parent
e7f055385f
commit
b37f5e842d
|
@ -43,8 +43,6 @@
|
||||||
#include "hfp.h"
|
#include "hfp.h"
|
||||||
#include "slc.h"
|
#include "slc.h"
|
||||||
|
|
||||||
#define OFONO_HANDSFREE_CNUM_SERVICE_VOICE 4
|
|
||||||
|
|
||||||
static const char *binp_prefix[] = { "+BINP:", NULL };
|
static const char *binp_prefix[] = { "+BINP:", NULL };
|
||||||
static const char *bvra_prefix[] = { "+BVRA:", NULL };
|
static const char *bvra_prefix[] = { "+BVRA:", NULL };
|
||||||
|
|
||||||
|
@ -149,19 +147,15 @@ static void cnum_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
list = g_new(struct ofono_phone_number, num);
|
list = g_new0(struct ofono_phone_number, num);
|
||||||
|
|
||||||
g_at_result_iter_init(&iter, result);
|
g_at_result_iter_init(&iter, result);
|
||||||
|
|
||||||
for (num = 0; g_at_result_iter_next(&iter, "+CNUM:"); ) {
|
for (num = 0; g_at_result_iter_next(&iter, "+CNUM:"); ) {
|
||||||
const char *number;
|
const char *number;
|
||||||
int len;
|
|
||||||
int service;
|
int service;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
list[num].number[0] = '\0';
|
|
||||||
list[num].type = 129;
|
|
||||||
|
|
||||||
if (!g_at_result_iter_skip_next(&iter))
|
if (!g_at_result_iter_skip_next(&iter))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -177,17 +171,17 @@ static void cnum_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
if (!g_at_result_iter_next_number(&iter, &service))
|
if (!g_at_result_iter_next_number(&iter, &service))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (service == OFONO_HANDSFREE_CNUM_SERVICE_VOICE) {
|
/* We are only interested in Voice services */
|
||||||
len = strlen(number);
|
if (service != 4)
|
||||||
if (len > OFONO_MAX_PHONE_NUMBER_LENGTH)
|
continue;
|
||||||
len = OFONO_MAX_PHONE_NUMBER_LENGTH;
|
|
||||||
strncpy(list[num].number, number, len);
|
|
||||||
list[num].number[len] = '\0';
|
|
||||||
list[num].type = type;
|
|
||||||
|
|
||||||
DBG("cnum_notify:%s", list[num].number);
|
strncpy(list[num].number, number,
|
||||||
num++;
|
OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||||
}
|
list[num].number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
|
||||||
|
list[num].type = type;
|
||||||
|
|
||||||
|
DBG("cnum_notify:%s", list[num].number);
|
||||||
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in New Issue