summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-25 15:39:01 +0100
committerGravatar Martin Szulecki2010-01-25 15:39:01 +0100
commite5d42da1321fa6c29363c97188d7e6148083ae64 (patch)
tree8fe73e1f7d2f26d6eafc65c8ce65775307a7ee1f /tools
parentdb62ad45f6881a019dbd15ed8df799fd1c589476 (diff)
downloadlibimobiledevice-e5d42da1321fa6c29363c97188d7e6148083ae64.tar.gz
libimobiledevice-e5d42da1321fa6c29363c97188d7e6148083ae64.tar.bz2
Improve some code comments for iphonebackup
Diffstat (limited to 'tools')
-rw-r--r--tools/iphonebackup.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/iphonebackup.c b/tools/iphonebackup.c
index 789dd21..f7f1ff1 100644
--- a/tools/iphonebackup.c
+++ b/tools/iphonebackup.c
@@ -355,20 +355,20 @@ int main(int argc, char *argv[])
355 /* TODO: verify battery on AC enough battery remaining */ 355 /* TODO: verify battery on AC enough battery remaining */
356 356
357 /* create Info.plist (Device infos, IC-Info.sidb, photos, app_ids, iTunesPrefs) */ 357 /* create Info.plist (Device infos, IC-Info.sidb, photos, app_ids, iTunesPrefs) */
358 printf("Creating \"%s/Info.plist\".\n", backup_directory); 358 printf("Creating Info.plist.\n");
359 plist_t info_plist = mobilebackup_factory_info_plist_new(); 359 plist_t info_plist = mobilebackup_factory_info_plist_new();
360 if (stat(info_path, &st) == 0) 360 if (stat(info_path, &st) == 0)
361 remove(info_path); 361 remove(info_path);
362 plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML); 362 plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML);
363 g_free(info_path); 363 g_free(info_path);
364 364
365 /* close down the lockdown connection as it is no longer needed */
365 if (client) { 366 if (client) {
366 lockdownd_client_free(client); 367 lockdownd_client_free(client);
367 client = NULL; 368 client = NULL;
368 } 369 }
369 370
370 /* create Manifest.plist (backup manifest (backup state)) */ 371 /* create Manifest.plist (backup manifest (backup state)) */
371 printf("Creating \"%s/Manifest.plist\".\n", backup_directory);
372 char *manifest_path = g_build_path(G_DIR_SEPARATOR_S, backup_directory, "Manifest.plist", NULL); 372 char *manifest_path = g_build_path(G_DIR_SEPARATOR_S, backup_directory, "Manifest.plist", NULL);
373 /* FIXME: We should read the last Manifest.plist and send it to the device */ 373 /* FIXME: We should read the last Manifest.plist and send it to the device */
374 plist_t manifest_plist = NULL; 374 plist_t manifest_plist = NULL;
@@ -379,7 +379,7 @@ int main(int argc, char *argv[])
379 mobilebackup_write_status(backup_directory, 0); 379 mobilebackup_write_status(backup_directory, 0);
380 380
381 /* request backup from device with manifest from last backup */ 381 /* request backup from device with manifest from last backup */
382 printf("Sending manifest and requesting backup.\n"); 382 printf("Requesting backup from device...\n");
383 383
384 node = plist_new_dict(); 384 node = plist_new_dict();
385 if (manifest_plist) 385 if (manifest_plist)
@@ -513,8 +513,9 @@ int main(int argc, char *argv[])
513 node_tmp = plist_array_get_item(message, 1); 513 node_tmp = plist_array_get_item(message, 1);
514 plist_get_data_val(node_tmp, &buffer, &length); 514 plist_get_data_val(node_tmp, &buffer, &length);
515 515
516 /* activate currently sent manifest */
517 buffer_to_filename(filename_mddata, buffer, length); 516 buffer_to_filename(filename_mddata, buffer, length);
517
518 /* activate currently sent manifest */
518 if ((c == 2) && (is_manifest)) { 519 if ((c == 2) && (is_manifest)) {
519 rename(filename_mddata, manifest_path); 520 rename(filename_mddata, manifest_path);
520 } 521 }
@@ -558,7 +559,7 @@ int main(int argc, char *argv[])
558 if (!plist_strcmp(node, "DLMessageProcessMessage")) { 559 if (!plist_strcmp(node, "DLMessageProcessMessage")) {
559 node_tmp = plist_array_get_item(message, 1); 560 node_tmp = plist_array_get_item(message, 1);
560 node = plist_dict_get_item(node_tmp, "BackupMessageTypeKey"); 561 node = plist_dict_get_item(node_tmp, "BackupMessageTypeKey");
561 /* wait until received final backup finished message */ 562 /* check if we received the final "backup finished" message */
562 if (node && !plist_strcmp(node, "BackupMessageBackupFinished")) { 563 if (node && !plist_strcmp(node, "BackupMessageBackupFinished")) {
563 /* backup finished */ 564 /* backup finished */
564 565
@@ -590,12 +591,13 @@ int main(int argc, char *argv[])
590 } 591 }
591 } 592 }
592 593
593 /* save new Manifest.plist */ 594 /* save last valid Manifest.plist */
594 node_tmp = plist_array_get_item(message, 1); 595 node_tmp = plist_array_get_item(message, 1);
595 manifest_plist = plist_dict_get_item(node_tmp, "BackupManifestKey"); 596 manifest_plist = plist_dict_get_item(node_tmp, "BackupManifestKey");
596 if (manifest_plist) { 597 if (manifest_plist) {
597 if (stat(manifest_path, &st) != 0) 598 if (stat(manifest_path, &st) != 0)
598 remove(manifest_path); 599 remove(manifest_path);
600 printf("Storing Manifest.plist...\n");
599 plist_write_to_filename(manifest_plist, manifest_path, PLIST_FORMAT_XML); 601 plist_write_to_filename(manifest_plist, manifest_path, PLIST_FORMAT_XML);
600 } 602 }
601 603