>> 2009/9/4 Christopher Michael <[email protected] >> <mailto:[email protected]>> >> >> Nicolas H. wrote: >> > Hello everyone here, >> > >> > >> > I hope it's the right place to send this, I was recommended to do >> so on >> > the #e irc. >> > >> > So, I already have used the mail module in the past and I >> remember it >> > used to display the number of new (unread) e-mails of my mailbox, >> using >> > pop3. This seems quite expected. I would be really surprised >> if I'm >> > wrong about this. >> > >> > Yesterday I tried it again but this time instead of displaying >> the >> > number of unread e-mails, it displays the total number of >> e-mails. Which >> > I find weird (is it really the purpose of the mail module ?). >> > >> > So I checked the source code here : >> > http://trac.enlightenment.org/e/browser … A/mail/src >> > >> >> <http://trac.enlightenment.org/e/browser/trunk/E-MODULES-EXTRA/mail/src> >> > >> > and noticed that there is a field called num_new that is >> used... and >> > because of its name, and because of the way it is used, I >> think it is >> > intended to get the number of new messages. >> > >> > For instance, in e_mod_main.c : >> > >> > >> > Code: >> > >> > 649 void >> > 650 _mail_set_text (void *data) >> > 651 { >> > 652 Instance *inst = data; >> > 653 Eina_List *l; >> > 654 char buf[1024]; >> > 655 int count = 0; >> > 656 >> > 657 if (!inst) >> > 658 return; >> > 659 >> > 660 for (l = inst->ci->boxes; l; l = l->next) >> > 661 { >> > 662 Config_Box *cb; >> > 663 >> > 664 cb = l->data; >> > 665 if (!cb) >> > 666 continue; >> > 667 count += cb->num_new; >> > 668 } >> > 669 >> > 670 if (count > 0) >> > 671 { >> > ... >> > >> > >> > The loop seems to count the sum of all new messages of the >> different >> > mailboxes. >> > >> > In pop.c : >> > >> > >> > Code: >> > >> > static void >> > 215 _mail_cb_mouse_down (void *data, Evas * e, Evas_Object >> * obj, >> > 216 void *event_info) >> > 217 { >> > ... >> > 254 snprintf (buf, sizeof (buf), "%s: %d/%d", >> cb->name, >> > cb->num_new, >> > 255 cb->num_total); >> > ... >> > >> > >> > >> > this seems to be the code what displays the small pop-up with >> name of >> > the mailbox, plus number of new messages and number of all >> messages >> > (that can be expected to be usually different). >> > >> > Then here in pop.c : >> > >> > >> > Code: >> > >> > 156 static int >> > 157 _mail_pop_server_data (void *data, int type, void *event) >> > 158 { >> > ... >> > 203 case POP_STATE_STATUS_OK: >> > 204 if (sscanf (in, "+OK %i %i", &num, &total) == 2) >> > 205 { >> > 206 pc->config->num_new = num; >> > 207 pc->config->num_total = num; >> > 208 } >> > >> > >> > >> > Here the data received from the pop3 server are "scanned" and >> weirdly, >> > both fields num_new and num_total get the same value (num). >> > >> > Then I read the pop3 rfc (http://www.ietf.org/rfc/rfc1939.txt) >> and >> > unfortunately it seems NOT to be possible to retrieve directly >> the >> > number of new e-mails from the pop3 server. The sscanf (in, "+OK >> %i %i", >> > &num, &total) actually gives the total number of e-mails to &num >> and the >> > size of the mailbox to &total. So num_new gets the total >> number of >> > e-mails and it's no surprise that the mail module displays this >> number >> > instead of the number of new messages. >> > >> > So I am a bit confused. I am quite sure it used to work. Is there >> still >> > a way to bring the mail module to display the number of new >> e-mails >> > (using pop3) ? Or am I totally wrong and it is not intended to do >> so ?? >> > >> > I hope I didn't bother you with a scilly question, but I couldn't >> find >> > an answer to it anywhere else so far. >> > >> > I wish you a nice day, >> > >> > >> > >> > Nicolas Hainaux >> > >> You are correct in your assumptions there. POP3 does not have a >> "total >> new" option. It may have been possible in the past (due to the >> code), >> but the pop code was rewritten (by someone, don't remember who) >> after my >> initial write, so I am not entirely sure how it is handled now. >> If you >> really really want the total # of new messages, I believe that >> IMAP has >> support for that (iirc). >> >> Honestly tho, the whole mail module needs a serious rewrite but I >> just >> haven't found the time. >> >> devilhorns >> > Atton Jonathan wrote: >> maybe the old way was to saved the number of messages in a file and >> then compare the new number to the old ? > Christopher Michael a écrit : >> >> IIRC, yea that was what it was doing. >> >> dh > > Well, I have no idea about this old way, maybe it is possible to find it again in the archives thanks to svn (or cvs ?). Anyway, just saving the number of messages and comparing it to the new one won't work in frequent cases. Let's assume there are 40 messages. The user, for any reason, deletes one. Then a new message comes before the mail module checked the box... the next time it will check it, it will find 40 messages again and won't display anything new !
On another hand, while reading the rfc again, I found a hint. Without any argument, the LIST command retrieves a short summary for each message in the mailbox. Each message is identified with a number. This number seems to be unique for each message (this sounds logical and moreover in other commands it is mentionned that the argument can be... a message-number (required) which may NOT refer to a message marked as deleted so when a message is deleted, its number is obviously not given to a new one later.) This example of a mailbox with two messages is given in the rfc : C: LIST S: +OK 2 messages (320 octets) S: 1 120 S: 2 200 S: . The second number is the size of the message, doesn't really matter. So I would suggest to save the numbers of the messages (in this case 1 and 2) in a file. The next time, count how many messages in the new list have got a number that doesn't exist in the saved list. This will give the number of new messages. And that's no matter if a message has been deleted in the meanwhile, it just won't appear in the new list, but we don't care. For example, if we saved the last result (1 2), and if message 1 is deleted on the server and a new one comes, the list would look like : C: LIST S: +OK 2 messages (350 octets) S: 2 200 S: 3 150 S: . As number 3 still doesn't exist in the saved list (1 2), we know that there's a message (even though the total amount didn't change). Just add number 3 to the saved list, display there's 1 new message and that's done. I don't think I am able to rewrite the whole mail module but if I find (a lot of) time, maybe I can try to propose a patch ? Nicolas H. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
