summaryrefslogtreecommitdiffstats
path: root/src/sbservices.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2012-04-07 18:20:47 +0200
committerGravatar Martin Szulecki2012-04-07 18:20:47 +0200
commit1c39477bba4c2e88fd193a03c18209eb7db91f75 (patch)
treef801204be6a8bdfe2817096232a8eaf8e485dea9 /src/sbservices.c
parenta3d02692d3772767ae847ed2f32c1203cfb7e42a (diff)
downloadlibimobiledevice-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.c46
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:
}
sbs_unlock(client);
return res;
+}
+/**
+ * Gets the interface orientation of the device.
+ *
+ * @param client The connected sbservices client to use.
+ * @param interface_orientation The interface orientation upon successful return.
+ *
+ * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
+ * client or state is invalid, or an SBSERVICES_E_* error code otherwise.
+ */
+sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation)
+{
+ if (!client || !client->parent || !interface_orientation)
+ return SBSERVICES_E_INVALID_ARG;
+
+ sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR;
+
+ plist_t dict = plist_new_dict();
+ plist_dict_insert_item(dict, "command", plist_new_string("getInterfaceOrientation"));
+
+ sbs_lock(client);
+
+ res = sbservices_error(property_list_service_send_binary_plist(client->parent, dict));
+ if (res != SBSERVICES_E_SUCCESS) {
+ debug_info("could not send plist, error %d", res);
+ goto leave_unlock;
+ }
+ plist_free(dict);
+ dict = NULL;
+
+ res = sbservices_error(property_list_service_receive_plist(client->parent, &dict));
+ if (res == SBSERVICES_E_SUCCESS) {
+ plist_t node = plist_dict_get_item(dict, "interfaceOrientation");
+ if (node) {
+ uint64_t value = SBSERVICES_INTERFACE_ORIENTATION_UNKNOWN;
+ plist_get_uint_val(node, &value);
+ *interface_orientation = (sbservices_interface_orientation_t)value;
+ }
+ }
+
+leave_unlock:
+ if (dict) {
+ plist_free(dict);
+ }
+ sbs_unlock(client);
+ return res;
}
/**