mirror of git://git.sysmocom.de/ofono
stkutil: Use l_queue instead of GSList
This commit is contained in:
parent
4927905db4
commit
22002d142c
13
src/stk.c
13
src/stk.c
|
@ -346,14 +346,14 @@ static char *dbus_apply_text_attributes(const char *text,
|
||||||
|
|
||||||
static struct stk_menu *stk_menu_create(const char *title,
|
static struct stk_menu *stk_menu_create(const char *title,
|
||||||
const struct stk_text_attribute *title_attr,
|
const struct stk_text_attribute *title_attr,
|
||||||
const struct stk_icon_id *icon, GSList *items,
|
const struct stk_icon_id *icon, struct l_queue *items,
|
||||||
const struct stk_item_text_attribute_list *item_attrs,
|
const struct stk_item_text_attribute_list *item_attrs,
|
||||||
const struct stk_item_icon_id_list *item_icon_ids,
|
const struct stk_item_icon_id_list *item_icon_ids,
|
||||||
int default_id, gboolean soft_key, gboolean has_help)
|
int default_id, bool soft_key, bool has_help)
|
||||||
{
|
{
|
||||||
unsigned int len = g_slist_length(items);
|
unsigned int len = l_queue_length(items);
|
||||||
struct stk_menu *ret;
|
struct stk_menu *ret;
|
||||||
GSList *l;
|
const struct l_queue_entry *entry;
|
||||||
int i;
|
int i;
|
||||||
struct stk_text_attribute attr;
|
struct stk_text_attribute attr;
|
||||||
|
|
||||||
|
@ -378,8 +378,9 @@ static struct stk_menu *stk_menu_create(const char *title,
|
||||||
ret->soft_key = soft_key;
|
ret->soft_key = soft_key;
|
||||||
ret->has_help = has_help;
|
ret->has_help = has_help;
|
||||||
|
|
||||||
for (l = items, i = 0; l; l = l->next, i++) {
|
for (entry = l_queue_get_entries(items), i = 0;
|
||||||
struct stk_item *item = l->data;
|
entry; entry = entry->next, i++) {
|
||||||
|
struct stk_item *item = entry->data;
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
ret->items[i].item_id = item->id;
|
ret->items[i].item_id = item->id;
|
||||||
|
|
|
@ -2231,42 +2231,39 @@ static void destroy_stk_item(gpointer pointer)
|
||||||
static gboolean parse_item_list(struct comprehension_tlv_iter *iter,
|
static gboolean parse_item_list(struct comprehension_tlv_iter *iter,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
GSList **out = data;
|
struct l_queue **out = data;
|
||||||
unsigned short tag = STK_DATA_OBJECT_TYPE_ITEM;
|
uint16_t tag = STK_DATA_OBJECT_TYPE_ITEM;
|
||||||
struct comprehension_tlv_iter iter_old;
|
struct comprehension_tlv_iter iter_old;
|
||||||
struct stk_item item;
|
struct stk_item item;
|
||||||
GSList *list = NULL;
|
struct l_queue *list = l_queue_new();
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
gboolean has_empty = FALSE;
|
bool has_empty = FALSE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
comprehension_tlv_iter_copy(iter, &iter_old);
|
comprehension_tlv_iter_copy(iter, &iter_old);
|
||||||
memset(&item, 0, sizeof(item));
|
memset(&item, 0, sizeof(item));
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (parse_dataobj_item(iter, &item) == TRUE) {
|
if (!parse_dataobj_item(iter, &item))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (item.id == 0) {
|
if (item.id == 0) {
|
||||||
has_empty = TRUE;
|
has_empty = TRUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = g_slist_prepend(list,
|
l_queue_push_tail(list, l_memdup(&item, sizeof(item)));
|
||||||
l_memdup(&item, sizeof(item)));
|
|
||||||
}
|
|
||||||
} while (comprehension_tlv_iter_next(iter) == TRUE &&
|
} while (comprehension_tlv_iter_next(iter) == TRUE &&
|
||||||
comprehension_tlv_iter_get_tag(iter) == tag);
|
comprehension_tlv_iter_get_tag(iter) == tag);
|
||||||
|
|
||||||
comprehension_tlv_iter_copy(&iter_old, iter);
|
comprehension_tlv_iter_copy(&iter_old, iter);
|
||||||
|
|
||||||
if (!has_empty) {
|
if (!has_empty || count == 1) {
|
||||||
*out = g_slist_reverse(list);
|
*out = list;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 1)
|
l_queue_destroy(list, destroy_stk_item);
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
g_slist_free_full(list, destroy_stk_item);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2590,7 +2587,7 @@ static enum stk_command_parse_result parse_poll_interval(
|
||||||
static void destroy_setup_menu(struct stk_command *command)
|
static void destroy_setup_menu(struct stk_command *command)
|
||||||
{
|
{
|
||||||
l_free(command->setup_menu.alpha_id);
|
l_free(command->setup_menu.alpha_id);
|
||||||
g_slist_free_full(command->setup_menu.items, destroy_stk_item);
|
l_queue_destroy(command->setup_menu.items, destroy_stk_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum stk_command_parse_result parse_setup_menu(
|
static enum stk_command_parse_result parse_setup_menu(
|
||||||
|
@ -2635,7 +2632,7 @@ static enum stk_command_parse_result parse_setup_menu(
|
||||||
static void destroy_select_item(struct stk_command *command)
|
static void destroy_select_item(struct stk_command *command)
|
||||||
{
|
{
|
||||||
l_free(command->select_item.alpha_id);
|
l_free(command->select_item.alpha_id);
|
||||||
g_slist_free_full(command->select_item.items, destroy_stk_item);
|
l_queue_destroy(command->select_item.items, destroy_stk_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum stk_command_parse_result parse_select_item(
|
static enum stk_command_parse_result parse_select_item(
|
||||||
|
@ -2675,7 +2672,7 @@ static enum stk_command_parse_result parse_select_item(
|
||||||
|
|
||||||
command->destructor = destroy_select_item;
|
command->destructor = destroy_select_item;
|
||||||
|
|
||||||
if (status == STK_PARSE_RESULT_OK && obj->items == NULL)
|
if (status == STK_PARSE_RESULT_OK && l_queue_isempty(obj->items))
|
||||||
status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
|
status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
|
||||||
|
|
||||||
CHECK_TEXT_AND_ICON(obj->alpha_id, obj->icon_id.id);
|
CHECK_TEXT_AND_ICON(obj->alpha_id, obj->icon_id.id);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct l_queue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TS 101.220, Section 7.2, Card Application Toolkit assigned templates,
|
* TS 101.220, Section 7.2, Card Application Toolkit assigned templates,
|
||||||
* These are the same as 3GPP 11.14 Sections 13.1 and 13.2
|
* These are the same as 3GPP 11.14 Sections 13.1 and 13.2
|
||||||
|
@ -1177,7 +1179,7 @@ struct stk_command_poll_interval {
|
||||||
|
|
||||||
struct stk_command_setup_menu {
|
struct stk_command_setup_menu {
|
||||||
char *alpha_id;
|
char *alpha_id;
|
||||||
GSList *items;
|
struct l_queue *items;
|
||||||
struct stk_items_next_action_indicator next_act;
|
struct stk_items_next_action_indicator next_act;
|
||||||
struct stk_icon_id icon_id;
|
struct stk_icon_id icon_id;
|
||||||
struct stk_item_icon_id_list item_icon_id_list;
|
struct stk_item_icon_id_list item_icon_id_list;
|
||||||
|
@ -1187,7 +1189,7 @@ struct stk_command_setup_menu {
|
||||||
|
|
||||||
struct stk_command_select_item {
|
struct stk_command_select_item {
|
||||||
char *alpha_id;
|
char *alpha_id;
|
||||||
GSList *items;
|
struct l_queue *items;
|
||||||
struct stk_items_next_action_indicator next_act;
|
struct stk_items_next_action_indicator next_act;
|
||||||
unsigned char item_id;
|
unsigned char item_id;
|
||||||
struct stk_icon_id icon_id;
|
struct stk_icon_id icon_id;
|
||||||
|
|
Loading…
Reference in New Issue