diff options
| -rw-r--r-- | include/libimobiledevice/sbservices.h | 12 | ||||
| -rw-r--r-- | src/sbservices.c | 46 |
2 files changed, 58 insertions, 0 deletions
diff --git a/include/libimobiledevice/sbservices.h b/include/libimobiledevice/sbservices.h index 616168e..08cb740 100644 --- a/include/libimobiledevice/sbservices.h +++ b/include/libimobiledevice/sbservices.h | |||
| @@ -39,6 +39,17 @@ extern "C" { | |||
| 39 | #define SBSERVICES_E_UNKNOWN_ERROR -256 | 39 | #define SBSERVICES_E_UNKNOWN_ERROR -256 |
| 40 | /*@}*/ | 40 | /*@}*/ |
| 41 | 41 | ||
| 42 | /** @name Orientation of the user interface on the device */ | ||
| 43 | /*@{*/ | ||
| 44 | typedef enum { | ||
| 45 | SBSERVICES_INTERFACE_ORIENTATION_UNKNOWN = 0, | ||
| 46 | SBSERVICES_INTERFACE_ORIENTATION_PORTRAIT = 1, | ||
| 47 | SBSERVICES_INTERFACE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2, | ||
| 48 | SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_RIGHT = 3, | ||
| 49 | SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_LEFT = 4 | ||
| 50 | } sbservices_interface_orientation_t; | ||
| 51 | /*@}*/ | ||
| 52 | |||
| 42 | /** Represents an error code. */ | 53 | /** Represents an error code. */ |
| 43 | typedef int16_t sbservices_error_t; | 54 | typedef int16_t sbservices_error_t; |
| 44 | 55 | ||
| @@ -51,6 +62,7 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client); | |||
| 51 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version); | 62 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version); |
| 52 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); | 63 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); |
| 53 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); | 64 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); |
| 65 | sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation); | ||
| 54 | sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); | 66 | sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); |
| 55 | 67 | ||
| 56 | #ifdef __cplusplus | 68 | #ifdef __cplusplus |
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 | /** |
