mirror of git://git.sysmocom.de/ofono
common: create GList helper ofono_call_compare
replaces at_util_call_compare (atmodem) and call_compare (rild).
This commit is contained in:
parent
1fafaee37e
commit
c97a48fd4b
|
@ -31,6 +31,7 @@
|
||||||
#define OFONO_API_SUBJECT_TO_CHANGE
|
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||||
#include <ofono/log.h>
|
#include <ofono/log.h>
|
||||||
#include <ofono/types.h>
|
#include <ofono/types.h>
|
||||||
|
#include "../src/common.h"
|
||||||
|
|
||||||
#include "atutil.h"
|
#include "atutil.h"
|
||||||
#include "vendor.h"
|
#include "vendor.h"
|
||||||
|
@ -101,20 +102,6 @@ gint at_util_call_compare_by_id(gconstpointer a, gconstpointer b)
|
||||||
return 0;
|
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)
|
GSList *at_util_parse_clcc(GAtResult *result, unsigned int *ret_mpty_ids)
|
||||||
{
|
{
|
||||||
GAtResultIter iter;
|
GAtResultIter iter;
|
||||||
|
@ -173,7 +160,7 @@ GSList *at_util_parse_clcc(GAtResult *result, unsigned int *ret_mpty_ids)
|
||||||
else
|
else
|
||||||
call->clip_validity = 2;
|
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)
|
if (mpty)
|
||||||
mpty_ids |= 1 << id;
|
mpty_ids |= 1 << id;
|
||||||
|
|
|
@ -54,7 +54,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_status(gconstpointer a, gconstpointer b);
|
||||||
gint at_util_call_compare_by_phone_number(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_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);
|
GSList *at_util_parse_clcc(GAtResult *result, unsigned int *mpty_ids);
|
||||||
gboolean at_util_parse_reg(GAtResult *result, const char *prefix,
|
gboolean at_util_parse_reg(GAtResult *result, const char *prefix,
|
||||||
int *mode, int *status,
|
int *mode, int *status,
|
||||||
|
|
|
@ -132,7 +132,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
|
||||||
call->clip_validity = clip;
|
call->clip_validity = clip;
|
||||||
call->cnap_validity = CNAP_VALIDITY_NOT_AVAILABLE;
|
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;
|
return call;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
|
||||||
call->phone_number.type = num_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;
|
call->clip_validity = clip;
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
|
||||||
|
|
||||||
call->clip_validity = clip;
|
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;
|
return call;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
|
||||||
|
|
||||||
call->clip_validity = clip;
|
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;
|
return call;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,20 +117,6 @@ done:
|
||||||
ofono_voicecall_disconnected(vc, reqdata->id, reason, NULL);
|
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)
|
static void clcc_poll_cb(struct ril_msg *message, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct ofono_voicecall *vc = user_data;
|
struct ofono_voicecall *vc = user_data;
|
||||||
|
@ -209,7 +195,7 @@ static void clcc_poll_cb(struct ril_msg *message, gpointer user_data)
|
||||||
call->id, call->status, call->type,
|
call->id, call->status, call->type,
|
||||||
call->phone_number.number, call->name);
|
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:
|
no_calls:
|
||||||
|
|
|
@ -128,7 +128,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
|
||||||
|
|
||||||
call->clip_validity = clip;
|
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;
|
return call;
|
||||||
}
|
}
|
||||||
|
|
14
src/common.c
14
src/common.c
|
@ -736,3 +736,17 @@ void ofono_call_init(struct ofono_call *call)
|
||||||
call->cnap_validity = CNAP_VALIDITY_NOT_AVAILABLE;
|
call->cnap_validity = CNAP_VALIDITY_NOT_AVAILABLE;
|
||||||
call->clip_validity = CLIP_VALIDITY_NOT_AVAILABLE;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -184,3 +184,5 @@ const char *registration_tech_to_string(int tech);
|
||||||
const char *packet_bearer_to_string(int bearer);
|
const char *packet_bearer_to_string(int bearer);
|
||||||
|
|
||||||
gboolean is_valid_apn(const char *apn);
|
gboolean is_valid_apn(const char *apn);
|
||||||
|
|
||||||
|
gint ofono_call_compare(gconstpointer a, gconstpointer b);
|
||||||
|
|
Loading…
Reference in New Issue