From 0727ae7c72bf149bf5898c667933a27d44e94f7d Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sun, 21 Jun 2009 23:02:22 +0200 Subject: Lkdn times out after few seconds idle so close it early and fix a crash on quit --- dev/syslog_relay.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'dev') diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 3407f2f..e552e9c 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -60,6 +61,7 @@ int main(int argc, char *argv[]) for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { iphone_set_debug_mask(DBGMASK_ALL); + iphone_set_debug(1); continue; } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { @@ -105,6 +107,8 @@ int main(int argc, char *argv[]) /* start syslog_relay service and retrieve port */ ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); if ((ret == IPHONE_E_SUCCESS) && port) { + iphone_lckd_free_client(control); + /* connect to socket relay messages */ int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); @@ -143,7 +147,6 @@ int main(int argc, char *argv[]) printf("ERROR: Could not start service com.apple.syslog_relay.\n"); } - iphone_lckd_free_client(control); iphone_free_device(phone); return 0; -- cgit v1.1-32-gdbae From 773f5c797622bedbc2aed0ee8d8680e45a2807d2 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sun, 21 Jun 2009 23:05:23 +0200 Subject: Silence warning and also dump iTunes format support information --- dev/iphoneinfo.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'dev') diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index c28eb9e..cee8dff 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -43,6 +44,7 @@ int main(int argc, char *argv[]) for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { iphone_set_debug_mask(DBGMASK_ALL); + iphone_set_debug(1); continue; } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { @@ -98,6 +100,7 @@ int main(int argc, char *argv[]) print_lckd_request_info(control, "com.apple.mobile.sync_data_class", "GetValue", NULL); print_lckd_request_info(control, "com.apple.iTunes", "GetValue", NULL); print_lckd_request_info(control, "com.apple.mobile.iTunes.store", "GetValue", NULL); + print_lckd_request_info(control, "com.apple.mobile.iTunes", "GetValue", NULL); iphone_lckd_free_client(control); iphone_free_device(phone); -- cgit v1.1-32-gdbae From 0463978f0c43d37e053d916b14c16121505266bb Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 27 Jun 2009 18:09:30 +0200 Subject: Make iphoneinfo useful by adding XML output and queries by domain and/or key --- dev/iphoneinfo.c | 126 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 105 insertions(+), 21 deletions(-) (limited to 'dev') diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index cee8dff..641b47d 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -26,8 +26,26 @@ #include +#define FORMAT_KEY_VALUE 1 +#define FORMAT_XML 2 + +static const char *domains[] = { + "com.apple.disk_usage", + "com.apple.mobile.battery", +/* FIXME: For some reason lockdownd segfaults on this, works sometimes though + "com.apple.mobile.debug",. */ + "com.apple.xcode.developerdomain", + "com.apple.international", + "com.apple.mobile.sync_data_class", + "com.apple.iTunes", + "com.apple.mobile.iTunes.store", + "com.apple.mobile.iTunes", + NULL +}; + +int is_domain_known(char *domain); void print_usage(int argc, char **argv); -void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, const char *request, const char *key); +void print_lckd_request_result(iphone_lckd_client_t control, const char *domain, const char *request, const char *key, int format); void plist_node_to_string(plist_t *node); void plist_children_to_string(plist_t *node); @@ -37,7 +55,10 @@ int main(int argc, char *argv[]) iphone_device_t phone = NULL; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; int i; + int format = FORMAT_KEY_VALUE; char uuid[41]; + char *domain = NULL; + char *key = NULL; uuid[0] = 0; /* parse cmdline args */ @@ -56,6 +77,31 @@ int main(int argc, char *argv[]) strcpy(uuid, argv[i]); continue; } + else if (!strcmp(argv[i], "-q") || !strcmp(argv[i], "--domain")) { + i++; + if (!argv[i] || (strlen(argv[i]) < 4)) { + print_usage(argc, argv); + return 0; + } + if (!is_domain_known(argv[i])) { + fprintf(stderr, "WARNING: Sending query with unknown domain \"%s\".\n", argv[i]); + } + domain = strdup(argv[i]); + continue; + } + else if (!strcmp(argv[i], "-k") || !strcmp(argv[i], "--key")) { + i++; + if (!argv[i] || (strlen(argv[i]) <= 1)) { + print_usage(argc, argv); + return 0; + } + key = strdup(argv[i]); + continue; + } + else if (!strcmp(argv[i], "-x") || !strcmp(argv[i], "--xml")) { + format = FORMAT_XML; + continue; + } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { print_usage(argc, argv); return 0; @@ -87,35 +133,45 @@ int main(int argc, char *argv[]) return -1; } - /* dump all information we can retrieve */ - printf("# general\n"); - print_lckd_request_info(control, NULL, "GetValue", NULL); - print_lckd_request_info(control, "com.apple.disk_usage", "GetValue", NULL); - print_lckd_request_info(control, "com.apple.mobile.battery", "GetValue", NULL); - /* FIXME: For some reason lockdownd segfaults on this, works sometimes though - print_lckd_request_info(control, "com.apple.mobile.debug", "GetValue", NULL); - */ - print_lckd_request_info(control, "com.apple.xcode.developerdomain", "GetValue", NULL); - print_lckd_request_info(control, "com.apple.international", "GetValue", NULL); - print_lckd_request_info(control, "com.apple.mobile.sync_data_class", "GetValue", NULL); - print_lckd_request_info(control, "com.apple.iTunes", "GetValue", NULL); - print_lckd_request_info(control, "com.apple.mobile.iTunes.store", "GetValue", NULL); - print_lckd_request_info(control, "com.apple.mobile.iTunes", "GetValue", NULL); + /* run query and output information */ + print_lckd_request_result(control, domain, "GetValue", key, format); + if (domain != NULL) + free(domain); iphone_lckd_free_client(control); iphone_free_device(phone); return 0; } +int is_domain_known(char *domain) +{ + int i = 0; + while (domains[i] != NULL) { + if (strstr(domain, domains[i++])) { + return 1; + } + } + return 0; +} + void print_usage(int argc, char **argv) { + int i = 0; printf("Usage: %s [OPTIONS]\n", (strrchr(argv[0], '/') + 1)); printf("Show information about the first connected iPhone/iPod Touch.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); + printf(" -q, --domain NAME\tset domain of query to NAME. Default: None\n"); + printf(" -k, --key NAME\tonly query key specified by NAME. Default: All keys.\n"); + printf(" -x, --xml\t\toutput information as xml plist instead of key/value pairs\n"); printf(" -h, --help\t\tprints usage information\n"); printf("\n"); + printf(" Known domains are:\n\n"); + while (domains[i] != NULL) { + printf(" %s\n", domains[i++]); + } + printf("\n"); } void plist_node_to_string(plist_t *node) @@ -189,14 +245,16 @@ void plist_children_to_string(plist_t *node) } } -void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, const char *request, const char *key) { +void print_lckd_request_result(iphone_lckd_client_t control, const char *domain, const char *request, const char *key, int format) { + char *xml_doc = NULL; + char *s = NULL; + uint32_t xml_length = 0; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; plist_t node = plist_new_dict(); if (domain) { plist_add_sub_key_el(node, "Domain"); plist_add_sub_string_el(node, domain); - printf("# %s\n", domain); } if (key) { plist_add_sub_key_el(node, "Key"); @@ -211,15 +269,41 @@ void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, c node = NULL; ret = iphone_lckd_recv(control, &node); if (ret == IPHONE_E_SUCCESS) { - /* seek to first dict node */ + /* seek to value node */ for ( node = plist_get_first_child(node); - node && (plist_get_node_type(node) != PLIST_DICT); + node != NULL; node = plist_get_next_sibling(node) ) { + if(plist_get_node_type(node) == PLIST_KEY) + { + plist_get_key_val(node, &s); + + if (strcmp("Value", s)) + continue; + + node = plist_get_next_sibling(node); + + if (plist_get_node_type(node) == PLIST_DICT) { + if (plist_get_first_child(node)) + { + switch (format) { + case FORMAT_XML: + plist_to_xml(node, &xml_doc, &xml_length); + printf(xml_doc); + free(xml_doc); + break; + case FORMAT_KEY_VALUE: + default: + plist_children_to_string(node); + break; + } + } + } + else if(node && (key != NULL)) + plist_node_to_string(node); + } } - if(plist_get_first_child(node)) - plist_children_to_string(node); } } if (node) -- cgit v1.1-32-gdbae From 922339633b08d0815eaf236c94edb774e190ff7f Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 1 Jul 2009 18:17:16 +0200 Subject: Fix segfault when displaying usage for installed iphoneinfo and iphonesyslog --- dev/iphoneinfo.c | 5 ++++- dev/syslog_relay.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'dev') diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 641b47d..18ee055 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -158,7 +158,10 @@ int is_domain_known(char *domain) void print_usage(int argc, char **argv) { int i = 0; - printf("Usage: %s [OPTIONS]\n", (strrchr(argv[0], '/') + 1)); + char *name = NULL; + + name = strrchr(argv[0], '/'); + printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); printf("Show information about the first connected iPhone/iPod Touch.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index e552e9c..6698653 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -154,7 +154,10 @@ int main(int argc, char *argv[]) void print_usage(int argc, char **argv) { - printf("Usage: %s [OPTIONS]\n", (strrchr(argv[0], '/') + 1)); + char *name = NULL; + + name = strrchr(argv[0], '/'); + printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); printf("Relay syslog of a connected iPhone/iPod Touch.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); -- cgit v1.1-32-gdbae From abb74bcae219c25cffb7e30db6a34c69dcd92f0a Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 6 Jul 2009 19:38:00 +0200 Subject: API cleanup for AFC Signed-off-by: Martin Szulecki --- dev/afccheck.c | 21 +++++++++++---------- dev/main.c | 47 ++++++++++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 33 deletions(-) (limited to 'dev') diff --git a/dev/afccheck.c b/dev/afccheck.c index 965981b..b107437 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -25,13 +25,14 @@ #include #include +#include #define BUFFER_SIZE 20000 #define NB_THREADS 10 typedef struct { - iphone_afc_client_t afc; + afc_client_t afc; int id; } param; @@ -53,18 +54,18 @@ void check_afc(gpointer data) uint64_t file = 0; char path[50]; sprintf(path, "/Buf%i", ((param *) data)->id); - iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); - iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); - iphone_afc_close_file(((param *) data)->afc, file); + afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); + afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); + afc_close_file(((param *) data)->afc, file); file = 0; if (bytes != buffersize) printf("Write operation failed\n"); //now read it bytes = 0; - iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); - iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); - iphone_afc_close_file(((param *) data)->afc, file); + afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); + afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); + afc_close_file(((param *) data)->afc, file); if (bytes != buffersize) printf("Read operation failed\n"); @@ -77,7 +78,7 @@ void check_afc(gpointer data) } //cleanup - iphone_afc_delete_file(((param *) data)->afc, path); + afc_delete_file(((param *) data)->afc, path); g_thread_exit(0); } @@ -87,7 +88,7 @@ int main(int argc, char *argv[]) iphone_device_t phone = NULL; GError *err; int port = 0; - iphone_afc_client_t afc = NULL; + afc_client_t afc = NULL; if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { printf("No iPhone found, is it plugged in?\n"); @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) return 1; } - iphone_afc_new_client(phone, port, &afc); + afc_new_client(phone, port, &afc); //makes sure thread environment is available if (!g_thread_supported()) diff --git a/dev/main.c b/dev/main.c index c8c9dfa..fe340ff 100644 --- a/dev/main.c +++ b/dev/main.c @@ -25,6 +25,7 @@ #include #include +#include #include "../src/utils.h" void notifier(const char *notification) @@ -97,8 +98,8 @@ int main(int argc, char *argv[]) iphone_lckd_start_service(control, "com.apple.afc", &port); if (port) { - iphone_afc_client_t afc = NULL; - iphone_afc_new_client(phone, port, &afc); + afc_client_t afc = NULL; + afc_new_client(phone, port, &afc); if (afc) { iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); if (npp) { @@ -120,18 +121,18 @@ int main(int argc, char *argv[]) perform_notification(phone, control, NP_SYNC_WILL_START); - iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); + afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); if (lockfile) { printf("locking file\n"); - iphone_afc_lock_file(afc, lockfile, 2 | 4); + afc_lock_file(afc, lockfile, 2 | 4); perform_notification(phone, control, NP_SYNC_DID_START); } char **dirs = NULL; - iphone_afc_get_dir_list(afc, "/eafaedf", &dirs); + afc_get_dir_list(afc, "/eafaedf", &dirs); if (!dirs) - iphone_afc_get_dir_list(afc, "/", &dirs); + afc_get_dir_list(afc, "/", &dirs); printf("Directory time.\n"); for (i = 0; dirs[i]; i++) { printf("/%s\n", dirs[i]); @@ -140,7 +141,7 @@ int main(int argc, char *argv[]) g_strfreev(dirs); dirs = NULL; - iphone_afc_get_devinfo(afc, &dirs); + afc_get_devinfo(afc, &dirs); if (dirs) { for (i = 0; dirs[i]; i += 2) { printf("%s: %s\n", dirs[i], dirs[i + 1]); @@ -151,7 +152,7 @@ int main(int argc, char *argv[]) uint64_t my_file = 0; char **info = NULL; uint64_t fsize = 0; - if (IPHONE_E_SUCCESS == iphone_afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { + if (IPHONE_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")) { @@ -161,58 +162,58 @@ int main(int argc, char *argv[]) } if (IPHONE_E_SUCCESS == - iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { + afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { printf("A file size: %i\n", fsize); char *file_data = (char *) malloc(sizeof(char) * fsize); - iphone_afc_read_file(afc, my_file, file_data, fsize, &bytes); + afc_read_file(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"); - iphone_afc_close_file(afc, my_file); + afc_close_file(afc, my_file); free(file_data); } else printf("couldn't open a file\n"); - iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); + afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); if (my_file) { char *outdatafile = strdup("this is a bitchin text file\n"); - iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); + afc_write_file(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"); - iphone_afc_close_file(afc, my_file); + afc_close_file(afc, my_file); } printf("Deleting a file...\n"); - bytes = iphone_afc_delete_file(afc, "/delme"); + bytes = afc_delete_file(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 = iphone_afc_rename_file(afc, "/renme", "/renme2"); + bytes = afc_rename_file(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"); - iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); - if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5, SEEK_CUR)) + afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); + if (IPHONE_E_SUCCESS != afc_seek_file(afc, my_file, 5, SEEK_CUR)) printf("WARN: SEEK DID NOT WORK\n"); char *threeletterword = (char *) malloc(sizeof(char) * 5); - iphone_afc_read_file(afc, my_file, threeletterword, 3, &bytes); + afc_read_file(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); - iphone_afc_close_file(afc, my_file); + afc_close_file(afc, my_file); } if (gnp && lockfile) { @@ -245,10 +246,10 @@ int main(int argc, char *argv[]) //perform_notification(phone, control, NP_SYNC_DID_FINISH); printf("XXX unlocking file\n"); - iphone_afc_lock_file(afc, lockfile, 8 | 4); + afc_lock_file(afc, lockfile, 8 | 4); printf("XXX closing file\n"); - iphone_afc_close_file(afc, lockfile); + afc_close_file(afc, lockfile); } if (gnp) { @@ -256,7 +257,7 @@ int main(int argc, char *argv[]) gnp = NULL; } - iphone_afc_free_client(afc); + afc_free_client(afc); } else { printf("Start service failure.\n"); } -- cgit v1.1-32-gdbae From a1e2fec59eb7d0d2a3adbd4691b3ea2ee1302921 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 6 Jul 2009 19:46:35 +0200 Subject: API cleanup for NotificationProxy Signed-off-by: Martin Szulecki --- dev/main.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'dev') diff --git a/dev/main.c b/dev/main.c index fe340ff..d39baa7 100644 --- a/dev/main.c +++ b/dev/main.c @@ -26,6 +26,7 @@ #include #include +#include #include "../src/utils.h" void notifier(const char *notification) @@ -38,16 +39,16 @@ void notifier(const char *notification) void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, const char *notification) { int nport = 0; - iphone_np_client_t np; + np_client_t np; iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); if (nport) { printf("::::::::::::::: np was started ::::::::::::\n"); - iphone_np_new_client(phone, nport, &np); + np_new_client(phone, nport, &np); if (np) { printf("::::::::: PostNotification %s\n", notification); - iphone_np_post_notification(np, notification); - iphone_np_free_client(np); + np_post_notification(np, notification); + np_free_client(np); } } else { printf("::::::::::::::: np was NOT started ::::::::::::\n"); @@ -61,7 +62,7 @@ int main(int argc, char *argv[]) iphone_lckd_client_t control = NULL; iphone_device_t phone = NULL; uint64_t lockfile = 0; - iphone_np_client_t gnp = NULL; + np_client_t gnp = NULL; if (argc > 1 && !strcasecmp(argv[1], "--debug")) { iphone_set_debug(1); @@ -104,7 +105,7 @@ int main(int argc, char *argv[]) iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); if (npp) { printf("Notification Proxy started.\n"); - iphone_np_new_client(phone, npp, &gnp); + np_new_client(phone, npp, &gnp); } else { printf("ERROR: Notification proxy could not be started.\n"); } @@ -115,8 +116,8 @@ int main(int argc, char *argv[]) NP_SYNC_RESUME_REQUEST, NULL }; - iphone_np_observe_notifications(gnp, nspec); - iphone_np_set_notify_callback(gnp, notifier); + np_observe_notifications(gnp, nspec); + np_set_notify_callback(gnp, notifier); } perform_notification(phone, control, NP_SYNC_WILL_START); @@ -219,28 +220,7 @@ int main(int argc, char *argv[]) if (gnp && lockfile) { char *noti; - /* - noti = NULL; - iphone_np_get_notification(gnp, ¬i); - if (noti) { - printf("------> received notification '%s'\n", noti); - free(noti); - }*/ - printf("XXX sleeping\n"); - /*for (i = 0; i < 5; i++) { - noti = NULL; - printf("--- getting notification\n"); - iphone_np_get_notification(gnp, ¬i); - if (noti) { - printf("------> received notification '%s'\n", noti); - free(noti); - } else { - printf("---- no notification\n"); - } - sleep(1); - } - */ sleep(5); //perform_notification(phone, control, NP_SYNC_DID_FINISH); @@ -253,7 +233,7 @@ int main(int argc, char *argv[]) } if (gnp) { - iphone_np_free_client(gnp); + np_free_client(gnp); gnp = NULL; } -- cgit v1.1-32-gdbae From 62a6f558ac7ca7a9b83c2ed810929732c02bbc9d Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 7 Jul 2009 21:02:00 +0200 Subject: Cleanup lockdown request API and fix docs, tools, bindings and exports --- dev/afccheck.c | 15 ++++++++------- dev/iphone_id.c | 9 +++++---- dev/iphoneinfo.c | 17 +++++++++-------- dev/lckdclient.c | 29 ++++++++++++++++++----------- dev/main.c | 35 ++++++++++++++++++----------------- dev/msyncclient.c | 12 ++++++------ dev/syslog_relay.c | 9 +++++---- 7 files changed, 69 insertions(+), 57 deletions(-) (limited to 'dev') diff --git a/dev/afccheck.c b/dev/afccheck.c index b107437..9174e32 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -25,6 +25,7 @@ #include #include +#include #include #define BUFFER_SIZE 20000 @@ -40,10 +41,10 @@ typedef struct { void check_afc(gpointer data) { //prepare a buffer - int buffersize = BUFFER_SIZE * sizeof(int); + unsigned int buffersize = BUFFER_SIZE * sizeof(unsigned int); int *buf = (int *) malloc(buffersize); int *buf2 = (int *) malloc(buffersize); - int bytes = 0; + unsigned int bytes = 0; //fill buffer int i = 0; for (i = 0; i < BUFFER_SIZE; i++) { @@ -84,7 +85,7 @@ void check_afc(gpointer data) int main(int argc, char *argv[]) { - iphone_lckd_client_t control = NULL; + lockdownd_client_t client = NULL; iphone_device_t phone = NULL; GError *err; int port = 0; @@ -95,13 +96,13 @@ int main(int argc, char *argv[]) return 1; } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); return 1; } - if (IPHONE_E_SUCCESS == iphone_lckd_start_service(control, "com.apple.afc", &port) && !port) { - iphone_lckd_free_client(control); + if (IPHONE_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { + lockdownd_free_client(client); iphone_free_device(phone); fprintf(stderr, "Something went wrong when starting AFC."); return 1; @@ -128,7 +129,7 @@ int main(int argc, char *argv[]) } - iphone_lckd_free_client(control); + lockdownd_free_client(client); iphone_free_device(phone); return 0; diff --git a/dev/iphone_id.c b/dev/iphone_id.c index c191608..15081f0 100644 --- a/dev/iphone_id.c +++ b/dev/iphone_id.c @@ -3,6 +3,7 @@ #include #include #include +#include #include static void usage() @@ -18,7 +19,7 @@ static void usage() int main(int argc, char **argv) { iphone_device_t phone = NULL; - iphone_lckd_client_t control = NULL; + lockdownd_client_t client = NULL; usbmuxd_scan_result *dev_list; char *devname = NULL; int ret = 0; @@ -67,18 +68,18 @@ int main(int argc, char **argv) return -2; } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); fprintf(stderr, "ERROR: Connecting to device failed!\n"); return -2; } - if ((IPHONE_E_SUCCESS != lockdownd_get_device_name(control, &devname)) || !devname) { + if ((IPHONE_E_SUCCESS != lockdownd_get_device_name(client, &devname)) || !devname) { fprintf(stderr, "ERROR: Could not get device name!\n"); ret = -2; } - iphone_lckd_free_client(control); + lockdownd_free_client(client); iphone_free_device(phone); if (ret == 0) { diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 18ee055..7c823e6 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -25,6 +25,7 @@ #include #include +#include #define FORMAT_KEY_VALUE 1 #define FORMAT_XML 2 @@ -45,13 +46,13 @@ static const char *domains[] = { int is_domain_known(char *domain); void print_usage(int argc, char **argv); -void print_lckd_request_result(iphone_lckd_client_t control, const char *domain, const char *request, const char *key, int format); +void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format); void plist_node_to_string(plist_t *node); void plist_children_to_string(plist_t *node); int main(int argc, char *argv[]) { - iphone_lckd_client_t control = NULL; + lockdownd_client_t client = NULL; iphone_device_t phone = NULL; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; int i; @@ -128,17 +129,17 @@ int main(int argc, char *argv[]) } } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); return -1; } /* run query and output information */ - print_lckd_request_result(control, domain, "GetValue", key, format); + print_lckd_request_result(client, domain, "GetValue", key, format); if (domain != NULL) free(domain); - iphone_lckd_free_client(control); + lockdownd_free_client(client); iphone_free_device(phone); return 0; @@ -248,7 +249,7 @@ void plist_children_to_string(plist_t *node) } } -void print_lckd_request_result(iphone_lckd_client_t control, const char *domain, const char *request, const char *key, int format) { +void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format) { char *xml_doc = NULL; char *s = NULL; uint32_t xml_length = 0; @@ -266,11 +267,11 @@ void print_lckd_request_result(iphone_lckd_client_t control, const char *domain, plist_add_sub_key_el(node, "Request"); plist_add_sub_string_el(node, request); - ret = iphone_lckd_send(control, node); + ret = lockdownd_send(client, node); if (ret == IPHONE_E_SUCCESS) { plist_free(node); node = NULL; - ret = iphone_lckd_recv(control, &node); + ret = lockdownd_recv(client, &node); if (ret == IPHONE_E_SUCCESS) { /* seek to value node */ for ( diff --git a/dev/lckdclient.c b/dev/lckdclient.c index c96f052..e197002 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -27,12 +27,11 @@ #include #include - +#include int main(int argc, char *argv[]) { - int bytes = 0, port = 0, i = 0; - iphone_lckd_client_t control = NULL; + lockdownd_client_t client = NULL; iphone_device_t phone = NULL; iphone_set_debug(1); @@ -42,13 +41,13 @@ int main(int argc, char *argv[]) return -1; } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); return -1; } char *uid = NULL; - if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid)) { + if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { printf("DeviceUniqueID : %s\n", uid); free(uid); } @@ -74,17 +73,25 @@ int main(int argc, char *argv[]) if (!strcmp(*args, "quit")) loop = FALSE; - if (!strcmp(*args, "get") && len == 3) { - char *value = NULL; - if (IPHONE_E_SUCCESS == lockdownd_generic_get_value(control, *(args + 1), *(args + 2), &value)) - printf("Success : value = %s\n", value); + if (!strcmp(*args, "get") && len >= 2) { + plist_t *value = NULL; + if (IPHONE_E_SUCCESS == lockdownd_get_value(client, len == 3 ? *(args + 1):NULL, len == 3 ? *(args + 2):*(args + 1), &value)) + { + char *xml = NULL; + uint32_t length; + plist_to_xml(value, &xml, &length); + printf("Success : value = %s\n", xml); + + free(xml); + free(value); + } else printf("Error\n"); } if (!strcmp(*args, "start") && len == 2) { int port = 0; - iphone_lckd_start_service(control, *(args + 1), &port); + lockdownd_start_service(client, *(args + 1), &port); printf("%i\n", port); } } @@ -94,7 +101,7 @@ int main(int argc, char *argv[]) cmd = NULL; } clear_history(); - iphone_lckd_free_client(control); + lockdownd_free_client(client); iphone_free_device(phone); return 0; diff --git a/dev/main.c b/dev/main.c index d39baa7..cf7dbaa 100644 --- a/dev/main.c +++ b/dev/main.c @@ -23,25 +23,27 @@ #include #include #include +#include #include +#include #include #include #include "../src/utils.h" -void notifier(const char *notification) +static void notifier(const char *notification) { printf("---------------------------------------------------------\n"); printf("------> Notification received: %s\n", notification); printf("---------------------------------------------------------\n"); } -void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, const char *notification) +static void perform_notification(iphone_device_t phone, lockdownd_client_t client, const char *notification) { int nport = 0; np_client_t np; - iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); + lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); if (nport) { printf("::::::::::::::: np was started ::::::::::::\n"); np_new_client(phone, nport, &np); @@ -57,9 +59,10 @@ void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, c int main(int argc, char *argv[]) { - int bytes = 0, port = 0, i = 0; + unsigned int bytes = 0; + int port = 0, i = 0; int npp; - iphone_lckd_client_t control = NULL; + lockdownd_client_t client = NULL; iphone_device_t phone = NULL; uint64_t lockfile = 0; np_client_t gnp = NULL; @@ -77,32 +80,32 @@ int main(int argc, char *argv[]) return -1; } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); printf("Exiting.\n"); return -1; } char *uid = NULL; - if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid)) { + if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { printf("DeviceUniqueID : %s\n", uid); free(uid); } char *nnn = NULL; - if (IPHONE_E_SUCCESS == lockdownd_get_device_name(control, &nnn)) { + if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { printf("DeviceName : %s\n", nnn); free(nnn); } - iphone_lckd_start_service(control, "com.apple.afc", &port); + lockdownd_start_service(client, "com.apple.afc", &port); if (port) { afc_client_t afc = NULL; afc_new_client(phone, port, &afc); if (afc) { - iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); + lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); if (npp) { printf("Notification Proxy started.\n"); np_new_client(phone, npp, &gnp); @@ -120,14 +123,14 @@ int main(int argc, char *argv[]) np_set_notify_callback(gnp, notifier); } - perform_notification(phone, control, NP_SYNC_WILL_START); + perform_notification(phone, client, NP_SYNC_WILL_START); afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); if (lockfile) { printf("locking file\n"); afc_lock_file(afc, lockfile, 2 | 4); - perform_notification(phone, control, NP_SYNC_DID_START); + perform_notification(phone, client, NP_SYNC_DID_START); } char **dirs = NULL; @@ -164,10 +167,10 @@ int main(int argc, char *argv[]) if (IPHONE_E_SUCCESS == afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { - printf("A file size: %i\n", fsize); + printf("A file size: %llu\n", fsize); char *file_data = (char *) malloc(sizeof(char) * fsize); afc_read_file(afc, my_file, file_data, fsize, &bytes); - if (bytes >= 0) { + if (bytes > 0) { printf("The file's data:\n"); fwrite(file_data, 1, bytes, stdout); } @@ -218,8 +221,6 @@ int main(int argc, char *argv[]) } if (gnp && lockfile) { - char *noti; - printf("XXX sleeping\n"); sleep(5); @@ -244,7 +245,7 @@ int main(int argc, char *argv[]) printf("All done.\n"); - iphone_lckd_free_client(control); + lockdownd_free_client(client); iphone_free_device(phone); return 0; diff --git a/dev/msyncclient.c b/dev/msyncclient.c index e3bb0c2..e06a5fe 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -25,12 +25,12 @@ #include #include - +#include int main(int argc, char *argv[]) { - int bytes = 0, port = 0, i = 0; - iphone_lckd_client_t control = NULL; + int port = 0; + lockdownd_client_t client = NULL; iphone_device_t phone = NULL; if (argc > 1 && !strcasecmp(argv[1], "--debug")) @@ -42,12 +42,12 @@ int main(int argc, char *argv[]) return -1; } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); return -1; } - iphone_lckd_start_service(control, "com.apple.mobilesync", &port); + lockdownd_start_service(client, "com.apple.mobilesync", &port); if (port) { iphone_msync_client_t msync = NULL; @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) printf("All done.\n"); - iphone_lckd_free_client(control); + lockdownd_free_client(client); iphone_free_device(phone); return 0; diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 6698653..a93e85b 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -27,6 +27,7 @@ #include #include +#include #include static int quit_flag = 0; @@ -44,7 +45,7 @@ static void clean_exit(int sig) int main(int argc, char *argv[]) { - iphone_lckd_client_t control = NULL; + lockdownd_client_t client = NULL; iphone_device_t phone = NULL; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; int i; @@ -99,15 +100,15 @@ int main(int argc, char *argv[]) } } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); return -1; } /* start syslog_relay service and retrieve port */ - ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); + ret = lockdownd_start_service(client, "com.apple.syslog_relay", &port); if ((ret == IPHONE_E_SUCCESS) && port) { - iphone_lckd_free_client(control); + lockdownd_free_client(client); /* connect to socket relay messages */ -- cgit v1.1-32-gdbae From 5d047fd1e514e098308430fb59ba335b8ae3d385 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 10 Jul 2009 19:01:09 +0200 Subject: Use new plist_copy instead of serialization workaround in lockdownd_et_value() --- dev/lckdclient.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'dev') diff --git a/dev/lckdclient.c b/dev/lckdclient.c index e197002..e7ad962 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -74,19 +74,20 @@ int main(int argc, char *argv[]) loop = FALSE; if (!strcmp(*args, "get") && len >= 2) { - plist_t *value = NULL; + plist_t value = NULL; if (IPHONE_E_SUCCESS == lockdownd_get_value(client, len == 3 ? *(args + 1):NULL, len == 3 ? *(args + 2):*(args + 1), &value)) { char *xml = NULL; uint32_t length; plist_to_xml(value, &xml, &length); printf("Success : value = %s\n", xml); - free(xml); - free(value); } else printf("Error\n"); + + if (value) + plist_free(value); } if (!strcmp(*args, "start") && len == 2) { -- cgit v1.1-32-gdbae From a68a82800f116706354adb97da1ef0cfd3e38a52 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 14 Jul 2009 14:21:53 +0200 Subject: Cleanup mobilesync API and bindings. Move get_all_contacts() into msyncclient. --- dev/msync.py | 2 +- dev/msyncclient.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 106 insertions(+), 5 deletions(-) (limited to 'dev') diff --git a/dev/msync.py b/dev/msync.py index 17e3121..fe7f1fd 100755 --- a/dev/msync.py +++ b/dev/msync.py @@ -12,7 +12,7 @@ def GetMobileSyncClient() : if not lckd : print "Failed to start lockdown service.\n" return None - msync = lckd.get_mobile_sync_client() + msync = lckd.get_mobilesync_client() if not msync : print "Failed to start mobilesync service.\n" return None diff --git a/dev/msyncclient.c b/dev/msyncclient.c index e06a5fe..5eb105d 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -26,6 +26,107 @@ #include #include +#include + +static iphone_error_t mobilesync_get_all_contacts(mobilesync_client_t client) +{ + if (!client) + return IPHONE_E_INVALID_ARG; + + iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; + plist_t array = NULL; + + array = plist_new_array(); + plist_add_sub_string_el(array, "SDMessageSyncDataClassWithDevice"); + plist_add_sub_string_el(array, "com.apple.Contacts"); + plist_add_sub_string_el(array, "---"); + plist_add_sub_string_el(array, "2009-01-09 18:03:58 +0100"); + plist_add_sub_uint_el(array, 106); + plist_add_sub_string_el(array, "___EmptyParameterString___"); + + ret = mobilesync_send(client, array); + plist_free(array); + array = NULL; + + ret = mobilesync_recv(client, &array); + + plist_t rep_node = plist_find_node_by_string(array, "SDSyncTypeSlow"); + + if (!rep_node) + return ret; + + plist_free(array); + array = NULL; + + array = plist_new_array(); + plist_add_sub_string_el(array, "SDMessageGetAllRecordsFromDevice"); + plist_add_sub_string_el(array, "com.apple.Contacts"); + + + ret = mobilesync_send(client, array); + plist_free(array); + array = NULL; + + ret = mobilesync_recv(client, &array); + + plist_t contact_node; + plist_t switch_node; + + contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); + switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); + + while (NULL == switch_node) { + + plist_free(array); + array = NULL; + + array = plist_new_array(); + plist_add_sub_string_el(array, "SDMessageAcknowledgeChangesFromDevice"); + plist_add_sub_string_el(array, "com.apple.Contacts"); + + ret = mobilesync_send(client, array); + plist_free(array); + array = NULL; + + ret = mobilesync_recv(client, &array); + + contact_node = plist_find_node_by_string(array, "com.apple.Contacts"); + switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges"); + } + + array = plist_new_array(); + plist_add_sub_string_el(array, "DLMessagePing"); + plist_add_sub_string_el(array, "Preparing to get changes for device"); + + ret = mobilesync_send(client, array); + plist_free(array); + array = NULL; + + array = plist_new_array(); + plist_add_sub_string_el(array, "SDMessageProcessChanges"); + plist_add_sub_string_el(array, "com.apple.Contacts"); + plist_add_sub_node(array, plist_new_dict()); + plist_add_sub_bool_el(array, 0); + plist_t dict = plist_new_dict(); + plist_add_sub_node(array, dict); + plist_add_sub_key_el(dict, "SyncDeviceLinkEntityNamesKey"); + plist_t array2 = plist_new_array(); + plist_add_sub_string_el(array2, "com.apple.contacts.Contact"); + plist_add_sub_string_el(array2, "com.apple.contacts.Group"); + plist_add_sub_key_el(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey"); + plist_add_sub_bool_el(dict, 0); + + ret = mobilesync_send(client, array); + plist_free(array); + array = NULL; + + ret = mobilesync_recv(client, &array); + plist_free(array); + array = NULL; + + + return ret; +} int main(int argc, char *argv[]) { @@ -50,11 +151,11 @@ int main(int argc, char *argv[]) lockdownd_start_service(client, "com.apple.mobilesync", &port); if (port) { - iphone_msync_client_t msync = NULL; - iphone_msync_new_client(phone, port, &msync); + mobilesync_client_t msync = NULL; + mobilesync_new_client(phone, port, &msync); if (msync) { - iphone_msync_get_all_contacts(msync); - iphone_msync_free_client(msync); + mobilesync_get_all_contacts(msync); + mobilesync_free_client(msync); } } else { printf("Start service failure.\n"); -- cgit v1.1-32-gdbae From 8606fb9575c9eb6ffcbc9afec50c7f24e9ddf8d6 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 18 Jul 2009 20:20:34 +0200 Subject: Simplify iphoneinfo by using new lockdownd_get_value replacing custom code --- dev/iphoneinfo.c | 95 ++++++++++++++++---------------------------------------- 1 file changed, 27 insertions(+), 68 deletions(-) (limited to 'dev') diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 7c823e6..33ab3ac 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -46,7 +46,6 @@ static const char *domains[] = { int is_domain_known(char *domain); void print_usage(int argc, char **argv); -void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format); void plist_node_to_string(plist_t *node); void plist_children_to_string(plist_t *node); @@ -60,6 +59,9 @@ int main(int argc, char *argv[]) char uuid[41]; char *domain = NULL; char *key = NULL; + char *xml_doc = NULL; + uint32_t xml_length; + plist_t node = NULL; uuid[0] = 0; /* parse cmdline args */ @@ -135,7 +137,30 @@ int main(int argc, char *argv[]) } /* run query and output information */ - print_lckd_request_result(client, domain, "GetValue", key, format); + if(lockdownd_get_value(client, domain, key, &node) == IPHONE_E_SUCCESS) + { + if (plist_get_node_type(node) == PLIST_DICT) { + if (plist_get_first_child(node)) + { + switch (format) { + case FORMAT_XML: + plist_to_xml(node, &xml_doc, &xml_length); + printf(xml_doc); + free(xml_doc); + break; + case FORMAT_KEY_VALUE: + default: + plist_children_to_string(node); + break; + } + } + } + else if(node && (key != NULL)) + plist_node_to_string(node); + if (node) + plist_free(node); + node = NULL; + } if (domain != NULL) free(domain); @@ -249,69 +274,3 @@ void plist_children_to_string(plist_t *node) } } -void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format) { - char *xml_doc = NULL; - char *s = NULL; - uint32_t xml_length = 0; - iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; - - plist_t node = plist_new_dict(); - if (domain) { - plist_add_sub_key_el(node, "Domain"); - plist_add_sub_string_el(node, domain); - } - if (key) { - plist_add_sub_key_el(node, "Key"); - plist_add_sub_string_el(node, key); - } - plist_add_sub_key_el(node, "Request"); - plist_add_sub_string_el(node, request); - - ret = lockdownd_send(client, node); - if (ret == IPHONE_E_SUCCESS) { - plist_free(node); - node = NULL; - ret = lockdownd_recv(client, &node); - if (ret == IPHONE_E_SUCCESS) { - /* seek to value node */ - for ( - node = plist_get_first_child(node); - node != NULL; - node = plist_get_next_sibling(node) - ) { - if(plist_get_node_type(node) == PLIST_KEY) - { - plist_get_key_val(node, &s); - - if (strcmp("Value", s)) - continue; - - node = plist_get_next_sibling(node); - - if (plist_get_node_type(node) == PLIST_DICT) { - if (plist_get_first_child(node)) - { - switch (format) { - case FORMAT_XML: - plist_to_xml(node, &xml_doc, &xml_length); - printf(xml_doc); - free(xml_doc); - break; - case FORMAT_KEY_VALUE: - default: - plist_children_to_string(node); - break; - } - } - } - else if(node && (key != NULL)) - plist_node_to_string(node); - } - } - } - } - if (node) - plist_free(node); - node = NULL; -} - -- cgit v1.1-32-gdbae From 37f8ad0f3e64c23cd32c8c58636510f7964f1891 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 19 Jul 2009 20:07:21 +0200 Subject: New type afc_lock_op_t with allowed lock operations for afc_lock_file. Only non-blocking locks are supported via AFC. Signed-off-by: Martin Szulecki --- dev/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dev') diff --git a/dev/main.c b/dev/main.c index cf7dbaa..33ebc2d 100644 --- a/dev/main.c +++ b/dev/main.c @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); if (lockfile) { printf("locking file\n"); - afc_lock_file(afc, lockfile, 2 | 4); + afc_lock_file(afc, lockfile, AFC_LOCK_EX); perform_notification(phone, client, NP_SYNC_DID_START); } @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) //perform_notification(phone, control, NP_SYNC_DID_FINISH); printf("XXX unlocking file\n"); - afc_lock_file(afc, lockfile, 8 | 4); + afc_lock_file(afc, lockfile, AFC_LOCK_UN); printf("XXX closing file\n"); afc_close_file(afc, lockfile); -- cgit v1.1-32-gdbae From 0e80ca70829eb7c3cab32019ca4dfaef577b6e69 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 21 Jul 2009 00:53:05 +0200 Subject: Add new lockdown request domains to iphoneinfo --- dev/iphoneinfo.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'dev') diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 33ab3ac..67e7552 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -37,7 +37,12 @@ static const char *domains[] = { "com.apple.mobile.debug",. */ "com.apple.xcode.developerdomain", "com.apple.international", + "com.apple.mobile.mobile_application_usage", + "com.apple.mobile.backup", + "com.apple.mobile.user_preferences", "com.apple.mobile.sync_data_class", + "com.apple.mobile.software_behavior", + "com.apple.mobile.iTunes.SQLMusicLibraryPostProcessCommands", "com.apple.iTunes", "com.apple.mobile.iTunes.store", "com.apple.mobile.iTunes", -- cgit v1.1-32-gdbae From cd1aa1c8107c1609746c12a6cd6777bd053167df Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 24 Jul 2009 16:21:37 +0200 Subject: Add --debug option to afccheck --- dev/afccheck.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'dev') diff --git a/dev/afccheck.c b/dev/afccheck.c index 9174e32..0525417 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -91,6 +91,14 @@ int main(int argc, char *argv[]) int port = 0; afc_client_t afc = NULL; + if (argc > 1 && !strcasecmp(argv[1], "--debug")) { + iphone_set_debug_level(1); + iphone_set_debug_mask(DBGMASK_ALL); + } else { + iphone_set_debug_level(0); + iphone_set_debug_mask(DBGMASK_NONE); + } + if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { printf("No iPhone found, is it plugged in?\n"); return 1; -- cgit v1.1-32-gdbae From f995c63e1bc56dd2d098a06f130d55334979f38f Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 24 Jul 2009 16:35:28 +0200 Subject: Add new NP_ITDBPREP_DID_END notification signaling music db refresh --- dev/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'dev') diff --git a/dev/main.c b/dev/main.c index 33ebc2d..b4e5c34 100644 --- a/dev/main.c +++ b/dev/main.c @@ -113,10 +113,11 @@ int main(int argc, char *argv[]) printf("ERROR: Notification proxy could not be started.\n"); } if (gnp) { - const char *nspec[4] = { + 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); -- cgit v1.1-32-gdbae From 601e70e8ee757b769bdc10b16e108e846a1a0b93 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 24 Jul 2009 17:46:30 +0200 Subject: Rename iphone_set_debug() to iphone_set_debug_level() and code using it --- dev/iphone_id.c | 2 +- dev/iphoneinfo.c | 2 +- dev/lckdclient.c | 2 +- dev/main.c | 4 ++-- dev/syslog_relay.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'dev') diff --git a/dev/iphone_id.c b/dev/iphone_id.c index 15081f0..dde15bc 100644 --- a/dev/iphone_id.c +++ b/dev/iphone_id.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) return 0; } - iphone_set_debug(0); + iphone_set_debug_level(0); iphone_get_device_by_uuid(&phone, argv[0]); if (!phone) { diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 67e7552..02b62d5 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { iphone_set_debug_mask(DBGMASK_ALL); - iphone_set_debug(1); + iphone_set_debug_level(1); continue; } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { diff --git a/dev/lckdclient.c b/dev/lckdclient.c index e7ad962..820d05f 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) lockdownd_client_t client = NULL; iphone_device_t phone = NULL; - iphone_set_debug(1); + iphone_set_debug_level(1); if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { printf("No iPhone found, is it plugged in?\n"); diff --git a/dev/main.c b/dev/main.c index b4e5c34..9c8b155 100644 --- a/dev/main.c +++ b/dev/main.c @@ -68,10 +68,10 @@ int main(int argc, char *argv[]) np_client_t gnp = NULL; if (argc > 1 && !strcasecmp(argv[1], "--debug")) { - iphone_set_debug(1); + iphone_set_debug_level(1); iphone_set_debug_mask(DBGMASK_ALL); } else { - iphone_set_debug(0); + iphone_set_debug_level(0); iphone_set_debug_mask(DBGMASK_NONE); } diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index a93e85b..09be6b8 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { iphone_set_debug_mask(DBGMASK_ALL); - iphone_set_debug(1); + iphone_set_debug_level(1); continue; } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { -- cgit v1.1-32-gdbae From 19a28b0ed18c8ca2f855e7d129ddcdb8c939a707 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 24 Jul 2009 23:51:53 +0200 Subject: Use iphone_device_get_uuid() not lockdown, for less overhead where possible --- dev/lckdclient.c | 13 +++++++------ dev/main.c | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'dev') diff --git a/dev/lckdclient.c b/dev/lckdclient.c index 820d05f..9518a6e 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -41,17 +41,18 @@ int main(int argc, char *argv[]) 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 (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); return -1; } - char *uid = NULL; - if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { - printf("DeviceUniqueID : %s\n", uid); - free(uid); - } - using_history(); int loop = TRUE; while (loop) { diff --git a/dev/main.c b/dev/main.c index 9c8b155..46c5557 100644 --- a/dev/main.c +++ b/dev/main.c @@ -80,19 +80,19 @@ int main(int argc, char *argv[]) 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 (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); printf("Exiting.\n"); return -1; } - char *uid = NULL; - if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { - printf("DeviceUniqueID : %s\n", uid); - free(uid); - } - - char *nnn = NULL; if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { printf("DeviceName : %s\n", nnn); -- cgit v1.1-32-gdbae From 40a0abaa1c7f2196d40276b0689b18a04e468acd Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 02:08:12 +0200 Subject: Update MobileSync API and introduce mobilesync error codes --- dev/msyncclient.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'dev') diff --git a/dev/msyncclient.c b/dev/msyncclient.c index 5eb105d..7651002 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -28,12 +28,12 @@ #include #include -static iphone_error_t mobilesync_get_all_contacts(mobilesync_client_t client) +static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client) { if (!client) - return IPHONE_E_INVALID_ARG; + return MOBILESYNC_E_INVALID_ARG; - iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; + mobilesync_error_t ret = MOBILESYNC_E_UNKNOWN_ERROR; plist_t array = NULL; array = plist_new_array(); @@ -124,7 +124,6 @@ static iphone_error_t mobilesync_get_all_contacts(mobilesync_client_t client) plist_free(array); array = NULL; - return ret; } @@ -137,7 +136,6 @@ int main(int argc, char *argv[]) if (argc > 1 && !strcasecmp(argv[1], "--debug")) iphone_set_debug_mask(DBGMASK_MOBILESYNC); - if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { printf("No iPhone found, is it plugged in?\n"); return -1; @@ -152,10 +150,10 @@ int main(int argc, char *argv[]) if (port) { mobilesync_client_t msync = NULL; - mobilesync_new_client(phone, port, &msync); + mobilesync_client_new(phone, port, &msync); if (msync) { mobilesync_get_all_contacts(msync); - mobilesync_free_client(msync); + mobilesync_client_free(msync); } } else { printf("Start service failure.\n"); -- cgit v1.1-32-gdbae From d11abfb48218a37d9c66831ebec8b0a736d5385f Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 02:20:03 +0200 Subject: Update NotificationProxy API and introduce new error codes --- dev/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'dev') diff --git a/dev/main.c b/dev/main.c index 46c5557..33c60f9 100644 --- a/dev/main.c +++ b/dev/main.c @@ -46,11 +46,11 @@ static void perform_notification(iphone_device_t phone, lockdownd_client_t clien lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); if (nport) { printf("::::::::::::::: np was started ::::::::::::\n"); - np_new_client(phone, nport, &np); + np_client_new(phone, nport, &np); if (np) { printf("::::::::: PostNotification %s\n", notification); np_post_notification(np, notification); - np_free_client(np); + np_client_free(np); } } else { printf("::::::::::::::: np was NOT started ::::::::::::\n"); @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); if (npp) { printf("Notification Proxy started.\n"); - np_new_client(phone, npp, &gnp); + np_client_new(phone, npp, &gnp); } else { printf("ERROR: Notification proxy could not be started.\n"); } @@ -225,17 +225,19 @@ int main(int argc, char *argv[]) printf("XXX sleeping\n"); sleep(5); - //perform_notification(phone, control, NP_SYNC_DID_FINISH); - printf("XXX unlocking file\n"); afc_lock_file(afc, lockfile, AFC_LOCK_UN); printf("XXX closing file\n"); afc_close_file(afc, lockfile); + + printf("XXX sleeping\n"); + sleep(5); + //perform_notification(phone, client, NP_SYNC_DID_FINISH); } if (gnp) { - np_free_client(gnp); + np_client_free(gnp); gnp = NULL; } -- cgit v1.1-32-gdbae From f5e9d76ebd74999512ab73f44fabba86879b1c1f Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 02:40:25 +0200 Subject: Update lockdown API and introduce new error codes --- dev/afccheck.c | 9 ++++----- dev/iphone_id.c | 6 +++--- dev/iphoneinfo.c | 6 +++--- dev/lckdclient.c | 15 ++++++++++----- dev/main.c | 6 +++--- dev/msyncclient.c | 4 ++-- dev/syslog_relay.c | 6 +++--- 7 files changed, 28 insertions(+), 24 deletions(-) (limited to 'dev') diff --git a/dev/afccheck.c b/dev/afccheck.c index 0525417..370742b 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -104,13 +104,13 @@ int main(int argc, char *argv[]) return 1; } - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); return 1; } - if (IPHONE_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { - lockdownd_free_client(client); + if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { + lockdownd_client_free(client); iphone_free_device(phone); fprintf(stderr, "Something went wrong when starting AFC."); return 1; @@ -136,8 +136,7 @@ int main(int argc, char *argv[]) g_thread_join(threads[i]); } - - lockdownd_free_client(client); + lockdownd_client_free(client); iphone_free_device(phone); return 0; diff --git a/dev/iphone_id.c b/dev/iphone_id.c index dde15bc..1b8f8a1 100644 --- a/dev/iphone_id.c +++ b/dev/iphone_id.c @@ -68,18 +68,18 @@ int main(int argc, char **argv) return -2; } - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); fprintf(stderr, "ERROR: Connecting to device failed!\n"); return -2; } - if ((IPHONE_E_SUCCESS != lockdownd_get_device_name(client, &devname)) || !devname) { + if ((LOCKDOWN_E_SUCCESS != lockdownd_get_device_name(client, &devname)) || !devname) { fprintf(stderr, "ERROR: Could not get device name!\n"); ret = -2; } - lockdownd_free_client(client); + lockdownd_client_free(client); iphone_free_device(phone); if (ret == 0) { diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 02b62d5..52d7c8a 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -136,13 +136,13 @@ int main(int argc, char *argv[]) } } - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); return -1; } /* run query and output information */ - if(lockdownd_get_value(client, domain, key, &node) == IPHONE_E_SUCCESS) + if(lockdownd_get_value(client, domain, key, &node) == LOCKDOWN_E_SUCCESS) { if (plist_get_node_type(node) == PLIST_DICT) { if (plist_get_first_child(node)) @@ -169,7 +169,7 @@ int main(int argc, char *argv[]) if (domain != NULL) free(domain); - lockdownd_free_client(client); + lockdownd_client_free(client); iphone_free_device(phone); return 0; diff --git a/dev/lckdclient.c b/dev/lckdclient.c index 9518a6e..4dcb0b4 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) if (uuid) free(uuid); - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); return -1; } @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) if (!strcmp(*args, "get") && len >= 2) { plist_t value = NULL; - if (IPHONE_E_SUCCESS == lockdownd_get_value(client, len == 3 ? *(args + 1):NULL, len == 3 ? *(args + 2):*(args + 1), &value)) + if (LOCKDOWN_E_SUCCESS == lockdownd_get_value(client, len == 3 ? *(args + 1):NULL, len == 3 ? *(args + 2):*(args + 1), &value)) { char *xml = NULL; uint32_t length; @@ -93,8 +93,13 @@ int main(int argc, char *argv[]) if (!strcmp(*args, "start") && len == 2) { int port = 0; - lockdownd_start_service(client, *(args + 1), &port); - printf("%i\n", port); + if(LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, *(args + 1), &port)) { + printf("started service %s on port %i\n", *(args + 1), port); + } + else + { + printf("failed to start service %s on device.\n", *(args + 1)); + } } } g_strfreev(args); @@ -103,7 +108,7 @@ int main(int argc, char *argv[]) cmd = NULL; } clear_history(); - lockdownd_free_client(client); + lockdownd_client_free(client); iphone_free_device(phone); return 0; diff --git a/dev/main.c b/dev/main.c index 33c60f9..69b0b80 100644 --- a/dev/main.c +++ b/dev/main.c @@ -87,14 +87,14 @@ int main(int argc, char *argv[]) if (uuid) free(uuid); - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); printf("Exiting.\n"); return -1; } char *nnn = NULL; - if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { + if (LOCKDOWN_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { printf("DeviceName : %s\n", nnn); free(nnn); } @@ -248,7 +248,7 @@ int main(int argc, char *argv[]) printf("All done.\n"); - lockdownd_free_client(client); + lockdownd_client_free(client); iphone_free_device(phone); return 0; diff --git a/dev/msyncclient.c b/dev/msyncclient.c index 7651002..6ab7c79 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) return -1; } - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); return -1; } @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) printf("All done.\n"); - lockdownd_free_client(client); + lockdownd_client_free(client); iphone_free_device(phone); return 0; diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 09be6b8..0c41c94 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -100,15 +100,15 @@ int main(int argc, char *argv[]) } } - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); return -1; } /* start syslog_relay service and retrieve port */ ret = lockdownd_start_service(client, "com.apple.syslog_relay", &port); - if ((ret == IPHONE_E_SUCCESS) && port) { - lockdownd_free_client(client); + if ((ret == LOCKDOWN_E_SUCCESS) && port) { + lockdownd_client_free(client); /* connect to socket relay messages */ -- cgit v1.1-32-gdbae From 5cb9ecc85240102402082c442d561d7350732027 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 02:54:40 +0200 Subject: Follow glib style and rename iphone_free_device to iphone_device_free --- dev/afccheck.c | 6 +++--- dev/iphone_id.c | 4 ++-- dev/iphoneinfo.c | 4 ++-- dev/lckdclient.c | 4 ++-- dev/main.c | 4 ++-- dev/msyncclient.c | 4 ++-- dev/syslog_relay.c | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'dev') diff --git a/dev/afccheck.c b/dev/afccheck.c index 370742b..067dd5b 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -105,13 +105,13 @@ int main(int argc, char *argv[]) } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); return 1; } if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); fprintf(stderr, "Something went wrong when starting AFC."); return 1; } @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) } lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); return 0; } diff --git a/dev/iphone_id.c b/dev/iphone_id.c index 1b8f8a1..f68fc8b 100644 --- a/dev/iphone_id.c +++ b/dev/iphone_id.c @@ -69,7 +69,7 @@ int main(int argc, char **argv) } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); fprintf(stderr, "ERROR: Connecting to device failed!\n"); return -2; } @@ -80,7 +80,7 @@ int main(int argc, char **argv) } lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); if (ret == 0) { printf("%s\n", devname); diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 52d7c8a..790804c 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); return -1; } @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) if (domain != NULL) free(domain); lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); return 0; } diff --git a/dev/lckdclient.c b/dev/lckdclient.c index 4dcb0b4..b880253 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) free(uuid); if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); return -1; } @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) } clear_history(); lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); return 0; } diff --git a/dev/main.c b/dev/main.c index 69b0b80..5551ed9 100644 --- a/dev/main.c +++ b/dev/main.c @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) free(uuid); if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); printf("Exiting.\n"); return -1; } @@ -249,7 +249,7 @@ int main(int argc, char *argv[]) printf("All done.\n"); lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); return 0; } diff --git a/dev/msyncclient.c b/dev/msyncclient.c index 6ab7c79..5fffe7a 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); return -1; } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) printf("All done.\n"); lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); return 0; } diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 0c41c94..58a2544 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); return -1; } @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) printf("ERROR: Could not start service com.apple.syslog_relay.\n"); } - iphone_free_device(phone); + iphone_device_free(phone); return 0; } -- cgit v1.1-32-gdbae From 1cfc2748d38eb97100cabced3b282108898099c2 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:07:01 +0200 Subject: Rename iphone_get_device_handle to iphone_device_get_handle and update tools --- dev/syslog_relay.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'dev') diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 58a2544..a096101 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) char uuid[41]; int port = 0; uuid[0] = 0; + uint32_t handle = 0; signal(SIGINT, clean_exit); signal(SIGQUIT, clean_exit); @@ -111,8 +112,8 @@ int main(int argc, char *argv[]) lockdownd_client_free(client); /* connect to socket relay messages */ - - int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); + iphone_device_get_handle(phone, &handle); + int sfd = usbmuxd_connect(handle, port); if (sfd < 0) { printf("ERROR: Could not open usbmux connection.\n"); } else { -- cgit v1.1-32-gdbae From 50be30047dbb0d38fd8d61763c13ec75d2b52543 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:26:39 +0200 Subject: Update AFC API and use error codes from the STATUS operation response --- dev/afccheck.c | 16 ++++++++-------- dev/main.c | 46 +++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'dev') diff --git a/dev/afccheck.c b/dev/afccheck.c index 067dd5b..d06a147 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -55,18 +55,18 @@ void check_afc(gpointer data) uint64_t file = 0; char path[50]; sprintf(path, "/Buf%i", ((param *) data)->id); - afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); - afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); - afc_close_file(((param *) data)->afc, file); + afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RW, &file); + afc_file_write(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); + afc_file_close(((param *) data)->afc, file); file = 0; if (bytes != buffersize) printf("Write operation failed\n"); //now read it bytes = 0; - afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); - afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); - afc_close_file(((param *) data)->afc, file); + afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); + afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); + afc_file_close(((param *) data)->afc, file); if (bytes != buffersize) printf("Read operation failed\n"); @@ -79,7 +79,7 @@ void check_afc(gpointer data) } //cleanup - afc_delete_file(((param *) data)->afc, path); + afc_remove_path(((param *) data)->afc, path); g_thread_exit(0); } @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) return 1; } - afc_new_client(phone, port, &afc); + afc_client_new(phone, port, &afc); //makes sure thread environment is available if (!g_thread_supported()) diff --git a/dev/main.c b/dev/main.c index 5551ed9..3e5860e 100644 --- a/dev/main.c +++ b/dev/main.c @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) if (port) { afc_client_t afc = NULL; - afc_new_client(phone, port, &afc); + afc_client_new(phone, port, &afc); if (afc) { lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); if (npp) { @@ -126,18 +126,18 @@ int main(int argc, char *argv[]) perform_notification(phone, client, NP_SYNC_WILL_START); - afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); + afc_file_open(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); if (lockfile) { printf("locking file\n"); - afc_lock_file(afc, lockfile, AFC_LOCK_EX); + afc_file_lock(afc, lockfile, AFC_LOCK_EX); perform_notification(phone, client, NP_SYNC_DID_START); } char **dirs = NULL; - afc_get_dir_list(afc, "/eafaedf", &dirs); + afc_read_directory(afc, "/eafaedf", &dirs); if (!dirs) - afc_get_dir_list(afc, "/", &dirs); + afc_read_directory(afc, "/", &dirs); printf("Directory time.\n"); for (i = 0; dirs[i]; i++) { printf("/%s\n", dirs[i]); @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) g_strfreev(dirs); dirs = NULL; - afc_get_devinfo(afc, &dirs); + afc_get_device_info(afc, &dirs); if (dirs) { for (i = 0; dirs[i]; i += 2) { printf("%s: %s\n", dirs[i], dirs[i + 1]); @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) uint64_t my_file = 0; char **info = NULL; uint64_t fsize = 0; - if (IPHONE_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { + 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")) { @@ -166,59 +166,59 @@ int main(int argc, char *argv[]) } } - if (IPHONE_E_SUCCESS == - afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { + if (AFC_E_SUCCESS == + afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { printf("A file size: %llu\n", fsize); char *file_data = (char *) malloc(sizeof(char) * fsize); - afc_read_file(afc, my_file, file_data, fsize, &bytes); + 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_close_file(afc, my_file); + afc_file_close(afc, my_file); free(file_data); } else printf("couldn't open a file\n"); - afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); + 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_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); + 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_close_file(afc, my_file); + afc_file_close(afc, my_file); } printf("Deleting a file...\n"); - bytes = afc_delete_file(afc, "/delme"); + 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_file(afc, "/renme", "/renme2"); + 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_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); - if (IPHONE_E_SUCCESS != afc_seek_file(afc, my_file, 5, SEEK_CUR)) + 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_read_file(afc, my_file, threeletterword, 3, &bytes); + 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_close_file(afc, my_file); + afc_file_close(afc, my_file); } if (gnp && lockfile) { @@ -226,10 +226,10 @@ int main(int argc, char *argv[]) sleep(5); printf("XXX unlocking file\n"); - afc_lock_file(afc, lockfile, AFC_LOCK_UN); + afc_file_lock(afc, lockfile, AFC_LOCK_UN); printf("XXX closing file\n"); - afc_close_file(afc, lockfile); + afc_file_close(afc, lockfile); printf("XXX sleeping\n"); sleep(5); @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) gnp = NULL; } - afc_free_client(afc); + afc_client_free(afc); } else { printf("Start service failure.\n"); } -- cgit v1.1-32-gdbae From 0e255cfe381caedf0375e6834021333d971f8050 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:46:54 +0200 Subject: Implement afc_file_tell() and adjust afc_receive_data() to handle it --- dev/afccheck.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'dev') diff --git a/dev/afccheck.c b/dev/afccheck.c index d06a147..a9b666e 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -45,6 +45,8 @@ void check_afc(gpointer data) int *buf = (int *) malloc(buffersize); int *buf2 = (int *) malloc(buffersize); unsigned int bytes = 0; + uint64_t position = 0; + //fill buffer int i = 0; for (i = 0; i < BUFFER_SIZE; i++) { @@ -65,9 +67,12 @@ void check_afc(gpointer data) //now read it bytes = 0; afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); - afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); + afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize/2, &bytes); + afc_file_read(((param *) data)->afc, file, (char *) buf2 + (buffersize/2), buffersize/2, &bytes); + if(AFC_E_SUCCESS != afc_file_tell(((param *) data)->afc, file, &position)) + printf("Tell operation failed\n"); afc_file_close(((param *) data)->afc, file); - if (bytes != buffersize) + if (position != buffersize) printf("Read operation failed\n"); //compare buffers -- cgit v1.1-32-gdbae