-
-
Save nikias/a8f82602453a5ff0554af61118072ba1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/libideviceactivation.h b/include/libideviceactivation.h | |
index 58997bb..de5d3a2 100644 | |
--- a/include/libideviceactivation.h | |
+++ b/include/libideviceactivation.h | |
@@ -83,6 +83,7 @@ void idevice_activation_response_get_label(idevice_activation_response_t respons | |
void idevice_activation_response_get_title(idevice_activation_response_t response, const char** title); | |
void idevice_activation_response_get_description(idevice_activation_response_t response, const char** description); | |
void idevice_activation_response_get_activation_record(idevice_activation_response_t response, plist_t* activation_record); | |
+void idevice_activation_response_get_headers(idevice_activation_response_t response, plist_t* headers); | |
int idevice_activation_response_is_activation_acknowledged(idevice_activation_response_t response); | |
int idevice_activation_response_is_authentication_required(idevice_activation_response_t response); | |
diff --git a/src/activation.c b/src/activation.c | |
index 0a56dc7..c6d0c32 100644 | |
--- a/src/activation.c | |
+++ b/src/activation.c | |
@@ -78,6 +78,7 @@ struct idevice_activation_response_private { | |
char* title; | |
char* description; | |
plist_t activation_record; | |
+ plist_t headers; | |
plist_t fields; | |
plist_t fields_require_input; | |
plist_t labels; | |
@@ -548,15 +549,42 @@ static size_t idevice_activation_header_callback(void *data, size_t size, size_t | |
idevice_activation_response_t response = (idevice_activation_response_t)userdata; | |
const size_t total = size * nmemb; | |
if (total != 0) { | |
- if (strstr(data, "Content-Type: text/xml") != NULL) { | |
- response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_PLIST; | |
- } else if (strstr(data, "Content-Type: application/xml") != NULL) { | |
- response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_PLIST; | |
- } else if (strstr(data, "Content-Type: application/x-buddyml") != NULL) { | |
- response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_BUDDYML; | |
- } else if (strstr(data, "Content-Type: text/html") != NULL) { | |
- response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_HTML; | |
+ char *header = malloc(total + 1); | |
+ char *value = NULL; | |
+ char *p = NULL; | |
+ memcpy(header, data, total); | |
+ header[total] = '\0'; | |
+ | |
+ p = strchr(header, ':'); | |
+ if (p) { | |
+ *p = '\0'; | |
+ p++; | |
+ while (*p == ' ') { | |
+ p++; | |
+ } | |
+ if (*p != '\0') { | |
+ value = p; | |
+ while (*p != '\0' && *p != '\n' && *p != '\r') { | |
+ p++; | |
+ } | |
+ *p = '\0'; | |
+ } | |
+ } | |
+ if (value) { | |
+ if (strcmp(header, "Content-Type") == 0) { | |
+ if (strcmp(value, "text/xml") == 0) { | |
+ response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_PLIST; | |
+ } else if (strcmp(value, "application/xml") == 0) { | |
+ response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_PLIST; | |
+ } else if (strcmp(value, "application/x-buddyml") == 0) { | |
+ response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_BUDDYML; | |
+ } else if (strcmp(value, "text/html") == 0) { | |
+ response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_HTML; | |
+ } | |
+ } | |
+ plist_dict_set_item(response->headers, header, plist_new_string(value)); | |
} | |
+ free(header); | |
} | |
return total; | |
} | |
@@ -929,6 +957,7 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_ne | |
tmp_response->title = NULL; | |
tmp_response->description = NULL; | |
tmp_response->activation_record = NULL; | |
+ tmp_response->headers = plist_new_dict(); | |
tmp_response->fields = plist_new_dict(); | |
tmp_response->fields_require_input = plist_new_dict(); | |
tmp_response->labels = plist_new_dict(); | |
@@ -1005,6 +1034,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_free(idevice_activation_ | |
free(response->title); | |
free(response->description); | |
plist_free(response->activation_record); | |
+ plist_free(response->headers); | |
plist_free(response->fields); | |
plist_free(response->fields_require_input); | |
plist_free(response->labels); | |
@@ -1071,6 +1101,14 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_activation_record(id | |
} | |
} | |
+IDEVICE_ACTIVATION_API void idevice_activation_response_get_headers(idevice_activation_response_t response, plist_t* headers) | |
+{ | |
+ if (!response || !headers) | |
+ return; | |
+ | |
+ *headers = plist_copy(response->headers); | |
+} | |
+ | |
IDEVICE_ACTIVATION_API int idevice_activation_response_is_activation_acknowledged(idevice_activation_response_t response) | |
{ | |
if (!response) | |
diff --git a/tools/ideviceactivation.c b/tools/ideviceactivation.c | |
index f54ce1f..561450c 100644 | |
--- a/tools/ideviceactivation.c | |
+++ b/tools/ideviceactivation.c | |
@@ -361,11 +361,15 @@ int main(int argc, char *argv[]) | |
} | |
if (session_mode) { | |
- if (MOBILEACTIVATION_E_SUCCESS != mobileactivation_activate_with_session(ma, record)) { | |
+ plist_t headers = NULL; | |
+ idevice_activation_response_get_headers(response, &headers); | |
+ if (MOBILEACTIVATION_E_SUCCESS != mobileactivation_activate_with_session(ma, record, headers)) { | |
+ plist_free(headers); | |
fprintf(stderr, "Failed to activate device with record.\n"); | |
result = EXIT_FAILURE; | |
goto cleanup; | |
} | |
+ plist_free(headers); | |
} else { | |
if (MOBILEACTIVATION_E_SUCCESS != mobileactivation_activate(ma, record)) { | |
fprintf(stderr, "Failed to activate device with record.\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment