Mercurial > pidgin.yaz
annotate src/protocols/oscar/email.c @ 11896:8aa6462e563c
[gaim-migrate @ 14187]
Change "Keep the dialog open" to "Close this window when all transfers finish". I think that's a lot clearer. I didn't change the underlying preference, just inverted the value when setting up the checkbox. That seemed like a lot of work for very little gain.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 29 Oct 2005 21:11:07 +0000 |
parents | acbd980d6179 |
children |
rev | line source |
---|---|
3694 | 1 /* |
2 * Family 0x0018 - Email notification | |
3 * | |
4 * Used for being alerted when the email address(es) associated with | |
5 * your screen name get new electronic-m. For normal AIM accounts, you | |
6 * get the email address screenname@netscape.net. AOL accounts have | |
7 * screenname@aol.com, and can also activate a netscape.net account. | |
8 * | |
9 */ | |
10 | |
11 #define FAIM_INTERNAL | |
12 #include <aim.h> | |
13 | |
3725 | 14 /** |
3694 | 15 * Subtype 0x0006 - Request information about your email account |
3725 | 16 * |
17 * @param sess The oscar session. | |
18 * @param conn The email connection for this session. | |
19 * @return Return 0 if no errors, otherwise return the error number. | |
3694 | 20 */ |
7282 | 21 faim_export int aim_email_sendcookies(aim_session_t *sess) |
3694 | 22 { |
7282 | 23 aim_conn_t *conn; |
3694 | 24 aim_frame_t *fr; |
25 aim_snacid_t snacid; | |
26 | |
7282 | 27 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_EML))) |
3694 | 28 return -EINVAL; |
29 | |
30 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+16+16))) | |
31 return -ENOMEM; | |
32 snacid = aim_cachesnac(sess, 0x0018, 0x0006, 0x0000, NULL, 0); | |
33 aim_putsnac(&fr->data, 0x0018, 0x0006, 0x0000, snacid); | |
34 | |
35 /* Number of cookies to follow */ | |
36 aimbs_put16(&fr->data, 0x0002); | |
37 | |
38 /* Cookie */ | |
39 aimbs_put16(&fr->data, 0x5d5e); | |
40 aimbs_put16(&fr->data, 0x1708); | |
41 aimbs_put16(&fr->data, 0x55aa); | |
42 aimbs_put16(&fr->data, 0x11d3); | |
43 aimbs_put16(&fr->data, 0xb143); | |
44 aimbs_put16(&fr->data, 0x0060); | |
45 aimbs_put16(&fr->data, 0xb0fb); | |
46 aimbs_put16(&fr->data, 0x1ecb); | |
47 | |
48 /* Cookie */ | |
49 aimbs_put16(&fr->data, 0xb380); | |
50 aimbs_put16(&fr->data, 0x9ad8); | |
51 aimbs_put16(&fr->data, 0x0dba); | |
52 aimbs_put16(&fr->data, 0x11d5); | |
53 aimbs_put16(&fr->data, 0x9f8a); | |
54 aimbs_put16(&fr->data, 0x0060); | |
55 aimbs_put16(&fr->data, 0xb0ee); | |
56 aimbs_put16(&fr->data, 0x0631); | |
57 | |
58 aim_tx_enqueue(sess, fr); | |
59 | |
60 return 0; | |
61 } | |
62 | |
63 | |
3725 | 64 /** |
3694 | 65 * Subtype 0x0007 - Receive information about your email account |
4804 | 66 * |
3725 | 67 * So I don't even know if you can have multiple 16 byte keys, |
3694 | 68 * but this is coded so it will handle that, and handle it well. |
3725 | 69 * This tells you if you have unread mail or not, the URL you |
70 * should use to access that mail, and the domain name for the | |
71 * email account (screenname@domainname.com). If this is the | |
72 * first 0x0007 SNAC you've received since you signed on, or if | |
73 * this is just a periodic status update, this will also contain | |
74 * the number of unread emails that you have. | |
3694 | 75 */ |
76 static int parseinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
77 { | |
4871 | 78 int ret = 0; |
3694 | 79 aim_rxcallback_t userfunc; |
80 struct aim_emailinfo *new; | |
81 aim_tlvlist_t *tlvlist; | |
82 fu8_t *cookie8, *cookie16; | |
3725 | 83 int tmp, havenewmail = 0; /* Used to tell the client we have _new_ mail */ |
3694 | 84 |
7297 | 85 char *alertitle = NULL, *alerturl = NULL; |
86 | |
3694 | 87 cookie8 = aimbs_getraw(bs, 8); /* Possibly the code used to log you in to mail? */ |
88 cookie16 = aimbs_getraw(bs, 16); /* Mail cookie sent above */ | |
89 | |
90 /* See if we already have some info associated with this cookie */ | |
10996 | 91 for (new = sess->emailinfo; (new && memcmp(cookie16, new->cookie16, 16)); new = new->next); |
3694 | 92 if (new) { |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
7313
diff
changeset
|
93 /* Free some of the old info, if it exists */ |
3952 | 94 free(new->cookie8); |
95 free(new->cookie16); | |
96 free(new->url); | |
97 free(new->domain); | |
3694 | 98 } else { |
99 /* We don't already have info, so create a new struct for it */ | |
100 if (!(new = malloc(sizeof(struct aim_emailinfo)))) | |
101 return -ENOMEM; | |
3725 | 102 memset(new, 0, sizeof(struct aim_emailinfo)); |
7045 | 103 new->next = sess->emailinfo; |
104 sess->emailinfo = new; | |
3694 | 105 } |
106 | |
107 new->cookie8 = cookie8; | |
108 new->cookie16 = cookie16; | |
109 | |
7167 | 110 tlvlist = aim_tlvlist_readnum(bs, aimbs_get16(bs)); |
3694 | 111 |
7167 | 112 tmp = aim_tlv_get16(tlvlist, 0x0080, 1); |
3725 | 113 if (tmp) { |
114 if (new->nummsgs < tmp) | |
115 havenewmail = 1; | |
116 new->nummsgs = tmp; | |
117 } else { | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
7313
diff
changeset
|
118 /* If they don't send a 0x0080 TLV, it means we definitely have new mail */ |
3725 | 119 /* (ie. this is not just another status update) */ |
120 havenewmail = 1; | |
121 new->nummsgs++; /* We know we have at least 1 new email */ | |
122 } | |
7167 | 123 new->url = aim_tlv_getstr(tlvlist, 0x0007, 1); |
124 if (!(new->unread = aim_tlv_get8(tlvlist, 0x0081, 1))) { | |
3725 | 125 havenewmail = 0; |
126 new->nummsgs = 0; | |
127 } | |
7167 | 128 new->domain = aim_tlv_getstr(tlvlist, 0x0082, 1); |
129 new->flag = aim_tlv_get16(tlvlist, 0x0084, 1); | |
3694 | 130 |
7297 | 131 alertitle = aim_tlv_getstr(tlvlist, 0x0005, 1); |
132 alerturl = aim_tlv_getstr(tlvlist, 0x000d, 1); | |
133 | |
3694 | 134 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
7313 | 135 ret = userfunc(sess, rx, new, havenewmail, alertitle, (alerturl ? alerturl + 2 : NULL)); |
3694 | 136 |
7167 | 137 aim_tlvlist_free(&tlvlist); |
4875 | 138 |
7313 | 139 free(alertitle); |
140 free(alerturl); | |
141 | |
4871 | 142 return ret; |
3694 | 143 } |
144 | |
3725 | 145 /** |
3694 | 146 * Subtype 0x0016 - Send something or other |
3725 | 147 * |
148 * @param sess The oscar session. | |
149 * @param conn The email connection for this session. | |
150 * @return Return 0 if no errors, otherwise return the error number. | |
3694 | 151 */ |
7282 | 152 faim_export int aim_email_activate(aim_session_t *sess) |
3694 | 153 { |
7282 | 154 aim_conn_t *conn; |
3694 | 155 aim_frame_t *fr; |
156 aim_snacid_t snacid; | |
157 | |
7282 | 158 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_EML))) |
3694 | 159 return -EINVAL; |
160 | |
161 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+16))) | |
162 return -ENOMEM; | |
163 snacid = aim_cachesnac(sess, 0x0018, 0x0016, 0x0000, NULL, 0); | |
164 aim_putsnac(&fr->data, 0x0018, 0x0016, 0x0000, snacid); | |
165 | |
166 /* I would guess this tells AIM that you want updates for your mail accounts */ | |
167 /* ...but I really have no idea */ | |
168 aimbs_put8(&fr->data, 0x02); | |
169 aimbs_put32(&fr->data, 0x04000000); | |
170 aimbs_put32(&fr->data, 0x04000000); | |
171 aimbs_put32(&fr->data, 0x04000000); | |
172 aimbs_put32(&fr->data, 0x00000000); | |
173 | |
174 aim_tx_enqueue(sess, fr); | |
175 | |
176 return 0; | |
177 } | |
178 | |
179 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
180 { | |
181 | |
182 if (snac->subtype == 0x0007) | |
183 return parseinfo(sess, mod, rx, snac, bs); | |
184 | |
185 return 0; | |
186 } | |
187 | |
188 static void email_shutdown(aim_session_t *sess, aim_module_t *mod) | |
189 { | |
7045 | 190 while (sess->emailinfo) { |
191 struct aim_emailinfo *tmp = sess->emailinfo; | |
192 sess->emailinfo = sess->emailinfo->next; | |
3952 | 193 free(tmp->cookie16); |
194 free(tmp->cookie8); | |
195 free(tmp->url); | |
196 free(tmp->domain); | |
3694 | 197 free(tmp); |
198 } | |
199 | |
200 return; | |
201 } | |
202 | |
203 faim_internal int email_modfirst(aim_session_t *sess, aim_module_t *mod) | |
204 { | |
205 | |
206 mod->family = 0x0018; | |
207 mod->version = 0x0001; | |
208 mod->toolid = 0x0010; | |
209 mod->toolversion = 0x0629; | |
210 mod->flags = 0; | |
211 strncpy(mod->name, "email", sizeof(mod->name)); | |
212 mod->snachandler = snachandler; | |
213 mod->shutdown = email_shutdown; | |
214 | |
215 return 0; | |
216 } |