Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: examples/albums.c

Issue 2364793002: Revert "Uprev libmtp to 1.1.12" (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libmtp@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « examples/albumart.c ('k') | examples/detect.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/albums.c
diff --git a/examples/albums.c b/examples/albums.c
index 23c8d5911719e7f61eb9bb7ce1350bc3b80a2ab7..49054670e27c3c345f3d1c7a03e7769e70100d71 100644
--- a/examples/albums.c
+++ b/examples/albums.c
@@ -34,44 +34,8 @@ static void dump_albuminfo(LIBMTP_album_t *album)
printf(" Tracks: %d\n\n",album->no_tracks);
}
-static void
-dump_albums(LIBMTP_mtpdevice_t *device, uint32_t storageid, int leaf)
-{
- LIBMTP_file_t *files;
-
- /* Get file listing. */
- files = LIBMTP_Get_Files_And_Folders(device,
- storageid,
- leaf);
- if (files == NULL) {
- LIBMTP_Dump_Errorstack(device);
- LIBMTP_Clear_Errorstack(device);
- } else {
- LIBMTP_file_t *file, *tmp;
- file = files;
- while (file != NULL) {
- /* Please don't print these */
- if (file->filetype == LIBMTP_FILETYPE_FOLDER) {
- dump_albums(device, storageid, file->item_id);
- } else if (file->filetype == LIBMTP_FILETYPE_ALBUM) {
- LIBMTP_album_t *album;
-
- album = LIBMTP_Get_Album(device, file->item_id);
- dump_albuminfo(album);
- LIBMTP_destroy_album_t(album);
- }
- tmp = file;
- file = file->next;
- LIBMTP_destroy_file_t(tmp);
- }
- }
-}
-
int main (int argc, char *argv[]) {
- LIBMTP_raw_device_t *rawdevices;
- int numrawdevices;
- LIBMTP_error_number_t err;
- int i;
+ LIBMTP_mtpdevice_t *device_list, *device;
int opt;
extern int optind;
@@ -92,8 +56,7 @@ int main (int argc, char *argv[]) {
fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
- err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
- switch(err)
+ switch(LIBMTP_Get_Connected_Devices(&device_list))
{
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
fprintf(stdout, "mtp-albums: No Devices have been found\n");
@@ -116,20 +79,13 @@ int main (int argc, char *argv[]) {
case LIBMTP_ERROR_NONE:
fprintf(stdout, "mtp-albums: Successfully connected\n");
fflush(stdout);
- break;
}
/* iterate through connected MTP devices */
- for (i = 0; i < numrawdevices; i++) {
- LIBMTP_mtpdevice_t *device;
- LIBMTP_devicestorage_t *storage;
+ for(device = device_list; device != NULL; device = device->next)
+ {
char *friendlyname;
-
- device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
- if (device == NULL) {
- fprintf(stderr, "Unable to open raw device %d\n", i);
- continue;
- }
+ LIBMTP_album_t *album_list, *album, *tmp;
/* Echo the friendly name so we know which device we are working with */
friendlyname = LIBMTP_Get_Friendlyname(device);
@@ -140,18 +96,18 @@ int main (int argc, char *argv[]) {
free(friendlyname);
}
- LIBMTP_Dump_Errorstack(device);
- LIBMTP_Clear_Errorstack(device);
-
- /* Loop over storages */
- for (storage = device->storage; storage != 0; storage = storage->next) {
- dump_albums(device, storage->id, 0);
+ album_list = LIBMTP_Get_Album_List(device);
+ album = album_list;
+ while(album != NULL)
+ {
+ dump_albuminfo(album);
+ tmp = album;
+ album = album->next;
+ LIBMTP_destroy_album_t(tmp);
}
- LIBMTP_Release_Device(device);
}
- free(rawdevices);
-
+ LIBMTP_Release_Device_List(device_list);
printf("OK.\n");
return 0;
}
« no previous file with comments | « examples/albumart.c ('k') | examples/detect.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698