summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice/webinspector.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libimobiledevice/webinspector.h')
-rw-r--r--include/libimobiledevice/webinspector.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/include/libimobiledevice/webinspector.h b/include/libimobiledevice/webinspector.h
new file mode 100644
index 0000000..16d2ca2
--- /dev/null
+++ b/include/libimobiledevice/webinspector.h
@@ -0,0 +1,137 @@
1/**
2 * @file libimobiledevice/webinspector.h
3 * @brief WebKit Remote Debugging.
4 * \internal
5 *
6 * Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved.
7 * Copyright (c) 2013 Yury Melnichek All Rights Reserved.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef IWEBINSPECTOR_H
25#define IWEBINSPECTOR_H
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <libimobiledevice/libimobiledevice.h>
32#include <libimobiledevice/lockdown.h>
33
34/** Service identifier passed to lockdownd_start_service() to start the webinspector service */
35#define WEBINSPECTOR_SERVICE_NAME "com.apple.webinspector"
36
37/** Error Codes */
38typedef enum {
39 WEBINSPECTOR_E_SUCCESS = 0,
40 WEBINSPECTOR_E_INVALID_ARG = -1,
41 WEBINSPECTOR_E_PLIST_ERROR = -2,
42 WEBINSPECTOR_E_MUX_ERROR = -3,
43 WEBINSPECTOR_E_SSL_ERROR = -4,
44 WEBINSPECTOR_E_RECEIVE_TIMEOUT = -5,
45 WEBINSPECTOR_E_NOT_ENOUGH_DATA = -6,
46 WEBINSPECTOR_E_UNKNOWN_ERROR = -256
47} webinspector_error_t;
48
49typedef struct webinspector_client_private webinspector_client_private; /**< \private */
50typedef webinspector_client_private *webinspector_client_t; /**< The client handle. */
51
52
53/**
54 * Connects to the webinspector service on the specified device.
55 *
56 * @param device The device to connect to.
57 * @param service The service descriptor returned by lockdownd_start_service.
58 * @param client Pointer that will point to a newly allocated
59 * webinspector_client_t upon successful return. Must be freed using
60 * webinspector_client_free() after use.
61 *
62 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
63 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
64 */
65LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client);
66
67/**
68 * Starts a new webinspector service on the specified device and connects to it.
69 *
70 * @param device The device to connect to.
71 * @param client Pointer that will point to a newly allocated
72 * webinspector_client_t upon successful return. Must be freed using
73 * webinspector_client_free() after use.
74 * @param label The label to use for communication. Usually the program name.
75 * Pass NULL to disable sending the label in requests to lockdownd.
76 *
77 * @return WEBINSPECTOR_E_SUCCESS on success, or an WEBINSPECTOR_E_* error
78 * code otherwise.
79 */
80LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label);
81
82/**
83 * Disconnects a webinspector client from the device and frees up the
84 * webinspector client data.
85 *
86 * @param client The webinspector client to disconnect and free.
87 *
88 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
89 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
90 */
91LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_free(webinspector_client_t client);
92
93
94/**
95 * Sends a plist to the service.
96 *
97 * @param client The webinspector client
98 * @param plist The plist to send
99 *
100 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
101 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
102 */
103LIBIMOBILEDEVICE_API webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist);
104
105/**
106 * Receives a plist from the service.
107 *
108 * @param client The webinspector client
109 * @param plist The plist to store the received data
110 *
111 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
112 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
113 */
114LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist);
115
116/**
117 * Receives a plist using the given webinspector client.
118 *
119 * @param client The webinspector client to use for receiving
120 * @param plist pointer to a plist_t that will point to the received plist
121 * upon successful return
122 * @param timeout_ms Maximum time in milliseconds to wait for data.
123 *
124 * @return WEBINSPECTOR_E_SUCCESS on success,
125 * WEBINSPECTOR_E_INVALID_ARG when client or *plist is NULL,
126 * WEBINSPECTOR_E_PLIST_ERROR when the received data cannot be
127 * converted to a plist, WEBINSPECTOR_E_MUX_ERROR when a
128 * communication error occurs, or WEBINSPECTOR_E_UNKNOWN_ERROR
129 * when an unspecified error occurs.
130 */
131LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms);
132
133#ifdef __cplusplus
134}
135#endif
136
137#endif