ofono 1.31-2 (aarch64;i686;x86_64;znver1) 2020-12443
9999

Submitter nobodydead [@T] gmail.com
Platform rolling
Repository main
URL https://abf.openmandriva.org/build_lists/825325
Packages
ofono-1.31-2.aarch64.binary
ofono-1.31-2.aarch64.source
ofono-debuginfo-1.31-2.aarch64.debuginfo
ofono-debugsource-1.31-2.aarch64.binary
ofono-devel-1.31-2.aarch64.binary
ofono-1.31-2.i686.source
ofono-1.31-2.i686.binary
ofono-debuginfo-1.31-2.i686.debuginfo
ofono-debugsource-1.31-2.i686.binary
ofono-devel-1.31-2.i686.binary
ofono-1.31-2.x86_64.source
ofono-1.31-2.x86_64.binary
ofono-debuginfo-1.31-2.x86_64.debuginfo
ofono-debugsource-1.31-2.x86_64.binary
ofono-devel-1.31-2.x86_64.binary
ofono-1.31-2.znver1.source
ofono-1.31-2.znver1.binary
ofono-debuginfo-1.31-2.znver1.debuginfo
ofono-debugsource-1.31-2.znver1.binary
ofono-devel-1.31-2.znver1.binary
Build Date 2020-09-14 18:46:38 +0000 UTC
Last Updated 2020-09-19 03:27:06.662006463 +0000 UTC
$ git show --format=fuller --patch-with-stat --summary 73437bb4d1d867961d104400d6df1c9f9ab78c3e

commit 73437bb4d1d867961d104400d6df1c9f9ab78c3e
Author:     Bernhard Rosenkränzer <bero@lindev.ch>
AuthorDate: Mon Sep 14 19:22:17 2020 +0200
Commit:     Bernhard Rosenkränzer <bero@lindev.ch>
CommitDate: Mon Sep 14 19:22:17 2020 +0200

    Port SailfishOS's qmimodem voicecall support to 1.31
---
 0001-qmimodem-implement-voice-calls.patch          | 983 +++++++++++++++++++++
 ...ll-list-helper-to-manage-voice-call-lists.patch | 445 ++++++++++
 0003-call-compare-by-status.patch                  | 289 ++++++
 0004-call-compare-by-id.patch                      | 134 +++
 0006-create-glist-helper-ofono_call_compare.patch  | 192 ++++
 ofono-1.31-qmimodem-voicecall.patch                | 876 ++++++++++++++++++
 ofono.spec                                         |  13 +-
 7 files changed, 2930 insertions(+), 2 deletions(-)
 create mode 100644 0001-qmimodem-implement-voice-calls.patch
 create mode 100644 0002-add-call-list-helper-to-manage-voice-call-lists.patch
 create mode 100644 0003-call-compare-by-status.patch
 create mode 100644 0004-call-compare-by-id.patch
 create mode 100644 0006-create-glist-helper-ofono_call_compare.patch
 create mode 100644 ofono-1.31-qmimodem-voicecall.patch

