summaryrefslogtreecommitdiffstats
path: root/src/NotificationProxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/NotificationProxy.c')
-rw-r--r--src/NotificationProxy.c71
1 files changed, 36 insertions, 35 deletions
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 */
55iphone_error_t iphone_np_new_client ( iphone_device_t device, int src_port, int dst_port, iphone_np_client_t *client ) 55iphone_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 */
85iphone_error_t iphone_np_free_client ( iphone_np_client_t client ) 85iphone_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 */
104iphone_error_t iphone_np_post_notification( iphone_np_client_t client, const char *notification ) 104iphone_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 */
181iphone_error_t iphone_np_observe_notification( iphone_np_client_t client ) 181iphone_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 }