From 14868dc30c7e59f9838a6b67e2e15673f0f1557b Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sat, 1 Aug 2009 15:04:27 +0100 Subject: Add afc_get_device_info_field() helper function For use in front-end applications, also serves to document the available keys. --- src/AFC.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/AFC.c') diff --git a/src/AFC.c b/src/AFC.c index 826c9e5..d2761cf 100644 --- a/src/AFC.c +++ b/src/AFC.c @@ -468,6 +468,35 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***infos) return ret; } +/** Get a specific field of the device info for a client connection to phone. + * Known values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize. This is + * a helper function for afc_get_device_info(). + * + * @param client The client to get device info for. + * @param field The field to get the information for + * + * @return A char * or NULL if there was an error. + */ +char * afc_get_device_info_field(afc_client_t client, const char *field) +{ + char *ret = NULL; + char **kvps, **ptr; + + if (field == NULL || afc_get_device_info(client, &kvps) != AFC_E_SUCCESS) + return NULL; + + for (ptr = kvps; *ptr; ptr++) { + if (!strcmp(*ptr, field)) { + ret = strdup(*(ptr+1)); + break; + } + } + + g_strfreev(kvps); + + return ret; +} + /** Deletes a file or directory. * * @param client The client to use. -- cgit v1.1-32-gdbae