diff options
Diffstat (limited to 'src/lockdown.c')
| -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 | |||
| 1385 | return ret; | 1385 | return ret; |
| 1386 | } | 1386 | } |
| 1387 | 1387 | ||
| 1388 | /** | ||
| 1389 | * Activates the device. Only works within an open session. | ||
| 1390 | * The ActivationRecord plist dictionary must be obtained using the | ||
| 1391 | * activation protocol requesting from Apple's https webservice. | ||
| 1392 | * | ||
| 1393 | * @see http://iphone-docs.org/doku.php?id=docs:protocols:activation | ||
| 1394 | * | ||
| 1395 | * @param control The lockdown client | ||
| 1396 | * @param activation_record The activation record plist dictionary | ||
| 1397 | * | ||
| 1398 | * @return an error code (LOCKDOWN_E_SUCCESS on success) | ||
| 1399 | */ | ||
| 1400 | lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record) | ||
| 1401 | { | ||
| 1402 | if (!client) | ||
| 1403 | return LOCKDOWN_E_INVALID_ARG; | ||
| 1404 | |||
| 1405 | if (!activation_record) | ||
| 1406 | return LOCKDOWN_E_INVALID_ARG; | ||
| 1407 | |||
| 1408 | lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; | ||
| 1409 | |||
| 1410 | plist_t dict = plist_new_dict(); | ||
| 1411 | plist_dict_add_label(dict, client->label); | ||
| 1412 | plist_dict_insert_item(dict,"Request", plist_new_string("Activate")); | ||
| 1413 | plist_dict_insert_item(dict,"ActivationRecord", activation_record); | ||
| 1414 | |||
| 1415 | ret = lockdownd_send(client, dict); | ||
| 1416 | plist_free(dict); | ||
| 1417 | dict = NULL; | ||
| 1418 | |||
| 1419 | ret = lockdownd_recv(client, &dict); | ||
| 1420 | if (!dict) { | ||
| 1421 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: LOCKDOWN_E_PLIST_ERROR\n", __func__); | ||
| 1422 | return LOCKDOWN_E_PLIST_ERROR; | ||
| 1423 | } | ||
| 1424 | |||
| 1425 | ret = LOCKDOWN_E_ACTIVATION_FAILED; | ||
| 1426 | if (lockdown_check_result(dict, "Activate") == RESULT_SUCCESS) { | ||
| 1427 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__); | ||
| 1428 | ret = LOCKDOWN_E_SUCCESS; | ||
| 1429 | } | ||
| 1430 | plist_free(dict); | ||
| 1431 | dict = NULL; | ||
| 1432 | |||
| 1433 | return ret; | ||
| 1434 | } | ||
| 1435 | |||
| 1436 | /** | ||
| 1437 | * Deactivates the device, returning it to the locked | ||
| 1438 | * “Activate with iTunes” screen. | ||
| 1439 | * | ||
| 1440 | * @param control The lockdown client | ||
| 1441 | * | ||
| 1442 | * @return an error code (LOCKDOWN_E_SUCCESS on success) | ||
| 1443 | */ | ||
| 1444 | lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client) | ||
| 1445 | { | ||
| 1446 | if (!client) | ||
| 1447 | return LOCKDOWN_E_INVALID_ARG; | ||
| 1448 | |||
| 1449 | lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; | ||
| 1450 | |||
| 1451 | plist_t dict = plist_new_dict(); | ||
| 1452 | plist_dict_add_label(dict, client->label); | ||
| 1453 | plist_dict_insert_item(dict,"Request", plist_new_string("Deactivate")); | ||
| 1454 | |||
| 1455 | ret = lockdownd_send(client, dict); | ||
| 1456 | plist_free(dict); | ||
| 1457 | dict = NULL; | ||
| 1458 | |||
| 1459 | ret = lockdownd_recv(client, &dict); | ||
| 1460 | if (!dict) { | ||
| 1461 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: LOCKDOWN_E_PLIST_ERROR\n", __func__); | ||
| 1462 | return LOCKDOWN_E_PLIST_ERROR; | ||
| 1463 | } | ||
| 1464 | |||
| 1465 | ret = LOCKDOWN_E_UNKNOWN_ERROR; | ||
| 1466 | if (lockdown_check_result(dict, "Deactivate") == RESULT_SUCCESS) { | ||
| 1467 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__); | ||
| 1468 | ret = LOCKDOWN_E_SUCCESS; | ||
| 1469 | } | ||
| 1470 | plist_free(dict); | ||
| 1471 | dict = NULL; | ||
| 1472 | |||
| 1473 | return ret; | ||
| 1474 | } | ||
| 1475 | |||
