annotate src/protocols/oscar/email.c @ 4951:207f1e546849

[gaim-migrate @ 5285] Hooray! The Ximian icons are here! Thanks to tigert, jimmac, and nat for these! committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 01 Apr 2003 19:38:22 +0000
parents 26837f462a66
children 4375bf2d9020
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /*
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * Family 0x0018 - Email notification
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 *
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 * Used for being alerted when the email address(es) associated with
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * your screen name get new electronic-m. For normal AIM accounts, you
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 * get the email address screenname@netscape.net. AOL accounts have
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 * screenname@aol.com, and can also activate a netscape.net account.
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 *
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 #define FAIM_INTERNAL
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 #include <aim.h>
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
14 /**
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 * Subtype 0x0006 - Request information about your email account
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
16 *
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
17 * @param sess The oscar session.
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
18 * @param conn The email connection for this session.
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
19 * @return Return 0 if no errors, otherwise return the error number.
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 faim_export int aim_email_sendcookies(aim_session_t *sess, aim_conn_t *conn)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 aim_frame_t *fr;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 aim_snacid_t snacid;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 if (!sess || !conn)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 return -EINVAL;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+16+16)))
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 return -ENOMEM;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 snacid = aim_cachesnac(sess, 0x0018, 0x0006, 0x0000, NULL, 0);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 aim_putsnac(&fr->data, 0x0018, 0x0006, 0x0000, snacid);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 /* Number of cookies to follow */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 aimbs_put16(&fr->data, 0x0002);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 /* Cookie */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 aimbs_put16(&fr->data, 0x5d5e);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 aimbs_put16(&fr->data, 0x1708);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 aimbs_put16(&fr->data, 0x55aa);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41 aimbs_put16(&fr->data, 0x11d3);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42 aimbs_put16(&fr->data, 0xb143);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 aimbs_put16(&fr->data, 0x0060);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 aimbs_put16(&fr->data, 0xb0fb);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 aimbs_put16(&fr->data, 0x1ecb);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 /* Cookie */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48 aimbs_put16(&fr->data, 0xb380);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49 aimbs_put16(&fr->data, 0x9ad8);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50 aimbs_put16(&fr->data, 0x0dba);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51 aimbs_put16(&fr->data, 0x11d5);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 aimbs_put16(&fr->data, 0x9f8a);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 aimbs_put16(&fr->data, 0x0060);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 aimbs_put16(&fr->data, 0xb0ee);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55 aimbs_put16(&fr->data, 0x0631);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 aim_tx_enqueue(sess, fr);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 return 0;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 }
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
63 /**
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 * Subtype 0x0007 - Receive information about your email account
4804
9810ce8e7a96 [gaim-migrate @ 5124]
Mark Doliner <mark@kingant.net>
parents: 3952
diff changeset
65 *
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
66 * So I don't even know if you can have multiple 16 byte keys,
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 * but this is coded so it will handle that, and handle it well.
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
68 * This tells you if you have unread mail or not, the URL you
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
69 * should use to access that mail, and the domain name for the
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
70 * email account (screenname@domainname.com). If this is the
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
71 * first 0x0007 SNAC you've received since you signed on, or if
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
72 * this is just a periodic status update, this will also contain
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
73 * the number of unread emails that you have.
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 static int parseinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 {
4871
0b64f386a7b8 [gaim-migrate @ 5201]
Mark Doliner <mark@kingant.net>
parents: 4804
diff changeset
77 int ret = 0;
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 aim_rxcallback_t userfunc;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 struct aim_emailinfo *new;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
80 aim_tlvlist_t *tlvlist;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 fu8_t *cookie8, *cookie16;
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
82 int tmp, havenewmail = 0; /* Used to tell the client we have _new_ mail */
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
84 cookie8 = aimbs_getraw(bs, 8); /* Possibly the code used to log you in to mail? */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
85 cookie16 = aimbs_getraw(bs, 16); /* Mail cookie sent above */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
87 /* See if we already have some info associated with this cookie */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
88 for (new=sess->emailinfo; (new && strncmp(cookie16, new->cookie16, 16)); new=new->next);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
89 if (new) {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
90 /* Free some of the old info, if existant */
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
91 free(new->cookie8);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
92 free(new->cookie16);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
93 free(new->url);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
94 free(new->domain);
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
95 } else {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
96 /* We don't already have info, so create a new struct for it */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97 if (!(new = malloc(sizeof(struct aim_emailinfo))))
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
98 return -ENOMEM;
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
99 memset(new, 0, sizeof(struct aim_emailinfo));
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
100 new->next = sess->emailinfo;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
101 sess->emailinfo = new;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
102 }
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
103
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
104 new->cookie8 = cookie8;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
105 new->cookie16 = cookie16;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
107 tlvlist = aim_readtlvchain_num(bs, aimbs_get16(bs));
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
108
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
109 tmp = aim_gettlv16(tlvlist, 0x0080, 1);
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
110 if (tmp) {
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
111 if (new->nummsgs < tmp)
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
112 havenewmail = 1;
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
113 new->nummsgs = tmp;
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
114 } else {
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
115 /* If they don't send a 0x0080 TLV, it means we definately have new mail */
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
116 /* (ie. this is not just another status update) */
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
117 havenewmail = 1;
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
118 new->nummsgs++; /* We know we have at least 1 new email */
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
119 }
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
120 new->url = aim_gettlv_str(tlvlist, 0x0007, 1);
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
121 if (!(new->unread = aim_gettlv8(tlvlist, 0x0081, 1))) {
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
122 havenewmail = 0;
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
123 new->nummsgs = 0;
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
124 }
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
125 new->domain = aim_gettlv_str(tlvlist, 0x0082, 1);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
126 new->flag = aim_gettlv16(tlvlist, 0x0084, 1);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
127
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
128 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
4871
0b64f386a7b8 [gaim-migrate @ 5201]
Mark Doliner <mark@kingant.net>
parents: 4804
diff changeset
129 ret = userfunc(sess, rx, new, havenewmail);
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
130
4875
26837f462a66 [gaim-migrate @ 5205]
Mark Doliner <mark@kingant.net>
parents: 4871
diff changeset
131 aim_freetlvchain(&tlvlist);
26837f462a66 [gaim-migrate @ 5205]
Mark Doliner <mark@kingant.net>
parents: 4871
diff changeset
132
4871
0b64f386a7b8 [gaim-migrate @ 5201]
Mark Doliner <mark@kingant.net>
parents: 4804
diff changeset
133 return ret;
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134 }
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
135
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
136 /**
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
137 * Subtype 0x0016 - Send something or other
3725
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
138 *
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
139 * @param sess The oscar session.
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
140 * @param conn The email connection for this session.
dd48b1ac5bd8 [gaim-migrate @ 3861]
Mark Doliner <mark@kingant.net>
parents: 3694
diff changeset
141 * @return Return 0 if no errors, otherwise return the error number.
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
142 */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
143 faim_export int aim_email_activate(aim_session_t *sess, aim_conn_t *conn)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144 {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
145 aim_frame_t *fr;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
146 aim_snacid_t snacid;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
147
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
148 if (!sess || !conn)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
149 return -EINVAL;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
150
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
151 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+16)))
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
152 return -ENOMEM;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
153 snacid = aim_cachesnac(sess, 0x0018, 0x0016, 0x0000, NULL, 0);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
154 aim_putsnac(&fr->data, 0x0018, 0x0016, 0x0000, snacid);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
155
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
156 /* I would guess this tells AIM that you want updates for your mail accounts */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
157 /* ...but I really have no idea */
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
158 aimbs_put8(&fr->data, 0x02);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
159 aimbs_put32(&fr->data, 0x04000000);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160 aimbs_put32(&fr->data, 0x04000000);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
161 aimbs_put32(&fr->data, 0x04000000);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
162 aimbs_put32(&fr->data, 0x00000000);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
163
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 aim_tx_enqueue(sess, fr);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166 return 0;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
167 }
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170 {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172 if (snac->subtype == 0x0007)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 return parseinfo(sess, mod, rx, snac, bs);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
174
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175 return 0;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
176 }
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
178 static void email_shutdown(aim_session_t *sess, aim_module_t *mod)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
179 {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
180 while (sess->emailinfo) {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
181 struct aim_emailinfo *tmp = sess->emailinfo;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
182 sess->emailinfo = sess->emailinfo->next;
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
183 free(tmp->cookie16);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
184 free(tmp->cookie8);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
185 free(tmp->url);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3725
diff changeset
186 free(tmp->domain);
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
187 free(tmp);
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
188 }
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
189
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
190 return;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
191 }
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
192
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
193 faim_internal int email_modfirst(aim_session_t *sess, aim_module_t *mod)
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
194 {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
195
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
196 mod->family = 0x0018;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
197 mod->version = 0x0001;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
198 mod->toolid = 0x0010;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
199 mod->toolversion = 0x0629;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
200 mod->flags = 0;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
201 strncpy(mod->name, "email", sizeof(mod->name));
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
202 mod->snachandler = snachandler;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
203 mod->shutdown = email_shutdown;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
204
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
205 return 0;
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
206 }