summary refs log tree commit diff stats
path: root/src/pixmaps/Makefile.am
blob: 57ab72b5b1ce88c31b71832cecab2a95b3321c72 (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
## Process this file with automake to produce Makefile.in

LIST =		png_ulist_voice $(srcdir)/ulist_voice.png \
			png_ulist_halfop $(srcdir)/ulist_halfop.png \
			png_ulist_op $(srcdir)/ulist_op.png \
			png_ulist_owner $(srcdir)/ulist_owner.png \
			png_ulist_founder $(srcdir)/ulist_founder.png \
			png_ulist_netop $(srcdir)/ulist_netop.png \
			png_tray_fileoffer $(srcdir)/tray_fileoffer.png \
			png_tray_highlight $(srcdir)/tray_highlight.png \
			png_tray_message $(srcdir)/tray_message.png \
			png_tree_channel $(srcdir)/tree_channel.png \
			png_tree_dialog $(srcdir)/tree_dialog.png \
			png_tree_server $(srcdir)/tree_server.png \
			png_tree_util $(srcdir)/tree_util.png \
			png_book $(srcdir)/book.png \
			png_hexchat $(srcdir)/hexchat.png

PNGS = ulist_voice.png ulist_halfop.png ulist_op.png ulist_owner.png ulist_founder.png ulist_netop.png tray_fileoffer.png tray_highlight.png tray_message.png tree_channel.png tree_dialog.png tree_server.png tree_util.png book.png
noinst_HEADERS = inline_pngs.h
CLEANFILES = $(noinst_HEADERS)
EXTRA_DIST = $(PNGS)

inline_pngs.h: $(PNGS)
	@gdkpixbufcsourcepath@ --raw --build-list $(LIST) > $(srcdir)/inline_pngs.h



















































                                                                                  
                                  













                                                                              
                                                      








                                                                                              
                                                     


                 
/* HexChat 2.0 plugin: Mail checker */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "hexchat-plugin.h"


static hexchat_plugin *ph;	/* plugin handle */

static int
mail_items(char *file)
{
	FILE *fp;
	int items;
	char buf[512];

	fp = fopen(file, "r");
	if(!fp)
		return 1;

	items = 0;
	while(fgets(buf, sizeof buf, fp))
	{
		if(!strncmp(buf, "From ", 5))
			items++;
	}
	fclose(fp);

	return items;
}

static void
xchat_mail_check (void)
{
	static int last_size = -1;
	int size;
	struct stat st;
	char buf[512];
	char *maildir;

	maildir = getenv("MAIL");
	if(!maildir)
	{
		snprintf (buf, sizeof(buf), "/var/spool/mail/%s", getenv("USER"));
		maildir = buf;
	}

	if(stat(maildir, &st) < 0)
		return;

	size = st.st_size;

	if(last_size == -1)
	{
		last_size = size;
		return;
	}

	if(size > last_size)
	{
		hexchat_printf(ph,
	"-\0033-\0039-\017\tYou have new mail (%d messages, %d bytes total).",
				mail_items(maildir), size);
	}

	last_size = size;
}

static int timeout_cb(void *userdata)
{
	xchat_mail_check();

	return 1;
}

int hexchat_plugin_init(hexchat_plugin *plugin_handle,
				char **plugin_name, char **plugin_desc, char **plugin_version,
				char *arg)
{
	ph = plugin_handle;

	*plugin_name = "MailCheck";
	*plugin_desc = "Checks your mailbox every 30 seconds";
	*plugin_version = "0.1";

	hexchat_hook_timer(ph, 30000, timeout_cb, 0);

	return 1;
}