[Pkg-wmaker-commits] [wmbiff] 15/32: Draft shell command and gnomeicu support from Benoît Rouits with minor modifications 1) implement gicu using the shell module rather than as a separate module, 2) edit Ben's shell format to have extra colons for extensibility, 3) add some extra error checking in the shell method. I also added a test wmbiffrc that can be used to verify that the gicu and shell methods "work".

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


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

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

commit 51c53f117078c0eaca70c879e077fdc76f648854
Author: bluehal <bluehal>
Date:   Wed Mar 6 07:15:08 2002 +0000

    Draft shell command and gnomeicu support from Benoît Rouits
    with minor modifications 1) implement gicu using the shell
    module rather than as a separate module, 2) edit Ben's
    shell format to have extra colons for extensibility,
    3) add some extra error checking in the shell method.
    I also added a test wmbiffrc that can be used to verify
    that the gicu and shell methods "work".
---
 wmbiff/Client.h            | 13 ++++----
 wmbiff/Makefile            |  3 +-
 wmbiff/ShellClient.c       | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 wmbiff/mboxClient.c        |  4 +--
 wmbiff/sample.wmbiffrc     |  8 ++++-
 wmbiff/test-wmbiffrc.shell | 24 ++++++++++++++
 wmbiff/wmbiff.1            |  6 ++--
 wmbiff/wmbiff.c            | 13 +++++++-
 wmbiff/wmbiffrc.5          | 23 ++++++++++++--
 9 files changed, 157 insertions(+), 16 deletions(-)

diff --git a/wmbiff/Client.h b/wmbiff/Client.h
index 338bc02..15736a0 100644
--- a/wmbiff/Client.h
+++ b/wmbiff/Client.h
@@ -1,9 +1,9 @@
-/* $Id: Client.h,v 1.10 2002/03/02 22:38:03 bluehal Exp $ */
+/* $Id: Client.h,v 1.11 2002/03/06 07:15:08 bluehal Exp $ */
 /* Author : Scott Holden ( scotth at thezone.net )
    Modified : Yong-iL Joh ( tolkien at mizi.com )
    Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
  *
- * Email Checker Pop3/Imap4/Licq/mbox/maildir
+ * Email Checker Pop3/Imap4/Licq/Gicu/mbox/maildir
  *
  * Last Updated : Mar 20, 05:32:35 CET 2001     
  *
@@ -83,6 +83,7 @@ int sock_connect(const char *hostname, int port);
 int pop3Create(Pop3 pc, const char *str);
 int imap4Create(Pop3 pc, const char *str);
 int licqCreate(Pop3 pc, char *str);
+int shellCreate(Pop3 pc, const char *str);
 int mboxCreate(Pop3 pc, char *str);
 int maildirCreate(Pop3 pc, char *str);
 FILE *openMailbox(Pop3 pc);
@@ -117,8 +118,8 @@ do { \
 /* technique used in apache to allow GCC's attribute tags,
    without requiring gcc as the compiler */
 #if !defined(__GNUC__) || __GNUC__ < 2 || \
