Two patches for the mail module.

The first one is a small optimisation in the _mail_mdir_get_files
function.  Since "ecore_file_ls" already excludes "." and ".." there's
no need to loop over the entire list.

The second one fixes the mail counting of maildir boxes.
For getting the total number of mails we need to count the mails in both
"new" and "cur" (not just "cur").  So for keeping track of the new/total
number two monitors are needed.
Since these directory monitors only trigger when there's an actual
change, we need do need to fill the num_new and num_total when creating
the mdir mailbox.  Otherwise it doesn't show the number of new/total
mails until something happens with the mailbox.

regards,
Peter van de Werken
-- 
Live in a world of your own,
but always welcome visitors.
Index: mdir.c
===================================================================
RCS file: /var/cvs/e/e_modules/mail/mdir.c,v
retrieving revision 1.7
diff -u -r1.7 mdir.c
--- mdir.c      25 Jul 2007 17:06:41 -0000      1.7
+++ mdir.c      2 Mar 2008 15:41:47 -0000
@@ -96,17 +96,10 @@
 _mail_mdir_get_files (const char *path)
 {
   Ecore_List *l;
-  char *item;
   int i = 0;
 
   l = ecore_file_ls (path);
-  ecore_list_first_goto (l);
-  while ((item = (char *) ecore_list_next (l)) != NULL)
-    {
-      if ((!strcmp (item, ".")) || (!strcmp (item, "..")))
-       continue;
-      i++;
-    }
+  i = ecore_list_count (l);
   ecore_list_destroy (l);
   return i;
 }
Index: mdir.c
===================================================================
RCS file: /var/cvs/e/e_modules/mail/mdir.c,v
retrieving revision 1.7
diff -u -r1.7 mdir.c
--- mdir.c      25 Jul 2007 17:06:41 -0000      1.7
+++ mdir.c      2 Mar 2008 15:42:52 -0000
@@ -21,11 +21,16 @@
   mc = E_NEW (MdirClient, 1);
   mc->config = cb;
   mc->data = data;
-  mc->config->num_new = 0;
-  mc->config->num_total = 0;
-  mc->monitor =
+  mc->monitor_new =
     ecore_file_monitor_add (cb->new_path, _mail_mdir_check_mail, mc);
+  mc->monitor_cur =
+    ecore_file_monitor_add (cb->cur_path, _mail_mdir_check_mail, mc);
+  
+  mc->config->num_new = _mail_mdir_get_files (mc->config->new_path);
+  mc->config->num_total = mc->config->num_new + _mail_mdir_get_files 
(mc->config->cur_path);
 
+  _mail_set_text(mc->data);
+  
   mdirs = evas_list_append (mdirs, mc);
 }
 
@@ -64,8 +69,10 @@
       MdirClient *mc;
 
       mc = mdirs->data;
-      if (mc->monitor)
-       ecore_file_monitor_del (mc->monitor);
+      if (mc->monitor_new)
+       ecore_file_monitor_del (mc->monitor_new);
+      if (mc->monitor_cur)
+       ecore_file_monitor_del (mc->monitor_cur);
       mdirs = evas_list_remove_list (mdirs, mdirs);
       free (mc);
       mc = NULL;
@@ -83,8 +90,9 @@
   if (!mc)
     return;
 
-  mc->config->num_total = _mail_mdir_get_files (mc->config->cur_path);
   mc->config->num_new = _mail_mdir_get_files (mc->config->new_path);
+  mc->config->num_total =
+    mc->config->num_new + _mail_mdir_get_files (mc->config->cur_path);
 
   _mail_set_text (mc->data);
   if ((mc->config->num_new > 0) && (mc->config->use_exec)
Index: mdir.h
===================================================================
RCS file: /var/cvs/e/e_modules/mail/mdir.h,v
retrieving revision 1.1
diff -u -r1.1 mdir.h
--- mdir.h      11 Jun 2006 17:37:53 -0000      1.1
+++ mdir.h      2 Mar 2008 15:42:52 -0000
@@ -10,7 +10,8 @@
 {
    void *data;
    Config_Box *config;
-   Ecore_File_Monitor *monitor;
+   Ecore_File_Monitor *monitor_new;
+   Ecore_File_Monitor *monitor_cur;
 };
 
 void _mail_mdir_add_mailbox(void *data, void *data2);

Attachment: pgpJBCQVEGIBD.pgp
Description: PGP signature

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to