summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice/notification_proxy.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libimobiledevice/notification_proxy.h')
-rw-r--r--include/libimobiledevice/notification_proxy.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/include/libimobiledevice/notification_proxy.h b/include/libimobiledevice/notification_proxy.h
index 4f025ee..a66057b 100644
--- a/include/libimobiledevice/notification_proxy.h
+++ b/include/libimobiledevice/notification_proxy.h
@@ -93,13 +93,103 @@ typedef np_client_private *np_client_t; /**< The client handle. */
93typedef void (*np_notify_cb_t) (const char *notification, void *user_data); 93typedef void (*np_notify_cb_t) (const char *notification, void *user_data);
94 94
95/* Interface */ 95/* Interface */
96
97/**
98 * Connects to the notification_proxy on the specified device.
99 *
100 * @param device The device to connect to.
101 * @param service The service descriptor returned by lockdownd_start_service.
102 * @param client Pointer that will be set to a newly allocated np_client_t
103 * upon successful return.
104 *
105 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when device is NULL,
106 * or NP_E_CONN_FAILED when the connection to the device could not be
107 * established.
108 */
96np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client); 109np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client);
110
111/**
112 * Starts a new notification proxy service on the specified device and connects to it.
113 *
114 * @param device The device to connect to.
115 * @param client Pointer that will point to a newly allocated
116 * np_client_t upon successful return. Must be freed using
117 * np_client_free() after use.
118 * @param label The label to use for communication. Usually the program name.
119 * Pass NULL to disable sending the label in requests to lockdownd.
120 *
121 * @return NP_E_SUCCESS on success, or an NP_E_* error
122 * code otherwise.
123 */
97np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label); 124np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label);
125
126/**
127 * Disconnects a notification_proxy client from the device and frees up the
128 * notification_proxy client data.
129 *
130 * @param client The notification_proxy client to disconnect and free.
131 *
132 * @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL.
133 */
98np_error_t np_client_free(np_client_t client); 134np_error_t np_client_free(np_client_t client);
99 135
136
137/**
138 * Sends a notification to the device's notification_proxy.
139 *
140 * @param client The client to send to
141 * @param notification The notification message to send
142 *
143 * @return NP_E_SUCCESS on success, or an error returned by np_plist_send
144 */
100np_error_t np_post_notification(np_client_t client, const char *notification); 145np_error_t np_post_notification(np_client_t client, const char *notification);
146
147/**
148 * Tells the device to send a notification on the specified event.
149 *
150 * @param client The client to send to
151 * @param notification The notifications that should be observed.
152 *
153 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or
154 * notification are NULL, or an error returned by np_plist_send.
155 */
101np_error_t np_observe_notification(np_client_t client, const char *notification); 156np_error_t np_observe_notification(np_client_t client, const char *notification);
157
158/**
159 * Tells the device to send a notification on specified events.
160 *
161 * @param client The client to send to
162 * @param notification_spec Specification of the notifications that should be
163 * observed. This is expected to be an array of const char* that MUST have a
164 * terminating NULL entry.
165 *
166 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null,
167 * or an error returned by np_observe_notification.
168 */
102np_error_t np_observe_notifications(np_client_t client, const char **notification_spec); 169np_error_t np_observe_notifications(np_client_t client, const char **notification_spec);
170
171/**
172 * This function allows an application to define a callback function that will
173 * be called when a notification has been received.
174 * It will start a thread that polls for notifications and calls the callback
175 * function if a notification has been received.
176 * In case of an error condition when polling for notifications - e.g. device
177 * disconnect - the thread will call the callback function with an empty
178 * notification "" and terminate itself.
179 *
180 * @param client the NP client
181 * @param notify_cb pointer to a callback function or NULL to de-register a
182 * previously set callback function.
183 * @param user_data Pointer that will be passed to the callback function as
184 * user data. If notify_cb is NULL, this parameter is ignored.
185 *
186 * @note Only one callback function can be registered at the same time;
187 * any previously set callback function will be removed automatically.
188 *
189 * @return NP_E_SUCCESS when the callback was successfully registered,
190 * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
191 * the callback thread could no be created.
192 */
103np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata); 193np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata);
104 194
105#ifdef __cplusplus 195#ifdef __cplusplus