diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2017-03-13 16:21:09 +0100 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2017-03-13 16:21:09 +0100 |
commit | 325580cf1436065df2b054c63e54a038b2f79ed3 (patch) | |
tree | 29990b6da129d1357a988ecb6f2ba5823e60bff9 | |
parent | 4c959803d09ae792708c5de586b2b80526e8b4ca (diff) | |
download | libgphoto2-325580cf1436065df2b054c63e54a038b2f79ed3.tar.gz |
in summary, use the cached storageids.
-rw-r--r-- | camlibs/ptp2/library.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index ea5fedca8..cc3d75796 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -5279,7 +5279,6 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context) char *txt, *txt_marker; PTPParams *params = &(camera->pl->params); PTPDeviceInfo pdi; - PTPStorageIDs storageids; SET_CONTEXT(camera, context); @@ -5430,20 +5429,19 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context) if (ptp_operation_issupported(params,PTP_OC_GetStorageIDs) && ptp_operation_issupported(params,PTP_OC_GetStorageInfo) ) { - C_PTP_REP (ptp_getstorageids(params, &storageids)); APPEND_TXT (_("\nStorage Devices Summary:\n")); - for (i=0; i<storageids.n; i++) { + for (i=0; i<params->storageids.n; i++) { char tmpname[20], *s; PTPStorageInfo storageinfo; /* invalid storage, storageinfo might fail on it (Nikon D300s e.g.) */ - if ((storageids.Storage[i]&0x0000ffff)==0) + if ((params->storageids.Storage[i]&0x0000ffff)==0) continue; - APPEND_TXT ("store_%08x:\n",(unsigned int)storageids.Storage[i]); + APPEND_TXT ("store_%08x:\n",(unsigned int)params->storageids.Storage[i]); - C_PTP_REP (ptp_getstorageinfo(params, storageids.Storage[i], &storageinfo)); + C_PTP_REP (ptp_getstorageinfo(params, params->storageids.Storage[i], &storageinfo)); APPEND_TXT (_("\tStorageDescription: %s\n"), storageinfo.StorageDescription?storageinfo.StorageDescription:_("None") ); @@ -5498,7 +5496,6 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context) free (storageinfo.StorageDescription); free (storageinfo.VolumeLabel); } - free (storageids.Storage); } APPEND_TXT (_("\nDevice Property Summary:\n")); @@ -5776,25 +5773,23 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, GP_LOG_D ("folder_list_func(%s)", folder); /* add storage pseudofolders in root folder */ if (!strcmp(folder, "/")) { + /* use the cached storageids. they should be valid after camera_init */ if (ptp_operation_issupported(params,PTP_OC_GetStorageIDs)) { - PTPStorageIDs storageids; char fname[PTP_MAXSTRLEN]; - C_PTP_REP (ptp_getstorageids(params, &storageids)); - if (!storageids.n) { + if (!params->storageids.n) { snprintf(fname, sizeof(fname), STORAGE_FOLDER_PREFIX"%08x",0x00010001); CR (gp_list_append (list, fname, NULL)); } - for (i=0; i<storageids.n; i++) { + for (i=0; i<params->storageids.n; i++) { /* invalid storage, storageinfo might fail on it (Nikon D300s e.g.) */ - if ((storageids.Storage[i]&0x0000ffff)==0) continue; + if ((params->storageids.Storage[i]&0x0000ffff)==0) continue; snprintf(fname, sizeof(fname), STORAGE_FOLDER_PREFIX"%08x", - storageids.Storage[i]); + params->storageids.Storage[i]); CR (gp_list_append (list, fname, NULL)); } - free (storageids.Storage); } else { char fname[PTP_MAXSTRLEN]; snprintf(fname, sizeof(fname), @@ -5822,7 +5817,7 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, /* list this directory */ C_PTP_REP (ptp_list_folder (params, storage, handler)); - GP_LOG_D ("after list folder"); + GP_LOG_D ("after list folder (storage=0x%08x, handler=0x08%x)", storage, handler); /* Look for objects we can present as directories. * Currently we specify *any* PTP association as directory. |