From 96101a1231a4ddfeb40fd738a24e108a3a904048 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 28 Jan 2010 22:18:41 +0100 Subject: Global renames due to project rename to libimobiledevice --- dev/Makefile.am | 24 ++--- dev/afccheck.c | 24 ++--- dev/filerelaytest.c | 16 +-- dev/ideviceclient.c | 252 +++++++++++++++++++++++++++++++++++++++++++++ dev/ideviceenterrecovery.c | 93 +++++++++++++++++ dev/iphoneclient.c | 252 --------------------------------------------- dev/iphoneenterrecovery.c | 93 ----------------- dev/lckdclient.c | 18 ++-- dev/msync.py | 4 +- dev/msyncclient.c | 20 ++-- 10 files changed, 398 insertions(+), 398 deletions(-) create mode 100644 dev/ideviceclient.c create mode 100644 dev/ideviceenterrecovery.c delete mode 100644 dev/iphoneclient.c delete mode 100644 dev/iphoneenterrecovery.c (limited to 'dev') diff --git a/dev/Makefile.am b/dev/Makefile.am index 1ca15e5..9b3ec6a 100644 --- a/dev/Makefile.am +++ b/dev/Makefile.am @@ -4,36 +4,36 @@ AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_C AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) if ENABLE_DEVTOOLS -noinst_PROGRAMS = iphoneclient lckd-client afccheck msyncclient iphoneenterrecovery filerelaytest +noinst_PROGRAMS = ideviceclient lckd-client afccheck msyncclient ideviceenterrecovery filerelaytest -iphoneclient_SOURCES = iphoneclient.c -iphoneclient_LDADD = ../src/libiphone.la +ideviceclient_SOURCES = ideviceclient.c +ideviceclient_LDADD = ../src/libimobiledevice.la lckd_client_SOURCES = lckdclient.c lckd_client_CFLAGS = $(AM_CFLAGS) lckd_client_LDFLAGS = -lreadline $(AM_LDFLAGS) -lckd_client_LDADD = ../src/libiphone.la +lckd_client_LDADD = ../src/libimobiledevice.la afccheck_SOURCES = afccheck.c afccheck_CFLAGS = $(AM_CFLAGS) afccheck_LDFLAGS = $(AM_LDFLAGS) -afccheck_LDADD = ../src/libiphone.la +afccheck_LDADD = ../src/libimobiledevice.la msyncclient_SOURCES = msyncclient.c msyncclient_CFLAGS = $(AM_CFLAGS) msyncclient_LDFLAGS = $(AM_LDFLAGS) -msyncclient_LDADD = ../src/libiphone.la +msyncclient_LDADD = ../src/libimobiledevice.la -iphoneenterrecovery_SOURCES = iphoneenterrecovery.c -iphoneenterrecovery_CFLAGS = $(AM_CFLAGS) -iphoneenterrecovery_LDFLAGS = $(AM_LDFLAGS) -iphoneenterrecovery_LDADD = ../src/libiphone.la +ideviceenterrecovery_SOURCES = ideviceenterrecovery.c +ideviceenterrecovery_CFLAGS = $(AM_CFLAGS) +ideviceenterrecovery_LDFLAGS = $(AM_LDFLAGS) +ideviceenterrecovery_LDADD = ../src/libimobiledevice.la filerelaytest_SOURCES = filerelaytest.c filerelaytest_CFLAGS = $(AM_CFLAGS) filerelaytest_LDFLAGS = $(AM_LDFLAGS) -filerelaytest_LDADD = ../src/libiphone.la +filerelaytest_LDADD = ../src/libimobiledevice.la endif # ENABLE_DEVTOOLS -EXTRA_DIST = iphoneclient.c lckdclient.c afccheck.c msyncclient.c iphoneenterrecovery.c +EXTRA_DIST = ideviceclient.c lckdclient.c afccheck.c msyncclient.c ideviceenterrecovery.c diff --git a/dev/afccheck.c b/dev/afccheck.c index 569acf1..b4d8910 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -24,9 +24,9 @@ #include #include -#include -#include -#include +#include +#include +#include #define BUFFER_SIZE 20000 #define NB_THREADS 10 @@ -53,7 +53,7 @@ static void check_afc(gpointer data) buf[i] = ((param *) data)->id * i; } - //now writes buffer on iphone + //now writes buffer on device uint64_t file = 0; char path[50]; sprintf(path, "/Buf%i", ((param *) data)->id); @@ -91,30 +91,30 @@ static void check_afc(gpointer data) int main(int argc, char *argv[]) { lockdownd_client_t client = NULL; - iphone_device_t phone = NULL; + idevice_t phone = NULL; GError *err; uint16_t port = 0; afc_client_t afc = NULL; if (argc > 1 && !strcasecmp(argv[1], "--debug")) { - iphone_set_debug_level(1); + idevice_set_debug_level(1); } else { - iphone_set_debug_level(0); + idevice_set_debug_level(0); } - if (IPHONE_E_SUCCESS != iphone_device_new(&phone, NULL)) { - printf("No iPhone found, is it plugged in?\n"); + if (IDEVICE_E_SUCCESS != idevice_new(&phone, NULL)) { + printf("No device found, is it plugged in?\n"); return 1; } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "afccheck")) { - iphone_device_free(phone); + idevice_free(phone); return 1; } if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { lockdownd_client_free(client); - iphone_device_free(phone); + idevice_free(phone); fprintf(stderr, "Something went wrong when starting AFC."); return 1; } @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) } lockdownd_client_free(client); - iphone_device_free(phone); + idevice_free(phone); return 0; } diff --git a/dev/filerelaytest.c b/dev/filerelaytest.c index f7e0d07..caaa491 100644 --- a/dev/filerelaytest.c +++ b/dev/filerelaytest.c @@ -19,17 +19,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { - iphone_device_t dev = NULL; + idevice_t dev = NULL; lockdownd_client_t client = NULL; file_relay_client_t frc = NULL; - if (iphone_device_new(&dev, NULL) != IPHONE_E_SUCCESS) { + if (idevice_new(&dev, NULL) != IDEVICE_E_SUCCESS) { printf("no device connected?!\n"); goto leave_cleanup; } @@ -56,7 +56,7 @@ int main(int argc, char **argv) goto leave_cleanup; } - iphone_connection_t dump = NULL; + idevice_connection_t dump = NULL; const char *sources[] = {"AppleSupport", "Network", "VPN", "WiFi", "UserDatabases", "CrashReporter", "tmp", "SystemConfiguration", NULL}; printf("Requesting"); @@ -83,7 +83,7 @@ int main(int argc, char **argv) FILE *f = fopen("dump.cpio.gz", "w"); setbuf(stdout, NULL); printf("receiving "); - while (iphone_connection_receive(dump, buf, 4096, &len) == IPHONE_E_SUCCESS) { + while (idevice_connection_receive(dump, buf, 4096, &len) == IDEVICE_E_SUCCESS) { fwrite(buf, 1, len, f); cnt += len; printf(".", len); @@ -101,7 +101,7 @@ leave_cleanup: lockdownd_client_free(client); } if (dev) { - iphone_device_free(dev); + idevice_free(dev); } return 0; diff --git a/dev/ideviceclient.c b/dev/ideviceclient.c new file mode 100644 index 0000000..2ed93d2 --- /dev/null +++ b/dev/ideviceclient.c @@ -0,0 +1,252 @@ +/* + * main.c + * Test program for testing several services. + * + * Copyright (c) 2008 Zach C. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +static void notifier(const char *notification) +{ + printf("---------------------------------------------------------\n"); + printf("------> Notification received: %s\n", notification); + printf("---------------------------------------------------------\n"); +} + +static void perform_notification(idevice_t phone, lockdownd_client_t client, const char *notification) +{ + uint16_t nport = 0; + np_client_t np; + + lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); + if (nport) { + printf("::::::::::::::: np was started ::::::::::::\n"); + np_client_new(phone, nport, &np); + if (np) { + printf("::::::::: PostNotification %s\n", notification); + np_post_notification(np, notification); + np_client_free(np); + } + } else { + printf("::::::::::::::: np was NOT started ::::::::::::\n"); + } +} + +int main(int argc, char *argv[]) +{ + unsigned int bytes = 0; + uint16_t port = 0, i = 0; + uint16_t npp; + lockdownd_client_t client = NULL; + idevice_t phone = NULL; + uint64_t lockfile = 0; + np_client_t gnp = NULL; + + if (argc > 1 && !strcasecmp(argv[1], "--debug")) { + idevice_set_debug_level(1); + } else { + idevice_set_debug_level(0); + } + + if (IDEVICE_E_SUCCESS != idevice_new(&phone, NULL)) { + printf("No device found, is it plugged in?\n"); + return -1; + } + + char *uuid = NULL; + if (IDEVICE_E_SUCCESS == idevice_get_uuid(phone, &uuid)) { + printf("DeviceUniqueID : %s\n", uuid); + } + if (uuid) + free(uuid); + + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "ideviceclient")) { + idevice_free(phone); + printf("Exiting.\n"); + return -1; + } + + char *nnn = NULL; + if (LOCKDOWN_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { + printf("DeviceName : %s\n", nnn); + free(nnn); + } + + lockdownd_start_service(client, "com.apple.afc", &port); + + if (port) { + afc_client_t afc = NULL; + afc_client_new(phone, port, &afc); + if (afc) { + lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); + if (npp) { + printf("Notification Proxy started.\n"); + np_client_new(phone, npp, &gnp); + } else { + printf("ERROR: Notification proxy could not be started.\n"); + } + if (gnp) { + const char *nspec[5] = { + NP_SYNC_CANCEL_REQUEST, + NP_SYNC_SUSPEND_REQUEST, + NP_SYNC_RESUME_REQUEST, + NP_ITDBPREP_DID_END, + NULL + }; + np_observe_notifications(gnp, nspec); + np_set_notify_callback(gnp, notifier); + } + + perform_notification(phone, client, NP_SYNC_WILL_START); + + afc_file_open(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); + if (lockfile) { + printf("locking file\n"); + afc_file_lock(afc, lockfile, AFC_LOCK_EX); + + perform_notification(phone, client, NP_SYNC_DID_START); + } + + char **dirs = NULL; + afc_read_directory(afc, "/eafaedf", &dirs); + if (!dirs) + afc_read_directory(afc, "/", &dirs); + printf("Directory time.\n"); + for (i = 0; dirs[i]; i++) { + printf("/%s\n", dirs[i]); + } + + g_strfreev(dirs); + + dirs = NULL; + afc_get_device_info(afc, &dirs); + if (dirs) { + for (i = 0; dirs[i]; i += 2) { + printf("%s: %s\n", dirs[i], dirs[i + 1]); + } + } + g_strfreev(dirs); + + uint64_t my_file = 0; + char **info = NULL; + uint64_t fsize = 0; + if (AFC_E_SUCCESS == afc_get_file_info(afc, "/readme.libimobiledevice.fx", &info) && info) { + for (i = 0; info[i]; i += 2) { + printf("%s: %s\n", info[i], info[i+1]); + if (!strcmp(info[i], "st_size")) { + fsize = atoll(info[i+1]); + } + } + } + + if (AFC_E_SUCCESS == + afc_file_open(afc, "/readme.libimobiledevice.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { + printf("A file size: %llu\n", (long long)fsize); + char *file_data = (char *) malloc(sizeof(char) * fsize); + afc_file_read(afc, my_file, file_data, fsize, &bytes); + if (bytes > 0) { + printf("The file's data:\n"); + fwrite(file_data, 1, bytes, stdout); + } + printf("\nClosing my file.\n"); + afc_file_close(afc, my_file); + free(file_data); + } else + printf("couldn't open a file\n"); + + afc_file_open(afc, "/readme.libimobiledevice.fx", AFC_FOPEN_WR, &my_file); + if (my_file) { + char *outdatafile = strdup("this is a bitchin text file\n"); + afc_file_write(afc, my_file, outdatafile, strlen(outdatafile), &bytes); + free(outdatafile); + if (bytes > 0) + printf("Wrote a surprise. ;)\n"); + else + printf("I wanted to write a surprise, but... :(\n"); + afc_file_close(afc, my_file); + } + printf("Deleting a file...\n"); + bytes = afc_remove_path(afc, "/delme"); + if (bytes) + printf("Success.\n"); + else + printf("Failure. (expected unless you have a /delme file on your phone)\n"); + + printf("Renaming a file...\n"); + bytes = afc_rename_path(afc, "/renme", "/renme2"); + if (bytes > 0) + printf("Success.\n"); + else + printf("Failure. (expected unless you have a /renme file on your phone)\n"); + + printf("Seek & read\n"); + afc_file_open(afc, "/readme.libimobiledevice.fx", AFC_FOPEN_RDONLY, &my_file); + if (AFC_E_SUCCESS != afc_file_seek(afc, my_file, 5, SEEK_CUR)) + printf("WARN: SEEK DID NOT WORK\n"); + char *threeletterword = (char *) malloc(sizeof(char) * 5); + afc_file_read(afc, my_file, threeletterword, 3, &bytes); + threeletterword[3] = '\0'; + if (bytes > 0) + printf("Result: %s\n", threeletterword); + else + printf("Couldn't read!\n"); + free(threeletterword); + afc_file_close(afc, my_file); + } + + if (gnp && lockfile) { + printf("XXX sleeping\n"); + sleep(5); + + printf("XXX unlocking file\n"); + afc_file_lock(afc, lockfile, AFC_LOCK_UN); + + printf("XXX closing file\n"); + afc_file_close(afc, lockfile); + + printf("XXX sleeping\n"); + sleep(5); + //perform_notification(phone, client, NP_SYNC_DID_FINISH); + } + + if (gnp) { + np_client_free(gnp); + gnp = NULL; + } + + afc_client_free(afc); + } else { + printf("Start service failure.\n"); + } + + printf("All done.\n"); + + lockdownd_client_free(client); + idevice_free(phone); + + return 0; +} diff --git a/dev/ideviceenterrecovery.c b/dev/ideviceenterrecovery.c new file mode 100644 index 0000000..82ea786 --- /dev/null +++ b/dev/ideviceenterrecovery.c @@ -0,0 +1,93 @@ +/* + * ideviceenterrecovery.c + * Simple utility to make a device in normal mode enter recovery mode. + * + * Copyright (c) 2009 Martin Szulecki All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#include +#include + +static void print_usage(int argc, char **argv) +{ + char *name = NULL; + + name = strrchr(argv[0], '/'); + printf("Usage: %s [OPTIONS] UUID\n", (name ? name + 1: argv[0])); + printf("Makes a device with the supplied 40-digit UUID enter recovery mode immediately.\n\n"); + printf(" -d, --debug\t\tenable communication debugging\n"); + printf(" -h, --help\t\tprints usage information\n"); + printf("\n"); +} + +int main(int argc, char *argv[]) +{ + lockdownd_client_t client = NULL; + idevice_t phone = NULL; + idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; + int i; + char uuid[41]; + uuid[0] = 0; + + /* parse cmdline args */ + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { + idevice_set_debug_level(1); + continue; + } + else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { + print_usage(argc, argv); + return 0; + } + } + + i--; + if (!argv[i] || (strlen(argv[i]) != 40)) { + print_usage(argc, argv); + return 0; + } + strcpy(uuid, argv[i]); + + ret = idevice_new(&phone, uuid); + if (ret != IDEVICE_E_SUCCESS) { + printf("No device found with uuid %s, is it plugged in?\n", uuid); + return -1; + } + + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "ideviceenterrecovery")) { + idevice_free(phone); + return -1; + } + + /* run query and output information */ + printf("Telling device with uuid %s to enter recovery mode.}\n", uuid); + if(lockdownd_enter_recovery(client) != LOCKDOWN_E_SUCCESS) + { + printf("Failed to enter recovery mode.\n"); + } + printf("Device is successfully switching to recovery mode.\n"); + + lockdownd_client_free(client); + idevice_free(phone); + + return 0; +} diff --git a/dev/iphoneclient.c b/dev/iphoneclient.c deleted file mode 100644 index eab903c..0000000 --- a/dev/iphoneclient.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * main.c - * Rudimentary interface to the iPhone - * - * Copyright (c) 2008 Zach C. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -static void notifier(const char *notification) -{ - printf("---------------------------------------------------------\n"); - printf("------> Notification received: %s\n", notification); - printf("---------------------------------------------------------\n"); -} - -static void perform_notification(iphone_device_t phone, lockdownd_client_t client, const char *notification) -{ - uint16_t nport = 0; - np_client_t np; - - lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); - if (nport) { - printf("::::::::::::::: np was started ::::::::::::\n"); - np_client_new(phone, nport, &np); - if (np) { - printf("::::::::: PostNotification %s\n", notification); - np_post_notification(np, notification); - np_client_free(np); - } - } else { - printf("::::::::::::::: np was NOT started ::::::::::::\n"); - } -} - -int main(int argc, char *argv[]) -{ - unsigned int bytes = 0; - uint16_t port = 0, i = 0; - uint16_t npp; - lockdownd_client_t client = NULL; - iphone_device_t phone = NULL; - uint64_t lockfile = 0; - np_client_t gnp = NULL; - - if (argc > 1 && !strcasecmp(argv[1], "--debug")) { - iphone_set_debug_level(1); - } else { - iphone_set_debug_level(0); - } - - if (IPHONE_E_SUCCESS != iphone_device_new(&phone, NULL)) { - printf("No iPhone found, is it plugged in?\n"); - return -1; - } - - char *uuid = NULL; - if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) { - printf("DeviceUniqueID : %s\n", uuid); - } - if (uuid) - free(uuid); - - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneclient")) { - iphone_device_free(phone); - printf("Exiting.\n"); - return -1; - } - - char *nnn = NULL; - if (LOCKDOWN_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { - printf("DeviceName : %s\n", nnn); - free(nnn); - } - - lockdownd_start_service(client, "com.apple.afc", &port); - - if (port) { - afc_client_t afc = NULL; - afc_client_new(phone, port, &afc); - if (afc) { - lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); - if (npp) { - printf("Notification Proxy started.\n"); - np_client_new(phone, npp, &gnp); - } else { - printf("ERROR: Notification proxy could not be started.\n"); - } - if (gnp) { - const char *nspec[5] = { - NP_SYNC_CANCEL_REQUEST, - NP_SYNC_SUSPEND_REQUEST, - NP_SYNC_RESUME_REQUEST, - NP_ITDBPREP_DID_END, - NULL - }; - np_observe_notifications(gnp, nspec); - np_set_notify_callback(gnp, notifier); - } - - perform_notification(phone, client, NP_SYNC_WILL_START); - - afc_file_open(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); - if (lockfile) { - printf("locking file\n"); - afc_file_lock(afc, lockfile, AFC_LOCK_EX); - - perform_notification(phone, client, NP_SYNC_DID_START); - } - - char **dirs = NULL; - afc_read_directory(afc, "/eafaedf", &dirs); - if (!dirs) - afc_read_directory(afc, "/", &dirs); - printf("Directory time.\n"); - for (i = 0; dirs[i]; i++) { - printf("/%s\n", dirs[i]); - } - - g_strfreev(dirs); - - dirs = NULL; - afc_get_device_info(afc, &dirs); - if (dirs) { - for (i = 0; dirs[i]; i += 2) { - printf("%s: %s\n", dirs[i], dirs[i + 1]); - } - } - g_strfreev(dirs); - - uint64_t my_file = 0; - char **info = NULL; - uint64_t fsize = 0; - if (AFC_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { - for (i = 0; info[i]; i += 2) { - printf("%s: %s\n", info[i], info[i+1]); - if (!strcmp(info[i], "st_size")) { - fsize = atoll(info[i+1]); - } - } - } - - if (AFC_E_SUCCESS == - afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { - printf("A file size: %llu\n", (long long)fsize); - char *file_data = (char *) malloc(sizeof(char) * fsize); - afc_file_read(afc, my_file, file_data, fsize, &bytes); - if (bytes > 0) { - printf("The file's data:\n"); - fwrite(file_data, 1, bytes, stdout); - } - printf("\nClosing my file.\n"); - afc_file_close(afc, my_file); - free(file_data); - } else - printf("couldn't open a file\n"); - - afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); - if (my_file) { - char *outdatafile = strdup("this is a bitchin text file\n"); - afc_file_write(afc, my_file, outdatafile, strlen(outdatafile), &bytes); - free(outdatafile); - if (bytes > 0) - printf("Wrote a surprise. ;)\n"); - else - printf("I wanted to write a surprise, but... :(\n"); - afc_file_close(afc, my_file); - } - printf("Deleting a file...\n"); - bytes = afc_remove_path(afc, "/delme"); - if (bytes) - printf("Success.\n"); - else - printf("Failure. (expected unless you have a /delme file on your phone)\n"); - - printf("Renaming a file...\n"); - bytes = afc_rename_path(afc, "/renme", "/renme2"); - if (bytes > 0) - printf("Success.\n"); - else - printf("Failure. (expected unless you have a /renme file on your phone)\n"); - - printf("Seek & read\n"); - afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); - if (AFC_E_SUCCESS != afc_file_seek(afc, my_file, 5, SEEK_CUR)) - printf("WARN: SEEK DID NOT WORK\n"); - char *threeletterword = (char *) malloc(sizeof(char) * 5); - afc_file_read(afc, my_file, threeletterword, 3, &bytes); - threeletterword[3] = '\0'; - if (bytes > 0) - printf("Result: %s\n", threeletterword); - else - printf("Couldn't read!\n"); - free(threeletterword); - afc_file_close(afc, my_file); - } - - if (gnp && lockfile) { - printf("XXX sleeping\n"); - sleep(5); - - printf("XXX unlocking file\n"); - afc_file_lock(afc, lockfile, AFC_LOCK_UN); - - printf("XXX closing file\n"); - afc_file_close(afc, lockfile); - - printf("XXX sleeping\n"); - sleep(5); - //perform_notification(phone, client, NP_SYNC_DID_FINISH); - } - - if (gnp) { - np_client_free(gnp); - gnp = NULL; - } - - afc_client_free(afc); - } else { - printf("Start service failure.\n"); - } - - printf("All done.\n"); - - lockdownd_client_free(client); - iphone_device_free(phone); - - return 0; -} diff --git a/dev/iphoneenterrecovery.c b/dev/iphoneenterrecovery.c deleted file mode 100644 index 153df15..0000000 --- a/dev/iphoneenterrecovery.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * iphoneenterrecovery.c - * Simple utility to make a device in normal mode enter recovery mode. - * - * Copyright (c) 2009 Martin Szulecki All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include - -#include -#include - -static void print_usage(int argc, char **argv) -{ - char *name = NULL; - - name = strrchr(argv[0], '/'); - printf("Usage: %s [OPTIONS] UUID\n", (name ? name + 1: argv[0])); - printf("Makes a device with the supplied 40-digit UUID enter recovery mode immediately.\n\n"); - printf(" -d, --debug\t\tenable communication debugging\n"); - printf(" -h, --help\t\tprints usage information\n"); - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - lockdownd_client_t client = NULL; - iphone_device_t phone = NULL; - iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; - int i; - char uuid[41]; - uuid[0] = 0; - - /* parse cmdline args */ - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { - iphone_set_debug_level(1); - continue; - } - else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { - print_usage(argc, argv); - return 0; - } - } - - i--; - if (!argv[i] || (strlen(argv[i]) != 40)) { - print_usage(argc, argv); - return 0; - } - strcpy(uuid, argv[i]); - - ret = iphone_device_new(&phone, uuid); - if (ret != IPHONE_E_SUCCESS) { - printf("No device found with uuid %s, is it plugged in?\n", uuid); - return -1; - } - - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneenterrecovery")) { - iphone_device_free(phone); - return -1; - } - - /* run query and output information */ - printf("Telling device with uuid %s to enter recovery mode.}\n", uuid); - if(lockdownd_enter_recovery(client) != LOCKDOWN_E_SUCCESS) - { - printf("Failed to enter recovery mode.\n"); - } - printf("Device is successfully switching to recovery mode.\n"); - - lockdownd_client_free(client); - iphone_device_free(phone); - - return 0; -} diff --git a/dev/lckdclient.c b/dev/lckdclient.c index 7b7604e..773de9f 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -26,30 +26,30 @@ #include #include -#include -#include +#include +#include int main(int argc, char *argv[]) { lockdownd_client_t client = NULL; - iphone_device_t phone = NULL; + idevice_t phone = NULL; - iphone_set_debug_level(1); + idevice_set_debug_level(1); - if (IPHONE_E_SUCCESS != iphone_device_new(&phone, NULL)) { - printf("No iPhone found, is it plugged in?\n"); + if (IDEVICE_E_SUCCESS != idevice_new(&phone, NULL)) { + printf("No device found, is it plugged in?\n"); return -1; } char *uuid = NULL; - if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) { + if (IDEVICE_E_SUCCESS == idevice_get_uuid(phone, &uuid)) { printf("DeviceUniqueID : %s\n", uuid); } if (uuid) free(uuid); if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "lckdclient")) { - iphone_device_free(phone); + idevice_free(phone); return -1; } @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) } clear_history(); lockdownd_client_free(client); - iphone_device_free(phone); + idevice_free(phone); return 0; } diff --git a/dev/msync.py b/dev/msync.py index 6bb85d7..951355c 100755 --- a/dev/msync.py +++ b/dev/msync.py @@ -1,11 +1,11 @@ #! /usr/bin/env python -from iphone import * +from imobiledevice import * from plist import * # get msync client def GetMobileSyncClient() : - phone = iPhone() + phone = idevice() if not phone.init_device() : print "Couldn't find device, is it connected ?\n" return None diff --git a/dev/msyncclient.c b/dev/msyncclient.c index 0107240..b9e39e6 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -1,6 +1,6 @@ /* * msyncclient.c - * Rudimentary interface to the MobileSync iPhone + * Rudimentary interface to the MobileSync service. * * Copyright (c) 2009 Jonathan Beck All Rights Reserved. * @@ -23,9 +23,9 @@ #include #include -#include -#include -#include +#include +#include +#include static char check_string(plist_t node, char* string) { @@ -143,18 +143,18 @@ int main(int argc, char *argv[]) { uint16_t port = 0; lockdownd_client_t client = NULL; - iphone_device_t phone = NULL; + idevice_t phone = NULL; if (argc > 1 && !strcasecmp(argv[1], "--debug")) - iphone_set_debug_level(1); + idevice_set_debug_level(1); - if (IPHONE_E_SUCCESS != iphone_device_new(&phone, NULL)) { - printf("No iPhone found, is it plugged in?\n"); + if (IDEVICE_E_SUCCESS != idevice_new(&phone, NULL)) { + printf("No device found, is it plugged in?\n"); return -1; } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "msyncclient")) { - iphone_device_free(phone); + idevice_free(phone); return -1; } @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) printf("All done.\n"); lockdownd_client_free(client); - iphone_device_free(phone); + idevice_free(phone); return 0; } -- cgit v1.1-32-gdbae