Skip to content
Snippets Groups Projects
Commit 0e7bafce authored by Jakob Olsson's avatar Jakob Olsson
Browse files

libmobile_zte: change get_apn_profile_by_name to function based on new array-based profile list

parent 076f2d9d
No related branches found
No related tags found
No related merge requests found
......@@ -434,27 +434,40 @@ fail:
struct json_object *mobile_get_apn_profile_by_name_zte(char *ip_addr, char *name)
{
struct json_object *apn_profiles, *apn_profile = NULL;
int idx, counter = 0, rv;
struct json_object *container, *profiles, *profile, *apn_name, *rv = NULL;
int i;
apn_profiles = mobile_get_apn_profiles_zte(ip_addr);
if (!apn_profiles)
container = mobile_get_apn_profiles_zte(ip_addr);
if (!container)
goto fail;
json_object_object_foreach(apn_profiles, key, val) {
json_object_object_foreach(val, inner_key, inner_val) {
if (strncmp(name, json_object_get_string(inner_val), 1024) != 0)
continue;
json_object_object_get_ex(container, "profiles", &profiles);
if (!profiles)
goto fail_profiles;
json_object_get(inner_val);
apn_profile = inner_val;
break;
}
for (i = 0; i < json_object_array_length(profiles); i++) {
profile = json_object_array_get_idx(profiles, i);
json_object_object_get_ex(profile, "profile", &profile);
if (!profile)
continue;
json_object_object_get_ex(profile, "name", &apn_name);
if (!apn_name)
continue;
if (strncmp(name, json_object_get_string(apn_name), 1024) != 0)
continue;
json_object_get(profile);
rv = profile;
break;
}
json_object_put(apn_profiles);
fail_profiles:
json_object_put(container);
fail:
return apn_profile;
return rv;
}
struct json_object *mobile_get_remaining_tries_zte(char *ip_addr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment