annotate plugins/chkmail.c @ 10345:2e01c503aa4f

[gaim-migrate @ 11556] Patch 1078151 from Felipe Contreras to fix some more MSN bugs: "User Dislpay messages, and other less used, did not set an slpcall, so the callback that should not be called, was called (in some very special cases)." ... "Here it goes the real real one, as far as I can tell. Cleaning + organizing + documentation + hard bug fix = big patch." -- Felipe Contreras I also fixed drag-and-drop to conversation window file transfers (which I had broken when I fixed some other dnd thing), made the debug output of the autoreconnect plugin more useful, and stopped the message notification plugin notifying you for messages sent by ignored users. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 11 Dec 2004 20:01:58 +0000
parents 61852117568f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
1 /* This is some funky code. It is still being developed by Rob Flynn - rob@linuxpimps.com
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
2 * I recommend not using this code right now. :)
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
3 */
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
4
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 #define GAIM_PLUGINS
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 #include <stdio.h>
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
8 #include <stdlib.h>
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
9 #include <unistd.h>
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
10 #include <string.h>
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
11 #include <netinet/in.h>
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
12 #include <arpa/inet.h>
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
13 #include <sys/socket.h>
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
14 #include <netdb.h>
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
15 #include <netinet/in.h>
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
16 #include <pthread.h>
9821
a09ffb82aef1 [gaim-migrate @ 10692]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
17
a09ffb82aef1 [gaim-migrate @ 10692]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
18 #include "internal.h"
a09ffb82aef1 [gaim-migrate @ 10692]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
19 #include "gtkgaim.h"
a09ffb82aef1 [gaim-migrate @ 10692]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
20
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
21 char username[] = "";
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
22 char password[] = "";
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
23 char mailhost[] = "";
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
24 int mailport = 110;
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
25 int state = 0;
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
26
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 static void *handle = NULL;
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
28 extern GtkWidget *buddies;
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
29
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
30 int lastnum = 0;
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
31 int orig = 0;
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
32 int mytimer;
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
33
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
34 void update_mail();
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
35 void check_mail();
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
36
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
37 int num_msgs()
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
38 {
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
39 struct in_addr *sin;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
40 char recv[1024];
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
41 char command[256];
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
42 int fd;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
43 int num = 0;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
44 int step = 0;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
45 int len;
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
46
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
47 sin = (struct in_addr *)get_address(mailhost);
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
48 fd = connect_address(sin->s_addr, mailport);
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
49 while ((len = read(fd, recv, 1023))>0) {
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
50 recv[len] = 0;
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
51 if (!strncmp(recv, "-ERR", strlen("-ERR"))) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
52 step = 4;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
53 break;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
54 } else if (!strncmp(recv, "+OK", strlen("+OK"))) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
55 if (step == 3) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
56 if (sscanf(recv, "+OK %d %d\n", &num, &step) != 2)
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
57 break;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
58 g_snprintf(command, sizeof(command), "QUIT\n");
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
59 write(fd, command, strlen(command));
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
60 close(fd);
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
61 return num;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
62 }
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
63
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
64 if (step == 0) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
65 g_snprintf(command, sizeof(command), "USER %s\n", username);
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
66 write(fd, command, strlen(command));
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
67 step = 1;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
68 } else if (step == 1) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
69 g_snprintf(command, sizeof(command), "PASS %s\n", password);
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
70 write(fd, command, strlen(command));
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
71 step = 2;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
72 } else if (step == 2) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
73 g_snprintf(command, sizeof(command), "STAT\n");
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
74 write(fd, command, strlen(command));
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
75 step = 3;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
76 }
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
77 }
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
78 }
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
79 close(fd);
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
80
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
81 return 0;
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
82 }
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
84 void destroy_mail_list()
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
85 {
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
86 GList *list;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
87 GtkWidget *w;
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
88
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
89 list = GTK_TREE(buddies)->children;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
90 while (list) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
91 w = (GtkWidget *)list->data;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
92 if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, _("Mail Server"))) {
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
93 gtk_tree_remove_items(GTK_TREE(buddies), list);
126
b4cd83f1d0b8 [gaim-migrate @ 136]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 124
diff changeset
94 list = GTK_TREE(buddies)->children;
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
95 if (!list)
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
96 break;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
97 }
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
98 list = list->next;
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
99 }
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
100 }
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
101
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
102 void setup_mail_list()
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
103 {
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
104 GList *list;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
105 GtkWidget *w;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
106 GtkWidget *item;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
107 GtkWidget *tree;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
108 gchar *buf;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
109
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
110 list = GTK_TREE(buddies)->children;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
111
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
112 while (list) {
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
113 w = (GtkWidget *)list->data;
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4168
diff changeset
114 if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, _("Mail Server"))) {
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
115 gtk_tree_remove_items(GTK_TREE(buddies), list);
126
b4cd83f1d0b8 [gaim-migrate @ 136]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 124
diff changeset
116 list = GTK_TREE(buddies)->children;
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
117 if (!list)
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
118 break;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
119 }
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
120 list = list->next;
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
121 }
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
122
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4168
diff changeset
123 item = gtk_tree_item_new_with_label(_("Mail Server"));
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
124 tree = gtk_tree_new();
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
125 gtk_widget_show(item);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
126 gtk_widget_show(tree);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
127 gtk_tree_append(GTK_TREE(buddies), item);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
128 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
129 gtk_tree_item_expand(GTK_TREE_ITEM(item));
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
130
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 9821
diff changeset
131 /* XXX - This needs to use ngettext() */
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 9821
diff changeset
132 buf = g_strdup_printf(_("%s (%d new/%d total)"), mailhost, lastnum - orig, lastnum);
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
133 item = gtk_tree_item_new_with_label(buf);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
134 g_free(buf);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
135
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
136 gtk_tree_append(GTK_TREE(tree), item);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
137 gtk_widget_show(item);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
138 }
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 9821
diff changeset
139
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140 void gaim_plugin_init(void *h) {
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
141 handle = h;
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
143 orig = num_msgs();
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
144 lastnum = orig;
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
145
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
146 gaim_signal_connect(handle, event_blist_update, setup_mail_list, NULL);
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
147 setup_mail_list();
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 9821
diff changeset
148
4168
ebfb80bbe1ed [gaim-migrate @ 4397]
Luke Schierer <lschiere@pidgin.im>
parents: 127
diff changeset
149 mytimer = g_timeout_add(30000, check_mail, NULL);
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
150 }
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
151
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
152 void check_mail() {
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
153 pthread_t mail_thread;
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
154 pthread_attr_t attr;
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
155
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
156 if (state == 0) {
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
157 state = 1;
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
158 pthread_attr_init(&attr);
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
159 pthread_create(&mail_thread, &attr, (void *)&update_mail, NULL);
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
160 }
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
161 }
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
162
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
163 void update_mail () {
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
164 int newnum;
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
165
4168
ebfb80bbe1ed [gaim-migrate @ 4397]
Luke Schierer <lschiere@pidgin.im>
parents: 127
diff changeset
166 g_source_remove(mytimer);
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
167
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
168 newnum = num_msgs();
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
169
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 5116
diff changeset
170 if ((newnum >= lastnum) && (newnum > 0)) {
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
171 newnum = newnum - lastnum;
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
172 } else {
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
173 newnum = 0;
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
174 }
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
175
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
176 if (newnum < lastnum) {
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
177 orig = lastnum;
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
178 }
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
179
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
180 lastnum = newnum;
4168
ebfb80bbe1ed [gaim-migrate @ 4397]
Luke Schierer <lschiere@pidgin.im>
parents: 127
diff changeset
181 mytimer = g_timeout_add(30000, check_mail, NULL);
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
182 setup_mail_list();
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
183 state = 0;
114
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
184 }
668727c82810 [gaim-migrate @ 124]
Rob Flynn <gaim@robflynn.com>
parents: 105
diff changeset
185
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
186 void gaim_plugin_remove() {
4168
ebfb80bbe1ed [gaim-migrate @ 4397]
Luke Schierer <lschiere@pidgin.im>
parents: 127
diff changeset
187 g_source_remove(mytimer);
127
1330d0c8b1ff [gaim-migrate @ 137]
Rob Flynn <gaim@robflynn.com>
parents: 126
diff changeset
188 while (state == 1) { }
124
5f294f7c4f2e [gaim-migrate @ 134]
Rob Flynn <gaim@robflynn.com>
parents: 114
diff changeset
189 destroy_mail_list();
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190 handle = NULL;
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
191 }
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
193 char *name() {
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4168
diff changeset
194 return _("Check Mail");
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195 }
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197 char *description() {
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4168
diff changeset
198 return _("Check email every X seconds.\n");
105
c76d4c0c5e3a [gaim-migrate @ 115]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199 }