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

Side by Side Diff: examples/folders.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 unified diff | Download patch
« no previous file with comments | « examples/filetree.c ('k') | examples/sendtr.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * \file folders.c 2 * \file folders.c
3 * Example program that lists all folders on a device. 3 * Example program that lists all folders on a device.
4 * 4 *
5 * Copyright (C) 2005-2011 Linus Walleij <triad@df.lth.se> 5 * Copyright (C) 2005-2011 Linus Walleij <triad@df.lth.se>
6 * Copyright (C) 2007 Ted Bullock <tbullock@canada.com> 6 * Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 23 matching lines...) Expand all
34 for(i=0;i<level;i++) printf(" "); 34 for(i=0;i<level;i++) printf(" ");
35 35
36 printf("%s\n", folderlist->name); 36 printf("%s\n", folderlist->name);
37 37
38 dump_folder_list(folderlist->child, level+1); 38 dump_folder_list(folderlist->child, level+1);
39 dump_folder_list(folderlist->sibling, level); 39 dump_folder_list(folderlist->sibling, level);
40 } 40 }
41 41
42 int main (int argc, char **argv) 42 int main (int argc, char **argv)
43 { 43 {
44 LIBMTP_raw_device_t *rawdevices; 44 LIBMTP_mtpdevice_t *device_list, *device;
45 int numrawdevices;
46 int i;
47 45
48 LIBMTP_Init(); 46 LIBMTP_Init();
49 printf("Attempting to connect device(s)\n"); 47 printf("Attempting to connect device(s)\n");
50 48
51 switch (LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices)) { 49 switch(LIBMTP_Get_Connected_Devices(&device_list))
50 {
52 case LIBMTP_ERROR_NO_DEVICE_ATTACHED: 51 case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
53 printf("mtp-folders: no devices found\n"); 52 printf("mtp-folders: no devices found\n");
54 return 0; 53 return 0;
55 case LIBMTP_ERROR_CONNECTING: 54 case LIBMTP_ERROR_CONNECTING:
56 fprintf(stderr, "mtp-folders: There has been an error connecting. Exit\n"); 55 fprintf(stderr, "mtp-folders: There has been an error connecting. Exit\n");
57 return 1; 56 return 1;
58 case LIBMTP_ERROR_MEMORY_ALLOCATION: 57 case LIBMTP_ERROR_MEMORY_ALLOCATION:
59 fprintf(stderr, "mtp-folders: Memory Allocation Error. Exit\n"); 58 fprintf(stderr, "mtp-folders: Memory Allocation Error. Exit\n");
60 return 1; 59 return 1;
61 60
62 /* Unknown general errors - This should never execute */ 61 /* Unknown general errors - This should never execute */
63 case LIBMTP_ERROR_GENERAL: 62 case LIBMTP_ERROR_GENERAL:
64 default: 63 default:
65 fprintf(stderr, "mtp-folders: Unknown error, please report " 64 fprintf(stderr, "mtp-folders: Unknown error, please report "
66 "this to the libmtp developers\n"); 65 "this to the libmtp developers\n");
67 return 1; 66 return 1;
68 67
69 /* Successfully connected at least one device, so continue */ 68 /* Successfully connected at least one device, so continue */
70 case LIBMTP_ERROR_NONE: 69 case LIBMTP_ERROR_NONE:
71 printf("mtp-folders: Successfully connected\n"); 70 printf("mtp-folders: Successfully connected\n");
72 } 71 }
73 72
74 /* iterate through connected MTP devices */ 73 /* iterate through connected MTP devices */
75 for (i = 0; i < numrawdevices; i++) { 74 for(device = device_list; device != NULL; device = device->next)
76 LIBMTP_mtpdevice_t *device; 75 {
77 LIBMTP_devicestorage_t *storage; 76 LIBMTP_devicestorage_t *storage;
78 char *friendlyname; 77 char *friendlyname;
79 int ret; 78 int ret;
80 79
81 device = LIBMTP_Open_Raw_Device(&rawdevices[i]);
82 if (device == NULL) {
83 fprintf(stderr, "Unable to open raw device %d\n", i);
84 continue;
85 }
86
87 /* Echo the friendly name so we know which device we are working with */ 80 /* Echo the friendly name so we know which device we are working with */
88 friendlyname = LIBMTP_Get_Friendlyname(device); 81 friendlyname = LIBMTP_Get_Friendlyname(device);
89 if (friendlyname == NULL) { 82 if (friendlyname == NULL) {
90 printf("Friendly name: (NULL)\n"); 83 printf("Friendly name: (NULL)\n");
91 } else { 84 } else {
92 printf("Friendly name: %s\n", friendlyname); 85 printf("Friendly name: %s\n", friendlyname);
93 free(friendlyname); 86 free(friendlyname);
94 } 87 }
95 88
96 LIBMTP_Dump_Errorstack(device); 89 LIBMTP_Dump_Errorstack(device);
(...skipping 17 matching lines...) Expand all
114 107
115 if (folders == NULL) { 108 if (folders == NULL) {
116 fprintf(stdout, "No folders found\n"); 109 fprintf(stdout, "No folders found\n");
117 LIBMTP_Dump_Errorstack(device); 110 LIBMTP_Dump_Errorstack(device);
118 LIBMTP_Clear_Errorstack(device); 111 LIBMTP_Clear_Errorstack(device);
119 } else { 112 } else {
120 dump_folder_list(folders,0); 113 dump_folder_list(folders,0);
121 } 114 }
122 LIBMTP_destroy_folder_t(folders); 115 LIBMTP_destroy_folder_t(folders);
123 } 116 }
124 LIBMTP_Release_Device(device);
125 } 117 }
126 118
127 free(rawdevices); 119 LIBMTP_Release_Device_List(device_list);
128 printf("OK.\n"); 120 printf("OK.\n");
129 121
130 return 0; 122 return 0;
131 } 123 }
OLDNEW
« no previous file with comments | « examples/filetree.c ('k') | examples/sendtr.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698