[ Cross list reply from users list, here is my original post if somebody is interested
http://lists.roundcube.net/mail-archive/users/2011-09/0000050.html
]
Hello again,
On Wed, 21 Sep 2011 12:18:31 +0200 A.L.E.C wrote:
On 21.09.2011 12:08, Miguel Telleria de Esteban wrote:
OPEN QUESTIONS: Is there a way in roundcube to trace the IMAP traffic?
imap_debug option.
Although I guess that if I don't have the threading options displayed in folder settings is because roundcube has already parsed the capabilities from the server correctly.
Right.
Ok, I can confirm that my IMAP server does not have the THREAD capability.
- Figuring out how to recover client-side thread sorting in
roundcube as a Fallback when the server does not implement it.
You could try to write the code, but it would be slow.
Ok, I am going to give it a try :).
So, if I understand correctly the indications here:
http://lists.roundcube.net/mail-archive/users/2011-08/0000028.html
THE FOLLOWING THINGS APPLY
Each time a threading sort is needed, the method: rcube_imap_generic :: thread() is called.
function thread($mailbox, $algorithm='REFERENCES', $criteria='', $encoding='US-ASCII')
This thread() method must perform the following actions:
Invoke the THREAD command on the IMAP server using the function arguments ordering algorithm, search criteria and encoding as their directly correspondants in the IMAP THREAD command (RFC 5256).
Treat the response, and parse it returning the following values:
These (tree, depthmap and haschildren) values are generated from the IMAP THREAD response by the recursive parseThread() private method.
The IMAP THREAD response is specified in RFC 5256, and here I paste an illustrative example
Server response:
* THREAD (2)(3 6 (4 23)(44 7 96))
means
-- 2
-- 3
\-- 6
|-- 4
| \-- 23
|
\-- 44
\-- 7
\-- 96
RFC 5256 defines two sorting/threading algorithms:
ORDEREDSUBJECT: Poor man's threading algo based on heuristincs in the subject content.
REFERENCES: Uses "References" (preferably) or "In-Reply-To" (alternatively) header to match "Message-Id" values and establish parent-->child relationships.
Besides than the RFC 5256, the references method is also described here: http://www.jwz.org/doc/threading.html
There is an additional sorting/threading algorithm recognised by roundcube:
REFS: Slight variation of REFERENCES in which the Subject field is completely ignored.
So far it seems to be defined in IETF Drafts, it has not reached RFC status yet.
http://tools.ietf.org/html/draft-ietf-morg-inthread-01 http://tools.ietf.org/html/draft-gulbrandsen-imap-inthread-03
The selected threading algorithm is stored in $RCMAIL->imap->threading
having as values: "REFS", "REFERENCES", "ORDEREDSUBJECT" or NULL (to signal no threading support)
The Iloha IMAP library (former file /program/lib/imap.inc) from which rcube_imap_generic.php evolves has the following functions related to threading:
iil_SortThreadHeaders() iil_C_FetchThreadHeaders() iil_C_BuildThreads2() iil_SortThreads() iil_IndexThreads()
the thread structure is implemented as:
class iilThreadHeader { var $id; var $sbj; var $irt; var $mid; }
MY PROPOSED APPROACH (see also open questions below)
Inside the rcube_imap_generic::thread() function bypass the this->execute(THREAD) command and call a function of my own:
client_side_thread_command($mailbox, $criteria, $encoding)
This function should perform the following actions:
Obtain the message-id (or UID?) of files with the SEARCH criteria
FETCH the headers REFERENCES, IN-REPLY-TO and MESSAGE-ID of the searched messages.
Perform the REFS algorithm on them following RFC 5256 or jmz.org's article (I hope that this is already done in iil library).
Return a parenthesised list with the thread ordering similar to the IMAP THREAD reply so that it can be fed to parseThread(), or alternatively generate the tree, depthmap and haschildren data structure directly.
CODING RESOURCES
http://trac.roundcube.net/wiki/Dev_Docs http://trac.roundcube.net/wiki/Dev_PHPCommons
http://roundcube.net/doc/phpdoc/Mail/rcube_imap.html http://roundcube.net/doc/phpdoc/Mail/rcube_imap_generic.html
OPEN QUESTIONS:
Is this thread() function, the only entry point for thread ordering in roundcube?. If it is true then I guess that paging, sorting, etc are solved elsewhere.
Is there a per-mailbox indication for threading?
Is there a combined search+fetch-headers function in rcube_imap_generic() or rcube_imap()
Should I work with UID's or message sequences?
Should I code based on 0.6-rc base or in a more modern svn checkout?
Any more comments will be welcome. I plan to start the work next week.
Regards,
Miguel