diff options
author | Linus Walleij <triad@df.lth.se> | 2006-02-27 07:41:46 +0000 |
---|---|---|
committer | Linus Walleij <triad@df.lth.se> | 2006-02-27 07:41:46 +0000 |
commit | fa1374cddc69121507592512b952b9ecda75337d (patch) | |
tree | 6ad7866bb16eafeb4c7035b27976d670eb0f0d8f /examples/detect.c | |
parent | a498273e79afe255c4744ccbd3ea29afc3345aa5 (diff) | |
download | libmtp-fa1374cddc69121507592512b952b9ecda75337d.tar.gz |
More work.
Diffstat (limited to 'examples/detect.c')
-rw-r--r-- | examples/detect.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/examples/detect.c b/examples/detect.c index 8e0f35c..780f7bc 100644 --- a/examples/detect.c +++ b/examples/detect.c @@ -1,9 +1,17 @@ #include "common.h" +#include <stdlib.h> int main (int argc, char **argv) { LIBMTP_mtpdevice_t *device; + uint64_t totalbytes; + uint64_t freebytes; + char *storage_description; + char *volume_label; char *owner; + uint8_t maxbattlevel; + uint8_t currbattlevel; + int ret; LIBMTP_Init(); device = LIBMTP_Get_First_Device(); @@ -12,17 +20,52 @@ int main (int argc, char **argv) exit (0); } - // Get owners name + // The owner name owner = LIBMTP_Get_Ownername(device); if (owner == NULL) { - printf("Owner name: (NULL)\n"); + printf(" Owner name: (NULL)\n"); } else { - printf("Owner name: %s\n", owner); + printf(" Owner name: %s\n", owner); free(owner); } + // Some storage info + ret = LIBMTP_Get_Storageinfo(device, &totalbytes, &freebytes, &storage_description, &volume_label); + if (ret == 0) { +#ifdef __WIN32__ + printf(" Total bytes on device: %I64u (%I64u MB)\n", + totalbytes, totalbytes/(1024*1024)); + printf(" Free bytes on device: %I64u (%I64u MB)\n", + freebytes, freebytes/(1024*1024)); +#else + printf(" Total bytes on device: %llu (%llu MB)\n", + totalbytes, totalbytes/(1024*1024)); + printf(" Free bytes on device: %llu (%llu MB)\n", + freebytes, freebytes/(1024*1024)); +#endif + if (storage_description != NULL) { + printf(" Storage description: \"%s\"\n", storage_description); + free(storage_description); + } + if (volume_label != NULL) { + printf(" Volume label: \"%s\"\n", volume_label); + free(volume_label); + } + } else { + printf(" Error getting disk info...\n"); + } + + // Some battery info + ret = LIBMTP_Get_Batterylevel(device, &maxbattlevel, &currbattlevel); + if (ret == 0) { + printf(" Battery level %d of %d (%d%%)\n",currbattlevel, maxbattlevel, + (currbattlevel/maxbattlevel * 100)); + } else { + printf(" Error getting battery info...\n"); + } + + // King Fisher of Triad rocks your world! LIBMTP_Release_Device(device); printf("OK.\n"); exit (0); } - |