comparison pidgin/plugins/mailchk.c @ 15823:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents d75099d2567e
children 941965d6fd88
comparison
equal deleted inserted replaced
15822:84b0f9b23ede 15823:32c366eeeb99
53 53
54 static gboolean 54 static gboolean
55 check_timeout(gpointer data) 55 check_timeout(gpointer data)
56 { 56 {
57 gint count = check_mail(); 57 gint count = check_mail();
58 GaimBuddyList *list = gaim_get_blist(); 58 PurpleBuddyList *list = purple_get_blist();
59 59
60 if (count == -1) 60 if (count == -1)
61 return FALSE; 61 return FALSE;
62 62
63 if (!list || !GAIM_IS_GTK_BLIST(list) || !(PIDGIN_BLIST(list)->vbox)) 63 if (!list || !PURPLE_IS_GTK_BLIST(list) || !(PIDGIN_BLIST(list)->vbox))
64 return TRUE; 64 return TRUE;
65 65
66 if (!mail) { 66 if (!mail) {
67 /* guess we better build it then :P */ 67 /* guess we better build it then :P */
68 GtkWidget *vbox = PIDGIN_BLIST(list)->vbox; 68 GtkWidget *vbox = PIDGIN_BLIST(list)->vbox;
73 g_signal_connect(G_OBJECT(mail), "destroy", G_CALLBACK(destroy_cb), NULL); 73 g_signal_connect(G_OBJECT(mail), "destroy", G_CALLBACK(destroy_cb), NULL);
74 gtk_widget_show(mail); 74 gtk_widget_show(mail);
75 } 75 }
76 76
77 if (count & NEW_MAIL) 77 if (count & NEW_MAIL)
78 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT, NULL); 78 purple_sound_play_event(PURPLE_SOUND_POUNCE_DEFAULT, NULL);
79 79
80 if (count & UNREAD_MAIL) 80 if (count & UNREAD_MAIL)
81 gtk_label_set_text(GTK_LABEL(mail), "You have new mail!"); 81 gtk_label_set_text(GTK_LABEL(mail), "You have new mail!");
82 else if (count & ANY_MAIL) 82 else if (count & ANY_MAIL)
83 gtk_label_set_text(GTK_LABEL(mail), "You have mail."); 83 gtk_label_set_text(GTK_LABEL(mail), "You have mail.");
86 86
87 return TRUE; 87 return TRUE;
88 } 88 }
89 89
90 static void 90 static void
91 signon_cb(GaimConnection *gc) 91 signon_cb(PurpleConnection *gc)
92 { 92 {
93 GaimBuddyList *list = gaim_get_blist(); 93 PurpleBuddyList *list = purple_get_blist();
94 if (list && GAIM_IS_GTK_BLIST(list) && !timer) { 94 if (list && PURPLE_IS_GTK_BLIST(list) && !timer) {
95 check_timeout(NULL); /* we want the box to be drawn immediately */ 95 check_timeout(NULL); /* we want the box to be drawn immediately */
96 timer = g_timeout_add(2000, check_timeout, NULL); 96 timer = g_timeout_add(2000, check_timeout, NULL);
97 } 97 }
98 } 98 }
99 99
100 static void 100 static void
101 signoff_cb(GaimConnection *gc) 101 signoff_cb(PurpleConnection *gc)
102 { 102 {
103 GaimBuddyList *list = gaim_get_blist(); 103 PurpleBuddyList *list = purple_get_blist();
104 if ((!list || !GAIM_IS_GTK_BLIST(list) || !PIDGIN_BLIST(list)->vbox) && timer) { 104 if ((!list || !PURPLE_IS_GTK_BLIST(list) || !PIDGIN_BLIST(list)->vbox) && timer) {
105 g_source_remove(timer); 105 g_source_remove(timer);
106 timer = 0; 106 timer = 0;
107 } 107 }
108 } 108 }
109 109
110 /* 110 /*
111 * EXPORTED FUNCTIONS 111 * EXPORTED FUNCTIONS
112 */ 112 */
113 113
114 static gboolean 114 static gboolean
115 plugin_load(GaimPlugin *plugin) 115 plugin_load(PurplePlugin *plugin)
116 { 116 {
117 GaimBuddyList *list = gaim_get_blist(); 117 PurpleBuddyList *list = purple_get_blist();
118 void *conn_handle = gaim_connections_get_handle(); 118 void *conn_handle = purple_connections_get_handle();
119 119
120 if (!check_timeout(NULL)) { 120 if (!check_timeout(NULL)) {
121 gaim_debug_warning("mailchk", "Could not read $MAIL or /var/spool/mail/$USER"); 121 purple_debug_warning("mailchk", "Could not read $MAIL or /var/spool/mail/$USER");
122 return FALSE; 122 return FALSE;
123 } 123 }
124 124
125 if (list && GAIM_IS_GTK_BLIST(list) && PIDGIN_BLIST(list)->vbox) 125 if (list && PURPLE_IS_GTK_BLIST(list) && PIDGIN_BLIST(list)->vbox)
126 timer = g_timeout_add(2000, check_timeout, NULL); 126 timer = g_timeout_add(2000, check_timeout, NULL);
127 127
128 gaim_signal_connect(conn_handle, "signed-on", 128 purple_signal_connect(conn_handle, "signed-on",
129 plugin, GAIM_CALLBACK(signon_cb), NULL); 129 plugin, PURPLE_CALLBACK(signon_cb), NULL);
130 gaim_signal_connect(conn_handle, "signed-off", 130 purple_signal_connect(conn_handle, "signed-off",
131 plugin, GAIM_CALLBACK(signoff_cb), NULL); 131 plugin, PURPLE_CALLBACK(signoff_cb), NULL);
132 132
133 return TRUE; 133 return TRUE;
134 } 134 }
135 135
136 static gboolean 136 static gboolean
137 plugin_unload(GaimPlugin *plugin) 137 plugin_unload(PurplePlugin *plugin)
138 { 138 {
139 if (timer) 139 if (timer)
140 g_source_remove(timer); 140 g_source_remove(timer);
141 timer = 0; 141 timer = 0;
142 if (mail) 142 if (mail)
144 mail = NULL; 144 mail = NULL;
145 145
146 return TRUE; 146 return TRUE;
147 } 147 }
148 148
149 static GaimPluginInfo info = 149 static PurplePluginInfo info =
150 { 150 {
151 GAIM_PLUGIN_MAGIC, 151 PURPLE_PLUGIN_MAGIC,
152 GAIM_MAJOR_VERSION, 152 PURPLE_MAJOR_VERSION,
153 GAIM_MINOR_VERSION, 153 PURPLE_MINOR_VERSION,
154 GAIM_PLUGIN_STANDARD, 154 PURPLE_PLUGIN_STANDARD,
155 PIDGIN_PLUGIN_TYPE, 155 PIDGIN_PLUGIN_TYPE,
156 0, 156 0,
157 NULL, 157 NULL,
158 GAIM_PRIORITY_DEFAULT, 158 PURPLE_PRIORITY_DEFAULT,
159 MAILCHK_PLUGIN_ID, 159 MAILCHK_PLUGIN_ID,
160 N_("Mail Checker"), 160 N_("Mail Checker"),
161 VERSION, 161 VERSION,
162 N_("Checks for new local mail."), 162 N_("Checks for new local mail."),
163 N_("Adds a small box to the buddy list that" 163 N_("Adds a small box to the buddy list that"
164 " shows if you have new mail."), 164 " shows if you have new mail."),
165 "Eric Warmenhoven <eric@warmenhoven.org>", 165 "Eric Warmenhoven <eric@warmenhoven.org>",
166 GAIM_WEBSITE, 166 PURPLE_WEBSITE,
167 plugin_load, 167 plugin_load,
168 plugin_unload, 168 plugin_unload,
169 NULL, 169 NULL,
170 NULL, 170 NULL,
171 NULL, 171 NULL,
172 NULL, 172 NULL,
173 NULL 173 NULL
174 }; 174 };
175 175
176 static void 176 static void
177 init_plugin(GaimPlugin *plugin) 177 init_plugin(PurplePlugin *plugin)
178 { 178 {
179 } 179 }
180 180
181 GAIM_INIT_PLUGIN(mailchk, init_plugin, info) 181 PURPLE_INIT_PLUGIN(mailchk, init_plugin, info)