After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 312178 - KMail backend
KMail backend
Status: RESOLVED FIXED
Product: beagle
Classification: Other
Component: General
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Beagle Bugs
Beagle Bugs
: 311755 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-08-01 00:40 UTC by Debajyoti Bera
Modified: 2005-09-26 18:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
beagled/MaildirQueryable/MaildirQueryable.cs (12.96 KB, patch)
2005-08-01 00:45 UTC, Debajyoti Bera
none Details | Review
beagled/MaildirQueryable/KMaildirCrawler.cs (7.75 KB, patch)
2005-08-01 00:45 UTC, Debajyoti Bera
none Details | Review
new version (14.36 KB, patch)
2005-08-05 22:15 UTC, Debajyoti Bera
none Details | Review
Inotify problem fixed and added deletion support (15.30 KB, patch)
2005-08-06 20:55 UTC, Debajyoti Bera
none Details | Review
+ beagled/KmailQueryable/KMailDriver.cs (6.41 KB, patch)
2005-08-27 06:33 UTC, Debajyoti Bera
none Details | Review
+ beagled/KmailQueryable/KMailIndexableGenerator.cs (8.44 KB, patch)
2005-08-27 06:33 UTC, Debajyoti Bera
none Details | Review
+ beagled/KmailQueryable/MailCrawler.cs (16.51 KB, patch)
2005-08-27 06:34 UTC, Debajyoti Bera
none Details | Review
KmailQueryable\KMailDriver.cs (7.28 KB, patch)
2005-08-30 16:45 UTC, Debajyoti Bera
none Details | Review
KmailQueryable\KMailIndexer.cs (18.03 KB, patch)
2005-08-30 16:46 UTC, Debajyoti Bera
none Details | Review
KmailQueryable\KMailIndexableGenerator.cs (8.65 KB, patch)
2005-08-30 16:47 UTC, Debajyoti Bera
none Details | Review

Description Debajyoti Bera 2005-08-01 00:40:11 UTC
First try at KMail maildir backend. To make it extensible and add support for   
any maildir mail client later, wrote it in two files.   
   
KMaildirCrawler.cs - contains the generic MaildirCrawler and KMaildirCrawler   
(extending MaildirCrawler) which implements the specific details of KMail   
maildir format.   
MaildirQueryable.cs - which asks MaildirCrawlers for the folders to watch and   
index. It is primarily a wrapper around FilterMail. 
   
This is only a first try. There are lots of comments in the file and lots of   
debug messages, pls ignore them. 
 
Add these files to beagled/MaildirQueryable.
Comment 1 Debajyoti Bera 2005-08-01 00:45:00 UTC
Created attachment 50037 [details] [review]
beagled/MaildirQueryable/MaildirQueryable.cs

This file is made similar to the backends in beagle-0.12. There might be some
changes necessary in lines of recent developments.
Comment 2 Debajyoti Bera 2005-08-01 00:45:47 UTC
Created attachment 50038 [details] [review]
beagled/MaildirQueryable/KMaildirCrawler.cs

Made against beagle-0.12.
Comment 3 Debajyoti Bera 2005-08-01 01:20:40 UTC
Sorry for the typo. Add the files in beagled/MaildirQueryable/ 
Comment 4 Daniel Drake 2005-08-02 23:04:21 UTC
*** Bug 311755 has been marked as a duplicate of this bug. ***
Comment 5 Debajyoti Bera 2005-08-05 22:15:30 UTC
Created attachment 50299 [details] [review]
new version

This is based on the discussion in the thread 
http://mail.gnome.org/archives/dashboard-hackers/2005-August/msg00023.html
Comment 6 Debajyoti Bera 2005-08-06 20:55:54 UTC
Created attachment 50330 [details] [review]
Inotify problem fixed and added deletion support

Fixed a bug when Inotify is not present and added support for deletion of mails
. Pls try and report.
Comment 7 Debajyoti Bera 2005-08-21 14:32:31 UTC
Dont review or try this.
I recently came to know and started using the disconnected imap feature of kmail
- so now we need to index two trees - one local and another dimap.
Additionally I noticed that the mail folders can be stored in maildir/mbox
format and they can be used interchangably.

Adding support for these required me to rewrite the backend completely (based on
the structure of Evo mail backend). It is unavoidable now to have separate
crawler class and separate indexable generator classes.

