diff options
author | Martin Szulecki | 2010-01-08 20:22:47 +0100 |
---|---|---|
committer | Martin Szulecki | 2010-01-08 20:22:47 +0100 |
commit | 3d157a4762119e28433003e42f4af469e32ba860 (patch) | |
tree | 5ab48137b18036dc87a11451168d4116e8f0b8c5 /src | |
parent | 9cc97faebcaabd6af2f9cc9280ba6a0f8cd85e60 (diff) | |
download | libimobiledevice-3d157a4762119e28433003e42f4af469e32ba860.tar.gz libimobiledevice-3d157a4762119e28433003e42f4af469e32ba860.tar.bz2 |
Implement lockdown activate and deactive
Passing the right activiation record allows activating a phone using
this functionality.
Diffstat (limited to 'src')
-rw-r--r-- | src/lockdown.c | 88 |
1 files changed, 88 insertions, 0 deletions
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; +} + |