forked from mirrors/lpac
[Breaking Change] libeuicc use more string in datastruct
This commit is contained in:
parent
c02c2d08ec
commit
88ed7b2521
6 changed files with 86 additions and 25 deletions
|
@ -577,7 +577,21 @@ int es10b_list_notification(struct euicc_ctx *ctx, struct es10b_notification_met
|
|||
memset(metadata, 0, sizeof(*metadata));
|
||||
asn_INTEGER2ulong(&asn1metadata->seqNumber, &metadata->seqNumber);
|
||||
|
||||
metadata->profileManagementOperation = asn1metadata->profileManagementOperation.buf[0];
|
||||
switch (asn1metadata->profileManagementOperation.buf[0])
|
||||
{
|
||||
case 128:
|
||||
metadata->profileManagementOperation = strdup("install");
|
||||
break;
|
||||
case 64:
|
||||
metadata->profileManagementOperation = strdup("enable");
|
||||
break;
|
||||
case 32:
|
||||
metadata->profileManagementOperation = strdup("disable");
|
||||
break;
|
||||
case 16:
|
||||
metadata->profileManagementOperation = strdup("delete");
|
||||
break;
|
||||
}
|
||||
|
||||
metadata->notificationAddress = malloc(asn1metadata->notificationAddress.size + 1);
|
||||
if (metadata->notificationAddress)
|
||||
|
@ -951,6 +965,7 @@ void es10b_notification_metadata_free_all(struct es10b_notification_metadata *me
|
|||
}
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
free(metadatas[i].profileManagementOperation);
|
||||
free(metadatas[i].notificationAddress);
|
||||
free(metadatas[i].iccid);
|
||||
}
|
||||
|
@ -960,7 +975,7 @@ void es10b_notification_metadata_free_all(struct es10b_notification_metadata *me
|
|||
void es10b_notification_metadata_print(struct es10b_notification_metadata *n)
|
||||
{
|
||||
printf("\tseqNumber: %ld\n", n->seqNumber);
|
||||
printf("\tprofileManagementOperation: %d\n", n->profileManagementOperation);
|
||||
printf("\tprofileManagementOperation: %s\n", n->profileManagementOperation);
|
||||
printf("\tnotificationAddress: %s\n", n->notificationAddress ? n->notificationAddress : "(null)");
|
||||
printf("\ticcid: %s\n", n->iccid ? n->iccid : "(null)");
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ struct es10b_prepare_download_param
|
|||
struct es10b_notification_metadata
|
||||
{
|
||||
unsigned long seqNumber;
|
||||
unsigned char profileManagementOperation;
|
||||
char *profileManagementOperation;
|
||||
char *notificationAddress;
|
||||
char *iccid;
|
||||
};
|
||||
|
|
|
@ -104,12 +104,45 @@ int es10c_get_profiles_info(struct euicc_ctx *ctx, struct es10c_profile_info **p
|
|||
|
||||
if (asn1p->profileState)
|
||||
{
|
||||
asn_INTEGER2ulong(asn1p->profileState, &p->profileState);
|
||||
long profileState;
|
||||
|
||||
asn_INTEGER2long(asn1p->profileState, &profileState);
|
||||
|
||||
switch (profileState)
|
||||
{
|
||||
case ES10C_PROFILE_INFO_STATE_DISABLED:
|
||||
p->profileState = strdup("disabled");
|
||||
break;
|
||||
case ES10C_PROFILE_INFO_STATE_ENABLED:
|
||||
p->profileState = strdup("enabled");
|
||||
break;
|
||||
default:
|
||||
p->profileState = strdup("unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (asn1p->profileClass)
|
||||
{
|
||||
asn_INTEGER2ulong(asn1p->profileClass, &p->profileClass);
|
||||
long profileClass;
|
||||
|
||||
asn_INTEGER2long(asn1p->profileClass, &profileClass);
|
||||
|
||||
switch (profileClass)
|
||||
{
|
||||
case ES10C_PROFILE_INFO_CLASS_TEST:
|
||||
p->profileClass = strdup("test");
|
||||
break;
|
||||
case ES10C_PROFILE_INFO_CLASS_PROVISIONING:
|
||||
p->profileClass = strdup("provisioning");
|
||||
break;
|
||||
case ES10C_PROFILE_INFO_CLASS_OPERATIONAL:
|
||||
p->profileClass = strdup("operational");
|
||||
break;
|
||||
default:
|
||||
p->profileClass = strdup("unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (asn1p->profileNickname)
|
||||
|
@ -142,10 +175,28 @@ int es10c_get_profiles_info(struct euicc_ctx *ctx, struct es10c_profile_info **p
|
|||
}
|
||||
}
|
||||
|
||||
p->iconType = ES10C_ICON_TYPE_INVALID;
|
||||
if (asn1p->iconType)
|
||||
{
|
||||
asn_INTEGER2long(asn1p->iconType, &p->iconType);
|
||||
long iconType;
|
||||
|
||||
asn_INTEGER2long(asn1p->iconType, &iconType);
|
||||
|
||||
switch (iconType)
|
||||
{
|
||||
case ES10C_ICON_TYPE_JPEG:
|
||||
p->iconType = strdup("jpeg");
|
||||
break;
|
||||
case ES10C_ICON_TYPE_PNG:
|
||||
p->iconType = strdup("png");
|
||||
break;
|
||||
default:
|
||||
p->iconType = strdup("unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p->iconType = strdup("none");
|
||||
}
|
||||
|
||||
if (asn1p->icon)
|
||||
|
@ -155,10 +206,6 @@ int es10c_get_profiles_info(struct euicc_ctx *ctx, struct es10c_profile_info **p
|
|||
{
|
||||
euicc_base64_encode(p->icon, asn1p->icon->buf, asn1p->icon->size);
|
||||
}
|
||||
else
|
||||
{
|
||||
p->iconType = ES10C_ICON_TYPE_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -880,9 +927,12 @@ void es10c_profile_info_free_all(struct es10c_profile_info *profiles, int count)
|
|||
}
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
free(profiles[i].profileState);
|
||||
free(profiles[i].profileClass);
|
||||
free(profiles[i].profileNickname);
|
||||
free(profiles[i].serviceProviderName);
|
||||
free(profiles[i].profileName);
|
||||
free(profiles[i].iconType);
|
||||
free(profiles[i].icon);
|
||||
}
|
||||
free(profiles);
|
||||
|
@ -892,10 +942,9 @@ void es10c_profile_info_print(struct es10c_profile_info *p)
|
|||
{
|
||||
printf("\ticcid: %s\n", p->iccid);
|
||||
printf("\tisdpAid: %s\n", p->isdpAid);
|
||||
printf("\tprofileState: %s\n", p->profileState ? "Enabled" : "Disabled");
|
||||
printf("\tprofileState: %s\n", p->profileState);
|
||||
printf("\tprofileNickname: %s\n", p->profileNickname ? p->profileNickname : "(null)");
|
||||
printf("\tserviceProviderName: %s\n", p->serviceProviderName ? p->serviceProviderName : "(null)");
|
||||
printf("\tprofileName: %s\n", p->profileName ? p->profileName : "(null)");
|
||||
printf("\tprofileClass: %s\n", p->profileClass == ES10C_PROFILE_INFO_CLASS_TEST ? "Test" : p->profileClass == ES10C_PROFILE_INFO_CLASS_PROVISIONING ? "Provisioning"
|
||||
: "Operational");
|
||||
printf("\tprofileClass: %s\n", p->profileClass);
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ struct es10c_profile_info
|
|||
{
|
||||
char iccid[(10 * 2) + 1];
|
||||
char isdpAid[(16 * 2) + 1];
|
||||
unsigned long profileState;
|
||||
unsigned long profileClass;
|
||||
char *profileState;
|
||||
char *profileClass;
|
||||
char *profileNickname;
|
||||
char *serviceProviderName;
|
||||
char *profileName;
|
||||
long iconType;
|
||||
char *iconType;
|
||||
char *icon;
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ static int applet_main(int argc, char **argv)
|
|||
|
||||
jnotification = cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(jnotification, "seqNumber", notifications[i].seqNumber);
|
||||
cJSON_AddNumberToObject(jnotification, "profileManagementOperation", notifications[i].profileManagementOperation);
|
||||
cJSON_AddStringToObject(jnotification, "profileManagementOperation", notifications[i].profileManagementOperation);
|
||||
cJSON_AddStringToObject(jnotification, "notificationAddress", notifications[i].notificationAddress);
|
||||
cJSON_AddStringToObject(jnotification, "iccid", notifications[i].iccid);
|
||||
|
||||
|
|
|
@ -25,16 +25,13 @@ static int applet_main(int argc, char **argv)
|
|||
jprofile = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(jprofile, "iccid", profiles[i].iccid);
|
||||
cJSON_AddStringToObject(jprofile, "isdpAid", profiles[i].isdpAid);
|
||||
cJSON_AddNumberToObject(jprofile, "profileState", profiles[i].profileState);
|
||||
cJSON_AddStringToObject(jprofile, "profileState", profiles[i].profileState);
|
||||
cJSON_AddStringToObject(jprofile, "profileNickname", profiles[i].profileNickname);
|
||||
cJSON_AddStringToObject(jprofile, "serviceProviderName", profiles[i].serviceProviderName);
|
||||
cJSON_AddStringToObject(jprofile, "profileName", profiles[i].profileName);
|
||||
if (profiles[i].iconType != ES10C_ICON_TYPE_INVALID)
|
||||
{
|
||||
cJSON_AddNumberToObject(jprofile, "iconType", profiles[i].iconType);
|
||||
cJSON_AddStringToObject(jprofile, "icon", profiles[i].icon);
|
||||
}
|
||||
cJSON_AddNumberToObject(jprofile, "profileClass", profiles[i].profileClass);
|
||||
cJSON_AddStringToObject(jprofile, "iconType", profiles[i].iconType);
|
||||
cJSON_AddStringToObject(jprofile, "icon", profiles[i].icon);
|
||||
cJSON_AddStringToObject(jprofile, "profileClass", profiles[i].profileClass);
|
||||
cJSON_AddItemToArray(jdata, jprofile);
|
||||
}
|
||||
es10c_profile_info_free_all(profiles, profiles_count);
|
||||
|
|
Loading…
Add table
Reference in a new issue