/** * Disconnects a screenshotr client from the device and frees up the * screenshotr client data. * * @param client The screenshotr client to disconnect and free. * * @return SCREENSHOTR_E_SUCCESS on success, or SCREENSHOTR_E_INVALID_ARG * if client is NULL. */ screenshotr_error_t screenshotr_client_free(screenshotr_client_t client) { if (!client) return SCREENSHOTR_E_INVALID_ARG; device_link_service_disconnect(client->parent, NULL); screenshotr_error_t err = screenshotr_error(device_link_service_client_free(client->parent)); free(client); return err; }
/** * Disconnects a mobilesync client from the device and frees up the * mobilesync client data. * * @param client The mobilesync client to disconnect and free. * * @retval MOBILESYNC_E_SUCCESS on success * @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL. */ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client) { if (!client) return MOBILESYNC_E_INVALID_ARG; device_link_service_disconnect(client->parent, "All done, thanks for the memories"); mobilesync_error_t err = mobilesync_error(device_link_service_client_free(client->parent)); free(client); return err; }
/** * Disconnects a mobilebackup2 client from the device and frees up the * mobilebackup2 client data. * * @param client The mobilebackup2 client to disconnect and free. * * @return MOBILEBACKUP2_E_SUCCESS on success, or MOBILEBACKUP2_E_INVALID_ARG * if client is NULL. */ mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client) { if (!client) return MOBILEBACKUP2_E_INVALID_ARG; mobilebackup2_error_t err = MOBILEBACKUP2_E_SUCCESS; if (client->parent) { device_link_service_disconnect(client->parent, NULL); err = mobilebackup2_error(device_link_service_client_free(client->parent)); } free(client); return err; }
/** * Tells the device that the restore process is complete and waits for the * device to close the connection. After that, the device should reboot. * * @param client The connected MobileBackup client to use. * * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if * client is invalid, MOBILEBACKUP_E_PLIST_ERROR if the received disconnect * message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication * error occurs. */ mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client) { mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL); if (err != MOBILEBACKUP_E_SUCCESS) { return err; } plist_t dlmsg = NULL; err = mobilebackup_receive(client, &dlmsg); if ((err != MOBILEBACKUP_E_SUCCESS) || !dlmsg || (plist_get_node_type(dlmsg) != PLIST_ARRAY) || (plist_array_get_size(dlmsg) != 2)) { if (dlmsg) { debug_info("ERROR: Did not receive DLMessageDisconnect:"); debug_plist(dlmsg); plist_free(dlmsg); } if (err == MOBILEBACKUP_E_SUCCESS) { err = MOBILEBACKUP_E_PLIST_ERROR; } return err; } plist_t node = plist_array_get_item (dlmsg, 0); char *msg = NULL; if (node && (plist_get_node_type(node) == PLIST_STRING)) { plist_get_string_val(node, &msg); } if (msg && !strcmp(msg, "DLMessageDisconnect")) { err = MOBILEBACKUP_E_SUCCESS; /* we need to do this here, otherwise mobilebackup_client_free will fail */ device_link_service_client_free(client->parent); client->parent = NULL; } else { debug_info("ERROR: Malformed plist received:"); debug_plist(dlmsg); err = MOBILEBACKUP_E_PLIST_ERROR; } plist_free(dlmsg); if (msg) free(msg); return err; }