diff --git a/ChangeLog b/ChangeLog index 002410da..0ec1823e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ Carpathia). * Fix shown battery status when the battery is not charging any more but is not full charged patch sf.net id #2556056 (thanks Martin) + * Extended support for local Maildir patch sf.net id #2561323 (thanks + Nicolas) 2009-02-15 * Added out_to_x diff --git a/README b/README index 8b405ce3..1d5b287b 100644 --- a/README +++ b/README @@ -1100,10 +1100,75 @@ conky(1) conky(1) your favourite protocol. See also new_mails. + 1mnew_mails (mailbox) (interval)0m + Unread mail count in the specified mailbox or mail spool if not. + Both mbox and maildir type mailboxes are supported. + + + 1mseen_mails (maildir) (interval)0m + Number of mails marked as seen in the specified mailbox or mail + spool if not. Only maildir type mailboxes are supported, mbox + type will return -1. + + + 1munseen_mails (maildir) (interval)0m + Number of new or unseen mails in the specified mailbox or mail + spool if not. Only maildir type mailboxes are supported, mbox + type will return -1. + + + 1mflagged_mails (maildir) (interval)0m + Number of mails marked as flagged in the specified mailbox or + mail spool if not. Only maildir type mailboxes are supported, + mbox type will return -1. + + + 1munflagged_mails (maildir) (interval)0m + Number of mails not marked as flagged in the specified mailbox + or mail spool if not. Only maildir type mailboxes are supported, + mbox type will return -1. + + + 1mforwarded_mails (maildir) (interval)0m + Number of mails marked as forwarded in the specified mailbox or + mail spool if not. Only maildir type mailboxes are supported, + mbox type will return -1. + + + 1munforwarded_mails (maildir) (interval)0m + Number of mails not marked as forwarded in the specified mailbox + or mail spool if not. Only maildir type mailboxes are supported, + mbox type will return -1. + + + 1mreplied_mails (maildir) (interval)0m + Number of mails marked as replied in the specified mailbox or + mail spool if not. Only maildir type mailboxes are supported, + mbox type will return -1. + + + 1munreplied_mails (maildir) (interval)0m + Number of mails not marked as replied in the specified mailbox + or mail spool if not. Only maildir type mailboxes are supported, + mbox type will return -1. + + + 1mdraft_mails (maildir) (interval)0m + Number of mails marked as draft in the specified mailbox or mail + spool if not. Only maildir type mailboxes are supported, mbox + type will return -1. + + + 1mtrashed_mails (maildir) (interval)0m + Number of mails marked as trashed in the specified mailbox or + mail spool if not. Only maildir type mailboxes are supported, + mbox type will return -1. + + 1mmboxscan (-n number of messages to print) (-fw from width) (-sw subject0m 1mwidth) mbox0m - Print a summary of recent messages in an mbox format mailbox. - mbox parameter is the filename of the mailbox (can be encapsu‐ + Print a summary of recent messages in an mbox format mailbox. + mbox parameter is the filename of the mailbox (can be encapsu‐ lated using ’"’, ie. ${mboxscan -n 10 "/home/brenden/some box"} @@ -1114,14 +1179,14 @@ conky(1) conky(1) Bar that shows amount of memory in use - 1mmemgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi‐0m + 1mmemgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi‐0m 1ment colour 2) (scale)0m - Memory usage graph. Uses a logarithmic scale (to see small num‐ + Memory usage graph. Uses a logarithmic scale (to see small num‐ bers) when you use "log" instead of "normal". 1mmemeasyfree0m - Amount of free memory including the memory that is very easily + Amount of free memory including the memory that is very easily freed (buffers/cache) @@ -1137,39 +1202,39 @@ conky(1) conky(1) 1mmixer (device)0m - Prints the mixer value as reported by the OS. Default mixer is - "vol", but you can specify one of the following optional argu‐ + Prints the mixer value as reported by the OS. Default mixer is + "vol", but you can specify one of the following optional argu‐ ments: "vol", "bass", "treble", "synth", "pcm", "speaker", - "line", "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", + "line", "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", "line1", "line2", "line3", "dig1", "dig2", "dig3", "phin", "phout", "video", "radio", "monitor". Refer to the definition of - SOUND_DEVICE_NAMES in (on Linux), (on Linux), (on OpenBSD), or to find the exact op‐ tions available on your system. 1mmixerbar (device)0m - Displays mixer value in a bar as reported by the OS. See docs + Displays mixer value in a bar as reported by the OS. See docs for $mixer for details on arguments. 1mmixerr (device)0m - Prints the right channel mixer value as reported by the OS. See + Prints the right channel mixer value as reported by the OS. See docs for $mixer for details on arguments. 1mmixerrbar (device)0m - Displays the right channel mixer value in a bar as reported by + Displays the right channel mixer value in a bar as reported by the OS. See docs for $mixer for details on arguments. 1mmixerl (device)0m - Prints the left channel mixer value as reported by the OS. See + Prints the left channel mixer value as reported by the OS. See docs for $mixer for details on arguments. 1mmixerlbar (device)0m - Displays the left channel mixer value in a bar as reported by + Displays the left channel mixer value in a bar as reported by the OS. See docs for $mixer for details on arguments. @@ -1291,20 +1356,15 @@ conky(1) conky(1) 1mif_mpd_playing0m - if mpd is playing or paused, display everything between + if mpd is playing or paused, display everything between $if_mpd_playing and the matching $endif 1mnameserver (index)0m - Print a nameserver from /etc/resolv.conf. Index starts at and + Print a nameserver from /etc/resolv.conf. Index starts at and defaults to 0. - 1mnew_mails (mailbox) (interval)0m - Unread mail count in the specified mailbox or mail spool if not. - Both mbox and maildir type mailboxes are supported. - - 1mnodename0m Hostname diff --git a/doc/conky.1 b/doc/conky.1 index 1a110264..0f4234a5 100644 --- a/doc/conky.1 +++ b/doc/conky.1 @@ -950,6 +950,61 @@ Both mbox and maildir type mailboxes are supported. You can use a program like fetchmail to get mails from some server using your favourite protocol. See also new_mails. +.TP +\fB\*(T<\fBnew_mails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Unread mail count in the specified mailbox or mail spool if +not. Both mbox and maildir type mailboxes are supported. + +.TP +\fB\*(T<\fBseen_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails marked as seen in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBunseen_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of new or unseen mails in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBflagged_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails marked as flagged in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBunflagged_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails not marked as flagged in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBforwarded_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails marked as forwarded in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBunforwarded_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails not marked as forwarded in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBreplied_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails marked as replied in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBunreplied_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails not marked as replied in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBdraft_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails marked as draft in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + +.TP +\fB\*(T<\fBtrashed_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T> +Number of mails marked as trashed in the specified mailbox or mail spool if +not. Only maildir type mailboxes are supported, mbox type will return -1. + .TP \fB\*(T<\fBmboxscan\fR\*(T>\fR \*(T<\fB(\-n number of messages to print) (\-fw from width) (\-sw subject width) mbox\fR\*(T> Print a summary of recent messages in an mbox format mailbox. mbox parameter is the filename of the mailbox (can be encapsulated using '"', ie. ${mboxscan -n 10 "/home/brenden/some box"} @@ -1130,11 +1185,6 @@ if mpd is playing or paused, display everything between $if_mpd_playing and the \fB\*(T<\fBnameserver\fR\*(T>\fR \*(T<\fB(index)\fR\*(T> Print a nameserver from /etc/resolv.conf. Index starts at and defaults to 0. -.TP -\fB\*(T<\fBnew_mails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T> -Unread mail count in the specified mailbox or mail spool if -not. Both mbox and maildir type mailboxes are supported. - .TP \fB\*(T<\fBnodename\fR\*(T>\fR Hostname diff --git a/doc/variables.xml b/doc/variables.xml index 43d482aa..ab14f1c7 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -1216,6 +1216,138 @@ + + + + + + + + Unread mail count in the specified mailbox or mail spool if + not. Both mbox and maildir type mailboxes are supported. + + + + + + + + + + + Number of mails marked as seen in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of new or unseen mails in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails marked as flagged in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails not marked as flagged in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails marked as forwarded in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails not marked as forwarded in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails marked as replied in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails not marked as replied in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails marked as draft in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + + + + + + + + + Number of mails marked as trashed in the specified mailbox or mail spool if + not. Only maildir type mailboxes are supported, mbox type will return -1. + + + @@ -1634,18 +1766,6 @@ - - - - - - - - Unread mail count in the specified mailbox or mail spool if - not. Both mbox and maildir type mailboxes are supported. - - - diff --git a/src/conky.c b/src/conky.c index f63baf75..2138a4bf 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1252,6 +1252,16 @@ static void free_text_objects(struct text_object *root) break; case OBJ_mails: case OBJ_new_mails: + case OBJ_seen_mails: + case OBJ_unseen_mails: + case OBJ_flagged_mails: + case OBJ_unflagged_mails: + case OBJ_forwarded_mails: + case OBJ_unforwarded_mails: + case OBJ_replied_mails: + case OBJ_unreplied_mails: + case OBJ_draft_mails: + case OBJ_trashed_mails: free(data.local_mail.box); break; case OBJ_imap: @@ -2600,6 +2610,193 @@ static struct text_object *construct_text_object(const char *s, } } + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(new_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(seen_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(unseen_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(flagged_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(unflagged_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(forwarded_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(unforwarded_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(replied_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(unreplied_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(draft_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + + variable_substitute(box, dst, sizeof(dst)); + obj->data.local_mail.box = strndup(dst, text_buffer_size); + obj->data.local_mail.interval = n1; + END OBJ(trashed_mails, 0) + float n1; + char box[256], dst[256]; + + if (!arg) { + n1 = 9.5; + strncpy(box, current_mail_spool, sizeof(box)); + } else { + if (sscanf(arg, "%s %f", box, &n1) != 2) { + n1 = 9.5; + strncpy(box, arg, sizeof(box)); + } + } + variable_substitute(box, dst, sizeof(dst)); obj->data.local_mail.box = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; @@ -2642,28 +2839,6 @@ static struct text_object *construct_text_object(const char *s, END OBJ(monitor, INFO_X11) END OBJ(monitor_number, INFO_X11) #endif - END OBJ(new_mails, 0) - float n1; - char box[256], dst[256]; - - if (!arg) { - n1 = 9.5; - /* Kapil: Changed from MAIL_FILE to - current_mail_spool since the latter - is a copy of the former if undefined - but the latter should take precedence - if defined */ - strncpy(box, current_mail_spool, sizeof(box)); - } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { - n1 = 9.5; - strncpy(box, arg, sizeof(box)); - } - } - - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); - obj->data.local_mail.interval = n1; END OBJ(nodename, 0) END OBJ(processes, INFO_PROCS) END OBJ(running_processes, INFO_RUN_PROCS) @@ -4725,16 +4900,66 @@ static void generate_text_internal(char *p, int p_max_size, update_mail_count(&obj->data.local_mail); snprintf(p, p_max_size, "%d", obj->data.local_mail.mail_count); } - OBJ(mboxscan) { - mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output, - text_buffer_size); - snprintf(p, p_max_size, "%s", obj->data.mboxscan.output); - } OBJ(new_mails) { update_mail_count(&obj->data.local_mail); snprintf(p, p_max_size, "%d", obj->data.local_mail.new_mail_count); } + OBJ(seen_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.seen_mail_count); + } + OBJ(unseen_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.unseen_mail_count); + } + OBJ(flagged_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.flagged_mail_count); + } + OBJ(unflagged_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.unflagged_mail_count); + } + OBJ(forwarded_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.forwarded_mail_count); + } + OBJ(unforwarded_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.unforwarded_mail_count); + } + OBJ(replied_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.replied_mail_count); + } + OBJ(unreplied_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.unreplied_mail_count); + } + OBJ(draft_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.draft_mail_count); + } + OBJ(trashed_mails) { + update_mail_count(&obj->data.local_mail); + snprintf(p, p_max_size, "%d", + obj->data.local_mail.trashed_mail_count); + } + OBJ(mboxscan) { + mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output, + text_buffer_size); + snprintf(p, p_max_size, "%s", obj->data.mboxscan.output); + } OBJ(nodename) { snprintf(p, p_max_size, "%s", cur->uname_s.nodename); } diff --git a/src/mail.c b/src/mail.c index 20655577..86691ed0 100644 --- a/src/mail.c +++ b/src/mail.c @@ -87,8 +87,14 @@ void update_mail_count(struct local_mail_s *mail) DIR *dir; char *dirname; struct dirent *dirent; + char *mailflags; mail->mail_count = mail->new_mail_count = 0; + mail->seen_mail_count = mail->unseen_mail_count = 0; + mail->flagged_mail_count = mail->unflagged_mail_count = 0; + mail->forwarded_mail_count = mail->unforwarded_mail_count = 0; + mail->replied_mail_count = mail->unreplied_mail_count = 0; + mail->draft_mail_count = mail->trashed_mail_count = 0; dirname = (char *) malloc(sizeof(char) * (strlen(mail->box) + 5)); if (!dirname) { ERR("malloc"); @@ -110,6 +116,41 @@ void update_mail_count(struct local_mail_s *mail) /* . and .. are skipped */ if (dirent->d_name[0] != '.') { mail->mail_count++; + mailflags = (char *) malloc(sizeof(char) * strlen(strrchr(dirent->d_name, ','))); + if (!mailflags) { + ERR("malloc"); + free(dirname); + return; + } + strcpy(mailflags, strrchr(dirent->d_name, ',')); + if (!strchr(mailflags, 'T')) { /* The message is not in the trash */ + if (strchr(mailflags, 'S')) { /*The message has been seen */ + mail->seen_mail_count++; + } else { + mail->unseen_mail_count++; + } + if (strchr(mailflags, 'F')) { /*The message was flagged */ + mail->flagged_mail_count++; + } else { + mail->unflagged_mail_count++; + } + if (strchr(mailflags, 'P')) { /*The message was forwarded */ + mail->forwarded_mail_count++; + } else { + mail->unforwarded_mail_count++; + } + if (strchr(mailflags, 'R')) { /*The message was replied */ + mail->replied_mail_count++; + } else { + mail->unreplied_mail_count++; + } + if (strchr(mailflags, 'D')) { /*The message is a draft */ + mail->draft_mail_count++; + } + } else { + mail->trashed_mail_count++; + } + free(mailflags); } dirent = readdir(dir); } @@ -130,6 +171,7 @@ void update_mail_count(struct local_mail_s *mail) if (dirent->d_name[0] != '.') { mail->new_mail_count++; mail->mail_count++; + mail->unseen_mail_count++; /* new messages cannot have been seen */ } dirent = readdir(dir); } @@ -151,6 +193,13 @@ void update_mail_count(struct local_mail_s *mail) mail->new_mail_count = mail->mail_count = 0; + /* these flags are not supported for mbox */ + mail->seen_mail_count = mail->unseen_mail_count = -1; + mail->flagged_mail_count = mail->unflagged_mail_count = -1; + mail->forwarded_mail_count = mail->unforwarded_mail_count = -1; + mail->replied_mail_count = mail->unreplied_mail_count = -1; + mail->draft_mail_count = mail->trashed_mail_count = -1; + fp = open_file(mail->box, &rep); if (!fp) { return; diff --git a/src/mail.h b/src/mail.h index 45f58665..5aee908a 100644 --- a/src/mail.h +++ b/src/mail.h @@ -27,6 +27,16 @@ struct local_mail_s { char *box; int mail_count; int new_mail_count; + int seen_mail_count; + int unseen_mail_count; + int flagged_mail_count; + int unflagged_mail_count; + int forwarded_mail_count; + int unforwarded_mail_count; + int replied_mail_count; + int unreplied_mail_count; + int draft_mail_count; + int trashed_mail_count; float interval; time_t last_mtime; double last_update; diff --git a/src/text_object.h b/src/text_object.h index 60c5a70d..571069f7 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -170,6 +170,17 @@ enum text_object_type { OBJ_loadavg, OBJ_machine, OBJ_mails, + OBJ_new_mails, + OBJ_seen_mails, + OBJ_unseen_mails, + OBJ_flagged_mails, + OBJ_unflagged_mails, + OBJ_forwarded_mails, + OBJ_unforwarded_mails, + OBJ_replied_mails, + OBJ_unreplied_mails, + OBJ_draft_mails, + OBJ_trashed_mails, OBJ_mboxscan, OBJ_mem, OBJ_memeasyfree, @@ -191,7 +202,6 @@ enum text_object_type { OBJ_monitor_number, #endif OBJ_nameserver, - OBJ_new_mails, OBJ_nodename, OBJ_nvidia, OBJ_pre_exec,