summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libiphone/lockdown.h3
-rw-r--r--src/lockdown.c88
2 files changed, 91 insertions, 0 deletions
diff --git a/include/libiphone/lockdown.h b/include/libiphone/lockdown.h
index da684c6..f076cf2 100644
--- a/include/libiphone/lockdown.h
+++ b/include/libiphone/lockdown.h
@@ -44,6 +44,7 @@ extern "C" {
#define LOCKDOWN_E_GET_VALUE_PROHIBITED -10
#define LOCKDOWN_E_REMOVE_VALUE_PROHIBITED -11
#define LOCKDOWN_E_MUX_ERROR -12
+#define LOCKDOWN_E_ACTIVATION_FAILED -13
#define LOCKDOWN_E_UNKNOWN_ERROR -256
@@ -67,6 +68,8 @@ lockdownd_error_t lockdownd_recv(lockdownd_client_t client, plist_t *plist);
lockdownd_error_t lockdownd_pair(lockdownd_client_t client, char *host_id);
lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, char *host_id);
lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, char *host_id);
+lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record);
+lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client);
lockdownd_error_t lockdownd_get_device_uuid(lockdownd_client_t control, char **uuid);
lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name);
lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client);
diff --git a/src/lockdown.c b/src/lockdown.c
index c27cd59..6ddd7c0 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -1385,3 +1385,91 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
return ret;
}
+/**
+ * Activates the device. Only works within an open session.
+ * The ActivationRecord plist dictionary must be obtained using the
+ * activation protocol requesting from Apple's https webservice.
+ *
+ * @see http://iphone-docs.org/doku.php?id=docs:protocols:activation
+ *
+ * @param control The lockdown client
+ * @param activation_record The activation record plist dictionary
+ *
+ * @return an error code (LOCKDOWN_E_SUCCESS on success)
+ */
+lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record)
+{
+ if (!client)
+ return LOCKDOWN_E_INVALID_ARG;
+
+ if (!activation_record)
+ return LOCKDOWN_E_INVALID_ARG;
+
+ lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
+
+ plist_t dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
+ plist_dict_insert_item(dict,"Request", plist_new_string("Activate"));
+ plist_dict_insert_item(dict,"ActivationRecord", activation_record);
+
+ ret = lockdownd_send(client, dict);
+ plist_free(dict);
+ dict = NULL;
+
+ ret = lockdownd_recv(client, &dict);
+ if (!dict) {
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: LOCKDOWN_E_PLIST_ERROR\n", __func__);
+ return LOCKDOWN_E_PLIST_ERROR;
+ }
+
+ ret = LOCKDOWN_E_ACTIVATION_FAILED;
+ if (lockdown_check_result(dict, "Activate") == RESULT_SUCCESS) {
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__);
+ ret = LOCKDOWN_E_SUCCESS;
+ }
+ plist_free(dict);
+ dict = NULL;
+
+ return ret;
+}
+
+/**
+ * Deactivates the device, returning it to the locked
+ * “Activate with iTunes” screen.
+ *
+ * @param control The lockdown client
+ *
+ * @return an error code (LOCKDOWN_E_SUCCESS on success)
+ */
+lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client)
+{
+ if (!client)
+ return LOCKDOWN_E_INVALID_ARG;
+
+ lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
+
+ plist_t dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
+ plist_dict_insert_item(dict,"Request", plist_new_string("Deactivate"));
+
+ ret = lockdownd_send(client, dict);
+ plist_free(dict);
+ dict = NULL;
+
+ ret = lockdownd_recv(client, &dict);
+ if (!dict) {
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: LOCKDOWN_E_PLIST_ERROR\n", __func__);
+ return LOCKDOWN_E_PLIST_ERROR;
+ }
+
+ ret = LOCKDOWN_E_UNKNOWN_ERROR;
+ if (lockdown_check_result(dict, "Deactivate") == RESULT_SUCCESS) {
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__);
+ ret = LOCKDOWN_E_SUCCESS;
+ }
+ plist_free(dict);
+ dict = NULL;
+
+ return ret;
+}
+