folders.c   folders.c 
skipping to change at line 44 skipping to change at line 44
for(i=0;i<level;i++) printf(" "); for(i=0;i<level;i++) printf(" ");
printf("%s\n", folderlist->name); printf("%s\n", folderlist->name);
dump_folder_list(folderlist->child, level+1); dump_folder_list(folderlist->child, level+1);
dump_folder_list(folderlist->sibling, level); dump_folder_list(folderlist->sibling, level);
} }
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
LIBMTP_mtpdevice_t *device, *iter; LIBMTP_mtpdevice_t *device_list, *device;
LIBMTP_Init(); LIBMTP_Init();
printf("Attempting to connect device(s)\n"); printf("Attempting to connect device(s)\n");
switch(LIBMTP_Get_Connected_Devices(&device)) switch(LIBMTP_Get_Connected_Devices(&device_list))
{ {
case LIBMTP_ERROR_NO_DEVICE_ATTACHED: case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
printf("mtp-folders: no devices found\n"); printf("mtp-folders: no devices found\n");
return 0; return 0;
case LIBMTP_ERROR_CONNECTING: case LIBMTP_ERROR_CONNECTING:
fprintf(stderr, "mtp-folders: There has been an error connecting. Exit\ n"); fprintf(stderr, "mtp-folders: There has been an error connecting. Exit\ n");
return 1; return 1;
case LIBMTP_ERROR_MEMORY_ALLOCATION: case LIBMTP_ERROR_MEMORY_ALLOCATION:
fprintf(stderr, "mtp-folders: Memory Allocation Error. Exit\n"); fprintf(stderr, "mtp-folders: Memory Allocation Error. Exit\n");
return 1; return 1;
skipping to change at line 74 skipping to change at line 74
fprintf(stderr, "mtp-folders: Unknown error, please report " fprintf(stderr, "mtp-folders: Unknown error, please report "
"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:
printf("mtp-folders: Successfully connected\n"); printf("mtp-folders: Successfully connected\n");
} }
/* iterate through connected MTP devices */ /* iterate through connected MTP devices */
for(iter = device; iter != NULL; iter = iter->next) for(device = device_list; device != NULL; device = device->next)
{ {
LIBMTP_devicestorage_t *storage; LIBMTP_devicestorage_t *storage;
char *friendlyname; char *friendlyname;
int ret; int ret;
/* 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);
} }
LIBMTP_Dump_Errorstack(iter); LIBMTP_Dump_Errorstack(device);
LIBMTP_Clear_Errorstack(iter); LIBMTP_Clear_Errorstack(device);
/* Get all storages for this device */ /* Get all storages for this device */
ret = LIBMTP_Get_Storage(device, LIBMTP_STORAGE_SORTBY_NOTSORTED); ret = LIBMTP_Get_Storage(device, LIBMTP_STORAGE_SORTBY_NOTSORTED);
if (ret != 0) { if (ret != 0) {
perror("LIBMTP_Get_Storage()\n"); perror("LIBMTP_Get_Storage()\n");
LIBMTP_Dump_Errorstack(iter); LIBMTP_Dump_Errorstack(device);
LIBMTP_Clear_Errorstack(iter); LIBMTP_Clear_Errorstack(device);
continue; continue;
} }
/* Loop over storages, dump folder for each one */ /* Loop over storages, dump folder for each one */
for (storage = device->storage; storage != 0; storage = storage->next) { for (storage = device->storage; storage != 0; storage = storage->next) {
LIBMTP_folder_t *folders; LIBMTP_folder_t *folders;
printf("Storage: %s\n", storage->StorageDescription); printf("Storage: %s\n", storage->StorageDescription);
folders = LIBMTP_Get_Folder_List_For_Storage(iter, storage->id); folders = LIBMTP_Get_Folder_List_For_Storage(device, storage->id);
if (folders == NULL) { if (folders == NULL) {
fprintf(stdout, "No folders found\n"); fprintf(stdout, "No folders found\n");
LIBMTP_Dump_Errorstack(iter); LIBMTP_Dump_Errorstack(device);
LIBMTP_Clear_Errorstack(iter); LIBMTP_Clear_Errorstack(device);
} else { } else {
dump_folder_list(folders,0); dump_folder_list(folders,0);
} }
LIBMTP_destroy_folder_t(folders); LIBMTP_destroy_folder_t(folders);
} }
} }
LIBMTP_Release_Device_List(device); LIBMTP_Release_Device_List(device_list);
printf("OK.\n"); printf("OK.\n");
return 0; return 0;
} }
 End of changes. 9 change blocks. 
12 lines changed or deleted 12 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/