summaryrefslogtreecommitdiff
path: root/mail/mutt-devel/files/extra-patch-maildir-mtime
blob: 09884c69b28b0dc6f075a07544b47c17b170cc0e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
--- PATCHES Dec 2002 17:44:54 -0000	3.6
+++ PATCHES Feb 2004 13:19:42 -0000
@@ -0,0 +1 @@
+patch-1.5.7.ust.maildir-mtime.1
--- browser.c Sep 2003 13:03:25 -0000	3.9
+++ browser.c Feb 2004 13:19:42 -0000
@@ -29,2 +29,3 @@
 #endif
+#include "mx.h"
 
@@ -304,4 +305,6 @@ folder_format_str (char *dest, size_t de
 static void add_folder (MUTTMENU *m, struct browser_state *state,
-			const char *name, const struct stat *s, int new)
+			const char *name, struct stat *s, BUFFY *mbuf)
 {
+  int new = (mbuf) ? mbuf->new : 0;
+
   if (state->entrylen == state->entrymax)
@@ -317,2 +320,5 @@ static void add_folder (MUTTMENU *m, str
 
+  if (mbuf && mbuf->magic == M_MAILDIR && mbuf->mtime)
+    s->st_mtime = mbuf->mtime;
+
   if (s != NULL)
@@ -411,3 +417,3 @@ static int examine_directory (MUTTMENU *
       tmp = tmp->next;
-    add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
+    add_folder (menu, state, de->d_name, &s, tmp);
   }
@@ -435,3 +441,3 @@ static int examine_mailboxes (MUTTMENU *
     {
-      add_folder (menu, state, tmp->path, NULL, tmp->new);
+      add_folder (menu, state, tmp->path, NULL, tmp);
       continue;
@@ -442,3 +448,3 @@ static int examine_mailboxes (MUTTMENU *
     {
-      add_folder (menu, state, tmp->path, NULL, tmp->new);
+      add_folder (menu, state, tmp->path, NULL, tmp);
       continue;
@@ -456,3 +462,3 @@ static int examine_mailboxes (MUTTMENU *
 
-    add_folder (menu, state, buffer, &s, tmp->new);
+    add_folder (menu, state, buffer, &s, tmp);
   }
--- buffy.c.orig	Sat Oct 30 23:40:07 2004
+++ buffy.c	Sat Feb  5 13:57:07 2005
@@ -227,6 +227,7 @@
     (*tmp)->new = 0;
     (*tmp)->notified = 1;
     (*tmp)->newly_created = 0;
+    (*tmp)->mtime = 0;
 
 #ifdef BUFFY_SIZE
     /* for buffy_size, it is important that if the folder is new (tested by
@@ -258,6 +259,7 @@
 {
   BUFFY *tmp;
   struct stat sb;
+  struct stat smd;
   struct dirent *de;
   DIR *dirp;
   char path[_POSIX_PATH_MAX];
@@ -297,6 +299,7 @@
   for (tmp = Incoming; tmp; tmp = tmp->next)
   {
     tmp->new = 0;
+    tmp->mtime = 0;
 
 #ifdef USE_IMAP
     if (mx_is_imap (tmp->path))
@@ -370,21 +373,31 @@
       case M_MAILDIR:
 
 	snprintf (path, sizeof (path), "%s/new", tmp->path);
+        stat (path, &smd);
+	tmp->mtime = smd.st_mtime;
 	if ((dirp = opendir (path)) == NULL)
 	{
 	  tmp->magic = 0;
 	  break;
 	}
+
 	while ((de = readdir (dirp)) != NULL)
 	{
 	  char *p;
 	  if (*de->d_name != '.' && 
 	      (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 	  {
-	    /* one new and undeleted message is enough */
-	    BuffyCount++;
-	    tmp->new = 1;
-	    break;
+	    if (!tmp->new)
+	    {
+	      /* one new and undeleted message is enough */
+	      BuffyCount++;
+	      tmp->new = 1;
+	    }
+	    snprintf (path, sizeof (path), "%s/new/%s", tmp->path, de->d_name);
+	    if (!stat (path, &smd) && smd.st_mtime > tmp->mtime)
+	    {
+	      tmp->mtime = smd.st_mtime;
+	    }
 	  }
 	}
 	closedir (dirp);
@@ -414,6 +427,12 @@
 #ifdef BUFFY_SIZE
     else if (Context && Context->path)
       tmp->size = (long) sb.st_size;	/* update the size */
+#else
+    else if(tmp->magic == M_MAILDIR) {
+	snprintf (path, sizeof (path), "%s/new", tmp->path);
+        stat (path, &smd);
+	tmp->mtime = smd.st_mtime;
+    }
 #endif
 
     if (!tmp->new)
--- buffy.h Dec 2002 11:19:39 -0000	3.2
+++ buffy.h Feb 2004 13:19:42 -0000
@@ -29,2 +29,3 @@ typedef struct buffy_t
   struct buffy_t *next;
+  time_t mtime;			/* for maildirs...time of newest entry */
   short new;			/* mailbox has new mail */