tracks.c | tracks.c | |||
---|---|---|---|---|
/** | /** | |||
* \file tracks.c | * \file tracks.c | |||
* Example program to list the tracks on a device. | * Example program to list the tracks on a device. | |||
* | * | |||
* Copyright (C) 2005-2007 Linus Walleij <triad@df.lth.se> | * Copyright (C) 2005-2012 Linus Walleij <triad@df.lth.se> | |||
* Copyright (C) 2007 Ted Bullock <tbullock@canada.com> | * Copyright (C) 2007 Ted Bullock <tbullock@canada.com> | |||
* | * | |||
* This library is free software; you can redistribute it and/or | * This library is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | * License as published by the Free Software Foundation; either | |||
* version 2 of the License, or (at your option) any later version. | * version 2 of the License, or (at your option) any later version. | |||
* | * | |||
* This library is distributed in the hope that it will be useful, | * This library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
skipping to change at line 84 | skipping to change at line 84 | |||
if (track->rating != 0) { | if (track->rating != 0) { | |||
printf(" User rating: %u (out of 100)\n", track->rating); | printf(" User rating: %u (out of 100)\n", track->rating); | |||
} | } | |||
if (track->usecount != 0) { | if (track->usecount != 0) { | |||
printf(" Use count: %u times\n", track->usecount); | printf(" Use count: %u times\n", track->usecount); | |||
} | } | |||
} | } | |||
int main (int argc, char **argv) | int main (int argc, char **argv) | |||
{ | { | |||
LIBMTP_mtpdevice_t *device_list, *iter; | LIBMTP_mtpdevice_t *device_list, *device; | |||
LIBMTP_track_t *tracks; | LIBMTP_track_t *tracks; | |||
LIBMTP_Init(); | LIBMTP_Init(); | |||
fprintf(stdout, "Attempting to connect device(s)\n"); | fprintf(stdout, "Attempting to connect device(s)\n"); | |||
switch(LIBMTP_Get_Connected_Devices(&device_list)) | switch(LIBMTP_Get_Connected_Devices(&device_list)) | |||
{ | { | |||
case LIBMTP_ERROR_NO_DEVICE_ATTACHED: | case LIBMTP_ERROR_NO_DEVICE_ATTACHED: | |||
fprintf(stdout, "mtp-tracks: No Devices have been found\n"); | fprintf(stdout, "mtp-tracks: No Devices have been found\n"); | |||
return 0; | return 0; | |||
skipping to change at line 116 | skipping to change at line 116 | |||
"this to the libmtp developers\n"); | "this to the libmtp developers\n"); | |||
return 1; | return 1; | |||
/* Successfully connected at least one device, so continue */ | /* Successfully connected at least one device, so continue */ | |||
case LIBMTP_ERROR_NONE: | case LIBMTP_ERROR_NONE: | |||
fprintf(stdout, "mtp-tracks: Successfully connected\n"); | fprintf(stdout, "mtp-tracks: Successfully connected\n"); | |||
fflush(stdout); | fflush(stdout); | |||
} | } | |||
/* iterate through connected MTP devices */ | /* iterate through connected MTP devices */ | |||
for(iter = device_list; iter != NULL; iter = iter->next) | for(device = device_list; device != NULL; device = device->next) { | |||
{ | char *friendlyname; | |||
char *friendlyname; | ||||
/* Echo the friendly name so we know which device we are working with * / | /* Echo the friendly name so we know which device we are working with * / | |||
friendlyname = LIBMTP_Get_Friendlyname(iter); | friendlyname = LIBMTP_Get_Friendlyname(device); | |||
if (friendlyname == NULL) { | if (friendlyname == NULL) { | |||
printf("Friendly name: (NULL)\n"); | printf("Friendly name: (NULL)\n"); | |||
} else { | } else { | |||
printf("Friendly name: %s\n", friendlyname); | printf("Friendly name: %s\n", friendlyname); | |||
free(friendlyname); | free(friendlyname); | |||
} | } | |||
// Get track listing. | ||||
// Get track listing. | tracks = LIBMTP_Get_Tracklisting_With_Callback(device, NULL, NULL); | |||
tracks = LIBMTP_Get_Tracklisting_With_Callback(iter, NULL, NULL); | if (tracks == NULL) { | |||
if (tracks == NULL) { | printf("No tracks.\n"); | |||
printf("No tracks.\n"); | } else { | |||
} else { | LIBMTP_track_t *track, *tmp; | |||
LIBMTP_track_t *track, *tmp; | track = tracks; | |||
track = tracks; | while (track != NULL) { | |||
while (track != NULL) { | dump_trackinfo(track); | |||
dump_trackinfo(track); | tmp = track; | |||
tmp = track; | track = track->next; | |||
track = track->next; | LIBMTP_destroy_track_t(tmp); | |||
LIBMTP_destroy_track_t(tmp); | } | |||
} | } | |||
} | ||||
} | } | |||
LIBMTP_Release_Device_List(device_list); | LIBMTP_Release_Device_List(device_list); | |||
printf("OK.\n"); | printf("OK.\n"); | |||
exit (0); | exit (0); | |||
} | } | |||
End of changes. 5 change blocks. | ||||
21 lines changed or deleted | 20 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |