Bug 8904

Summary: Implement dragging messages as a whole (i.e. as message/rfc822) to other applications
Product: [Unmaintained] kmail Reporter: Unknown <null>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: wishlist CC: adam, ce, Daniel.Frein, fuzz
Priority: NOR    
Version: 1.1.90   
Target Milestone: ---   
Platform: unspecified   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: start of a patch

Description George Staikos 2000-08-24 14:36:22 UTC
(*** This bug was imported into bugs.kde.org ***)

Package: kmail
Version: 1.1.90 (KDE 1.93 Beta >= 20000813)
Severity: normal

Dragging a message from a folder to the desktop still doesn't work.  I assume it doesn't
work to try to drag to another app either.  The file created on the desktop is empty although
it appears to save the empty file just fine.
Comment 1 Neil Stevens 2003-03-10 04:40:39 UTC
Bug still exists in KDE 3.1. 
Comment 2 Ingo Klöcker 2003-06-17 01:41:57 UTC
*** Bug 59920 has been marked as a duplicate of this bug. ***
Comment 3 David Jarvie 2003-07-19 05:57:56 UTC
Drag-and-drop to another application would be a useful feature for KAlarm, and 
possibly KOrganizer too.
Comment 4 Michael Jahn 2004-07-07 13:47:46 UTC
Still valid for kdepim CVS 2004-06-30.
Comment 5 Carsten Burghardt 2004-07-07 19:51:12 UTC
How did you try that? What kind of folder is the source and what kind of 
message it is? Works here, that's why I ask.

Comment 6 George Staikos 2004-07-07 20:03:32 UTC
On Wednesday 07 July 2004 13:51, Carsten Burghardt wrote:
> ------- Additional Comments From burghardt kde org  2004-07-07 19:51
> ------- How did you try that? What kind of folder is the source and what
> kind of message it is? Works here, that's why I ask.

  Just tried it, the source folder is Inbox on a dimap account, and I get a 
"filename for clipboard contents" dialog.  I give it a filename, and it 
contains utf8 text and binary data of little meaning.

Comment 7 David Faure 2004-07-07 20:46:20 UTC
I see the same when dropping a mail from a local maildir folder.
The 'garbage' in the result looks like a QByteArray containing QStrings.
Will debug later, the garden calls :)

Comment 8 Ingo Klöcker 2004-07-18 16:50:48 UTC
KMail creates a KPIM::MailListDrag. The result of the drag is a KPIM::MailSummary. What did you expect? The same as if you'd save the message? Well, sorry, but that's still not implemented.

Dragging messages to KDE PIM applications that can handle MailListDrags works very well.
Comment 9 Tom Albers 2004-09-08 17:09:02 UTC
*** Bug 89085 has been marked as a duplicate of this bug. ***
Comment 10 Sebastien 2005-01-24 18:47:27 UTC
I tryed with Evolution and it give interesting data:
- x-evolution-message (contain "file:///home/seb/evolution/local/Inbox\010568")
- message/rfc822 (contain the integral message)
- text/uri-list (contain "file:///tmp/evolution-501-3377/drag-n-drop-QEIsZ3/Re: basket")
When dragging more than one mail at a time, the uri-list contain a link
to a mbox file ("file:///tmp/evolution-501-3377/drag-n-drop-3muxAc/mbox"), but the rfc822 contain nothing (bad), the x-evolution-message add a '\0' and a
mail number for each mail at the end.

Just some toughts...
Comment 11 George Staikos 2005-03-01 00:16:38 UTC
This shouldn't be too hard to implement.  We need to make sure that kmail decodes drops correctly (ie: it looks for what it wants, not just taking the first mimetype provided), and we need to modify libkdepim/maillistdrag.* to provide a mechanism to decode the data in full.
Comment 12 George Staikos 2005-03-01 00:47:38 UTC
Created attachment 9896 [details]
start of a patch

I think this is the way to do it.  I just need to know how to store the right
pointers or variables in the drag object and turn those into a QByteArray
message/rfc822 when required.
Comment 13 George Staikos 2005-03-01 22:20:37 UTC
CVS commit by staikos: 

Implement drag and drop of email to KDesktop, etc.
FEATURE: 8904
COOKIES: staikos@kde.org
X-Thanks-To: faure@kde.org, adam@kde.org


  A            kmail/textsource.cpp   1.1 [LGPL (v2+)]
  A            kmail/textsource.h   1.1 [LGPL (v2+)]
  M +1 -1      kmail/Makefile.am   1.330
  M +3 -1      kmail/kmheaders.cpp   1.705
  M +74 -4     libkdepim/maillistdrag.cpp   1.3
  M +24 -4     libkdepim/maillistdrag.h   1.4



Comment 14 David Jarvie 2005-03-23 17:07:46 UTC
I wonder if drag and drop to other applications has actually been implemented with the new code? In order to fetch the whole message, a class needs to be derived from MailTextSource which is defined as a virtual base class in maillistdrag.h. To fetch the message data, the virtual method text(), which takes the message serial number as a parameter, must be implemented. Am I right in thinking that for an application other than kmail, this is not actually possible since only kmail can access the message data by serial number?
Comment 15 George Staikos 2005-03-23 17:16:25 UTC
On Wednesday 23 March 2005 11:07, David Jarvie wrote:
> ------- I wonder if drag and drop to other applications has actually been
> implemented with the new code? In order to fetch the whole message, a class
> needs to be derived from MailTextSource which is defined as a virtual base
> class in maillistdrag.h. To fetch the message data, the virtual method
> text(), which takes the message serial number as a parameter, must be
> implemented. Am I right in thinking that for an application other than
> kmail, this is not actually possible since only kmail can access the
> message data by serial number?


   It provides two different formats, the original KMail one, and the full 
contents.  The app is free to choose what it wants.  The one thing that 
should probably still be done is to make dragging of multiple messages 
actually create a proper mbox.  I have no idea how to do this with KMail 
right now so I didn't do it.
Comment 16 David Jarvie 2005-03-23 18:18:47 UTC
But the full contents are accessible only if the app derives a class from MailTextSource and implements the virtual method text(). The revised maillistdrag library files don't appear to provide any way for an app to implement this method. Only kmail has access to the data required to implement this method.

This was always the stumbling block in the past to fetching the full contents of messages - kmail provides no DCOP call to return the contents given a serial number. The new library methods don't appear to remedy this.
Comment 17 George Staikos 2005-03-23 18:23:06 UTC
On Wednesday 23 March 2005 12:18, David Jarvie wrote:
> ------- But the full contents are accessible only if the app derives a
> class from MailTextSource and implements the virtual method text(). The
> revised maillistdrag library files don't appear to provide any way for an
> app to implement this method. Only kmail has access to the data required to
> implement this method.
>
> This was always the stumbling block in the past to fetching the full
> contents of messages - kmail provides no DCOP call to return the contents
> given a serial number. The new library methods don't appear to remedy this.


  ?? The new code puts the contents inside the drag object already...  That's 
how, for example, you can drop the messages onto KDesktop.  Am I somehow 
misunderstanding?
Comment 18 David Jarvie 2005-03-23 20:01:35 UTC
My reading of the code is that in order to access the contents of a dropped message, you have to call MailListDrag::encodedData("message/rfc822"). However, this method only returns the contents of the message via the member _src (a MailTextSource*). However, the libkdepim library doesn't define a non-virtual MailTextSource class, so I don't see how the contents can be extracted by calling the library functions.
Comment 19 George Staikos 2005-03-23 20:10:53 UTC
On Wednesday 23 March 2005 14:01, David Jarvie wrote:

> ------- My reading of the code is that in order to access the contents of a
> dropped message, you have to call
> MailListDrag::encodedData("message/rfc822"). However, this method only
> returns the contents of the message via the member _src (a
> MailTextSource*). However, the libkdepim library doesn't define a
> non-virtual MailTextSource class, so I don't see how the contents can be
> extracted by calling the library functions.


   The drag source inherits from MailTextSource and reimplements it to give 
the text of a message with a given serial number.  The target calls 
encodedData("message/rfc822") and gets the text in a QByteArray.  It doesn't 
need to know about MailTextSource.
Comment 20 Adam Porter 2006-03-05 10:22:02 UTC
Any progress on this?
Comment 21 Till Adam 2006-03-05 10:49:00 UTC
On Sunday 05 March 2006 10:22, Adam Porter wrote:
> Any progress on this?


I think I implemented this a while ago. Not sure whether it's in 3.5, 
but should be.

Till