mirror of git://git.sysmocom.de/ofono
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.
This commit is contained in:
parent
9cba079221
commit
4704531a56
|
@ -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 \
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 */
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue