This patch, which applies to fvwm 2.5.10, gives FvwmTaskBar the ability to
read from a qemu Maildir mail box. It needs some work (may not be a compliant
Maildir reader) but it seems to work.

I don't feel confortable playing around with the Makefiles so I just added
#define USE_MAILDIR at the top of Goodies.c (I'm hoping that someone who
knows more can do this right).

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
--- Goodies.c.orig      Sun Jun 29 20:55:22 2003
+++ Goodies.c   Tue Aug  3 19:47:43 2004
@@ -16,10 +16,15 @@
 
 #include "config.h"
 
+#define USE_MAILDIR
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
+#ifdef USE_MAILDIR
+#include <dirent.h>
+#endif
 #include <pwd.h>
 #include "libs/ftime.h"
 #include <sys/stat.h>
@@ -712,13 +717,75 @@
 /* (based on the code of 'coolmail' By Byron C. Darrah */
 /*-----------------------------------------------------*/
 
+#ifdef USE_MAILDIR
+static int oldsize = 0;
+
+/* filter to show only new entries */
+int maildir_filter(const struct dirent * a)
+{
+    if (!strcmp(a->d_name, ".") || !strcmp(a->d_name, ".."))
+    {
+       return 0;
+    }
+    return 1;
+}
+#endif
+
 void cool_get_inboxstatus()
 {
+#ifdef USE_MAILDIR
+   int  newsize;
+   struct dirent **newlist;
+   struct dirent **curlist;
+   char * alt_mailpath;
+   int curent, newent;
+#else
    static off_t oldsize = 0;
    off_t  newsize;
    struct stat st;
    int fd;
+#endif
+
+#ifdef USE_MAILDIR
+   alt_mailpath = malloc(strlen(mailpath) + strlen("/new") + 1);
+   strcpy(alt_mailpath, mailpath);
+   strcat(alt_mailpath, "/new");
+   newent = scandir(alt_mailpath, &newlist, maildir_filter, alphasort);
+   free(alt_mailpath);
+
+   alt_mailpath = malloc(strlen(mailpath) + strlen("/cur") + 1);
+   strcpy(alt_mailpath, mailpath);
+   strcat(alt_mailpath, "/cur");
+   curent = scandir(alt_mailpath, &curlist, maildir_filter, alphasort);
+   free(alt_mailpath);
+
+   newsize = curent + newent;
 
+   if (newent > 0)
+   {
+       anymail = 1;
+       unreadmail = 1;
+   }
+   else if (curent > 0)
+   {
+       anymail = 1;
+       unreadmail = 0;
+   }
+   else
+   {
+       anymail = 0;
+       unreadmail = 0;
+   }
+   if (newsize > oldsize && unreadmail)
+   {
+       newmail = 1;
+       mailcleared = 0;
+   }
+   else
+   {
+       newmail = 0;
+   }
+#else
    fd = open (mailpath, O_RDONLY, 0);
    if (fd < 0)
    {
@@ -750,6 +817,7 @@
       else
         newmail = 0;
    }
+#endif
 
    oldsize = newsize;
 }

Reply via email to