summaryrefslogtreecommitdiffstats
path: root/dev/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/main.c')
-rw-r--r--dev/main.c35
1 files changed, 18 insertions, 17 deletions
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 @@
23#include <string.h> 23#include <string.h>
24#include <errno.h> 24#include <errno.h>
25#include <usb.h> 25#include <usb.h>
26#include <glib.h>
26 27
27#include <libiphone/libiphone.h> 28#include <libiphone/libiphone.h>
29#include <libiphone/lockdown.h>
28#include <libiphone/afc.h> 30#include <libiphone/afc.h>
29#include <libiphone/notification_proxy.h> 31#include <libiphone/notification_proxy.h>
30#include "../src/utils.h" 32#include "../src/utils.h"
31 33
32void notifier(const char *notification) 34static void notifier(const char *notification)
33{ 35{
34 printf("---------------------------------------------------------\n"); 36 printf("---------------------------------------------------------\n");
35 printf("------> Notification received: %s\n", notification); 37 printf("------> Notification received: %s\n", notification);
36 printf("---------------------------------------------------------\n"); 38 printf("---------------------------------------------------------\n");
37} 39}
38 40
39void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, const char *notification) 41static void perform_notification(iphone_device_t phone, lockdownd_client_t client, const char *notification)
40{ 42{
41 int nport = 0; 43 int nport = 0;
42 np_client_t np; 44 np_client_t np;
43 45
44 iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); 46 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport);
45 if (nport) { 47 if (nport) {
46 printf("::::::::::::::: np was started ::::::::::::\n"); 48 printf("::::::::::::::: np was started ::::::::::::\n");
47 np_new_client(phone, nport, &np); 49 np_new_client(phone, nport, &np);
@@ -57,9 +59,10 @@ void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, c
57 59
58int main(int argc, char *argv[]) 60int main(int argc, char *argv[])
59{ 61{
60 int bytes = 0, port = 0, i = 0; 62 unsigned int bytes = 0;
63 int port = 0, i = 0;
61 int npp; 64 int npp;
62 iphone_lckd_client_t control = NULL; 65 lockdownd_client_t client = NULL;
63 iphone_device_t phone = NULL; 66 iphone_device_t phone = NULL;
64 uint64_t lockfile = 0; 67 uint64_t lockfile = 0;
65 np_client_t gnp = NULL; 68 np_client_t gnp = NULL;
@@ -77,32 +80,32 @@ int main(int argc, char *argv[])
77 return -1; 80 return -1;
78 } 81 }
79 82
80 if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { 83 if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) {
81 iphone_free_device(phone); 84 iphone_free_device(phone);
82 printf("Exiting.\n"); 85 printf("Exiting.\n");
83 return -1; 86 return -1;
84 } 87 }
85 88
86 char *uid = NULL; 89 char *uid = NULL;
87 if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid)) { 90 if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) {
88 printf("DeviceUniqueID : %s\n", uid); 91 printf("DeviceUniqueID : %s\n", uid);
89 free(uid); 92 free(uid);
90 } 93 }
91 94
92 95
93 char *nnn = NULL; 96 char *nnn = NULL;
94 if (IPHONE_E_SUCCESS == lockdownd_get_device_name(control, &nnn)) { 97 if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) {
95 printf("DeviceName : %s\n", nnn); 98 printf("DeviceName : %s\n", nnn);
96 free(nnn); 99 free(nnn);
97 } 100 }
98 101
99 iphone_lckd_start_service(control, "com.apple.afc", &port); 102 lockdownd_start_service(client, "com.apple.afc", &port);
100 103
101 if (port) { 104 if (port) {
102 afc_client_t afc = NULL; 105 afc_client_t afc = NULL;
103 afc_new_client(phone, port, &afc); 106 afc_new_client(phone, port, &afc);
104 if (afc) { 107 if (afc) {
105 iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); 108 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp);
106 if (npp) { 109 if (npp) {
107 printf("Notification Proxy started.\n"); 110 printf("Notification Proxy started.\n");
108 np_new_client(phone, npp, &gnp); 111 np_new_client(phone, npp, &gnp);
@@ -120,14 +123,14 @@ int main(int argc, char *argv[])
120 np_set_notify_callback(gnp, notifier); 123 np_set_notify_callback(gnp, notifier);
121 } 124 }
122 125
123 perform_notification(phone, control, NP_SYNC_WILL_START); 126 perform_notification(phone, client, NP_SYNC_WILL_START);
124 127
125 afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); 128 afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile);
126 if (lockfile) { 129 if (lockfile) {
127 printf("locking file\n"); 130 printf("locking file\n");
128 afc_lock_file(afc, lockfile, 2 | 4); 131 afc_lock_file(afc, lockfile, 2 | 4);
129 132
130 perform_notification(phone, control, NP_SYNC_DID_START); 133 perform_notification(phone, client, NP_SYNC_DID_START);
131 } 134 }
132 135
133 char **dirs = NULL; 136 char **dirs = NULL;
@@ -164,10 +167,10 @@ int main(int argc, char *argv[])
164 167
165 if (IPHONE_E_SUCCESS == 168 if (IPHONE_E_SUCCESS ==
166 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { 169 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) {
167 printf("A file size: %i\n", fsize); 170 printf("A file size: %llu\n", fsize);
168 char *file_data = (char *) malloc(sizeof(char) * fsize); 171 char *file_data = (char *) malloc(sizeof(char) * fsize);
169 afc_read_file(afc, my_file, file_data, fsize, &bytes); 172 afc_read_file(afc, my_file, file_data, fsize, &bytes);
170 if (bytes >= 0) { 173 if (bytes > 0) {
171 printf("The file's data:\n"); 174 printf("The file's data:\n");
172 fwrite(file_data, 1, bytes, stdout); 175 fwrite(file_data, 1, bytes, stdout);
173 } 176 }
@@ -218,8 +221,6 @@ int main(int argc, char *argv[])
218 } 221 }
219 222
220 if (gnp && lockfile) { 223 if (gnp && lockfile) {
221 char *noti;
222
223 printf("XXX sleeping\n"); 224 printf("XXX sleeping\n");
224 sleep(5); 225 sleep(5);
225 226
@@ -244,7 +245,7 @@ int main(int argc, char *argv[])
244 245
245 printf("All done.\n"); 246 printf("All done.\n");
246 247
247 iphone_lckd_free_client(control); 248 lockdownd_free_client(client);
248 iphone_free_device(phone); 249 iphone_free_device(phone);
249 250
250 return 0; 251 return 0;