gril: Remove g_ril_reply_parse_avail_ops

This commit is contained in:
Denis Kenzior 2015-11-13 14:19:05 -06:00
parent 2801acc03e
commit 2a6e6df52c
2 changed files with 0 additions and 147 deletions

View File

@ -67,144 +67,6 @@ static void ril_reply_free_operator(gpointer data)
}
}
void g_ril_reply_free_avail_ops(struct reply_avail_ops *reply)
{
if (reply) {
g_slist_free_full(reply->list, ril_reply_free_operator);
g_free(reply);
}
}
struct reply_avail_ops *g_ril_reply_parse_avail_ops(GRil *gril,
const struct ril_msg *message)
{
struct parcel rilp;
struct reply_operator *operator;
struct reply_avail_ops *reply = NULL;
unsigned int num_ops, num_strings;
unsigned int i;
int strings_per_opt;
if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
strings_per_opt = 5;
else
strings_per_opt = 4;
/*
* Minimum message length is 4:
* - array size
*/
if (message->buf_len < 4) {
ofono_error("%s: invalid QUERY_AVAIL_NETWORKS reply: "
"size too small (< 4): %d ",
__func__,
(int) message->buf_len);
goto error;
}
g_ril_init_parcel(message, &rilp);
g_ril_append_print_buf(gril, "{");
/* Number of operators at the list */
num_strings = (unsigned int) parcel_r_int32(&rilp);
if (num_strings % strings_per_opt) {
ofono_error("%s: invalid QUERY_AVAIL_NETWORKS reply: "
"num_strings (%d) MOD %d != 0",
__func__,
num_strings, strings_per_opt);
goto error;
}
num_ops = num_strings / strings_per_opt;
DBG("noperators = %d", num_ops);
reply = g_try_new0(struct reply_avail_ops, 1);
if (reply == NULL) {
ofono_error("%s: can't allocate reply struct", __func__);
goto error;
}
reply->num_ops = num_ops;
for (i = 0; i < num_ops; i++) {
operator = g_try_new0(struct reply_operator, 1);
if (operator == NULL) {
ofono_error("%s: can't allocate reply struct",
__func__);
goto error;
}
operator->lalpha = parcel_r_string(&rilp);
operator->salpha = parcel_r_string(&rilp);
operator->numeric = parcel_r_string(&rilp);
operator->status = parcel_r_string(&rilp);
/*
* MTK: additional string with technology: 2G/3G are the only
* valid values currently.
*/
if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
char *tech = parcel_r_string(&rilp);
if (strcmp(tech, "3G") == 0)
operator->tech = RADIO_TECH_UMTS;
else
operator->tech = RADIO_TECH_GSM;
g_free(tech);
} else {
operator->tech = RADIO_TECH_GSM;
}
if (operator->lalpha == NULL && operator->salpha == NULL) {
ofono_error("%s: operator (%s) doesn't specify names",
operator->numeric,
__func__);
g_ril_reply_free_operator(operator);
continue;
}
if (operator->numeric == NULL) {
ofono_error("%s: operator (%s/%s) "
"doesn't specify numeric",
operator->lalpha,
operator->salpha,
__func__);
g_ril_reply_free_operator(operator);
continue;
}
if (operator->status == NULL) {
ofono_error("%s: operator (%s/%s) "
"doesn't specify status",
operator->lalpha,
operator->salpha,
__func__);
g_ril_reply_free_operator(operator);
continue;
}
reply->list = g_slist_append(reply->list, operator);
g_ril_append_print_buf(gril, "%s [lalpha=%s, salpha=%s, "
" numeric=%s status=%s tech=%s]",
print_buf,
operator->lalpha,
operator->salpha,
operator->numeric,
operator->status,
ril_radio_tech_to_string(operator->tech));
}
g_ril_append_print_buf(gril, "%s}", print_buf);
g_ril_print_response(gril, message);
return reply;
error:
if (reply)
g_ril_reply_free_avail_ops(reply);
return NULL;
}
void g_ril_reply_free_operator(struct reply_operator *reply)
{
ril_reply_free_operator(reply);

View File

@ -40,11 +40,6 @@ struct reply_operator {
int tech;
};
struct reply_avail_ops {
guint num_ops;
GSList *list;
};
struct reply_reg_state {
int status;
int lac;
@ -92,10 +87,6 @@ struct reply_oem_hook {
void *data;
};
void g_ril_reply_free_avail_ops(struct reply_avail_ops *reply);
struct reply_avail_ops *g_ril_reply_parse_avail_ops(GRil *gril,
const struct ril_msg *message);
void g_ril_reply_free_operator(struct reply_operator *reply);
struct reply_operator *g_ril_reply_parse_operator(GRil *gril,