common: create GList helper ofono_call_compare

replaces at_util_call_compare (atmodem) and
call_compare (rild).
This commit is contained in:
Alexander Couzens 2017-07-12 21:00:00 +02:00 committed by Pau Espin Pedrol
parent 6bd0e4ed9b
commit d03af77d94
11 changed files with 26 additions and 37 deletions

View File

@ -36,6 +36,8 @@
#include <ofono/types.h>
#include <ofono/modem.h>
#include "../src/common.h"
#include "atutil.h"
#include "vendor.h"
@ -105,20 +107,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;
@ -177,7 +165,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;

View File

@ -59,7 +59,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,

View File

@ -131,7 +131,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;
}

View File

@ -363,7 +363,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;

View File

@ -128,7 +128,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;

View File

@ -75,7 +75,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;
}

View File

@ -106,7 +106,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;
}

View File

@ -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 *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:

View File

@ -127,7 +127,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;
}

View File

@ -834,3 +834,17 @@ gboolean gprs_auth_method_from_string(const char *str,
return FALSE;
}
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;
}

View File

@ -196,3 +196,5 @@ gboolean gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto);
const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth);
gboolean gprs_auth_method_from_string(const char *str,
enum ofono_gprs_auth_method *auth);
gint ofono_call_compare(gconstpointer a, gconstpointer b);