Age | Commit message (Collapse) | Author |
|
Examples assumed that parent id 0 will list only the top directory, but
actually that's an id for all files (it does happen to correspond to the
reported parent id however). The actual id to be used for the top folder
is 0xffffffff.
Add a new define to make the value more obvious as well.
|
|
The existing LIBMTP_Read_Event function blocks while waiting for
an event. This can lead to race conditions where a client attempts
to disconnect from the device in one thread while an event just
happens to arrive in the polling thread, with unpredictable results,
including attempts to disconnect twice.
To make life easier for clients, we can offer an asynchronous form
of event checking, which gives the client the ability to terminate
polling when necessary.
To do this, we can leverage the asynchronous capabilities of
libusb-1. That's only one of three possible backends, but it's the
most commonly and heavily used library.
Starting an asynchronous transfer is pretty straightforward, but
polling can be done in a variety of ways, some of which are very
complicated. For my purposes, one of the simpler forms is sufficient,
and, in fact, the most generalised form doesn't offer me any
advantages.
Accordingly, I put a trivial wrapper around this method so that it
can be used without making the client explicitly pull in libusb-1.
It's a bit weird, but worth the convenience.
So, we now have a Read_Events_Async that takes a callback and
a Handle_Events method that will poll for activity. How have we
solved the original problem?
There are two ways.
1) We can pass a timeout to Handle_Events. This will cause it to
return if no activity happened. We can then assess whether it is
safe to poll some more or give up.
2) libusb has recently added an 'interrupt_event_handler' function
https://github.com/libusb/libusb/commit/a6db382ad11f7662b550338e0570d5a2dfd8ce5a
This function finally offers a way to interrupt polling on demand.
No release of libusb with this in it has happened yet, but hopefully
it will happen soon.
Now, you could ask, with fairness, why this interrupt mechanism
shouldn't work with the existing synchronous Read_Event; and I
agree - it should - but it doesn't.
Due to a bug in libusb, even though the interruption works, the
synchronous wrapper code they have will immediately start the
polling again and never return control to the caller.
So, even when we're in a position to use this interruption
function, we'll still need to be using the async API to take
advantage of it.
I've verified that all this logic works in gvfs.
|
|
This adds and API to check a device for specific capabilities,
when need be.
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
These events, along with the previously exposed StoreAdded event,
are the most frequently implemented events on MTP devices. In the
case of Google's Android MTP stack, they are the only events
exposed.
In the case of StoreRemoved, the param value is the storage ID
and in the case of ObjectAdded/Removed, it is the entity ID.
Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
This change just adds simple libmtp wrappers for the libptp
methods that in turn expose the android in-place read/write extensions.
Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
I noticed that, for my MTP devices, Windows appeared to
detect when storages appeared after unlocking the device.
So, I figured there were probably StoreAdded events being
generated, and this turned out to be the case.
So, it would be highly desirable to pass these events on to
clients so they can react accordingly.
This implementation is quite ad-hoc, and can't really be considered
fully baked. I don't know what the grand scheme is/was for events,
but I'm sure passing each param out separately was not part of it.
In any case, I'm passing out param1 as it is the ID of the added
storage entity.
I've tested this with my in-progress mtp backend for gvfs and it
works as hoped; I can pass on a gvfs notification that results in the
storage appearing in Nautilus.
Signed-off-by: Philip Langdale <philipl@overt.org>
|
|
Even though this is theoretically obsolete in MTP, it may still
be the only working mechanism to obtain thumbnails from an MTP
device.
Signed-off-by: Philip Langdale <philipl@overt.org>
|
|
Signed-off-by: Catalin Patulea <cat@vv.carleton.ca>
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
Some symbols from <usb.h> were still used here and there
in the libusb glue code. Remove <usb.h> from the libmtp.h
header, what did it do there in the first place?
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
|
|
|
|
storage, useful in file handling:
LIBMTP_Get_Folder_List_For_Storage()
|
|
|
|
Introduce new mtp-filetree test program for the new interface.
|
|
from Yavor Goulishev <yavor@google.com> for use in an
OS X MTP file transfer program for Android.
Refactor:
- Break out obj2file and reuse in all functions that want
to fill in a LIBMTP_file_t from a PTP object.
Introduce new interfaces:
- LIBMTP_Open_Raw_Device_Uncached() to open an uncached
device from a raw device.
- LIBMTP_Get_Files_And_Folders() that will only work on
uncached devices.
Signed-off-by: Yavor Goulishev <yavor@google.com>
Signed-off-by: Linus Walleij <triad@df.lth.se>
|
|
|
|
|
|
|
|
This function permits you to select all tracks only for a device storage
|
|
This function permits you to select all albums only for a device storage
|
|
|
|
See :
LIBMTP_DEBUG_NONE
LIBMTP_DEBUG_PTP
LIBMTP_DEBUG_USB
LIBMTP_DEBUG_PLST
LIBMTP_DEBUG_DATA
LIBMTP_DEBUG_ALL
|
|
To avoid build and build only to enable (or disable) debug mode, we
work now as the lib libusb :)
As libusb, you can do :
LIBMTP_Set_Debug(flags);
or use an environnement variable :
export LIBMTP_DEBUG=flags
flags value details :
* 0x00 [0000 0000] : no debug (default)
* 0x01 [0000 0001] : PTP debug
* 0x02 [0000 0010] : Playlist debug
* 0x04 [0000 0100] : USB debug
* 0x08 [0000 1000] : USB data debug
|
|
|
|
|
|
|
|
|
|
album & playlist types
|
|
|
|
Changed LIBMTP_Update_Playlist metadata from const * const to * const, since
Samsung playlist updates can't promise that the playlist ID will remain
unchanged due to the inability to modify files in place.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
content, use this in sendtr.c.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
values in libusb-glue.c. Update fdi file generation.
|
|
|
|
hold the object size for objects on a certain device.
|
|
|