summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2012-11-30 15:43:33 +0100
committerGravatar Martin Szulecki2012-11-30 15:43:33 +0100
commit4013a355c623c5de3db48f24e81174df88ef7f2c (patch)
treeeaf85e06c957c8297facffbac2bca2b454759546
parent0cc434f7aadc4ea0dd837e9461674eb76f963884 (diff)
downloadlibimobiledevice-4013a355c623c5de3db48f24e81174df88ef7f2c.tar.gz
libimobiledevice-4013a355c623c5de3db48f24e81174df88ef7f2c.tar.bz2
diagnostics_relay: Handle "UnknownRequest" status response correctly
-rw-r--r--include/libimobiledevice/diagnostics_relay.h1
-rw-r--r--src/diagnostics_relay.c58
2 files changed, 51 insertions, 8 deletions
diff --git a/include/libimobiledevice/diagnostics_relay.h b/include/libimobiledevice/diagnostics_relay.h
index c2e7d9e..bdb3f36 100644
--- a/include/libimobiledevice/diagnostics_relay.h
+++ b/include/libimobiledevice/diagnostics_relay.h
@@ -35,6 +35,7 @@ extern "C" {
#define DIAGNOSTICS_RELAY_E_INVALID_ARG -1
#define DIAGNOSTICS_RELAY_E_PLIST_ERROR -2
#define DIAGNOSTICS_RELAY_E_MUX_ERROR -3
+#define DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST -4
#define DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR -256
/*@}*/
diff --git a/src/diagnostics_relay.c b/src/diagnostics_relay.c
index 72a5fd7..7178952 100644
--- a/src/diagnostics_relay.c
+++ b/src/diagnostics_relay.c
@@ -26,6 +26,7 @@
#define RESULT_SUCCESS 0
#define RESULT_FAILURE 1
+#define RESULT_UNKNOWN_REQUEST 2
/**
* Internally used function for checking the result from a service response
@@ -56,6 +57,8 @@ static int diagnostics_relay_check_result(plist_t dict)
ret = RESULT_SUCCESS;
} else if (!strcmp(result_value, "Failure")) {
ret = RESULT_FAILURE;
+ } else if (!strcmp(result_value, "UnknownRequest")) {
+ ret = RESULT_UNKNOWN_REQUEST;
} else {
debug_info("ERROR: unknown result value '%s'", result_value);
}
@@ -205,10 +208,15 @@ diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t c
return DIAGNOSTICS_RELAY_E_PLIST_ERROR;
}
- if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) {
- debug_info("success");
+ int check = diagnostics_relay_check_result(dict);
+ if (check == RESULT_SUCCESS) {
ret = DIAGNOSTICS_RELAY_E_SUCCESS;
+ } else if (check == RESULT_UNKNOWN_REQUEST) {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST;
+ } else {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
}
+
plist_free(dict);
dict = NULL;
return ret;
@@ -243,8 +251,13 @@ diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t cli
return DIAGNOSTICS_RELAY_E_PLIST_ERROR;
}
- if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) {
+ int check = diagnostics_relay_check_result(dict);
+ if (check == RESULT_SUCCESS) {
ret = DIAGNOSTICS_RELAY_E_SUCCESS;
+ } else if (check == RESULT_UNKNOWN_REQUEST) {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST;
+ } else {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
}
plist_free(dict);
@@ -282,8 +295,13 @@ static diagnostics_relay_error_t internal_diagnostics_relay_action(diagnostics_r
return DIAGNOSTICS_RELAY_E_PLIST_ERROR;
}
- if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) {
+ int check = diagnostics_relay_check_result(dict);
+ if (check == RESULT_SUCCESS) {
ret = DIAGNOSTICS_RELAY_E_SUCCESS;
+ } else if (check == RESULT_UNKNOWN_REQUEST) {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST;
+ } else {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
}
plist_free(dict);
@@ -348,9 +366,15 @@ diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_rela
return DIAGNOSTICS_RELAY_E_PLIST_ERROR;
}
- if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) {
+ int check = diagnostics_relay_check_result(dict);
+ if (check == RESULT_SUCCESS) {
ret = DIAGNOSTICS_RELAY_E_SUCCESS;
+ } else if (check == RESULT_UNKNOWN_REQUEST) {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST;
+ } else {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
}
+
if (ret != DIAGNOSTICS_RELAY_E_SUCCESS) {
plist_free(dict);
return ret;
@@ -384,9 +408,15 @@ diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_rela
return DIAGNOSTICS_RELAY_E_PLIST_ERROR;
}
- if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) {
+ int check = diagnostics_relay_check_result(dict);
+ if (check == RESULT_SUCCESS) {
ret = DIAGNOSTICS_RELAY_E_SUCCESS;
+ } else if (check == RESULT_UNKNOWN_REQUEST) {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST;
+ } else {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
}
+
if (ret != DIAGNOSTICS_RELAY_E_SUCCESS) {
plist_free(dict);
return ret;
@@ -423,9 +453,15 @@ diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_r
return DIAGNOSTICS_RELAY_E_PLIST_ERROR;
}
- if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) {
+ int check = diagnostics_relay_check_result(dict);
+ if (check == RESULT_SUCCESS) {
ret = DIAGNOSTICS_RELAY_E_SUCCESS;
+ } else if (check == RESULT_UNKNOWN_REQUEST) {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST;
+ } else {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
}
+
if (ret != DIAGNOSTICS_RELAY_E_SUCCESS) {
plist_free(dict);
return ret;
@@ -459,9 +495,15 @@ diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_r
return DIAGNOSTICS_RELAY_E_PLIST_ERROR;
}
- if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) {
+ int check = diagnostics_relay_check_result(dict);
+ if (check == RESULT_SUCCESS) {
ret = DIAGNOSTICS_RELAY_E_SUCCESS;
+ } else if (check == RESULT_UNKNOWN_REQUEST) {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST;
+ } else {
+ ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
}
+
if (ret != DIAGNOSTICS_RELAY_E_SUCCESS) {
plist_free(dict);
return ret;