diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/main.c | 40 |
1 files changed, 10 insertions, 30 deletions
| @@ -26,6 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | #include <libiphone/libiphone.h> | 27 | #include <libiphone/libiphone.h> |
| 28 | #include <libiphone/afc.h> | 28 | #include <libiphone/afc.h> |
| 29 | #include <libiphone/notification_proxy.h> | ||
| 29 | #include "../src/utils.h" | 30 | #include "../src/utils.h" |
| 30 | 31 | ||
| 31 | void notifier(const char *notification) | 32 | void notifier(const char *notification) |
| @@ -38,16 +39,16 @@ void notifier(const char *notification) | |||
| 38 | void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, const char *notification) | 39 | void perform_notification(iphone_device_t phone, iphone_lckd_client_t control, const char *notification) |
| 39 | { | 40 | { |
| 40 | int nport = 0; | 41 | int nport = 0; |
| 41 | iphone_np_client_t np; | 42 | np_client_t np; |
| 42 | 43 | ||
| 43 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); | 44 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); |
| 44 | if (nport) { | 45 | if (nport) { |
| 45 | printf("::::::::::::::: np was started ::::::::::::\n"); | 46 | printf("::::::::::::::: np was started ::::::::::::\n"); |
| 46 | iphone_np_new_client(phone, nport, &np); | 47 | np_new_client(phone, nport, &np); |
| 47 | if (np) { | 48 | if (np) { |
| 48 | printf("::::::::: PostNotification %s\n", notification); | 49 | printf("::::::::: PostNotification %s\n", notification); |
| 49 | iphone_np_post_notification(np, notification); | 50 | np_post_notification(np, notification); |
| 50 | iphone_np_free_client(np); | 51 | np_free_client(np); |
| 51 | } | 52 | } |
| 52 | } else { | 53 | } else { |
| 53 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); | 54 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); |
| @@ -61,7 +62,7 @@ int main(int argc, char *argv[]) | |||
| 61 | iphone_lckd_client_t control = NULL; | 62 | iphone_lckd_client_t control = NULL; |
| 62 | iphone_device_t phone = NULL; | 63 | iphone_device_t phone = NULL; |
| 63 | uint64_t lockfile = 0; | 64 | uint64_t lockfile = 0; |
| 64 | iphone_np_client_t gnp = NULL; | 65 | np_client_t gnp = NULL; |
| 65 | 66 | ||
| 66 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 67 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| 67 | iphone_set_debug(1); | 68 | iphone_set_debug(1); |
| @@ -104,7 +105,7 @@ int main(int argc, char *argv[]) | |||
| 104 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); | 105 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); |
| 105 | if (npp) { | 106 | if (npp) { |
| 106 | printf("Notification Proxy started.\n"); | 107 | printf("Notification Proxy started.\n"); |
| 107 | iphone_np_new_client(phone, npp, &gnp); | 108 | np_new_client(phone, npp, &gnp); |
| 108 | } else { | 109 | } else { |
| 109 | printf("ERROR: Notification proxy could not be started.\n"); | 110 | printf("ERROR: Notification proxy could not be started.\n"); |
| 110 | } | 111 | } |
| @@ -115,8 +116,8 @@ int main(int argc, char *argv[]) | |||
| 115 | NP_SYNC_RESUME_REQUEST, | 116 | NP_SYNC_RESUME_REQUEST, |
| 116 | NULL | 117 | NULL |
| 117 | }; | 118 | }; |
| 118 | iphone_np_observe_notifications(gnp, nspec); | 119 | np_observe_notifications(gnp, nspec); |
| 119 | iphone_np_set_notify_callback(gnp, notifier); | 120 | np_set_notify_callback(gnp, notifier); |
| 120 | } | 121 | } |
| 121 | 122 | ||
| 122 | perform_notification(phone, control, NP_SYNC_WILL_START); | 123 | perform_notification(phone, control, NP_SYNC_WILL_START); |
| @@ -219,28 +220,7 @@ int main(int argc, char *argv[]) | |||
| 219 | if (gnp && lockfile) { | 220 | if (gnp && lockfile) { |
| 220 | char *noti; | 221 | char *noti; |
| 221 | 222 | ||
| 222 | /* | ||
| 223 | noti = NULL; | ||
| 224 | iphone_np_get_notification(gnp, ¬i); | ||
| 225 | if (noti) { | ||
| 226 | printf("------> received notification '%s'\n", noti); | ||
| 227 | free(noti); | ||
| 228 | }*/ | ||
| 229 | |||
| 230 | printf("XXX sleeping\n"); | 223 | printf("XXX sleeping\n"); |
| 231 | /*for (i = 0; i < 5; i++) { | ||
| 232 | noti = NULL; | ||
| 233 | printf("--- getting notification\n"); | ||
| 234 | iphone_np_get_notification(gnp, ¬i); | ||
| 235 | if (noti) { | ||
| 236 | printf("------> received notification '%s'\n", noti); | ||
| 237 | free(noti); | ||
| 238 | } else { | ||
| 239 | printf("---- no notification\n"); | ||
| 240 | } | ||
| 241 | sleep(1); | ||
| 242 | } | ||
| 243 | */ | ||
| 244 | sleep(5); | 224 | sleep(5); |
| 245 | 225 | ||
| 246 | //perform_notification(phone, control, NP_SYNC_DID_FINISH); | 226 | //perform_notification(phone, control, NP_SYNC_DID_FINISH); |
| @@ -253,7 +233,7 @@ int main(int argc, char *argv[]) | |||
| 253 | } | 233 | } |
| 254 | 234 | ||
| 255 | if (gnp) { | 235 | if (gnp) { |
| 256 | iphone_np_free_client(gnp); | 236 | np_free_client(gnp); |
| 257 | gnp = NULL; | 237 | gnp = NULL; |
| 258 | } | 238 | } |
| 259 | 239 | ||
