diff options
| author | 2012-04-07 18:20:47 +0200 | |
|---|---|---|
| committer | 2012-04-07 18:20:47 +0200 | |
| commit | 1c39477bba4c2e88fd193a03c18209eb7db91f75 (patch) | |
| tree | f801204be6a8bdfe2817096232a8eaf8e485dea9 /src/sbservices.c | |
| parent | a3d02692d3772767ae847ed2f32c1203cfb7e42a (diff) | |
| download | libimobiledevice-1c39477bba4c2e88fd193a03c18209eb7db91f75.tar.gz libimobiledevice-1c39477bba4c2e88fd193a03c18209eb7db91f75.tar.bz2 | |
sbservices: Implement retrieving interface orientation from device
Diffstat (limited to 'src/sbservices.c')
| -rw-r--r-- | src/sbservices.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/sbservices.c b/src/sbservices.c index 7f050bf..2c17d8c 100644 --- a/src/sbservices.c +++ b/src/sbservices.c | |||
| @@ -283,7 +283,53 @@ leave_unlock: | |||
| 283 | } | 283 | } |
| 284 | sbs_unlock(client); | 284 | sbs_unlock(client); |
| 285 | return res; | 285 | return res; |
| 286 | } | ||
| 286 | 287 | ||
| 288 | /** | ||
| 289 | * Gets the interface orientation of the device. | ||
| 290 | * | ||
| 291 | * @param client The connected sbservices client to use. | ||
| 292 | * @param interface_orientation The interface orientation upon successful return. | ||
| 293 | * | ||
| 294 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
| 295 | * client or state is invalid, or an SBSERVICES_E_* error code otherwise. | ||
| 296 | */ | ||
| 297 | sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation) | ||
| 298 | { | ||
| 299 | if (!client || !client->parent || !interface_orientation) | ||
| 300 | return SBSERVICES_E_INVALID_ARG; | ||
| 301 | |||
| 302 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; | ||
| 303 | |||
| 304 | plist_t dict = plist_new_dict(); | ||
| 305 | plist_dict_insert_item(dict, "command", plist_new_string("getInterfaceOrientation")); | ||
| 306 | |||
| 307 | sbs_lock(client); | ||
| 308 | |||
| 309 | res = sbservices_error(property_list_service_send_binary_plist(client->parent, dict)); | ||
| 310 | if (res != SBSERVICES_E_SUCCESS) { | ||
| 311 | debug_info("could not send plist, error %d", res); | ||
| 312 | goto leave_unlock; | ||
| 313 | } | ||
| 314 | plist_free(dict); | ||
| 315 | dict = NULL; | ||
| 316 | |||
| 317 | res = sbservices_error(property_list_service_receive_plist(client->parent, &dict)); | ||
| 318 | if (res == SBSERVICES_E_SUCCESS) { | ||
| 319 | plist_t node = plist_dict_get_item(dict, "interfaceOrientation"); | ||
| 320 | if (node) { | ||
| 321 | uint64_t value = SBSERVICES_INTERFACE_ORIENTATION_UNKNOWN; | ||
| 322 | plist_get_uint_val(node, &value); | ||
| 323 | *interface_orientation = (sbservices_interface_orientation_t)value; | ||
| 324 | } | ||
| 325 | } | ||
| 326 | |||
| 327 | leave_unlock: | ||
| 328 | if (dict) { | ||
| 329 | plist_free(dict); | ||
| 330 | } | ||
| 331 | sbs_unlock(client); | ||
| 332 | return res; | ||
| 287 | } | 333 | } |
| 288 | 334 | ||
| 289 | /** | 335 | /** |
