[Kde-pim] Kmail API: deleting emails from a kmail maildir folder.

Kevin Krammer krammer at kde.org
Mon Apr 23 17:14:47 BST 2012


On Monday, 2012-04-23, augustin wrote:
> Hello Kevin and all,
> 
> Thanks for your detailed reply.
> 
> On Saturday, April 21, 2012 12:00:38 AM Kevin Krammer wrote:

> > What version of KMail / KDE PIM are you targetting?
> 
> This already in an important issue.
> I am still using Kubuntu 11.04 with KDE 4.6.5 and Kmail  1.13.6.
> The reason I have not yet upgraded to newer versions is precisely because
> of kmail.

Ok, that establishes a base line we can work with :)

> I have almost 10 years worth of emails, with family pictures attachments,
> .pps and movie clips forwarded by friends, etc.... so much that my mail
> directory is quite imposing and my hard drive quite full (with other stuff
> as well!)

I think I understand that quite well :)

> So my first question is:
> 1- how much extra space does kmail need to upgrade? Does it need space to
> copy data from an old format to a new one? HDD space is an issue.

It is more or less "in-place", only things like custom tags or custom flags are 
copied.

> 2- Are there known issues for kubuntu 11.04 -> 11.11 upgrade (kmail 1 ->
> kmail 2)? Do I really need to be worried?

The problem is that it is know to have caused problems that do not manifest 
during developer testing. Which usually means it is related to something small 
which the impacts the process rather severely :(

> Yep. I'd like to work with kmail2, but there is a chicken and egg question:
> 
> Do I tidy my mails and make space on the drive before attempting the
> upgrade? In which case I'd like to take the time to develop a helper tool
> (using Kmail 1 API) beforehand.

I see.

> Or do I upgrade first and tidy later (using a Kmail 2 / Akodani helper
> tool)?

I guess both approaches have their advantages.

> I haven't yet taken the time to properly investigate the distro's upgrade
> path.

The easiest way is probably to make sure that KMail/Kontact does not autostart 
and run the migrator tool manually.
I.e. having one process less that can interfer with the procedure :)

> > > I can write the application to browse the maildirs, and parse the MIME.
> > > I have found a couple of APIs that I might use (any recommendations?).
> > 
> > libkmime (kdepimlibs/kmime), libmaildir (kdepim-
> > runtime/resources/maildir/libmaildir)
> 
> Ok. I'll check them out.

I think the maildir resource should contain all use cases you'll have as well, 
i.e. traversing the tree, reading mails, deleting mails.

> > > But where I am a bit uncertain, is how to handle the deletion of the
> > > emails. Deleting a specific email is certainly easy (delete the
> > > corresponding file), but what about regenerating indexes?
> > 
> > Depends on the targetted KDE PIM version.
> > With KMail 1 you can not do that, it assumes full ownership of its
> > maildir tree.
> 
> Well, I could still use a very ugly hack.
> 
> With a maildir format, I can easily delete the mail (the corresponding
> file). As to the index, I noticed the following:
> http://userbase.kde.org/KMail/FAQs_Hints_and_Tips#Problem:_You_are_losing_m
> ail I see that there is an option to manually rebuild an index, or as
> suggested I could delete the index file, which would be recreated when I
> next start kmail.

Right. Recreation of index files can lead to loss of status that is not encoded 
into mail filenames. depends on whether you use those flags and tags.

> Ugly, yes, but only a temporary hack. Unless of course I upgrade first.

Probably not that bad of a hack depending on your custom flag usage.
Just make sure KMail is not running while you do that :)

> > With KMail 2 it depends on what Akonadi resource is handling the maildir
> > tree. The maildir resource can deal with file notifications (right
> > Andras?), the "KMail Folders" (mixed maildir) resource can't do that yet.
> > However in the case of a KMail 2 setup, mail manipulation facilities are
> > available for all programs, not just KMail.
> 
> "Kmail folders"? They are not in the (I assume standard) maildir format?
> What's the difference?

KMail had the capability of doing folders in MBox and Maildir formats (hence 
"mixed"). There is an abstraction in kdepim-runtime/resources/mixedmaildir 
called the MixedMaildirStore that deals with those differences. But you don't 
need that if you have a maildir only tree.

We only needed KMail index file read support for that so it can't unfortunately 
write them. Otherwise it would be a perfect match for modifying the tree while 
keeping the index files updated as well.

Not sure how much work it would be to add index file writing.

> > > Wouldn't I be better off using some d-bus API? Let kmail perform the
> > > deletion itself? Does one d-bus API exist for email deletion?
> > 
> > I don't think there is such an API yet, but somebody else might know
> > better.
> 
> Using 'qdbus', I browsed the available methods, but didn't find anything
> related to deletion.

I thought so. This operation is just not needed for the use case the D-Bus 
interface was created for.

> As I have hinted above, I am a long term, very happy KDE user (kmail,
> konqueror... etc.). My professional and personal life leaves me with little
> time, but I really would like to find appropriate ways to contribute. I am
> a very beginner C++ developer and learning (very) slowly.

If you have any questions, also for general KDE development advice, just come 
back here.

> However, we already noticed that API documentation was an issue. And I am
> very willing to extract the essence of your help here and put it in a more
> appropriate place (in an official KDE wiki, in a tutorial in my own web
> site, etc...) so that future developers can learn from my own learning
> process... Please, do let me know which ways would be the most appropriate
> to achieve this.

Tutorials and high-level documentation is always welcome.
techbase.kde.org hosts those. I think you can login with any OpenID provider 
or create an account on identity.kde.org

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20120423/573e0acf/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list