pmaports/temp/ofono/0001-common-create-GList-helper-ofono_call_compare.patch

359 lines
11 KiB
Diff
Raw Normal View History

From 43cb37372435a38f25f5a26f52f7b8a97cb76bfa Mon Sep 17 00:00:00 2001
From: Alexander Couzens <lynxis@fe80.eu>
Date: Wed, 12 Jul 2017 21:00:00 +0200
Subject: [PATCH 1/5] common: create GList helper ofono_call_compare
replaces at_util_call_compare (atmodem) and
call_compare (rild).
Introduce a drivers/common directory to be used by drivers
to reduce the common code.
---
Makefile.am | 3 ++-
drivers/atmodem/atutil.c | 18 +++----------
drivers/atmodem/atutil.h | 1 -
drivers/atmodem/voicecall.c | 4 ++-
drivers/common/call_list.c | 43 ++++++++++++++++++++++++++++++++
drivers/common/call_list.h | 29 +++++++++++++++++++++
drivers/gemaltomodem/voicecall.c | 4 ++-
drivers/hfpmodem/voicecall.c | 4 ++-
drivers/huaweimodem/voicecall.c | 4 ++-
drivers/ifxmodem/voicecall.c | 4 ++-
drivers/rilmodem/voicecall.c | 18 +++----------
drivers/stemodem/voicecall.c | 4 ++-
12 files changed, 98 insertions(+), 38 deletions(-)
create mode 100644 drivers/common/call_list.c
create mode 100644 drivers/common/call_list.h
diff --git a/Makefile.am b/Makefile.am
index 6aa8f8fe..1251d792 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -348,7 +348,8 @@ builtin_sources += drivers/atmodem/atmodem.h \
drivers/atmodem/gprs.c \
drivers/atmodem/gprs-context.c \
drivers/atmodem/gnss.c \
- drivers/atmodem/lte.c
+ drivers/atmodem/lte.c \
+ drivers/common/call_list.c
builtin_modules += nwmodem
builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index 98e3a2f8..fcbc39a9 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -34,6 +34,8 @@
#include <ofono/log.h>
#include <ofono/types.h>
+#include <drivers/common/call_list.h>
+
#include "atutil.h"
#include "vendor.h"
@@ -103,20 +105,6 @@ gint at_util_call_compare_by_id(gconstpointer a, gconstpointer b)
return 0;
}
-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;
@@ -175,7 +163,7 @@ GSList *at_util_parse_clcc(GAtResult *result, unsigned int *ret_mpty_ids)
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 --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 69e8b499..23d172aa 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -55,7 +55,6 @@ void decode_at_error(struct ofono_error *error, const char *final);
gint at_util_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);
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 --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index d55cf008..f9d71e21 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -33,6 +33,8 @@
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/voicecall.h>
+#include <drivers/common/call_list.h>
+
#include "vendor.h"
#include "gatchat.h"
@@ -131,7 +133,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
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 --git a/drivers/common/call_list.c b/drivers/common/call_list.c
new file mode 100644
index 00000000..487b85e4
--- /dev/null
+++ b/drivers/common/call_list.c
@@ -0,0 +1,43 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2019 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <ofono/types.h>
+
+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;
+}
+
diff --git a/drivers/common/call_list.h b/drivers/common/call_list.h
new file mode 100644
index 00000000..2cca87b2
--- /dev/null
+++ b/drivers/common/call_list.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2019 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __OFONO_DRIVER_COMMON_CALL_LIST
+#define __OFONO_DRIVER_COMMON_CALL_LIST
+
+#include <glib.h>
+
+gint ofono_call_compare(gconstpointer a, gconstpointer b);
+
+#endif /* __OFONO_DRIVER_COMMON_CALL_LIST */
diff --git a/drivers/gemaltomodem/voicecall.c b/drivers/gemaltomodem/voicecall.c
index ad6d78af..c17dd8c8 100644
--- a/drivers/gemaltomodem/voicecall.c
+++ b/drivers/gemaltomodem/voicecall.c
@@ -35,6 +35,8 @@
#include <ofono/modem.h>
#include <ofono/voicecall.h>
+#include <drivers/common/call_list.h>
+
#include "gatchat.h"
#include "gatresult.h"
@@ -363,7 +365,7 @@ static void gemalto_parse_slcc(GAtResult *result, GSList **l,
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/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c
index 69667f14..faa25c7f 100644
--- a/drivers/hfpmodem/voicecall.c
+++ b/drivers/hfpmodem/voicecall.c
@@ -35,6 +35,8 @@
#include <ofono/modem.h>
#include <ofono/voicecall.h>
+#include <drivers/common/call_list.h>
+
#include "common.h"
#include "hfp.h"
@@ -128,7 +130,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
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 --git a/drivers/huaweimodem/voicecall.c b/drivers/huaweimodem/voicecall.c
index 3044f602..b0dfdbc7 100644
--- a/drivers/huaweimodem/voicecall.c
+++ b/drivers/huaweimodem/voicecall.c
@@ -34,6 +34,8 @@
#include <ofono/modem.h>
#include <ofono/voicecall.h>
+#include <drivers/common/call_list.h>
+
#include "gatchat.h"
#include "gatresult.h"
@@ -75,7 +77,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
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 --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index ae694e3a..b5db5d3e 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -34,6 +34,8 @@
#include <ofono/modem.h>
#include <ofono/voicecall.h>
+#include <drivers/common/call_list.h>
+
#include "gatchat.h"
#include "gatresult.h"
@@ -106,7 +108,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
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 --git a/drivers/rilmodem/voicecall.c b/drivers/rilmodem/voicecall.c
index 13dc5071..5619c40f 100644
--- a/drivers/rilmodem/voicecall.c
+++ b/drivers/rilmodem/voicecall.c
@@ -38,6 +38,8 @@
#include <ofono/modem.h>
#include <ofono/voicecall.h>
+#include <drivers/common/call_list.h>
+
#include <gril/gril.h>
#include "common.h"
@@ -116,20 +118,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 +196,7 @@ static void clcc_poll_cb(struct ril_msg *message, gpointer user_data)
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 --git a/drivers/stemodem/voicecall.c b/drivers/stemodem/voicecall.c
index 3fd3c1f4..7abb78eb 100644
--- a/drivers/stemodem/voicecall.c
+++ b/drivers/stemodem/voicecall.c
@@ -35,6 +35,8 @@
#include <ofono/modem.h>
#include <ofono/voicecall.h>
+#include <drivers/common/call_list.h>
+
#include "gatchat.h"
#include "gatresult.h"
#include "common.h"
@@ -127,7 +129,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
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;
}
--
2.22.0