diff options
| author | 2012-05-14 01:40:28 +0200 | |
|---|---|---|
| committer | 2012-10-21 14:19:50 +0200 | |
| commit | 1e81510664853114d123a7154e236b538356111b (patch) | |
| tree | 601f7573aa538620b530c9f482e9e7f1efe91790 | |
| parent | 046093a4ba12d374006c1ea3a7a5a4bfe8bc4c3d (diff) | |
| download | libimobiledevice-1e81510664853114d123a7154e236b538356111b.tar.gz libimobiledevice-1e81510664853114d123a7154e236b538356111b.tar.bz2 | |
diagnostics_relay: Implement query functions for MobileGestalt and IORegistry
| -rw-r--r-- | include/libimobiledevice/diagnostics_relay.h | 3 | ||||
| -rw-r--r-- | src/diagnostics_relay.c | 111 |
2 files changed, 114 insertions, 0 deletions
diff --git a/include/libimobiledevice/diagnostics_relay.h b/include/libimobiledevice/diagnostics_relay.h index 5a82931..c2e7d9e 100644 --- a/include/libimobiledevice/diagnostics_relay.h +++ b/include/libimobiledevice/diagnostics_relay.h | |||
| @@ -62,6 +62,9 @@ diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t cli | |||
| 62 | diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags); | 62 | diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags); |
| 63 | diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags); | 63 | diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags); |
| 64 | diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics); | 64 | diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics); |
| 65 | diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result); | ||
| 66 | diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* name, const char* class, plist_t* result); | ||
| 67 | diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result); | ||
| 65 | 68 | ||
| 66 | #ifdef __cplusplus | 69 | #ifdef __cplusplus |
| 67 | } | 70 | } |
diff --git a/src/diagnostics_relay.c b/src/diagnostics_relay.c index f289fd9..72a5fd7 100644 --- a/src/diagnostics_relay.c +++ b/src/diagnostics_relay.c | |||
| @@ -364,3 +364,114 @@ diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_rela | |||
| 364 | plist_free(dict); | 364 | plist_free(dict); |
| 365 | return ret; | 365 | return ret; |
| 366 | } | 366 | } |
| 367 | |||
| 368 | diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result) | ||
| 369 | { | ||
| 370 | if (!client || plist_get_node_type(keys) != PLIST_ARRAY || result == NULL) | ||
| 371 | return DIAGNOSTICS_RELAY_E_INVALID_ARG; | ||
| 372 | |||
| 373 | diagnostics_relay_error_t ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR; | ||
| 374 | |||
| 375 | plist_t dict = plist_new_dict(); | ||
| 376 | plist_dict_insert_item(dict,"MobileGestaltKeys", plist_copy(keys)); | ||
| 377 | plist_dict_insert_item(dict,"Request", plist_new_string("MobileGestalt")); | ||
| 378 | ret = diagnostics_relay_send(client, dict); | ||
| 379 | plist_free(dict); | ||
| 380 | dict = NULL; | ||
| 381 | |||
| 382 | ret = diagnostics_relay_receive(client, &dict); | ||
| 383 | if (!dict) { | ||
| 384 | return DIAGNOSTICS_RELAY_E_PLIST_ERROR; | ||
| 385 | } | ||
| 386 | |||
| 387 | if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) { | ||
| 388 | ret = DIAGNOSTICS_RELAY_E_SUCCESS; | ||
| 389 | } | ||
| 390 | if (ret != DIAGNOSTICS_RELAY_E_SUCCESS) { | ||
| 391 | plist_free(dict); | ||
| 392 | return ret; | ||
| 393 | } | ||
| 394 | |||
| 395 | plist_t value_node = plist_dict_get_item(dict, "Diagnostics"); | ||
| 396 | if (value_node) { | ||
| 397 | *result = plist_copy(value_node); | ||
| 398 | } | ||
| 399 | |||
| 400 | plist_free(dict); | ||
| 401 | return ret; | ||
| 402 | } | ||
| 403 | |||
| 404 | diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* name, const char* class, plist_t* result) | ||
| 405 | { | ||
| 406 | if (!client || (name == NULL && class == NULL) || result == NULL) | ||
| 407 | return DIAGNOSTICS_RELAY_E_INVALID_ARG; | ||
| 408 | |||
| 409 | diagnostics_relay_error_t ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR; | ||
| 410 | |||
| 411 | plist_t dict = plist_new_dict(); | ||
| 412 | if (name) | ||
| 413 | plist_dict_insert_item(dict,"EntryName", plist_new_string(name)); | ||
| 414 | if (class) | ||
| 415 | plist_dict_insert_item(dict,"EntryClass", plist_new_string(class)); | ||
| 416 | plist_dict_insert_item(dict,"Request", plist_new_string("IORegistry")); | ||
| 417 | ret = diagnostics_relay_send(client, dict); | ||
| 418 | plist_free(dict); | ||
| 419 | dict = NULL; | ||
| 420 | |||
| 421 | ret = diagnostics_relay_receive(client, &dict); | ||
| 422 | if (!dict) { | ||
| 423 | return DIAGNOSTICS_RELAY_E_PLIST_ERROR; | ||
| 424 | } | ||
| 425 | |||
| 426 | if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) { | ||
| 427 | ret = DIAGNOSTICS_RELAY_E_SUCCESS; | ||
| 428 | } | ||
| 429 | if (ret != DIAGNOSTICS_RELAY_E_SUCCESS) { | ||
| 430 | plist_free(dict); | ||
| 431 | return ret; | ||
| 432 | } | ||
| 433 | |||
| 434 | plist_t value_node = plist_dict_get_item(dict, "Diagnostics"); | ||
| 435 | if (value_node) { | ||
| 436 | *result = plist_copy(value_node); | ||
| 437 | } | ||
| 438 | |||
| 439 | plist_free(dict); | ||
| 440 | return ret; | ||
| 441 | } | ||
| 442 | |||
| 443 | diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result) | ||
| 444 | { | ||
| 445 | if (!client || plane == NULL || result == NULL) | ||
| 446 | return DIAGNOSTICS_RELAY_E_INVALID_ARG; | ||
| 447 | |||
| 448 | diagnostics_relay_error_t ret = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR; | ||
| 449 | |||
| 450 | plist_t dict = plist_new_dict(); | ||
| 451 | plist_dict_insert_item(dict,"CurrentPlane", plist_new_string(plane)); | ||
| 452 | plist_dict_insert_item(dict,"Request", plist_new_string("IORegistry")); | ||
| 453 | ret = diagnostics_relay_send(client, dict); | ||
| 454 | plist_free(dict); | ||
| 455 | dict = NULL; | ||
| 456 | |||
| 457 | ret = diagnostics_relay_receive(client, &dict); | ||
| 458 | if (!dict) { | ||
| 459 | return DIAGNOSTICS_RELAY_E_PLIST_ERROR; | ||
| 460 | } | ||
| 461 | |||
| 462 | if (diagnostics_relay_check_result(dict) == RESULT_SUCCESS) { | ||
| 463 | ret = DIAGNOSTICS_RELAY_E_SUCCESS; | ||
| 464 | } | ||
| 465 | if (ret != DIAGNOSTICS_RELAY_E_SUCCESS) { | ||
| 466 | plist_free(dict); | ||
| 467 | return ret; | ||
| 468 | } | ||
| 469 | |||
| 470 | plist_t value_node = plist_dict_get_item(dict, "Diagnostics"); | ||
| 471 | if (value_node) { | ||
| 472 | *result = plist_copy(value_node); | ||
| 473 | } | ||
| 474 | |||
| 475 | plist_free(dict); | ||
| 476 | return ret; | ||
| 477 | } | ||