Work in progress. Keep watching the space - I will need review and testing once
done :)
Comment 8 Debajyoti Bera 2005-08-27 06:33:20 UTC
Created attachment 51406 [details] [review]
+ beagled/KmailQueryable/KMailDriver.cs
Comment 9 Debajyoti Bera 2005-08-27 06:33:47 UTC
Created attachment 51407 [details] [review]
+ beagled/KmailQueryable/KMailIndexableGenerator.cs
Comment 10 Debajyoti Bera 2005-08-27 06:34:22 UTC
Created attachment 51408 [details] [review]
+ beagled/KmailQueryable/MailCrawler.cs
Comment 11 Debajyoti Bera 2005-08-27 06:42:34 UTC
Redid the backend. The queryable needs to watch multiple locations, each of
which can contain an arbitrary mix of mbox and maildir mail folders. The design
of Evo mail backend suits this case so the new files follow the design of
EvolutionMailDriver, with some changes as needed. As a result, now we have 3 files.

* KMailDriver - main indexable - which is kind of dummy - just creates seperate
crawlers for different mail locations
* KMailIndexableGenerator - Maildir and Mbox indexable generator
* MailCrawler - does the bulk of the actual indexing work

TODO: parse kmailrc ... kinda boring :(
TODO: parsing the .index files to find out which mails are deleted (done by
Camel in evo) - pointers ?
Comment 12 Debajyoti Bera 2005-08-30 16:45:21 UTC
Created attachment 51562 [details] [review]
KmailQueryable\KMailDriver.cs

Some cleanup. Waiting for review on this version.
Comment 13 Debajyoti Bera 2005-08-30 16:46:13 UTC
Created attachment 51563 [details] [review]
KmailQueryable\KMailIndexer.cs

Some cleanup. Pls review and test this version.
Comment 14 Debajyoti Bera 2005-08-30 16:47:06 UTC
Created attachment 51564 [details] [review]
KmailQueryable\KMailIndexableGenerator.cs

Some cleanup and better use of mboxlastoffset. Pls review.
Comment 15 Joe Shaw 2005-09-22 20:03:04 UTC
Ok, finally got a chance to look this over.  Overall, very good.  I only have a
few nitpicks:

* Rename KMailDriver.cs to KMailQueryable.cs and change the namespace as well. 
I suspect you copied this from the Evo backend, which calls itself a Driver as a
historial artifact (and the fact that you can't rename files in CVS, argh.)

* Let's move the changelogs out of the source files and into the toplevel
ChangeLog file.  Right now we're not requiring ChangeLog entries, but we will
start at some point.

* Could the directory that GuessLocalFolder() calls DirectoryInfo.GetFiles() be
very big (regardless of the wildcard)?  If so, use our specialided
DirectoryWalker class.  Ditto for Crawl() in KMailIndexer.cs.

* In OnInotifyEvent() in KMailIndexer.cs, I would recommend moving the code
which actually creates an indexable task out into a separate function (like
AddIndexable()) and then just short circuit all of the if clauses, so make the
function easier to read.  (Some return and others fall through.)

* In Watch(), definitely use our DirectoryWalker class or else you'll use a ton
of CPU and memory if there are many files.

* "Array _mbox_files = mbox_files.ToArray ();" with the comment "copy the
contents as mail_directories, mbox_files might change due to async events". 
This is pretty gross.  Are you worried about the elements being removed?  If so,
make a copy along the lines of "ArrayList mbox_files_copy = new ArrayList
(mbox_files);" rather than using Array.  (Or strongly type the array)

* I see "if (folder_name == Queryable.sentmail_foldername)".  By convention
public fields are StudlyCapped.  So this should probably beb "if (folder_name ==
Queryable.SentMailFolderName)".

* I am pretty sure the ParentUri thing will work for mboxes, but if it causes
problems I recently added a special remove task which will remove anything that
matches a property, so you could remove any item which has a parent folder
property of a certain name.  But I think this will work too

* In GetMboxFile, "filename.Remove (pos, 6).Remove (0,1);"  That's pretty ugly,
and not immediately obvious on inspection.  Can you change it to be
filename.Substring (1, pos - 2)?

* Update_directories() should be UpdateDirectories().

* Try to avoid passing around Arrays, and instead use ICollection.

* I think that the indexable generator's AddFiles stuff will need to be
refactored a bit.  I have some *huge* maildir directories, and as I mentioned
before DirectoryInfo.GetFiles() sucks bad.  You'll need to use
DirectoryWalker.GetFiles(), which returns an IEnumerable (which actually
probably makes things a little easier).

* A lot of this code is derived from the Evo backend, so you should add
"Copyright (C) 2005 Novell, Inc." to the comments.
Comment 16 Debajyoti Bera 2005-09-26 17:06:23 UTC
Phew! In CVS, at last. Joe, thanks a ton. 
Comment 17 Aviram Jenik 2005-09-26 18:00:11 UTC
I can confirm that the CVS version works nicely. Sweet :-) 
Thanks for the great work guys!