On Tue, Aug 03, 2004 at 09:32:28PM -0400, Jim C. Brown wrote:
> 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.

The patch looks interesting.

> 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).

Using compile time configuration in general and #ifdef in
particular is not the right way in fvwm.  Every feature has to be
configurable at run time.  Here is what I would do:

 - Add a new config variable, e.g. MailDir
 - Add a flag that indicates whether MailBox or MailDir is used.
 - Split the __cool_get_inboxstatus() function into two sub
   functions __cool_get_inboxstatus_mailbox() and
   cool_get_inboxstatus_maildir() and call one of them from
   cool_get_inboxstatus() according to the flag state.

> --- 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;
>  }

Ciao

Dominik ^_^  ^_^

 --
Dominik Vogt, [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]

Attachment: pgpsllA3MeheY.pgp
Description: PGP signature

Reply via email to