summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2014-03-06 08:36:13 -0500
committerGravatar Martin Szulecki2014-03-12 19:26:42 +0100
commitee11102d5977442252b7ffcfbe00e27d11a08256 (patch)
tree58c40e9068032860a1b7cf87d4edaa0dda82c9b3
parent2636941a177dcbbb0fc1d00fd3213632b55c9b7d (diff)
downloadlibimobiledevice-ee11102d5977442252b7ffcfbe00e27d11a08256.tar.gz
libimobiledevice-ee11102d5977442252b7ffcfbe00e27d11a08256.tar.bz2
file_relay: Added file_relay_request_sources_timeout()
Signed-off-by: Martin Szulecki <m.szulecki@libimobiledevice.org>
-rw-r--r--include/libimobiledevice/file_relay.h1
-rw-r--r--src/file_relay.c41
2 files changed, 40 insertions, 2 deletions
diff --git a/include/libimobiledevice/file_relay.h b/include/libimobiledevice/file_relay.h
index 28ce2ab..d197f2e 100644
--- a/include/libimobiledevice/file_relay.h
+++ b/include/libimobiledevice/file_relay.h
@@ -55,6 +55,7 @@ file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_
55file_relay_error_t file_relay_client_free(file_relay_client_t client); 55file_relay_error_t file_relay_client_free(file_relay_client_t client);
56 56
57file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection); 57file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection);
58file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout);
58 59
59#ifdef __cplusplus 60#ifdef __cplusplus
60} 61}
diff --git a/src/file_relay.c b/src/file_relay.c
index eacaa11..3d064b9 100644
--- a/src/file_relay.c
+++ b/src/file_relay.c
@@ -116,6 +116,7 @@ file_relay_error_t file_relay_client_free(file_relay_client_t client)
116 * data using idevice_connection_receive(). The connection will be closed 116 * data using idevice_connection_receive(). The connection will be closed
117 * automatically by the device, but use file_relay_client_free() to clean 117 * automatically by the device, but use file_relay_client_free() to clean
118 * up properly. 118 * up properly.
119 * @param timeout Maximum time in milliseconds to wait for data.
119 * 120 *
120 * @note WARNING: Don't call this function without reading the data afterwards. 121 * @note WARNING: Don't call this function without reading the data afterwards.
121 * A directory mobile_file_relay.XXXX used for creating the archive will 122 * A directory mobile_file_relay.XXXX used for creating the archive will
@@ -128,7 +129,7 @@ file_relay_error_t file_relay_client_free(file_relay_client_t client)
128 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available 129 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
129 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise. 130 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
130 */ 131 */
131file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection) 132file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout)
132{ 133{
133 if (!client || !client->parent || !sources || !sources[0]) { 134 if (!client || !client->parent || !sources || !sources[0]) {
134 return FILE_RELAY_E_INVALID_ARG; 135 return FILE_RELAY_E_INVALID_ARG;
@@ -153,7 +154,7 @@ file_relay_error_t file_relay_request_sources(file_relay_client_t client, const
153 plist_free(dict); 154 plist_free(dict);
154 155
155 dict = NULL; 156 dict = NULL;
156 if (property_list_service_receive_plist_with_timeout(client->parent, &dict, 60000) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 157 if (property_list_service_receive_plist_with_timeout(client->parent, &dict, timeout) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
157 debug_info("ERROR: Could not receive answer from device!"); 158 debug_info("ERROR: Could not receive answer from device!");
158 err = FILE_RELAY_E_MUX_ERROR; 159 err = FILE_RELAY_E_MUX_ERROR;
159 goto leave; 160 goto leave;
@@ -216,3 +217,39 @@ leave:
216 } 217 }
217 return err; 218 return err;
218} 219}
220
221/**
222 * Request data for the given sources. Calls file_relay_request_sources_timeout() with
223 * a timeout of 60000 milliseconds (60 seconds).
224 *
225 * @param client The connected file_relay client.
226 * @param sources A NULL-terminated list of sources to retrieve.
227 * Valid sources are:
228 * - AppleSupport
229 * - Network
230 * - VPN
231 * - WiFi
232 * - UserDatabases
233 * - CrashReporter
234 * - tmp
235 * - SystemConfiguration
236 * @param connection The connection that has to be used for receiving the
237 * data using idevice_connection_receive(). The connection will be closed
238 * automatically by the device, but use file_relay_client_free() to clean
239 * up properly.
240 *
241 * @note WARNING: Don't call this function without reading the data afterwards.
242 * A directory mobile_file_relay.XXXX used for creating the archive will
243 * remain in the /tmp directory otherwise.
244 *
245 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
246 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
247 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
248 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
249 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
250 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
251 */
252file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection)
253{
254 return file_relay_request_sources_timeout(client, sources, connection, 60000);
255}