diff options
| author | 2009-12-09 20:27:09 +0100 | |
|---|---|---|
| committer | 2009-12-11 08:58:07 -0800 | |
| commit | 4c00fb43042a1e8d1a4e2d29827d00ed3144575f (patch) | |
| tree | eb2adf1571f9eb177181fcb510cd631761a18509 /src/NotificationProxy.c | |
| parent | 318cc4f7b336109819c7b4c6a1a9f2e8d37d9bed (diff) | |
| download | libimobiledevice-4c00fb43042a1e8d1a4e2d29827d00ed3144575f.tar.gz libimobiledevice-4c00fb43042a1e8d1a4e2d29827d00ed3144575f.tar.bz2 | |
Documentation cleanup and a new error code
[#96 state:resolved]
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/NotificationProxy.c')
| -rw-r--r-- | src/NotificationProxy.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/NotificationProxy.c b/src/NotificationProxy.c index 884be5f..160ac4a 100644 --- a/src/NotificationProxy.c +++ b/src/NotificationProxy.c | |||
| @@ -62,7 +62,9 @@ static void np_unlock(np_client_t client) | |||
| 62 | * @param client NP to send data to | 62 | * @param client NP to send data to |
| 63 | * @param dict plist to send | 63 | * @param dict plist to send |
| 64 | * | 64 | * |
| 65 | * @return NP_E_SUCCESS or an error code. | 65 | * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or dict |
| 66 | * are NULL, NP_E_PLIST_ERROR when dict is not a valid plist, | ||
| 67 | * or NP_E_UNKNOWN_ERROR when an unspecified error occurs. | ||
| 66 | */ | 68 | */ |
| 67 | static np_error_t np_plist_send(np_client_t client, plist_t dict) | 69 | static np_error_t np_plist_send(np_client_t client, plist_t dict) |
| 68 | { | 70 | { |
| @@ -105,11 +107,14 @@ static np_error_t np_plist_send(np_client_t client, plist_t dict) | |||
| 105 | 107 | ||
| 106 | /** Makes a connection to the NP service on the phone. | 108 | /** Makes a connection to the NP service on the phone. |
| 107 | * | 109 | * |
| 108 | * @param phone The iPhone to connect on. | 110 | * @param device The device to connect to. |
| 109 | * @param s_port The source port. | 111 | * @param dst_port Destination port (usually given by lockdownd_start_service). |
| 110 | * @param d_port The destination port. | 112 | * @param client Pointer that will be set to a newly allocated np_client_t |
| 113 | * upon successful return. | ||
| 111 | * | 114 | * |
| 112 | * @return A handle to the newly-connected client or NULL upon error. | 115 | * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when device is NULL, |
| 116 | * or NP_E_CONN_FAILED when the connection to the device could not be | ||
| 117 | * established. | ||
| 113 | */ | 118 | */ |
| 114 | np_error_t np_client_new(iphone_device_t device, int dst_port, np_client_t *client) | 119 | np_error_t np_client_new(iphone_device_t device, int dst_port, np_client_t *client) |
| 115 | { | 120 | { |
| @@ -123,7 +128,7 @@ np_error_t np_client_new(iphone_device_t device, int dst_port, np_client_t *clie | |||
| 123 | /* Attempt connection */ | 128 | /* Attempt connection */ |
| 124 | iphone_connection_t connection = NULL; | 129 | iphone_connection_t connection = NULL; |
| 125 | if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) { | 130 | if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) { |
| 126 | return NP_E_UNKNOWN_ERROR; | 131 | return NP_E_CONN_FAILED; |
| 127 | } | 132 | } |
| 128 | 133 | ||
| 129 | np_client_t client_loc = (np_client_t) malloc(sizeof(struct np_client_int)); | 134 | np_client_t client_loc = (np_client_t) malloc(sizeof(struct np_client_int)); |
| @@ -137,9 +142,11 @@ np_error_t np_client_new(iphone_device_t device, int dst_port, np_client_t *clie | |||
| 137 | return NP_E_SUCCESS; | 142 | return NP_E_SUCCESS; |
| 138 | } | 143 | } |
| 139 | 144 | ||
| 140 | /** Disconnects an NP client from the phone. | 145 | /** Disconnects an NP client from the device. |
| 141 | * | 146 | * |
| 142 | * @param client The client to disconnect. | 147 | * @param client The client to disconnect. |
| 148 | * | ||
| 149 | * @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL. | ||
| 143 | */ | 150 | */ |
| 144 | np_error_t np_client_free(np_client_t client) | 151 | np_error_t np_client_free(np_client_t client) |
| 145 | { | 152 | { |
| @@ -168,6 +175,8 @@ np_error_t np_client_free(np_client_t client) | |||
| 168 | * | 175 | * |
| 169 | * @param client The client to send to | 176 | * @param client The client to send to |
| 170 | * @param notification The notification message to send | 177 | * @param notification The notification message to send |
| 178 | * | ||
| 179 | * @return NP_E_SUCCESS on success, or an error returned by np_plist_send | ||
| 171 | */ | 180 | */ |
| 172 | np_error_t np_post_notification(np_client_t client, const char *notification) | 181 | np_error_t np_post_notification(np_client_t client, const char *notification) |
| 173 | { | 182 | { |
| @@ -201,6 +210,9 @@ np_error_t np_post_notification(np_client_t client, const char *notification) | |||
| 201 | * | 210 | * |
| 202 | * @param client The client to send to | 211 | * @param client The client to send to |
| 203 | * @param notification The notifications that should be observed. | 212 | * @param notification The notifications that should be observed. |
| 213 | * | ||
| 214 | * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or | ||
| 215 | * notification are NULL, or an error returned by np_plist_send. | ||
| 204 | */ | 216 | */ |
| 205 | np_error_t np_observe_notification( np_client_t client, const char *notification ) | 217 | np_error_t np_observe_notification( np_client_t client, const char *notification ) |
| 206 | { | 218 | { |
| @@ -241,6 +253,9 @@ np_error_t np_observe_notification( np_client_t client, const char *notification | |||
| 241 | * observed. This is expected to be an array of const char* that MUST have a | 253 | * observed. This is expected to be an array of const char* that MUST have a |
| 242 | * terminating NULL entry. However this parameter can be NULL; in this case, | 254 | * terminating NULL entry. However this parameter can be NULL; in this case, |
| 243 | * the default set of notifications will be used. | 255 | * the default set of notifications will be used. |
| 256 | * | ||
| 257 | * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null, | ||
| 258 | * or an error returned by np_observe_notification. | ||
| 244 | */ | 259 | */ |
| 245 | np_error_t np_observe_notifications(np_client_t client, const char **notification_spec) | 260 | np_error_t np_observe_notifications(np_client_t client, const char **notification_spec) |
| 246 | { | 261 | { |
| @@ -275,7 +290,7 @@ np_error_t np_observe_notifications(np_client_t client, const char **notificatio | |||
| 275 | * with the notification that has been received. | 290 | * with the notification that has been received. |
| 276 | * | 291 | * |
| 277 | * @return 0 if a notification has been received or nothing has been received, | 292 | * @return 0 if a notification has been received or nothing has been received, |
| 278 | * or an error value if an error occured. | 293 | * or a negative value if an error occured. |
| 279 | * | 294 | * |
| 280 | * @note You probably want to check out np_set_notify_callback | 295 | * @note You probably want to check out np_set_notify_callback |
| 281 | * @see np_set_notify_callback | 296 | * @see np_set_notify_callback |
| @@ -401,10 +416,14 @@ gpointer np_notifier( gpointer arg ) | |||
| 401 | * | 416 | * |
| 402 | * @param client the NP client | 417 | * @param client the NP client |
| 403 | * @param notify_cb pointer to a callback function or NULL to de-register a | 418 | * @param notify_cb pointer to a callback function or NULL to de-register a |
| 404 | * previously set callback function | 419 | * previously set callback function. |
| 420 | * | ||
| 421 | * @note Only one callback function can be registered at the same time; | ||
| 422 | * any previously set callback function will be removed automatically. | ||
| 405 | * | 423 | * |
| 406 | * @return NP_E_SUCCESS when the callback was successfully registered, | 424 | * @return NP_E_SUCCESS when the callback was successfully registered, |
| 407 | * or an error value when an error occured. | 425 | * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when |
| 426 | * the callback thread could no be created. | ||
| 408 | */ | 427 | */ |
| 409 | np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb ) | 428 | np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb ) |
| 410 | { | 429 | { |
