diff options
| -rw-r--r-- | src/SBServices.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/SBServices.c b/src/SBServices.c index 18f9fb6..7b6d3c8 100644 --- a/src/SBServices.c +++ b/src/SBServices.c | |||
| @@ -75,6 +75,17 @@ static sbservices_error_t sbservices_error(property_list_service_error_t err) | |||
| 75 | return SBSERVICES_E_UNKNOWN_ERROR; | 75 | return SBSERVICES_E_UNKNOWN_ERROR; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | /** | ||
| 79 | * Creates a new sbservices client. | ||
| 80 | * | ||
| 81 | * @param device The device to connect to. | ||
| 82 | * @param dst_port The port on device to connect to. | ||
| 83 | * @param client Pointer that will point to a newly allocated | ||
| 84 | * sbservices_client_t upon successful return. | ||
| 85 | * | ||
| 86 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
| 87 | * client is NULL, or an SBSERVICES_E_* error code otherwise. | ||
| 88 | */ | ||
| 78 | sbservices_error_t sbservices_client_new(iphone_device_t device, int dst_port, sbservices_client_t *client) | 89 | sbservices_error_t sbservices_client_new(iphone_device_t device, int dst_port, sbservices_client_t *client) |
| 79 | { | 90 | { |
| 80 | /* makes sure thread environment is available */ | 91 | /* makes sure thread environment is available */ |
| @@ -98,6 +109,14 @@ sbservices_error_t sbservices_client_new(iphone_device_t device, int dst_port, s | |||
| 98 | return SBSERVICES_E_SUCCESS; | 109 | return SBSERVICES_E_SUCCESS; |
| 99 | } | 110 | } |
| 100 | 111 | ||
| 112 | /** | ||
| 113 | * Frees an sbservices client. | ||
| 114 | * | ||
| 115 | * @param client The sbservices client to free. | ||
| 116 | * | ||
| 117 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
| 118 | * client is NULL, or an SBSERVICES_E_* error code otherwise. | ||
| 119 | */ | ||
| 101 | sbservices_error_t sbservices_client_free(sbservices_client_t client) | 120 | sbservices_error_t sbservices_client_free(sbservices_client_t client) |
| 102 | { | 121 | { |
| 103 | if (!client) | 122 | if (!client) |
| @@ -113,6 +132,16 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client) | |||
| 113 | return err; | 132 | return err; |
| 114 | } | 133 | } |
| 115 | 134 | ||
| 135 | /** | ||
| 136 | * Gets the icon state of the connected device. | ||
| 137 | * | ||
| 138 | * @param client The connected sbservices client to use. | ||
| 139 | * @param state Pointer that will point to a newly allocated plist containing | ||
| 140 | * the current icon state. It is up to the caller to free the memory. | ||
| 141 | * | ||
| 142 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
| 143 | * client or state is invalid, or an SBSERVICES_E_* error code otherwise. | ||
| 144 | */ | ||
| 116 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state) | 145 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state) |
| 117 | { | 146 | { |
| 118 | if (!client || !client->parent || !state) | 147 | if (!client || !client->parent || !state) |
| @@ -150,6 +179,15 @@ leave_unlock: | |||
| 150 | return res; | 179 | return res; |
| 151 | } | 180 | } |
| 152 | 181 | ||
| 182 | /** | ||
| 183 | * Sets the icon state of the connected device. | ||
| 184 | * | ||
| 185 | * @param client The connected sbservices client to use. | ||
| 186 | * @param newstate A plist containing the new iconstate. | ||
| 187 | * | ||
| 188 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
| 189 | * client or newstate is NULL, or an SBSERVICES_E_* error code otherwise. | ||
| 190 | */ | ||
| 153 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate) | 191 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate) |
| 154 | { | 192 | { |
| 155 | if (!client || !client->parent || !newstate) | 193 | if (!client || !client->parent || !newstate) |
| @@ -176,9 +214,24 @@ sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t | |||
| 176 | return res; | 214 | return res; |
| 177 | } | 215 | } |
| 178 | 216 | ||
| 217 | /** | ||
| 218 | * Get the icon of the specified app as PNG data. | ||
| 219 | * | ||
| 220 | * @param client The connected sbservices client to use. | ||
| 221 | * @param bundleId The bundle identifier of the app to retrieve the icon for. | ||
| 222 | * @param pngdata Pointer that will point to a newly allocated buffer | ||
| 223 | * containing the PNG data upon successful return. It is up to the caller | ||
| 224 | * to free the memory. | ||
| 225 | * @param pngsize Pointer to a uint64_t that will be set to the size of the | ||
| 226 | * buffer pngdata points to upon successful return. | ||
| 227 | * | ||
| 228 | * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when | ||
| 229 | * client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error | ||
| 230 | * code otherwise. | ||
| 231 | */ | ||
| 179 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize) | 232 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize) |
| 180 | { | 233 | { |
| 181 | if (!client || !client->parent || !pngdata) | 234 | if (!client || !client->parent || !bundleId || !pngdata) |
| 182 | return SBSERVICES_E_INVALID_ARG; | 235 | return SBSERVICES_E_INVALID_ARG; |
| 183 | 236 | ||
| 184 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; | 237 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; |
