Mercurial > pidgin
view plugins/mailchk.c @ 2406:184a7b05fd02
[gaim-migrate @ 2419]
(09:34:45) ***warmenhoven returns
(09:35:09) black_bmc: warmenhoven at least!
(09:35:27) black_bmc: warmenhoven i need something from you -)
(09:35:44) warmenhoven: ok
(09:35:44) black_bmc: look in ru.po in gaim/po/ directory
(09:35:50) ***murley snickers, thinks warmenhoven should rewrtie gaim in java, heh
(09:35:56) warmenhoven: oh yeah.
(09:36:06) warmenhoven: because you know i love java so much.
(09:36:11) warmenhoven: and then it'd be cross-platform.
(09:36:11) black_bmc: "Content-Type: text/plain; charset=ISO-8859-5\n"
(09:36:17) black_bmc: you see that ?
(09:36:20) murley: that way we could all use a slow nasty hiddious looking program
(09:36:25) warmenhoven: yep
(09:36:39) warmenhoven: i take it that's not correct
(09:36:40) black_bmc: warmenhoven here must be "Content-Type: text/plain; charset=KOI8-R\n"
(09:37:02) warmenhoven: okie dokie
(09:37:05) warmenhoven: that the only change?
(09:37:07) murley: I'm a sysadmin, and I just found out a user installed a java tomcat webserver on my server, it was eating 400MB or ram
(09:37:09) black_bmc: yes
(09:37:26) black_bmc: warmenhoven why somebody change it to ISO ?
(09:37:38) warmenhoven: i don't know
(09:37:49) murley: Then i began to wonder why 2000 websites went to a scretching halt. :)
(09:37:56) black_bmc: warmenhoven heh. -)
(09:38:08) murley: kill -9 is my friend, the world is good now :)
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 01 Oct 2001 16:39:10 +0000 |
parents | 866bf3ced1bc |
children | 61b139b6d6d3 |
line wrap: on
line source
#define GAIM_PLUGINS #include "gaim.h" #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #define ANY_MAIL 0x01 #define UNREAD_MAIL 0x02 #define NEW_MAIL 0x04 static guint32 timer = 0; static GtkWidget *mail = NULL; static gint check_mail() { static off_t oldsize = 0; gchar *filename; off_t newsize; struct stat s; gint ret = 0; filename = g_getenv("MAIL"); if (!filename) filename = g_strconcat("/var/spool/mail/", g_get_user_name(), NULL); else filename = g_strdup(filename); if (stat(filename, &s) < 0) { g_free(filename); return -1; } newsize = s.st_size; if (newsize) ret |= ANY_MAIL; if (s.st_mtime > s.st_atime && newsize) ret |= UNREAD_MAIL; if (newsize != oldsize && (ret & UNREAD_MAIL)) ret |= NEW_MAIL; oldsize = newsize; g_free(filename); return ret; } static void maildes() { mail = NULL; } static gboolean check_timeout(gpointer data) { gint count = check_mail(); char buf[256]; if (count == -1) return FALSE; if (!blist) return TRUE; if (!mail) { /* guess we better build it then :P */ GList *tmp = gtk_container_children(GTK_CONTAINER(blist)); GtkWidget *vbox2 = (GtkWidget *)tmp->data; mail = gtk_label_new("No mail messages."); gtk_box_pack_start(GTK_BOX(vbox2), mail, FALSE, FALSE, 0); gtk_box_reorder_child(GTK_BOX(vbox2), mail, 1); gtk_signal_connect(GTK_OBJECT(mail), "destroy", GTK_SIGNAL_FUNC(maildes), NULL); gtk_widget_show(mail); } if (count & NEW_MAIL) play_sound(POUNCE_DEFAULT); if (count & UNREAD_MAIL) gtk_label_set_text(GTK_LABEL(mail), "You have new mail!"); else if (count & ANY_MAIL) gtk_label_set_text(GTK_LABEL(mail), "You have mail."); else gtk_label_set_text(GTK_LABEL(mail), "No mail messages."); return TRUE; } static void mail_signon(struct gaim_connection *gc) { if (blist && !timer) timer = gtk_timeout_add(2000, check_timeout, NULL); } static void mail_signoff(struct gaim_connection *gc) { if (!blist && timer) { gtk_timeout_remove(timer); timer = 0; } } char *gaim_plugin_init(GModule *m) { if (!check_timeout(NULL)) return "Could not read $MAIL or /var/spool/mail/$USER"; if (blist) timer = gtk_timeout_add(2000, check_timeout, NULL); gaim_signal_connect(m, event_signon, mail_signon, NULL); gaim_signal_connect(m, event_signoff, mail_signoff, NULL); return NULL; } void gaim_plugin_remove() { if (timer) gtk_timeout_remove(timer); timer = 0; if (mail) gtk_widget_destroy(mail); mail = NULL; } char *name() { return "Mail Check"; } char *description() { return "Checks for new local mail"; }