diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/device_link_service.c | 28 | ||||
-rw-r--r-- | src/device_link_service.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/device_link_service.c b/src/device_link_service.c index 7baef02..430b1db 100644 --- a/src/device_link_service.c +++ b/src/device_link_service.c @@ -254,6 +254,34 @@ device_link_service_error_t device_link_service_disconnect(device_link_service_c } /** + * Sends a DLMessagePing plist. + * + * @param client The device link service client to use. + * @param message String to send as ping message. + * + * @return DEVICE_LINK_SERVICE_E_SUCCESS on success, + * DEVICE_LINK_SERVICE_E_INVALID_ARG if client or message is invalid, + * or DEVICE_LINK_SERVICE_E_MUX_ERROR if the DLMessagePing plist could + * not be sent. + */ +device_link_service_error_t device_link_service_send_ping(device_link_service_client_t client, const char *message) +{ + if (!client || !client->parent || !message) + return DEVICE_LINK_SERVICE_E_INVALID_ARG; + + plist_t array = plist_new_array(); + plist_array_append_item(array, plist_new_string("DLMessagePing")); + plist_array_append_item(array, plist_new_string(message)); + + device_link_service_error_t err = DEVICE_LINK_SERVICE_E_SUCCESS; + if (property_list_service_send_binary_plist(client->parent, array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { + err = DEVICE_LINK_SERVICE_E_MUX_ERROR; + } + plist_free(array); + return err; +} + +/** * Sends a DLMessageProcessMessage plist. * * @param client The device link service client to use. diff --git a/src/device_link_service.h b/src/device_link_service.h index b90ddcc..4e652c4 100644 --- a/src/device_link_service.h +++ b/src/device_link_service.h @@ -44,6 +44,7 @@ typedef int16_t device_link_service_error_t; device_link_service_error_t device_link_service_client_new(idevice_t device, uint16_t port, device_link_service_client_t *client); device_link_service_error_t device_link_service_client_free(device_link_service_client_t client); device_link_service_error_t device_link_service_version_exchange(device_link_service_client_t client, uint64_t version_major, uint64_t version_minor); +device_link_service_error_t device_link_service_send_ping(device_link_service_client_t client, const char *message); device_link_service_error_t device_link_service_send_process_message(device_link_service_client_t client, plist_t message); device_link_service_error_t device_link_service_receive_process_message(device_link_service_client_t client, plist_t *message); device_link_service_error_t device_link_service_disconnect(device_link_service_client_t client); |