-  (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 
-#define __attribute__(__x)             
-#endif /* gnuc */
-#endif /* client.h */
+  (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#define __attribute__(__x)
+#endif							/* gnuc */
+#endif							/* client.h */
 /* vim:set ts=4: */
diff --git a/wmbiff/Makefile b/wmbiff/Makefile
index 072d300..23f7b61 100644
--- a/wmbiff/Makefile
+++ b/wmbiff/Makefile
@@ -1,6 +1,6 @@
 # Makefile for wmbiff
 #
-# $Id: Makefile,v 1.26 2002/03/02 23:25:08 bluehal Exp $
+# $Id: Makefile,v 1.27 2002/03/06 07:15:08 bluehal Exp $
 
 # Disable gnutls crypto?
 #WITHOUT_CRYPTO=	1
@@ -74,6 +74,7 @@ INSTALL_FILE?=	$(INSTALL) -p -o $(INSTALL_USER) -g $(INSTALL_GROUP) -m 644
 OBJS =	wmbiff.o socket.o \
 	Pop3Client.o LicqClient.o mboxClient.o \
 	maildirClient.o Imap4Client.o tlsComm.o \
+	ShellClient.o \
 	../wmgeneral/wmgeneral.o \
 	../wmgeneral/misc.o \
 	../wmgeneral/list.o \
diff --git a/wmbiff/ShellClient.c b/wmbiff/ShellClient.c
new file mode 100644
index 0000000..762d4e0
--- /dev/null
+++ b/wmbiff/ShellClient.c
@@ -0,0 +1,79 @@
+/* Author : Yong-iL Joh ( tolkien at mizi.com )
+   Modified: Jorge Garc�a ( Jorge.Garcia at uv.es )
+   shellcmd support : Beno�t Rouits ( brouits at free.fr ) thanks to Neil Spring.
+ * 
+ * generic Shell command support
+ *
+ * Last Updated : Tue Mar  5 15:23:35 CET 2002
+ *
+ */
+
+#include "Client.h"
+#include <errno.h>
+#ifdef USE_DMALLOC
+#include <dmalloc.h>
+#include <string.h>
+#endif
+
+int shellCmdCheck(Pop3 pc)
+{
+	FILE *F;
+	int count_status = 0;
+
+	DM(pc, DEBUG_INFO, ">Mailbox: '%s'\n", pc->path);
+
+	if ((F = popen(pc->path, "r")) == NULL) {
+		DM(pc, DEBUG_ERROR, "popen: error while reading '%s': %s\n",
+		   pc->path, strerror(errno));
+		pc->TotalMsgs = pc->UnreadMsgs = -1;
+		return 1;
+	}
+
+	if (fscanf(F, "%d\n", &(count_status)) != 1) {
+		DM(pc, DEBUG_ERROR,
+		   "'%s' returned something other than an integer message count.\n",
+		   pc->path);
+		pc->TotalMsgs = pc->UnreadMsgs = -1;
+		return 1;
+	}
+
+	pc->TotalMsgs = pc->UnreadMsgs + count_status;
+	pc->UnreadMsgs = count_status;
+	DM(pc, DEBUG_INFO, "from: %d status: %d\n", pc->TotalMsgs,
+	   pc->UnreadMsgs);
+
+	pclose(F);
+	return 0;
+}
+
+int shellCreate(Pop3 pc, const char *str)
+{
+	/* SHELL format: shell:::/path/to/script */
+	const char *reserved1, *reserved2, *commandline;
+
+	pc->TotalMsgs = 0;
+	pc->UnreadMsgs = 0;
+	pc->OldMsgs = -1;
+	pc->OldUnreadMsgs = -1;
+	pc->open = openMailbox;
+	pc->checkMail = shellCmdCheck;
+	reserved1 = str + 6;		/* shell:>:: */
+	reserved2 = index(reserved1, ':') + 1;	/* shell::>: */
+	if (reserved2 == NULL) {
+		DM(pc, DEBUG_ERROR,
+		   "shell method, unable to parse '%s', expecting ':'", str);
+		return 0;
+	}
+	commandline = index(reserved2, ':') + 1;	/* shell:::> */
+	if (commandline == NULL) {
+		DM(pc, DEBUG_ERROR,
+		   "shell method, unable to parse '%s', expecting another ':'",
+		   str);
+		return 0;
+	}
+	strcpy(pc->path, commandline);
+	DM(pc, DEBUG_INFO, "shell: path= '%s'\n", commandline);
+	return 0;
+}
+
+/* vim:set ts=4: */
diff --git a/wmbiff/mboxClient.c b/wmbiff/mboxClient.c
index 10cbc6a..2fbee5a 100644
--- a/wmbiff/mboxClient.c
+++ b/wmbiff/mboxClient.c
@@ -1,4 +1,4 @@
-/* $Id: mboxClient.c,v 1.5 2002/03/04 06:57:17 bluehal Exp $ */
+/* $Id: mboxClient.c,v 1.6 2002/03/06 07:15:08 bluehal Exp $ */
 /* Author:		Yong-iL Joh <tolkien at mizi.com>
    Modified:	Jorge Garc�a <Jorge.Garcia at uv.es>
    			 	Rob Funk <rfunk at funknet.net>
@@ -50,7 +50,7 @@ int mboxCheckHistory(Pop3 pc)
 	/* mbox file */
 	if (stat(pc->path, &st)) {
 		DM(pc, DEBUG_ERROR, "Can't stat mailbox '%s': %s\n",
-				pc->path, strerror(errno));
+		   pc->path, strerror(errno));
 		return -1;				/* Error stating mailbox */
 	}
 
diff --git a/wmbiff/sample.wmbiffrc b/wmbiff/sample.wmbiffrc
index 4bafad9..660456b 100644
--- a/wmbiff/sample.wmbiffrc
+++ b/wmbiff/sample.wmbiffrc
@@ -1,4 +1,4 @@
-# $Id: sample.wmbiffrc,v 1.7 2001/11/23 15:53:17 jordi Exp $
+# $Id: sample.wmbiffrc,v 1.8 2002/03/06 07:15:08 bluehal Exp $
 #
 # See wmbiffrc(5) for more info.
 #
@@ -54,6 +54,12 @@ path.2=licq:/home/person/.licq/history/1111111.history
 notify.2=beep
 action.2=licq&
 
+#or if you use gnomeicu:
+#label.2=ICQ
+#path.2=gicu:USER_UIN
+#notify.2=beep
+#action.2=gnomeicu-client show
+
 label.3=POP3
 # pop3 format: pop3:user:password at server[:port] [auth]
 path.3=pop3:user:password at server apop
diff --git a/wmbiff/test-wmbiffrc.shell b/wmbiff/test-wmbiffrc.shell
new file mode 100644
index 0000000..a84c552
--- /dev/null
+++ b/wmbiff/test-wmbiffrc.shell
@@ -0,0 +1,24 @@
+# $Id: test-wmbiffrc.shell,v 1.1 2002/03/06 07:15:08 bluehal Exp $
+#
+# test wmbiffrc for the shell command and gicu method.
+# see sample.wmbiffrc and wmbiffrc.5 as documentation for the format.
+#
+interval=10
+
+label.0=one
+path.0=shell:::echo 1
+
+label.1=two
+path.1=shell:::echo 2
+
+label.2=uptm
+path.2=shell:::uptime | awk '{print $3}'
+
+label.3=mem
+path.3=shell:::grep Mem: < /proc/meminfo | awk '{ print $3 " * 100 / " $2}' | bc
+
+label.3=gicu
+path.3=gicu:38673016
+
+label.4=nouin
+path.4=gicu:
diff --git a/wmbiff/wmbiff.1 b/wmbiff/wmbiff.1
index a7fbce7..258f362 100644
--- a/wmbiff/wmbiff.1
+++ b/wmbiff/wmbiff.1
@@ -1,5 +1,5 @@
 .\" Hey, Emacs!  This is an -*- nroff -*- source file.
-.\" $Id: wmbiff.1,v 1.6 2002/03/01 08:41:29 bluehal Exp $
+.\" $Id: wmbiff.1,v 1.7 2002/03/06 07:15:08 bluehal Exp $
 .\"
 .\" wmbiff.1 and wmbiffrc.5 are copyright 1999-2001 by
 .\" Jordi Mallach <jordi at debian.org>
@@ -21,8 +21,8 @@ WMbiff displays the status of up to five mailboxes. It gives information
 about new mail, if any, or total number of messages. It also has mail
 retrieval capabilies, and can be configured to do this automatically. At the
 moment, UNIX-style, maildir, POP3, APOP and IMAP4 mailboxes are supported.
-WMbiff also supports Licq history files, displaying the number of new
-messages in your running Licq session, as if they were mail.
+WMbiff also supports Licq history files and gnomeicu, displaying the number of new
+messages in your running session, as if they were mail.  
 
 The mailboxes are displayed in 5 different lines, each one with its own
 description of up to five chars. If no mail is present in a given mailbox,
diff --git a/wmbiff/wmbiff.c b/wmbiff/wmbiff.c
index f3aee13..9e2b56f 100644
--- a/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff.c
@@ -1,4 +1,4 @@
-/* $Id: wmbiff.c,v 1.15 2002/03/02 23:25:08 bluehal Exp $ */
+/* $Id: wmbiff.c,v 1.16 2002/03/06 07:15:08 bluehal Exp $ */
 
 #define	USE_POLL
 
@@ -480,6 +480,17 @@ void parse_mbox_path(int item)
 {
 	if (!strncasecmp(mbox[item].path, "pop3:", 5)) {	/* pop3 account */
 		pop3Create((&mbox[item]), mbox[item].path);
+	} else if (!strncasecmp(mbox[item].path, "shell:", 6)) {	/* generic cmd */
+		shellCreate((&mbox[item]), mbox[item].path);
+	} else if (!strncasecmp(mbox[item].path, "gicu:", 5)) {	/* gnomeicu check */
+		char buf[255];
+		if (isdigit(mbox[item].path[5])) {
+			sprintf(buf, "shell:::gnomeicu-client -u%s msgcount",
+					mbox[item].path + 5);
+		} else {
+			sprintf(buf, "shell:::gnomeicu-client msgcount");
+		}
+		shellCreate((&mbox[item]), buf);
 	} else if (!strncasecmp(mbox[item].path, "licq:", 5)) {	/* licq history file */
 		licqCreate((&mbox[item]), mbox[item].path);
 	} else if (!strncasecmp(mbox[item].path, "imap:", 5) ||	/* imap4 account */
diff --git a/wmbiff/wmbiffrc.5 b/wmbiff/wmbiffrc.5
index b46927c..a823074 100644
--- a/wmbiff/wmbiffrc.5
+++ b/wmbiff/wmbiffrc.5
@@ -1,5 +1,5 @@
 .\" Hey, Emacs!  This is an -*- nroff -*- source file.
-.\" $Id: wmbiffrc.5,v 1.9 2002/03/01 08:41:29 bluehal Exp $
+.\" $Id: wmbiffrc.5,v 1.10 2002/03/06 07:15:08 bluehal Exp $
 .\"
 .\" wmbiff.1 and wmbiffrc.5 are copyright 1999-2002 by 
 .\" Jordi Mallach <jordi at debian.org>
@@ -105,6 +105,25 @@ number of messages in it. It just needs a path to a given licq history file.
 .RS
 licq:/path/to/.licq/history/file.history
 .RE
+.TP
+.I gicu
+With this box type, wmbiff will ask gnomeicu for the number
+of pending messages.  If gnomeicu is not running, nothing
+will be displayed.  gnomeicu-client must be in your path.
+The user's icq UIN is optional.
+.RS
+gicu:[UIN]
+.RE
+.TP
+.I shell
+With this EXPERIMENTAL keyword, wmbiff will launch the
+specified shell command and read its output (STDOUT)
+expecting an integer number to be displayed as a count
+of new messages.   The behavior of this experimental
+keyword is likely to change in future revisions.
+.RS
+shell:::/path/to/command
+.RE
 .RE
 .TP
 \fBnotify.n\fP
@@ -164,7 +183,7 @@ wmbiff(1) for details.
 .SH FILES
 .TP
 .I ~/.wmbiffrc
-peruser wmbiff configuration file.
+per-user wmbiff configuration file.
 
 .SH AUTHOR
 This manual page was written by Jordi Mallach <jordi at debian.org>,

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