diff options
| -rw-r--r-- | src/AFC.h | 35 | ||||
| -rw-r--r-- | src/NotificationProxy.c | 71 | ||||
| -rw-r--r-- | src/NotificationProxy.h | 1 |
3 files changed, 53 insertions, 54 deletions
| @@ -59,33 +59,32 @@ struct iphone_afc_file_int { | |||
| 59 | enum { | 59 | enum { |
| 60 | AFC_ERROR = 0x00000001, | 60 | AFC_ERROR = 0x00000001, |
| 61 | AFC_SUCCESS_RESPONSE = 0x00000002, | 61 | AFC_SUCCESS_RESPONSE = 0x00000002, |
| 62 | AFC_LIST_DIR = 0x00000003, // ReadDir | 62 | AFC_LIST_DIR = 0x00000003, // ReadDir |
| 63 | // 0x00000004 // ReadFile | 63 | // 0x00000004 // ReadFile |
| 64 | // 0x00000005 // WriteFile | 64 | // 0x00000005 // WriteFile |
| 65 | // 0x00000006 // WritePart | 65 | // 0x00000006 // WritePart |
| 66 | AFC_TRUNCATE = 0x00000007, // Truncate | 66 | AFC_TRUNCATE = 0x00000007, // Truncate |
| 67 | AFC_DELETE = 0x00000008, // RemovePath | 67 | AFC_DELETE = 0x00000008, // RemovePath |
| 68 | AFC_MAKE_DIR = 0x00000009, // MakeDir | 68 | AFC_MAKE_DIR = 0x00000009, // MakeDir |
| 69 | AFC_GET_INFO = 0x0000000a, // GetFileInfo | 69 | AFC_GET_INFO = 0x0000000a, // GetFileInfo |
| 70 | AFC_GET_DEVINFO = 0x0000000b, // GetDeviceInfo | 70 | AFC_GET_DEVINFO = 0x0000000b, // GetDeviceInfo |
| 71 | // 0x0000000c // same as 5, but writes to temp file, then renames it. | 71 | // 0x0000000c // same as 5, but writes to temp file, then renames it. |
| 72 | AFC_FILE_OPEN = 0x0000000d, // FileRefOpen | 72 | AFC_FILE_OPEN = 0x0000000d, // FileRefOpen |
| 73 | AFC_FILE_HANDLE = 0x0000000e, // _unknownPacket | 73 | AFC_FILE_HANDLE = 0x0000000e, // _unknownPacket |
| 74 | AFC_READ = 0x0000000f, // FileRefRead | 74 | AFC_READ = 0x0000000f, // FileRefRead |
| 75 | AFC_WRITE = 0x00000010, // FileRefWrite | 75 | AFC_WRITE = 0x00000010, // FileRefWrite |
| 76 | AFC_FILE_SEEK = 0x00000011, // FileRefSeek | 76 | AFC_FILE_SEEK = 0x00000011, // FileRefSeek |
| 77 | AFC_FILE_TELL = 0x00000012, // FileRefTell | 77 | AFC_FILE_TELL = 0x00000012, // FileRefTell |
| 78 | // 0x00000013 // _unknownPacket | 78 | // 0x00000013 // _unknownPacket |
| 79 | AFC_FILE_CLOSE = 0x00000014, // FileRefClose | 79 | AFC_FILE_CLOSE = 0x00000014, // FileRefClose |
| 80 | AFC_FILE_TRUNCATE = 0x00000015, // FileRefSetFileSize (ftruncate) | 80 | AFC_FILE_TRUNCATE = 0x00000015, // FileRefSetFileSize (ftruncate) |
| 81 | // 0x00000016 // SetFatalError | 81 | // 0x00000016 // SetFatalError |
| 82 | // 0x00000017 // SetConnectionOptions | 82 | // 0x00000017 // SetConnectionOptions |
| 83 | AFC_RENAME = 0x00000018, // RenamePath | 83 | AFC_RENAME = 0x00000018, // RenamePath |
| 84 | // 0x00000019 // SetFSBlockSize (0x800000) | 84 | // 0x00000019 // SetFSBlockSize (0x800000) |
| 85 | // 0x0000001A // SetBlockSize (0x800000) | 85 | // 0x0000001A // SetBlockSize (0x800000) |
| 86 | AFC_FILE_LOCK = 0x0000001B, // FileRefLock | 86 | AFC_FILE_LOCK = 0x0000001B, // FileRefLock |
| 87 | AFC_MAKE_LINK = 0x0000001C // MakeLink | 87 | AFC_MAKE_LINK = 0x0000001C // MakeLink |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | uint32 iphone_afc_get_file_handle(iphone_afc_file_t file); | 90 | uint32 iphone_afc_get_file_handle(iphone_afc_file_t file); |
| 91 | |||
diff --git a/src/NotificationProxy.c b/src/NotificationProxy.c index b0c10ea..c13a547 100644 --- a/src/NotificationProxy.c +++ b/src/NotificationProxy.c | |||
| @@ -52,7 +52,7 @@ static void np_unlock(iphone_np_client_t client) | |||
| 52 | * | 52 | * |
| 53 | * @return A handle to the newly-connected client or NULL upon error. | 53 | * @return A handle to the newly-connected client or NULL upon error. |
| 54 | */ | 54 | */ |
| 55 | iphone_error_t iphone_np_new_client ( iphone_device_t device, int src_port, int dst_port, iphone_np_client_t *client ) | 55 | iphone_error_t iphone_np_new_client(iphone_device_t device, int src_port, int dst_port, iphone_np_client_t * client) |
| 56 | { | 56 | { |
| 57 | int ret = IPHONE_E_SUCCESS; | 57 | int ret = IPHONE_E_SUCCESS; |
| 58 | 58 | ||
| @@ -75,16 +75,16 @@ iphone_error_t iphone_np_new_client ( iphone_device_t device, int src_port, int | |||
| 75 | client_loc->mutex = g_mutex_new(); | 75 | client_loc->mutex = g_mutex_new(); |
| 76 | 76 | ||
| 77 | *client = client_loc; | 77 | *client = client_loc; |
| 78 | return IPHONE_E_SUCCESS; | 78 | return IPHONE_E_SUCCESS; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | /** Disconnects an NP client from the phone. | 81 | /** Disconnects an NP client from the phone. |
| 82 | * | 82 | * |
| 83 | * @param client The client to disconnect. | 83 | * @param client The client to disconnect. |
| 84 | */ | 84 | */ |
| 85 | iphone_error_t iphone_np_free_client ( iphone_np_client_t client ) | 85 | iphone_error_t iphone_np_free_client(iphone_np_client_t client) |
| 86 | { | 86 | { |
| 87 | if (!client || !client->connection ) | 87 | if (!client || !client->connection) |
| 88 | return IPHONE_E_INVALID_ARG; | 88 | return IPHONE_E_INVALID_ARG; |
| 89 | 89 | ||
| 90 | iphone_mux_free_client(client->connection); | 90 | iphone_mux_free_client(client->connection); |
| @@ -101,11 +101,11 @@ iphone_error_t iphone_np_free_client ( iphone_np_client_t client ) | |||
| 101 | * @param client The client to send to | 101 | * @param client The client to send to |
| 102 | * @param notification The notification Message | 102 | * @param notification The notification Message |
| 103 | */ | 103 | */ |
| 104 | iphone_error_t iphone_np_post_notification( iphone_np_client_t client, const char *notification ) | 104 | iphone_error_t iphone_np_post_notification(iphone_np_client_t client, const char *notification) |
| 105 | { | 105 | { |
| 106 | xmlDocPtr plist; | 106 | xmlDocPtr plist; |
| 107 | xmlNode *dict, *key; | 107 | xmlNode *dict, *key; |
| 108 | char *XML_content; | 108 | char *XML_content; |
| 109 | uint32_t length; | 109 | uint32_t length; |
| 110 | int bytes; | 110 | int bytes; |
| 111 | iphone_error_t ret; | 111 | iphone_error_t ret; |
| @@ -126,11 +126,11 @@ iphone_error_t iphone_np_post_notification( iphone_np_client_t client, const cha | |||
| 126 | 126 | ||
| 127 | nlen = htonl(length); | 127 | nlen = htonl(length); |
| 128 | 128 | ||
| 129 | memcpy(sndbuf+sndlen, &nlen, 4); | 129 | memcpy(sndbuf + sndlen, &nlen, 4); |
| 130 | sndlen += 4; | 130 | sndlen += 4; |
| 131 | memcpy(sndbuf+sndlen, XML_content, length); | 131 | memcpy(sndbuf + sndlen, XML_content, length); |
| 132 | sndlen += length; | 132 | sndlen += length; |
| 133 | 133 | ||
| 134 | xmlFree(XML_content); | 134 | xmlFree(XML_content); |
| 135 | xmlFreeDoc(plist); | 135 | xmlFreeDoc(plist); |
| 136 | 136 | ||
| @@ -141,11 +141,11 @@ iphone_error_t iphone_np_post_notification( iphone_np_client_t client, const cha | |||
| 141 | 141 | ||
| 142 | nlen = htonl(length); | 142 | nlen = htonl(length); |
| 143 | 143 | ||
| 144 | memcpy(sndbuf+sndlen, &nlen, 4); | 144 | memcpy(sndbuf + sndlen, &nlen, 4); |
| 145 | sndlen+=4; | 145 | sndlen += 4; |
| 146 | 146 | ||
| 147 | memcpy(sndbuf+sndlen, XML_content, length); | 147 | memcpy(sndbuf + sndlen, XML_content, length); |
| 148 | sndlen+=length; | 148 | sndlen += length; |
| 149 | 149 | ||
| 150 | xmlFree(XML_content); | 150 | xmlFree(XML_content); |
| 151 | xmlFreeDoc(plist); | 151 | xmlFreeDoc(plist); |
| @@ -154,7 +154,7 @@ iphone_error_t iphone_np_post_notification( iphone_np_client_t client, const cha | |||
| 154 | log_debug_buffer(sndbuf, sndlen); | 154 | log_debug_buffer(sndbuf, sndlen); |
| 155 | 155 | ||
| 156 | iphone_mux_send(client->connection, sndbuf, sndlen, &bytes); | 156 | iphone_mux_send(client->connection, sndbuf, sndlen, &bytes); |
| 157 | if (bytes <= 0) { | 157 | if (bytes <= 0) { |
| 158 | np_unlock(client); | 158 | np_unlock(client); |
| 159 | return bytes; | 159 | return bytes; |
| 160 | } | 160 | } |
| @@ -178,29 +178,30 @@ iphone_error_t iphone_np_post_notification( iphone_np_client_t client, const cha | |||
| 178 | * | 178 | * |
| 179 | * @param client The client to send to | 179 | * @param client The client to send to |
| 180 | */ | 180 | */ |
| 181 | iphone_error_t iphone_np_observe_notification( iphone_np_client_t client ) | 181 | iphone_error_t iphone_np_observe_notification(iphone_np_client_t client) |
| 182 | { | 182 | { |
| 183 | xmlDocPtr plist; | 183 | xmlDocPtr plist; |
| 184 | xmlNode *dict, *key; | 184 | xmlNode *dict, *key; |
| 185 | char *XML_content; | 185 | char *XML_content; |
| 186 | uint32_t length; | 186 | uint32_t length; |
| 187 | int bytes; | 187 | int bytes; |
| 188 | iphone_error_t ret; | 188 | iphone_error_t ret; |
| 189 | unsigned char sndbuf[4096]; | 189 | unsigned char sndbuf[4096]; |
| 190 | int sndlen = 0; | 190 | int sndlen = 0; |
| 191 | int nlen; | 191 | int nlen; |
| 192 | int i=0; | 192 | int i = 0; |
| 193 | char *notifications[10] = { | 193 | char *notifications[10] = { |
| 194 | "com.apple.itunes-client.syncCancelRequest", | 194 | "com.apple.itunes-client.syncCancelRequest", |
| 195 | "com.apple.itunes-client.syncSuspendRequest", | 195 | "com.apple.itunes-client.syncSuspendRequest", |
| 196 | "com.apple.itunes-client.syncResumeRequest", | 196 | "com.apple.itunes-client.syncResumeRequest", |
| 197 | "com.apple.mobile.lockdown.phone_number_changed", | 197 | "com.apple.mobile.lockdown.phone_number_changed", |
| 198 | "com.apple.mobile.lockdown.device_name_changed", | 198 | "com.apple.mobile.lockdown.device_name_changed", |
| 199 | "com.apple.springboard.attemptactivation", | 199 | "com.apple.springboard.attemptactivation", |
| 200 | "com.apple.mobile.data_sync.domain_changed", | 200 | "com.apple.mobile.data_sync.domain_changed", |
| 201 | "com.apple.mobile.application_installed", | 201 | "com.apple.mobile.application_installed", |
| 202 | "com.apple.mobile.application_uninstalled", | 202 | "com.apple.mobile.application_uninstalled", |
| 203 | NULL}; | 203 | NULL |
| 204 | }; | ||
| 204 | 205 | ||
| 205 | sndlen = 0; | 206 | sndlen = 0; |
| 206 | 207 | ||
| @@ -217,11 +218,11 @@ iphone_error_t iphone_np_observe_notification( iphone_np_client_t client ) | |||
| 217 | xmlDocDumpMemory(plist, (xmlChar **) & XML_content, &length); | 218 | xmlDocDumpMemory(plist, (xmlChar **) & XML_content, &length); |
| 218 | 219 | ||
| 219 | nlen = htonl(length); | 220 | nlen = htonl(length); |
| 220 | memcpy(sndbuf+sndlen, &nlen, 4); | 221 | memcpy(sndbuf + sndlen, &nlen, 4); |
| 221 | sndlen += 4; | 222 | sndlen += 4; |
| 222 | memcpy(sndbuf+sndlen, XML_content, length); | 223 | memcpy(sndbuf + sndlen, XML_content, length); |
| 223 | sndlen += length; | 224 | sndlen += length; |
| 224 | 225 | ||
| 225 | xmlFree(XML_content); | 226 | xmlFree(XML_content); |
| 226 | xmlFreeDoc(plist); | 227 | xmlFreeDoc(plist); |
| 227 | } | 228 | } |
| @@ -233,11 +234,11 @@ iphone_error_t iphone_np_observe_notification( iphone_np_client_t client ) | |||
| 233 | 234 | ||
| 234 | nlen = htonl(length); | 235 | nlen = htonl(length); |
| 235 | 236 | ||
| 236 | memcpy(sndbuf+sndlen, &nlen, 4); | 237 | memcpy(sndbuf + sndlen, &nlen, 4); |
| 237 | sndlen+=4; | 238 | sndlen += 4; |
| 238 | 239 | ||
| 239 | memcpy(sndbuf+sndlen, XML_content, length); | 240 | memcpy(sndbuf + sndlen, XML_content, length); |
| 240 | sndlen+=length; | 241 | sndlen += length; |
| 241 | 242 | ||
| 242 | xmlFree(XML_content); | 243 | xmlFree(XML_content); |
| 243 | xmlFreeDoc(plist); | 244 | xmlFreeDoc(plist); |
| @@ -246,7 +247,7 @@ iphone_error_t iphone_np_observe_notification( iphone_np_client_t client ) | |||
| 246 | log_debug_buffer(sndbuf, sndlen); | 247 | log_debug_buffer(sndbuf, sndlen); |
| 247 | 248 | ||
| 248 | iphone_mux_send(client->connection, sndbuf, sndlen, &bytes); | 249 | iphone_mux_send(client->connection, sndbuf, sndlen, &bytes); |
| 249 | if (bytes <= 0) { | 250 | if (bytes <= 0) { |
| 250 | np_unlock(client); | 251 | np_unlock(client); |
| 251 | return bytes; | 252 | return bytes; |
| 252 | } | 253 | } |
diff --git a/src/NotificationProxy.h b/src/NotificationProxy.h index 7b47346..b2fa3d9 100644 --- a/src/NotificationProxy.h +++ b/src/NotificationProxy.h | |||
| @@ -27,4 +27,3 @@ struct iphone_np_client_int { | |||
| 27 | iphone_umux_client_t connection; | 27 | iphone_umux_client_t connection; |
| 28 | GMutex *mutex; | 28 | GMutex *mutex; |
| 29 | }; | 29 | }; |
| 30 | |||
