Accept drop: Thunderbird attachment?

Hi!

I have a little app which accepts a file drop from Finder and this works well.
Now I want to accept a direct drop from a Thunderbird mail attachment but I don’t get anything.

Any idea what I need to use as “me.Accept…Drop” for Thunderbird attachment?

PS. After dropping the file to Finder I can of course drop it from Finder to my app but I want a direct drop which is much more convenient.

I had the same problem with Apple Mail, but I don’t find an answer. I have an Apple script which grabs the selected email and save it to a folder of my application, but this will not work if sandbox is activated (for MAS).

[quote=174122:@Thomas Eckert]Hi!

I have a little app which accepts a file drop from Finder and this works well.
Now I want to accept a direct drop from a Thunderbird mail attachment but I don’t get anything.

Any idea what I need to use as “me.Accept…Drop” for Thunderbird attachment?

PS. After dropping the file to Finder I can of course drop it from Finder to my app but I want a direct drop which is much more convenient.[/quote]

I just quickly played with Thunderbird and a test project. I could not find any file type that worked, but then I tried dragging the attachment from Thunderbird over the Xojo app icon. The App.OpenDocument fires and shows an item.folderitem that points to the Temp folder. No file.

Apparently, Thunderbird saves the attachment based solely on the destination, but the dragged item does not contain informations about the actual file.

Yep. Only a folder item to a Temp folder is provided.

Well, that information must be somehow provided. How could you drag the attachment to Finder otherwise?

There is no file when you start dragging a message from Apple Mail (don’t know about Thunderbird). There is only a so-called “Promised File” on OS X.

That’s how far I got:

AcceptMacDataDrop("url ") // note the space after url AcceptMacDataDrop("urln") AcceptMacDataDrop("phfs") AcceptMacDataDrop("fssP")

MacDataAvailable will give you kind of an id of the message for "url ", the subject line of the email for “urln”, some data for “phfs” (maybe a pointer to the promised file ?), nothing for “fssP”.

There is somewhere in the forum an AppleScript to get the message text by the id returned by MacDataAvailable("url ").

Thanks Eli.
This does help because now I get the drop but the DragItem does not contain useful data.
Everything is nil in debugger, only the DragHeight, width, top and left got values and obj.Handle.

So I did add

dim p As Ptr = ptr(obj.Handle) dim pp As Ptr = p.Ptr
to investigate the content in debugger. Unfortunately it gives no clue because there is no file name or other useful information (for me at least :wink:

Any ideas how to use that data?

As I wrote: “That’s how far I got”. Never been able to solve this.

To answer my own post…
I managed to get something working. Thunderbird does use no NSURLPboardType (like Finder) or NSFilenamesPboardType (like Apple Mail) but NSFilesPromisePboardType.
The promise file handling is somewhat tricky but documented (see Apple NSDraggingInfo Protocol Reference for details).
Unfortunately the Thunderbird implementation is buggy because the namesOfPromisedFilesDroppedAtDestination call returns no file name at all.
I implemented a workaround and now I’m able to receive a drop from Thunderbird. Unfortunately I saw no way to build this in Xojo and so I used Swift instead.

Great to here. Can you share the Swift code?

Swift –> Objective C –> Xojo Declare

I would like to dig into that.

Sorry. No source, just a clue.
Implement the NSDraggingDestination protocol events with some tracing to see what´s happend during the drop.
In performDragOperation check sender.draggingPasteboard() for the pb.types.
When you get this working it should be easy to get everything from the pasteboard.
Just remember to call namesOfPromisedFilesDroppedAtDestination so that Thunderbird writes a file, even when it returns no useful filename(s).

I had to handle Promised Files with Apple’s Photos, I posted the code here, let me know if it helps in any way.

https://forum.xojo.com/21742-promised-files-or-getting-files-from-apple-s-photos-app

Thanks Sam.

I got it already running using Promised Files in SWIFT.