[Pkg-wmaker-commits] [wmbiff] 82/84: Peter McAlpine's globalnotify patch

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:02:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to tag wmbiff_0_4_10
in repository wmbiff.

commit 53a4941c9d5b7f54715107567584ffd1e45db4c9
Author: bluehal <bluehal>
Date:   Mon Dec 9 21:45:28 2002 +0000

    Peter McAlpine's globalnotify patch
---
 AUTHORS                |  4 ++++
 wmbiff/sample.wmbiffrc | 14 +++++++++----
 wmbiff/wmbiff.c        | 57 +++++++++++++++++++++++++++++++++++++++-----------
 wmbiff/wmbiffrc.5.in   |  6 +++++-
 4 files changed, 64 insertions(+), 17 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 1b21957..453b628 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -14,6 +14,9 @@
    
    POP3 checking code was taken from wmpop3 by
    Scott Holden (scotth at thezone.net)
+
+   Additional code was taken from xlassie, written by
+   Trent Piepho <xyzzy at speakeasy.net>
    
    Many thanks for:
    Angus Mackay (amackay at gusnet.cx)
@@ -33,4 +36,5 @@
    Beno�t Rouits (brouits at free.fr)
    Andelko Horvat (comel at srk.fer.hr)
    Jun-ichiro itojun Hagino (itojun at iijlab.net)
+   Peter McAlpine (pmcalpin at uoguelph.ca)
 
diff --git a/wmbiff/sample.wmbiffrc b/wmbiff/sample.wmbiffrc
index cf3fbb8..070e8d2 100644
--- a/wmbiff/sample.wmbiffrc
+++ b/wmbiff/sample.wmbiffrc
@@ -1,4 +1,4 @@
-# $Id: sample.wmbiffrc,v 1.13 2002/05/03 05:42:44 bluehal Exp $
+# $Id: sample.wmbiffrc,v 1.14 2002/12/09 21:45:29 bluehal Exp $
 #
 # See wmbiffrc(5) for more info.
 #
@@ -47,9 +47,15 @@ label.0=Spool
 # port are optional, default - 110
 path.0=mbox:/var/mail/gb
 
+# Command, which will be executed for new mail in any watched mailbox
+globalnotify=my_play /home/gb/sounds/new_mail_has_arrived.wav
+
 # Command, which executed on new mail arrival, or special keyword 'beep'
 #notify.0=beep
-notify.0=my_play /home/gb/sounds/new_mail_has_arrived.wav
+#notify.0=my_play /home/gb/sounds/new_mail_has_arrived.wav
+
+# Don't want any global notification for this mailbox
+notify.0=true
 
 # Command, which executed on left mouse click on label 
 action.0=rxvt -name mutt -e mutt
@@ -71,7 +77,7 @@ action.0=rxvt -name mutt -e mutt
 label.1 = MBOX
 # MBOX format: mbox:fullpathname
 path.1=mbox:/home/gb/mail/10_ksi-linux-list
-notify.1=my_play /home/gb/sounds/new_mail_has_arrived.wav
+#notify.1=my_play /home/gb/sounds/new_mail_has_arrived.wav
 action.1=rxvt -name mutt -e mutt -f /home/gb/mail/10_ksi-linux-list
 
 # label.1 = MDIR
@@ -95,7 +101,7 @@ action.2=licq&
 label.3=POP3
 # pop3 format: pop3:user:password at server[:port] [auth]
 path.3=pop3:user:password at server apop
-notify.3=my_play /home/gb/sounds/new_mail_has_arrived.wav
+#notify.3=my_play /home/gb/sounds/new_mail_has_arrived.wav
 action.3=rxvt -name mutt -e mutt -f /home/gb/mail/30_nftp-list
 interval.3=300		# 5 minutes
 fetchinterval.3=-1
diff --git a/wmbiff/wmbiff.c b/wmbiff/wmbiff.c
index 2a6084d..40c451c 100644
--- a/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff.c
@@ -1,4 +1,4 @@
-/* $Id: wmbiff.c,v 1.35 2002/11/13 06:44:08 bluehal Exp $ */
+/* $Id: wmbiff.c,v 1.36 2002/12/09 21:45:29 bluehal Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -53,6 +53,8 @@ mbox_t mbox[MAX_NUM_MAILBOXES];
 
 /* this is the normal pixmap. */
 const char *skin_filename = "wmbiff-master-led.xpm";
+/* global notify action taken (if globalnotify option is set) */
+const char *globalnotify = NULL;
 /* path to search for pixmaps */
 /* /usr/share/wmbiff should have the default pixmap. */
 /* /usr/local/share/wmbiff if compiled locally. */
@@ -288,18 +290,40 @@ static int wmbiffrc_permissions_check(const char *wmbiffrc_fname)
 	return (1);
 }
 