diff --git a/0001-qmimodem-implement-voice-calls.patch b/0001-qmimodem-implement-voice-calls.patch
new file mode 100644
index 0000000..92d2a64
--- /dev/null
+++ b/0001-qmimodem-implement-voice-calls.patch
@@ -0,0 +1,983 @@
+From 0bfb7039c9cb821aefb5e1cacc252172b8c80f1d Mon Sep 17 00:00:00 2001
+From: Alexander Couzens <lynxis@fe80.eu>
+Date: Tue, 25 Jul 2017 15:31:48 +0200
+Subject: [RFC] qmimodem: implement voice calls
+
+The voice_generated.* files is an RFC how files should look like.
+They aren't yet generated.
+---
+ Makefile.am                        |   5 +-
+ drivers/qmimodem/qmi.h             |  13 ++
+ drivers/qmimodem/voice.c           |  86 ++++++++++
+ drivers/qmimodem/voice.h           |  84 ++++++++++
+ drivers/qmimodem/voice_generated.c | 210 +++++++++++++++++++++++
+ drivers/qmimodem/voice_generated.h | 113 +++++++++++++
+ drivers/qmimodem/voicecall.c       | 332 ++++++++++++++++++++++++++++++++++++-
+ 7 files changed, 840 insertions(+), 3 deletions(-)
+ create mode 100644 drivers/qmimodem/voice.c
+ create mode 100644 drivers/qmimodem/voice.h
+ create mode 100644 drivers/qmimodem/voice_generated.c
+ create mode 100644 drivers/qmimodem/voice_generated.h
+
+diff --git a/Makefile.am b/Makefile.am
+index 4336297b..6cdff94c 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -216,7 +216,9 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
+ 					drivers/qmimodem/wds.h \
+ 					drivers/qmimodem/pds.h \
+ 					drivers/qmimodem/common.h \
+-					drivers/qmimodem/wda.h
++					drivers/qmimodem/wda.h \
++					drivers/qmimodem/voice.h \
++					drivers/qmimodem/voice.c
+ 
+ builtin_modules += qmimodem
+ builtin_sources += $(qmi_sources) \
+@@ -225,6 +227,7 @@ builtin_sources += $(qmi_sources) \
+ 			drivers/qmimodem/qmimodem.c \
+ 			drivers/qmimodem/devinfo.c \
+ 			drivers/qmimodem/voicecall.c \
++			drivers/qmimodem/voice_generated.c \
+ 			drivers/qmimodem/network-registration.c \
+ 			drivers/qmimodem/sim-legacy.c \
+ 			drivers/qmimodem/sim.c \
+diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
+index d244cd89..f0453cc6 100644
+--- a/drivers/qmimodem/qmi.h
++++ b/drivers/qmimodem/qmi.h
+@@ -19,6 +19,9 @@
+  *
+  */
+ 
++#ifndef __OFONO_QMI_QMI_H
++#define __OFONO_QMI_QMI_H
++
+ #include <stdbool.h>
+ #include <stdint.h>
+ 
+@@ -173,3 +176,13 @@ uint16_t qmi_service_register(struct qmi_service *service,
+ 				void *user_data, qmi_destroy_func_t destroy);
+ bool qmi_service_unregister(struct qmi_service *service, uint16_t id);
+ bool qmi_service_unregister_all(struct qmi_service *service);
++
++
++/* FIXME: find a place for parse_error */
++enum parse_error {
++	NONE = 0,
++	MISSING_MANDATORY = 1,
++	INVALID_LENGTH = 2,
++};
++
++#endif /* __OFONO_QMI_QMI_H */
+diff --git a/drivers/qmimodem/voice.c b/drivers/qmimodem/voice.c
+new file mode 100644
+index 00000000..c0856176
+--- /dev/null
++++ b/drivers/qmimodem/voice.c
+@@ -0,0 +1,86 @@
++/*
++ *
++ *  oFono - Open Source Telephony
++ *
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ *
++ *  This program is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ */
++
++#include <stdint.h>
++
++#include "voice.h"
++#include "../../src/common.h"
++
++#define _(X) case X: return #X
++
++const char *qmi_voice_call_state_name(enum qmi_voice_call_state value)
++{
++	switch (value) {
++		_(QMI_CALL_STATE_IDLE);
++		_(QMI_CALL_STATE_ORIG);
++		_(QMI_CALL_STATE_INCOMING);
++		_(QMI_CALL_STATE_CONV);
++		_(QMI_CALL_STATE_CC_IN_PROG);
++		_(QMI_CALL_STATE_ALERTING);
++		_(QMI_CALL_STATE_HOLD);
++		_(QMI_CALL_STATE_WAITING);
++		_(QMI_CALL_STATE_DISCONNECTING);
++		_(QMI_CALL_STATE_END);
++		_(QMI_CALL_STATE_SETUP);
++	}
++	return "QMI_CALL_STATE_<UNKNOWN>";
++}
++
++int qmi_to_ofono_status(uint8_t status, int *ret) {
++	int err = 0;
++	switch (status) {
++	case QMI_CALL_STATE_IDLE:
++	case QMI_CALL_STATE_END:
++	case QMI_CALL_STATE_DISCONNECTING:
++		*ret = CALL_STATUS_DISCONNECTED;
++		break;
++	case QMI_CALL_STATE_HOLD:
++		*ret = CALL_STATUS_HELD;
++		break;
++	case QMI_CALL_STATE_WAITING:
++		*ret = CALL_STATUS_WAITING;
++		break;
++	case QMI_CALL_STATE_ORIG:
++		*ret = CALL_STATUS_DIALING;
++		break;
++	case QMI_CALL_STATE_INCOMING:
++		*ret = CALL_STATUS_INCOMING;
++		break;
++	case QMI_CALL_STATE_CONV:
++		*ret = CALL_STATUS_ACTIVE;
++		break;
++	case QMI_CALL_STATE_CC_IN_PROG:
++	case QMI_CALL_STATE_SETUP:
++		/* FIXME: unsure if _SETUP is dialing or not */
++		*ret = CALL_STATUS_DIALING;
++		break;
++	case QMI_CALL_STATE_ALERTING:
++		*ret = CALL_STATUS_ALERTING;
++		break;
++	default:
++		err = 1;
++	}
++	return err;
++}
++
++uint8_t ofono_to_qmi_direction(enum call_direction ofono_direction) {
++	return ofono_direction + 1;
++}
++enum call_direction qmi_to_ofono_direction(uint8_t qmi_direction) {
++	return qmi_direction - 1;
++}
++
+diff --git a/drivers/qmimodem/voice.h b/drivers/qmimodem/voice.h
+new file mode 100644
+index 00000000..f25648f7
+--- /dev/null
++++ b/drivers/qmimodem/voice.h
+@@ -0,0 +1,84 @@
++/*
++ *
++ *  oFono - Open Source Telephony
++ *
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ *
++ *  This program is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ */
++
++enum call_direction;
++
++enum ussd_dcs {
++	USS_DCS_ASCII = 0x1,
++	USS_DCS_8BIT,
++	USS_DCS_UCS2,
++};
++
++enum ussd_user_required {
++	NO_USER_ACTION_REQUIRED = 0x1,
++	USER_ACTION_REQUIRED = 0x2,
++};
++
++struct qmi_ussd_data {
++	uint8_t dcs;
++	uint8_t length;
++	uint8_t data[0];
++} __attribute__((__packed__));
++
++enum voice_commands {
++	QMI_VOICE_CANCEL_USSD = 0x3c,
++	QMI_VOICE_USSD_RELEASE_IND = 0x3d,
++	QMI_VOICE_USSD_IND = 0x3e,
++	QMI_VOICE_SUPS_IND = 0x42,
++	QMI_VOICE_ASYNC_ORIG_USSD = 0x43,
++};
++
++enum qmi_voice_call_state {
++	QMI_CALL_STATE_IDLE = 0x0,
++	QMI_CALL_STATE_ORIG,
++	QMI_CALL_STATE_INCOMING,
++	QMI_CALL_STATE_CONV,
++	QMI_CALL_STATE_CC_IN_PROG,
++	QMI_CALL_STATE_ALERTING,
++	QMI_CALL_STATE_HOLD,
++	QMI_CALL_STATE_WAITING,
++	QMI_CALL_STATE_DISCONNECTING,
++	QMI_CALL_STATE_END,
++	QMI_CALL_STATE_SETUP
++};
++
++enum qmi_voice_call_type {
++	QMI_CALL_TYPE_VOICE = 0x0,
++	QMI_CALL_TYPE_VOICE_FORCE,
++};
++
++const char *qmi_voice_call_state_name(enum qmi_voice_call_state value);
++uint8_t ofono_to_qmi_direction(enum call_direction ofono_direction);
++enum call_direction qmi_to_ofono_direction(uint8_t qmi_direction);
++int qmi_to_ofono_status(uint8_t status, int *ret);
++
++#define QMI_VOICE_IND_ALL_STATUS 0x2e
++
++#define QMI_VOICE_PARAM_USS_DATA 0x01
++
++#define QMI_VOICE_PARAM_ASYNC_USSD_ERROR 0x10
++#define QMI_VOICE_PARAM_ASYNC_USSD_FAILURE_CASE 0x11
++#define QMI_VOICE_PARAM_ASYNC_USSD_DATA 0x12
++
++#define QMI_VOICE_PARAM_USSD_IND_USER_ACTION 0x01
++#define QMI_VOICE_PARAM_USSD_IND_DATA 0x10
++#define QMI_VOICE_PARAM_USSD_IND_UCS2 0x11
++
++/* according to GSM TS 23.038 */
++#define USSD_DCS_8BIT 0xf4
++#define USSD_DCS_UCS2 0x48
++#define USSD_DCS_UNSPECIFIC 0x0f
+diff --git a/drivers/qmimodem/voice_generated.c b/drivers/qmimodem/voice_generated.c
+new file mode 100644
+index 00000000..3440be43
+--- /dev/null
++++ b/drivers/qmimodem/voice_generated.c
+@@ -0,0 +1,210 @@
++
++#include <stdint.h>
++#include <string.h>
++#include <glib.h>
++
++#include "voice_generated.h"
++
++int qmi_voice_dial_call(
++		struct qmi_voice_dial_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy)
++{
++	struct qmi_param *param = NULL;
++
++	param = qmi_param_new();
++	if (!param)
++		goto error;
++
++	if (arg->calling_number_set) {
++		if (!qmi_param_append(param,
++				 0x1,
++				 strlen(arg->calling_number),
++				 arg->calling_number))
++			goto error;
++	}
++
++	if (arg->call_type_set)
++		qmi_param_append_uint8(param, 0x10, arg->call_type);
++
++	if (qmi_service_send(service,
++			     0x20,
++			     param,
++			     func,
++			     user_data,
++			     destroy) > 0)
++		return 0;
++error:
++	g_free(param);
++	return 1;
++}
++
++enum parse_error qmi_voice_dial_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_dial_call_result *result)
++{
++	int err = NONE;
++
++	/* mandatory */
++	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
++		result->call_id_set = 1;
++	else
++		err = MISSING_MANDATORY;
++
++	return err;
++}
++
++int qmi_voice_end_call(
++		struct qmi_voice_end_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy)
++{
++	struct qmi_param *param = NULL;
++
++	param = qmi_param_new();
++	if (!param)
++		goto error;
++
++	if (arg->call_id_set) {
++		if (!qmi_param_append_uint8(
++					param,
++					0x1,
++					arg->call_id))
++			goto error;
++	}
++
++	if (qmi_service_send(service,
++			     0x21,
++			     param,
++			     func,
++			     user_data,
++			     destroy) > 0)
++		return 0;
++error:
++	g_free(param);
++	return 1;
++}
++
++enum parse_error qmi_voice_end_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_end_call_result *result)
++{
++	int err = NONE;
++
++	/* optional */
++	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
++		result->call_id_set = 1;
++
++	return err;
++}
++
++
++int qmi_voice_answer_call(
++		struct qmi_voice_answer_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy)
++{
++	struct qmi_param *param = NULL;
++
++	param = qmi_param_new();
++	if (!param)
++		goto error;
++
++	if (arg->call_id_set) {
++		if (!qmi_param_append_uint8(
++					param,
++					0x1,
++					arg->call_id))
++			goto error;
++	}
++
++	if (qmi_service_send(service,
++			     0x22,
++			     param,
++			     func,
++			     user_data,
++			     destroy) > 0)
++		return 0;
++error:
++	g_free(param);
++	return 1;
++}
++
++
++enum parse_error qmi_voice_answer_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_answer_call_result *result)
++{
++	int err = NONE;
++
++	/* optional */
++	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
++		result->call_id_set = 1;
++
++	return err;
++}
++
++enum parse_error qmi_voice_ind_call_status(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_all_call_status_ind *result)
++{
++	int err = NONE;
++	int offset;
++	uint16_t len;
++	const struct qmi_voice_remote_party_number *remote_party_number;
++	const struct qmi_voice_call_information *call_information;
++
++	/* mandatory */
++	call_information = qmi_result_get(qmi_result, 0x01, &len);
++	if (call_information)
++	{
++		int instance_size = sizeof(struct qmi_voice_call_information_instance);
++		/* verify the length */
++		if (len < sizeof(call_information->size))
++			return INVALID_LENGTH;
++
++		if (len != call_information->size * sizeof(struct qmi_voice_call_information_instance)
++			    + sizeof(call_information->size))
++			return INVALID_LENGTH;
++		result->call_information_set = 1;
++		result->call_information = call_information;
++	} else
++		return MISSING_MANDATORY;
++
++	/* mandatory */
++	remote_party_number = qmi_result_get(qmi_result, 0x10, &len);
++	if (remote_party_number) {
++		const struct qmi_voice_remote_party_number_instance *instance;
++		int instance_size = sizeof(struct qmi_voice_remote_party_number_instance);
++		int i;
++
++		/* verify the length */
++		if (len < sizeof(remote_party_number->size))
++			return INVALID_LENGTH;
++
++		for (i = 0, offset = sizeof(remote_party_number->size);
++		     offset <= len && i < 16 && i < remote_party_number->size; i++)
++		{
++			if (offset == len) {
++				break;
++			} else if (offset + instance_size > len) {
++				return INVALID_LENGTH;
++			}
++
++			instance = (void *)remote_party_number + offset;
++			result->remote_party_number[i] = instance;
++			offset += sizeof(struct qmi_voice_remote_party_number_instance) + instance->number_size;
++		}
++		result->remote_party_number_set = 1;
++		result->remote_party_number_size = remote_party_number->size;
++	} else
++		return MISSING_MANDATORY;
++
++	return err;
++}
+diff --git a/drivers/qmimodem/voice_generated.h b/drivers/qmimodem/voice_generated.h
+new file mode 100644
+index 00000000..471b52ea
+--- /dev/null
++++ b/drivers/qmimodem/voice_generated.h
+@@ -0,0 +1,113 @@
++
++#ifndef __OFONO_QMI_VOICE_GENERATED_H
++#define __OFONO_QMI_VOICE_GENERATED_H
++
++#include "qmi.h"
++
++struct qmi_voice_remote_party_number_instance {
++	uint8_t call_id;
++	uint8_t presentation_indicator;
++	uint8_t number_size;
++	char number[0];
++} __attribute__((__packed__));
++
++struct qmi_voice_remote_party_number {
++	uint8_t size;
++	struct qmi_voice_remote_party_number_instance instance[0];
++} __attribute__((__packed__));
++
++/* generator / parser */
++
++struct qmi_voice_dial_call_arg {
++	bool calling_number_set;
++	const char *calling_number;
++	bool call_type_set;
++	uint8_t call_type;
++};
++
++int qmi_voice_dial_call(
++		struct qmi_voice_dial_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy);
++
++struct qmi_voice_dial_call_result {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++enum parse_error qmi_voice_dial_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_dial_call_result *result);
++
++struct qmi_voice_end_call_arg {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++int qmi_voice_end_call(
++		struct qmi_voice_end_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy);
++
++struct qmi_voice_end_call_result {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++enum parse_error qmi_voice_end_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_end_call_result *result);
++
++struct qmi_voice_answer_call_arg {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++int qmi_voice_answer_call(
++		struct qmi_voice_answer_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy);
++
++struct qmi_voice_answer_call_result {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++enum parse_error qmi_voice_answer_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_answer_call_result *result);
++
++struct qmi_voice_call_information_instance {
++	uint8_t id;
++	uint8_t state;
++	uint8_t type;
++	uint8_t direction;
++	uint8_t mode;
++	uint8_t multipart_indicator;
++	uint8_t als;
++} __attribute__((__packed__));
++
++struct qmi_voice_call_information {
++	uint8_t size;
++	struct qmi_voice_call_information_instance instance[0];
++} __attribute__((__packed__)) ;
++
++struct qmi_voice_all_call_status_ind {
++	bool call_information_set;
++	const struct qmi_voice_call_information *call_information;
++	bool remote_party_number_set;
++	uint8_t remote_party_number_size;
++	const struct qmi_voice_remote_party_number_instance *remote_party_number[16];
++};
++
++enum parse_error qmi_voice_ind_call_status(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_all_call_status_ind *result);
++
++#endif /* __OFONO_QMI_VOICE_GENERATED_H */
+diff --git a/drivers/qmimodem/voicecall.c b/drivers/qmimodem/voicecall.c
+index 29166b08..27aae40c 100644
+--- a/drivers/qmimodem/voicecall.c
++++ b/drivers/qmimodem/voicecall.c
+@@ -3,6 +3,7 @@
+  *  oFono - Open Source Telephony
+  *
+  *  Copyright (C) 2011-2012  Intel Corporation. All rights reserved.
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
+  *
+  *  This program is free software; you can redistribute it and/or modify
+  *  it under the terms of the GNU General Public License version 2 as
+@@ -23,20 +24,113 @@
+ #include <config.h>
+ #endif
+ 
++#include <string.h>
++
+ #include <ofono/log.h>
+ #include <ofono/modem.h>
+ #include <ofono/voicecall.h>
++#include <ofono/call-list.h>
+ 
+-#include "qmi.h"
++#include "../src/common.h"
+ 
++#include "qmi.h"
+ #include "qmimodem.h"
++#include "voice.h"
++#include "voice_generated.h"
++
++#ifndef ARRAY_SIZE
++#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
++#endif
++
++
++/* qmi protocol */
++
++
++/* end of qmi */
+ 
+ struct voicecall_data {
+ 	struct qmi_service *voice;
+ 	uint16_t major;
+ 	uint16_t minor;
++	GSList *call_list;
++	struct voicecall_static *vs;
++	struct ofono_phone_number dialed;
+ };
+ 
++static void all_call_status_ind(struct qmi_result *result, void *user_data)
++{
++	struct ofono_voicecall *vc = user_data;
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	GSList *calls = NULL;
++	int i;
++	int size = 0;
++	struct qmi_voice_all_call_status_ind status_ind;
++	GSList *n, *o;
++	struct ofono_call *nc, *oc;
++
++
++	if (qmi_voice_ind_call_status(result, &status_ind) != NONE) {
++		DBG("Parsing of all call status indication failed");
++		return;
++	}
++
++	if (!status_ind.remote_party_number_set || !status_ind.call_information_set) {
++		DBG("Some required fields are not set");
++		return;
++	}
++
++	size = status_ind.call_information->size;
++	if (!size) {
++		DBG("No call informations received!");
++		return;
++	}
++
++	/* expect we have valid fields for every call */
++	if (size != status_ind.remote_party_number_size)  {
++		DBG("Not all fields have the same size");
++		return;
++	}
++
++	for (i = 0; i < size; i++) {
++		struct qmi_voice_call_information_instance call_info;
++		struct ofono_call *call;
++		const struct qmi_voice_remote_party_number_instance *remote_party = status_ind.remote_party_number[i];
++		int number_size;
++
++		call_info = status_ind.call_information->instance[i];
++		call = g_new0(struct ofono_call, 1);
++		call->id = call_info.id;
++		call->direction = qmi_to_ofono_direction(call_info.direction);
++
++		if (qmi_to_ofono_status(call_info.state, &call->status)) {
++			DBG("Ignore call id %d, because can not convert QMI state 0x%x to ofono.",
++			    call_info.id, call_info.state);
++			continue;
++		}
++		DBG("Call %d in state %s(%d)",
++		    call_info.id,
++		    qmi_voice_call_state_name(call_info.state),
++		    call_info.state);
++
++		call->type = 0; /* always voice */
++		number_size = remote_party->number_size;
++		if (number_size > OFONO_MAX_PHONE_NUMBER_LENGTH)
++			OFONO_MAX_PHONE_NUMBER_LENGTH;
++		strncpy(call->phone_number.number, remote_party->number,
++				number_size);
++		/* FIXME: set phone_number_type */
++
++		if (strlen(call->phone_number.number) > 0)
++			call->clip_validity = 0;
++		else
++			call->clip_validity = 2;
++
++		calls = g_slist_insert_sorted(calls, call, ofono_call_compare);
++	}
++
++	ofono_call_list_notify(vc, &vd->call_list, calls);
++}
++
+ static void create_voice_cb(struct qmi_service *service, void *user_data)
+ {
+ 	struct ofono_voicecall *vc = user_data;
+@@ -58,6 +152,12 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
+ 
+ 	data->voice = qmi_service_ref(service);
+ 
++	/* FIXME: we should call indication_register to ensure we get notified on call events.
++	 * We rely at the moment on the default value of notifications
++	 */
++	qmi_service_register(data->voice, QMI_VOICE_IND_ALL_STATUS,
++			     all_call_status_ind, vc, NULL);
++
+ 	ofono_voicecall_register(vc);
+ }
+ 
+@@ -77,7 +177,6 @@ static int qmi_voicecall_probe(struct ofono_voicecall *vc,
+ 					create_voice_cb, vc, NULL);
+ 
+ 	return 0;
+-
+ }
+ 
+ static void qmi_voicecall_remove(struct ofono_voicecall *vc)
+@@ -92,13 +191,242 @@ static void qmi_voicecall_remove(struct ofono_voicecall *vc)
+ 
+ 	qmi_service_unref(data->voice);
+ 
++	g_slist_free_full(data->call_list, g_free);
++
+ 	g_free(data);
+ }
+ 
++
++static struct ofono_call *create_call(struct ofono_voicecall *vc,
++				      enum call_direction direction,
++				      enum call_status status,
++				      const char *num,
++				      int num_type,
++				      int clip)
++{
++	return NULL;
++}
++
++static void dial_cb(struct qmi_result *result, void *user_data)
++{
++	struct cb_data *cbd = user_data;
++	struct ofono_voicecall *vc = cbd->user;
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	ofono_voicecall_cb_t cb = cbd->cb;
++	uint16_t error;
++	struct qmi_voice_dial_call_result dial_result;
++	struct ofono_call *call;
++
++	if (qmi_result_set_error(result, &error)) {
++		DBG("QMI Error %d", error);
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	if (NONE != qmi_voice_dial_call_parse(result, &dial_result)) {
++		DBG("Received invalid Result");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	if (!dial_result.call_id_set) {
++		DBG("Didn't receive a call id");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	DBG("New call QMI id %d", dial_result.call_id);
++	ofono_call_list_dial_callback(vc,
++				      &vd->call_list,
++				      &vd->dialed,
++				      dial_result.call_id);
++
++
++	/* FIXME: create a timeout on this call_id */
++	CALLBACK_WITH_SUCCESS(cb, cbd->data);
++}
++
++static void dial(struct ofono_voicecall *vc, const struct ofono_phone_number *ph,
++		enum ofono_clir_option clir, ofono_voicecall_cb_t cb,
++		void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct cb_data *cbd = cb_data_new(cb, data);
++	struct qmi_voice_dial_call_arg arg;
++
++	cbd->user = vc;
++	arg.calling_number_set = true;
++	arg.calling_number = ph->number;
++	memcpy(&vd->dialed, ph, sizeof(*ph));
++
++	arg.call_type_set = true;
++	arg.call_type = QMI_CALL_TYPE_VOICE_FORCE;
++
++	if (!qmi_voice_dial_call(
++				&arg,
++				vd->voice,
++				dial_cb,
++				cbd,
++				g_free))
++		return;
++
++	CALLBACK_WITH_FAILURE(cb, data);
++	g_free(cbd);
++}
++
++static void answer_cb(struct qmi_result *result, void *user_data)
++{
++	struct cb_data *cbd = user_data;
++	struct ofono_voicecall *vc = cbd->user;
++	ofono_voicecall_cb_t cb = cbd->cb;
++	uint16_t error;
++	struct qmi_voice_answer_call_result answer_result;
++	struct ofono_call *call;
++
++	if (qmi_result_set_error(result, &error)) {
++		DBG("QMI Error %d", error);
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	/* TODO: what happens when calling it with no active call or wrong caller id? */
++	if (NONE != qmi_voice_answer_call_parse(result, &answer_result)) {
++		DBG("Received invalid Result");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	CALLBACK_WITH_SUCCESS(cb, cbd->data);
++}
++
++static void answer(struct ofono_voicecall *vc, ofono_voicecall_cb_t cb, void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct cb_data *cbd = cb_data_new(cb, data);
++	struct qmi_voice_answer_call_arg arg;
++	struct ofono_call *call;
++	GSList *list;
++
++	DBG("");
++	cbd->user = vc;
++
++	list = g_slist_find_custom(vd->call_list,
++				   GINT_TO_POINTER(CALL_STATUS_INCOMING),
++				   ofono_call_compare_by_status);
++
++	if (list == NULL) {
++		DBG("Can not find a call to answer");
++		goto err;
++	}
++
++	call = list->data;
++
++	arg.call_id_set = true;
++	arg.call_id = call->id;
++
++	if (!qmi_voice_answer_call(
++				&arg,
++				vd->voice,
++				answer_cb,
++				cbd,
++				g_free))
++		return;
++err:
++	CALLBACK_WITH_FAILURE(cb, data);
++	g_free(cbd);
++}
++
++static void end_cb(struct qmi_result *result, void *user_data)
++{
++	struct cb_data *cbd = user_data;
++	struct ofono_voicecall *vc = cbd->user;
++	ofono_voicecall_cb_t cb = cbd->cb;
++	uint16_t error;
++	struct qmi_voice_end_call_result end_result;
++	struct ofono_call *call;
++
++	if (qmi_result_set_error(result, &error)) {
++		DBG("QMI Error %d", error);
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	if (NONE != qmi_voice_end_call_parse(result, &end_result)) {
++		DBG("Received invalid Result");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	CALLBACK_WITH_SUCCESS(cb, cbd->data);
++}
++
++static void release_specific(struct ofono_voicecall *vc, int id,
++		ofono_voicecall_cb_t cb, void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct cb_data *cbd = cb_data_new(cb, data);
++	struct qmi_voice_end_call_arg arg;
++	int i;
++
++	DBG("");
++	cbd->user = vc;
++
++	arg.call_id_set = true;
++	arg.call_id = id;
++
++	if (!qmi_voice_end_call(&arg,
++				vd->voice,
++				end_cb,
++				cbd,
++				g_free))
++		return;
++
++	CALLBACK_WITH_FAILURE(cb, data);
++	g_free(cbd);
++}
++
++static void hangup_active(struct ofono_voicecall *vc,
++		ofono_voicecall_cb_t cb, void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct qmi_voice_end_call_arg arg;
++	struct ofono_call *call;
++	GSList *list = NULL;
++	enum call_status active[] = {
++		CALL_STATUS_ACTIVE,
++		CALL_STATUS_DIALING,
++		CALL_STATUS_ALERTING
++	};
++	int i;
++
++	DBG("");
++	for (i = 0; i < ARRAY_SIZE(active); i++) {
++		list = g_slist_find_custom(vd->call_list,
++					   GINT_TO_POINTER(CALL_STATUS_ACTIVE),
++					   ofono_call_compare_by_status);
++
++		if (list)
++			break;
++	}
++
++	if (list == NULL) {
++		DBG("Can not find a call to hang up");
++		CALLBACK_WITH_FAILURE(cb, data);
++		return;
++	}
++
++	call = list->data;
++	release_specific(vc, call->id, cb, data);
++}
++
+ static struct ofono_voicecall_driver driver = {
+ 	.name		= "qmimodem",
+ 	.probe		= qmi_voicecall_probe,
+ 	.remove		= qmi_voicecall_remove,
++	.dial		= dial,
++	.answer		= answer,
++	.hangup_active  = hangup_active,
++	.release_specific  = release_specific,
+ };
+ 
+ void qmi_voicecall_init(void)
+-- 
+cgit v1.2.1
+
diff --git a/0002-add-call-list-helper-to-manage-voice-call-lists.patch b/0002-add-call-list-helper-to-manage-voice-call-lists.patch
new file mode 100644
index 0000000..7aa984d
--- /dev/null
+++ b/0002-add-call-list-helper-to-manage-voice-call-lists.patch
@@ -0,0 +1,445 @@
+diff -up ofono-1.31/include/call-list.h.1~ ofono-1.31/include/call-list.h
+--- ofono-1.31/include/call-list.h.1~	2020-09-14 18:59:47.205557339 +0200
++++ ofono-1.31/include/call-list.h	2020-09-14 18:59:47.205557339 +0200
+@@ -0,0 +1,38 @@
++/*
++ *
++ *  oFono - Open Source Telephony
++ *
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ *
++ *  This program is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ */
++
++#include <glib.h>
++
++struct ofono_voicecall;
++struct ofono_phone_number;
++
++/*
++ * Can be called by the driver in the dialing callback,
++ * when the new call id already known
++ */
++void ofono_call_list_dial_callback(struct ofono_voicecall *vc,
++				   GSList **call_list,
++				   const struct ofono_phone_number *ph,
++				   int call_id);
++
++/*
++ * Called with a list of known calls e.g. clcc.
++ * Call list will take ownership of all ofono call within the calls.
++ */
++void ofono_call_list_notify(struct ofono_voicecall *vc,
++			    GSList **call_list,
++			    GSList *calls);
+diff -up ofono-1.31/Makefile.am.1~ ofono-1.31/Makefile.am
+--- ofono-1.31/Makefile.am.1~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/Makefile.am	2020-09-14 19:01:23.229612076 +0200
+@@ -79,7 +79,7 @@ pkginclude_HEADERS = include/log.h inclu
+ 			include/cdma-provision.h include/handsfree.h \
+ 			include/handsfree-audio.h include/siri.h \
+ 			include/netmon.h include/lte.h include/ims.h \
+-			include/storage.h
++			include/storage.h include/call-list.h
+ 
+ nodist_pkginclude_HEADERS = include/version.h
+ 
+@@ -723,7 +723,7 @@ src_ofonod_SOURCES = $(builtin_sources)
+ 			src/cdma-provision.c src/handsfree.c \
+ 			src/handsfree-audio.c src/bluetooth.h \
+ 			src/hfp.h src/siri.c \
+-			src/netmon.c src/lte.c src/ims.c \
++			src/netmon.c src/lte.c src/ims.c src/call-list.c \
+ 			src/netmonagent.c src/netmonagent.h
+ 
+ src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) $(ell_ldadd) \
+@@ -906,7 +906,8 @@ unit_tests = unit/test-common unit/test-
+ 				unit/test-rilmodem-cs \
+ 				unit/test-rilmodem-sms \
+ 				unit/test-rilmodem-cb \
+-				unit/test-rilmodem-gprs
++				unit/test-rilmodem-gprs \
++				unit/test-call-list
+ 
+ noinst_PROGRAMS = $(unit_tests) \
+ 			unit/test-sms-root unit/test-mux unit/test-caif
+@@ -944,6 +945,12 @@ unit_test_sms_root_SOURCES = unit/test-s
+ unit_test_sms_root_LDADD = @GLIB_LIBS@ $(ell_ldadd)
+ unit_objects += $(unit_test_sms_root_OBJECTS)
+ 
++unit_test_call_list_SOURCES = \
++				     src/common.c src/util.c src/log.c \
++				     src/call-list.c unit/test-call-list.c
++unit_test_call_list_LDADD = @GLIB_LIBS@ -ldl
++unit_objects += $(unit_test_call_list_OBJECTS)
++
+ unit_test_mux_SOURCES = unit/test-mux.c $(gatchat_sources)
+ unit_test_mux_LDADD = @GLIB_LIBS@
+ unit_objects += $(unit_test_mux_OBJECTS)
+diff -up ofono-1.31/src/call-list.c.1~ ofono-1.31/src/call-list.c
+--- ofono-1.31/src/call-list.c.1~	2020-09-14 18:59:47.205557339 +0200
++++ ofono-1.31/src/call-list.c	2020-09-14 18:59:47.205557339 +0200
+@@ -0,0 +1,114 @@
++/*
++ *
++ *  oFono - Open Source Telephony
++ *
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ *
++ *  This program is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ */
++
++#include <glib.h>
++
++#include "common.h"
++
++#include <ofono/types.h>
++#include <ofono/log.h>
++#include <ofono/voicecall.h>
++#include <ofono/call-list.h>
++
++#include <string.h>
++
++void ofono_call_list_dial_callback(struct ofono_voicecall *vc,
++				   GSList **call_list,
++				   const struct ofono_phone_number *ph,
++				   int call_id)
++{
++	GSList *list;
++	struct ofono_call *call;
++
++	/* list_notify could be triggered before this call back is handled */
++	list = g_slist_find_custom(*call_list,
++				   GINT_TO_POINTER(call_id),
++				   ofono_call_compare_by_id);
++
++	if (list && list->data) {
++		call = list->data;
++		DBG("Call id %d already known. In state %s(%d)",
++		    call_id, call_status_to_string(call->status),
++		    call->status);
++		return;
++	}
++
++	call = g_new0(struct ofono_call, 1);
++	call->id = call_id;
++
++	memcpy(&call->called_number, ph, sizeof(*ph));
++	call->direction = CALL_DIRECTION_MOBILE_ORIGINATED;
++	call->status = CALL_STATUS_DIALING;
++	call->type = 0; /* voice */
++
++	*call_list = g_slist_insert_sorted(*call_list,
++					    call,
++					    ofono_call_compare);
++	ofono_voicecall_notify(vc, call);
++}
++
++void ofono_call_list_notify(struct ofono_voicecall *vc,
++			    GSList **call_list,
++			    GSList *calls)
++{
++	GSList *old_calls = *call_list;
++	GSList *new_calls = calls;
++	struct ofono_call *new_call, *old_call;
++
++	while (old_calls || new_calls) {
++		old_call = old_calls ? old_calls->data : NULL;
++		new_call = new_calls ? new_calls->data : NULL;
++
++		/* we drop disconnected calls and treat them as not existent */
++		if (new_call && new_call->status == CALL_STATUS_DISCONNECTED) {
++			new_calls = new_calls->next;
++			calls = g_slist_remove(calls, new_call);
++			g_free(new_call);
++			continue;
++		}
++
++		if (old_call &&
++				(new_call == NULL ||
++				(new_call->id > old_call->id))) {
++			ofono_voicecall_disconnected(
++						vc,
++						old_call->id,
++						OFONO_DISCONNECT_REASON_UNKNOWN,
++						NULL);
++			old_calls = old_calls->next;
++		} else if (new_call &&
++			   (old_call == NULL ||
++			   (new_call->id < old_call->id))) {
++
++			/* new call, signal it */
++			if (new_call->type == 0)
++				ofono_voicecall_notify(vc, new_call);
++
++			new_calls = new_calls->next;
++		} else {
++			if (memcmp(new_call, old_call, sizeof(*new_call))
++					&& new_call->type == 0)
++				ofono_voicecall_notify(vc, new_call);
++
++			new_calls = new_calls->next;
++			old_calls = old_calls->next;
++		}
++	}
++
++	g_slist_free_full(*call_list, g_free);
++	*call_list = calls;
++}
+diff -up ofono-1.31/unit/test-call-list.c.1~ ofono-1.31/unit/test-call-list.c
+--- ofono-1.31/unit/test-call-list.c.1~	2020-09-14 18:59:47.205557339 +0200
++++ ofono-1.31/unit/test-call-list.c	2020-09-14 18:59:47.205557339 +0200
+@@ -0,0 +1,237 @@
++/*
++ *
++ *  oFono - Open Source Telephony
++ *
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ *
++ *  This program is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ */
++
++
++#include <glib.h>
++#include <string.h>
++
++
++#include "../src/common.h"
++#include <ofono/types.h>
++#include <ofono/call-list.h>
++
++struct voicecall {
++};
++
++struct notified {
++	unsigned int id;
++	enum call_status status;
++};
++
++static struct notified notified_list[32];
++static int notified_idx;
++static int notified_check;
++
++void reset_notified(void)
++{
++	notified_idx = 0;
++	notified_check = 0;
++	memset(&notified_list, 0, sizeof(notified_list));
++}
++
++void ofono_voicecall_notify(struct ofono_voicecall *vc,
++				struct ofono_call *call)
++{
++	notified_list[notified_idx].id = call->id;
++	notified_list[notified_idx].status = call->status;
++	notified_idx++;
++}
++
++void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id,
++				enum ofono_disconnect_reason reason,
++				const struct ofono_error *error)
++{
++	notified_list[notified_idx].id = id;
++	notified_list[notified_idx].status = CALL_STATUS_DISCONNECTED;
++	notified_idx++;
++}
++
++static GSList *create_call(
++		GSList *calls,
++		unsigned int id,
++		enum call_status status,
++		enum call_direction direction)
++{
++	struct ofono_call *call = g_new0(struct ofono_call, 1);
++
++	call->id = id;
++	call->status = status;
++	call->direction = direction;
++
++	calls = g_slist_insert_sorted(calls, call, ofono_call_compare);
++
++	return calls;
++}
++
++static void assert_notified(unsigned int call_id, int call_status)
++{
++	g_assert(notified_idx >= notified_check);
++	g_assert(notified_list[notified_check].id == call_id);
++	g_assert(notified_list[notified_check].status == call_status);
++
++	notified_check++;
++}
++
++static void test_notify_disconnected(void)
++{
++	struct ofono_voicecall *vc = NULL;
++	struct ofono_phone_number ph;
++	GSList *call_list;
++	GSList *calls;
++
++	strcpy(ph.number, "004888123456");
++	ph.type = 0;
++
++	/* reset test */
++	reset_notified();
++	call_list = NULL;
++
++	/* fill disconnected call*/
++	calls = create_call(NULL, 1, CALL_STATUS_DISCONNECTED,
++			    CALL_DIRECTION_MOBILE_TERMINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++
++	/* incoming call */
++	calls = create_call(NULL, 1, CALL_STATUS_DISCONNECTED,
++			    CALL_DIRECTION_MOBILE_TERMINATED);
++	calls = create_call(calls, 1, CALL_STATUS_ALERTING,
++			   CALL_DIRECTION_MOBILE_TERMINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++
++	/* answer call */
++	calls = create_call(NULL, 1, CALL_STATUS_ACTIVE,
++			   CALL_DIRECTION_MOBILE_TERMINATED);
++	calls = create_call(calls, 1, CALL_STATUS_DISCONNECTED,
++			    CALL_DIRECTION_MOBILE_TERMINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++
++	/* another call waiting */
++	calls = create_call(NULL, 1, CALL_STATUS_DISCONNECTED,
++			    CALL_DIRECTION_MOBILE_TERMINATED);
++	calls = create_call(calls, 1, CALL_STATUS_ACTIVE,
++			   CALL_DIRECTION_MOBILE_TERMINATED);
++	calls = create_call(calls, 2, CALL_STATUS_DISCONNECTED,
++			    CALL_DIRECTION_MOBILE_TERMINATED);
++	calls = create_call(calls, 2, CALL_STATUS_WAITING,
++				   CALL_DIRECTION_MOBILE_TERMINATED);
++	calls = create_call(calls, 2, CALL_STATUS_DISCONNECTED,
++			    CALL_DIRECTION_MOBILE_TERMINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++
++	/* end all calls */
++	ofono_call_list_notify(vc, &call_list, NULL);
++
++	/* verify call history */
++	assert_notified(1, CALL_STATUS_ALERTING);
++	assert_notified(1, CALL_STATUS_ACTIVE);
++	assert_notified(2, CALL_STATUS_WAITING);
++	assert_notified(1, CALL_STATUS_DISCONNECTED);
++	assert_notified(2, CALL_STATUS_DISCONNECTED);
++
++	g_assert(notified_check == notified_idx);
++	g_slist_free_full(call_list, g_free);
++}
++
++static void test_notify(void)
++{
++	struct ofono_voicecall *vc = NULL;
++	struct ofono_phone_number ph;
++	GSList *call_list;
++	GSList *calls;
++
++	strcpy(ph.number, "004888123456");
++	ph.type = 0;
++
++	/* reset test */
++	reset_notified();
++	call_list = NULL;
++
++	/* incoming call */
++	calls = create_call(NULL, 1, CALL_STATUS_ALERTING,
++			   CALL_DIRECTION_MOBILE_TERMINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++
++	/* answer call */
++	calls = create_call(NULL, 1, CALL_STATUS_ACTIVE,
++			   CALL_DIRECTION_MOBILE_TERMINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++
++	/* another call waiting */
++	calls = create_call(NULL, 1, CALL_STATUS_ACTIVE,
++			   CALL_DIRECTION_MOBILE_TERMINATED);
++	calls = create_call(calls, 2, CALL_STATUS_WAITING,
++				   CALL_DIRECTION_MOBILE_TERMINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++
++	/* end all calls */
++	ofono_call_list_notify(vc, &call_list, NULL);
++
++	/* verify call history */
++	assert_notified(1, CALL_STATUS_ALERTING);
++	assert_notified(1, CALL_STATUS_ACTIVE);
++	assert_notified(2, CALL_STATUS_WAITING);
++	assert_notified(1, CALL_STATUS_DISCONNECTED);
++	assert_notified(2, CALL_STATUS_DISCONNECTED);
++
++	g_assert(notified_check == notified_idx);
++	g_slist_free_full(call_list, g_free);
++}
++
++static void test_dial_callback(void)
++{
++	struct ofono_voicecall *vc = NULL;
++	struct ofono_phone_number ph;
++	struct ofono_call *call;
++	GSList *call_list, *calls;
++
++	/* reset test */
++	reset_notified();
++	call_list = NULL;
++
++	strcpy(ph.number, "0099301234567890");
++	ph.type = 0;
++
++	/* check if a call gets added to the call_list */
++	ofono_call_list_dial_callback(vc, &call_list, &ph, 33);
++
++	call = call_list->data;
++	g_assert(strcmp(call->called_number.number, ph.number) == 0);
++	g_slist_free_full(call_list, g_free);
++
++	/* check when notify is faster than dial_callback */
++	call_list = NULL;
++	calls = create_call(NULL, 1, CALL_STATUS_DIALING,
++			   CALL_DIRECTION_MOBILE_ORIGINATED);
++	ofono_call_list_notify(vc, &call_list, calls);
++	ofono_call_list_dial_callback(vc, &call_list, &ph, 1);
++	call = call_list->data;
++	g_assert(call_list->next == NULL);
++	g_slist_free_full(call_list, g_free);
++
++	call_list = NULL;
++}
++
++int main(int argc, char **argv)
++{
++	g_test_init(&argc, &argv, NULL);
++
++	g_test_add_func("/test-call-list/test_notify", test_notify);
++	g_test_add_func("/test-call-list/test_notify_disconnected",
++			test_notify_disconnected);
++	g_test_add_func("/test-call-list/dial_callback", test_dial_callback);
++	return g_test_run();
++}
diff --git a/0003-call-compare-by-status.patch b/0003-call-compare-by-status.patch
new file mode 100644
index 0000000..7d1cb76
--- /dev/null
+++ b/0003-call-compare-by-status.patch
@@ -0,0 +1,289 @@
+diff -up ofono-1.31/drivers/atmodem/atutil.c.2~ ofono-1.31/drivers/atmodem/atutil.c
+--- ofono-1.31/drivers/atmodem/atutil.c.2~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/drivers/atmodem/atutil.c	2020-09-14 19:05:07.244807012 +0200
+@@ -71,17 +71,6 @@ void decode_at_error(struct ofono_error
+ 	}
+ }
+ 
+-gint at_util_call_compare_by_status(gconstpointer a, gconstpointer b)
+-{
+-	const struct ofono_call *call = a;
+-	int status = GPOINTER_TO_INT(b);
+-
+-	if (status != call->status)
+-		return 1;
+-
+-	return 0;
+-}
+-
+ gint at_util_call_compare_by_phone_number(gconstpointer a, gconstpointer b)
+ {
+ 	const struct ofono_call *call = a;
+diff -up ofono-1.31/drivers/atmodem/atutil.h.2~ ofono-1.31/drivers/atmodem/atutil.h
+--- ofono-1.31/drivers/atmodem/atutil.h.2~	2020-09-14 19:05:07.244807012 +0200
++++ ofono-1.31/drivers/atmodem/atutil.h	2020-09-14 19:06:07.832350857 +0200
+@@ -56,7 +56,7 @@ enum at_util_charset {
+ typedef void (*at_util_sim_inserted_cb_t)(gboolean present, void *userdata);
+ 
+ void decode_at_error(struct ofono_error *error, const char *final);
+-gint at_util_call_compare_by_status(gconstpointer a, gconstpointer b);
++gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b);
+ gint at_util_call_compare_by_phone_number(gconstpointer a, gconstpointer b);
+ gint at_util_call_compare_by_id(gconstpointer a, gconstpointer b);
+ gint at_util_call_compare(gconstpointer a, gconstpointer b);
+diff -up ofono-1.31/drivers/atmodem/voicecall.c.2~ ofono-1.31/drivers/atmodem/voicecall.c
+--- ofono-1.31/drivers/atmodem/voicecall.c.2~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/drivers/atmodem/voicecall.c	2020-09-14 19:05:07.244807012 +0200
+@@ -660,13 +660,13 @@ static void ring_notify(GAtResult *resul
+ 	/* See comment in CRING */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_WAITING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	/* RING can repeat, ignore if we already have an incoming call */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	/* Generate an incoming call of unknown type */
+@@ -698,13 +698,13 @@ static void cring_notify(GAtResult *resu
+ 	 */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_WAITING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	/* CRING can repeat, ignore if we already have an incoming call */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	g_at_result_iter_init(&iter, result);
+@@ -748,7 +748,7 @@ static void clip_notify(GAtResult *resul
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CLIP for unknown call");
+ 		return;
+@@ -810,7 +810,7 @@ static void cdip_notify(GAtResult *resul
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CDIP for unknown call");
+ 		return;
+@@ -859,7 +859,7 @@ static void cnap_notify(GAtResult *resul
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CNAP for unknown call");
+ 		return;
+@@ -913,7 +913,7 @@ static void ccwa_notify(GAtResult *resul
+ 	/* Some modems resend CCWA, ignore it the second time around */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_WAITING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	g_at_result_iter_init(&iter, result);
+diff -up ofono-1.31/drivers/hfpmodem/voicecall.c.2~ ofono-1.31/drivers/hfpmodem/voicecall.c
+--- ofono-1.31/drivers/hfpmodem/voicecall.c.2~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/drivers/hfpmodem/voicecall.c	2020-09-14 19:05:07.244807012 +0200
+@@ -84,12 +84,12 @@ static GSList *find_dialing(GSList *call
+ 	GSList *c;
+ 
+ 	c = g_slist_find_custom(calls, GINT_TO_POINTER(CALL_STATUS_DIALING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 
+ 	if (c == NULL)
+ 		c = g_slist_find_custom(calls,
+ 					GINT_TO_POINTER(CALL_STATUS_ALERTING),
+-					at_util_call_compare_by_status);
++					ofono_call_compare_by_status);
+ 
+ 	return c;
+ }
+@@ -759,7 +759,7 @@ static void ccwa_notify(GAtResult *resul
+ 	/* CCWA can repeat, ignore if we already have an waiting call */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_WAITING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	/* some phones may send extra CCWA after active call is ended
+@@ -768,7 +768,7 @@ static void ccwa_notify(GAtResult *resul
+ 	 */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 
+@@ -811,7 +811,7 @@ static gboolean clip_timeout(gpointer us
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 
+ 	if (l == NULL)
+ 		return FALSE;
+@@ -840,12 +840,12 @@ static void ring_notify(GAtResult *resul
+ 	/* RING can repeat, ignore if we already have an incoming call */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	waiting = g_slist_find_custom(vd->calls,
+ 					GINT_TO_POINTER(CALL_STATUS_WAITING),
+-					at_util_call_compare_by_status);
++					ofono_call_compare_by_status);
+ 
+ 	/* If we started receiving RINGS but have a waiting call, most
+ 	 * likely all other calls were dropped and we just didn't get
+@@ -890,7 +890,7 @@ static void clip_notify(GAtResult *resul
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 
+ 	if (l == NULL) {
+ 		ofono_error("CLIP for unknown call");
+@@ -1006,7 +1006,7 @@ static void ciev_callsetup_notify(struct
+ 
+ 	waiting = g_slist_find_custom(vd->calls,
+ 					GINT_TO_POINTER(CALL_STATUS_WAITING),
+-					at_util_call_compare_by_status);
++					ofono_call_compare_by_status);
+ 
+ 	/* This is a truly bizarre case not covered at all by the specification
+ 	 * (yes, they are complete idiots).  Here we assume the other side is
+@@ -1085,7 +1085,7 @@ static void ciev_callsetup_notify(struct
+ 	{
+ 		GSList *o = g_slist_find_custom(vd->calls,
+ 					GINT_TO_POINTER(CALL_STATUS_DIALING),
+-					at_util_call_compare_by_status);
++					ofono_call_compare_by_status);
+ 
+ 		if (o) {
+ 			struct ofono_call *call = o->data;
+diff -up ofono-1.31/drivers/huaweimodem/voicecall.c.2~ ofono-1.31/drivers/huaweimodem/voicecall.c
+--- ofono-1.31/drivers/huaweimodem/voicecall.c.2~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/drivers/huaweimodem/voicecall.c	2020-09-14 19:05:07.244807012 +0200
+@@ -178,7 +178,7 @@ static void cring_notify(GAtResult *resu
+ 	/* CRING can repeat, ignore if we already have an incoming call */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	g_at_result_iter_init(&iter, result);
+@@ -217,7 +217,7 @@ static void clip_notify(GAtResult *resul
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CLIP for unknown call");
+ 		return;
+diff -up ofono-1.31/drivers/ifxmodem/voicecall.c.2~ ofono-1.31/drivers/ifxmodem/voicecall.c
+--- ofono-1.31/drivers/ifxmodem/voicecall.c.2~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/drivers/ifxmodem/voicecall.c	2020-09-14 19:05:07.244807012 +0200
+@@ -544,12 +544,12 @@ static void cring_notify(GAtResult *resu
+ 	 */
+ 	if (g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_WAITING),
+-				at_util_call_compare_by_status))
++				ofono_call_compare_by_status))
+ 		return;
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CRING received before XCALLSTAT!!!");
+ 		return;
+@@ -588,7 +588,7 @@ static void clip_notify(GAtResult *resul
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CLIP for unknown call");
+ 		return;
+@@ -648,7 +648,7 @@ static void cnap_notify(GAtResult *resul
+ 	 */
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_INCOMING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CNAP for unknown call");
+ 		return;
+@@ -694,7 +694,7 @@ static void ccwa_notify(GAtResult *resul
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(CALL_STATUS_WAITING),
+-				at_util_call_compare_by_status);
++				ofono_call_compare_by_status);
+ 	if (l == NULL) {
+ 		ofono_error("CCWA received before XCALLSTAT!!!");
+ 		return;
+diff -up ofono-1.31/src/common.c.2~ ofono-1.31/src/common.c
+--- ofono-1.31/src/common.c.2~	2020-09-14 19:05:07.244807012 +0200
++++ ofono-1.31/src/common.c	2020-09-14 19:06:45.993684638 +0200
+@@ -752,6 +752,17 @@ void ofono_call_init(struct ofono_call *
+ 	call->clip_validity = CLIP_VALIDITY_NOT_AVAILABLE;
+ }
+ 
++gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b)
++{
++	const struct ofono_call *call = a;
++	int status = GPOINTER_TO_INT(b);
++
++	if (status != call->status)
++		return 1;
++
++	return 0;
++}
++
+ const char *call_status_to_string(enum call_status status)
+ {
+ 	switch (status) {
+diff -up ofono-1.31/src/common.h.2~ ofono-1.31/src/common.h
+--- ofono-1.31/src/common.h.2~	2020-09-14 19:05:07.244807012 +0200
++++ ofono-1.31/src/common.h	2020-09-14 19:07:25.828026453 +0200
+@@ -188,6 +188,7 @@ const char *registration_tech_to_string(
+ const char *packet_bearer_to_string(int bearer);
+ 
+ gboolean is_valid_apn(const char *apn);
++gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b);
+ const char *call_status_to_string(enum call_status status);
+ 
+ const char *gprs_proto_to_string(enum ofono_gprs_proto proto);
diff --git a/0004-call-compare-by-id.patch b/0004-call-compare-by-id.patch
new file mode 100644
index 0000000..241a3af
--- /dev/null
+++ b/0004-call-compare-by-id.patch
@@ -0,0 +1,134 @@
+diff -up ofono-1.31/drivers/atmodem/atutil.c.3~ ofono-1.31/drivers/atmodem/atutil.c
+--- ofono-1.31/drivers/atmodem/atutil.c.3~	2020-09-14 19:07:46.244199192 +0200
++++ ofono-1.31/drivers/atmodem/atutil.c	2020-09-14 19:08:51.917744476 +0200
+@@ -80,20 +80,6 @@ gint at_util_call_compare_by_phone_numbe
+ 				sizeof(struct ofono_phone_number));
+ }
+ 
+-gint at_util_call_compare_by_id(gconstpointer a, gconstpointer b)
+-{
+-	const struct ofono_call *call = a;
+-	unsigned int id = GPOINTER_TO_UINT(b);
+-
+-	if (id < call->id)
+-		return -1;
+-
+-	if (id > call->id)
+-		return 1;
+-
+-	return 0;
+-}
+-
+ gint at_util_call_compare(gconstpointer a, gconstpointer b)
+ {
+ 	const struct ofono_call *ca = a;
+diff -up ofono-1.31/drivers/atmodem/atutil.h.3~ ofono-1.31/drivers/atmodem/atutil.h
+--- ofono-1.31/drivers/atmodem/atutil.h.3~	2020-09-14 19:07:46.244199192 +0200
++++ ofono-1.31/drivers/atmodem/atutil.h	2020-09-14 19:09:17.480952745 +0200
+@@ -58,7 +58,7 @@ typedef void (*at_util_sim_inserted_cb_t
+ void decode_at_error(struct ofono_error *error, const char *final);
+ gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b);
+ gint at_util_call_compare_by_phone_number(gconstpointer a, gconstpointer b);
+-gint at_util_call_compare_by_id(gconstpointer a, gconstpointer b);
++gint ofono_call_compare_by_id(gconstpointer a, gconstpointer b);
+ gint at_util_call_compare(gconstpointer a, gconstpointer b);
+ GSList *at_util_parse_clcc(GAtResult *result, unsigned int *mpty_ids);
+ gboolean at_util_parse_reg(GAtResult *result, const char *prefix,
+diff -up ofono-1.31/drivers/huaweimodem/voicecall.c.3~ ofono-1.31/drivers/huaweimodem/voicecall.c
+--- ofono-1.31/drivers/huaweimodem/voicecall.c.3~	2020-09-14 19:07:46.243199184 +0200
++++ ofono-1.31/drivers/huaweimodem/voicecall.c	2020-09-14 19:07:46.244199192 +0200
+@@ -346,7 +346,7 @@ static void conf_notify(GAtResult *resul
+ 	ofono_info("Call setup: id %d", call_id);
+ 
+ 	l = g_slist_find_custom(vd->calls, GINT_TO_POINTER(call_id),
+-				at_util_call_compare_by_id);
++				ofono_call_compare_by_id);
+ 	if (l == NULL) {
+ 		ofono_error("Received CONF for untracked call");
+ 		return;
+@@ -383,7 +383,7 @@ static void conn_notify(GAtResult *resul
+ 	ofono_info("Call connect: id %d type %d", call_id, call_type);
+ 
+ 	l = g_slist_find_custom(vd->calls, GINT_TO_POINTER(call_id),
+-				at_util_call_compare_by_id);
++				ofono_call_compare_by_id);
+ 	if (l == NULL) {
+ 		ofono_error("Received CONN for untracked call");
+ 		return;
+@@ -427,7 +427,7 @@ static void cend_notify(GAtResult *resul
+ 				call_id, duration, end_status);
+ 
+ 	l = g_slist_find_custom(vd->calls, GINT_TO_POINTER(call_id),
+-				at_util_call_compare_by_id);
++				ofono_call_compare_by_id);
+ 	if (l == NULL) {
+ 		ofono_error("Received CEND for untracked call");
+ 		return;
+diff -up ofono-1.31/drivers/ifxmodem/voicecall.c.3~ ofono-1.31/drivers/ifxmodem/voicecall.c
+--- ofono-1.31/drivers/ifxmodem/voicecall.c.3~	2020-09-14 19:07:46.243199184 +0200
++++ ofono-1.31/drivers/ifxmodem/voicecall.c	2020-09-14 19:07:46.244199192 +0200
+@@ -134,7 +134,7 @@ static void xcallstat_notify(GAtResult *
+ 		return;
+ 
+ 	l = g_slist_find_custom(vd->calls, GINT_TO_POINTER(id),
+-				at_util_call_compare_by_id);
++				ofono_call_compare_by_id);
+ 
+ 	if (l == NULL && status != CALL_STATUS_DIALING &&
+ 				status != CALL_STATUS_INCOMING &&
+@@ -772,7 +772,7 @@ static void xcolp_notify(GAtResult *resu
+ 
+ 	l = g_slist_find_custom(vd->calls,
+ 				GINT_TO_POINTER(call_id),
+-				at_util_call_compare_by_id);
++				ofono_call_compare_by_id);
+ 	if (l == NULL) {
+ 		ofono_error("XCOLP for unknown call");
+ 		return;
+diff -up ofono-1.31/drivers/stemodem/voicecall.c.3~ ofono-1.31/drivers/stemodem/voicecall.c
+--- ofono-1.31/drivers/stemodem/voicecall.c.3~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/drivers/stemodem/voicecall.c	2020-09-14 19:07:46.244199192 +0200
+@@ -461,7 +461,7 @@ static void ecav_notify(GAtResult *resul
+ 	 * If it doesn't exists we make a new one
+ 	 */
+ 	l = g_slist_find_custom(vd->calls, GUINT_TO_POINTER(id),
+-				at_util_call_compare_by_id);
++				ofono_call_compare_by_id);
+ 
+ 	if (l)
+ 		existing_call = l->data;
+diff -up ofono-1.31/src/common.c.3~ ofono-1.31/src/common.c
+--- ofono-1.31/src/common.c.3~	2020-09-14 19:07:46.244199192 +0200
++++ ofono-1.31/src/common.c	2020-09-14 19:10:00.768300760 +0200
+@@ -763,6 +763,20 @@ gint ofono_call_compare_by_status(gconst
+ 	return 0;
+ }
+ 
++gint ofono_call_compare_by_id(gconstpointer a, gconstpointer b)
++{
++	const struct ofono_call *call = a;
++	unsigned int id = GPOINTER_TO_UINT(b);
++
++	if (id < call->id)
++		return -1;
++
++	if (id > call->id)
++		return 1;
++
++	return 0;
++}
++
+ const char *call_status_to_string(enum call_status status)
+ {
+ 	switch (status) {
+diff -up ofono-1.31/src/common.h.3~ ofono-1.31/src/common.h
+--- ofono-1.31/src/common.h.3~	2020-09-14 19:07:46.244199192 +0200
++++ ofono-1.31/src/common.h	2020-09-14 19:10:31.777546690 +0200
+@@ -189,6 +189,7 @@ const char *packet_bearer_to_string(int
+ 
+ gboolean is_valid_apn(const char *apn);
+ gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b);
++gint ofono_call_compare_by_id(gconstpointer a, gconstpointer b);
+ const char *call_status_to_string(enum call_status status);
+ 
+ const char *gprs_proto_to_string(enum ofono_gprs_proto proto);
diff --git a/0006-create-glist-helper-ofono_call_compare.patch b/0006-create-glist-helper-ofono_call_compare.patch
new file mode 100644
index 0000000..2ddce80
--- /dev/null
+++ b/0006-create-glist-helper-ofono_call_compare.patch
@@ -0,0 +1,192 @@
+diff -up ofono-1.31/drivers/atmodem/atutil.c.4~ ofono-1.31/drivers/atmodem/atutil.c
+--- ofono-1.31/drivers/atmodem/atutil.c.4~	2020-09-14 19:11:51.196164922 +0200
++++ ofono-1.31/drivers/atmodem/atutil.c	2020-09-14 19:12:46.849589207 +0200
+@@ -35,6 +35,7 @@
+ #include <ofono/log.h>
+ #include <ofono/types.h>
+ #include <ofono/modem.h>
++#include "../src/common.h"
+ 
+ #include "atutil.h"
+ #include "vendor.h"
+@@ -80,20 +81,6 @@ gint at_util_call_compare_by_phone_numbe
+ 				sizeof(struct ofono_phone_number));
+ }
+ 
+-gint at_util_call_compare(gconstpointer a, gconstpointer b)
+-{
+-	const struct ofono_call *ca = a;
+-	const struct ofono_call *cb = b;
+-
+-	if (ca->id < cb->id)
+-		return -1;
+-
+-	if (ca->id > cb->id)
+-		return 1;
+-
+-	return 0;
+-}
+-
+ GSList *at_util_parse_clcc(GAtResult *result, unsigned int *ret_mpty_ids)
+ {
+ 	GAtResultIter iter;
+@@ -152,7 +139,7 @@ GSList *at_util_parse_clcc(GAtResult *re
+ 		else
+ 			call->clip_validity = 2;
+ 
+-		l = g_slist_insert_sorted(l, call, at_util_call_compare);
++		l = g_slist_insert_sorted(l, call, ofono_call_compare);
+ 
+ 		if (mpty)
+ 			mpty_ids |= 1 << id;
+diff -up ofono-1.31/drivers/atmodem/atutil.h.4~ ofono-1.31/drivers/atmodem/atutil.h
+--- ofono-1.31/drivers/atmodem/atutil.h.4~	2020-09-14 19:11:51.197164929 +0200
++++ ofono-1.31/drivers/atmodem/atutil.h	2020-09-14 19:13:04.579722976 +0200
+@@ -59,7 +59,6 @@ void decode_at_error(struct ofono_error
+ gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b);
+ gint at_util_call_compare_by_phone_number(gconstpointer a, gconstpointer b);
+ gint ofono_call_compare_by_id(gconstpointer a, gconstpointer b);
+-gint at_util_call_compare(gconstpointer a, gconstpointer b);
+ GSList *at_util_parse_clcc(GAtResult *result, unsigned int *mpty_ids);
+ gboolean at_util_parse_reg(GAtResult *result, const char *prefix,
+ 				int *mode, int *status,
+diff -up ofono-1.31/drivers/atmodem/voicecall.c.4~ ofono-1.31/drivers/atmodem/voicecall.c
+--- ofono-1.31/drivers/atmodem/voicecall.c.4~	2020-09-14 19:11:51.195164914 +0200
++++ ofono-1.31/drivers/atmodem/voicecall.c	2020-09-14 19:11:51.197164929 +0200
+@@ -131,7 +131,7 @@ static struct ofono_call *create_call(st
+ 	call->clip_validity = clip;
+ 	call->cnap_validity = CNAP_VALIDITY_NOT_AVAILABLE;
+ 
+-	d->calls = g_slist_insert_sorted(d->calls, call, at_util_call_compare);
++	d->calls = g_slist_insert_sorted(d->calls, call, ofono_call_compare);
+ 
+ 	return call;
+ }
+diff -up ofono-1.31/drivers/hfpmodem/voicecall.c.4~ ofono-1.31/drivers/hfpmodem/voicecall.c
+--- ofono-1.31/drivers/hfpmodem/voicecall.c.4~	2020-09-14 19:11:51.195164914 +0200
++++ ofono-1.31/drivers/hfpmodem/voicecall.c	2020-09-14 19:11:51.197164929 +0200
+@@ -128,7 +128,7 @@ static struct ofono_call *create_call(st
+ 		call->phone_number.type = num_type;
+ 	}
+ 
+-	d->calls = g_slist_insert_sorted(d->calls, call, at_util_call_compare);
++	d->calls = g_slist_insert_sorted(d->calls, call, ofono_call_compare);
+ 
+ 	call->clip_validity = clip;
+ 
+diff -up ofono-1.31/drivers/huaweimodem/voicecall.c.4~ ofono-1.31/drivers/huaweimodem/voicecall.c
+--- ofono-1.31/drivers/huaweimodem/voicecall.c.4~	2020-09-14 19:11:51.196164922 +0200
++++ ofono-1.31/drivers/huaweimodem/voicecall.c	2020-09-14 19:11:51.197164929 +0200
+@@ -75,7 +75,7 @@ static struct ofono_call *create_call(st
+ 
+ 	call->clip_validity = clip;
+ 
+-	d->calls = g_slist_insert_sorted(d->calls, call, at_util_call_compare);
++	d->calls = g_slist_insert_sorted(d->calls, call, ofono_call_compare);
+ 
+ 	return call;
+ }
+diff -up ofono-1.31/drivers/ifxmodem/voicecall.c.4~ ofono-1.31/drivers/ifxmodem/voicecall.c
+--- ofono-1.31/drivers/ifxmodem/voicecall.c.4~	2020-09-14 19:11:51.196164922 +0200
++++ ofono-1.31/drivers/ifxmodem/voicecall.c	2020-09-14 19:11:51.198164937 +0200
+@@ -106,7 +106,7 @@ static struct ofono_call *create_call(st
+ 
+ 	call->clip_validity = clip;
+ 
+-	d->calls = g_slist_insert_sorted(d->calls, call, at_util_call_compare);
++	d->calls = g_slist_insert_sorted(d->calls, call, ofono_call_compare);
+ 
+ 	return call;
+ }
+diff -up ofono-1.31/drivers/rilmodem/voicecall.c.4~ ofono-1.31/drivers/rilmodem/voicecall.c
+--- ofono-1.31/drivers/rilmodem/voicecall.c.4~	2019-10-31 08:58:24.000000000 +0100
++++ ofono-1.31/drivers/rilmodem/voicecall.c	2020-09-14 19:11:51.198164937 +0200
+@@ -116,20 +116,6 @@ done:
+ 	ofono_voicecall_disconnected(vc, reqdata->id, reason, NULL);
+ }
+ 
+-static int call_compare(gconstpointer a, gconstpointer b)
+-{
+-	const struct ofono_call *ca = a;
+-	const struct ofono_call *cb = b;
+-
+-	if (ca->id < cb->id)
+-		return -1;
+-
+-	if (ca->id > cb->id)
+-		return 1;
+-
+-	return 0;
+-}
+-
+ static void clcc_poll_cb(struct ril_msg *message, gpointer user_data)
+ {
+ 	struct ofono_voicecall *vc = user_data;
+@@ -208,7 +194,7 @@ static void clcc_poll_cb(struct ril_msg
+ 			call->id, call->status, call->type,
+ 			call->phone_number.number, call->name);
+ 
+-		calls = g_slist_insert_sorted(calls, call, call_compare);
++		calls = g_slist_insert_sorted(calls, call, ofono_call_compare);
+ 	}
+ 
+ no_calls:
+diff -up ofono-1.31/drivers/stemodem/voicecall.c.4~ ofono-1.31/drivers/stemodem/voicecall.c
+--- ofono-1.31/drivers/stemodem/voicecall.c.4~	2020-09-14 19:11:51.196164922 +0200
++++ ofono-1.31/drivers/stemodem/voicecall.c	2020-09-14 19:11:51.198164937 +0200
+@@ -127,7 +127,7 @@ static struct ofono_call *create_call(st
+ 
+ 	call->clip_validity = clip;
+ 
+-	d->calls = g_slist_insert_sorted(d->calls, call, at_util_call_compare);
++	d->calls = g_slist_insert_sorted(d->calls, call, ofono_call_compare);
+ 
+ 	return call;
+ }
+diff -up ofono-1.31/src/common.c.4~ ofono-1.31/src/common.c
+--- ofono-1.31/src/common.c.4~	2020-09-14 19:11:51.198164937 +0200
++++ ofono-1.31/src/common.c	2020-09-14 19:13:54.885099119 +0200
+@@ -752,6 +752,20 @@ void ofono_call_init(struct ofono_call *
+ 	call->clip_validity = CLIP_VALIDITY_NOT_AVAILABLE;
+ }
+ 
++gint ofono_call_compare(gconstpointer a, gconstpointer b)
++{
++	const struct ofono_call *ca = a;
++	const struct ofono_call *cb = b;
++
++	if (ca->id < cb->id)
++		return -1;
++
++	if (ca->id > cb->id)
++		return 1;
++
++	return 0;
++}
++
+ gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b)
+ {
+ 	const struct ofono_call *call = a;
+diff -up ofono-1.31/src/common.h.4~ ofono-1.31/src/common.h
+--- ofono-1.31/src/common.h.4~	2020-09-14 19:11:51.198164937 +0200
++++ ofono-1.31/src/common.h	2020-09-14 19:14:19.614282289 +0200
+@@ -188,6 +188,7 @@ const char *registration_tech_to_string(
+ const char *packet_bearer_to_string(int bearer);
+ 
+ gboolean is_valid_apn(const char *apn);
++gint ofono_call_compare(gconstpointer a, gconstpointer b);
+ gint ofono_call_compare_by_status(gconstpointer a, gconstpointer b);
+ gint ofono_call_compare_by_id(gconstpointer a, gconstpointer b);
+ const char *call_status_to_string(enum call_status status);
+diff -up ofono-1.31/drivers/gemaltomodem/voicecall.c.omv~ ofono-1.31/drivers/gemaltomodem/voicecall.c
+--- ofono-1.31/drivers/gemaltomodem/voicecall.c.omv~	2020-09-14 19:20:34.461952814 +0200
++++ ofono-1.31/drivers/gemaltomodem/voicecall.c	2020-09-14 19:20:40.751996323 +0200
+@@ -363,7 +363,7 @@ static void gemalto_parse_slcc(GAtResult
+ 	else
+ 		call->clip_validity = 0;
+ 
+-	*l = g_slist_insert_sorted(*l, call, at_util_call_compare);
++	*l = g_slist_insert_sorted(*l, call, ofono_call_compare);
+ 
+ 	if (ret_mpty)
+ 		*ret_mpty = mpty;
diff --git a/ofono-1.31-qmimodem-voicecall.patch b/ofono-1.31-qmimodem-voicecall.patch
new file mode 100644
index 0000000..7624a99
--- /dev/null
+++ b/ofono-1.31-qmimodem-voicecall.patch
@@ -0,0 +1,876 @@
+diff -up ofono-1.31/drivers/qmimodem/qmi.h.omv~ ofono-1.31/drivers/qmimodem/qmi.h
+--- ofono-1.31/drivers/qmimodem/qmi.h.omv~	2020-09-14 18:27:53.745539595 +0200
++++ ofono-1.31/drivers/qmimodem/qmi.h	2020-09-14 18:28:57.123362334 +0200
+@@ -19,6 +19,9 @@
+  *
+  */
+ 
++#ifndef __OFONO_QMI_QMI_H
++#define __OFONO_QMI_QMI_H
++
+ #include <stdbool.h>
+ #include <stdint.h>
+ 
+@@ -174,3 +177,11 @@ uint16_t qmi_service_register(struct qmi
+ 				void *user_data, qmi_destroy_func_t destroy);
+ bool qmi_service_unregister(struct qmi_service *service, uint16_t id);
+ bool qmi_service_unregister_all(struct qmi_service *service);
++
++/* FIXME: find a place for parse_error */
++enum parse_error {
++	NONE = 0,
++	MISSING_MANDATORY = 1,
++	INVALID_LENGTH = 2,
++};
++#endif /* __OFONO_QMI_QMI_H */
+diff -up ofono-1.31/drivers/qmimodem/voicecall.c.omv~ ofono-1.31/drivers/qmimodem/voicecall.c
+--- ofono-1.31/drivers/qmimodem/voicecall.c.omv~	2020-09-14 18:46:28.542681396 +0200
++++ ofono-1.31/drivers/qmimodem/voicecall.c	2020-09-14 18:52:20.729145473 +0200
+@@ -3,6 +3,8 @@
+  *  oFono - Open Source Telephony
+  *
+  *  Copyright (C) 2011-2012  Intel Corporation. All rights reserved.
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
++ *  Copyright (C) 2020 Bernhard Rosenkraenzer <bero@lindev.ch>
+  *
+  *  This program is free software; you can redistribute it and/or modify
+  *  it under the terms of the GNU General Public License version 2 as
+@@ -23,20 +25,108 @@
+ #include <config.h>
+ #endif
+ 
++#include <string.h>
++
+ #include <ofono/log.h>
+ #include <ofono/modem.h>
+ #include <ofono/voicecall.h>
++#include <ofono/call-list.h>
++
++#include "../src/common.h"
+ 
+ #include "qmi.h"
+ 
+ #include "qmimodem.h"
++#include "voice.h"
++#include "voice_generated.h"
++
++#ifndef ARRAY_SIZE
++#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
++#endif
+ 
+ struct voicecall_data {
+ 	struct qmi_service *voice;
+ 	uint16_t major;
+ 	uint16_t minor;
++	GSList *call_list;
++	struct voicecall_static *vs;
++	struct ofono_phone_number dialed;
+ };
+ 
++static void all_call_status_ind(struct qmi_result *result, void *user_data)
++{
++	struct ofono_voicecall *vc = user_data;
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	GSList *calls = NULL;
++	int i;
++	int size = 0;
++	struct qmi_voice_all_call_status_ind status_ind;
++	GSList *n, *o;
++	struct ofono_call *nc, *oc;
++
++
++	if (qmi_voice_ind_call_status(result, &status_ind) != NONE) {
++		DBG("Parsing of all call status indication failed");
++		return;
++	}
++
++	if (!status_ind.remote_party_number_set || !status_ind.call_information_set) {
++		DBG("Some required fields are not set");
++		return;
++	}
++
++	size = status_ind.call_information->size;
++	if (!size) {
++		DBG("No call informations received!");
++		return;
++	}
++
++	/* expect we have valid fields for every call */
++	if (size != status_ind.remote_party_number_size)  {
++		DBG("Not all fields have the same size");
++		return;
++	}
++
++	for (i = 0; i < size; i++) {
++		struct qmi_voice_call_information_instance call_info;
++		struct ofono_call *call;
++		const struct qmi_voice_remote_party_number_instance *remote_party = status_ind.remote_party_number[i];
++		int number_size;
++
++		call_info = status_ind.call_information->instance[i];
++		call = g_new0(struct ofono_call, 1);
++		call->id = call_info.id;
++		call->direction = qmi_to_ofono_direction(call_info.direction);
++
++		if (qmi_to_ofono_status(call_info.state, &call->status)) {
++			DBG("Ignore call id %d, because can not convert QMI state 0x%x to ofono.",
++			    call_info.id, call_info.state);
++			continue;
++		}
++		DBG("Call %d in state %s(%d)",
++		    call_info.id,
++		    qmi_voice_call_state_name(call_info.state),
++		    call_info.state);
++
++		call->type = 0; /* always voice */
++		number_size = remote_party->number_size;
++		if (number_size > OFONO_MAX_PHONE_NUMBER_LENGTH)
++			OFONO_MAX_PHONE_NUMBER_LENGTH;
++		strncpy(call->phone_number.number, remote_party->number,
++				number_size);
++		/* FIXME: set phone_number_type */
++
++		if (strlen(call->phone_number.number) > 0)
++			call->clip_validity = 0;
++		else
++			call->clip_validity = 2;
++
++		calls = g_slist_insert_sorted(calls, call, ofono_call_compare);
++	}
++
++	ofono_call_list_notify(vc, &vd->call_list, calls);
++}
++
+ static void create_voice_cb(struct qmi_service *service, void *user_data)
+ {
+ 	struct ofono_voicecall *vc = user_data;
+@@ -58,6 +148,12 @@ static void create_voice_cb(struct qmi_s
+ 
+ 	data->voice = qmi_service_ref(service);
+ 
++	/* FIXME: we should call indication_register to ensure we get notified on call events.
++	 * We rely at the moment on the default value of notifications.
++	 */
++	qmi_service_register(data->voice, QMI_VOICE_IND_ALL_STATUS,
++			     all_call_status_ind, vc, NULL);
++
+ 	ofono_voicecall_register(vc);
+ }
+ 
+@@ -92,13 +188,241 @@ static void qmi_voicecall_remove(struct
+ 
+ 	qmi_service_unref(data->voice);
+ 
++	g_slist_free_full(data->call_list, g_free);
++
+ 	g_free(data);
+ }
+ 
++static struct ofono_call *create_call(struct ofono_voicecall *vc,
++				      enum call_direction direction,
++				      enum call_status status,
++				      const char *num,
++				      int num_type,
++				      int clip)
++{
++	return NULL;
++}
++
++static void dial_cb(struct qmi_result *result, void *user_data)
++{
++	struct cb_data *cbd = user_data;
++	struct ofono_voicecall *vc = cbd->user;
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	ofono_voicecall_cb_t cb = cbd->cb;
++	uint16_t error;
++	struct qmi_voice_dial_call_result dial_result;
++	struct ofono_call *call;
++
++	if (qmi_result_set_error(result, &error)) {
++		DBG("QMI Error %d", error);
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	if (NONE != qmi_voice_dial_call_parse(result, &dial_result)) {
++		DBG("Received invalid Result");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	if (!dial_result.call_id_set) {
++		DBG("Didn't receive a call id");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	DBG("New call QMI id %d", dial_result.call_id);
++	ofono_call_list_dial_callback(vc,
++				      &vd->call_list,
++				      &vd->dialed,
++				      dial_result.call_id);
++
++
++	/* FIXME: create a timeout on this call_id */
++	CALLBACK_WITH_SUCCESS(cb, cbd->data);
++}
++
++static void dial(struct ofono_voicecall *vc, const struct ofono_phone_number *ph,
++		enum ofono_clir_option clir, ofono_voicecall_cb_t cb,
++		void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct cb_data *cbd = cb_data_new(cb, data);
++	struct qmi_voice_dial_call_arg arg;
++
++	cbd->user = vc;
++	arg.calling_number_set = true;
++	arg.calling_number = ph->number;
++	memcpy(&vd->dialed, ph, sizeof(*ph));
++
++	arg.call_type_set = true;
++	arg.call_type = QMI_CALL_TYPE_VOICE_FORCE;
++
++	if (!qmi_voice_dial_call(
++				&arg,
++				vd->voice,
++				dial_cb,
++				cbd,
++				g_free))
++		return;
++
++	CALLBACK_WITH_FAILURE(cb, data);
++	g_free(cbd);
++}
++
++static void answer_cb(struct qmi_result *result, void *user_data)
++{
++	struct cb_data *cbd = user_data;
++	struct ofono_voicecall *vc = cbd->user;
++	ofono_voicecall_cb_t cb = cbd->cb;
++	uint16_t error;
++	struct qmi_voice_answer_call_result answer_result;
++	struct ofono_call *call;
++
++	if (qmi_result_set_error(result, &error)) {
++		DBG("QMI Error %d", error);
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	/* TODO: what happens when calling it with no active call or wrong caller id? */
++	if (NONE != qmi_voice_answer_call_parse(result, &answer_result)) {
++		DBG("Received invalid Result");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	CALLBACK_WITH_SUCCESS(cb, cbd->data);
++}
++
++static void answer(struct ofono_voicecall *vc, ofono_voicecall_cb_t cb, void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct cb_data *cbd = cb_data_new(cb, data);
++	struct qmi_voice_answer_call_arg arg;
++	struct ofono_call *call;
++	GSList *list;
++
++	DBG("");
++	cbd->user = vc;
++
++	list = g_slist_find_custom(vd->call_list,
++				   GINT_TO_POINTER(CALL_STATUS_INCOMING),
++				   ofono_call_compare_by_status);
++
++	if (list == NULL) {
++		DBG("Can not find a call to answer");
++		goto err;
++	}
++
++	call = list->data;
++
++	arg.call_id_set = true;
++	arg.call_id = call->id;
++
++	if (!qmi_voice_answer_call(
++				&arg,
++				vd->voice,
++				answer_cb,
++				cbd,
++				g_free))
++		return;
++err:
++	CALLBACK_WITH_FAILURE(cb, data);
++	g_free(cbd);
++}
++
++static void end_cb(struct qmi_result *result, void *user_data)
++{
++	struct cb_data *cbd = user_data;
++	struct ofono_voicecall *vc = cbd->user;
++	ofono_voicecall_cb_t cb = cbd->cb;
++	uint16_t error;
++	struct qmi_voice_end_call_result end_result;
++	struct ofono_call *call;
++
++	if (qmi_result_set_error(result, &error)) {
++		DBG("QMI Error %d", error);
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	if (NONE != qmi_voice_end_call_parse(result, &end_result)) {
++		DBG("Received invalid Result");
++		CALLBACK_WITH_FAILURE(cb, cbd->data);
++		return;
++	}
++
++	CALLBACK_WITH_SUCCESS(cb, cbd->data);
++}
++
++static void release_specific(struct ofono_voicecall *vc, int id,
++		ofono_voicecall_cb_t cb, void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct cb_data *cbd = cb_data_new(cb, data);
++	struct qmi_voice_end_call_arg arg;
++	int i;
++
++	DBG("");
++	cbd->user = vc;
++
++	arg.call_id_set = true;
++	arg.call_id = id;
++
++	if (!qmi_voice_end_call(&arg,
++				vd->voice,
++				end_cb,
++				cbd,
++				g_free))
++		return;
++
++	CALLBACK_WITH_FAILURE(cb, data);
++	g_free(cbd);
++}
++
++static void hangup_active(struct ofono_voicecall *vc,
++		ofono_voicecall_cb_t cb, void *data)
++{
++	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
++	struct qmi_voice_end_call_arg arg;
++	struct ofono_call *call;
++	GSList *list = NULL;
++	enum call_status active[] = {
++		CALL_STATUS_ACTIVE,
++		CALL_STATUS_DIALING,
++		CALL_STATUS_ALERTING
++	};
++	int i;
++
++	DBG("");
++	for (i = 0; i < ARRAY_SIZE(active); i++) {
++		list = g_slist_find_custom(vd->call_list,
++					   GINT_TO_POINTER(CALL_STATUS_ACTIVE),
++					   ofono_call_compare_by_status);
++
++		if (list)
++			break;
++	}
++
++	if (list == NULL) {
++		DBG("Can not find a call to hang up");
++		CALLBACK_WITH_FAILURE(cb, data);
++		return;
++	}
++
++	call = list->data;
++	release_specific(vc, call->id, cb, data);
++}
++
+ static const struct ofono_voicecall_driver driver = {
+ 	.name		= "qmimodem",
+ 	.probe		= qmi_voicecall_probe,
+ 	.remove		= qmi_voicecall_remove,
++	.dial		= dial,
++	.answer		= answer,
++	.hangup_active	= hangup_active,
++	.release_specific = release_specific,
+ };
+ 
+ void qmi_voicecall_init(void)
+diff -up ofono-1.31/drivers/qmimodem/voice.c.omv~ ofono-1.31/drivers/qmimodem/voice.c
+--- ofono-1.31/drivers/qmimodem/voice.c.omv~	2020-09-14 18:30:33.012186798 +0200
++++ ofono-1.31/drivers/qmimodem/voice.c	2020-09-14 18:31:19.641136683 +0200
+@@ -0,0 +1,85 @@
++/*
++ *
++ *  oFono - Open Source Telephony
++ *
++ *  Copyright (C) 2017 Alexander Couzens <lynxis@fe80.eu>
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ *
++ *  This program is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ */
++
++#include <stdint.h>
++
++#include "voice.h"
++#include "../../src/common.h"
++
++#define _(X) case X: return #X
++
++const char *qmi_voice_call_state_name(enum qmi_voice_call_state value)
++{
++	switch (value) {
++		_(QMI_CALL_STATE_IDLE);
++		_(QMI_CALL_STATE_ORIG);
++		_(QMI_CALL_STATE_INCOMING);
++		_(QMI_CALL_STATE_CONV);
++		_(QMI_CALL_STATE_CC_IN_PROG);
++		_(QMI_CALL_STATE_ALERTING);
++		_(QMI_CALL_STATE_HOLD);
++		_(QMI_CALL_STATE_WAITING);
++		_(QMI_CALL_STATE_DISCONNECTING);
++		_(QMI_CALL_STATE_END);
++		_(QMI_CALL_STATE_SETUP);
++	}
++	return "QMI_CALL_STATE_<UNKNOWN>";
++}
++
++int qmi_to_ofono_status(uint8_t status, int *ret) {
++	int err = 0;
++	switch (status) {
++	case QMI_CALL_STATE_IDLE:
++	case QMI_CALL_STATE_END:
++	case QMI_CALL_STATE_DISCONNECTING:
++		*ret = CALL_STATUS_DISCONNECTED;
++		break;
++	case QMI_CALL_STATE_HOLD:
++		*ret = CALL_STATUS_HELD;
++		break;
++	case QMI_CALL_STATE_WAITING:
++		*ret = CALL_STATUS_WAITING;
++		break;
++	case QMI_CALL_STATE_ORIG:
++		*ret = CALL_STATUS_DIALING;
++		break;
++	case QMI_CALL_STATE_INCOMING:
++		*ret = CALL_STATUS_INCOMING;
++		break;
++	case QMI_CALL_STATE_CONV:
++		*ret = CALL_STATUS_ACTIVE;
++		break;
++	case QMI_CALL_STATE_CC_IN_PROG:
++	case QMI_CALL_STATE_SETUP:
++		/* FIXME: unsure if _SETUP is dialing or not */
++		*ret = CALL_STATUS_DIALING;
++		break;
++	case QMI_CALL_STATE_ALERTING:
++		*ret = CALL_STATUS_ALERTING;
++		break;
++	default:
++		err = 1;
++	}
++	return err;
++}
++
++uint8_t ofono_to_qmi_direction(enum call_direction ofono_direction) {
++	return ofono_direction + 1;
++}
++enum call_direction qmi_to_ofono_direction(uint8_t qmi_direction) {
++	return qmi_direction - 1;
++}
+diff -up ofono-1.31/drivers/qmimodem/voice_generated.c.omv~ ofono-1.31/drivers/qmimodem/voice_generated.c
+--- ofono-1.31/drivers/qmimodem/voice_generated.c.omv~	2020-09-14 18:42:30.455989308 +0200
++++ ofono-1.31/drivers/qmimodem/voice_generated.c	2020-09-14 18:45:38.948528259 +0200
+@@ -0,0 +1,209 @@
++#include <stdint.h>
++#include <string.h>
++#include <glib.h>
++
++#include "voice_generated.h"
++
++int qmi_voice_dial_call(
++		struct qmi_voice_dial_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy)
++{
++	struct qmi_param *param = NULL;
++
++	param = qmi_param_new();
++	if (!param)
++		goto error;
++
++	if (arg->calling_number_set) {
++		if (!qmi_param_append(param,
++				 0x1,
++				 strlen(arg->calling_number),
++				 arg->calling_number))
++			goto error;
++	}
++
++	if (arg->call_type_set)
++		qmi_param_append_uint8(param, 0x10, arg->call_type);
++
++	if (qmi_service_send(service,
++			     0x20,
++			     param,
++			     func,
++			     user_data,
++			     destroy) > 0)
++		return 0;
++error:
++	g_free(param);
++	return 1;
++}
++
++enum parse_error qmi_voice_dial_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_dial_call_result *result)
++{
++	int err = NONE;
++
++	/* mandatory */
++	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
++		result->call_id_set = 1;
++	else
++		err = MISSING_MANDATORY;
++
++	return err;
++}
++
++int qmi_voice_end_call(
++		struct qmi_voice_end_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy)
++{
++	struct qmi_param *param = NULL;
++
++	param = qmi_param_new();
++	if (!param)
++		goto error;
++
++	if (arg->call_id_set) {
++		if (!qmi_param_append_uint8(
++					param,
++					0x1,
++					arg->call_id))
++			goto error;
++	}
++
++	if (qmi_service_send(service,
++			     0x21,
++			     param,
++			     func,
++			     user_data,
++			     destroy) > 0)
++		return 0;
++error:
++	g_free(param);
++	return 1;
++}
++
++enum parse_error qmi_voice_end_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_end_call_result *result)
++{
++	int err = NONE;
++
++	/* optional */
++	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
++		result->call_id_set = 1;
++
++	return err;
++}
++
++
++int qmi_voice_answer_call(
++		struct qmi_voice_answer_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy)
++{
++	struct qmi_param *param = NULL;
++
++	param = qmi_param_new();
++	if (!param)
++		goto error;
++
++	if (arg->call_id_set) {
++		if (!qmi_param_append_uint8(
++					param,
++					0x1,
++					arg->call_id))
++			goto error;
++	}
++
++	if (qmi_service_send(service,
++			     0x22,
++			     param,
++			     func,
++			     user_data,
++			     destroy) > 0)
++		return 0;
++error:
++	g_free(param);
++	return 1;
++}
++
++
++enum parse_error qmi_voice_answer_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_answer_call_result *result)
++{
++	int err = NONE;
++
++	/* optional */
++	if (qmi_result_get_uint8(qmi_result, 0x10, &result->call_id))
++		result->call_id_set = 1;
++
++	return err;
++}
++
++enum parse_error qmi_voice_ind_call_status(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_all_call_status_ind *result)
++{
++	int err = NONE;
++	int offset;
++	uint16_t len;
++	const struct qmi_voice_remote_party_number *remote_party_number;
++	const struct qmi_voice_call_information *call_information;
++
++	/* mandatory */
++	call_information = qmi_result_get(qmi_result, 0x01, &len);
++	if (call_information)
++	{
++		int instance_size = sizeof(struct qmi_voice_call_information_instance);
++		/* verify the length */
++		if (len < sizeof(call_information->size))
++			return INVALID_LENGTH;
++
++		if (len != call_information->size * sizeof(struct qmi_voice_call_information_instance)
++			    + sizeof(call_information->size))
++			return INVALID_LENGTH;
++		result->call_information_set = 1;
++		result->call_information = call_information;
++	} else
++		return MISSING_MANDATORY;
++
++	/* mandatory */
++	remote_party_number = qmi_result_get(qmi_result, 0x10, &len);
++	if (remote_party_number) {
++		const struct qmi_voice_remote_party_number_instance *instance;
++		int instance_size = sizeof(struct qmi_voice_remote_party_number_instance);
++		int i;
++
++		/* verify the length */
++		if (len < sizeof(remote_party_number->size))
++			return INVALID_LENGTH;
++
++		for (i = 0, offset = sizeof(remote_party_number->size);
++		     offset <= len && i < 16 && i < remote_party_number->size; i++)
++		{
++			if (offset == len) {
++				break;
++			} else if (offset + instance_size > len) {
++				return INVALID_LENGTH;
++			}
++
++			instance = (void *)remote_party_number + offset;
++			result->remote_party_number[i] = instance;
++			offset += sizeof(struct qmi_voice_remote_party_number_instance) + instance->number_size;
++		}
++		result->remote_party_number_set = 1;
++		result->remote_party_number_size = remote_party_number->size;
++	} else
++		return MISSING_MANDATORY;
++
++	return err;
++}
+diff -up ofono-1.31/drivers/qmimodem/voice_generated.h.omv~ ofono-1.31/drivers/qmimodem/voice_generated.h
+--- ofono-1.31/drivers/qmimodem/voice_generated.h.omv~	2020-09-14 18:45:49.820561477 +0200
++++ ofono-1.31/drivers/qmimodem/voice_generated.h	2020-09-14 18:46:16.173642823 +0200
+@@ -0,0 +1,112 @@
++#ifndef __OFONO_QMI_VOICE_GENERATED_H
++#define __OFONO_QMI_VOICE_GENERATED_H
++
++#include "qmi.h"
++
++struct qmi_voice_remote_party_number_instance {
++	uint8_t call_id;
++	uint8_t presentation_indicator;
++	uint8_t number_size;
++	char number[0];
++} __attribute__((__packed__));
++
++struct qmi_voice_remote_party_number {
++	uint8_t size;
++	struct qmi_voice_remote_party_number_instance instance[0];
++} __attribute__((__packed__));
++
++/* generator / parser */
++
++struct qmi_voice_dial_call_arg {
++	bool calling_number_set;
++	const char *calling_number;
++	bool call_type_set;
++	uint8_t call_type;
++};
++
++int qmi_voice_dial_call(
++		struct qmi_voice_dial_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy);
++
++struct qmi_voice_dial_call_result {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++enum parse_error qmi_voice_dial_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_dial_call_result *result);
++
++struct qmi_voice_end_call_arg {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++int qmi_voice_end_call(
++		struct qmi_voice_end_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy);
++
++struct qmi_voice_end_call_result {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++enum parse_error qmi_voice_end_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_end_call_result *result);
++
++struct qmi_voice_answer_call_arg {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++int qmi_voice_answer_call(
++		struct qmi_voice_answer_call_arg *arg,
++		struct qmi_service *service,
++		qmi_result_func_t func,
++		void *user_data,
++		qmi_destroy_func_t destroy);
++
++struct qmi_voice_answer_call_result {
++	bool call_id_set;
++	uint8_t call_id;
++};
++
++enum parse_error qmi_voice_answer_call_parse(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_answer_call_result *result);
++
++struct qmi_voice_call_information_instance {
++	uint8_t id;
++	uint8_t state;
++	uint8_t type;
++	uint8_t direction;
++	uint8_t mode;
++	uint8_t multipart_indicator;
++	uint8_t als;
++} __attribute__((__packed__));
++
++struct qmi_voice_call_information {
++	uint8_t size;
++	struct qmi_voice_call_information_instance instance[0];
++} __attribute__((__packed__)) ;
++
++struct qmi_voice_all_call_status_ind {
++	bool call_information_set;
++	const struct qmi_voice_call_information *call_information;
++	bool remote_party_number_set;
++	uint8_t remote_party_number_size;
++	const struct qmi_voice_remote_party_number_instance *remote_party_number[16];
++};
++
++enum parse_error qmi_voice_ind_call_status(
++		struct qmi_result *qmi_result,
++		struct qmi_voice_all_call_status_ind *result);
++
++#endif /* __OFONO_QMI_VOICE_GENERATED_H */
+diff -up ofono-1.31/drivers/qmimodem/voice.h.omv~ ofono-1.31/drivers/qmimodem/voice.h
+--- ofono-1.31/drivers/qmimodem/voice.h.omv~	2020-09-14 18:31:29.084129073 +0200
++++ ofono-1.31/drivers/qmimodem/voice.h	2020-09-14 18:42:04.449921305 +0200
+@@ -60,3 +60,32 @@ struct qmi_ussd_data {
+ 	uint8_t length;
+ 	uint8_t data[0];
+ } __attribute__((__packed__));
++
++enum call_direction;
++
++enum qmi_voice_call_state {
++	QMI_CALL_STATE_IDLE =		0x0,
++	QMI_CALL_STATE_ORIG,
++	QMI_CALL_STATE_INCOMING,
++	QMI_CALL_STATE_CONV,
++	QMI_CALL_STATE_CC_IN_PROG,
++	QMI_CALL_STATE_ALERTING,
++	QMI_CALL_STATE_HOLD,
++	QMI_CALL_STATE_WAITING,
++	QMI_CALL_STATE_DISCONNECTING,
++	QMI_CALL_STATE_END,
++	QMI_CALL_STATE_SETUP
++};
++
++enum qmi_voice_call_type {
++	QMI_CALL_TYPE_VOICE =		0x0,
++	QMI_CALL_TYPE_VOICE_FORCE,
++};
++
++const char *qmi_voice_call_state_name(enum qmi_voice_call_state value);
++uint8_t ofono_to_qmi_direction(enum call_direction ofonod_direction);
++enum call_direction qmi_to_ofono_direction(uint8_t qmi_direction);
++int qmi_to_ofono_status(uint8_t status, int *ret);
++
++#define QMI_VOICE_IND_ALL_STATUS 0x2e
++#define QMI_VOICE_PARAM_USS_DATA 0x01
+diff -up ofono-1.31/Makefile.am.omv~ ofono-1.31/Makefile.am
+--- ofono-1.31/Makefile.am.omv~	2020-09-14 18:27:04.717714977 +0200
++++ ofono-1.31/Makefile.am	2020-09-14 18:27:45.718565917 +0200
+@@ -274,7 +274,8 @@ qmi_sources = drivers/qmimodem/qmi.h dri
+ 					drivers/qmimodem/pds.h \
+ 					drivers/qmimodem/common.h \
+ 					drivers/qmimodem/wda.h \
+-					drivers/qmimodem/voice.h
++					drivers/qmimodem/voice.h \
++					drivers/qmimodem/voice.c
+ 
+ builtin_modules += qmimodem
+ builtin_sources += $(qmi_sources) \
+@@ -283,6 +284,7 @@ builtin_sources += $(qmi_sources) \
+ 			drivers/qmimodem/qmimodem.c \
+ 			drivers/qmimodem/devinfo.c \
+ 			drivers/qmimodem/voicecall.c \
++			drivers/qmimodem/voice_generated.c \
+ 			drivers/qmimodem/network-registration.c \
+ 			drivers/qmimodem/sim-legacy.c \
+ 			drivers/qmimodem/sim.c \
diff --git a/ofono.spec b/ofono.spec
index d93b591..a784680 100644
--- a/ofono.spec
+++ b/ofono.spec
@@ -1,10 +1,19 @@
 Name:    ofono
 Summary: Open Source Telephony
 Version: 1.31
-Release: 1
+Release: 2
 License: GPLv2
 URL:     http://ofono.org/
 Source0: https://git.kernel.org/pub/scm/network/ofono/ofono.git/snapshot/ofono-%{version}.tar.gz
+# Based on https://raw.githubusercontent.com/sailfish-on-dontbeevil/ofono/master/ofono/0002-add-call-list-helper-to-manage-voice-call-lists.patch
+Patch0:  0002-add-call-list-helper-to-manage-voice-call-lists.patch
+Patch1:	 https://raw.githubusercontent.com/sailfish-on-dontbeevil/ofono/master/ofono/0003-call-compare-by-status.patch
+# Based on https://raw.githubusercontent.com/sailfish-on-dontbeevil/ofono/master/ofono/0004-call-compare-by-id.patch
+Patch2:  0004-call-compare-by-id.patch
+# Based on https://raw.githubusercontent.com/sailfish-on-dontbeevil/ofono/master/ofono/0006-create-glist-helper-ofono_call_compare.patch
+Patch3:  0006-create-glist-helper-ofono_call_compare.patch
+# Based on https://raw.githubusercontent.com/sailfish-on-dontbeevil/ofono/master/ofono/0001-qmimodem-implement-voice-calls.patch
+Patch4:  ofono-1.31-qmimodem-voicecall.patch
 BuildRequires: automake libtool
 BuildRequires: pkgconfig(ell)
 BuildRequires: pkgconfig(glib-2.0)
@@ -34,7 +43,7 @@ Requires: %{name} = %{version}-%{release}
 %{summary}.
 
 %prep
-%setup -q
+%autosetup -p1
 
 %build
 if [ ! -f configure ]; then
Not Available
benbullard79 [@T] cox.netPerfect packages, no one ever says a word!6d 19hrs
benbullard79 [@T] cox.netFantastic!6d 19hrs