summaryrefslogtreecommitdiffstats
path: root/dev/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/main.c')
-rw-r--r--dev/main.c89
1 files changed, 46 insertions, 43 deletions
diff --git a/dev/main.c b/dev/main.c
index f2d72b1..eb74c89 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");
@@ -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);
}
@@ -80,21 +80,21 @@ int main(int argc, char *argv[])
return -1;
}
- if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) {
- iphone_free_device(phone);
- printf("Exiting.\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);
- char *uid = NULL;
- if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) {
- printf("DeviceUniqueID : %s\n", uid);
- free(uid);
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ iphone_device_free(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);
}
@@ -103,20 +103,21 @@ 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) {
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");
}
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);
@@ -125,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, 2 | 4);
+ 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]);
@@ -145,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]);
@@ -156,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")) {
@@ -165,88 +166,90 @@ int main(int argc, char *argv[])
}
}
- if (IPHONE_E_SUCCESS ==
+ if (AFC_E_SUCCESS ==
afc_open_file(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_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) {
printf("XXX sleeping\n");
sleep(5);
- //perform_notification(phone, control, NP_SYNC_DID_FINISH);
-
printf("XXX unlocking file\n");
- afc_lock_file(afc, lockfile, 8 | 4);
+ 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);
+ //perform_notification(phone, client, NP_SYNC_DID_FINISH);
}
if (gnp) {
- np_free_client(gnp);
+ np_client_free(gnp);
gnp = NULL;
}
- afc_free_client(afc);
+ afc_client_free(afc);
} else {
printf("Start service failure.\n");
}
printf("All done.\n");
- lockdownd_free_client(client);
- iphone_free_device(phone);
+ lockdownd_client_free(client);
+ iphone_device_free(phone);
return 0;
}