well this makes things fail for people ...
[apps/madmutt.git] / buffy.cpkg
index 5ea4188..264caac 100644 (file)
@@ -15,8 +15,7 @@
 #include <utime.h>
 
 #include <lib-lua/lib-lua.h>
-#include <lib-ui/curses.h>
-#include <lib-ui/sidebar.h>
+#include <lib-ui/lib-ui.h>
 #include <lib-mx/mx.h>
 #include <lib-mx/mh.h>
 
@@ -32,7 +31,7 @@ static short  BuffyCount = 0;     /* how many boxes with new mail */
 static short  BuffyNotify = 0;    /* # of unnotified new boxes */
 buffy_array   Incoming;
 
-@package Buffy {
+@package mod_buffy {
     /*
      ** .pp
      ** This variable configures how often (in seconds) Madmutt should look for
@@ -121,7 +120,7 @@ int buffy_check(int force)
     struct stat contex_sb;
     time_t now, last1, last2;
     CONTEXT *ctx;
-    int i = 0, local = 0, count = 0;
+    int i = 0, local = 0;
 
     /* update postponed count as well, on force */
     if (force == 1)
@@ -132,12 +131,12 @@ int buffy_check(int force)
         return 0;
 
     now = time (NULL);
-    if (force == 0 && (now - BuffyTime < Buffy.mail_check)
+    if (force == 0 && (now - BuffyTime < mod_buffy.mail_check)
         && (now - ImapBuffyTime < ImapBuffyTimeout))
         return BuffyCount;
 
     last1 = BuffyTime;
-    if (force == 1 || now - BuffyTime >= Buffy.mail_check)
+    if (force == 1 || now - BuffyTime >= mod_buffy.mail_check)
         BuffyTime = now;
     last2 = ImapBuffyTime;
     if (force == 1 || now - ImapBuffyTime >= ImapBuffyTimeout)
@@ -145,8 +144,6 @@ int buffy_check(int force)
     BuffyCount = 0;
     BuffyNotify = 0;
 
-    count = sidebar_need_count();
-
     if (!Context || !Context->path || 
         (mx_is_local (Context->magic-1) && stat (Context->path, &contex_sb) != 0)) {
         /* check device ID and serial number instead of comparing paths */
@@ -173,10 +170,9 @@ int buffy_check(int force)
                                            m_strcmp(tmp->path, Context->path))) {
             switch (tmp->magic) {
               case M_MBOX:
-              case M_MMDF:
                 /* only check on force or $mail_check reached */
-                if (force == 1 || (now - last1 >= Buffy.mail_check)) {
-                    if (!count) {
+                if (force == 1 || (now - last1 >= mod_buffy.mail_check)) {
+                    if (!sidebar_w) {
                         if (STAT_CHECK) {
                             BuffyCount++;
                             tmp->new = 1;
@@ -205,7 +201,7 @@ int buffy_check(int force)
 
               case M_MAILDIR:
                 /* only check on force or $mail_check reached */
-                if (force == 1 || (now - last1 >= Buffy.mail_check)) {
+                if (force == 1 || (now - last1 >= mod_buffy.mail_check)) {
                     snprintf (path, sizeof (path), "%s/new", tmp->path);
                     if ((dirp = opendir (path)) == NULL) {
                         tmp->magic = 0;
@@ -222,7 +218,7 @@ int buffy_check(int force)
                             /* one new and undeleted message is enough */
                             if (tmp->new == 0) {
                                 BuffyCount++;
-                                if (!count) {
+                                if (!sidebar_w) {
                                     /* if sidebar invisible -> done */
                                     tmp->new = 1;
                                     break;
@@ -235,7 +231,7 @@ int buffy_check(int force)
                     }
                     closedir (dirp);
 
-                    if (count) {
+                    if (sidebar_w) {
                         /* only count total mail if sidebar visible */
                         snprintf (path, sizeof (path), "%s/cur", tmp->path);
                         if ((dirp = opendir (path)) == NULL) {
@@ -264,10 +260,10 @@ int buffy_check(int force)
 
               case M_MH:
                 /* only check on force or $mail_check reached */
-                if (force == 1 || (now - last1 >= Buffy.mail_check)) {
+                if (force == 1 || (now - last1 >= mod_buffy.mail_check)) {
                     if ((tmp->new = mh_buffy (tmp->path)) > 0)
                         BuffyCount++;
-                    if (count) {
+                    if (sidebar_w) {
                         DIR *dp;
 
                         if ((dp = opendir (path)) == NULL)
@@ -319,7 +315,7 @@ int buffy_check(int force)
     }
     if (BuffyCount > 0 && force != 2)
         sidebar_draw ();
-    return (BuffyCount);
+    return BuffyCount;
 }
 
 int buffy_list (void)