mirror of git://git.sysmocom.de/ofono
stkutil: Use l_queue instead of GSList
This commit is contained in:
parent
22002d142c
commit
c3d5ccbe53
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <ell/ell.h>
|
||||
|
||||
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||
|
||||
|
@ -387,9 +388,8 @@ ofono_bool_t __ofono_is_valid_sim_pin(const char *pin,
|
|||
|
||||
ofono_bool_t __ofono_is_valid_net_pin(const char *pin);
|
||||
|
||||
void __ofono_sim_refresh(struct ofono_sim *sim, GSList *file_list,
|
||||
ofono_bool_t full_file_change,
|
||||
ofono_bool_t naa_init);
|
||||
void __ofono_sim_refresh(struct ofono_sim *sim, struct l_queue *file_list,
|
||||
bool full_file_change, bool naa_init);
|
||||
|
||||
void __ofono_sim_recheck_pin(struct ofono_sim *sim);
|
||||
|
||||
|
|
14
src/sim.c
14
src/sim.c
|
@ -3400,17 +3400,17 @@ static void sim_file_changed_flush(struct ofono_sim *sim, int id)
|
|||
sim_fs_cache_flush_file(sim->simfs, id);
|
||||
}
|
||||
|
||||
void __ofono_sim_refresh(struct ofono_sim *sim, GSList *file_list,
|
||||
ofono_bool_t full_file_change, ofono_bool_t naa_init)
|
||||
void __ofono_sim_refresh(struct ofono_sim *sim, struct l_queue *files,
|
||||
bool full_file_change, bool naa_init)
|
||||
{
|
||||
GSList *l;
|
||||
gboolean reinit_naa = naa_init || full_file_change;
|
||||
const struct l_queue_entry *l;
|
||||
bool reinit_naa = naa_init || full_file_change;
|
||||
|
||||
/*
|
||||
* Check if any files used in SIM initialisation procedure
|
||||
* are affected, except EFiccid, EFpl, EFli.
|
||||
*/
|
||||
for (l = file_list; l; l = l->next) {
|
||||
for (l = l_queue_get_entries(files); l; l = l->next) {
|
||||
struct stk_file *file = l->data;
|
||||
uint32_t mf, df, ef;
|
||||
|
||||
|
@ -3451,7 +3451,7 @@ void __ofono_sim_refresh(struct ofono_sim *sim, GSList *file_list,
|
|||
if (full_file_change)
|
||||
sim_fs_cache_flush(sim->simfs);
|
||||
else {
|
||||
for (l = file_list; l; l = l->next) {
|
||||
for (l = l_queue_get_entries(files); l; l = l->next) {
|
||||
struct stk_file *file = l->data;
|
||||
int id = (file->file[file->len - 2] << 8) |
|
||||
(file->file[file->len - 1] << 0);
|
||||
|
@ -3476,7 +3476,7 @@ void __ofono_sim_refresh(struct ofono_sim *sim, GSList *file_list,
|
|||
if (full_file_change)
|
||||
sim_fs_notify_file_watches(sim->simfs, -1);
|
||||
else {
|
||||
for (l = file_list; l; l = l->next) {
|
||||
for (l = l_queue_get_entries(files); l; l = l->next) {
|
||||
struct stk_file *file = l->data;
|
||||
int id = (file->file[file->len - 2] << 8) |
|
||||
(file->file[file->len - 1] << 0);
|
||||
|
|
12
src/stk.c
12
src/stk.c
|
@ -2164,7 +2164,7 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
|
|||
struct ofono_sim *sim;
|
||||
uint8_t addnl_info[1];
|
||||
int err;
|
||||
GSList *l;
|
||||
const struct l_queue_entry *entry;
|
||||
|
||||
DBG("");
|
||||
|
||||
|
@ -2208,8 +2208,9 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
|
|||
}
|
||||
|
||||
DBG("Files:");
|
||||
for (l = cmd->refresh.file_list; l; l = l->next) {
|
||||
struct stk_file *file = l->data;
|
||||
for (entry = l_queue_get_entries(cmd->refresh.file_list);
|
||||
entry; entry = entry->next) {
|
||||
struct stk_file *file = entry->data;
|
||||
char buf[17];
|
||||
|
||||
encode_hex_own_buf(file->file, file->len, 0, buf);
|
||||
|
@ -2273,7 +2274,8 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
|
|||
*/
|
||||
if (cmd->qualifier < 4 || rsp == NULL) {
|
||||
int qualifier = stk->pending_cmd->qualifier;
|
||||
GSList *file_list = stk->pending_cmd->refresh.file_list;
|
||||
struct l_queue *file_list =
|
||||
stk->pending_cmd->refresh.file_list;
|
||||
|
||||
/* Don't free the list yet */
|
||||
stk->pending_cmd->refresh.file_list = NULL;
|
||||
|
@ -2316,7 +2318,7 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
|
|||
break;
|
||||
}
|
||||
|
||||
g_slist_free_full(file_list, g_free);
|
||||
l_queue_destroy(file_list, l_free);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -602,7 +602,8 @@ static gboolean parse_dataobj_ussd(struct comprehension_tlv_iter *iter,
|
|||
static gboolean parse_dataobj_file_list(struct comprehension_tlv_iter *iter,
|
||||
void *user)
|
||||
{
|
||||
GSList **fl = user;
|
||||
struct l_queue **out = user;
|
||||
struct l_queue *fl;
|
||||
const unsigned char *data;
|
||||
unsigned int len;
|
||||
struct stk_file *sf;
|
||||
|
@ -613,27 +614,24 @@ static gboolean parse_dataobj_file_list(struct comprehension_tlv_iter *iter,
|
|||
return FALSE;
|
||||
|
||||
data = comprehension_tlv_iter_get_data(iter);
|
||||
|
||||
stk_file_iter_init(&sf_iter, data + 1, len - 1);
|
||||
fl = l_queue_new();
|
||||
|
||||
while (stk_file_iter_next(&sf_iter)) {
|
||||
sf = g_try_new0(struct stk_file, 1);
|
||||
if (sf == NULL)
|
||||
goto error;
|
||||
|
||||
sf = l_new(struct stk_file, 1);
|
||||
sf->len = sf_iter.len;
|
||||
memcpy(sf->file, sf_iter.file, sf_iter.len);
|
||||
*fl = g_slist_prepend(*fl, sf);
|
||||
l_queue_push_tail(fl, sf);
|
||||
}
|
||||
|
||||
if (sf_iter.pos != sf_iter.max)
|
||||
goto error;
|
||||
|
||||
*fl = g_slist_reverse(*fl);
|
||||
*out = fl;
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
g_slist_free_full(*fl, g_free);
|
||||
l_queue_destroy(fl, l_free);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -2270,25 +2268,25 @@ static gboolean parse_item_list(struct comprehension_tlv_iter *iter,
|
|||
static gboolean parse_provisioning_list(struct comprehension_tlv_iter *iter,
|
||||
void *data)
|
||||
{
|
||||
GSList **out = data;
|
||||
struct l_queue **out = data;
|
||||
unsigned short tag = STK_DATA_OBJECT_TYPE_PROVISIONING_FILE_REF;
|
||||
struct comprehension_tlv_iter iter_old;
|
||||
struct stk_file file;
|
||||
GSList *list = NULL;
|
||||
struct l_queue *list = l_queue_new();
|
||||
|
||||
do {
|
||||
comprehension_tlv_iter_copy(iter, &iter_old);
|
||||
memset(&file, 0, sizeof(file));
|
||||
|
||||
if (parse_dataobj_provisioning_file_reference(iter, &file)
|
||||
== TRUE)
|
||||
list = g_slist_prepend(list,
|
||||
g_memdup(&file, sizeof(file)));
|
||||
if (!parse_dataobj_provisioning_file_reference(iter, &file))
|
||||
continue;
|
||||
|
||||
l_queue_push_tail(list, l_memdup(&file, sizeof(file)));
|
||||
} while (comprehension_tlv_iter_next(iter) == TRUE &&
|
||||
comprehension_tlv_iter_get_tag(iter) == tag);
|
||||
|
||||
comprehension_tlv_iter_copy(&iter_old, iter);
|
||||
*out = g_slist_reverse(list);
|
||||
*out = list;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2907,7 +2905,7 @@ static enum stk_command_parse_result parse_setup_call(
|
|||
|
||||
static void destroy_refresh(struct stk_command *command)
|
||||
{
|
||||
g_slist_free_full(command->refresh.file_list, g_free);
|
||||
l_queue_destroy(command->refresh.file_list, l_free);
|
||||
l_free(command->refresh.alpha_id);
|
||||
}
|
||||
|
||||
|
@ -3222,7 +3220,7 @@ static void destroy_launch_browser(struct stk_command *command)
|
|||
{
|
||||
l_free(command->launch_browser.url);
|
||||
l_free(command->launch_browser.bearer.array);
|
||||
g_slist_free_full(command->launch_browser.prov_file_refs, g_free);
|
||||
l_queue_destroy(command->launch_browser.prov_file_refs, l_free);
|
||||
l_free(command->launch_browser.text_gateway_proxy_id);
|
||||
l_free(command->launch_browser.alpha_id);
|
||||
l_free(command->launch_browser.network_name.array);
|
||||
|
@ -3608,7 +3606,7 @@ static enum stk_command_parse_result parse_get_frames_status(
|
|||
static void destroy_retrieve_mms(struct stk_command *command)
|
||||
{
|
||||
l_free(command->retrieve_mms.alpha_id);
|
||||
g_slist_free_full(command->retrieve_mms.mms_rec_files, g_free);
|
||||
l_queue_destroy(command->retrieve_mms.mms_rec_files, l_free);
|
||||
}
|
||||
|
||||
static enum stk_command_parse_result parse_retrieve_mms(
|
||||
|
@ -3655,7 +3653,7 @@ static enum stk_command_parse_result parse_retrieve_mms(
|
|||
static void destroy_submit_mms(struct stk_command *command)
|
||||
{
|
||||
l_free(command->submit_mms.alpha_id);
|
||||
g_slist_free_full(command->submit_mms.mms_subm_files, g_free);
|
||||
l_queue_destroy(command->submit_mms.mms_subm_files, l_free);
|
||||
}
|
||||
|
||||
static enum stk_command_parse_result parse_submit_mms(
|
||||
|
@ -3695,7 +3693,7 @@ static enum stk_command_parse_result parse_submit_mms(
|
|||
|
||||
static void destroy_display_mms(struct stk_command *command)
|
||||
{
|
||||
g_slist_free_full(command->display_mms.mms_subm_files, g_free);
|
||||
l_queue_destroy(command->display_mms.mms_subm_files, l_free);
|
||||
}
|
||||
|
||||
static enum stk_command_parse_result parse_display_mms(
|
||||
|
@ -4377,18 +4375,19 @@ static gboolean build_dataobj_ussd_string(struct stk_tlv_builder *tlv,
|
|||
static gboolean build_dataobj_file_list(struct stk_tlv_builder *tlv,
|
||||
const void *data, gboolean cr)
|
||||
{
|
||||
GSList *l = (void *) data;
|
||||
struct l_queue *fl = (void *) data;
|
||||
const struct l_queue_entry *entry = l_queue_get_entries(fl);
|
||||
const struct stk_file *file;
|
||||
unsigned char tag = STK_DATA_OBJECT_TYPE_FILE_LIST;
|
||||
|
||||
if (stk_tlv_builder_open_container(tlv, cr, tag, TRUE) != TRUE)
|
||||
return FALSE;
|
||||
|
||||
if (stk_tlv_builder_append_byte(tlv, g_slist_length(l)) != TRUE)
|
||||
if (stk_tlv_builder_append_byte(tlv, l_queue_length(fl)) != TRUE)
|
||||
return FALSE;
|
||||
|
||||
for (; l; l = l->next) {
|
||||
file = l->data;
|
||||
for (; entry; entry = entry->next) {
|
||||
file = entry->data;
|
||||
|
||||
if (stk_tlv_builder_append_bytes(tlv, file->file,
|
||||
file->len) != TRUE)
|
||||
|
@ -4402,12 +4401,14 @@ static gboolean build_dataobj_file_list(struct stk_tlv_builder *tlv,
|
|||
static gboolean build_dataobj_file(struct stk_tlv_builder *tlv,
|
||||
const void *data, gboolean cr)
|
||||
{
|
||||
GSList l = {
|
||||
.data = (void *) data,
|
||||
.next = NULL,
|
||||
};
|
||||
struct l_queue *fl = l_queue_new();
|
||||
gboolean ret;
|
||||
|
||||
return build_dataobj_file_list(tlv, &l, cr);
|
||||
l_queue_push_tail(fl, (void *) data);
|
||||
ret = build_dataobj_file_list(tlv, fl, cr);
|
||||
|
||||
l_queue_destroy(fl, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Described in TS 102.223 Section 8.19 */
|
||||
|
|
|
@ -1239,7 +1239,7 @@ struct stk_command_setup_call {
|
|||
};
|
||||
|
||||
struct stk_command_refresh {
|
||||
GSList *file_list;
|
||||
struct l_queue *file_list;
|
||||
struct stk_aid aid;
|
||||
char *alpha_id;
|
||||
struct stk_icon_id icon_id;
|
||||
|
@ -1291,7 +1291,7 @@ struct stk_command_launch_browser {
|
|||
unsigned char browser_id;
|
||||
char *url;
|
||||
struct stk_common_byte_array bearer;
|
||||
GSList *prov_file_refs;
|
||||
struct l_queue *prov_file_refs;
|
||||
char *text_gateway_proxy_id;
|
||||
char *alpha_id;
|
||||
struct stk_icon_id icon_id;
|
||||
|
@ -1372,7 +1372,7 @@ struct stk_command_retrieve_mms {
|
|||
char *alpha_id;
|
||||
struct stk_icon_id icon_id;
|
||||
struct stk_mms_reference mms_ref;
|
||||
GSList *mms_rec_files;
|
||||
struct l_queue *mms_rec_files;
|
||||
struct stk_mms_content_id mms_content_id;
|
||||
struct stk_mms_id mms_id;
|
||||
struct stk_text_attribute text_attr;
|
||||
|
@ -1382,14 +1382,14 @@ struct stk_command_retrieve_mms {
|
|||
struct stk_command_submit_mms {
|
||||
char *alpha_id;
|
||||
struct stk_icon_id icon_id;
|
||||
GSList *mms_subm_files;
|
||||
struct l_queue *mms_subm_files;
|
||||
struct stk_mms_id mms_id;
|
||||
struct stk_text_attribute text_attr;
|
||||
struct stk_frame_id frame_id;
|
||||
};
|
||||
|
||||
struct stk_command_display_mms {
|
||||
GSList *mms_subm_files;
|
||||
struct l_queue *mms_subm_files;
|
||||
struct stk_mms_id mms_id;
|
||||
ofono_bool_t imd_resp;
|
||||
struct stk_frame_id frame_id;
|
||||
|
|
Loading…
Reference in New Issue