+/*
+ * void execnotify(1) : runs notify command (if given)
+ */
+void execnotify(const char *notifycmd)
+{
+	if (notifycmd != 0) {		/* need to call notify() ? */
+		if (!strcasecmp(notifycmd, "beep")) {	/* Internal keyword ? */
+			/* Yes, bell */
+			XBell(display, 100);
+		} else if (!strcasecmp(notifycmd, "true")) {
+			/* Yes, nothing */
+		} else {
+			/* Else call external notifyer */
+			execCommand((char *) notifycmd);
+		}
+	}
+}
+
+
 static int periodic_mail_check(void)
 {
 	int NeedRedraw = 0;
 	static int Blink_Mode = 0;	/* Bit mask, digits are in blinking 
 								   mode or not. Each bit for separate 
 								   mailbox */
-	int Sleep_Interval;			/* is either DEFAULT_SLEEP_INTERVAL or BLINK_SLEEP_INTERVAL */
+	int Sleep_Interval;			/* either DEFAULT_SLEEP_INTERVAL or
+								   BLINK_SLEEP_INTERVAL */
+	int NewMail = 0;			/* flag for global notify */
 	int i;
 	for (i = 0; i < num_mailboxes; i++) {
 		if (mbox[i].label[0] != 0) {
 			time_t curtime = time(0);
 			if (curtime >= mbox[i].prevtime + mbox[i].loopinterval) {
+				int mailstat = 0;
 				NeedRedraw = 1;
 				DM(&mbox[i], DEBUG_INFO,
 				   "working on [%d].label=>%s< [%d].path=>%s<\n", i,
@@ -309,7 +333,12 @@ static int periodic_mail_check(void)
 				   (int) curtime, (int) mbox[i].prevtime,
 				   mbox[i].loopinterval);
 				mbox[i].prevtime = curtime;
-				displayMsgCounters(i, count_mail(i), &Sleep_Interval,
+				mailstat = count_mail(i);
+				if ((mailstat == 2) && (mbox[i].notify[0] == 0)) {
+					/* for global notify */
+					NewMail = 1;
+				}
+				displayMsgCounters(i, mailstat, &Sleep_Interval,
 								   &Blink_Mode);
 			}
 			if (mbox[i].blink_stat > 0) {
@@ -329,6 +358,12 @@ static int periodic_mail_check(void)
 		}
 	}
 
+	/* exec globalnotify if there was any new mail */
+	if (NewMail == 1) {
+		execnotify(globalnotify);
+	}
+
+
 	if (Blink_Mode == 0) {
 		for (i = 0; i < num_mailboxes; i++) {
 			mbox[i].blink_stat = 0;
@@ -533,8 +568,9 @@ static void blitMsgCounters(int i)
 	}
 }
 
-void displayMsgCounters(int i, int mail_stat, int *Sleep_Interval,
-						int *Blink_Mode)
+void
+displayMsgCounters(int i, int mail_stat, int *Sleep_Interval,
+				   int *Blink_Mode)
 {
 	switch (mail_stat) {
 	case 2:					/* New mail has arrived */
@@ -543,13 +579,7 @@ void displayMsgCounters(int i, int mail_stat, int *Sleep_Interval,
 		*Sleep_Interval = BLINK_SLEEP_INTERVAL;
 		*Blink_Mode |= (1 << i);	/* Global blink flag set for this mailbox */
 		blitMsgCounters(i);
-		if (mbox[i].notify[0] != 0) {	/* need to call notify() ? */
-			if (!strcasecmp(mbox[i].notify, "beep")) {	/* Internal keyword ? */
-				XBell(display, 100);	/* Yes, bell */
-			} else {
-				execCommand(mbox[i].notify);	/* Else call external notifyer */
-			}
-		}
+		execnotify(mbox[i].notify);
 
 		/* Autofetch on new mail arrival? */
 		if (mbox[i].fetchinterval == -1 && mbox[i].fetchcmd[0] != 0) {
@@ -833,6 +863,8 @@ int Read_Config_File(char *filename, int *loopinterval)
 			skin_filename = strdup(value);
 		} else if (!strcmp(setting, "certfile")) {	/* not yet supported */
 			certificate_filename = strdup(value);
+		} else if (!strcmp(setting, "globalnotify")) {
+			globalnotify = strdup(value);
 		} else if (mbox_index == -1)
 			continue;			/* Didn't read any setting.[0-5] value */
 
@@ -1067,6 +1099,7 @@ void printversion(void)
 	printf("wmbiff v%s\n", VERSION);
 }
 
+
 /* vim:set ts=4: */
 /*
  * Local Variables:
diff --git a/wmbiff/wmbiffrc.5.in b/wmbiff/wmbiffrc.5.in
index 83a8217..6b4f1dd 100644
--- a/wmbiff/wmbiffrc.5.in
+++ b/wmbiff/wmbiffrc.5.in
@@ -1,5 +1,5 @@
 .\" Hey, Emacs!  This is an -*- nroff -*- source file.
-.\" $Id: wmbiffrc.5.in,v 1.9 2002/11/12 08:27:47 bluehal Exp $
+.\" $Id: wmbiffrc.5.in,v 1.10 2002/12/09 21:45:29 bluehal Exp $
 .\"
 .\" @configure_input@
 .\"
@@ -43,6 +43,10 @@ path, wmbiff will search @SKINDIR@, /usr/share/wmbiff,
 /usr/local/share/wmbiff, and the current directory for the
 pixmap file.
 .TP
+\fBglobalnotify\fP
+Command to be executed when new mail is recieved in any mailbox. Set
+notify.n to override this option for mailbox n.
+.TP
 \fBlabel.n\fP
 Specifies the displayed label for a mailbox. It can be up to five characters
 long.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list