On Sun, 18 May 2008, [EMAIL PROTECTED] wrote:
Current issue: mail_sort works as expected, consistently, with one exception.
Any search program (spg) passed to it seems to be completely ignored. I've
tried many different approaches for the last 48 hours and nothing has worked,
so I'm curious if there are known issues with this.
I sympathize with your frustration. Nonetheless, the searching capability
of mail_sort() works. The problem is either in your program or possibly
in your IMAP server.
Here is how you can prove that mail_sort() works. UW imapd calls
mail_sort() to implement sorting. You can see what it does to call
mail_sort(), starting at approximately line 700 in imapd.c.
Given that imapd calls mail_sort(), here is how you can test it with an
arrival sort for undeleted messages. Run imapd from the shell, and type
the commands in manually. The following what happened when I did it at
home:
1 select inbox
* 22 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1204587420] UID validity status
* OK [UIDNEXT 67] Predicted next UID
* FLAGS (Note Flames Request $NotJunk $Junk $Forwarded \Answered
\Flagged \Deleted \Draft \Seen)
* OK [PERMANENTFLAGS (Note Flames Request $NotJunk $Junk $Forwarded \*
\Answered \Flagged \Deleted \Draft \Seen)] Permanent flags
1 OK [READ-WRITE] SELECT completed
2 sort (arrival) utf-8 deleted
* SORT
2 OK SORT completed
3 sort (arrival) utf-8 undeleted
* SORT 1 2 3 4 8 5 6 7 9 10 11 12 13 14 15 16 17 18 19 22 20 21
3 OK SORT completed
If that doesn't convince you, apply the following patch to mtest.c
------------------------------Cut Here----------------------------------------
*** ../mtest/mtest.c Mon Nov 5 16:40:01 2007
--- ./mtest.c Sun May 18 13:17:46 2008
***************
*** 164,169 ****
--- 164,194 ----
/* get argument */
if (arg = strchr (cmd,' ')) *arg++ = '\0';
switch (*ucase (cmd)) { /* dispatch based on command */
+ case '$':
+ {
+ SEARCHPGM *search_pgm = mail_newsearchpgm ();
+ SORTPGM *sort_pgm = mail_newsortpgm ();
+ unsigned long *r,*sort_results;
+ search_pgm->undeleted = T;
+ sort_pgm->function = SORTARRIVAL;
+ fputs ("arrival sorting undeleted:",stdout);
+ if (sort_results = mail_sort
(stream,"UTF-8",search_pgm,sort_pgm,SO_FREE | SE_FREE)) {
+ for (r = sort_results; *r; ++r) printf (" %lu",*r);
+ putchar ('\n');
+ fs_give ((void **) &sort_results);
+ }
+ else puts ("sort error");
+ (search_pgm = mail_newsearchpgm ())->deleted = T;
+ (sort_pgm = mail_newsortpgm ())->function = SORTARRIVAL;
+ fputs ("arrival sorting deleted:",stdout);
+ if (sort_results = mail_sort
(stream,"UTF-8",search_pgm,sort_pgm,SO_FREE | SE_FREE)) {
+ for (r = sort_results; *r; ++r) printf (" %lu",*r);
+ putchar ('\n');
+ fs_give ((void **) &sort_results);
+ }
+ else puts ("sort error");
+ }
+ break;
case 'B': /* Body command */
if (arg) last = atoi (arg);
else if (!last) {
------------------------------Cut Here----------------------------------------
which is essentially the code in your snippet.
Then run mtest, and try the added $ command. Assuming that your copy of
c-client hasn't been "improved" by some third party in a way that breaks
searching, it will give the correct results for the two cases for local
mailboxes, POP3, and NNTP.
Now, if the mail is being accessed via IMAP, answer "Y" to the "debug
protocol command" in mtest to get protocol telemetry and analyze what the
server is doing. If you see something like:
00000002 SORT (ARRIVAL) UTF-8 DELETED
* SORT 1 2 3 4 8 5 6 7 9 10 11 12 13 14 15 16 17 18 19 22 20 21
00000002 OK SORT completed
00000003 SORT (ARRIVAL) UTF-8 UNDELETED
* SORT 1 2 3 4 8 5 6 7 9 10 11 12 13 14 15 16 17 18 19 22 20 21
00000003 OK SORT completed
or
00000002 SEARCH UTF-8 DELETED
* SEARCH 1 2 3 4 8 5 6 7 9 10 11 12 13 14 15 16 17 18 19 22 20 21
00000002 OK SEARCH completed
00000003 SEARCH UTF-8 UNDELETED
* SEARCH 1 2 3 4 8 5 6 7 9 10 11 12 13 14 15 16 17 18 19 22 20 21
00000003 OK SEARCH completed
Then you have a smoking gun that the IMAP server is broken. The only
remedy is to replace your IMAP server with a known working server, such as
UW imapd, Cyrus, or Dovecot.
stream->dtb->sort = &mail_sort_msgs;
Do not do this, nor any other modifications to DTBs or other c-client
internals. At best, doing so is harmless. Far more likely, this kind of
skullduggery will create bizarre problems that nobody will have a hope of
finding.
If you are not using an IMAP server, or the IMAP server is behaving
reasonably, then it's a bug in your program.
-- Mark --
http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
_______________________________________________
Imap-uw mailing list
[email protected]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw