Various changes
diff --git a/src/libmtp.c b/src/libmtp.c
index 3ead587..ef00a54 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -186,11 +186,11 @@
typedef struct _MTPDataHandler {
MTPDataGetFunc getfunc;
MTPDataPutFunc putfunc;
- void *private;
+ void *priv;
} MTPDataHandler;
-static uint16_t get_func_wrapper(PTPParams* params, void* private, unsigned long wantlen, unsigned char *data, unsigned long *gotlen);
-static uint16_t put_func_wrapper(PTPParams* params, void* private, unsigned long sendlen, unsigned char *data, unsigned long *putlen);
+static uint16_t get_func_wrapper(PTPParams* params, void* priv, unsigned long wantlen, unsigned char *data, unsigned long *gotlen);
+static uint16_t put_func_wrapper(PTPParams* params, void* priv, unsigned long sendlen, unsigned char *data, unsigned long *putlen);
/**
* Checks if a filename ends with ".ogg". Used in various
@@ -4410,12 +4410,12 @@
* This is a manual conversion from MTPDataGetFunc to PTPDataGetFunc
* to isolate the internal type.
*/
-static uint16_t get_func_wrapper(PTPParams* params, void* private, unsigned long wantlen, unsigned char *data, unsigned long *gotlen)
+static uint16_t get_func_wrapper(PTPParams* params, void* priv, unsigned long wantlen, unsigned char *data, unsigned long *gotlen)
{
- MTPDataHandler *handler = (MTPDataHandler *)private;
+ MTPDataHandler *handler = (MTPDataHandler *)priv;
uint16_t ret;
uint32_t local_gotlen = 0;
- ret = handler->getfunc(params, handler->private, wantlen, data, &local_gotlen);
+ ret = handler->getfunc(params, handler->priv, wantlen, data, &local_gotlen);
*gotlen = local_gotlen;
switch (ret)
{
@@ -4434,12 +4434,12 @@
* This is a manual conversion from MTPDataPutFunc to PTPDataPutFunc
* to isolate the internal type.
*/
-static uint16_t put_func_wrapper(PTPParams* params, void* private, unsigned long sendlen, unsigned char *data, unsigned long *putlen)
+static uint16_t put_func_wrapper(PTPParams* params, void* priv, unsigned long sendlen, unsigned char *data, unsigned long *putlen)
{
- MTPDataHandler *handler = (MTPDataHandler *)private;
+ MTPDataHandler *handler = (MTPDataHandler *)priv;
uint16_t ret;
uint32_t local_putlen = 0;
- ret = handler->putfunc(params, handler->private, sendlen, data, &local_putlen);
+ ret = handler->putfunc(params, handler->priv, sendlen, data, &local_putlen);
*putlen = local_putlen;
switch (ret)
{
@@ -4626,13 +4626,13 @@
MTPDataHandler mtp_handler;
mtp_handler.getfunc = NULL;
mtp_handler.putfunc = put_func;
- mtp_handler.private = priv;
-
+ mtp_handler.priv = priv;
+
PTPDataHandler handler;
handler.getfunc = NULL;
handler.putfunc = put_func_wrapper;
- handler.private = &mtp_handler;
-
+ handler.priv = &mtp_handler;
+
ret = ptp_getobject_to_handler(params, id, &handler);
ptp_usb->callback_active = 0;
@@ -5228,7 +5228,7 @@
// no need to output an error since send_file_object_info will already have done so
return -1;
}
-
+
// Callbacks
ptp_usb->callback_active = 1;
// The callback will deactivate itself after this amount of data has been sent
@@ -5237,19 +5237,19 @@
ptp_usb->current_transfer_complete = 0;
ptp_usb->current_transfer_callback = callback;
ptp_usb->current_transfer_callback_data = data;
-
+
MTPDataHandler mtp_handler;
mtp_handler.getfunc = get_func;
mtp_handler.putfunc = NULL;
- mtp_handler.private = priv;
-
+ mtp_handler.priv = priv;
+
PTPDataHandler handler;
handler.getfunc = get_func_wrapper;
handler.putfunc = NULL;
- handler.private = &mtp_handler;
-
+ handler.priv = &mtp_handler;
+
ret = ptp_sendobject_from_handler(params, &handler, filedata->filesize);
-
+
ptp_usb->callback_active = 0;
ptp_usb->current_transfer_callback = NULL;
ptp_usb->current_transfer_callback_data = NULL;
@@ -5265,7 +5265,7 @@
}
add_object_to_cache(device, filedata->item_id);
-
+
/*
* Get the device-assined parent_id from the cache.
* The operation that adds it to the cache will
@@ -5287,7 +5287,7 @@
return 0;
}
-/**
+/**
* This function sends the file object info, ready for sendobject
* @param device a pointer to the device to send the file to.
* @param filedata a file metadata set to be written along with the file.
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index f7f2ca1..61ffdce 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -25,7 +25,7 @@
*
* Created by Richard Low on 24/12/2005. (as mtp-utils.c)
* Modified by Linus Walleij 2006-03-06
- * (Notice that Anglo-Saxons use little-endian dates and Swedes
+ * (Notice that Anglo-Saxons use little-endian dates and Swedes
* use big-endian dates.)
*
*/
@@ -44,6 +44,11 @@
#include "ptp-pack.c"
+/* Aha, older libusb does not have USB_CLASS_PTP */
+#ifndef USB_CLASS_PTP
+#define USB_CLASS_PTP 6
+#endif
+
/* To enable debug prints for USB stuff, switch on this */
//#define ENABLE_USB_BULK_DEBUG
@@ -454,6 +459,18 @@
dev,
bus->location);
}
+ /*
+ * By thomas_-_s: Also append devices that are no MTP but PTP devices
+ * if this is commented out.
+ */
+ /*
+ else {
+ // Check whether the device is no USB hub but a PTP.
+ if ( dev->config != NULL &&dev->config->interface->altsetting->bInterfaceClass == USB_CLASS_PTP && dev->descriptor.bDeviceClass != USB_CLASS_HUB ) {
+ *mtp_device_list = append_to_mtpdevice_list(*mtp_device_list, dev, bus->location);
+ }
+ }
+ */
}
}
}
@@ -769,7 +786,7 @@
result--;
}
- int putfunc_ret = handler->putfunc(NULL, handler->private, result, bytes, &written);
+ int putfunc_ret = handler->putfunc(NULL, handler->priv, result, bytes, &written);
if (putfunc_ret != PTP_RC_OK)
return putfunc_ret;
@@ -848,7 +865,7 @@
towrite -= towrite % ptp_usb->outep_maxpacket;
}
}
- int getfunc_ret = handler->getfunc(NULL, handler->private,towrite,bytes,&towrite);
+ int getfunc_ret = handler->getfunc(NULL, handler->priv,towrite,bytes,&towrite);
if (getfunc_ret != PTP_RC_OK)
return getfunc_ret;
while (usbwritten < towrite) {
@@ -952,7 +969,7 @@
ptp_init_recv_memory_handler(PTPDataHandler *handler) {
PTPMemHandlerPrivate* priv;
priv = malloc (sizeof(PTPMemHandlerPrivate));
- handler->private = priv;
+ handler->priv = priv;
handler->getfunc = memory_getfunc;
handler->putfunc = memory_putfunc;
priv->data = NULL;
@@ -972,7 +989,7 @@
priv = malloc (sizeof(PTPMemHandlerPrivate));
if (!priv)
return PTP_RC_GeneralError;
- handler->private = priv;
+ handler->priv = priv;
handler->getfunc = memory_getfunc;
handler->putfunc = memory_putfunc;
priv->data = data;
@@ -984,7 +1001,7 @@
/* free private struct + data */
static uint16_t
ptp_exit_send_memory_handler (PTPDataHandler *handler) {
- PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->private;
+ PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
/* data is owned by caller */
free (priv);
return PTP_RC_OK;
@@ -995,7 +1012,7 @@
ptp_exit_recv_memory_handler (PTPDataHandler *handler,
unsigned char **data, unsigned long *size
) {
- PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->private;
+ PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
*data = priv->data;
*size = priv->size;
free (priv);
@@ -1084,7 +1101,7 @@
datawlen = (size<PTP_USB_BULK_PAYLOAD_LEN_WRITE)?size:PTP_USB_BULK_PAYLOAD_LEN_WRITE;
wlen = PTP_USB_BULK_HDR_LEN + datawlen;
- ret = handler->getfunc(params, handler->private, datawlen, usbdata.payload.data, &gotlen);
+ ret = handler->getfunc(params, handler->priv, datawlen, usbdata.payload.data, &gotlen);
if (ret != PTP_RC_OK)
return ret;
if (gotlen != datawlen)
@@ -1195,7 +1212,7 @@
/* Copy first part of data to 'data' */
int putfunc_ret =
handler->putfunc(
- params, handler->private, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data,
+ params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data,
&written
);
if (putfunc_ret != PTP_RC_OK)
@@ -1264,13 +1281,13 @@
/* Copy first part of data to 'data' */
int putfunc_ret =
handler->putfunc(
- params, handler->private, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data,
+ params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data,
&written
);
if (putfunc_ret != PTP_RC_OK)
return putfunc_ret;
-
- if (FLAG_NO_ZERO_READS(ptp_usb) &&
+
+ if (FLAG_NO_ZERO_READS(ptp_usb) &&
len+PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ) {
#ifdef ENABLE_USB_BULK_DEBUG
printf("Reading in extra terminating byte\n");
@@ -1279,7 +1296,7 @@
int result = 0;
char byte = 0;
result = USB_BULK_READ(ptp_usb->handle, ptp_usb->inep, &byte, 1, ptp_usb->timeout);
-
+
if (result != 1)
printf("Could not read in extra byte for PTP_USB_BULK_HS_MAX_PACKET_LEN_READ long file, return value 0x%04x\n", result);
} else if (len+PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ && params->split_header_data == 0) {
diff --git a/src/libusb-glue.h b/src/libusb-glue.h
index 22e80fd..c68677e 100644
--- a/src/libusb-glue.h
+++ b/src/libusb-glue.h
@@ -27,12 +27,19 @@
* Modified by Linus Walleij
*
*/
+#ifndef LIBUSB_GLUE_H
+#define LIBUSB_GLUE_H
#include "ptp.h"
#include <usb.h>
#include "libmtp.h"
#include "device-flags.h"
+/* Make functions available for C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
#define USB_BULK_READ usb_bulk_read
#define USB_BULK_WRITE usb_bulk_write
@@ -114,3 +121,9 @@
#define PTP_CD_RC_CONNECTED 0
#define PTP_CD_RC_NO_DEVICES 1
#define PTP_CD_RC_ERROR_CONNECTING 2
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif // LIBUSB-GLUE_H
diff --git a/src/music-players.h b/src/music-players.h
index 0f3f083..0e29c04 100644
--- a/src/music-players.h
+++ b/src/music-players.h
@@ -209,6 +209,9 @@
// Added by Greg Fitzgerald <netzdamon@gmail.com>
{ "Samsung", 0x04e8, "SAMSUNG Trance", 0x6763, DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_NO_ZERO_READS | DEVICE_FLAG_PLAYLIST_SPL_V1 },
+ // From anonymous Sourceforge user
+ { "Samsung", 0x04e8, "GT-S5230", 0xe20c, DEVICE_FLAG_NONE },
+
/*
@@ -263,6 +266,9 @@
// From Elie De Brauwer <elie@de-brauwer.be>
{ "Philips", 0x0471, "GoGear ViBE SA1VBE08", 0x207b,
DEVICE_FLAG_UNLOAD_DRIVER },
+ // From josmtx <josmtx@users.sourceforge.net>
+ { "Philips", 0x0471, "GoGear Aria", 0x207c,
+ DEVICE_FLAG_UNLOAD_DRIVER },
// from XNJB user
{ "Philips", 0x0471, "PSA235", 0x7e01, DEVICE_FLAG_NONE },
@@ -687,7 +693,7 @@
*/
// Reported by Stefan Voss <svoss@web.de>
// This is a Sigmatel SoC with a hard disk.
- { "TrekStor", 0x066f, "Vibez 8/12GB", 0x842a,
+ { "TrekStor", 0x066f, "Vibez 8/12GB", 0x842a,
DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
// Reported by anonymous SourceForge user.
// This one done for Medion, whatever that is. Error reported so assume
@@ -701,12 +707,15 @@
{ "Maxfield", 0x066f, "G-Flash NG 1GB", 0x846c,
DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
// Reported by Cristi Magherusan <majeru@gentoo.ro>
- { "TrekStor", 0x0402, "i.Beat Sweez FM", 0x0611,
+ { "TrekStor", 0x0402, "i.Beat Sweez FM", 0x0611,
+ DEVICE_FLAG_UNLOAD_DRIVER },
+ // Reported by Fox-ino <fox-ino@users.sourceforge.net>
+ { "ALi Corp.", 0x0402, "MPMAN 2GB", 0x5668,
DEVICE_FLAG_UNLOAD_DRIVER },
// Reported by Anonymous SourceForge user
{"TrekStor", 0x1e68, "i.Beat Organix 2.0", 0x0002,
DEVICE_FLAG_UNLOAD_DRIVER },
-
+
/*
* Disney/Tevion/MyMusix
*/
@@ -822,6 +831,8 @@
* of the firmware seem to have broken it, so all are flagged as broken
* for now.
*/
+ // Reported by Thomas Schweitzer <thomas_-_s@users.sourceforge.net>
+ { "SonyEricsson", 0x0fce, "K550i", 0xe000, DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
// Reported by Øyvind Stegard <stegaro@users.sourceforge.net>
{ "SonyEricsson", 0x0fce, "K850i", 0x0075, DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
// Reported by Michael Eriksson
diff --git a/src/playlist-spl.c b/src/playlist-spl.c
index de21035..95844d0 100644
--- a/src/playlist-spl.c
+++ b/src/playlist-spl.c
@@ -1,5 +1,5 @@
/**
- * \file playlist-spl.c
+ * \File playlist-spl.c
*
* Playlist_t to Samsung (.spl) and back conversion functions.
*
@@ -21,8 +21,8 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-
+#include <config.h>
+
#include <stdio.h>
#include <stdlib.h> // mkstmp()
#include <unistd.h>
@@ -260,12 +260,12 @@
* @return 0 on success, any other value means failure.
*/
int update_spl_playlist(LIBMTP_mtpdevice_t *device,
- LIBMTP_playlist_t * const new)
+ LIBMTP_playlist_t * const newlist)
{
- IF_DEBUG() printf("pl->name='%s'\n",new->name);
+ IF_DEBUG() printf("pl->name='%s'\n",newlist->name);
// read in the playlist of interest
- LIBMTP_playlist_t * old = LIBMTP_Get_Playlist(device, new->playlist_id);
+ LIBMTP_playlist_t * old = LIBMTP_Get_Playlist(device, newlist->playlist_id);
// check to see if we found it
if (!old)
@@ -274,10 +274,10 @@
// check if the playlists match
int delta = 0;
int i;
- if(old->no_tracks != new->no_tracks)
+ if(old->no_tracks != newlist->no_tracks)
delta++;
- for(i=0;i<new->no_tracks && delta==0;i++) {
- if(old->tracks[i] != new->tracks[i])
+ for(i=0;i<newlist->no_tracks && delta==0;i++) {
+ if(old->tracks[i] != newlist->tracks[i])
delta++;
}
@@ -290,24 +290,24 @@
return -1;
IF_DEBUG() {
- if(strcmp(old->name,new->name) == 0)
+ if(strcmp(old->name,newlist->name) == 0)
printf("name unchanged\n");
else
- printf("name is changing too -> %s\n",new->name);
+ printf("name is changing too -> %s\n",newlist->name);
}
- return LIBMTP_Create_New_Playlist(device, new);
+ return LIBMTP_Create_New_Playlist(device, newlist);
}
// update the name only
- if(strcmp(old->name,new->name) != 0) {
- IF_DEBUG() printf("ONLY name is changing -> %s\n",new->name);
+ if(strcmp(old->name,newlist->name) != 0) {
+ IF_DEBUG() printf("ONLY name is changing -> %s\n",newlist->name);
IF_DEBUG() printf("playlist_id will remain unchanged\n");
- char* s = malloc(sizeof(char)*(strlen(new->name)+5));
- strcpy(s, new->name);
+ char* s = malloc(sizeof(char)*(strlen(newlist->name)+5));
+ strcpy(s, newlist->name);
strcat(s,".spl"); // FIXME check for success
- int ret = LIBMTP_Set_Playlist_Name(device, new, s);
+ int ret = LIBMTP_Set_Playlist_Name(device, newlist, s);
free(s);
return ret;
}
diff --git a/src/playlist-spl.h b/src/playlist-spl.h
index b5f84b4..ee00d35 100644
--- a/src/playlist-spl.h
+++ b/src/playlist-spl.h
@@ -30,6 +30,6 @@
int playlist_t_to_spl(LIBMTP_mtpdevice_t *device,
LIBMTP_playlist_t * const metadata);
int update_spl_playlist(LIBMTP_mtpdevice_t *device,
- LIBMTP_playlist_t * const new);
+ LIBMTP_playlist_t * const newlist);
#endif //__MTP__PLAYLIST_SPL__H
diff --git a/src/ptp.c b/src/ptp.c
index abbafae..4a2e051 100644
--- a/src/ptp.c
+++ b/src/ptp.c
@@ -246,7 +246,7 @@
ptp_init_recv_memory_handler(PTPDataHandler *handler) {
PTPMemHandlerPrivate* priv;
priv = malloc (sizeof(PTPMemHandlerPrivate));
- handler->private = priv;
+ handler->priv = priv;
handler->getfunc = memory_getfunc;
handler->putfunc = memory_putfunc;
priv->data = NULL;
@@ -266,7 +266,7 @@
priv = malloc (sizeof(PTPMemHandlerPrivate));
if (!priv)
return PTP_RC_GeneralError;
- handler->private = priv;
+ handler->priv = priv;
handler->getfunc = memory_getfunc;
handler->putfunc = memory_putfunc;
priv->data = data;
@@ -278,7 +278,7 @@
/* free private struct + data */
static uint16_t
ptp_exit_send_memory_handler (PTPDataHandler *handler) {
- PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->private;
+ PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
/* data is owned by caller */
free (priv);
return PTP_RC_OK;
@@ -289,7 +289,7 @@
ptp_exit_recv_memory_handler (PTPDataHandler *handler,
unsigned char **data, unsigned long *size
) {
- PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->private;
+ PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
*data = priv->data;
*size = priv->size;
free (priv);
@@ -337,7 +337,7 @@
ptp_init_fd_handler(PTPDataHandler *handler, int fd) {
PTPFDHandlerPrivate* priv;
priv = malloc (sizeof(PTPFDHandlerPrivate));
- handler->private = priv;
+ handler->priv = priv;
handler->getfunc = fd_getfunc;
handler->putfunc = fd_putfunc;
priv->fd = fd;
@@ -346,7 +346,7 @@
static uint16_t
ptp_exit_fd_handler (PTPDataHandler *handler) {
- PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->private;
+ PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->priv;
free (priv);
return PTP_RC_OK;
}
diff --git a/src/ptp.h b/src/ptp.h
index a96bb18..a558ff5 100644
--- a/src/ptp.h
+++ b/src/ptp.h
@@ -40,6 +40,11 @@
#define PTP_DL_BE 0xF0
#define PTP_DL_LE 0x0F
+/* USB interface class */
+#ifndef USB_CLASS_PTP
+#define USB_CLASS_PTP 6
+#endif
+
/* PTP request/response/event general PTP container (transport independent) */
struct _PTPContainer {
@@ -1839,17 +1844,17 @@
typedef struct _PTPParams PTPParams;
-typedef uint16_t (* PTPDataGetFunc) (PTPParams* params, void* private,
+typedef uint16_t (* PTPDataGetFunc) (PTPParams* params, void*priv,
unsigned long wantlen,
unsigned char *data, unsigned long *gotlen);
-typedef uint16_t (* PTPDataPutFunc) (PTPParams* params, void* private,
+typedef uint16_t (* PTPDataPutFunc) (PTPParams* params, void*priv,
unsigned long sendlen,
unsigned char *data, unsigned long *putlen);
typedef struct _PTPDataHandler {
PTPDataGetFunc getfunc;
PTPDataPutFunc putfunc;
- void *private;
+ void *priv;
} PTPDataHandler;
/*