summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyihong Chae <hh.chae@samsung.com>2016-04-11 15:15:42 +0900
committerHyihong Chae <hh.chae@samsung.com>2016-04-11 15:17:17 +0900
commitf8edfd95f4b73fe69cebe189450e03d5dbd4de05 (patch)
treef007985464ebb0ca1a0ce61a2ef6b7c49d8f5eb2
parentea990fe71a65b396410d4ec17ff7ff072b3406a8 (diff)
downloadlibmtp-accepted/tizen/mobile/20160411.100403.tar.gz
libmtp-accepted/tizen/mobile/20160411.100403.tar.bz2
libmtp-accepted/tizen/mobile/20160411.100403.zip
Change-Id: I0b986dde31da30bbc205bdeeaf663ee3c8b9b211 Signed-off-by: HyiHong Chae <hh.chae@samsung.com>
-rwxr-xr-xexamples/albumart.c18
-rwxr-xr-xexamples/albums.c72
-rwxr-xr-xexamples/detect.c76
-rwxr-xr-xexamples/files.c79
-rwxr-xr-xexamples/sendtr.c33
-rwxr-xr-xexamples/thumb.c33
-rwxr-xr-xexamples/tracks.c79
-rwxr-xr-xpackaging/libmtp.spec2
-rwxr-xr-xsrc/gphoto2-endian.h2
-rwxr-xr-xsrc/libusb1-glue.c14
-rwxr-xr-xutil/mtp-probe.c2
11 files changed, 261 insertions, 149 deletions
diff --git a/examples/albumart.c b/examples/albumart.c
index 6536ea4..350ba45 100755
--- a/examples/albumart.c
+++ b/examples/albumart.c
@@ -55,6 +55,7 @@ int main (int argc, char **argv) {
struct stat statbuff;
uint32_t storageid = 0;
uint32_t parentid = 0;
+ int ret;
fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
@@ -124,19 +125,9 @@ int main (int argc, char **argv) {
return 1;
}
else {
-#ifdef TIZEN_EXT
- int rv;
- rv = read(fd, imagedata, filesize);
+ ret = read(fd, imagedata, filesize);
+ if (ret == -1) perror("read");
close(fd);
-
- if (rv < 0) {
- printf("Read fail.\n");
- return 0;
- }
-#else /* TIZEN_EXT */
- read(fd, imagedata, filesize);
- close(fd);
-#endif /* TIZEN_EXT */
}
LIBMTP_Init();
@@ -157,7 +148,8 @@ int main (int argc, char **argv) {
album->tracks = ids;
album->parent_id = parentid;
album->storage_id = storageid;
- int ret = LIBMTP_Create_New_Album(device,album);
+
+ ret = LIBMTP_Create_New_Album(device,album);
if (ret == 0) {
ret = LIBMTP_Send_Representative_Sample(device,album->album_id, albumart);
if (ret != 0) {
diff --git a/examples/albums.c b/examples/albums.c
index 4905467..23c8d59 100755
--- a/examples/albums.c
+++ b/examples/albums.c
@@ -34,8 +34,44 @@ 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_mtpdevice_t *device_list, *device;
+ LIBMTP_raw_device_t *rawdevices;
+ int numrawdevices;
+ LIBMTP_error_number_t err;
+ int i;
int opt;
extern int optind;
@@ -56,7 +92,8 @@ int main (int argc, char *argv[]) {
fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
- switch(LIBMTP_Get_Connected_Devices(&device_list))
+ err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
+ switch(err)
{
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
fprintf(stdout, "mtp-albums: No Devices have been found\n");
@@ -79,13 +116,20 @@ 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(device = device_list; device != NULL; device = device->next)
- {
+ for (i = 0; i < numrawdevices; i++) {
+ LIBMTP_mtpdevice_t *device;
+ LIBMTP_devicestorage_t *storage;
char *friendlyname;
- LIBMTP_album_t *album_list, *album, *tmp;
+
+ device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
+ if (device == NULL) {
+ fprintf(stderr, "Unable to open raw device %d\n", i);
+ continue;
+ }
/* Echo the friendly name so we know which device we are working with */
friendlyname = LIBMTP_Get_Friendlyname(device);
@@ -96,18 +140,18 @@ int main (int argc, char *argv[]) {
free(friendlyname);
}
- 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_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);
}
+ LIBMTP_Release_Device(device);
}
- LIBMTP_Release_Device_List(device_list);
+ free(rawdevices);
+
printf("OK.\n");
return 0;
}
diff --git a/examples/detect.c b/examples/detect.c
index e155708..220f92e 100755
--- a/examples/detect.c
+++ b/examples/detect.c
@@ -2,7 +2,7 @@
* \file detect.c
* Example program to detect a device and list capabilities.
*
- * Copyright (C) 2005-2008 Linus Walleij <triad@df.lth.se>
+ * Copyright (C) 2005-2015 Linus Walleij <triad@df.lth.se>
* Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
*
* This library is free software; you can redistribute it and/or
@@ -130,20 +130,18 @@ int main (int argc, char **argv)
fprintf(stdout, "Attempting to connect device(s)\n");
for (i = 0; i < numrawdevices; i++) {
LIBMTP_mtpdevice_t *device;
- LIBMTP_file_t *files;
+ LIBMTP_devicestorage_t *storage;
char *friendlyname;
char *syncpartner;
char *sectime;
-#ifndef TIZEN_EXT
char *devcert;
-#endif /* TIZEN_EXT */
uint16_t *filetypes;
uint16_t filetypes_len;
uint8_t maxbattlevel;
uint8_t currbattlevel;
int ret;
- device = LIBMTP_Open_Raw_Device(&rawdevices[i]);
+ device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
if (device == NULL) {
fprintf(stderr, "Unable to open raw device %d\n", i);
continue;
@@ -205,34 +203,43 @@ int main (int argc, char **argv)
}
// Device certificate XML fragment
-#if 0
- /*
- * This code is currently disabled: all devices say that
- * they support getting a device certificate but a lot of
- * them obviously doesn't, instead they crash when you try
- * to obtain it.
- */
- ret = LIBMTP_Get_Device_Certificate(device, &devcert);
- if (ret == 0 && devcert != NULL) {
- fprintf(stdout, "\nDevice Certificate:\n%s\n", devcert);
- free(devcert);
- } else {
- fprintf(stdout, "Unable to acquire device certificate, perhaps this device "
- "does not support this\n");
- LIBMTP_Dump_Errorstack(device);
- LIBMTP_Clear_Errorstack(device);
+ if (rawdevices[i].device_entry.vendor_id == 0x041e) {
+ /*
+ * This code is currently disabled except for vendors we
+ * know does support it: all devices say that
+ * they support getting a device certificate but a lot of
+ * them obviously doesn't, instead they crash when you try
+ * to obtain it.
+ */
+ ret = LIBMTP_Get_Device_Certificate(device, &devcert);
+ if (ret == 0 && devcert != NULL) {
+ fprintf(stdout, "\nDevice Certificate:\n%s\n", devcert);
+ free(devcert);
+ } else {
+ fprintf(stdout, "Unable to acquire device certificate, perhaps this device "
+ "does not support this\n");
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
+ }
}
-#endif
- // Try to get Media player device info XML file...
- files = LIBMTP_Get_Filelisting_With_Callback(device, NULL, NULL);
- if (files != NULL) {
- LIBMTP_file_t *file, *tmp;
- file = files;
- while (file != NULL) {
- if (!strcmp(file->filename, "WMPInfo.xml") ||
- !strcmp(file->filename, "WMPinfo.xml") ||
- !strcmp(file->filename, "default-capabilities.xml")) {
+ /* Try to get Media player device info XML file... */
+ /* Loop over storages */
+ for (storage = device->storage; storage != 0; storage = storage->next) {
+ LIBMTP_file_t *files;
+
+ /* Get file listing for the root directory, no other dirs */
+ files = LIBMTP_Get_Files_And_Folders(device,
+ storage->id,
+ 0);
+
+ if (files != NULL) {
+ LIBMTP_file_t *file, *tmp;
+ file = files;
+ while (file != NULL) {
+ if (!strcmp(file->filename, "WMPInfo.xml") ||
+ !strcmp(file->filename, "WMPinfo.xml") ||
+ !strcmp(file->filename, "default-capabilities.xml")) {
if (file->item_id != 0) {
/* Dump this file */
FILE *xmltmp = tmpfile();
@@ -276,10 +283,11 @@ int main (int argc, char **argv)
fclose(xmltmp);
}
}
+ }
+ tmp = file;
+ file = file->next;
+ LIBMTP_destroy_file_t(tmp);
}
- tmp = file;
- file = file->next;
- LIBMTP_destroy_file_t(tmp);
}
}
LIBMTP_Release_Device(device);
diff --git a/examples/files.c b/examples/files.c
index 11b0c04..8c3e586 100755
--- a/examples/files.c
+++ b/examples/files.c
@@ -46,16 +46,48 @@ static void dump_fileinfo(LIBMTP_file_t *file)
printf(" Filetype: %s\n", LIBMTP_Get_Filetype_Description(file->filetype));
}
-int main (int argc, char **argv)
+static void
+dump_files(LIBMTP_mtpdevice_t *device, uint32_t storageid, int leaf)
{
- LIBMTP_mtpdevice_t *device_list, *device;
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_files(device, storageid, file->item_id);
+ } else {
+ dump_fileinfo(file);
+ }
+ 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;
+
fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
LIBMTP_Init();
- switch(LIBMTP_Get_Connected_Devices(&device_list))
+ err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
+ switch(err)
{
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
fprintf(stdout, "mtp-files: No Devices have been found\n");
@@ -72,19 +104,27 @@ int main (int argc, char **argv)
default:
fprintf(stderr, "mtp-files: Unknown error, please report "
"this to the libmtp developers\n");
- return 1;
+ return 1;
/* Successfully connected at least one device, so continue */
case LIBMTP_ERROR_NONE:
fprintf(stdout, "mtp-files: Successfully connected\n");
fflush(stdout);
+ break;
}
/* iterate through connected MTP devices */
- for(device = device_list; device != NULL; device = device->next)
- {
+ for (i = 0; i < numrawdevices; i++) {
+ LIBMTP_mtpdevice_t *device;
+ LIBMTP_devicestorage_t *storage;
char *friendlyname;
+ device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
+ if (device == NULL) {
+ fprintf(stderr, "Unable to open raw device %d\n", i);
+ continue;
+ }
+
/* Echo the friendly name so we know which device we are working with */
friendlyname = LIBMTP_Get_Friendlyname(device);
if (friendlyname == NULL) {
@@ -94,25 +134,18 @@ int main (int argc, char **argv)
free(friendlyname);
}
- /* Get track listing. */
- files = LIBMTP_Get_Filelisting_With_Callback(device, NULL, NULL);
- if (files == NULL) {
- printf("No files.\n");
- LIBMTP_Dump_Errorstack(device);
- LIBMTP_Clear_Errorstack(device);
- } else {
- LIBMTP_file_t *file, *tmp;
- file = files;
- while (file != NULL) {
- dump_fileinfo(file);
- tmp = file;
- file = file->next;
- LIBMTP_destroy_file_t(tmp);
- }
- }
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
+
+ /* Loop over storages */
+ for (storage = device->storage; storage != 0; storage = storage->next) {
+ dump_files(device, storage->id, 0);
+ }
+ LIBMTP_Release_Device(device);
}
- LIBMTP_Release_Device_List(device_list);
+ free(rawdevices);
+
printf("OK.\n");
exit (0);
}
diff --git a/examples/sendtr.c b/examples/sendtr.c
index ef1f130..a608d15 100755
--- a/examples/sendtr.c
+++ b/examples/sendtr.c
@@ -186,6 +186,7 @@ int sendtrack_function(char * from_path, char * to_path, char *partist, char *pa
{
char *filename, *parent;
char artist[80], albumartist[80], title[80], genre[80], album[80], composer[80];
+ char *to_path_copy = NULL;
char num[80];
uint64_t filesize;
uint32_t parent_id = 0;
@@ -196,22 +197,28 @@ int sendtrack_function(char * from_path, char * to_path, char *partist, char *pa
printf("Sending track %s to %s\n", from_path, to_path);
- parent = dirname(strdup(to_path));
- filename = basename(strdup(to_path));
+ to_path_copy = strdup(to_path);
+ parent = dirname(to_path_copy);
parent_id = parse_path (parent,files,folders);
if (parent_id == -1) {
+ free (to_path_copy);
printf("Parent folder could not be found, skipping\n");
return 1;
}
+ strcpy (to_path_copy,to_path);
+ filename = basename(to_path_copy);
if (stat(from_path, &sb) == -1) {
fprintf(stderr, "%s: ", from_path);
perror("stat");
+ free (to_path_copy);
return 1;
}
- if (!S_ISREG(sb.st_mode))
+ if (!S_ISREG(sb.st_mode)) {
+ free (to_path_copy);
return 0;
+ }
filesize = sb.st_size;
@@ -220,6 +227,7 @@ int sendtrack_function(char * from_path, char * to_path, char *partist, char *pa
if (!LIBMTP_FILETYPE_IS_TRACK(trackmeta->filetype)) {
printf("Not a valid track codec: \"%s\"\n", LIBMTP_Get_Filetype_Description(trackmeta->filetype));
LIBMTP_destroy_track_t(trackmeta);
+ free (to_path_copy);
return 1;
}
@@ -374,6 +382,7 @@ int sendtrack_function(char * from_path, char * to_path, char *partist, char *pa
LIBMTP_destroy_album_t(albuminfo);
LIBMTP_destroy_track_t(trackmeta);
+ free (to_path_copy);
return ret;
}
@@ -397,24 +406,31 @@ int sendtrack_command (int argc, char **argv) {
while ( (opt = getopt(argc, argv, "qD:t:a:A:w:l:c:g:n:d:y:s:")) != -1 ) {
switch (opt) {
case 't':
+ free (ptitle);
ptitle = strdup(optarg);
break;
case 'a':
+ free (partist);
partist = strdup(optarg);
break;
case 'A':
+ free (palbumartist);
palbumartist = strdup(optarg);
break;
case 'w':
+ free (pcomposer);
pcomposer = strdup(optarg);
break;
case 'l':
+ free (palbum);
palbum = strdup(optarg);
break;
case 'c':
+ free (pcodec);
pcodec = strdup(optarg); // FIXME: DSM check for MP3, WAV or WMA
break;
case 'g':
+ free (pgenre);
pgenre = strdup(optarg);
break;
case 'n':
@@ -442,13 +458,12 @@ int sendtrack_command (int argc, char **argv) {
if ( argc != 2 ) {
printf("You need to pass a filename and destination.\n");
sendtrack_usage();
- return 0;
+ ret = 0;
+ } else {
+ checklang();
+ printf("%s,%s,%s,%s,%s,%s,%s,%s,%d%d,%d,%u,%d\n",argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer,tracknum, length, year, storageid, quiet);
+ ret = sendtrack_function(argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer, tracknum, length, year, storageid, quiet);
}
-
- checklang();
-
- printf("%s,%s,%s,%s,%s,%s,%s,%s,%d%d,%d,%u,%d\n",argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer,tracknum, length, year, storageid, quiet);
- ret = sendtrack_function(argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer, tracknum, length, year, storageid, quiet);
free (ptitle);
free (partist);
free (palbumartist);
diff --git a/examples/thumb.c b/examples/thumb.c
index 03f8983..3dc360e 100755
--- a/examples/thumb.c
+++ b/examples/thumb.c
@@ -47,7 +47,7 @@ int main (int argc, char **argv) {
int fd;
uint32_t id = 0;
uint64_t filesize;
- uint8_t *imagedata = NULL;
+ char *imagedata = NULL;
char *path = NULL;
char *rest;
struct stat statbuff;
@@ -81,8 +81,8 @@ int main (int argc, char **argv) {
perror("stat");
exit(1);
}
- filesize = (uint64_t) statbuff.st_size;
- imagedata = malloc(filesize * sizeof(uint16_t));
+ filesize = statbuff.st_size;
+ imagedata = malloc(filesize);
#ifdef __WIN32__
if ( (fd = open(path, O_RDONLY|O_BINARY) == -1) ) {
@@ -91,21 +91,10 @@ int main (int argc, char **argv) {
#endif
printf("Couldn't open image file %s (%s)\n",path,strerror(errno));
return 1;
- }
- else {
-#ifdef TIZEN_EXT
- int rv;
- rv = read(fd, imagedata, filesize);
- close(fd);
-
- if (rv < 0) {
- printf("Read fail.\n");
- return 0;
- }
-#else /* TIZEN_EXT */
- read(fd, imagedata, filesize);
+ } else {
+ ret = read(fd, imagedata, filesize);
+ if (ret == -1) perror("read thumb data");
close(fd);
-#endif /* TIZEN_EXT */
}
LIBMTP_Init();
@@ -116,16 +105,9 @@ int main (int argc, char **argv) {
}
LIBMTP_filesampledata_t *thumb = LIBMTP_new_filesampledata_t();
-
- int i;
- thumb->data = malloc(sizeof(uint16_t) * filesize);
- for (i = 0; i < filesize; i++) {
- thumb->data[i] = imagedata[i];
- }
-
+ thumb->data = imagedata;
thumb->size = filesize;
thumb->filetype = LIBMTP_FILETYPE_JPEG;
-
ret = LIBMTP_Send_Representative_Sample(device,id,thumb);
if (ret != 0) {
printf("Couldn't send thumbnail\n");
@@ -133,7 +115,6 @@ int main (int argc, char **argv) {
LIBMTP_Clear_Errorstack(device);
}
- free(imagedata);
LIBMTP_destroy_filesampledata_t(thumb);
LIBMTP_Release_Device(device);
diff --git a/examples/tracks.c b/examples/tracks.c
index 04aa2e1..e22506e 100755
--- a/examples/tracks.c
+++ b/examples/tracks.c
@@ -79,15 +79,52 @@ static void dump_trackinfo(LIBMTP_track_t *track)
}
}
+static void
+dump_tracks(LIBMTP_mtpdevice_t *device, uint32_t storageid, int leaf)
+{
+ LIBMTP_file_t *files;
+
+ /* Get track 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_tracks(device, storageid, file->item_id);
+ } else if (LIBMTP_FILETYPE_IS_TRACK(file->filetype)) {
+ LIBMTP_track_t *track;
+
+ track = LIBMTP_Get_Trackmetadata(device, file->item_id);
+ dump_trackinfo(track);
+ LIBMTP_destroy_track_t(track);
+ }
+ tmp = file;
+ file = file->next;
+ LIBMTP_destroy_file_t(tmp);
+ }
+ }
+}
+
int main (int argc, char **argv)
{
- LIBMTP_mtpdevice_t *device_list, *device;
- LIBMTP_track_t *tracks;
+ LIBMTP_raw_device_t *rawdevices;
+ int numrawdevices;
+ LIBMTP_error_number_t err;
+ int i;
LIBMTP_Init();
fprintf(stdout, "Attempting to connect device(s)\n");
- switch(LIBMTP_Get_Connected_Devices(&device_list))
+ err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
+ switch(err)
{
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
fprintf(stdout, "mtp-tracks: No Devices have been found\n");
@@ -110,12 +147,21 @@ int main (int argc, char **argv)
case LIBMTP_ERROR_NONE:
fprintf(stdout, "mtp-tracks: Successfully connected\n");
fflush(stdout);
+ break;
}
- /* iterate through connected MTP devices */
- for(device = device_list; device != NULL; device = device->next) {
+ /* Iterate through connected MTP devices */
+ for (i = 0; i < numrawdevices; i++) {
+ LIBMTP_mtpdevice_t *device;
+ LIBMTP_devicestorage_t *storage;
char *friendlyname;
+ device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
+ if (device == NULL) {
+ fprintf(stderr, "Unable to open raw device %d\n", i);
+ continue;
+ }
+
/* Echo the friendly name so we know which device we are working with */
friendlyname = LIBMTP_Get_Friendlyname(device);
if (friendlyname == NULL) {
@@ -124,23 +170,18 @@ int main (int argc, char **argv)
printf("Friendly name: %s\n", friendlyname);
free(friendlyname);
}
- // Get track listing.
- tracks = LIBMTP_Get_Tracklisting_With_Callback(device, NULL, NULL);
- if (tracks == NULL) {
- printf("No tracks.\n");
- } else {
- LIBMTP_track_t *track, *tmp;
- track = tracks;
- while (track != NULL) {
- dump_trackinfo(track);
- tmp = track;
- track = track->next;
- LIBMTP_destroy_track_t(tmp);
- }
+
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
+
+ /* Loop over storages */
+ for (storage = device->storage; storage != 0; storage = storage->next) {
+ dump_tracks(device, storage->id, 0);
}
+
+ LIBMTP_Release_Device(device);
}
- LIBMTP_Release_Device_List(device_list);
printf("OK.\n");
exit (0);
}
diff --git a/packaging/libmtp.spec b/packaging/libmtp.spec
index 0f84ff5..e628350 100755
--- a/packaging/libmtp.spec
+++ b/packaging/libmtp.spec
@@ -3,7 +3,7 @@
Name: libmtp
Summary: Library for media transfer protocol (mtp)
Version: 1.1.11
-Release: 0
+Release: 1
Group: Network & Connectivity/Other
License: LGPL-2.1
Source0: libmtp-%{version}.tar.gz
diff --git a/src/gphoto2-endian.h b/src/gphoto2-endian.h
index 4794882..ddc17f3 100755
--- a/src/gphoto2-endian.h
+++ b/src/gphoto2-endian.h
@@ -1,5 +1,5 @@
/* This file is generated automatically by configure */
-/* It is valid only for the system type x86_64-unknown-linux-gnu */
+/* It is valid only for the system type x86_64-suse-linux-gnu */
#ifndef __BYTEORDER_H
#define __BYTEORDER_H
diff --git a/src/libusb1-glue.c b/src/libusb1-glue.c
index 5c65f02..ef13f03 100755
--- a/src/libusb1-glue.c
+++ b/src/libusb1-glue.c
@@ -1728,7 +1728,7 @@ static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev)
ret = libusb_open(dev, &device_handle);
if (ret != LIBUSB_SUCCESS) {
- perror("libusb_open() failed!");
+ LIBMTP_ERROR("libusb_open() failed! ret[%d]", ret);
return -1;
}
ptp_usb->handle = device_handle;
@@ -1742,7 +1742,7 @@ static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev)
libusb_kernel_driver_active(device_handle, ptp_usb->interface)
) {
if (LIBUSB_SUCCESS != libusb_detach_kernel_driver(device_handle, ptp_usb->interface)) {
- perror("libusb_detach_kernel_driver() failed, continuing anyway...");
+ LIBMTP_ERROR("libusb_detach_kernel_driver() failed, continuing anyway...");
}
}
@@ -1756,27 +1756,27 @@ static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev)
*/
ret = libusb_get_active_config_descriptor(dev, &config);
if (ret != LIBUSB_SUCCESS) {
- perror("libusb_get_active_config_descriptor(1) failed");
+ LIBMTP_ERROR("libusb_get_active_config_descriptor(1) failed");
fprintf(stderr, "no active configuration, trying to set configuration\n");
if (libusb_set_configuration(device_handle, ptp_usb->config) != LIBUSB_SUCCESS) {
- perror("libusb_set_configuration() failed, continuing anyway...");
+ LIBMTP_ERROR("libusb_set_configuration() failed, continuing anyway...");
}
ret = libusb_get_active_config_descriptor(dev, &config);
if (ret != LIBUSB_SUCCESS) {
- perror("libusb_get_active_config_descriptor(2) failed");
+ LIBMTP_ERROR("libusb_get_active_config_descriptor(2) failed");
return -1;
}
}
if (config->bConfigurationValue != ptp_usb->config) {
fprintf(stderr, "desired configuration different from current, trying to set configuration\n");
if (libusb_set_configuration(device_handle, ptp_usb->config)) {
- perror("libusb_set_configuration() failed, continuing anyway...");
+ LIBMTP_ERROR("libusb_set_configuration() failed, continuing anyway...");
}
/* Re-fetch the config descriptor if we changed */
libusb_free_config_descriptor(config);
ret = libusb_get_active_config_descriptor(dev, &config);
if (ret != LIBUSB_SUCCESS) {
- perror("libusb_get_active_config_descriptor(2) failed");
+ LIBMTP_ERROR("libusb_get_active_config_descriptor(2) failed");
return -1;
}
}
diff --git a/util/mtp-probe.c b/util/mtp-probe.c
index 7269de7..3ff2040 100755
--- a/util/mtp-probe.c
+++ b/util/mtp-probe.c
@@ -186,9 +186,7 @@ static int check_interface(char *sysfspath)
/* Check for dirs that identify endpoints */
ret = regcomp(&r, "^ep_[0-9a-f]+$", REG_EXTENDED | REG_NOSUB);
if (ret) {
-#ifdef TIZEN_EXT
closedir(dir);
-#endif
return -1;
}