diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c index bbdb01c4..b4d5a501 100644 --- a/drivers/atmodem/atutil.c +++ b/drivers/atmodem/atutil.c @@ -36,6 +36,8 @@ #include #include +#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; diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h index fe2acb39..4a8e26cb 100644 --- a/drivers/atmodem/atutil.h +++ b/drivers/atmodem/atutil.h @@ -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, diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c index 7ab6567f..6746e46b 100644 --- a/drivers/atmodem/voicecall.c +++ b/drivers/atmodem/voicecall.c @@ -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; } diff --git a/drivers/gemaltomodem/voicecall.c b/drivers/gemaltomodem/voicecall.c index ad6d78af..7055fe18 100644 --- a/drivers/gemaltomodem/voicecall.c +++ b/drivers/gemaltomodem/voicecall.c @@ -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; diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c index 69667f14..afa9c61a 100644 --- a/drivers/hfpmodem/voicecall.c +++ b/drivers/hfpmodem/voicecall.c @@ -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; diff --git a/drivers/huaweimodem/voicecall.c b/drivers/huaweimodem/voicecall.c index 3044f602..1ef33e13 100644 --- a/drivers/huaweimodem/voicecall.c +++ b/drivers/huaweimodem/voicecall.c @@ -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; } diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c index ae694e3a..b48981f2 100644 --- a/drivers/ifxmodem/voicecall.c +++ b/drivers/ifxmodem/voicecall.c @@ -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; } diff --git a/drivers/rilmodem/voicecall.c b/drivers/rilmodem/voicecall.c index 13dc5071..f9e76b2a 100644 --- a/drivers/rilmodem/voicecall.c +++ b/drivers/rilmodem/voicecall.c @@ -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: diff --git a/drivers/stemodem/voicecall.c b/drivers/stemodem/voicecall.c index 3fd3c1f4..9a7e36d8 100644 --- a/drivers/stemodem/voicecall.c +++ b/drivers/stemodem/voicecall.c @@ -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; } diff --git a/src/common.c b/src/common.c index 4dcbc835..2324a676 100644 --- a/src/common.c +++ b/src/common.c @@ -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; +} diff --git a/src/common.h b/src/common.h index 8fef4432..8e8ead0a 100644 --- a/src/common.h +++ b/src/common.h @@ -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);