Mercurial > pidgin.yaz
comparison plugins/mailchk.c @ 5255:c0baa01cdeda
[gaim-migrate @ 5627]
Paul A (darkrain) writes:
" This patch updates the events.c, filectl.c, gaiminc.c,
and mailchk.c plugins to the new api as well as
updating mailchk.c to the new buddy list code.
events.so, gaiminc.so, and mailchk.so all load and
function properly on my computer.
filectl doesn't even compile, but then, it has been a
while since it did actually compile. I didn't even bother
to update a few of the other plugins, since they're
completely out of date. Perhaps one of the developers
needs to go through and prune out a bunch of the
plugins that are not kept up to date.
Out of date plugins:
chatlist.c - superceded by faceprint's recent commit to
cvs.
filectl.c - doesn't support multiple accounts for IMs and
away messages.
raw.c - does anyone use this? it doesn't compile, but it
looks like an easy fix. "
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 28 Apr 2003 18:45:38 +0000 |
parents | fefad67de2c7 |
children | 1f901484599d |
comparison
equal
deleted
inserted
replaced
5254:d1e1ca490894 | 5255:c0baa01cdeda |
---|---|
1 #include "gaim.h" | 1 #include "gaim.h" |
2 #include "gtkplugin.h" | |
3 #include "blist.h" | |
4 #include "gtkblist.h" | |
2 #include "sound.h" | 5 #include "sound.h" |
3 #include <sys/stat.h> | 6 #include <sys/stat.h> |
4 #include <sys/types.h> | 7 #include <sys/types.h> |
5 #include <unistd.h> | 8 #include <unistd.h> |
6 | 9 |
7 #define MAILCHK_PLUGIN_ID "core-mailchk" | 10 #define MAILCHK_PLUGIN_ID "gtk-mailchk" |
8 | 11 |
9 #define ANY_MAIL 0x01 | 12 #define ANY_MAIL 0x01 |
10 #define UNREAD_MAIL 0x02 | 13 #define UNREAD_MAIL 0x02 |
11 #define NEW_MAIL 0x04 | 14 #define NEW_MAIL 0x04 |
12 | 15 |
39 g_free(filename); | 42 g_free(filename); |
40 | 43 |
41 return ret; | 44 return ret; |
42 } | 45 } |
43 | 46 |
44 static void maildes() | 47 static void destroy_cb() |
45 { | 48 { |
46 mail = NULL; | 49 mail = NULL; |
47 } | 50 } |
48 | 51 |
49 static gboolean check_timeout(gpointer data) | 52 static gboolean check_timeout(gpointer data) |
50 { | 53 { |
51 gint count = check_mail(); | 54 gint count = check_mail(); |
52 | 55 struct gaim_buddy_list *list = gaim_get_blist(); |
53 if (count == -1) | 56 if (count == -1) |
54 return FALSE; | 57 return FALSE; |
55 | 58 |
56 if (!blist) | 59 if (!list || !GAIM_GTK_BLIST(list)) |
57 return TRUE; | 60 return TRUE; |
58 | 61 |
59 if (!mail) { | 62 if (!mail) { |
60 /* guess we better build it then :P */ | 63 /* guess we better build it then :P */ |
61 GList *tmp = gtk_container_get_children(GTK_CONTAINER(blist)); | 64 //GList *tmp = gtk_container_get_children(GTK_CONTAINER(GAIM_GTK_BLIST(list))); |
62 GtkWidget *vbox2 = (GtkWidget *)tmp->data; | 65 //GtkWidget *vbox2 = (GtkWidget *)tmp->data; |
66 GtkWidget *vbox = (GtkWidget *)(GAIM_GTK_BLIST(list)->vbox); | |
63 | 67 |
64 mail = gtk_label_new("No mail messages."); | 68 mail = gtk_label_new("No mail messages."); |
65 gtk_box_pack_start(GTK_BOX(vbox2), mail, FALSE, FALSE, 0); | 69 gtk_box_pack_start(GTK_BOX(vbox), mail, FALSE, FALSE, 0); |
66 gtk_box_reorder_child(GTK_BOX(vbox2), mail, 1); | 70 gtk_box_reorder_child(GTK_BOX(vbox), mail, 1); |
67 g_signal_connect(GTK_OBJECT(mail), "destroy", G_CALLBACK(maildes), NULL); | 71 g_signal_connect(GTK_OBJECT(mail), "destroy", G_CALLBACK(destroy_cb), NULL); |
68 gtk_widget_show(mail); | 72 gtk_widget_show(mail); |
69 } | 73 } |
70 | 74 |
71 if (count & NEW_MAIL) | 75 if (count & NEW_MAIL) |
72 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); | 76 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); |
79 gtk_label_set_text(GTK_LABEL(mail), "No mail messages."); | 83 gtk_label_set_text(GTK_LABEL(mail), "No mail messages."); |
80 | 84 |
81 return TRUE; | 85 return TRUE; |
82 } | 86 } |
83 | 87 |
84 static void mail_signon(struct gaim_connection *gc) | 88 static void signon_cb(struct gaim_connection *gc) |
85 { | 89 { |
86 if (blist && !timer) | 90 struct gaim_buddy_list *list = gaim_get_blist(); |
91 if (list && GAIM_GTK_BLIST(list) && !timer) | |
87 timer = g_timeout_add(2000, check_timeout, NULL); | 92 timer = g_timeout_add(2000, check_timeout, NULL); |
88 } | 93 } |
89 | 94 |
90 static void mail_signoff(struct gaim_connection *gc) | 95 static void signoff_cb(struct gaim_connection *gc) |
91 { | 96 { |
92 if (!blist && timer) { | 97 struct gaim_buddy_list *list = gaim_get_blist(); |
98 if ((!list || !GAIM_GTK_BLIST(list)) && timer) { | |
93 g_source_remove(timer); | 99 g_source_remove(timer); |
94 timer = 0; | 100 timer = 0; |
95 } | 101 } |
96 } | 102 } |
97 | 103 |
98 char *gaim_plugin_init(GModule *m) | 104 /* |
105 * EXPORTED FUNCTIONS | |
106 */ | |
107 | |
108 static gboolean | |
109 plugin_load(GaimPlugin *plugin) | |
99 { | 110 { |
100 if (!check_timeout(NULL)) | 111 struct gaim_buddy_list *list = gaim_get_blist(); |
101 return "Could not read $MAIL or /var/spool/mail/$USER"; | 112 if (!check_timeout(NULL)) { |
102 if (blist) | 113 gaim_debug(GAIM_DEBUG_WARNING, "mailchk", "Could not read $MAIL or /var/spool/mail/$USER"); |
114 return FALSE; | |
115 } | |
116 | |
117 if (list && GAIM_GTK_BLIST(list)) | |
103 timer = g_timeout_add(2000, check_timeout, NULL); | 118 timer = g_timeout_add(2000, check_timeout, NULL); |
104 gaim_signal_connect(m, event_signon, mail_signon, NULL); | 119 |
105 gaim_signal_connect(m, event_signoff, mail_signoff, NULL); | 120 gaim_signal_connect(plugin, event_signon, signon_cb, NULL); |
106 return NULL; | 121 gaim_signal_connect(plugin, event_signoff, signoff_cb, NULL); |
122 | |
123 return TRUE; | |
107 } | 124 } |
108 | 125 |
109 void gaim_plugin_remove() | 126 static gboolean |
127 plugin_unload(GaimPlugin *plugin) | |
110 { | 128 { |
111 if (timer) | 129 if (timer) |
112 g_source_remove(timer); | 130 g_source_remove(timer); |
113 timer = 0; | 131 timer = 0; |
114 if (mail) | 132 if (mail) |
115 gtk_widget_destroy(mail); | 133 gtk_widget_destroy(mail); |
116 mail = NULL; | 134 mail = NULL; |
135 | |
136 return TRUE; | |
117 } | 137 } |
118 | 138 |
119 struct gaim_plugin_description desc; | 139 static GaimPluginInfo info = |
120 struct gaim_plugin_description *gaim_plugin_desc() { | 140 { |
121 desc.api_version = GAIM_PLUGIN_API_VERSION; | 141 2, /**< api_version */ |
122 desc.name = g_strdup("Mail Checker"); | 142 GAIM_PLUGIN_STANDARD, /**< type */ |
123 desc.version = g_strdup(VERSION); | 143 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
124 desc.description = g_strdup("Checks for new local mail."); | 144 0, /**< flags */ |
125 desc.authors = g_strdup("Eric Warmehoven <eric@warmenhoven.org>"); | 145 NULL, /**< dependencies */ |
126 desc.url = g_strdup(WEBSITE); | 146 GAIM_PRIORITY_DEFAULT, /**< priority */ |
127 return &desc; | 147 |
148 MAILCHK_PLUGIN_ID, /**< id */ | |
149 N_("Mail Checker"), /**< name */ | |
150 VERSION, /**< version */ | |
151 /** summary */ | |
152 N_("Checks for new local mail."), | |
153 /** description */ | |
154 N_("Checks for new local mail."), | |
155 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */ | |
156 WEBSITE, /**< homepage */ | |
157 | |
158 plugin_load, /**< load */ | |
159 plugin_unload, /**< unload */ | |
160 NULL, /**< destroy */ | |
161 | |
162 NULL, /**< ui_info */ | |
163 NULL /**< extra_info */ | |
164 }; | |
165 | |
166 static void | |
167 __init_plugin(GaimPlugin *plugin) | |
168 { | |
128 } | 169 } |
129 | 170 |
130 char *name() | 171 GAIM_INIT_PLUGIN(mailchk, __init_plugin, info); |
131 { | |
132 return "Mail Check"; | |
133 } | |
134 | |
135 char *description() | |
136 { | |
137 return "Checks for new local mail"; | |
138 } |