Mercurial > pidgin.yaz
annotate plugins/mailchk.c @ 5205:fefad67de2c7
[gaim-migrate @ 5573]
I had a damn good commit message, but it was eaten. Let's try it again.
Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short.
There are lots'a cool thingies here.
Okay now, this isn't as cool as the previous message, but:
1) There's now a single entry function for all plugin types. It returns a
detailed information structure on the plugin. This removes a lot of the
ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so
if you use it, well, you shouldn't have used it anyway, but now you
can't! bwahahaha. Use AIM/ICQ.
2) There are now 3 types of plugins: Standard, Loader, and Protocol
plugins.
Standard plugins are, well, standard, compiled plugins.
Loader plugins load other plugins. For example, the perl support is now
a loader plugin. It loads perl scripts. In the future, we'll have
Ruby and Python loader plugins.
Protocol plugins are, well, protocol plugins... yeah...
3) Plugins have unique IDs, so they can be referred to or automatically
updated from a plugin database in the future. Neat, huh?
4) Plugins will have dependency support in the future, and can be hidden,
so if you have, say, a logging core plugin, it won't have to show up,
but then you load the GTK+ logging plugin and it'll auto-load the core
plugin. Core/UI split plugins!
5) There will eventually be custom plugin signals and RPC of some sort, for
the core/ui split plugins.
So, okay, back up .gaimrc.
I'd like to thank my parents for their support, javabsp for helping convert
a bunch of protocol plugins, and Etan for helping convert a bunch of
standard plugins.
Have fun. If you have any problems, please let me know, but you probably
won't have anything major happen. You will have to convert your plugins,
though, and I'm not guaranteeing that all perl scripts will still work.
I'll end up changing the perl script API eventually, so I know they won't
down the road. Don't worry, though. It'll be mass cool.
faceprint wants me to just commit the damn code already. So, here we go!!!
..
..
I need a massage. From a young, cute girl. Are there any young, cute girls
in the audience? IM me plz k thx.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 25 Apr 2003 06:47:33 +0000 |
parents | fac4c73dd5ad |
children | c0baa01cdeda |
rev | line source |
---|---|
1803 | 1 #include "gaim.h" |
4576 | 2 #include "sound.h" |
1803 | 3 #include <sys/stat.h> |
4 #include <sys/types.h> | |
5 #include <unistd.h> | |
6 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4655
diff
changeset
|
7 #define MAILCHK_PLUGIN_ID "core-mailchk" |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4655
diff
changeset
|
8 |
1803 | 9 #define ANY_MAIL 0x01 |
10 #define UNREAD_MAIL 0x02 | |
11 #define NEW_MAIL 0x04 | |
12 | |
13 static guint32 timer = 0; | |
14 static GtkWidget *mail = NULL; | |
15 | |
16 static gint check_mail() | |
17 { | |
18 static off_t oldsize = 0; | |
19 gchar *filename; | |
20 off_t newsize; | |
21 struct stat s; | |
22 gint ret = 0; | |
23 | |
4655 | 24 filename = g_strdup(g_getenv("MAIL")); |
1803 | 25 if (!filename) |
26 filename = g_strconcat("/var/spool/mail/", g_get_user_name(), NULL); | |
27 | |
28 if (stat(filename, &s) < 0) { | |
29 g_free(filename); | |
30 return -1; | |
31 } | |
32 | |
33 newsize = s.st_size; | |
34 if (newsize) ret |= ANY_MAIL; | |
35 if (s.st_mtime > s.st_atime && newsize) ret |= UNREAD_MAIL; | |
36 if (newsize != oldsize && (ret & UNREAD_MAIL)) ret |= NEW_MAIL; | |
37 oldsize = newsize; | |
38 | |
39 g_free(filename); | |
40 | |
41 return ret; | |
42 } | |
43 | |
44 static void maildes() | |
45 { | |
46 mail = NULL; | |
47 } | |
48 | |
49 static gboolean check_timeout(gpointer data) | |
50 { | |
51 gint count = check_mail(); | |
52 | |
53 if (count == -1) | |
54 return FALSE; | |
55 | |
56 if (!blist) | |
57 return TRUE; | |
58 | |
59 if (!mail) { | |
60 /* guess we better build it then :P */ | |
4655 | 61 GList *tmp = gtk_container_get_children(GTK_CONTAINER(blist)); |
1803 | 62 GtkWidget *vbox2 = (GtkWidget *)tmp->data; |
63 | |
64 mail = gtk_label_new("No mail messages."); | |
65 gtk_box_pack_start(GTK_BOX(vbox2), mail, FALSE, FALSE, 0); | |
66 gtk_box_reorder_child(GTK_BOX(vbox2), mail, 1); | |
4165
07a3d1fae88f
[gaim-migrate @ 4394]
Christian Hammond <chipx86@chipx86.com>
parents:
3551
diff
changeset
|
67 g_signal_connect(GTK_OBJECT(mail), "destroy", G_CALLBACK(maildes), NULL); |
1803 | 68 gtk_widget_show(mail); |
69 } | |
70 | |
71 if (count & NEW_MAIL) | |
4576 | 72 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); |
1803 | 73 |
74 if (count & UNREAD_MAIL) | |
75 gtk_label_set_text(GTK_LABEL(mail), "You have new mail!"); | |
76 else if (count & ANY_MAIL) | |
77 gtk_label_set_text(GTK_LABEL(mail), "You have mail."); | |
78 else | |
79 gtk_label_set_text(GTK_LABEL(mail), "No mail messages."); | |
80 | |
81 return TRUE; | |
82 } | |
83 | |
84 static void mail_signon(struct gaim_connection *gc) | |
85 { | |
86 if (blist && !timer) | |
4168 | 87 timer = g_timeout_add(2000, check_timeout, NULL); |
1803 | 88 } |
89 | |
90 static void mail_signoff(struct gaim_connection *gc) | |
91 { | |
2259
866bf3ced1bc
[gaim-migrate @ 2269]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1804
diff
changeset
|
92 if (!blist && timer) { |
4168 | 93 g_source_remove(timer); |
2259
866bf3ced1bc
[gaim-migrate @ 2269]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1804
diff
changeset
|
94 timer = 0; |
866bf3ced1bc
[gaim-migrate @ 2269]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1804
diff
changeset
|
95 } |
1803 | 96 } |
97 | |
98 char *gaim_plugin_init(GModule *m) | |
99 { | |
100 if (!check_timeout(NULL)) | |
101 return "Could not read $MAIL or /var/spool/mail/$USER"; | |
102 if (blist) | |
4168 | 103 timer = g_timeout_add(2000, check_timeout, NULL); |
1803 | 104 gaim_signal_connect(m, event_signon, mail_signon, NULL); |
105 gaim_signal_connect(m, event_signoff, mail_signoff, NULL); | |
106 return NULL; | |
107 } | |
108 | |
109 void gaim_plugin_remove() | |
110 { | |
111 if (timer) | |
4168 | 112 g_source_remove(timer); |
1803 | 113 timer = 0; |
114 if (mail) | |
115 gtk_widget_destroy(mail); | |
116 mail = NULL; | |
117 } | |
118 | |
3551 | 119 struct gaim_plugin_description desc; |
120 struct gaim_plugin_description *gaim_plugin_desc() { | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4655
diff
changeset
|
121 desc.api_version = GAIM_PLUGIN_API_VERSION; |
3551 | 122 desc.name = g_strdup("Mail Checker"); |
123 desc.version = g_strdup(VERSION); | |
124 desc.description = g_strdup("Checks for new local mail."); | |
125 desc.authors = g_strdup("Eric Warmehoven <eric@warmenhoven.org>"); | |
126 desc.url = g_strdup(WEBSITE); | |
127 return &desc; | |
128 } | |
129 | |
1803 | 130 char *name() |
131 { | |
132 return "Mail Check"; | |
133 } | |
134 | |
135 char *description() | |
136 { | |
137 return "Checks for new local mail"; | |
138 } |