summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/notification_proxy.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/notification_proxy.c b/src/notification_proxy.c
index 3015ed9..cd8e64c 100644
--- a/src/notification_proxy.c
+++ b/src/notification_proxy.c
@@ -186,13 +186,8 @@ LIBIMOBILEDEVICE_API np_error_t np_post_notification(np_client_t client, const c
186 return res; 186 return res;
187} 187}
188 188
189LIBIMOBILEDEVICE_API np_error_t np_observe_notification( np_client_t client, const char *notification ) 189static np_error_t internal_np_observe_notification(np_client_t client, const char *notification)
190{ 190{
191 if (!client || !notification) {
192 return NP_E_INVALID_ARG;
193 }
194 np_lock(client);
195
196 plist_t dict = plist_new_dict(); 191 plist_t dict = plist_new_dict();
197 plist_dict_set_item(dict,"Command", plist_new_string("ObserveNotification")); 192 plist_dict_set_item(dict,"Command", plist_new_string("ObserveNotification"));
198 plist_dict_set_item(dict,"Name", plist_new_string(notification)); 193 plist_dict_set_item(dict,"Name", plist_new_string(notification));
@@ -203,6 +198,16 @@ LIBIMOBILEDEVICE_API np_error_t np_observe_notification( np_client_t client, con
203 } 198 }
204 plist_free(dict); 199 plist_free(dict);
205 200
201 return res;
202}
203
204LIBIMOBILEDEVICE_API np_error_t np_observe_notification( np_client_t client, const char *notification )
205{
206 if (!client || !notification) {
207 return NP_E_INVALID_ARG;
208 }
209 np_lock(client);
210 np_error_t res = internal_np_observe_notification(client, notification);
206 np_unlock(client); 211 np_unlock(client);
207 return res; 212 return res;
208} 213}
@@ -221,13 +226,15 @@ LIBIMOBILEDEVICE_API np_error_t np_observe_notifications(np_client_t client, con
221 return NP_E_INVALID_ARG; 226 return NP_E_INVALID_ARG;
222 } 227 }
223 228
229 np_lock(client);
224 while (notifications[i]) { 230 while (notifications[i]) {
225 res = np_observe_notification(client, notifications[i]); 231 res = internal_np_observe_notification(client, notifications[i]);
226 if (res != NP_E_SUCCESS) { 232 if (res != NP_E_SUCCESS) {
227 break; 233 break;
228 } 234 }
229 i++; 235 i++;
230 } 236 }
237 np_unlock(client);
231 238
232 return res; 239 return res;
233} 240}